Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Window_BattleEquip < Window_Selectable
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :status_window # Status window
- attr_reader :item_window # Item window
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(x, y, width)
- super(x, y, width, window_height)
- @actor = nil
- refresh
- end
- #--------------------------------------------------------------------------
- # * Get Window Height
- #--------------------------------------------------------------------------
- def window_height
- fitting_height(visible_line_number)
- end
- #--------------------------------------------------------------------------
- # * Get Number of Lines to Show
- #--------------------------------------------------------------------------
- def visible_line_number
- return 1
- end
- def col_max
- return 2
- end
- #--------------------------------------------------------------------------
- # * Set Actor
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- @item_window.slot_id = index if @item_window
- end
- #--------------------------------------------------------------------------
- # * Get Number of Items
- #--------------------------------------------------------------------------
- def item_max
- 2
- #@actor ? @actor.equip_slots.size : 0
- end
- #--------------------------------------------------------------------------
- # * Get Item
- #--------------------------------------------------------------------------
- def item
- @actor ? @actor.equips[index] : nil
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- return unless @actor
- rect = item_rect_for_text(index)
- change_color(system_color, enable?(index))
- contents.font.size = 14
- draw_text(rect.x, rect.y, 92, line_height * 0.5, slot_name(index))
- contents.font.size = 20
- draw_item_name(@actor.equips[index], rect.x + 54, rect.y, enable?(index))
- end
- #--------------------------------------------------------------------------
- # * Get Equipment Slot Name
- #--------------------------------------------------------------------------
- def slot_name(index)
- @actor ? Vocab::etype(@actor.equip_slots[index]) : ""
- end
- #--------------------------------------------------------------------------
- # * Display Equipment Slot in Enabled State?
- #--------------------------------------------------------------------------
- def enable?(index)
- @actor ? @actor.equip_change_ok?(index) : false
- end
- #--------------------------------------------------------------------------
- # * Get Activation State of Selection Item
- #--------------------------------------------------------------------------
- def current_item_enabled?
- enable?(index)
- end
- def item_window=(item_window)
- @item_window = item_window
- update
- end
- end
- class Scene_BattleEquip < Scene_MenuBase
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- super
- create_slot_window
- create_item_window
- end
- #--------------------------------------------------------------------------
- # * Create Slot Window
- #--------------------------------------------------------------------------
- def create_slot_window
- wx = 0
- wy = 248
- ww = Graphics.width
- wh = 200
- @slot_window = Window_BattleEquip.new(wx, wy, ww)
- @slot_window.viewport = @viewport
- @slot_window.actor = @actor
- @slot_window.activate
- @slot_window.select(0)
- @slot_window.set_handler(:ok, method(:on_slot_ok))
- @slot_window.set_handler(:cancel, method(:return_scene))
- end
- #--------------------------------------------------------------------------
- # * Create Item Window
- #--------------------------------------------------------------------------
- def create_item_window
- wx = 0
- wy = @slot_window.y + @slot_window.height
- ww = Graphics.width
- wh = 120
- @item_window = Window_EquipItem.new(wx, wy, ww, wh)
- @item_window.viewport = @viewport
- @item_window.actor = @actor
- @item_window.set_handler(:ok, method(:on_item_ok))
- @item_window.set_handler(:cancel, method(:on_item_cancel))
- @slot_window.item_window = @item_window
- end
- #--------------------------------------------------------------------------
- # * Slot [OK]
- #--------------------------------------------------------------------------
- def on_slot_ok
- @item_window.activate
- @item_window.select(0)
- end
- #--------------------------------------------------------------------------
- # * Slot [Cancel]
- #--------------------------------------------------------------------------
- def on_slot_cancel
- @slot_window.unselect
- end
- #--------------------------------------------------------------------------
- # * Item [OK]
- #--------------------------------------------------------------------------
- def on_item_ok
- Sound.play_equip
- @actor.change_equip(@slot_window.index, @item_window.item)
- @slot_window.activate
- @slot_window.refresh
- @item_window.unselect
- @item_window.refresh
- end
- #--------------------------------------------------------------------------
- # * Item [Cancel]
- #--------------------------------------------------------------------------
- def on_item_cancel
- @slot_window.activate
- @item_window.unselect
- end
- def on_actor_change
- end
- end
- class Scene_Battle
- alias scene_battle_create_item_window_ry create_item_window
- def create_item_window
- scene_battle_create_item_window_ry
- @item_window.set_handler(:equip, method(:command_equip))
- end
- def command_equip
- Graphics.freeze
- @info_viewport.visible = false
- actor = $game_party.battle_members[@status_window.index]
- $game_party.menu_actor = actor
- previous_equips = actor.equips.clone
- SceneManager.snapshot_for_battle
- @item_window.close.deactivate
- #---
- SceneManager.call(Scene_BattleEquip)
- SceneManager.scene.main
- #SceneManager.force_recall(self)
- #---
- @item_window.open.activate
- @info_viewport.visible = true
- @status_window.refresh
- perform_transition
- end
- end
- class Window_BattleItem < Window_ItemList
- def help_show
- if @help_window.visible
- @help_window.hide
- @help_window.width = Graphics.width - 375
- else
- @help_window.width = Graphics.width
- @help_window.show
- end
- end
- def update
- return process_equip if @index <= 1 and Input.trigger?(:UP) and open? && active # perform check to go to equip
- super # run superclass method for update, contains cursor movement and other processing checks
- end
- def process_handling
- return unless open? && active
- return process_ok if ok_enabled? && Input.trigger?(:C)
- return help_show if Input.trigger?(:Z)
- return process_cancel if cancel_enabled? && Input.trigger?(:B)
- return process_pagedown if handle?(:pagedown) && Input.trigger?(:R)
- return process_pageup if handle?(:pageup) && Input.trigger?(:L)
- end
- def process_equip
- Sound.play_cursor
- Input.update
- deactivate
- call_handler(:equip)
- end
- end
- module SceneManager
- def self.snapshot_for_battle
- @background_bitmap.dispose if @background_bitmap
- @background_bitmap = Graphics.snap_to_bitmap
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement