diff game/js/input.js @ 24:3f2811aebb3d 0.9.0

splash screen buttons, help button, info screen
author ark
date 2026-10-20 15:58 +0200
parents fe680946164b
children 85d23328a215
line wrap: on
line diff
--- a/game/js/input.js	Tue Oct 20 12:04:42 2026 +0200
+++ b/game/js/input.js	Tue Oct 20 15:58:17 2026 +0200
@@ -80,9 +80,11 @@
         return { x: mx, y: my };
     }
 
-    // a press at css position x, y. buttons and tower selection act at once.
-    // a press on the map while a shop tower is chosen returns the drag that
-    // places the preview:
+    // a press at css position x, y. buttons and tower selection act at once,
+    // apart from the logo and the email address on the help popup: tablets
+    // open a new tab only when the finger is lifted, so the press on either
+    // returns {game, button} and the release acts. a press on the map while a shop tower is chosen returns
+    // the drag that places the preview:
     //   game      the game it belongs to
     //   onPreview the press was on the preview; it builds on release unless
     //             the pointer moved further than DRAG_SLOP
@@ -104,10 +106,13 @@
             // the tower menu closes it
             if (b.id !== "sell") game.sellArmed = false;
             if (b.id !== "sell" && b.id !== "upgrade") game.selected = null;
+            if (b.id === "logo" || b.id === "email") return { game: game, button: b.id };
             if (b.id === "play") app.play();
             else if (b.id === "next") app.next();
             else if (b.id === "retry") app.retry();
             else if (b.id === "restart") app.restart();
+            else if (b.id === "help") game.openHelp();
+            else if (b.id === "close_help") game.closeHelp();
             else if (b.id === "pause") game.togglePause();
             else if (b.id === "speed") game.speedIndex = (game.speedIndex + 1) % game.speeds.length;
             else if (b.id === "early") game.startEarly();
@@ -141,7 +146,7 @@
     // the pointer of a drag moved to css position x, y
     function move(app, d, x, y) {
         var game = app.game();
-        if (game !== d.game || game.result || !game.shop) return;
+        if (d.button || game !== d.game || game.result || !game.shop) return;
         if (!d.moved && Math.hypot(x - d.sx, y - d.sy) <= DRAG_SLOP) {
             // a press on the preview stays a tap until it moves far enough
             if (d.onPreview) return;
@@ -152,10 +157,22 @@
         if (m && game.movePreview(m.x + d.dx, m.y + d.dy)) d.found = true;
     }
 
-    // the pointer of a drag was released at css position x, y. a tap on the
-    // preview builds; a drag that never found a legal position is refused
+    // the pointer of a drag was released at css position x, y. the logo
+    // opens its web page and the email address a new mail when the pointer
+    // is still on it. a tap on the preview builds; a drag that never found a
+    // legal position is refused
     function release(app, d, x, y) {
         var game = app.game(), L = app.layout();
+        if (d.button) {
+            var b = MM.ui.hit(game, L, x, y), links = MM.config.links;
+            if (!b || b.id !== d.button) return;
+            if (b.id === "logo" && links.logo_url) window.open(links.logo_url, "_blank", "noopener");
+            if (b.id === "email") {
+                window.location.href = "mailto:" + links.email + "?subject=" +
+                    encodeURIComponent(links.email_subject);
+            }
+            return;
+        }
         if (game !== d.game || game.result || game.paused) return;
         var ok = d.onPreview && !d.moved ? game.build() : d.found;
         if (ok) return;