diff --git a/scripts/Data_Settings.rb b/scripts/Data_Settings.rb index 9149fff..cc62402 100644 --- a/scripts/Data_Settings.rb +++ b/scripts/Data_Settings.rb @@ -34,6 +34,17 @@ module Settings #controls :gamepad_led => true, :gamepad_deadzone => 5, + + # Debug + :debug => false, + :debug_character => false, + :debug_text => false, + } + reset_controls! + end + + def reset_controls! + @data.merge!({ :controls_walk_down => [ KeyBind.key(Input::key_from_name("Down")), KeyBind.caxis(Input::c_axis_from_name("LeftY"), KeyBind::Positive), @@ -97,12 +108,7 @@ module Settings KeyBind.key(Input::key_from_name("Left Ctrl")), KeyBind.cbutton(Input::c_button_from_name("rightstick")), ], - - # Debug - :debug => false, - :debug_character => false, - :debug_text => false, - } + }) end end end @@ -313,6 +319,11 @@ class Window_Settings :parameter => :controls_debug, :bind => Input::DEBUGACTION }, + { + :type => :action, + :name => tr("Reset Controls"), + :action => Settings.method(:reset_controls!) + }, ], tr("Advanced") => [ { diff --git a/scripts/Data_Settings_Classes.rb b/scripts/Data_Settings_Classes.rb index d6909d9..a23cd9b 100644 --- a/scripts/Data_Settings_Classes.rb +++ b/scripts/Data_Settings_Classes.rb @@ -613,6 +613,10 @@ class Window_Settings end def redraw() + if (@parameter) + @key_binds = Settings[@parameter] + end + @sprite.bitmap.clear if @selected @@ -659,7 +663,7 @@ class Window_Settings end def apply() - if @bind + if @bind != nil Input::set_binding(@key_binds, @bind) end end @@ -713,4 +717,32 @@ class Window_Settings redraw end end + class ActionParameter < BaseParameter + TYPE = :action + + def initialize(settings_content, screen_id, position, name, value_text, func, arg1, arg2, arg3, arg4) + @func = func + @arg1 = arg1 + @arg2 = arg2 + @arg3 = arg3 + @arg4 = arg4 + + super(settings_content, screen_id, position, name, nil, value_text) + end + + def action() + if @arg1 == nil && @arg2 == nil && @arg3 == nil && @arg4 == nil + @func.call + elsif @arg2 == nil && @arg3 == nil && @arg4 == nil + @func.call(@arg1) + elsif @arg3 == nil && @arg4 == nil + @func.call(@arg1, @arg2) + elsif @arg4 == nil + @func.call(@arg1, @arg2, @arg3) + else + @func.call(@arg1, @arg2, @arg3, @arg4) + end + @settings_content.redraw_all + end + end end \ No newline at end of file diff --git a/scripts/Window_Settings.rb b/scripts/Window_Settings.rb index c7db8dc..53bcae2 100644 --- a/scripts/Window_Settings.rb +++ b/scripts/Window_Settings.rb @@ -58,6 +58,10 @@ class Window_Settings when :key @content.add_parameter(screen_title, KeyParameter.new(@content, screen_index, parameter_index, parameter_info[:name], parameter_info[:parameter], parameter_info[:key_binds], parameter_info[:bind])) + when :action + @content.add_parameter(screen_title, ActionParameter.new(@content, screen_index, parameter_index, + parameter_info[:name], parameter_info[:default], parameter_info[:action], + parameter_info[:arg1], parameter_info[:arg2], parameter_info[:arg3], parameter_info[:arg4])) end end end