WME TRAVEL MENU lksxfjglk;jfsdgk;ljfsg;ljkhdfg;kljhdfsgjk;l

So far, only for barrens
This commit is contained in:
Issac332 2026-05-24 19:00:36 +03:00
parent e5e2076e41
commit da0fe12086
15 changed files with 404 additions and 47 deletions

View File

@ -64,6 +64,9 @@ module RPG
def self.windowskin(filename) def self.windowskin(filename)
self.load_bitmap("Graphics/Windowskins/", filename) self.load_bitmap("Graphics/Windowskins/", filename)
end end
#def self.minimap(zone, location)
# self.load_bitmap("Graphics/Menus/minimap/", zone + "_" + location)
#end
def self.tile(filename, tile_id, hue) def self.tile(filename, tile_id, hue)
key = [filename, tile_id, hue] key = [filename, tile_id, hue]
if not @cache.include?(key) or @cache[key].disposed? if not @cache.include?(key) or @cache[key].disposed?

View File

@ -41,6 +41,7 @@ RB_METHOD(spriteInitialize){
wrapProperty(self, &s->getSrcRect(), "src_rect", RectType); wrapProperty(self, &s->getSrcRect(), "src_rect", RectType);
wrapProperty(self, &s->getColor(), "color", ColorType); wrapProperty(self, &s->getColor(), "color", ColorType);
wrapProperty(self, &s->getTone(), "tone", ToneType); wrapProperty(self, &s->getTone(), "tone", ToneType);
wrapProperty(self, &s->getModulate(), "modulate", ColorType);
return self; return self;
} }
@ -49,6 +50,7 @@ DEF_PROP_OBJ_REF(Sprite, Bitmap, Bitmap, "bitmap")
DEF_PROP_OBJ_VAL(Sprite, Rect, SrcRect, "src_rect") DEF_PROP_OBJ_VAL(Sprite, Rect, SrcRect, "src_rect")
DEF_PROP_OBJ_VAL(Sprite, Color, Color, "color") DEF_PROP_OBJ_VAL(Sprite, Color, Color, "color")
DEF_PROP_OBJ_VAL(Sprite, Tone, Tone, "tone") DEF_PROP_OBJ_VAL(Sprite, Tone, Tone, "tone")
DEF_PROP_OBJ_VAL(Sprite, Color, Modulate,"modulate")
DEF_PROP_I(Sprite, X) DEF_PROP_I(Sprite, X)
DEF_PROP_I(Sprite, Y) DEF_PROP_I(Sprite, Y)
@ -118,6 +120,7 @@ void spriteBindingInit(){
INIT_PROP_BIND( Sprite, BlendType, "blend_type" ); INIT_PROP_BIND( Sprite, BlendType, "blend_type" );
INIT_PROP_BIND( Sprite, Color, "color" ); INIT_PROP_BIND( Sprite, Color, "color" );
INIT_PROP_BIND( Sprite, Tone, "tone" ); INIT_PROP_BIND( Sprite, Tone, "tone" );
INIT_PROP_BIND( Sprite, Modulate, "modulate" );
INIT_PROP_BIND( Sprite, Obscured, "obscured" ); INIT_PROP_BIND( Sprite, Obscured, "obscured" );
_rb_define_method(klass, "width", spriteWidth); _rb_define_method(klass, "width", spriteWidth);

View File

@ -2,9 +2,32 @@ class FastTravel
class Zone class Zone
attr_reader :name attr_reader :name
attr_reader :maps attr_reader :maps
def initialize(name, maps) attr_reader :locations
def initialize(name, maps, locations)
@name = name @name = name
@maps = maps @maps = maps
@locations = locations;
end
end
class ZoneLocations
attr_reader :x
attr_reader :y
attr_reader :niko_x
attr_reader :niko_y
attr_reader :next_top
attr_reader :next_right
attr_reader :next_bottom
attr_reader :next_left
def initialize(x, y, niko_x, niko_y, next_top, next_right, next_bottom, next_left)
@x = x
@y = y
@niko_x = niko_x
@niko_y = niko_y
@next_top = next_top
@next_right = next_right
@next_bottom = next_bottom
@next_left = next_left
end end
end end
@ -15,7 +38,7 @@ class FastTravel
:backalley => tr("back alley"), :backalley => tr("back alley"),
:library => tr("library"), :library => tr("library"),
:factory => tr("factory"), :factory => tr("factory"),
}), }, nil),
:red => Zone.new(tr("The Refuge"), { :red => Zone.new(tr("The Refuge"), {
:garden => tr("garden"), :garden => tr("garden"),
:gate => tr("city gate"), :gate => tr("city gate"),
@ -24,7 +47,7 @@ class FastTravel
:cafe => tr("cafe"), :cafe => tr("cafe"),
:office => tr("office"), :office => tr("office"),
:obsdeck => tr("observation deck"), :obsdeck => tr("observation deck"),
}), }, nil),
:green => Zone.new(tr("The Glen"), { :green => Zone.new(tr("The Glen"), {
:village => tr("village"), :village => tr("village"),
:ruins => tr("ruins"), :ruins => tr("ruins"),
@ -34,7 +57,7 @@ class FastTravel
:courtyard => tr("courtyard"), :courtyard => tr("courtyard"),
:research => tr("research station"), :research => tr("research station"),
:grave => tr("graveyard") :grave => tr("graveyard")
}), }, nil),
:blue => Zone.new(tr("The Barrens"), { :blue => Zone.new(tr("The Barrens"), {
:entrance => tr("entrance"), :entrance => tr("entrance"),
:outpost => tr("outpost"), :outpost => tr("outpost"),
@ -45,6 +68,17 @@ class FastTravel
:swamp => tr("shrimp swamp"), :swamp => tr("shrimp swamp"),
:docks => tr("docks"), :docks => tr("docks"),
:quarry => tr("lookout point"), :quarry => tr("lookout point"),
},
{
:entrance => ZoneLocations.new(-81, 22, -4, 3, :docks, :outpost, nil, nil),
:outpost => ZoneLocations.new(-52, 42, 6, -3, nil, :cliffs, nil, :entrance),
:cliffs => ZoneLocations.new(4, -3, 21, 38, :factory, :quarry, nil, :outpost),
:mineshaft => ZoneLocations.new(88, -3, 5, 0, nil, nil, nil, :quarry),
:factory => ZoneLocations.new(15, -42, 13, 2, nil, nil, :cliffs, :dorms),
:dorms => ZoneLocations.new(-46, -49, 20, 4, nil, :factory, nil, :swamp),
:swamp => ZoneLocations.new(-98, -44, 10, 7, nil, :dorms, :docks, nil),
:docks => ZoneLocations.new(-82, -9, -4, -2, :swamp, nil, :entrance, nil),
:quarry => ZoneLocations.new(52, -4, 17, -3, nil, :mineshaft, nil, :cliffs),
}), }),
} }
end end

View File

@ -1,11 +1,17 @@
class FastTravel class FastTravel
MARGIN = 30 MARGIN = 30
TITLE_TOP_MARGIN = 32 TITLE_TOP_MARGIN = -16
TITLE_MARGIN = 100 TITLE_MARGIN = 100
ITEM_SPACING = 28 ITEM_SPACING = 28
ACTIVE_MARGIN = MARGIN * 2 + 20 ACTIVE_MARGIN = MARGIN * 2 + 20
attr_accessor :legacy_ui
def initialize def initialize
@legacy_ui = false
@scale_multiplier = Graphics.height > 600 ? 3.0 : 2.0
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@bg = Sprite.new(@viewport) @bg = Sprite.new(@viewport)
@bg.bitmap = Bitmap.new(Graphics.width, Graphics.height) @bg.bitmap = Bitmap.new(Graphics.width, Graphics.height)
@ -13,10 +19,70 @@ class FastTravel
@title = Sprite.new(@viewport) @title = Sprite.new(@viewport)
Language.register_text_sprite(self.class.name + "_title", @title) Language.register_text_sprite(self.class.name + "_title", @title)
@title.bitmap = Bitmap.new(Graphics.width / 2, TITLE_MARGIN) @title.bitmap = Bitmap.new(Graphics.width / 2, TITLE_MARGIN)
@title.bitmap.font.size = 40 @title.bitmap.font.size = 20
@title.y = TITLE_TOP_MARGIN @title.y = TITLE_TOP_MARGIN
@title.x = MARGIN @title.x = MARGIN
@title.zoom_x = @title.zoom_y = 2
# WME Location name
@location_name_text = Sprite.new(@viewport)
@location_name_text.bitmap = Bitmap.new(Graphics.width, 30)
@location_name_text.y = Graphics.height - 64
@location_name_text.bitmap.font.size = 20
@location_name_text.opacity = 0
# WME Niko Icon
@niko_icon = Sprite.new(@viewport)
@niko_icon.bitmap = RPG::Cache.load_bitmap("Graphics/Menus/Minimap/", "niko_icon")
@niko_icon.zoom_x = @niko_icon.zoom_y = @scale_multiplier
@niko_icon.z = 10
@niko_icon.opacity = 0
@niko_pos_x = 0.0
@niko_pos_y = 0.0
@niko_target_pos_x = 0.0
@niko_target_pos_y = 0.0
# WME Niko arrows
arrows_bitmap = RPG::Cache.load_bitmap("Graphics/Menus/Minimap/", "small_arrows")
@arrow_top = Sprite.new(@viewport)
@arrow_top.bitmap = Bitmap.new(16, 16)
@arrow_top.bitmap.stretch_blt(Rect.new(0, 0, 16, 16), arrows_bitmap, Rect.new(0, 0, 16, 16))
@arrow_bottom = Sprite.new(@viewport)
@arrow_bottom.bitmap = Bitmap.new(16, 16)
@arrow_bottom.bitmap.stretch_blt(Rect.new(0, 0, 16, 16), arrows_bitmap, Rect.new(16, 0, 16, 16))
@arrow_left = Sprite.new(@viewport)
@arrow_left.bitmap = Bitmap.new(16, 16)
@arrow_left.bitmap.stretch_blt(Rect.new(0, 0, 16, 16), arrows_bitmap, Rect.new(32, 0, 16, 16))
@arrow_right = Sprite.new(@viewport)
@arrow_right.bitmap = Bitmap.new(16, 16)
@arrow_right.bitmap.stretch_blt(Rect.new(0, 0, 16, 16), arrows_bitmap, Rect.new(48, 0, 16, 16))
@arrow_top.zoom_x = @arrow_top.zoom_y =
@arrow_bottom.zoom_x = @arrow_bottom.zoom_y =
@arrow_left.zoom_x = @arrow_left.zoom_y =
@arrow_right.zoom_x = @arrow_right.zoom_y = @scale_multiplier
@arrow_top.opacity = @arrow_bottom.opacity =
@arrow_left.opacity = @arrow_right.opacity = 0
@arrow_top.z = @arrow_bottom.z =
@arrow_left.z = @arrow_right.z = 11
@arrows_timer = 0
@arrows_offset = 0
# WME data
@data_locations = {}
@selected_location = nil
# legacy
@data_sprites = [] @data_sprites = []
#other
@viewport.z = 9998 @viewport.z = 9998
self.visible = false self.visible = false
@ -27,30 +93,89 @@ class FastTravel
@transfer_player = nil @transfer_player = nil
end end
#WME
def update_location_name_text
if ZONES[$game_fasttravel.zone].locations == nil || @legacy_ui
return
end
@location_name_text.bitmap.clear
@location_name_text.bitmap.draw_text(0, 0, Graphics.width, 30, ZONES[$game_fasttravel.zone].maps[@selected_location], 1)
end
def set_color(location_name)
if @selected_location == location_name
@data_locations[location_name].modulate.set(255, 255, 255)
return
end
case $game_fasttravel.zone
when :blue
@data_locations[location_name].modulate.set(84, 76, 209)
when :green
@data_locations[location_name].modulate.set(63, 213, 100)
when :red, :red_ground
@data_locations[location_name].modulate.set(213, 33, 106)
end
end
def update_arrows_positions
@arrow_left.y = @arrow_right.y = @niko_icon.y
@arrow_top.x = @arrow_bottom.x = @niko_icon.x + 4 * @scale_multiplier
@arrow_top.y = @niko_icon.y - (12 + @arrows_offset) * @scale_multiplier
@arrow_bottom.y = @niko_icon.y + @niko_icon.bitmap.height + (6 + @arrows_offset) * @scale_multiplier
@arrow_left.x = @niko_icon.x - (8 + @arrows_offset) * @scale_multiplier
@arrow_right.x = @niko_icon.x + @niko_icon.bitmap.width + (7 + @arrows_offset) * @scale_multiplier
end
#Not WME
def dispose def dispose
@bg.dispose @bg.dispose
@title.dispose @title.dispose
@data_sprites.each do |spr| @data_sprites.each do |spr|
spr.dispose spr.dispose
end end
#WME
@data_locations.each do |name, spr|
spr.dispose
end
@location_name_text.dispose
@niko_icon.dispose
@arrow_top.dispose
@arrow_bottom.dispose
@arrow_left.dispose
@arrow_right.dispose
#Not WME
@viewport.dispose @viewport.dispose
end end
def open def open
self.visible = true self.visible = true
self.opacity = 0 self.opacity = 0
#WME
if !@legacy_ui
@niko_icon.opacity = @location_name_text.opacity =
@arrow_top.opacity = @arrow_bottom.opacity =
@arrow_left.opacity = @arrow_right.opacity = 0
end
#Not WME
@fade_in = true @fade_in = true
@data = $game_fasttravel.unlocked_maps.keys.sort @data = $game_fasttravel.unlocked_maps.keys.sort
zone = ZONES[$game_fasttravel.zone]
# Set cursor to current map # Set cursor to current map
@data.each_with_index do |map, i| @data.each_with_index do |map, i|
if $game_fasttravel.unlocked_maps[map].id == $game_map.map_id if $game_fasttravel.unlocked_maps[map].id == $game_map.map_id
@index = i @index = i
@selected_location = map
break break
end end
end end
zone = ZONES[$game_fasttravel.zone]
# Create title # Create title
@title.bitmap.clear @title.bitmap.clear
@ -58,25 +183,85 @@ class FastTravel
# Create menu options # Create menu options
@data.each_with_index do |item, i| @data.each_with_index do |item, i|
if zone.locations != nil && !@legacy_ui
#WME
spr = Sprite.new(@viewport)
spr.bitmap = RPG::Cache.load_bitmap("Graphics/Menus/Minimap/", "#{$game_fasttravel.zone}_#{item}")
spr.zoom_x = spr.zoom_y = @scale_multiplier
spr.x = Graphics.width / 2 + zone.locations[item].x * @scale_multiplier
spr.y = Graphics.height / 2 + zone.locations[item].y * @scale_multiplier
spr.opacity = 0
@data_locations[item] = spr
set_color(item)
else
#Legacy
spr = Sprite.new(@viewport) spr = Sprite.new(@viewport)
spr.bitmap = Bitmap.new(320, ITEM_SPACING) spr.bitmap = Bitmap.new(320, ITEM_SPACING)
spr.x = MARGIN spr.x = MARGIN
spr.y = TITLE_MARGIN + TITLE_TOP_MARGIN + ITEM_SPACING * i spr.y = TITLE_MARGIN + TITLE_TOP_MARGIN + ITEM_SPACING * i + 32
spr.opacity = 0 spr.opacity = 0
spr.bitmap.draw_text(0, 0, spr.bitmap.width, spr.bitmap.height, zone.maps[item]) spr.bitmap.draw_text(0, 0, spr.bitmap.width, spr.bitmap.height, zone.maps[item])
@data_sprites << spr @data_sprites << spr
end end
end end
if @legacy_ui
return
end
#WME
if @data_locations.has_key?(@selected_location)
@niko_pos_x = (zone.locations[@selected_location].x.to_f + zone.locations[@selected_location].niko_x.to_f)
@niko_pos_y = (zone.locations[@selected_location].y.to_f + zone.locations[@selected_location].niko_y.to_f)
@niko_icon.x = @niko_pos_x.to_i * @scale_multiplier + Graphics.width / 2
@niko_icon.y = @niko_pos_y.to_i * @scale_multiplier + Graphics.height / 2
end
update_location_name_text
update_arrows_positions
end
def update def update
zone = ZONES[$game_fasttravel.zone]
if zone.locations != nil && !@legacy_ui
@arrows_timer += 1
if @arrows_timer >= 30
@arrows_timer = 0
@arrows_offset = @arrows_offset == 1 ? 0 : 1
end
end
if @fade_in if @fade_in
self.opacity += 20 self.opacity += 20
if zone.locations != nil && !@legacy_ui
#WME
@niko_icon.opacity += 20
@location_name_text.opacity += 20
location = zone.locations[@selected_location]
@arrow_top.opacity += @data.include?(location.next_top) ? 20 : 0
@arrow_bottom.opacity += @data.include?(location.next_bottom) ? 20 : 0
@arrow_left.opacity += @data.include?(location.next_left) ? 20 : 0
@arrow_right.opacity += @data.include?(location.next_right) ? 20 : 0
end
active_spr = nil active_spr = nil
@data_sprites.each do |spr| @data_sprites.each do |spr|
spr.opacity += 10 spr.opacity += 10
spr.opacity = 128 if spr.opacity > 128 spr.opacity = 128 if spr.opacity > 128
active_spr = spr if !active_spr && spr.x < MARGIN * 2 active_spr = spr if !active_spr && spr.x < MARGIN * 2
end end
#WME
if !@legacy_ui
@data_locations.each do |name, spr|
spr.opacity += 20
spr.opacity = 255 if spr.opacity > 255
end
end
#Not WME
if active_spr if active_spr
active_spr.x += 6 active_spr.x += 6
active_spr.x = MARGIN * 2 if active_spr.x > MARGIN * 2 active_spr.x = MARGIN * 2 if active_spr.x > MARGIN * 2
@ -88,15 +273,47 @@ class FastTravel
if @fade_out if @fade_out
self.opacity -= 20 self.opacity -= 20
if zone.locations != nil && !@legacy_ui
#WME
@niko_icon.opacity -= 20
@location_name_text.opacity -= 20
location = zone.locations[@selected_location]
@arrow_top.opacity -= @data.include?(location.next_top) ? 20 : 0
@arrow_bottom.opacity -= @data.include?(location.next_bottom) ? 20 : 0
@arrow_left.opacity -= @data.include?(location.next_left) ? 20 : 0
@arrow_right.opacity -= @data.include?(location.next_right) ? 20 : 0
end
@data_sprites.each do |spr| @data_sprites.each do |spr|
spr.opacity -= 10 spr.opacity -= 10
end end
#WME
if !@legacy_ui
@data_locations.each do |name, spr|
spr.opacity -= 20
end
end
#Not WME
if self.opacity == 0 if self.opacity == 0
@fade_out = false @fade_out = false
self.visible = false self.visible = false
@data_sprites.each do |spr| @data_sprites.each do |spr|
spr.dispose spr.dispose
end end
#WME
if !@legacy_ui
@data_locations.each do |name, spr|
spr.dispose
end
@data_locations = {}
end
#Not WME
@data_sprites = [] @data_sprites = []
if @transfer_player if @transfer_player
@ -116,6 +333,35 @@ class FastTravel
return if !self.visible return if !self.visible
#WME noik
if zone.locations != nil && !@legacy_ui
@niko_target_pos_x = (zone.locations[@selected_location].x.to_f + zone.locations[@selected_location].niko_x.to_f)
@niko_target_pos_y = (zone.locations[@selected_location].y.to_f + zone.locations[@selected_location].niko_y.to_f)
if @data_locations.has_key?(@selected_location)
@niko_pos_x = (@niko_target_pos_x * 0.25 + @niko_pos_x * 0.75)
@niko_pos_y = (@niko_target_pos_y * 0.25 + @niko_pos_y * 0.75)
end
@niko_pos_x = (@niko_pos_x - @niko_target_pos_x).abs < 0.5 ? @niko_target_pos_x : @niko_pos_x
@niko_pos_y = (@niko_pos_y - @niko_target_pos_y).abs < 0.5 ? @niko_target_pos_y : @niko_pos_y
@niko_icon.x = @niko_pos_x.to_i * @scale_multiplier + Graphics.width / 2
@niko_icon.y = @niko_pos_y.to_i * @scale_multiplier + Graphics.height / 2
update_arrows_positions
location = zone.locations[@selected_location]
@arrow_top.opacity += @data.include?(location.next_top) ? 40 : -40
@arrow_bottom.opacity += @data.include?(location.next_bottom) ? 40 : -40
@arrow_left.opacity += @data.include?(location.next_left) ? 40 : -40
@arrow_right.opacity += @data.include?(location.next_right) ? 40 : -40
elsif !@legacy_ui
@niko_icon.opacity =
@arrow_top.opacity = @arrow_bottom.opacity =
@arrow_left.opacity = @arrow_right.opacity = 0
end
# Adjust position and visibility # Adjust position and visibility
@data_sprites.each_with_index do |spr, i| @data_sprites.each_with_index do |spr, i|
if i == @index if i == @index
@ -134,18 +380,67 @@ class FastTravel
end end
end end
if !@legacy_ui
#WME
@data_locations.each do |name, spr|
set_color(name)
end
end
if Input.trigger?(Input::UP) if Input.trigger?(Input::UP)
if zone.locations != nil && !@legacy_ui
next_location = zone.locations[@selected_location].next_top
if @data_locations.has_key?(next_location)
@selected_location = next_location
$game_system.se_play($data_system.cursor_se)
update_location_name_text
end
else
@index = (@index - 1) % @data.size @index = (@index - 1) % @data.size
$game_system.se_play($data_system.cursor_se) $game_system.se_play($data_system.cursor_se)
end end
end
if Input.trigger?(Input::DOWN) if Input.trigger?(Input::DOWN)
if zone.locations != nil && !@legacy_ui
next_location = zone.locations[@selected_location].next_bottom
if @data_locations.has_key?(next_location)
@selected_location = next_location
$game_system.se_play($data_system.cursor_se)
update_location_name_text
end
else
@index = (@index + 1) % @data.size @index = (@index + 1) % @data.size
$game_system.se_play($data_system.cursor_se) $game_system.se_play($data_system.cursor_se)
end end
end
if Input.trigger?(Input::LEFT)
if zone.locations != nil && !@legacy_ui
next_location = zone.locations[@selected_location].next_left
if @data_locations.has_key?(next_location)
@selected_location = next_location
$game_system.se_play($data_system.cursor_se)
update_location_name_text
end
end
end
if Input.trigger?(Input::RIGHT)
if zone.locations != nil && !@legacy_ui
next_location = zone.locations[@selected_location].next_right
if @data_locations.has_key?(next_location)
@selected_location = next_location
$game_system.se_play($data_system.cursor_se)
update_location_name_text
end
end
end
if Input.trigger?(Input::ACTION) if Input.trigger?(Input::ACTION)
$game_system.se_play($data_system.decision_se) $game_system.se_play($data_system.decision_se)
choice = $game_fasttravel.unlocked_maps[@selected_location]
if zone.locations == nil || @legacy_ui
choice = $game_fasttravel.unlocked_maps[@data[@index]] choice = $game_fasttravel.unlocked_maps[@data[@index]]
end
if choice.id != $game_map.map_id if choice.id != $game_map.map_id
@transfer_player = choice @transfer_player = choice
end end

View File

@ -5,7 +5,7 @@ class Window_MainMenu < Window_Selectable
# Set up menu options # Set up menu options
@commands = Array.new @commands = Array.new
@commands << 'Travel' @commands << 'Fast Travel'
@commands << 'Notes' @commands << 'Notes'
@commands << 'Settings' @commands << 'Settings'
@ -53,6 +53,9 @@ class Window_MainMenu < Window_Selectable
# Update item # Update item
rect = Rect.new(w * index, 0, w - 32, 32) rect = Rect.new(w * index, 0, w - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
if index == 0 && !$game_fasttravel.enabled? # 0 - Fast Travel
self.contents.font.color.set(127, 127, 127, 255)
end
self.contents.draw_text(rect, tr(@commands[index]), 1) self.contents.draw_text(rect, tr(@commands[index]), 1)
end end
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------

View File

@ -169,6 +169,7 @@ class Window_Message < Window_Selectable
if $game_temp.message_face != nil if $game_temp.message_face != nil
if $game_temp.message_face.start_with?("en") if $game_temp.message_face.start_with?("en")
$game_system.windowskin_name = "en_normal" $game_system.windowskin_name = "en_normal"
self.y = 16;
else else
$game_system.windowskin_name = "normal" $game_system.windowskin_name = "normal"
end end

View File

@ -5,6 +5,7 @@ uniform lowp vec4 tone;
uniform lowp float opacity; uniform lowp float opacity;
uniform lowp vec4 color; uniform lowp vec4 color;
uniform lowp vec4 modulate;
uniform float bushDepth; uniform float bushDepth;
uniform lowp float bushOpacity; uniform lowp float bushOpacity;
@ -30,6 +31,9 @@ void main(){
/* Apply color */ /* Apply color */
frag.rgb = mix(frag.rgb, color.rgb, color.a); frag.rgb = mix(frag.rgb, color.rgb, color.a);
/* Apply modulation */
frag *= modulate;
/* Apply bush alpha by mathematical if */ /* Apply bush alpha by mathematical if */
lowp float underBush = float(v_texCoord.y < bushDepth); lowp float underBush = float(v_texCoord.y < bushDepth);
frag.a *= clamp(bushOpacity + underBush, 0.0, 1.0); frag.a *= clamp(bushOpacity + underBush, 0.0, 1.0);

View File

@ -211,6 +211,7 @@ struct EtcTemps{
Color color; Color color;
Tone tone; Tone tone;
Rect rect; Rect rect;
Color modulate;
}; };
#endif // ETC_H #endif // ETC_H

View File

@ -398,7 +398,7 @@ int main(int argc, char *argv[]){
Sound_Quit(); Sound_Quit();
TTF_Quit(); TTF_Quit();
SDL_Quit(); // i got "Thread 1 received signal ?, Unknown signal" here on windows after closing game + SDL_Quit(); // i got "Thread 1 received signal ?, Unknown signal" here on windows after closing game
#ifdef STEAM #ifdef STEAM
STEAMSHIM_deinit(); STEAMSHIM_deinit();

View File

@ -40,7 +40,7 @@
#include <algorithm> #include <algorithm>
#include <assert.h> #include <assert.h>
const Vec2i winSize(700, 500); const Vec2i winSize(700, 600);
const uint8_t cBgNorm = 50; const uint8_t cBgNorm = 50;
const uint8_t cBgDark = 20; const uint8_t cBgDark = 20;

View File

@ -374,6 +374,7 @@ SpriteShader::SpriteShader(){
GET_U(spriteMat); GET_U(spriteMat);
GET_U(tone); GET_U(tone);
GET_U(color); GET_U(color);
GET_U(modulate);
GET_U(opacity); GET_U(opacity);
GET_U(bushDepth); GET_U(bushDepth);
GET_U(bushOpacity); GET_U(bushOpacity);
@ -391,6 +392,10 @@ void SpriteShader::setColor(const Vec4 &color){
setVec4Uniform(u_color, color); setVec4Uniform(u_color, color);
} }
void SpriteShader::setModulate(const Vec4 &color){
setVec4Uniform(u_modulate, color);
}
void SpriteShader::setOpacity(float value){ void SpriteShader::setOpacity(float value){
gl.Uniform1f(u_opacity, value); gl.Uniform1f(u_opacity, value);
} }

View File

@ -167,12 +167,13 @@ public:
void setSpriteMat(const float value[16]); void setSpriteMat(const float value[16]);
void setTone(const Vec4 &value); void setTone(const Vec4 &value);
void setColor(const Vec4 &value); void setColor(const Vec4 &value);
void setModulate(const Vec4 &value);
void setOpacity(float value); void setOpacity(float value);
void setBushDepth(float value); void setBushDepth(float value);
void setBushOpacity(float value); void setBushOpacity(float value);
private: private:
GLint u_spriteMat, u_tone, u_opacity, u_color, u_bushDepth, u_bushOpacity; GLint u_spriteMat, u_tone, u_opacity, u_color, u_modulate, u_bushDepth, u_bushOpacity;
}; };
class PlaneShader : public ShaderBase{ class PlaneShader : public ShaderBase{

View File

@ -69,6 +69,7 @@ struct SpritePrivate{
Color *color; Color *color;
Tone *tone; Tone *tone;
Color *modulate;
struct{ struct{
int amp; int amp;
@ -99,7 +100,8 @@ struct SpritePrivate{
isVisible(false), isVisible(false),
obscured(false), obscured(false),
color(&tmp.color), color(&tmp.color),
tone(&tmp.tone) tone(&tmp.tone),
modulate(&tmp.modulate)
{ {
sceneRect.x = sceneRect.y = 0; sceneRect.x = sceneRect.y = 0;
@ -313,6 +315,7 @@ DEF_ATTR_SIMPLE(Sprite, Opacity, int, p->opacity)
DEF_ATTR_SIMPLE(Sprite, SrcRect, Rect&, *p->srcRect) DEF_ATTR_SIMPLE(Sprite, SrcRect, Rect&, *p->srcRect)
DEF_ATTR_SIMPLE(Sprite, Color, Color&, *p->color) DEF_ATTR_SIMPLE(Sprite, Color, Color&, *p->color)
DEF_ATTR_SIMPLE(Sprite, Tone, Tone&, *p->tone) DEF_ATTR_SIMPLE(Sprite, Tone, Tone&, *p->tone)
DEF_ATTR_SIMPLE(Sprite, Modulate, Color&, *p->modulate)
DEF_ATTR_SIMPLE(Sprite, Obscured, bool, p->obscured) DEF_ATTR_SIMPLE(Sprite, Obscured, bool, p->obscured)
void Sprite::setBitmap(Bitmap *bitmap){ void Sprite::setBitmap(Bitmap *bitmap){
@ -465,6 +468,7 @@ void Sprite::initDynAttribs(){
p->srcRect = new Rect; p->srcRect = new Rect;
p->color = new Color; p->color = new Color;
p->tone = new Tone; p->tone = new Tone;
p->modulate = new Color(255, 255, 255);
p->updateSrcRectCon(); p->updateSrcRectCon();
} }
@ -491,6 +495,7 @@ void Sprite::draw(){
bool renderEffect = p->color->hasEffect() || bool renderEffect = p->color->hasEffect() ||
p->tone->hasEffect() || p->tone->hasEffect() ||
p->modulate->hasEffect() ||
flashing || flashing ||
p->bushDepth != 0; p->bushDepth != 0;
@ -519,6 +524,7 @@ void Sprite::draw(){
&flashColor : &p->color->norm; &flashColor : &p->color->norm;
shader.setColor(*blend); shader.setColor(*blend);
shader.setModulate(p->modulate->norm);
base = &shader; base = &shader;
} }

View File

@ -60,6 +60,7 @@ public:
DECL_ATTR( Opacity, int ) DECL_ATTR( Opacity, int )
DECL_ATTR( BlendType, int ) DECL_ATTR( BlendType, int )
DECL_ATTR( Color, Color& ) DECL_ATTR( Color, Color& )
DECL_ATTR( Modulate, Color& )
DECL_ATTR( Tone, Tone& ) DECL_ATTR( Tone, Tone& )
DECL_ATTR( WaveAmp, int ) DECL_ATTR( WaveAmp, int )
DECL_ATTR( WaveLength, int ) DECL_ATTR( WaveLength, int )

View File

@ -50,4 +50,4 @@
#define TRSTR_KEYBIND_DEACTIVATE 49 #define TRSTR_KEYBIND_DEACTIVATE 49
#define TRSTR_KEYBIND_ITEMS 50 #define TRSTR_KEYBIND_ITEMS 50
#define TRSTR_KEYBIND_R 51 #define TRSTR_KEYBIND_R 51
#define TRSTR_KEYBIND_DEBUGACTION 50 #define TRSTR_KEYBIND_DEBUGACTION 52