mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
gamepad icons (post)
This commit is contained in:
parent
d0f2f211c3
commit
5d4e2fbf61
2 changed files with 148 additions and 22 deletions
|
|
@ -221,7 +221,22 @@ module GamepadMapColors
|
||||||
end
|
end
|
||||||
|
|
||||||
module GamepadIcons
|
module GamepadIcons
|
||||||
ICONS_CACHE = []
|
GAMEPADS = [nil,
|
||||||
|
Input::GamepadType::XBOX360,
|
||||||
|
Input::GamepadType::XBOXONE,
|
||||||
|
:series_x,
|
||||||
|
Input::GamepadType::PS3,
|
||||||
|
Input::GamepadType::PS4,
|
||||||
|
Input::GamepadType::PS5,
|
||||||
|
Input::GamepadType::SWITCH_PRO,
|
||||||
|
Input::GamepadType::JOYCON_PAIR,
|
||||||
|
:luna,
|
||||||
|
:ouya,
|
||||||
|
:stadia,
|
||||||
|
:steam_controller,
|
||||||
|
:steam_deck,
|
||||||
|
Input::GamepadType::GAMECUBE
|
||||||
|
]
|
||||||
|
|
||||||
ICONS = {
|
ICONS = {
|
||||||
# SDL supported types, can be detected automatically
|
# SDL supported types, can be detected automatically
|
||||||
|
|
@ -244,6 +259,7 @@ module GamepadIcons
|
||||||
},
|
},
|
||||||
Input::GamepadType::STANDART => {
|
Input::GamepadType::STANDART => {
|
||||||
:icon => [10, 13],
|
:icon => [10, 13],
|
||||||
|
:face_skinnable => true,
|
||||||
:buttons => {
|
:buttons => {
|
||||||
Input::GamepadButton::INVALID => [9, 16],
|
Input::GamepadButton::INVALID => [9, 16],
|
||||||
Input::GamepadButton::SOUTH => [0, 0],
|
Input::GamepadButton::SOUTH => [0, 0],
|
||||||
|
|
@ -338,16 +354,6 @@ module GamepadIcons
|
||||||
Input::GamepadButton::MISC1 => [7, 11],
|
Input::GamepadButton::MISC1 => [7, 11],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Input::GamepadType::PS5 => {
|
|
||||||
:extends => Input::GamepadType::PS4,
|
|
||||||
:icon => [10, 12],
|
|
||||||
:buttons => {
|
|
||||||
Input::GamepadButton::BACK => [4, 9],
|
|
||||||
Input::GamepadButton::START => [5, 9],
|
|
||||||
Input::GamepadButton::TOUCHPAD => [4, 10],
|
|
||||||
Input::GamepadButton::MISC1 => [7, 11],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Input::GamepadType::SWITCH_PRO => {
|
Input::GamepadType::SWITCH_PRO => {
|
||||||
:extends => Input::GamepadType::JOYCON_PAIR,
|
:extends => Input::GamepadType::JOYCON_PAIR,
|
||||||
:icon => [10, 13],
|
:icon => [10, 13],
|
||||||
|
|
@ -391,6 +397,7 @@ module GamepadIcons
|
||||||
},
|
},
|
||||||
Input::GamepadType::GAMECUBE => {
|
Input::GamepadType::GAMECUBE => {
|
||||||
:extends => Input::GamepadType::STANDART,
|
:extends => Input::GamepadType::STANDART,
|
||||||
|
:face_skinnable => false,
|
||||||
:icon => [8, 11],
|
:icon => [8, 11],
|
||||||
:buttons => {
|
:buttons => {
|
||||||
Input::GamepadButton::SOUTH => [8, 10],
|
Input::GamepadButton::SOUTH => [8, 10],
|
||||||
|
|
@ -422,7 +429,7 @@ module GamepadIcons
|
||||||
},
|
},
|
||||||
:luna => {
|
:luna => {
|
||||||
:extends => Input::GamepadType::XBOXONE,
|
:extends => Input::GamepadType::XBOXONE,
|
||||||
:icon => [8, 11],
|
:icon => [10, 11],
|
||||||
:buttons => {
|
:buttons => {
|
||||||
Input::GamepadButton::BACK => [7, 13],
|
Input::GamepadButton::BACK => [7, 13],
|
||||||
Input::GamepadButton::GUIDE => [7, 12],
|
Input::GamepadButton::GUIDE => [7, 12],
|
||||||
|
|
@ -597,6 +604,54 @@ module GamepadIcons
|
||||||
}
|
}
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
def icon(gamepad_type = nil)
|
||||||
|
current_gamepad = get_gamepad_type(gamepad_type)
|
||||||
|
|
||||||
|
debug_string = ""
|
||||||
|
iterations = 0
|
||||||
|
|
||||||
|
result = nil
|
||||||
|
while !result
|
||||||
|
if !ICONS[current_gamepad].has_key?(:icon)
|
||||||
|
current_gamepad = ICONS[current_gamepad][:extends]
|
||||||
|
debug_string << "gamepad " << current_gamepad << "\n"
|
||||||
|
iterations += 1
|
||||||
|
if iterations > 10
|
||||||
|
puts debug_string
|
||||||
|
result = [8, 16]
|
||||||
|
end
|
||||||
|
next
|
||||||
|
end
|
||||||
|
result = ICONS[current_gamepad][:icon].clone
|
||||||
|
current_gamepad = ICONS[current_gamepad][:extends]
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def face_skinnable(gamepad_type = nil)
|
||||||
|
current_gamepad = get_gamepad_type(gamepad_type)
|
||||||
|
|
||||||
|
debug_string = ""
|
||||||
|
iterations = 0
|
||||||
|
|
||||||
|
result = nil
|
||||||
|
while result == nil
|
||||||
|
if !ICONS[current_gamepad].has_key?(:face_skinnable)
|
||||||
|
current_gamepad = ICONS[current_gamepad][:extends]
|
||||||
|
debug_string << "gamepad " << current_gamepad << "\n"
|
||||||
|
iterations += 1
|
||||||
|
if iterations > 10
|
||||||
|
puts debug_string
|
||||||
|
result = false
|
||||||
|
end
|
||||||
|
next
|
||||||
|
end
|
||||||
|
result = ICONS[current_gamepad][:face_skinnable]
|
||||||
|
current_gamepad = ICONS[current_gamepad][:extends]
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
def button(id, skinned = true, gamepad_type = nil)
|
def button(id, skinned = true, gamepad_type = nil)
|
||||||
current_gamepad = get_gamepad_type(gamepad_type)
|
current_gamepad = get_gamepad_type(gamepad_type)
|
||||||
|
|
||||||
|
|
@ -647,14 +702,15 @@ module GamepadIcons
|
||||||
end
|
end
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
result = ICONS[current_gamepad][:axes][id][1 - dir].clone
|
axis = ICONS[current_gamepad][:axes][id]
|
||||||
|
result = axis[1 - dir].clone if axis
|
||||||
current_gamepad = ICONS[current_gamepad][:extends]
|
current_gamepad = ICONS[current_gamepad][:extends]
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_gamepad_type(gamepad_override = nil)
|
def get_gamepad_type(gamepad_override = nil)
|
||||||
current_gamepad = gamepad_override
|
current_gamepad = gamepad_override || GamepadIcons::GAMEPADS[Settings[:gamepad_type]]
|
||||||
if !ICONS.has_key?(current_gamepad)
|
if !ICONS.has_key?(current_gamepad)
|
||||||
current_gamepad = GUIDS[Input::GamepadType.current_guid]
|
current_gamepad = GUIDS[Input::GamepadType.current_guid]
|
||||||
if !ICONS.has_key?(current_gamepad)
|
if !ICONS.has_key?(current_gamepad)
|
||||||
|
|
|
||||||
|
|
@ -294,25 +294,42 @@ class Window_Settings
|
||||||
{ :type => :sep, :name => "Gamepad" },
|
{ :type => :sep, :name => "Gamepad" },
|
||||||
{
|
{
|
||||||
:type => :custom,
|
:type => :custom,
|
||||||
:name => "Face buttons style",
|
:name => "Your gamepad type",
|
||||||
:parameter => :gamepad_face_style,
|
:parameter => :gamepad_type,
|
||||||
:default => 0,
|
:default => 0,
|
||||||
:callbacks => {
|
:callbacks => {
|
||||||
:init => proc { |super_proc|
|
:init => proc { |super_proc|
|
||||||
@max_value = 5
|
@max_value = GamepadIcons::GAMEPADS.length
|
||||||
|
@texts = [
|
||||||
|
"Auto",
|
||||||
|
"XBOX 360",
|
||||||
|
"XBOX One",
|
||||||
|
"XBOX Series X",
|
||||||
|
"PS 3",
|
||||||
|
"PS 4",
|
||||||
|
"PS 5",
|
||||||
|
"Nintendo Switch Pro",
|
||||||
|
"Nintendo Joycons",
|
||||||
|
"Amazon Luna",
|
||||||
|
"OUYA",
|
||||||
|
"Google Stadia",
|
||||||
|
"Steam Controller",
|
||||||
|
"Steam Deck",
|
||||||
|
"Nintendo GAMECUBE"
|
||||||
|
]
|
||||||
|
|
||||||
super_proc.call
|
super_proc.call
|
||||||
},
|
},
|
||||||
:get_display_value => proc { |super_proc|
|
:get_display_value => proc { |super_proc|
|
||||||
"" # meow >w<
|
""
|
||||||
},
|
},
|
||||||
:redraw => proc { |super_proc|
|
:redraw => proc { |super_proc|
|
||||||
super_proc.call
|
super_proc.call
|
||||||
|
|
||||||
x, y = GamepadIcons.button(Input::GamepadButton::SOUTH, false)
|
x, y = GamepadIcons.icon()
|
||||||
y += self.value * ICON_SIZE
|
|
||||||
|
|
||||||
@sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 4 * 2, (PARAMETER_HEIGHT - ICON_SIZE * 2) / 2, ICON_SIZE * 4 * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(x, y, ICON_SIZE * 4, ICON_SIZE))
|
@sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 2, PARAMETER_HEIGHT / 2 - ICON_SIZE, ICON_SIZE * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(x * ICON_SIZE, y * ICON_SIZE, ICON_SIZE, ICON_SIZE))
|
||||||
|
@sprite.bitmap.draw_text(@sprite.bitmap.width - @value_width - ICON_SIZE * 2 - 8, 0, @value_width, @sprite.bitmap.height, tr(@texts[self.value]), 2)
|
||||||
},
|
},
|
||||||
:value_set => proc { |super_proc, value|
|
:value_set => proc { |super_proc, value|
|
||||||
if (value != self.value)
|
if (value != self.value)
|
||||||
|
|
@ -332,9 +349,62 @@ class Window_Settings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
:type => :custom,
|
||||||
|
:name => "Face buttons style",
|
||||||
|
:parameter => :gamepad_face_style,
|
||||||
|
:default => 0,
|
||||||
|
:callbacks => {
|
||||||
|
:init => proc { |super_proc|
|
||||||
|
@max_value = 5
|
||||||
|
|
||||||
|
super_proc.call
|
||||||
|
},
|
||||||
|
:get_display_value => proc { |super_proc|
|
||||||
|
"" # meow >w<
|
||||||
|
},
|
||||||
|
:redraw => proc { |super_proc|
|
||||||
|
@disabled = !GamepadIcons.face_skinnable
|
||||||
|
|
||||||
|
super_proc.call
|
||||||
|
|
||||||
|
sx, sy = GamepadIcons.button(Input::GamepadButton::SOUTH, false)
|
||||||
|
wx, wy = GamepadIcons.button(Input::GamepadButton::WEST, false)
|
||||||
|
nx, ny = GamepadIcons.button(Input::GamepadButton::NORTH, false)
|
||||||
|
ex, ey = GamepadIcons.button(Input::GamepadButton::EAST, false)
|
||||||
|
if GamepadIcons.face_skinnable
|
||||||
|
sy += self.value
|
||||||
|
wy += self.value
|
||||||
|
ny += self.value
|
||||||
|
ey += self.value
|
||||||
|
end
|
||||||
|
|
||||||
|
@sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 8, PARAMETER_HEIGHT / 2 - ICON_SIZE, ICON_SIZE * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(sx * ICON_SIZE, sy * ICON_SIZE, ICON_SIZE, ICON_SIZE))
|
||||||
|
@sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 6, PARAMETER_HEIGHT / 2 - ICON_SIZE, ICON_SIZE * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(wx * ICON_SIZE, wy * ICON_SIZE, ICON_SIZE, ICON_SIZE))
|
||||||
|
@sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 4, PARAMETER_HEIGHT / 2 - ICON_SIZE, ICON_SIZE * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(nx * ICON_SIZE, ny * ICON_SIZE, ICON_SIZE, ICON_SIZE))
|
||||||
|
@sprite.bitmap.stretch_blt(Rect.new(PARAMETER_WIDTH - ICON_SIZE * 2, PARAMETER_HEIGHT / 2 - ICON_SIZE, ICON_SIZE * 2, ICON_SIZE * 2), RPG::Cache.menu("gamepad_icons"), Rect.new(ex * ICON_SIZE, ey * ICON_SIZE, ICON_SIZE, ICON_SIZE))
|
||||||
|
},
|
||||||
|
:value_set => proc { |super_proc, value|
|
||||||
|
if (value != self.value)
|
||||||
|
Audio.se_play(PARAMETER_CHANGE_AUDIO, 70, (value.to_f / @max_value.to_f * 50.0).to_i + 75)
|
||||||
|
end
|
||||||
|
super_proc.call(value)
|
||||||
|
},
|
||||||
|
:value_left => proc { |super_proc|
|
||||||
|
next if @disabled
|
||||||
|
self.value = (self.value - 1) % @max_value
|
||||||
|
@settings_content.redraw_all
|
||||||
|
},
|
||||||
|
:value_right => proc { |super_proc|
|
||||||
|
next if @disabled
|
||||||
|
self.value = (self.value + 1) % @max_value
|
||||||
|
@settings_content.redraw_all
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
:type => :bool,
|
:type => :bool,
|
||||||
:name => "Control LED lighting on gamepads",
|
:name => "Control LED lighting",
|
||||||
:parameter => :gamepad_led
|
:parameter => :gamepad_led
|
||||||
},
|
},
|
||||||
{ :type => :sep, :name => "Walk" },
|
{ :type => :sep, :name => "Walk" },
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue