reset controls button

This commit is contained in:
Issac332 2026-06-25 21:25:50 +03:00
parent d3548caeaa
commit 2d71858bdf
3 changed files with 54 additions and 7 deletions

View file

@ -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") => [
{

View file

@ -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

View file

@ -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