Add control (default: X) to unselect current weapon
authorWuzzy <Wuzzy2@mail.ru>
Wed, 09 Jan 2019 19:39:48 +0100
changeset 14551 ec0afe1c6024
parent 14550 db646b3c0b95
child 14552 e0af4ce7d8bc
Add control (default: X) to unselect current weapon
ChangeLog.txt
QTfrontend/binds.cpp
QTfrontend/binds.h
README.md
hedgewars/uCommandHandlers.pas
hedgewars/uInputHandler.pas
hedgewars/uTypes.pas
--- a/ChangeLog.txt	Wed Jan 09 19:10:11 2019 +0100
+++ b/ChangeLog.txt	Wed Jan 09 19:39:48 2019 +0100
@@ -14,6 +14,7 @@
  + The Specialists: Unlock game scheme
  + The Specialists: Add script parameter support to set custom specialists order
  + Display player name of own teams in online games
+ + Add control to unselect current weapon (default: X)
  * Use player-chosen team identity in campaigns and singleplayer missions
  * Fix last 2 characters in demo chat being missing
  * Fix homing bee flying weird if passing wrap world edge or target was placed beyond it
--- a/QTfrontend/binds.cpp	Wed Jan 09 19:10:11 2019 +0100
+++ b/QTfrontend/binds.cpp	Wed Jan 09 19:39:48 2019 +0100
@@ -39,6 +39,7 @@
     {"slot 8",    "f8",         QT_TRANSLATE_NOOP("binds", "slot 8"),          NULL, NULL},
     {"slot 9",    "f9",         QT_TRANSLATE_NOOP("binds", "slot 9"),          NULL, NULL},
     {"slot :",    "f10",        QT_TRANSLATE_NOOP("binds", "slot 10"),         NULL, NULL},
+    {"setweap ~", "x",          QT_TRANSLATE_NOOP("binds", "unselect weapon"), NULL, NULL},
     {"timer 1",   "1",          QT_TRANSLATE_NOOP("binds", "timer 1 sec"),     NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Set the timer on bombs and timed weapons:")},
     {"timer 2",   "2",          QT_TRANSLATE_NOOP("binds", "timer 2 sec"),     NULL, NULL},
     {"timer 3",   "3",          QT_TRANSLATE_NOOP("binds", "timer 3 sec"),     NULL, NULL},
--- a/QTfrontend/binds.h	Wed Jan 09 19:10:11 2019 +0100
+++ b/QTfrontend/binds.h	Wed Jan 09 19:39:48 2019 +0100
@@ -22,9 +22,9 @@
 #include <QString>
 
 #ifdef VIDEOREC
-#define BINDS_NUMBER 51
+#define BINDS_NUMBER 52
 #else
-#define BINDS_NUMBER 50
+#define BINDS_NUMBER 51
 #endif
 
 struct BindAction
--- a/README.md	Wed Jan 09 19:10:11 2019 +0100
+++ b/README.md	Wed Jan 09 19:39:48 2019 +0100
@@ -63,6 +63,7 @@
 * Tab: Switch hedgehog (after activating the utility)
 * 1-5: Set weapon timer
 * F1-F10: Weapon shortcuts
+* X: Unselect weapon
 * M: Mission panel / game mode information. Hold pressed to display, release to hide
 * P: Pause, when playing offline, toggle automatic turn skipping when online
 * Esc: Quit with prompt
--- a/hedgewars/uCommandHandlers.pas	Wed Jan 09 19:10:11 2019 +0100
+++ b/hedgewars/uCommandHandlers.pas	Wed Jan 09 19:39:48 2019 +0100
@@ -478,6 +478,11 @@
     if CheckNoTeamOrHH then
         exit;
 
+    (* Use "~" (ASCII character 126) as synonym for NUL byte (=amNothing).
+    This is done to allow to add "setweap ~" in QTfrontend/binds.cpp because
+    the NUL byte would terminate the strings in C++ otherwise. *)
+    if (s[1] = '~') then
+        s[1]:= #0;
     if checkFails((s[0] = #1) and (s[1] <= char(High(TAmmoType))), 'Malformed /setweap', true) then exit;
 
     if not isExternalSource then
--- a/hedgewars/uInputHandler.pas	Wed Jan 09 19:10:11 2019 +0100
+++ b/hedgewars/uInputHandler.pas	Wed Jan 09 19:39:48 2019 +0100
@@ -385,6 +385,7 @@
     RegisterBind(DefaultBinds, 'f12', 'fullscr');
 
     for i:= 1 to 10 do RegisterBind(DefaultBinds, 'f'+IntToStr(i), 'slot '+char(48+i));
+    RegisterBind(DefaultBinds, 'x', 'setweap ~');
     for i:= 1 to 5  do RegisterBind(DefaultBinds, IntToStr(i), 'timer '+IntToStr(i));
     RegisterBind(DefaultBinds, _S'n', 'timer_u');
 
--- a/hedgewars/uTypes.pas	Wed Jan 09 19:10:11 2019 +0100
+++ b/hedgewars/uTypes.pas	Wed Jan 09 19:39:48 2019 +0100
@@ -168,6 +168,8 @@
             amPiano, amGasBomb, amSineGun, amFlamethrower, amSMine, amHammer, // 48
             amResurrector, amDrillStrike, amSnowball, amTardis, amLandGun, // 53
             amIceGun, amKnife, amRubber, amAirMine, amCreeper, amMinigun); // 59
+    // NOTE: If we ever reach 126 ammo types, make sure to skip ammo type number 126 because it's
+    // reserved as synonym for amNothing. See also chSetWeapon.
 
     // Different kind of crates that e.g. hedgehogs can pick up
     TCrateType = (HealthCrate, AmmoCrate, UtilityCrate);