From 8b6f629a6a5c86071a87ac932e684f6aa53a40a7 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Thu, 21 Nov 2019 14:23:21 -0600 Subject: [PATCH] Fixed sidebar action names having underscores shown, added sidebar actions to construction worker --- lib/components/sidebar_actions.rb | 2 +- lib/entities/units/construction_worker.rb | 5 +++++ lib/entity_controller.rb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/components/sidebar_actions.rb b/lib/components/sidebar_actions.rb index 52853e3..a3f58d4 100644 --- a/lib/components/sidebar_actions.rb +++ b/lib/components/sidebar_actions.rb @@ -14,7 +14,7 @@ class IMICRTS when :add_to_build_queue action = Action.new ent = IMICRTS::Entity.get(args.first) - action.label = ent.name.to_s + action.label = ent.name.to_s.split("_").map{ |s| s.capitalize }.join(" ") action.description = "Cost: #{ent.cost}\n#{ent.description}" action.block = proc { @parent.component(:build_queue).add(args.first) } diff --git a/lib/entities/units/construction_worker.rb b/lib/entities/units/construction_worker.rb index a6d042f..cdfa77a 100644 --- a/lib/entities/units/construction_worker.rb +++ b/lib/entities/units/construction_worker.rb @@ -1,5 +1,10 @@ IMICRTS::Entity.define_entity(:construction_worker, :unit, 1000, "Constructs buildings") do |entity| entity.has(:movement) + entity.has(:build_queue) + entity.has(:sidebar_actions) + [:power_plant, :refinery, :barracks, :war_factory, :helipad, :construction_yard].each do |ent| + entity.component(:sidebar_actions).add(:add_to_build_queue, ent) + end entity.radius = 14 entity.movement = :ground diff --git a/lib/entity_controller.rb b/lib/entity_controller.rb index 0dd434b..65cdeb4 100644 --- a/lib/entity_controller.rb +++ b/lib/entity_controller.rb @@ -74,7 +74,7 @@ class IMICRTS @game.sidebar_actions.clear do |stack| ent.component(:sidebar_actions).actions.each do |action| - stack.button action.label, tip: action.description do + stack.button action.label, tip: action.description, width: 1.0 do action.block.call if action.block end end