From c9bd84eaf290ff62b9b56439ad9caabfb2bc5015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ritzl?= Date: Mon, 23 Dec 2024 12:31:13 +0100 Subject: [PATCH] Added example --- api.json | 81 ++++++++++ api.md | 29 ++++ examples/utils/utils.gui | 259 +++++++------------------------- examples/utils/utils.gui_script | 8 + steam/api/steam.script_api | 45 ++++++ steam/src/steam.cpp | 15 ++ 6 files changed, 233 insertions(+), 204 deletions(-) diff --git a/api.json b/api.json index 2ae82dc..fff5963 100644 --- a/api.json +++ b/api.json @@ -1422,6 +1422,87 @@ ], "summary": "Returns the Steam server time in Unix epoch format. (Number of seconds since Jan 1, 1970 UTC)", "usage": null + }, + { + "description": "", + "has_params": true, + "has_returns": true, + "name": "utils_show_floating_gamepad_text_input", + "params": [ + { + "description": "EFloatingGamepadTextInputMode", + "name": "mode", + "type": "number" + }, + { + "description": "Text field x position", + "name": "x", + "type": "number" + }, + { + "description": "Text field y position", + "name": "y", + "type": "number" + }, + { + "description": "Text field width", + "name": "width", + "type": "number" + }, + { + "description": "Text field height", + "name": "height", + "type": "number" + } + ], + "params_string": "mode,x,y,width,height", + "returns": [ + { + "description": "True if the floating keyboard was shown, otherwise, false.", + "name": "result", + "type": "bool" + } + ], + "summary": "Opens a floating keyboard over the game content and sends OS keyboard keys directly to the game.", + "usage": null + }, + { + "description": "", + "has_params": true, + "has_returns": true, + "name": "utils_show_gamepad_text_input", + "params": [ + { + "description": "EGamepadTextInputMode", + "name": "input_mode", + "type": "number" + }, + { + "description": "EGamepadTextInputLineMode", + "name": "line_input_mode", + "type": "number" + }, + { + "description": "Sets the description that should inform the user what the input dialog is for", + "name": "description", + "type": "string" + }, + { + "description": "Sets the preexisting text which the user can edit.", + "name": "existing_text", + "type": "string" + } + ], + "params_string": "input_mode,line_input_mode,description,existing_text", + "returns": [ + { + "description": "True if the big picture overlay is running; otherwise, false", + "name": "result", + "type": "bool" + } + ], + "summary": "Activates the Big Picture text input dialog which only supports gamepad input.", + "usage": null } ], "filename": "steam/src/steam_utils.cpp", diff --git a/api.md b/api.md index 9d13745..9f792ec 100644 --- a/api.md +++ b/api.md @@ -675,5 +675,34 @@ RETURNS * `Server` [`number`] - Time +### utils_show_floating_gamepad_text_input(mode,x,y,width,height) +Opens a floating keyboard over the game content and sends OS keyboard keys directly to the game. + + +PARAMS +* `mode` [`number`] - EFloatingGamepadTextInputMode +* `x` [`number`] - Text field x position +* `y` [`number`] - Text field y position +* `width` [`number`] - Text field width +* `height` [`number`] - Text field height + +RETURNS +* `result` [`bool`] - True if the floating keyboard was shown, otherwise, false. + + +### utils_show_gamepad_text_input(input_mode,line_input_mode,description,existing_text) +Activates the Big Picture text input dialog which only supports gamepad input. + + +PARAMS +* `input_mode` [`number`] - EGamepadTextInputMode +* `line_input_mode` [`number`] - EGamepadTextInputLineMode +* `description` [`string`] - Sets the description that should inform the user what the input dialog is for +* `existing_text` [`string`] - Sets the preexisting text which the user can edit. + +RETURNS +* `result` [`bool`] - True if the big picture overlay is running; otherwise, false + + --- diff --git a/examples/utils/utils.gui b/examples/utils/utils.gui index f155860..8efcb46 100644 --- a/examples/utils/utils.gui +++ b/examples/utils/utils.gui @@ -7,52 +7,18 @@ textures { name: "rpg" texture: "/gooey/themes/rpg/images/rpg.atlas" } -background_color { - x: 0.0 - y: 0.0 - z: 0.0 - w: 0.0 -} nodes { position { x: 163.0 y: 448.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } size { x: 300.0 y: 400.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA texture: "rpg/panel_blue" id: "panel" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - layer: "" inherit_alpha: true slice9 { x: 24.0 @@ -60,234 +26,120 @@ nodes { z: 24.0 w: 24.0 } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 - template_node_child: false - size_mode: SIZE_MODE_MANUAL } nodes { position { x: -136.0 y: 188.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } size { x: 200.0 y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA text: "" font: "rpg" id: "info" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE pivot: PIVOT_NW outline { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } shadow { x: 1.0 y: 1.0 z: 1.0 - w: 1.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false parent: "panel" - layer: "" inherit_alpha: true - alpha: 1.0 - outline_alpha: 1.0 - shadow_alpha: 1.0 - template_node_child: false - text_leading: 1.0 - text_tracking: 0.0 } nodes { position { x: 71.0 y: 683.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - size { - x: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_TEMPLATE id: "back" - layer: "" inherit_alpha: true - alpha: 1.0 template: "/gooey/themes/rpg/components/button.gui" - template_node_child: false } nodes { - position { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } size { x: 120.0 y: 49.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 } type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "rpg/buttonSquare_blue" id: "back/bg" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT parent: "back" - layer: "below" - inherit_alpha: true - slice9 { - x: 8.0 - y: 20.0 - z: 8.0 - w: 20.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false - alpha: 1.0 overridden_fields: 4 template_node_child: true - size_mode: SIZE_MODE_MANUAL +} +nodes { + type: TYPE_TEXT + text: "< BACK" + id: "back/label" + parent: "back/bg" + overridden_fields: 8 + template_node_child: true } nodes { position { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - rotation { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - scale { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 + x: 427.0 + y: 599.0 } + type: TYPE_TEMPLATE + id: "floating_text" + inherit_alpha: true + template: "/gooey/themes/rpg/components/button.gui" +} +nodes { size { - x: 200.0 - y: 100.0 - z: 0.0 - w: 1.0 - } - color { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 + x: 120.0 + y: 49.0 } + type: TYPE_BOX + id: "floating_text/bg" + parent: "floating_text" + overridden_fields: 4 + template_node_child: true +} +nodes { type: TYPE_TEXT - blend_mode: BLEND_MODE_ALPHA - text: "< BACK" - font: "rpg" - id: "back/label" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 0.0 - y: 0.0 - z: 0.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 + text: "FLOATING TEXT" + id: "floating_text/label" + parent: "floating_text/bg" + overridden_fields: 8 + template_node_child: true +} +nodes { + position { + x: 427.0 + y: 486.0 } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "back/bg" - layer: "text" + type: TYPE_TEMPLATE + id: "gamepad_text" inherit_alpha: true - alpha: 1.0 - outline_alpha: 0.0 - shadow_alpha: 1.0 + template: "/gooey/themes/rpg/components/button.gui" +} +nodes { + size { + x: 120.0 + y: 49.0 + } + type: TYPE_BOX + id: "gamepad_text/bg" + parent: "gamepad_text" + overridden_fields: 4 + template_node_child: true +} +nodes { + type: TYPE_TEXT + text: "GAMEPAD TEXT" + id: "gamepad_text/label" + parent: "gamepad_text/bg" overridden_fields: 8 template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 } layers { name: "below" @@ -297,4 +149,3 @@ layers { } material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT -max_nodes: 512 diff --git a/examples/utils/utils.gui_script b/examples/utils/utils.gui_script index 56eb20f..3b84957 100644 --- a/examples/utils/utils.gui_script +++ b/examples/utils/utils.gui_script @@ -34,4 +34,12 @@ function on_input(self, action_id, action) rpg.button("back", action_id, action, function() monarch.back() end) + rpg.button("floating_text", action_id, action, function() + local ok = steam.utils_show_floating_gamepad_text_input(steam.EFloatingGamepadTextInputModeModeSingleLine, 10, 10, 100, 100) + print(ok) + end) + rpg.button("gamepad_text", action_id, action, function() + local ok = steam.utils_show_gamepad_text_input(steam.EGamepadTextInputModeNormal, steam.EGamepadTextInputLineModeSingleLine, "Some description", "Existing text") + print(ok) + end) end \ No newline at end of file diff --git a/steam/api/steam.script_api b/steam/api/steam.script_api index 96c9729..f5d66d1 100644 --- a/steam/api/steam.script_api +++ b/steam/api/steam.script_api @@ -655,3 +655,48 @@ type: number desc: Time + - name: utils_show_floating_gamepad_text_input + type: function + desc: Opens a floating keyboard over the game content and sends OS keyboard keys directly to the game. + parameters: + - name: mode + type: number + desc: EFloatingGamepadTextInputMode + - name: x + type: number + desc: Text field x position + - name: y + type: number + desc: Text field y position + - name: width + type: number + desc: Text field width + - name: height + type: number + desc: Text field height + returns: + - name: result + type: bool + desc: True if the floating keyboard was shown, otherwise, false. + + - name: utils_show_gamepad_text_input + type: function + desc: Activates the Big Picture text input dialog which only supports gamepad input. + parameters: + - name: input_mode + type: number + desc: EGamepadTextInputMode + - name: line_input_mode + type: number + desc: EGamepadTextInputLineMode + - name: description + type: string + desc: Sets the description that should inform the user what the input dialog is for + - name: existing_text + type: string + desc: Sets the preexisting text which the user can edit. + returns: + - name: result + type: bool + desc: True if the big picture overlay is running; otherwise, false + diff --git a/steam/src/steam.cpp b/steam/src/steam.cpp index c43b1a6..9e1a399 100644 --- a/steam/src/steam.cpp +++ b/steam/src/steam.cpp @@ -287,6 +287,21 @@ static void LuaInit(lua_State* L) SETCONSTANT(EGamepadTextInputModePassword, k_EGamepadTextInputModePassword); + // + // EGamepadTextInputLineMode + // + /** + * Single line text + * @field EGamepadTextInputLineModeSingleLine + */ + SETCONSTANT(EGamepadTextInputLineModeSingleLine, k_EGamepadTextInputLineModeSingleLine); + /** + * Multi line text + * @field EGamepadTextInputLineModeMultipleLines + */ + SETCONSTANT(EGamepadTextInputLineModeMultipleLines, k_EGamepadTextInputLineModeMultipleLines); + + // // ELeaderboardDataRequest //