X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fmenu%2Fmenu.qc;h=312a2dc2cbfb80aaa26296a656ac16de0d23d27f;hp=d3bf2ec6298996246eeabdf0c3424f51ca790187;hb=def24368510d38164b0f6756a1cd5e3bb82f67a8;hpb=f879dea04474678d9a263cf5d8c127415e390ca5 diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index d3bf2ec62..312a2dc2c 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -16,12 +16,13 @@ float menuInitialized; float menuNotTheFirstFrame; float menuMouseMode; -void SUB_Null() { } +float conwidth_s, conheight_s, vidwidth_s, vidheight_s, vidpixelheight_s, + realconwidth, realconheight, screenconwidth, screenconheight; void m_sync() { updateCompression(); - updateConwidths(); + vidwidth_s = vidheight_s = vidpixelheight_s = 0; loadAllCvars(main); } @@ -55,7 +56,7 @@ void m_init() check_unacceptable_compiler_bugs(); #ifdef WATERMARK - print(sprintf(_("^4MQC Build information: ^1%s\n"), WATERMARK())); + print(sprintf(_("^4MQC Build information: ^1%s\n"), WATERMARK)); #endif // list all game dirs (TEST) @@ -81,7 +82,6 @@ void m_init() updateCompression(); if(ddsload != cvar("r_texture_dds_load") || texcomp != cvar("gl_texturecompression")) localcmd("\nr_restart\n"); - initConwidths(); if(!restarting) { @@ -93,9 +93,9 @@ void m_init() } } -float MENU_ASPECT = 1.25; // 1280x1024 -float MENU_MINHEIGHT = 600; -float conwidth_s, conheight_s, realconwidth, realconheight, screenconwidth, screenconheight; +const float MENU_ASPECT = 1.25; // 1280x1024 +const float MENU_MINHEIGHT = 600; + void draw_reset_cropped() { draw_reset(screenconwidth, screenconheight, 0.5 * (realconwidth - screenconwidth), 0.5 * (realconheight - screenconheight)); @@ -104,8 +104,16 @@ void draw_reset_full() { draw_reset(realconwidth, realconheight, 0, 0); } -void UpdateConWidthHeight() + +void UpdateConWidthHeight(float w, float h, float p) { + if (w != vidwidth_s || h != vidheight_s || p != vidpixelheight_s) + { + updateConwidths(w, h, p); + vidwidth_s = w; + vidheight_s = h; + vidpixelheight_s = p; + } conwidth_s = conwidth; conheight_s = conheight; realconwidth = cvar("vid_conwidth"); @@ -142,6 +150,10 @@ void UpdateConWidthHeight() 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; @@ -150,8 +162,6 @@ void m_init_delayed() float fh, glob, n, i; string s; - conwidth = conheight = -1; - UpdateConWidthHeight(); draw_reset_cropped(); menuInitialized = 0; @@ -259,6 +269,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; @@ -291,11 +314,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; @@ -306,6 +329,9 @@ void draw_Picture_Aligned(vector algn, float scalemode, string img, float a) 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: @@ -657,7 +683,7 @@ void m_tooltip(vector pos) } } -void m_draw() +void m_draw(float width, float height) { float t; float realFrametime; @@ -671,8 +697,7 @@ void m_draw() if (anim) anim.tickAll(anim); - if(main) - UpdateConWidthHeight(); + UpdateConWidthHeight(width, height, cvar("vid_pixelheight")); if(!menuInitialized) { @@ -686,7 +711,7 @@ void m_draw() if(Menu_Active) if(!cvar("menu_video_played")) { - localcmd("cd loop $menu_cdtrack; play sound/announcer/default/welcome.ogg\n"); + localcmd("cd loop $menu_cdtrack; play sound/announcer/default/welcome.wav\n"); menuLogoAlpha = -0.8; // no idea why, but when I start this at zero, it jumps instead of fading FIXME } // ALWAYS set this cvar; if we start but menu is not active, this means we want no background music! @@ -783,7 +808,12 @@ void m_draw() draw_alpha *= menuAlpha; - if(menuMouseMode) + if(!Menu_Active) + { + // do not update mouse position + // it prevents mouse jumping to '0 0 0' when menu is fading out + } + else if(menuMouseMode) { vector newMouse; newMouse = globalToBox(getmousepos(), draw_shift, draw_scale); @@ -972,7 +1002,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);