Skip to content

Commit

Permalink
Improved gamepad navigation in the game UI (#943)
Browse files Browse the repository at this point in the history
Support for stick navigation
  • Loading branch information
Xottab-DUTY committed Jan 9, 2025
1 parent 4f21c2b commit eabe172
Show file tree
Hide file tree
Showing 21 changed files with 162 additions and 58 deletions.
6 changes: 3 additions & 3 deletions res/gamedata/configs/ui/ui_mm_load_dlg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
<list x="33" y="215" width="497" height="173" item_height="18" can_select="1">
<font font="letterica16"/>
</list>
<btn_load x="65" y="427" width="135" height="26">
<btn_load x="65" y="427" width="135" height="26" accel="ui_accept">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_load</text>
</btn_load>
<btn_delete x="221" y="427" width="135" height="26">
<btn_delete x="221" y="427" width="135" height="26" accel="ui_action_1">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_delete</text>
</btn_delete>
<btn_cancel x="377" y="427" width="135" height="26">
<btn_cancel x="377" y="427" width="135" height="26" accel="ui_back">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_cancel</text>
</btn_cancel>
Expand Down
6 changes: 3 additions & 3 deletions res/gamedata/configs/ui/ui_mm_load_dlg_16.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
<list x="26" y="215" width="417" height="173" item_height="18" can_select="1">
<font font="letterica16"/>
</list>
<btn_load x="54" y="427" width="108" height="26" stretch="1">
<btn_load x="54" y="427" width="108" height="26" stretch="1" accel="ui_accept">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_load</text>
</btn_load>
<btn_delete x="184" y="427" width="108" height="26" stretch="1">
<btn_delete x="184" y="427" width="108" height="26" stretch="1" accel="ui_action_1">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_delete</text>
</btn_delete>
<btn_cancel x="314" y="427" width="108" height="26" stretch="1">
<btn_cancel x="314" y="427" width="108" height="26" stretch="1" accel="ui_back">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_cancel</text>
</btn_cancel>
Expand Down
28 changes: 14 additions & 14 deletions res/gamedata/configs/ui/ui_mm_opt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,48 @@
</auto_static>
</dialog>

<btn_accept x="105" y="431" width="135" height="26">
<btn_accept x="105" y="431" width="135" height="26" accel="ui_accept">
<text font="letterica18" align="c">ui_mm_apply</text>
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text_color>
<e r="170" g="170" b="170"/>
</text_color>
</btn_accept>

<btn_cancel x="246" y="431" width="135" height="26">
<btn_cancel x="246" y="431" width="135" height="26" accel="ui_back">
<text font="letterica18" align="c">ui_mm_cancel</text>
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text_color>
<e r="170" g="170" b="170"/>
</text_color>
</btn_cancel>

<tab x="14" y="27" width="461" height="38">
<button x="2" y="2" width="131" height="25" id="video">
<tab x="14" y="27" width="461" height="38" accelerators="1">
<button x="2" y="2" width="131" height="25" id="video" accel="ui_button_1">
<texture>ui_inGame2_opt_button_1</texture>
<text font="letterica18" align="c">ui_mm_video</text>
<text_color>
<e r="200" g="200" b="200"/>
</text_color>
</button>

<button x="111" y="2" width="131" height="25" id="sound">
<button x="111" y="2" width="131" height="25" id="sound" accel="ui_button_2">
<texture>ui_inGame2_opt_button_1</texture>
<text font="letterica18" align="c">ui_mm_sound</text>
<text_color>
<e r="200" g="200" b="200"/>
</text_color>
</button>

<button x="221" y="2" width="131" height="25" id="gameplay">
<button x="221" y="2" width="131" height="25" id="gameplay" accel="ui_button_3">
<texture>ui_inGame2_opt_button_1</texture>
<text font="letterica18" align="c">ui_mm_gameplay</text>
<text_color>
<e r="200" g="200" b="200"/>
</text_color>
</button>

<button x="330" y="2" width="129" height="25" id="controls">
<button x="330" y="2" width="129" height="25" id="controls" accel="ui_button_4">
<texture>ui_inGame2_opt_button_2</texture>
<text font="letterica18" align="c">ui_mm_controls</text>
<text_color>
Expand Down Expand Up @@ -165,7 +165,7 @@
<options_item entry="rs_c_brightness" group="mm_opt_video" depend="runtime"/>
</track_brightness>

<btn_advanced x="338" y="322" width="108" height="24">
<btn_advanced x="338" y="322" width="108" height="24" accel="ui_action_1">
<text align="c" font="letterica16">ui_mm_advanced</text>
<texture>ui_inGame2_button</texture>
<text_color>
Expand Down Expand Up @@ -523,7 +523,7 @@
<options_item entry="r4_enable_tessellation" group="mm_opt_video_adv" depend="vid"/>
</check_r4_tessellation>

<btn_to_simply x="338" y="322" width="108" height="24">
<btn_to_simply x="338" y="322" width="108" height="24" accel="ui_action_1">
<text align="c" font="letterica16">ui_mm_simply</text>
<texture>ui_inGame2_button</texture>
<text_color>
Expand Down Expand Up @@ -806,15 +806,15 @@
</scroll_view>
</key_binding>

<btn_default x="338" y="322" width="108" height="24">
<btn_default x="338" y="322" width="108" height="24" accel="ui_action_2">
<text align="c" font="letterica16">ui_mm_default</text>
<texture>ui_inGame2_button</texture>
<text_color>
<e r="210" g="210" b="210"/>
</text_color>
</btn_default>

<btn_advanced x="201" y="322" width="133" height="24" stretch="1">
<btn_advanced x="201" y="322" width="133" height="24" stretch="1" accel="ui_action_1">
<text align="c" font="letterica16">ui_mm_gamepad_setup</text>
<texture>ui_inGame2_button</texture>
<text_color>
Expand Down Expand Up @@ -860,15 +860,15 @@
</scroll_view>
</key_binding_gamepad>

<btn_default x="338" y="322" width="108" height="24" stretch="1">
<btn_default x="338" y="322" width="108" height="24" stretch="1" accel="ui_action_2">
<text align="c" font="letterica16">ui_mm_default</text>
<texture>ui_inGame2_button</texture>
<text_color>
<e r="210" g="210" b="210"/>
</text_color>
</btn_default>

<btn_controls x="191" y="322" width="143" height="24" stretch="1">
<btn_controls x="191" y="322" width="143" height="24" stretch="1" accel="ui_action_1">
<text align="c" font="letterica16">ui_mm_keyboard_setup</text>
<texture>ui_inGame2_button</texture>
<text_color>
Expand Down Expand Up @@ -896,6 +896,6 @@
<text_color>
<e r="170" g="170" b="170"/>
</text_color>
<texture>ui_button_ordinary</texture>
<texture>ui_buttonordinary</texture>
</btn_cancel_download>
</w>
26 changes: 13 additions & 13 deletions res/gamedata/configs/ui/ui_mm_opt_16.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,48 @@
</auto_static>
</dialog>

<btn_accept x="84" y="431" width="108" height="26" stretch="1">
<btn_accept x="84" y="431" width="108" height="26" stretch="1" accel="ui_accept">
<text font="letterica18" align="c">ui_mm_apply</text>
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text_color>
<e r="170" g="170" b="170"/>
</text_color>
</btn_accept>

<btn_cancel x="196" y="431" width="108" height="26" stretch="1">
<btn_cancel x="196" y="431" width="108" height="26" stretch="1" accel="ui_back">
<text font="letterica18" align="c">ui_mm_cancel</text>
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text_color>
<e r="170" g="170" b="170"/>
</text_color>
</btn_cancel>

<tab x="11" y="27" width="368" height="38">
<button x="1" y="2" width="105" height="25" id="video" stretch="1">
<tab x="11" y="27" width="368" height="38" accelerators="1">
<button x="1" y="2" width="105" height="25" id="video" stretch="1" accel="ui_button_1">
<texture>ui_inGame2_opt_button_1</texture>
<text font="letterica18" align="c">ui_mm_video</text>
<text_color>
<e r="200" g="200" b="200"/>
</text_color>
</button>

<button x="89" y="2" width="104" height="25" id="sound" stretch="1">
<button x="89" y="2" width="104" height="25" id="sound" stretch="1" accel="ui_button_2">
<texture>ui_inGame2_opt_button_1</texture>
<text font="letterica18" align="c">ui_mm_sound</text>
<text_color>
<e r="200" g="200" b="200"/>
</text_color>
</button>

<button x="176" y="2" width="105" height="25" id="gameplay" stretch="1">
<button x="176" y="2" width="105" height="25" id="gameplay" stretch="1" accel="ui_button_3">
<texture>ui_inGame2_opt_button_1</texture>
<text font="letterica18" align="c">ui_mm_gameplay</text>
<text_color>
<e r="200" g="200" b="200"/>
</text_color>
</button>

<button x="264" y="2" width="103" height="25" id="controls" stretch="1">
<button x="264" y="2" width="103" height="25" id="controls" stretch="1" accel="ui_button_4">
<texture>ui_inGame2_opt_button_2</texture>
<text font="letterica18" align="c">ui_mm_controls</text>
<text_color>
Expand Down Expand Up @@ -168,7 +168,7 @@
<options_item entry="rs_c_brightness" group="mm_opt_video" depend="runtime"/>
</track_brightness>

<btn_advanced x="270" y="322" width="86" height="24" stretch="1">
<btn_advanced x="270" y="322" width="86" height="24" stretch="1" accel="ui_action_1">
<text r="170" g="170" b="170" align="c" font="letterica16">ui_mm_advanced</text>
<texture>ui_inGame2_button</texture>
<text_color>
Expand Down Expand Up @@ -526,7 +526,7 @@
<options_item entry="r4_enable_tessellation" group="mm_opt_video_adv" depend="vid"/>
</check_r4_tessellation>

<btn_to_simply x="270" y="322" width="86" height="24" stretch="1">
<btn_to_simply x="270" y="322" width="86" height="24" stretch="1" accel="ui_action_1">
<text align="c" font="letterica16">ui_mm_simply</text>
<texture>ui_inGame2_button</texture>
<text_color>
Expand Down Expand Up @@ -808,15 +808,15 @@
</scroll_view>
</key_binding>

<btn_default x="270" y="322" width="86" height="24" stretch="1">
<btn_default x="270" y="322" width="86" height="24" stretch="1" accel="ui_action_2">
<text align="c" font="letterica16">ui_mm_default</text>
<texture>ui_inGame2_button</texture>
<text_color>
<e r="210" g="210" b="210"/>
</text_color>
</btn_default>

<btn_advanced x="156" y="322" width="110" height="24" stretch="1">
<btn_advanced x="156" y="322" width="110" height="24" stretch="1" accel="ui_action_1">
<text align="c" font="letterica16">ui_mm_gamepad_setup</text>
<texture>ui_inGame2_button</texture>
<text_color>
Expand Down Expand Up @@ -862,15 +862,15 @@
</scroll_view>
</key_binding_gamepad>

<btn_default x="270" y="322" width="86" height="24" stretch="1">
<btn_default x="270" y="322" width="86" height="24" stretch="1" accel="ui_action_2">
<text align="c" font="letterica16">ui_mm_default</text>
<texture>ui_inGame2_button</texture>
<text_color>
<e r="210" g="210" b="210"/>
</text_color>
</btn_default>

<btn_controls x="150" y="322" width="116" height="24" stretch="1">
<btn_controls x="150" y="322" width="116" height="24" stretch="1" accel="ui_action_1">
<text align="c" font="letterica16">ui_mm_keyboard_setup</text>
<texture>ui_inGame2_button</texture>
<text_color>
Expand Down
6 changes: 3 additions & 3 deletions res/gamedata/configs/ui/ui_mm_save_dlg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
<list x="33" y="110" width="497" height="273" item_height="18" can_select="1">
<font font="letterica16"/>
</list>
<btn_save x="65" y="427" width="135" height="26">
<btn_save x="65" y="427" width="135" height="26" accel="ui_accept">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_save</text>
</btn_save>
<btn_delete x="221" y="427" width="135" height="26">
<btn_delete x="221" y="427" width="135" height="26" accel="ui_action_1">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_delete</text>
<text_color>
</text_color>
</btn_delete>
<btn_cancel x="377" y="427" width="135" height="26">
<btn_cancel x="377" y="427" width="135" height="26" accel="ui_back">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_cancel</text>
<text_color>
Expand Down
6 changes: 3 additions & 3 deletions res/gamedata/configs/ui/ui_mm_save_dlg_16.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
<list x="26" y="110" width="417" height="273" item_height="18" can_select="1">
<font font="letterica16"/>
</list>
<btn_save x="54" y="427" width="108" height="26" stretch="1">
<btn_save x="54" y="427" width="108" height="26" stretch="1" accel="ui_accept">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_save</text>
</btn_save>
<btn_delete x="184" y="427" width="108" height="26" stretch="1">
<btn_delete x="184" y="427" width="108" height="26" stretch="1" accel="ui_action_1">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_delete</text>
</btn_delete>
<btn_cancel x="314" y="427" width="108" height="26" stretch="1">
<btn_cancel x="314" y="427" width="108" height="26" stretch="1" accel="ui_back">
<texture>ui_inGame2_Mp_bigbuttone</texture>
<text font="letterica18">ui_mm_cancel</text>
</btn_cancel>
Expand Down
8 changes: 6 additions & 2 deletions res/gamedata/scripts/ui_load_dialog.script
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,20 @@ function load_dialog:OnButton_del_clicked()
end

function load_dialog:OnKeyboard(dik, keyboard_action) --virtual function
CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
if CUIScriptWnd.OnKeyboard(self,dik,keyboard_action) then
return true
end
local bind = dik_to_bind(dik)
if bind == key_bindings.kQUIT then
self:OnButton_back_clicked()
return true
else
if bind == key_bindings.kENTER and keyboard_action == ui_events.WINDOW_KEY_PRESSED then
self:OnButton_load_clicked()
return true
end
end
return true
return false
end

function load_dialog:AddItemToList(file_name, date_time)
Expand Down
5 changes: 4 additions & 1 deletion res/gamedata/scripts/ui_main_menu.script
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ function main_menu:Dispatch(cmd, param) --virtual function
end

function main_menu:OnKeyboard(dik, keyboard_action) --virtual function
CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
if CUIScriptWnd.OnKeyboard(self,dik,keyboard_action) then
return true
end

local bind = dik_to_bind(dik)
local console = get_console()

Expand Down
10 changes: 8 additions & 2 deletions res/gamedata/scripts/ui_mm_mp_gamespy.script
Original file line number Diff line number Diff line change
Expand Up @@ -393,31 +393,37 @@ function gamespy_page:OnMsgNo()
end

function gamespy_page:OnKeyboard(dik, keyboard_action)
CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
if CUIScriptWnd.OnKeyboard(self,dik,keyboard_action) then
return true
end

local bind = dik_to_bind(dik)
local console = get_console()

if keyboard_action == ui_events.WINDOW_KEY_RELEASED then
if dik == DIK_keys.DIK_LCONTROL then
ctrl = false
return true
end
elseif keyboard_action == ui_events.WINDOW_KEY_PRESSED then
if dik == DIK_keys.DIK_LCONTROL then
ctrl = true
return true
elseif bind == key_bindings.kQUIT then
self:OnBtnCancel()
return true
elseif bind == key_bindings.kSCORES then
if(ctrl) then
if(self.active_page=="login_page") then
self:OnBtnShowCreateAccountPage()
else
self:OnBtnLogin()
end
return true
end
end
end
return true
return false
end

function gamespy_page:OnEditLPEmailChanged()
Expand Down
Loading

0 comments on commit eabe172

Please sign in to comment.