]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/menu.qc
restart menu when having turned "" to "en" to make menu.dat.en.po apply
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / menu.qc
index 09ef47a6aa672b5626c90fd289ec2d7915ebb98b..c46069a3c436297cdaeb1ff8f23ba5d9a28df171 100644 (file)
@@ -16,12 +16,28 @@ float menuInitialized;
 float menuNotTheFirstFrame;
 float menuMouseMode;
 
-void SUB_Null() { };
+void SUB_Null() { }
 
-void() m_init =
+void m_sync()
+{
+       updateCompression();
+       updateConwidths();
+
+       loadAllCvars(main);
+}
+
+void m_init()
 {
        cvar_set("_menu_alpha", "0");
-       prvm_language = strzone(cvar_string("prvm_language"));
+       prvm_language = cvar_string("prvm_language");
+       if(prvm_language == "")
+       {
+               prvm_language = "en";
+               cvar_set("prvm_language", prvm_language);
+               localcmd("\nmenu_restart; togglemenu\n");
+       }
+       prvm_language = strzone(prvm_language);
+       cvar_set("_menu_prvm_language", prvm_language);
 
        check_unacceptable_compiler_bugs();
 
@@ -42,6 +58,17 @@ void() m_init =
                        dprint(s, ": ", getgamedirinfo(i, GETGAMEDIRINFO_DESCRIPTION));
                }
        }
+
+       // needs to be done so early because of the constants they create
+       RegisterWeapons();
+       RegisterGametypes();
+
+       float ddsload = cvar("r_texture_dds_load");
+       float texcomp = cvar("gl_texturecompression");
+       updateCompression();
+       if(ddsload != cvar("r_texture_dds_load") || texcomp != cvar("gl_texturecompression"))
+               localcmd("\nr_restart\n");
+       initConwidths();
 }
 
 float MENU_ASPECT = 1.25; // 1280x1024
@@ -95,7 +122,7 @@ void UpdateConWidthHeight()
        }
 }
 
-void() m_init_delayed =
+void m_init_delayed()
 {
        float fh, glob, n, i;
        string s;
@@ -108,9 +135,6 @@ void() m_init_delayed =
        if(!preMenuInit())
                return;
        menuInitialized = 1;
-       GameCommand_Init();
-
-       RegisterWeapons();
 
        fh = -1;
        if(cvar_string("menu_skin") != "")
@@ -169,11 +193,13 @@ void() m_init_delayed =
        menuShiftState = 0;
        menuMousePos = '0.5 0.5 0';
 
+       m_sync();
+
        if(Menu_Active)
                m_display(); // delayed menu display
-};
+}
 
-void(float key, float ascii) m_keyup =
+void m_keyup (float key, float ascii)
 {
        if(!menuInitialized)
                return;
@@ -195,9 +221,9 @@ void(float key, float ascii) m_keyup =
        if(key == K_ALT) menuShiftState -= (menuShiftState & S_ALT);
        if(key == K_CTRL) menuShiftState -= (menuShiftState & S_CTRL);
        if(key == K_SHIFT) menuShiftState -= (menuShiftState & S_SHIFT);
-};
+}
 
-void(float key, float ascii) m_keydown =
+void m_keydown(float key, float ascii)
 {
        if(!menuInitialized)
                return;
@@ -233,7 +259,7 @@ void(float key, float ascii) m_keydown =
        if(key == K_ALT) menuShiftState |= S_ALT;
        if(key == K_CTRL) menuShiftState |= S_CTRL;
        if(key == K_SHIFT) menuShiftState |= S_SHIFT;
-};
+}
 
 float SCALEMODE_CROP = 0;
 float SCALEMODE_LETTERBOX = 1;
@@ -274,7 +300,7 @@ void draw_Picture_Aligned(vector algn, float scalemode, string img, float a)
        draw_Picture(org, img, isz, '1 1 1', a);
 }
 
-void(string img, float a, string algn, float force1) drawBackground =
+void drawBackground(string img, float a, string algn, float force1)
 {
        if(main.mainNexposee.ModalController_state == 0)
                return;
@@ -559,7 +585,16 @@ void m_tooltip(vector pos)
                        break;
        }
 
-       if(menuTooltipItem)
+       if(menuTooltipItem == world)
+       {
+               if (menuTooltipText)
+               {
+                       strunzone(menuTooltipText);
+                       menuTooltipText = string_null;
+               }
+               return;
+       }
+       else
        {
                if(menu_tooltips != menu_tooltips_old)
                {
@@ -591,11 +626,13 @@ void m_tooltip(vector pos)
        }
 }
 
-void() m_draw =
+void m_draw()
 {
        float t;
        float realFrametime;
 
+       execute_next_frame();
+
        menuMouseMode = cvar("menu_mouse_absolute");
 
        if (anim)
@@ -768,9 +805,9 @@ void() m_draw =
        postMenuDraw();
 
        frametime = 0;
-};
+}
 
-void() m_display =
+void m_display()
 {
        Menu_Active = true;
        setkeydest(KEY_MENU);
@@ -785,9 +822,9 @@ void() m_display =
 
        main.focusEnter(main);
        main.showNotify(main);
-};
+}
 
-void() m_hide =
+void m_hide()
 {
        Menu_Active = false;
        setkeydest(KEY_GAME);
@@ -798,17 +835,25 @@ void() m_hide =
 
        main.focusLeave(main);
        main.hideNotify(main);
-};
+}
 
-void() m_toggle =
+void m_toggle(float mode)
 {
        if(Menu_Active)
+       {
+               if (mode == 1)
+                       return;
                m_hide();
+       }
        else
+       {
+               if (mode == 0)
+                       return;
                m_display();
-};
+       }
+}
 
-void() m_shutdown =
+void Shutdown()
 {
        entity e;
 
@@ -819,7 +864,7 @@ void() m_shutdown =
                        if(e.destroy)
                                e.destroy(e);
        }
-};
+}
 
 void m_focus_item_chain(entity outermost, entity innermost)
 {
@@ -875,7 +920,7 @@ void m_setpointerfocus(entity wnd)
        }
 }
 
-void(string itemname) m_goto =
+void m_goto(string itemname)
 {
        entity e;
        if(!menuInitialized)
@@ -892,7 +937,7 @@ void(string itemname) m_goto =
        }
        else
        {
-               for(e = NULL; (e = findstring(e, name, itemname)); )
+               for(e = NULL; (e = find(e, name, itemname)); )
                        if(e.classname != "vtbl")
                                break;
                if(e)
@@ -905,7 +950,7 @@ void(string itemname) m_goto =
        }
 }
 
-void() m_goto_skin_selector =
+void m_goto_skin_selector()
 {
        if(!menuInitialized)
                return;
@@ -913,7 +958,7 @@ void() m_goto_skin_selector =
        m_goto("skinselector");
 }
 
-void() m_goto_language_selector =
+void m_goto_language_selector()
 {
        if(!menuInitialized)
                return;
@@ -921,7 +966,7 @@ void() m_goto_language_selector =
        m_goto("languageselector");
 }
 
-void() m_goto_video_settings =
+void m_goto_video_settings()
 {
        if(!menuInitialized)
                return;