X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fmenu.qc;h=382a19d2ded3074b4fae4dabc92c9e73e13b819f;hb=ee3543c1c14ffc6cd14b6dbd07d76d4cb65e3bd6;hp=490a40a4d116bc497a0add07acaf6a4941490a4f;hpb=a9e20bf70ac7ab858241a2213f89673165ea1f09;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 490a40a4d..382a19d2d 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -16,10 +16,13 @@ float menuInitialized; float menuNotTheFirstFrame; float menuMouseMode; +float conwidth_s, conheight_s, vidwidth_s, vidheight_s, vidpixelheight_s, + realconwidth, realconheight; + void m_sync() { updateCompression(); - updateConwidths(); + vidwidth_s = vidheight_s = vidpixelheight_s = 0; // Force updateConwidths on next draw. loadAllCvars(main); } @@ -53,7 +56,7 @@ void m_init() check_unacceptable_compiler_bugs(); #ifdef WATERMARK - print(sprintf(_("^4MQC Build information: ^1%s\n"), WATERMARK)); + printf(_("^4MQC Build information: ^1%s\n"), WATERMARK); #endif // list all game dirs (TEST) @@ -64,7 +67,7 @@ void m_init() for(i = 0; ; ++i) { s = getgamedirinfo(i, GETGAMEDIRINFO_NAME); - if not(s) + if (!s) break; dprint(s, ": ", getgamedirinfo(i, GETGAMEDIRINFO_DESCRIPTION)); } @@ -74,12 +77,13 @@ void m_init() CALL_ACCUMULATED_FUNCTION(RegisterWeapons); CALL_ACCUMULATED_FUNCTION(RegisterGametypes); + RegisterSLCategories(); + 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(); if(!restarting) { @@ -91,27 +95,26 @@ void m_init() } } -float MENU_ASPECT = 1.25; // 1280x1024 -float MENU_MINHEIGHT = 600; -float conwidth_s, conheight_s, vidwidth_s, vidheight_s, realconwidth, - realconheight, screenconwidth, screenconheight; +const float MENU_ASPECT = 1.25; // 1280x1024 + void draw_reset_cropped() { - draw_reset(screenconwidth, screenconheight, 0.5 * (realconwidth - screenconwidth), 0.5 * (realconheight - screenconheight)); + draw_reset(conwidth, conheight, 0.5 * (realconwidth - conwidth), 0.5 * (realconheight - conheight)); } void draw_reset_full() { draw_reset(realconwidth, realconheight, 0, 0); } -void UpdateConWidthHeight(float w, float h) +void UpdateConWidthHeight(float w, float h, float p) { - if (w != vidwidth_s || h != vidheight_s) + if (w != vidwidth_s || h != vidheight_s || p != vidpixelheight_s) { - initConwidths(w, h); - updateConwidths(); + if (updateConwidths(w, h, p)) + localcmd(sprintf("\nexec %s\n", cvar_string("menu_font_cfg"))); vidwidth_s = w; vidheight_s = h; + vidpixelheight_s = p; } conwidth_s = conwidth; conheight_s = conheight; @@ -129,18 +132,6 @@ void UpdateConWidthHeight(float w, float h) conwidth = realconwidth; conheight = realconwidth / MENU_ASPECT; } - screenconwidth = conwidth; - screenconheight = conheight; - if(conwidth < MENU_MINHEIGHT * MENU_ASPECT) - { - conheight *= MENU_MINHEIGHT * MENU_ASPECT / conwidth; - conwidth = MENU_MINHEIGHT * MENU_ASPECT; - } - if(conheight < MENU_MINHEIGHT) - { - conwidth *= MENU_MINHEIGHT / conheight; - conheight = MENU_MINHEIGHT; - } if(main) { if(conwidth_s != conwidth || conheight_s != conheight) @@ -149,6 +140,10 @@ void UpdateConWidthHeight(float w, float h) main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight); } } + else + { + vidwidth_s = vidheight_s = vidpixelheight_s = 0; // retry next frame + } } string m_goto_buffer; @@ -157,8 +152,6 @@ void m_init_delayed() float fh, glob, n, i; string s; - conwidth = conheight = -1; - UpdateConWidthHeight(cvar("vid_width"), cvar("vid_height")); draw_reset_cropped(); menuInitialized = 0; @@ -266,6 +259,19 @@ void m_keydown(float key, float ascii) return; if(!Menu_Active) return; + + if(menuMouseMode) + if(key >= K_MOUSE1 && key <= K_MOUSE3) + { + // detect a click outside of the game window + vector p = getmousepos(); + if(p_x < 0 || p_x > realconwidth || p_y < 0 || p_y > realconheight) + { + ++mouseButtonsPressed; + return; + } + } + if(keyGrabber) { entity e; @@ -298,11 +304,11 @@ void m_keydown(float key, float ascii) if(key == K_SHIFT) menuShiftState |= S_SHIFT; } -float SCALEMODE_CROP = 0; -float SCALEMODE_LETTERBOX = 1; -float SCALEMODE_WIDTH = 2; -float SCALEMODE_HEIGHT = 3; -float SCALEMODE_STRETCH = 4; +const float SCALEMODE_CROP = 0; +const float SCALEMODE_LETTERBOX = 1; +const float SCALEMODE_WIDTH = 2; +const float SCALEMODE_HEIGHT = 3; +const float SCALEMODE_STRETCH = 4; void draw_Picture_Aligned(vector algn, float scalemode, string img, float a) { vector sz, org, isz, isz_w, isz_h; @@ -437,7 +443,7 @@ float m_allocatetooltipbox(vector pos) v = pos + avoidplus; if(m_testtooltipbox(v)) return TRUE; - + // bottom center v_x = pos_x - menuTooltipSize_x * 0.5; if(m_testtooltipbox(v)) @@ -457,12 +463,12 @@ float m_allocatetooltipbox(vector pos) v_x = pos_x - menuTooltipSize_x * 0.5; if(m_testtooltipbox(v)) return TRUE; - + // top right v_x = pos_x + avoidplus_x; if(m_testtooltipbox(v)) return TRUE; - + return FALSE; } entity m_findtooltipitem(entity root, vector pos) @@ -681,14 +687,7 @@ void m_draw(float width, float height) if (anim) anim.tickAll(anim); - if(main) - { -#ifdef COMPAT_XON070_OLD_M_DRAW - UpdateConWidthHeight(width ? width : cvar("vid_width"), height ? height : cvar("vid_height")); -#else - UpdateConWidthHeight(width, height); -#endif - } + UpdateConWidthHeight(width, height, cvar("vid_pixelheight")); if(!menuInitialized) { @@ -993,7 +992,8 @@ void m_goto(string itemname) for(e = NULL; (e = find(e, name, itemname)); ) if(e.classname != "vtbl") break; - if(e) + + if((e) && (!e.requiresConnection || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED)))) { m_hide(); m_activate_window(e);