Browse Source

TouchScreenGUI: Add an exit / "ESC" button to the rare controls bar (#13574)

Gregor Parzefall 10 months ago
parent
commit
03ffc2618c

+ 3 - 0
LICENSE.txt

@@ -87,6 +87,9 @@ DS:
   games/devtest/mods/soundstuff/sounds/soundstuff_sinus.ogg
   games/devtest/mods/testtools/textures/testtools_branding_iron.png
 
+grorp:
+  textures/base/pack/exit_btn.png
+
 License of Minetest source code
 -------------------------------
 

+ 111 - 0
android/icons/exit_btn.svg

@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   width="512"
+   height="512"
+   viewBox="0 0 135.46666 135.46667"
+   version="1.1"
+   id="svg8"
+   inkscape:version="1.2.2 (732a01da63, 2022-12-09)"
+   sodipodi:docname="exit_btn.svg"
+   inkscape:export-filename="../../textures/base/pack/exit_btn.png"
+   inkscape:export-xdpi="24.000002"
+   inkscape:export-ydpi="24.000002"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:dc="http://purl.org/dc/elements/1.1/">
+  <defs
+     id="defs10" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#404040"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.84958349"
+     inkscape:cx="-94.752312"
+     inkscape:cy="291.31922"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer2"
+     showgrid="true"
+     units="px"
+     inkscape:window-width="1920"
+     inkscape:window-height="1001"
+     inkscape:window-x="-9"
+     inkscape:window-y="-9"
+     inkscape:window-maximized="1"
+     inkscape:pagecheckerboard="false"
+     inkscape:snap-grids="true"
+     inkscape:snap-page="true"
+     showguides="false"
+     inkscape:showpageshadow="2"
+     inkscape:deskcolor="#404040">
+    <inkscape:grid
+       type="xygrid"
+       id="grid16"
+       spacingx="0.26458333"
+       spacingy="0.26458333"
+       empspacing="4"
+       color="#40ff40"
+       opacity="0.1254902"
+       empcolor="#40ff40"
+       empopacity="0.25098039" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata5">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <cc:license
+           rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
+      </cc:Work>
+      <cc:License
+         rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#Reproduction" />
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#Distribution" />
+        <cc:requires
+           rdf:resource="http://creativecommons.org/ns#Notice" />
+        <cc:requires
+           rdf:resource="http://creativecommons.org/ns#Attribution" />
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+        <cc:requires
+           rdf:resource="http://creativecommons.org/ns#ShareAlike" />
+      </cc:License>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:groupmode="layer"
+     id="layer2"
+     inkscape:label="Layer 2"
+     style="display:inline">
+    <path
+       id="rect5028"
+       style="display:inline;fill:none;stroke:#ffffff;stroke-width:5.99996;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none"
+       d="m 78.052082,90.48746 v 17.4625 l -50.535415,4e-5 V 27.516667 l 50.535415,3.7e-5 v 17.462423"
+       sodipodi:nodetypes="cccccc" />
+    <path
+       style="display:inline;fill:none;stroke:#ffffff;stroke-width:5.99996;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="m 101.49853,55.033202 12.69966,12.700052 -12.69966,12.699942"
+       id="path4737"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="ccc" />
+    <path
+       style="display:inline;fill:none;stroke:#ffffff;stroke-width:6;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 113.36416,67.733332 H 59.484405"
+       id="path4729"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cc" />
+  </g>
+</svg>

+ 1 - 0
doc/texture_packs.md

@@ -152,6 +152,7 @@ are placeholders intended to be overwritten by the game.
 * `debug_btn.png`
 * `gear_icon.png`
 * `rare_controls.png`
+* `exit_btn.png`
 
 Texture Overrides
 -----------------

+ 7 - 1
src/gui/touchscreengui.cpp

@@ -50,6 +50,11 @@ const char **joystick_imagenames = (const char *[]) {
 
 static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
 {
+	// ESC isn't part of the keymap.
+	if (id == exit_id) {
+		return KEY_ESCAPE;
+	}
+
 	std::string key = "";
 	switch (id) {
 		case inventory_id:
@@ -548,9 +553,10 @@ void TouchScreenGUI::init(ISimpleTextureSource *tsrc)
 				+ (0.5 * button_size)),
 		AHBB_Dir_Left_Right, 2.0);
 
-	m_rarecontrolsbar.addButton(chat_id,      L"Chat", "chat_btn.png");
+	m_rarecontrolsbar.addButton(chat_id,      L"chat", "chat_btn.png");
 	m_rarecontrolsbar.addButton(inventory_id, L"inv",  "inventory_btn.png");
 	m_rarecontrolsbar.addButton(drop_id,      L"drop", "drop_btn.png");
+	m_rarecontrolsbar.addButton(exit_id,      L"exit", "exit_btn.png");
 
 	m_initialized = true;
 }

+ 1 - 0
src/gui/touchscreengui.h

@@ -54,6 +54,7 @@ typedef enum
 	chat_id,
 	inventory_id,
 	drop_id,
+	exit_id,
 	joystick_off_id,
 	joystick_bg_id,
 	joystick_center_id

BIN
textures/base/pack/exit_btn.png