]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/keybinder.qc
Shorten a few names
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / keybinder.qc
index 3cb20d3018dfaa69b20c0ac3867dd62f98d01992..69734ef18e18b44efe30f5494bc67774b095a492 100644 (file)
@@ -1,6 +1,6 @@
 #include "keybinder.qh"
 
-#include <common/weapons/all.qh>
+#include <common/weapons/_all.qh>
 .int flags;
 
 #include "button.qh"
@@ -10,21 +10,21 @@ const string KEY_NOT_BOUND_CMD = "// not bound";
 
 const int MAX_KEYS_PER_FUNCTION = 2;
 const int MAX_KEYBINDS = 256;
-string Xonotic_KeyBinds_Functions[MAX_KEYBINDS];
-string Xonotic_KeyBinds_Descriptions[MAX_KEYBINDS];
-int Xonotic_KeyBinds_Count = -1;
+string KeyBinds_Functions[MAX_KEYBINDS];
+string KeyBinds_Descriptions[MAX_KEYBINDS];
+int KeyBinds_Count = -1;
 
-void Xonotic_KeyBinds_Read()
+void KeyBinds_Read()
 {
-       Xonotic_KeyBinds_Count = 0;
+       KeyBinds_Count = 0;
 
-       #define KEYBIND_DEF(func, desc) MACRO_BEGIN \
-               if((Xonotic_KeyBinds_Count < MAX_KEYBINDS)) { \
-                       Xonotic_KeyBinds_Functions[Xonotic_KeyBinds_Count] = strzone(func); \
-                       Xonotic_KeyBinds_Descriptions[Xonotic_KeyBinds_Count] = strzone(desc); \
-                       ++Xonotic_KeyBinds_Count; \
+       #define KEYBIND_DEF(func, desc) MACRO_BEGIN \
+               if((KeyBinds_Count < MAX_KEYBINDS)) { \
+                       KeyBinds_Functions[KeyBinds_Count] = strzone(func); \
+                       KeyBinds_Descriptions[KeyBinds_Count] = strzone(desc); \
+                       ++KeyBinds_Count; \
                } \
-       MACRO_END
+       MACRO_END
 
        KEYBIND_DEF(""                                      , _("Moving"));
        KEYBIND_DEF("+forward"                              , _("forward"));
@@ -34,34 +34,35 @@ void Xonotic_KeyBinds_Read()
        KEYBIND_DEF("+jump"                                 , _("jump / swim"));
        KEYBIND_DEF("+crouch"                               , _("crouch / sink"));
        KEYBIND_DEF("+hook"                                 , _("off-hand hook"));
-       KEYBIND_DEF("+jetpack"                              , _("jet pack"));
+       KEYBIND_DEF("+jetpack"                              , _("jetpack"));
        KEYBIND_DEF(""                                      , "");
        KEYBIND_DEF(""                                      , _("Attacking"));
        KEYBIND_DEF("+fire"                                 , _("primary fire"));
        KEYBIND_DEF("+fire2"                                , _("secondary fire"));
        KEYBIND_DEF(""                                      , "");
-       KEYBIND_DEF(""                                      , _("Weapon switching"));
-       KEYBIND_DEF("weapprev"                              , _("previous"));
-       KEYBIND_DEF("weapnext"                              , _("next"));
-       KEYBIND_DEF("weaplast"                              , _("previously used"));
-       KEYBIND_DEF("weapbest"                              , _("best"));
+       KEYBIND_DEF(""                                      , _("Weapons"));
+       KEYBIND_DEF("weapprev"                              , CTX(_("WEAPON^previous")));
+       KEYBIND_DEF("weapnext"                              , CTX(_("WEAPON^next")));
+       KEYBIND_DEF("weaplast"                              , CTX(_("WEAPON^previously used")));
+       KEYBIND_DEF("weapbest"                              , CTX(_("WEAPON^best")));
        KEYBIND_DEF("reload"                                , _("reload"));
+       KEYBIND_DEF("dropweapon"                            , _("drop weapon / throw nade"));
 
        int i;
 
        #define ADD_TO_W_LIST(pred) \
-               FOREACH(Weapons, it != WEP_Null, LAMBDA( \
+               FOREACH(Weapons, it != WEP_Null, { \
                        if (it.impulse != imp) continue; \
                        if (!(pred)) continue; \
                        w_list = strcat(w_list, it.m_name, " / "); \
-               ))
+               })
 
        for(int imp = 1; imp <= 9; ++imp)
        {
-        string w_list = "";
-               ADD_TO_W_LIST(!(it.flags & WEP_FLAG_MUTATORBLOCKED) && !(it.flags & WEP_FLAG_SUPERWEAPON));
-               ADD_TO_W_LIST(it.flags & WEP_FLAG_SUPERWEAPON);
-               ADD_TO_W_LIST(it.flags & WEP_FLAG_MUTATORBLOCKED);
+               string w_list = "";
+               ADD_TO_W_LIST(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_HIDDEN) && !(it.spawnflags & WEP_FLAG_SUPERWEAPON));
+               ADD_TO_W_LIST((it.spawnflags & WEP_FLAG_SUPERWEAPON) && !(it.spawnflags & WEP_FLAG_HIDDEN));
+               ADD_TO_W_LIST((it.spawnflags & WEP_FLAG_MUTATORBLOCKED) && !(it.spawnflags & WEP_FLAG_HIDDEN));
                if(w_list)
                        KEYBIND_DEF(strcat("weapon_group_", itos(imp)), substring(w_list, 0, -4));
                if(imp == 0)
@@ -78,6 +79,8 @@ void Xonotic_KeyBinds_Read()
        KEYBIND_DEF("+showscores"                           , _("show scores"));
        KEYBIND_DEF("screenshot"                            , _("screen shot"));
        KEYBIND_DEF("+hud_panel_radar_maximized"            , _("maximize radar"));
+       KEYBIND_DEF("toggle chase_active"                   , _("3rd person view"));
+       KEYBIND_DEF("spec"                                  , _("enter spectator mode"));
        KEYBIND_DEF(""                                      , "");
        KEYBIND_DEF(""                                      , _("Communicate"));
        KEYBIND_DEF("messagemode"                           , _("public chat"));
@@ -97,12 +100,13 @@ void Xonotic_KeyBinds_Read()
        KEYBIND_DEF("messagemode2"                          , _("team chat"));
        KEYBIND_DEF("team_auto"                             , _("auto-join team"));
        KEYBIND_DEF("menu_showteamselect"                   , _("team menu"));
-       KEYBIND_DEF("menu_showsandboxtools"                 , _("sandbox menu"));
-       KEYBIND_DEF("spec"                                  , _("enter spectator mode"));
-       KEYBIND_DEF("dropweapon"                            , _("drop weapon"));
        KEYBIND_DEF("+use"                                  , _("drop key / drop flag"));
+       KEYBIND_DEF(""                                      , "");
+       KEYBIND_DEF(""                                      , _("Misc"));
+       KEYBIND_DEF("kill"                                  , _("respawn"));
+       KEYBIND_DEF("quickmenu"                             , _("quick menu"));
+       KEYBIND_DEF("menu_showsandboxtools"                 , _("sandbox menu"));
        KEYBIND_DEF("+button8"                              , _("drag object"));
-       KEYBIND_DEF("toggle chase_active"                   , _("3rd person view"));
        KEYBIND_DEF(""                                      , "");
        KEYBIND_DEF(""                                      , _("User defined"));
 
@@ -153,10 +157,10 @@ void XonoticKeyBinder_configureXonoticKeyBinder(entity me)
 void XonoticKeyBinder_loadKeyBinds(entity me)
 {
        bool force_initial_selection = false;
-       if(Xonotic_KeyBinds_Count < 0) // me.handle not loaded yet?
+       if(KeyBinds_Count < 0) // me.handle not loaded yet?
                force_initial_selection = true;
-       Xonotic_KeyBinds_Read();
-       me.nItems = Xonotic_KeyBinds_Count;
+       KeyBinds_Read();
+       me.nItems = KeyBinds_Count;
        if(force_initial_selection)
                me.setSelected(me, 0);
 }
@@ -180,9 +184,7 @@ void XonoticKeyBinder_resizeNotify(entity me, vector relOrigin, vector relSize,
 }
 void KeyBinder_Bind_Change(entity btn, entity me)
 {
-       string func;
-
-       func = Xonotic_KeyBinds_Functions[me.selectedItem];
+       string func = KeyBinds_Functions[me.selectedItem];
        if(func == "")
                return;
 
@@ -194,7 +196,6 @@ void XonoticKeyBinder_keyGrabbed(entity me, int key, bool ascii)
 {
        int n, j, nvalid;
        float k;
-       string func;
 
        me.keyGrabButton.forcePressed = 0;
        me.clearButton.disabled = 0;
@@ -209,7 +210,7 @@ void XonoticKeyBinder_keyGrabbed(entity me, int key, bool ascii)
                return;
        }
 
-       func = Xonotic_KeyBinds_Functions[me.selectedItem];
+       string func = KeyBinds_Functions[me.selectedItem];
        if(func == "")
                return;
 
@@ -238,32 +239,26 @@ void XonoticKeyBinder_keyGrabbed(entity me, int key, bool ascii)
 }
 void XonoticKeyBinder_destroy(entity me)
 {
-       if(Xonotic_KeyBinds_Count < 0)
+       if(KeyBinds_Count < 0)
                return;
 
        for(int i = 0; i < MAX_KEYBINDS; ++i)
        {
-               if(Xonotic_KeyBinds_Functions[i])
-                       strunzone(Xonotic_KeyBinds_Functions[i]);
-               Xonotic_KeyBinds_Functions[i] = string_null;
-               if(Xonotic_KeyBinds_Descriptions[i])
-                       strunzone(Xonotic_KeyBinds_Descriptions[i]);
-               Xonotic_KeyBinds_Descriptions[i] = string_null;
+               strfree(KeyBinds_Functions[i]);
+               strfree(KeyBinds_Descriptions[i]);
        }
-       Xonotic_KeyBinds_Count = 0;
+       KeyBinds_Count = 0;
 }
 void XonoticKeyBinder_editUserbind(entity me, string theName, string theCommandPress, string theCommandRelease)
 {
-       string func, descr;
-
        if(!me.userbindEditDialog)
                return;
 
-       func = Xonotic_KeyBinds_Functions[me.selectedItem];
+       string func = KeyBinds_Functions[me.selectedItem];
        if(func == "")
                return;
 
-       descr = Xonotic_KeyBinds_Descriptions[me.selectedItem];
+       string descr = KeyBinds_Descriptions[me.selectedItem];
        if(substring(descr, 0, 1) != "$")
                return;
        descr = substring(descr, 1, strlen(descr) - 1);
@@ -275,16 +270,14 @@ void XonoticKeyBinder_editUserbind(entity me, string theName, string theCommandP
 }
 void KeyBinder_Bind_Edit(entity btn, entity me)
 {
-       string func, descr;
-
        if(!me.userbindEditDialog)
                return;
 
-       func = Xonotic_KeyBinds_Functions[me.selectedItem];
+       string func = KeyBinds_Functions[me.selectedItem];
        if(func == "")
                return;
 
-       descr = Xonotic_KeyBinds_Descriptions[me.selectedItem];
+       string descr = KeyBinds_Descriptions[me.selectedItem];
        if(substring(descr, 0, 1) != "$")
                return;
        descr = substring(descr, 1, strlen(descr) - 1);
@@ -297,9 +290,8 @@ void KeyBinder_Bind_Edit(entity btn, entity me)
 void KeyBinder_Bind_Clear(entity btn, entity me)
 {
        float n, j, k;
-       string func;
 
-       func = Xonotic_KeyBinds_Functions[me.selectedItem];
+       string func = KeyBinds_Functions[me.selectedItem];
        if(func == "")
                return;
 
@@ -334,23 +326,23 @@ void XonoticKeyBinder_setSelected(entity me, int i)
        {
                if(i > me.previouslySelected)
                {
-                       while((i < me.nItems - 1) && (Xonotic_KeyBinds_Functions[i] == ""))
+                       while((i < me.nItems - 1) && (KeyBinds_Functions[i] == ""))
                                ++i;
                }
-               while((i > 0) && (Xonotic_KeyBinds_Functions[i] == ""))
+               while((i > 0) && (KeyBinds_Functions[i] == ""))
                        --i;
-               while((i < me.nItems - 1) && (Xonotic_KeyBinds_Functions[i] == ""))
+               while((i < me.nItems - 1) && (KeyBinds_Functions[i] == ""))
                        ++i;
        }
        if(me.pressed == 3) // released the mouse - fall back to last valid item
        {
-               if(Xonotic_KeyBinds_Functions[i] == "")
+               if(KeyBinds_Functions[i] == "")
                        i = me.previouslySelected;
        }
-       if(Xonotic_KeyBinds_Functions[i] != "")
+       if(KeyBinds_Functions[i] != "")
                me.previouslySelected = i;
        if(me.userbindEditButton)
-               me.userbindEditButton.disabled = (substring(Xonotic_KeyBinds_Descriptions[i], 0, 1) != "$");
+               me.userbindEditButton.disabled = (substring(KeyBinds_Descriptions[i], 0, 1) != "$");
        SUPER(XonoticKeyBinder).setSelected(me, i);
 }
 float XonoticKeyBinder_keyDown(entity me, int key, bool ascii, float shift)
@@ -381,11 +373,10 @@ void XonoticKeyBinder_drawListBoxItem(entity me, int i, vector absSize, bool isS
        float k;
        vector theColor;
        float theAlpha;
-       string func, descr;
        float extraMargin;
 
-       descr = Xonotic_KeyBinds_Descriptions[i];
-       func = Xonotic_KeyBinds_Functions[i];
+       string descr = KeyBinds_Descriptions[i];
+       string func = KeyBinds_Functions[i];
 
        if(func == "")
        {