From 18641ece15e4847a83aa6448080459436a05d5f0 Mon Sep 17 00:00:00 2001 From: cyberarm Date: Tue, 5 Jan 2021 23:13:13 -0600 Subject: [PATCH] Added production queue progress bar --- lib/entity.rb | 9 +++++++++ lib/setting.rb | 3 ++- lib/states/menus/solo_lobby_menu.rb | 20 +++++++++++++++++--- lib/team_colors.rb | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/entity.rb b/lib/entity.rb index ddbab0d..038f810 100644 --- a/lib/entity.rb +++ b/lib/entity.rb @@ -177,6 +177,15 @@ class IMICRTS # healthbar Gosu.draw_rect(@position.x - @radius, @position.y - (@radius + 2), @radius * 2, 2, Gosu::Color::GREEN, ZOrder::ENTITY_GIZMOS) + # build queue progress + if component(:build_queue) && component(:build_queue).queue.size.positive? + item = component(:build_queue).queue.first + factor = item.progress / item.entity.build_steps.to_f + + Gosu.draw_rect(@position.x - @radius, @position.y - (@radius + 6), @radius * 2, 2, Gosu::Color::BLACK, ZOrder::ENTITY_GIZMOS) + Gosu.draw_rect(@position.x - @radius, @position.y - (@radius + 6), (@radius * 2) * factor, 2, Gosu::Color::WHITE, ZOrder::ENTITY_GIZMOS) + end + if Setting.enabled?(:debug_pathfinding) && component(:movement) && component(:movement).pathfinder && component(:movement).pathfinder.path_current_node current_node = component(:movement).pathfinder.path_current_node.tile.position + @director.map.tile_size / 2 Gosu.draw_line( diff --git a/lib/setting.rb b/lib/setting.rb index 3e71e7d..fde43e9 100644 --- a/lib/setting.rb +++ b/lib/setting.rb @@ -11,9 +11,10 @@ class IMICRTS def self.save_defaults hash = { - player_name: "Rookie", + player_name: "Commander", player_color: :orange, player_team: 1, + player_position: "A", player_default_map_spawn: 0, default_map: "test_map", diff --git a/lib/states/menus/solo_lobby_menu.rb b/lib/states/menus/solo_lobby_menu.rb index e3fb760..b8672bf 100644 --- a/lib/states/menus/solo_lobby_menu.rb +++ b/lib/states/menus/solo_lobby_menu.rb @@ -22,22 +22,26 @@ class IMICRTS label "Color" @player_color = list_box items: TeamColors.keys, choose: Setting.get(:player_color).to_sym, width: 1.0 @player_color.style.background = (TeamColors[@player_color.value.to_sym]) + @player_color.style.color = Gosu::Color.new(@player_color.style.background&.gl).value > 0.9 ? Gosu::Color::BLACK : Gosu::Color::WHITE @player_color.subscribe(:changed) do |sender, value| @player_color.style.background = TeamColors[value.to_sym] + @player_color.style.color = Gosu::Color.new(@player_color.style.background&.gl).value > 0.9 ? Gosu::Color::BLACK : Gosu::Color::WHITE :handled end 7.times do |i| box = list_box items: TeamColors.keys, choose: TeamColors.keys[i + 1], width: 1.0 box.style.background = (TeamColors[box.value.to_sym]) + box.style.color = Gosu::Color.new(box.style.background&.gl).value > 0.9 ? Gosu::Color::BLACK : Gosu::Color::WHITE box.subscribe(:changed) do |sender, value| box.style.background = TeamColors[value.to_sym] + box.style.color = Gosu::Color.new(box.style.background&.gl).value > 0.9 ? Gosu::Color::BLACK : Gosu::Color::WHITE :handled end end end - stack(width: 0.29) do + stack(width: 0.15) do label "Team" @player_team = list_box items: Array(1..8), choose: Setting.get(:player_team), width: 1.0 @@ -45,10 +49,18 @@ class IMICRTS list_box items: Array(1..8), choose: i + 2, width: 1.0 end end + + stack(width: 0.15) do + label "Position" + @player_position = list_box items: Array("A".."H"), choose: Setting.get(:player_position), width: 1.0 + + 7.times do |i| + list_box items: Array("A".."H"), choose: Array("A".."H")[i + 1], width: 1.0 + end + end end stack(width: 0.30, height: 1.0) do - # TODO: Show preview image label "Map" maps_list = Dir.glob("#{GAME_ROOT_PATH}/assets/maps/*.tmx").map do |m| File.basename(m, ".tmx").to_sym @@ -59,7 +71,7 @@ class IMICRTS @map_preview.value = map_preview(value) end - @map_preview = image map_preview(@map_name.value), width: 1.0, border_thickness: 2, border_color: Gosu::Color::BLACK, background: Gosu::Color::GRAY + @map_preview = image map_preview(@map_name.value), width: 1.0, margin_top: 4, border_thickness: 1, border_color: 0xffff5500, background: Gosu::Color::BLACK end end @@ -77,6 +89,7 @@ class IMICRTS button("Back", align: :right) do save_playerdata + push_state(MainMenu) end end @@ -87,6 +100,7 @@ class IMICRTS Setting.set(:player_name, @player_name.value) Setting.set(:player_color, @player_color.value.to_sym) Setting.set(:player_team, @player_team.value.to_i) + Setting.set(:player_position, @player_position.value) Setting.set(:default_map, @map_name.value.to_s) Setting.save! diff --git a/lib/team_colors.rb b/lib/team_colors.rb index 97c5aba..3b4f94c 100644 --- a/lib/team_colors.rb +++ b/lib/team_colors.rb @@ -11,6 +11,6 @@ class IMICRTS gold: Gosu::Color::YELLOW, lightgray: Gosu::Color::WHITE, gray: Gosu::Color::GRAY, - black: Gosu::Color.rgb(25, 25, 25), + black: Gosu::Color.rgb(50, 50, 50), } end \ No newline at end of file