]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/menu.qc
Clean up MENUQC #includes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / menu.qc
index 382a19d2ded3074b4fae4dabc92c9e73e13b819f..ec19cb9e1f017275bd265ccc692178cd6669cdaa 100644 (file)
@@ -1,3 +1,8 @@
+#if defined(CSQC)
+#elif defined(MENUQC)
+#elif defined(SVQC)
+#endif
+
 ///////////////////////////////////////////////
 // Menu Source File
 ///////////////////////
@@ -53,10 +58,8 @@ void m_init()
        prvm_language = strzone(prvm_language);
        cvar_set("_menu_prvm_language", prvm_language);
 
-       check_unacceptable_compiler_bugs();
-
 #ifdef WATERMARK
-       printf(_("^4MQC Build information: ^1%s\n"), WATERMARK);
+       dprintf("^4MQC Build information: ^1%s\n", WATERMARK);
 #endif
 
        // list all game dirs (TEST)
@@ -93,6 +96,7 @@ void m_init()
                        m_hide();
                cvar_set("_menu_initialized", "1");
        }
+
 }
 
 const float MENU_ASPECT = 1.25; // 1280x1024
@@ -195,7 +199,7 @@ void m_init_delayed()
        }
        fclose(fh);
 
-       glob = search_begin(strcat(draw_currentSkin, "/*.tga"), TRUE, TRUE);
+       glob = search_begin(strcat(draw_currentSkin, "/*.tga"), true, true);
        if(glob >= 0)
        {
                n = search_getsize(glob);
@@ -265,7 +269,7 @@ void m_keydown(float key, float ascii)
        {
                // detect a click outside of the game window
                vector p = getmousepos();
-               if(p_x < 0 || p_x > realconwidth || p_y < 0 || p_y > realconheight)
+               if(p.x < 0 || p.x > realconwidth || p.y < 0 || p.y > realconheight)
                {
                        ++mouseButtonsPressed;
                        return;
@@ -315,13 +319,10 @@ void draw_Picture_Aligned(vector algn, float scalemode, string img, float a)
        float width_is_larger;
 
        sz = draw_PictureSize(img);
-       width_is_larger = (sz_x * draw_scale_y >= sz_y * draw_scale_x);
-       isz_w = '1 0 0' + '0 1 0' * ((sz_y / sz_x) * (draw_scale_x / draw_scale_y));
-       isz_h = '0 1 0' + '1 0 0' * ((sz_x / sz_y) * (draw_scale_y / draw_scale_x));
+       width_is_larger = (sz.x * draw_scale.y >= sz.y * draw_scale.x);
+       isz_w = '1 0 0' + '0 1 0' * ((sz.y / sz.x) * (draw_scale.x / draw_scale.y));
+       isz_h = '0 1 0' + '1 0 0' * ((sz.x / sz.y) * (draw_scale.y / draw_scale.x));
 
-#ifdef GMQCC
-       isz = '0 0 0';
-#endif
        switch(scalemode)
        {
                default:
@@ -342,7 +343,7 @@ void draw_Picture_Aligned(vector algn, float scalemode, string img, float a)
                        break;
        }
 
-       org = eX * (algn_x * (1 - isz_x)) + eY * (algn_y * (1 - isz_y));
+       org = eX * (algn.x * (1 - isz.x)) + eY * (algn.y * (1 - isz.y));
        draw_Picture(org, img, isz, '1 1 1', a);
 }
 
@@ -408,23 +409,23 @@ string menuTooltipText;
 float menuTooltipState; // 0: static, 1: fading in, 2: fading out
 float m_testmousetooltipbox(vector pos)
 {
-       if(pos_x >= menuTooltipOrigin_x && pos_x < menuTooltipOrigin_x + menuTooltipSize_x)
-       if(pos_y >= menuTooltipOrigin_y && pos_y < menuTooltipOrigin_y + menuTooltipSize_y)
-               return FALSE;
-       return TRUE;
+       if(pos.x >= menuTooltipOrigin.x && pos.x < menuTooltipOrigin.x + menuTooltipSize.x)
+       if(pos.y >= menuTooltipOrigin.y && pos.y < menuTooltipOrigin.y + menuTooltipSize.y)
+               return false;
+       return true;
 }
 float m_testtooltipbox(vector tooltippos)
 {
-       if(tooltippos_x < 0)
-               return FALSE;
-       if(tooltippos_y < 0)
-               return FALSE;
-       if(tooltippos_x + menuTooltipSize_x > 1)
-               return FALSE;
-       if(tooltippos_y + menuTooltipSize_y > 1)
-               return FALSE;
+       if(tooltippos.x < 0)
+               return false;
+       if(tooltippos.y < 0)
+               return false;
+       if(tooltippos.x + menuTooltipSize.x > 1)
+               return false;
+       if(tooltippos.y + menuTooltipSize.y > 1)
+               return false;
        menuTooltipOrigin = tooltippos;
-       return TRUE;
+       return true;
 }
 float m_allocatetooltipbox(vector pos)
 {
@@ -435,41 +436,41 @@ float m_allocatetooltipbox(vector pos)
        avoidplus_y = (SKINAVOID_TOOLTIP_y + SKINSIZE_CURSOR_y - SKINOFFSET_CURSOR_y * SKINSIZE_CURSOR_y) / conheight;
        avoidplus_z = 0;
 
-       avoidminus_x = (SKINAVOID_TOOLTIP_x + SKINOFFSET_CURSOR_x * SKINSIZE_CURSOR_x) / conwidth + menuTooltipSize_x;
-       avoidminus_y = (SKINAVOID_TOOLTIP_y + SKINOFFSET_CURSOR_y * SKINSIZE_CURSOR_y) / conheight + menuTooltipSize_y;
+       avoidminus_x = (SKINAVOID_TOOLTIP_x + SKINOFFSET_CURSOR_x * SKINSIZE_CURSOR_x) / conwidth + menuTooltipSize.x;
+       avoidminus_y = (SKINAVOID_TOOLTIP_y + SKINOFFSET_CURSOR_y * SKINSIZE_CURSOR_y) / conheight + menuTooltipSize.y;
        avoidminus_z = 0;
 
        // bottom right
        v = pos + avoidplus;
        if(m_testtooltipbox(v))
-               return TRUE;
+               return true;
 
        // bottom center
-       v_x = pos_x - menuTooltipSize_x * 0.5;
+       v_x = pos.x - menuTooltipSize.x * 0.5;
        if(m_testtooltipbox(v))
-               return TRUE;
+               return true;
 
        // bottom left
-       v_x = pos_x - avoidminus_x;
+       v_x = pos.x - avoidminus.x;
        if(m_testtooltipbox(v))
-               return TRUE;
+               return true;
 
        // top left
-       v_y = pos_y - avoidminus_y;
+       v_y = pos.y - avoidminus.y;
        if(m_testtooltipbox(v))
-               return TRUE;
+               return true;
 
        // top center
-       v_x = pos_x - menuTooltipSize_x * 0.5;
+       v_x = pos.x - menuTooltipSize.x * 0.5;
        if(m_testtooltipbox(v))
-               return TRUE;
+               return true;
 
        // top right
-       v_x = pos_x + avoidplus_x;
+       v_x = pos.x + avoidplus.x;
        if(m_testtooltipbox(v))
-               return TRUE;
+               return true;
 
-       return FALSE;
+       return false;
 }
 entity m_findtooltipitem(entity root, vector pos)
 {
@@ -590,12 +591,12 @@ void m_tooltip(vector pos)
                                        {
                                                s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors);
                                                ++i;
-                                               f = draw_TextWidth(s, FALSE, fontsize);
+                                               f = draw_TextWidth(s, false, fontsize);
                                                if(f > w)
                                                        w = f;
                                        }
                                        menuTooltipSize_x = w + 2 * (SKINMARGIN_TOOLTIP_x / conwidth);
-                                       menuTooltipSize_y = i * fontsize_y + 2 * (SKINMARGIN_TOOLTIP_y / conheight);
+                                       menuTooltipSize_y = i * fontsize.y + 2 * (SKINMARGIN_TOOLTIP_y / conheight);
                                        menuTooltipSize_z = 0;
                                }
                                break;
@@ -649,25 +650,25 @@ void m_tooltip(vector pos)
                                menuTooltipItem = world; // reload tooltip next frame
                        menu_tooltips_old = menu_tooltips;
                }
-               else if(menuTooltipOrigin_x < 0) // unallocated?
+               else if(menuTooltipOrigin.x < 0) // unallocated?
                        m_allocatetooltipbox(pos);
 
-               if(menuTooltipOrigin_x >= 0)
+               if(menuTooltipOrigin.x >= 0)
                {
                        // draw the tooltip!
                        p = SKINBORDER_TOOLTIP;
-                       p_x *= 1 / conwidth;
-                       p_y *= 1 / conheight;
+                       p.x *= 1 / conwidth;
+                       p.y *= 1 / conheight;
                        draw_BorderPicture(menuTooltipOrigin, SKINGFX_TOOLTIP, menuTooltipSize, '1 1 1', menuTooltipAlpha, p);
                        p = menuTooltipOrigin;
-                       p_x += SKINMARGIN_TOOLTIP_x / conwidth;
-                       p_y += SKINMARGIN_TOOLTIP_y / conheight;
+                       p.x += SKINMARGIN_TOOLTIP_x / conwidth;
+                       p.y += SKINMARGIN_TOOLTIP_y / conheight;
                        getWrappedLine_remaining = menuTooltipText;
                        while(getWrappedLine_remaining)
                        {
                                s = getWrappedLine(SKINWIDTH_TOOLTIP, fontsize, draw_TextWidth_WithoutColors);
-                               draw_Text(p, s, fontsize, '1 1 1', SKINALPHA_TOOLTIP * menuTooltipAlpha, FALSE);
-                               p_y += fontsize_y;
+                               draw_Text(p, s, fontsize, SKINCOLOR_TOOLTIP, SKINALPHA_TOOLTIP * menuTooltipAlpha, false);
+                               p.y += fontsize.y;
                        }
                }
        }
@@ -760,7 +761,7 @@ void m_draw(float width, float height)
                {
                        draw_reset_full();
                        draw_Fill('0 0 0', '1 1 0', SKINCOLOR_BACKGROUND, 1);
-                       drawBackground(SKINGFX_BACKGROUND, bound(0, menuLogoAlpha, 1), SKINALIGN_BACKGROUND, TRUE);
+                       drawBackground(SKINGFX_BACKGROUND, bound(0, menuLogoAlpha, 1), SKINALIGN_BACKGROUND, true);
                        draw_reset_cropped();
                        if(menuAlpha <= 0 && SKINALPHA_CURSOR_INTRO > 0)
                        {
@@ -775,7 +776,7 @@ void m_draw(float width, float height)
                if(menuAlpha > 0)
                {
                        draw_reset_full();
-                       drawBackground(SKINGFX_BACKGROUND_INGAME, menuAlpha * SKINALPHA_BACKGROUND_INGAME, SKINALIGN_BACKGROUND_INGAME, FALSE);
+                       drawBackground(SKINGFX_BACKGROUND_INGAME, menuAlpha * SKINALPHA_BACKGROUND_INGAME, SKINALIGN_BACKGROUND_INGAME, false);
                        draw_reset_cropped();
                }
        }
@@ -829,8 +830,8 @@ void m_draw(float width, float height)
                                maxpos = globalToBox(eX * (realconwidth - 1) + eY * (realconheight - 1), draw_shift, draw_scale);
                                dMouse = globalToBoxSize(dMouse, draw_scale);
                                menuMousePos += dMouse * cvar("menu_mouse_speed");
-                               menuMousePos_x = bound(minpos_x, menuMousePos_x, maxpos_x);
-                               menuMousePos_y = bound(minpos_y, menuMousePos_y, maxpos_y);
+                               menuMousePos_x = bound(minpos.x, menuMousePos.x, maxpos.x);
+                               menuMousePos_y = bound(minpos.y, menuMousePos.y, maxpos.y);
                                if(mouseButtonsPressed)
                                        main.mouseDrag(main, menuMousePos);
                                else
@@ -957,8 +958,8 @@ void m_setpointerfocus(entity wnd)
                if(focus)
                {
                        menuMousePos = focus.origin + 0.5 * focus.size;
-                       menuMousePos_x *= 1 / conwidth;
-                       menuMousePos_y *= 1 / conheight;
+                       menuMousePos.x *= 1 / conwidth;
+                       menuMousePos.y *= 1 / conheight;
                        if(wnd.focused) // why does this never happen?
                                m_focus_item_chain(wnd, focus);
                }