Permalink
Browse files

finally got rid of old hideous menu code

  • Loading branch information...
1 parent b3ebff7 commit 1a2b6df407f597d6d2e3898ca83db227b14ac54b @bgoodspeed committed Nov 2, 2010
@@ -1,23 +0,0 @@
-class BattleMenuHelper < MenuHelper
- def initialize(battle, screen, layer,text_helper, sections, cursor_x, cursor_y, cursor_main_color=:blue, cursor_inactive_color=:white)
- super(screen, layer,text_helper, sections, cursor_x, cursor_y, cursor_main_color, cursor_inactive_color)
- @battle = battle
- end
-
- def current_cursor_member_ready?
- @battle.party.members[@cursor_position].ready?
- end
-
- def color_for_current_section_cursor
- if current_cursor_member_ready?
- @cursor_main_color
- else
- @cursor_inactive_color
- end
- end
- def enter_current_cursor_location(game)
- super(game) if current_cursor_member_ready?
- end
-
-
-end
@@ -1,31 +0,0 @@
-class AttackMenuAction < MenuAction
- def initialize(text, battle_layer, menu_helper)
- super(text, AttackAction.new)
- @battle_layer = battle_layer
- @menu_helper = menu_helper
- end
-
- def activate(party_member_index, game, action_idx, subsection_position=nil, option_position=nil)
- @menu_helper.set_active_subsection(action_idx)
-
- return false unless subsection_position
- battle = @battle_layer.battle
-
- hero = battle.player.party.members[party_member_index]
- target = battle.current_battle_participant(subsection_position)
- puts "I am going to attack #{target}"
- @action.perform(hero, target)
- msg = "attacked for #{hero.damage} damage"
-# msg += "hero #{hero} killed #{battle.monster}" if battle.monster.dead?
- game.add_notification(BattleScreenNotification.new("Attacked for #{hero.damage}"))
- false
- end
-
- def size
- @battle_layer.participants.size
- end
-
- def details
- false
- end
-end
@@ -1,11 +0,0 @@
-
-class EndBattleMenuAction < MenuAction
- def initialize(text, battle_layer)
- super(text)
- @battle_layer = battle_layer
- end
-
- def activate(menu_idx, game, submenu_idx)
- @battle_layer.end_battle
- end
-end
@@ -1,55 +0,0 @@
-
-class ItemMenuAction < MenuAction
-
- include Rubygame
-
- def initialize(text, battle_layer, menu_helper, game)
- super(text, ItemAction.new)
- @battle_layer = battle_layer
- @menu_helper = menu_helper
- @game = game
- end
-
- def activate(party_member_index, game, action_idx, subsection_position=nil, option_position=nil)
- @menu_helper.set_active_subsection(action_idx)
-
- return false unless subsection_position
- return true unless option_position
-
- battle = @battle_layer.battle
- hero = battle.player.party.members[party_member_index]
- item = battle.inventory_item_at(subsection_position)
- target = battle.current_battle_participant(option_position)
- puts "target is: #{option_position}->#{target}"
- @action.perform(hero, target, item)
- game.add_notification(BattleScreenNotification.new("Item used: #{item}"))
- false
- end
-
- def option_at(idx)
- @battle_layer.participants
- end
-
- def size
- @battle_layer.inventory.size
- end
-
- def info
- @game.inventory_info
- end
-
- def surface_for(posn)
- false
- end
-
-
- def details
- info_lines = info.collect {|item| item.to_info}
- s = Surface.new([@@STATUS_WIDTH, @@STATUS_HEIGHT])
- s.fill(:purple)
- @menu_helper.render_text_to(s, info_lines, TextRenderingConfig.new(0, 0, 0,@@MENU_LINE_SPACING))
- s
- end
-
-
-end
View
@@ -89,27 +89,6 @@
require 'lib/menu/cursor_helper'
require 'lib/menu/menu_layer_config'
-#TODO delete this
-require 'lib/menu/noop_action'
-require 'lib/menu/menu_helper'
-require 'lib/menu/menu_action'
-require 'lib/menu/menu_section'
-require 'lib/menu/menu_sections'
-require 'lib/menu/abstract_actor_menu_action'
-require 'lib/menu/hero_menu_section'
-require 'lib/menu/inventory_display_action'
-require 'lib/menu/key_inventory_display_action'
-require 'lib/menu/level_up_action'
-require 'lib/menu/sort_inventory_action'
-require 'lib/menu/status_display_action'
-require 'lib/menu/update_equipment_action'
-require 'lib/menu/menu_helper'
-require 'lib/menu/menu_layer_config'
-require 'lib/menu/save_load_menu_action'
-require 'lib/menu/save_menu_action'
-require 'lib/menu/load_menu_action'
-
-#to here
require 'lib/text/text_rendering_config'
require 'lib/text/text_rendering_helper'
@@ -140,11 +119,7 @@
require 'lib/battle/battle_readiness_helper'
require 'lib/battle/battle_victory_helper'
require 'lib/battle/battle_hud'
-require 'lib/battle/battle_menu_helper'
require 'lib/battle/battle_participant_cursor_text_rendering_config'
-require 'lib/battle/menu/attack_menu_action'
-require 'lib/battle/menu/end_battle_menu_action'
-require 'lib/battle/menu/item_menu_action'
require 'lib/battle/menu/selectors/battle_skill_menu_selector'
require 'lib/battle/menu/selectors/battle_ready_party_menu_selector'
@@ -51,8 +51,8 @@ def menu_layer_config
mlc.main_menu_text = TextRenderingConfig.new(@@MENU_TEXT_INSET, @@MENU_TEXT_WIDTH, @layer.h - 125, 0)
mlc.section_menu_text = TextRenderingConfig.new(@@MENU_TEXT_INSET, @@MENU_TEXT_WIDTH, @layer.h - 150, 0)
mlc.in_section_cursor = TextRenderingConfig.new(@@MENU_TEXT_INSET , @@MENU_TEXT_WIDTH, @layer.h - 175, 0)
- mlc.in_subsection_cursor = BattleParticipantCursorTextRenderingConfig.new([AttackMenuAction], 2 * @@MENU_TEXT_INSET + 4*@@MENU_TEXT_WIDTH, 0, @@MENU_TEXT_INSET, @@MENU_LINE_SPACING)
- mlc.in_option_section_cursor = BattleParticipantCursorTextRenderingConfig.new([ItemMenuAction], 2 * @@MENU_TEXT_INSET + 4*@@MENU_TEXT_WIDTH, 0, @@MENU_TEXT_INSET, @@MENU_LINE_SPACING)
+ mlc.in_subsection_cursor = BattleParticipantCursorTextRenderingConfig.new([AttackBattleMenuAction], 2 * @@MENU_TEXT_INSET + 4*@@MENU_TEXT_WIDTH, 0, @@MENU_TEXT_INSET, @@MENU_LINE_SPACING)
+ mlc.in_option_section_cursor = BattleParticipantCursorTextRenderingConfig.new([UseBattleItemBattleMenuAction], 2 * @@MENU_TEXT_INSET + 4*@@MENU_TEXT_WIDTH, 0, @@MENU_TEXT_INSET, @@MENU_LINE_SPACING)
mlc.main_cursor = TextRenderingConfig.new(@@MENU_TEXT_INSET , @@MENU_TEXT_WIDTH, @layer.h - 100, 0)
mlc.layer_inset_on_screen = [@@LAYER_INSET,@@LAYER_INSET]
mlc.details_inset_on_layer = [@@MENU_DETAILS_INSET_X, @@MENU_DETAILS_INSET_Y]
@@ -1,33 +0,0 @@
-
-
-class AbstractActorMenuAction
- include Rubygame
- extend Forwardable
- def initialize(actor, menu_helper)
- @actor = actor
- @menu_helper = menu_helper
- end
- def text
- @actor.name
- end
- def section_by_index(idx)
- puts "hrm, maybe should be picking a certain status line"
- end
- def display_actor_status_info
- info_lines = @actor.status_info
- s = Surface.new([@@STATUS_WIDTH, @@STATUS_HEIGHT])
- s.fill(:green)
- @menu_helper.render_text_to(s, info_lines, TextRenderingConfig.new(0, 0, 0,@@MENU_LINE_SPACING))
- s
- end
- def has_subsections?
- true
- end
-
-
- def draw(menu_layer_config, game, text_rendering_helper, layer, screen)
- display_actor_status_info.blit(layer, menu_layer_config.details_inset_on_layer)
- end
-
- alias_method :name, :text
-end
@@ -1,10 +0,0 @@
-
-
-class HeroMenuSection < MenuSection
- def initialize(hero, content)
- super(hero.name, content)
- @hero = hero
- end
-end
-
-
@@ -1,105 +0,0 @@
-
-class HeroWrapper
- def initialize(game, item, member)
- @game = game
- @item = item
- @member = member
- end
-
- def name
- @member.name
- end
- def section_by_index(idx)
- self #TODO this is odd..
- end
-
-end
-
-class InventoryDisplayWrapper
- def initialize(game, item)
- @game = game
- @item = item
- end
- def party_members
- @game.party_members
- end
-
- def section_by_index(idx)
- HeroWrapper.new(@game, @item, party_members[idx])
- end
-
-end
-
-class InventoryDisplayAction
- include Rubygame
-
- attr_reader :text
- alias_method :name, :text
- def initialize(text, game, menu_helper)
- @text = text
- @game = game
- @menu_helper = menu_helper
- @selected_option = nil
- end
-
- def has_subsections?
- true
- end
-
- def section_by_index(idx)
- InventoryDisplayWrapper.new(@game, info[idx])
- end
-
- def activate(cursor_position, game, section_position, subsection_position=nil, option_position=nil)
- if !option_position.nil?
- item = info[subsection_position]
- target = party_members[option_position]
- target.consume_item(item) #TODO this is similar to ItemAction refactor
- elsif subsection_position.nil?
- @menu_helper.set_active_subsection(section_position)
- end
- return !subsection_position.nil?
- end
- def surface_for(posn)
- item = info[posn]
- s = Surface.new([@@STATUS_WIDTH, @@STATUS_HEIGHT])
- s.fill(:white)
- member_names = party_members.collect {|m| m.name}
- @menu_helper.render_text_to(s,member_names , TextRenderingConfig.new(0, 0, 0,@@MENU_LINE_SPACING))
- s
-
- end
-
- def option_at(idx=nil)
- if idx.nil?
- party_members
- else
- party_members[idx]
- end
- end
-
- def party_members
- @game.party_members
- end
-
- def info
- @game.inventory_info
- end
-
- def details
- info_lines = info.collect {|item| item.to_info}
- s = Surface.new([@@STATUS_WIDTH, @@STATUS_HEIGHT])
- s.fill(:yellow)
- @menu_helper.render_text_to(s, info_lines, TextRenderingConfig.new(0, 0, 0,@@MENU_LINE_SPACING))
- s
- end
-
- def size
- info.size
- end
-
- def draw(menu_layer_config, game, text_rendering_helper, layer, screen)
- details.blit(layer, menu_layer_config.details_inset_on_layer)
- end
-
-end
@@ -1,3 +0,0 @@
-
-class KeyInventoryDisplayAction < InventoryDisplayAction
-end
@@ -1,19 +0,0 @@
-
-class LevelUpAction < AbstractActorMenuAction
-
- def size
- 2 #TODO this should come from the size of the attribute set
- end
-
- alias_method :details, :display_actor_status_info
-
- def activate(cursor_position, game, section_position, subsection_position=nil, option_position=nil)
- @menu_helper.set_active_subsection(section_position)
- if !subsection_position.nil?
- @actor.consume_level_up(subsection_position)
- end
- false
- end
-
-
-end
@@ -1,14 +0,0 @@
-
-class LoadMenuAction < SaveLoadMenuAction
- def activate(menu_idx, game, submenu_idx)
- slot = save_slot(submenu_idx)
- puts "load from #{slot}"
-
- data = IO.readlines(slot)
-
- rebuilt = JSON.parse(data.join(" "))
- puts "got rebuilt: #{rebuilt.class} "
- ReloaderHelper.new.replace(game, rebuilt)
- game.add_notification(WorldScreenNotification.new("Loaded from #{slot}"))
- end
-end
View
@@ -1,14 +0,0 @@
-
-class MenuAction
- attr_reader :text
- alias_method :name, :text
- def initialize(text, action=NoopAction.new)
- @text = text
- @action = action
- end
-
- def activate(main_menu_idx, game, submenu_idx)
- puts "This is a no-op action: #{@text}"
- end
-end
-
Oops, something went wrong.

0 comments on commit 1a2b6df

Please sign in to comment.