Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module YIN
- # Name of the confirm button in the button config
- Confirm = "Confirm"
- # Name of the cancel button in the button config
- Cancel = "Menu/Cancel"
- # Name of the dash button in the button config
- Dash = "Accessory"
- # Name of the attack button in the button config
- # NOTE - For some reason the word Attack causes the text to show in the
- # correct spot.
- # I actually think it might be trying to draw an icon through Blackmorning's
- # icons script.
- Attack = "Weapon"
- # Name of the attack button in the button config
- Skill = "Magic"
- # Name of the weapon skill button in the button config
- WeaponSkill = "Skill"
- # Name of the move button in the button config
- Move_Up = "Move Up"
- Move_Down = "Move Down"
- Move_Left = "Move Left"
- Move_Right = "Move Right"
- # Name of the menu button in the button config
- Menu = "Menu"
- # Name of the pageup button in the button config
- Page_Up = "Accessory"
- # Name of the pagedown button in the button config
- Page_Down = "Switch"
- end
- class Window_CurrentButtons < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- make_item_list
- height = window_height
- super
- @buttons = []
- refresh
- end
- #--------------------------------------------------------------------------
- # * Get Digit Count
- #--------------------------------------------------------------------------
- def col_max
- return 1
- end
- #--------------------------------------------------------------------------
- # * Get Number of Items
- #--------------------------------------------------------------------------
- def item_max
- @buttons ? @buttons.size : 1
- end
- #--------------------------------------------------------------------------
- # * Get Window Height
- #--------------------------------------------------------------------------
- def window_height
- fitting_height(item_max)
- end
- #--------------------------------------------------------------------------
- # * Get Item
- #--------------------------------------------------------------------------
- def item
- @buttons && index >= 0 ? @buttons[index] : nil
- end
- #--------------------------------------------------------------------------
- # * Create Item List
- #--------------------------------------------------------------------------
- def make_item_list
- inputs = {
- :Confirm => PadConfig.confirm,
- :Cancel => PadConfig.cancel,
- :Dash => PadConfig.dash,
- :Attack => PadConfig.attack,
- :Skill => PadConfig.skill,
- :Skill2 => PadConfig.skill2,
- :Move_Up => PadConfig.move_up,
- :Move_Down => PadConfig.move_down,
- :Move_Left => PadConfig.move_left,
- :Move_Right => PadConfig.move_right
- #~ :Page_Up => PadConfig.page_up,
- #~ :Page_Down => PadConfig.page_down
- }
- @buttons = []
- inputs.each{|key,val|
- @buttons << [key,val]
- }
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @buttons[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- button = item[1].to_s.gsub(/_/, ' ').strip.capitalize
- case item[0]
- when :Confirm
- button_name = YIN::Confirm
- when :Cancel
- button_name = YIN::Cancel
- when :Dash
- button_name = YIN::Dash
- when :Attack
- button_name = YIN::Attack
- when :Skill
- button_name = YIN::Skill
- when :Skill2
- button_name = YIN::WeaponSkill #Nama Skill menu
- when :Move_Up
- button_name = YIN::Move_Up
- when :Move_Down
- button_name = YIN::Move_Down
- when :Move_Left
- button_name = YIN::Move_Left
- when :Move_Right
- button_name = YIN::Move_Right
- when :Page_Up
- button_name = YIN::Page_Up
- when :Page_Down
- button_name = YIN::Page_Down
- end
- draw_text(rect.x, rect.y, rect.width, rect.height, button_name.strip)
- draw_text(rect.x, rect.y, rect.width, rect.height, button, 2)
- end
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help
- end
- def process_cursor_move
- super
- if @help_window
- @help_window.refresh_input_config("Change button configuration")
- end
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
- end
- class Window_Help < Window_Base
- def refresh_input_config(text)
- contents.clear
- draw_text(4, 0, contents.width, contents.height, text, 1)
- end
- end
- #==============================================================================
- # ** Scene_ButtonConfig
- #------------------------------------------------------------------------------
- # This class performs basic processing related to the menu screen.
- #==============================================================================
- class Scene_ButtonConfig < Scene_MenuBase
- include Zale::Keyboard_Manager
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- super
- @change_current = nil
- @waiting = false
- @counter = 10
- create_current_window
- create_help_window
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_background
- end
- #--------------------------------------------------------------------------
- # * Create Background
- #--------------------------------------------------------------------------
- def create_background
- @background_sprite = Sprite.new
- @background_sprite.bitmap = SceneManager.background_bitmap
- @background_sprite.color.set(16, 16, 16, 128)
- end
- #--------------------------------------------------------------------------
- # * Free Background
- #--------------------------------------------------------------------------
- def dispose_background
- @background_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # * Create Help Window
- #--------------------------------------------------------------------------
- def create_help_window
- @help_window = Window_Help.new
- @help_window.viewport = @viewport
- if WolfPad.plugged_in?
- @help_window.refresh_input_config("Using Game Controller. Change button configuration")
- else
- @help_window.refresh_input_config("Using Keyboard. Change button configuration")
- end
- end
- def create_current_window
- @current_window = Window_CurrentButtons.new((Graphics.width - 192) / 2, (Graphics.height - 192) / 2, 192, 216)
- @current_window.viewport = @viewport
- @current_window.help_window = @help_window
- @current_window.set_handler(:ok, method(:on_current_ok))
- @current_window.set_handler(:cancel, method(:on_current_cancel))
- @current_window.activate
- @current_window.select(0)
- end
- def on_current_ok
- @change_current = @current_window.item
- case @change_current[0]
- when :Confirm
- button_name = YIN::Confirm
- when :Cancel
- button_name = YIN::Cancel
- when :Dash
- button_name = YIN::Dash
- when :Attack
- button_name = YIN::Attack
- when :Skill
- button_name = YIN::Skill
- when :Skill2
- button_name = YIN::WeaponSkill #Nama Skill menu
- when :Move_Up
- button_name = YIN::Move_Up
- when :Move_Down
- button_name = YIN::Move_Down
- when :Move_Left
- button_name = YIN::Move_Left
- when :Move_Right
- button_name = YIN::Move_Right
- when :Page_Up
- button_name = YIN::Page_Up
- when :Page_Down
- button_name = YIN::Page_Down
- end
- @waiting = true
- @help_window.refresh_input_config("Press the button you want to change '#{button_name}' to.")
- end
- def on_current_cancel
- if @waiting == true ; return; end
- SceneManager.return
- end
- def wait_for_input
- @counter -= 1 if @counter > 0
- if @counter > 0 ; return ; end
- if WolfPad.trigger?(:A); assign(@change_current, :A); end
- if WolfPad.trigger?(:B); assign(@change_current, :B); end
- if WolfPad.trigger?(:X); assign(@change_current, :X); end
- if WolfPad.trigger?(:Y); assign(@change_current, :Y); end
- if WolfPad.trigger?(:L1); assign(@change_current, :L1); end
- if WolfPad.trigger?(:L2); assign(@change_current, :L2); end
- if WolfPad.trigger?(:R1); assign(@change_current, :R1); end
- if WolfPad.trigger?(:R2); assign(@change_current, :R2); end
- if WolfPad.trigger?(:SELECT); assign(@change_current, :SELECT); end
- if WolfPad.trigger?(:START); assign(@change_current, :START); end
- if WolfPad.trigger?(:L3); assign(@change_current, :L3); end
- if WolfPad.trigger?(:R3); assign(@change_current, :R3); end
- if WolfPad.trigger?(:R_UP); assign(@change_current, :R_UP); end
- if WolfPad.trigger?(:R_DOWN); assign(@change_current, :R_DOWN); end
- if WolfPad.trigger?(:R_LEFT); assign(@change_current, :R_LEFT); end
- if WolfPad.trigger?(:R_RIGHT); assign(@change_current, :R_RIGHT); end
- if Input.get_key[1] === true;
- assign(@change_current, Input.get_key[0][0])
- end
- end
- def check_button_assignment(new)
- controls = WolfPad.plugged_in? ? $game_options.game_controls[:controller] : $game_options.game_controls[:keyboard]
- controls.any? {|key| key[1] == new}
- end
- def assign(current, new)
- cur = @current_window.item[0]
- if cur != :Move_Up && cur != :Move_Down && cur != :Move_Left && cur != :Move_Right
- if new == :_left || new == :_right || new == :_up || new == :_down
- @waiting = false
- Sound.play_buzzer
- button = new.to_s.gsub(/_/, ' ').strip.capitalize
- @help_window.refresh_input_config("Cannot assign directional buttons to action functions!")
- @current_window.activate
- @current_window.refresh
- @counter = 10
- return
- end
- end
- if check_button_assignment(new)
- @waiting = false
- Sound.play_buzzer
- button = new.to_s.gsub(/_/, ' ').strip.capitalize
- @help_window.refresh_input_config("Button #{button} is already assigned to a function!")
- @current_window.activate
- @current_window.refresh
- @counter = 10
- return
- end
- Sound.play_ok
- @counter = 10
- controls = WolfPad.plugged_in? ? $game_options.game_controls[:controller] : $game_options.game_controls[:keyboard]
- controls[@change_current[0]] = new
- @waiting = false
- @current_window.activate
- @current_window.refresh
- end
- def update
- super
- if @change_current != @current_window.item
- if WolfPad.plugged_in?
- @help_window.refresh_input_config("Using Game Controller. Change button configuration")
- else
- @help_window.refresh_input_config("Using Keyboard. Change button configuration")
- end
- end
- if @waiting == true
- wait_for_input
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement