-#if defined(CSQC)
-#elif defined(MENUQC)
-#elif defined(SVQC)
-#endif
+#include "menu.qh"
+#include "oo/classes.qc"
+#include "xonotic/util.qh"
+
+#include "../common/items/all.qh"
+#include "../common/weapons/all.qh"
+#include "../common/mapinfo.qh"
+#include "../common/mutators/base.qh"
///////////////////////////////////////////////
// Menu Source File
float mouseButtonsPressed;
vector menuMousePos;
-float menuShiftState;
+int menuShiftState;
float menuPrevTime;
float menuAlpha;
float menuLogoAlpha;
cvar_set("_menu_prvm_language", prvm_language);
#ifdef WATERMARK
- dprintf("^4MQC Build information: ^1%s\n", WATERMARK);
+ LOG_TRACEF("^4MQC Build information: ^1%s\n", WATERMARK);
#endif
// list all game dirs (TEST)
s = getgamedirinfo(i, GETGAMEDIRINFO_NAME);
if (!s)
break;
- dprint(s, ": ", getgamedirinfo(i, GETGAMEDIRINFO_DESCRIPTION));
+ LOG_TRACE(s, ": ", getgamedirinfo(i, GETGAMEDIRINFO_DESCRIPTION));
}
}
// needs to be done so early because of the constants they create
- CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
- CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
+ static_init();
RegisterSLCategories();
draw_setMousePointer(SKINGFX_CURSOR, SKINSIZE_CURSOR, SKINOFFSET_CURSOR);
loadTooltips();
- anim = spawnAnimHost();
- main = spawnMainWindow(); main.configureMainWindow(main);
+ anim = NEW(AnimHost);
+ main = NEW(MainWindow); main.configureMainWindow(main);
unloadTooltips();
main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight);
if(mouseButtonsPressed < 0)
{
mouseButtonsPressed = 0;
- dprint("Warning: released an already released button\n");
+ LOG_TRACE("Warning: released an already released button\n");
}
}
if(key == K_ALT) menuShiftState -= (menuShiftState & S_ALT);
if(mouseButtonsPressed > 10)
{
mouseButtonsPressed = 10;
- dprint("Warning: pressed an already pressed button\n");
+ LOG_TRACE("Warning: pressed an already pressed button\n");
}
}
if(key == K_ALT) menuShiftState |= S_ALT;
string c;
float scalemode;
- v_z = 0;
+ v.z = 0;
scalemode = SCALEMODE_CROP;
case "h": scalemode = SCALEMODE_HEIGHT; goto nopic;
case "w": scalemode = SCALEMODE_WIDTH; goto nopic;
case "s": scalemode = SCALEMODE_STRETCH; goto nopic;
- case "1": case "4": case "7": v_x = 0.0; break;
- case "2": case "5": case "8": v_x = 0.5; break;
- case "3": case "6": case "9": v_x = 1.0; break;
- default: v_x = random(); break;
+ case "1": case "4": case "7": v.x = 0.0; break;
+ case "2": case "5": case "8": v.x = 0.5; break;
+ case "3": case "6": case "9": v.x = 1.0; break;
+ default: v.x = random(); break;
}
switch(c)
{
- case "7": case "8": case "9": v_y = 0.0; break;
- case "4": case "5": case "6": v_y = 0.5; break;
- case "1": case "2": case "3": v_y = 1.0; break;
- default: v_y = random(); break;
+ case "7": case "8": case "9": v.y = 0.0; break;
+ case "4": case "5": case "6": v.y = 0.5; break;
+ case "1": case "2": case "3": v.y = 1.0; break;
+ default: v.y = random(); break;
}
if(l == 0)
draw_Picture_Aligned(v, scalemode, img, a);
vector avoidplus, avoidminus;
vector v;
- avoidplus_x = (SKINAVOID_TOOLTIP_x + SKINSIZE_CURSOR_x - SKINOFFSET_CURSOR_x * SKINSIZE_CURSOR_x) / conwidth;
- avoidplus_y = (SKINAVOID_TOOLTIP_y + SKINSIZE_CURSOR_y - SKINOFFSET_CURSOR_y * SKINSIZE_CURSOR_y) / conheight;
- avoidplus_z = 0;
+ avoidplus.x = (SKINAVOID_TOOLTIP_x + SKINSIZE_CURSOR_x - SKINOFFSET_CURSOR_x * SKINSIZE_CURSOR_x) / conwidth;
+ 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_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.z = 0;
// bottom right
v = pos + avoidplus;
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;
// bottom left
- v_x = pos.x - avoidminus.x;
+ v.x = pos.x - avoidminus.x;
if(m_testtooltipbox(v))
return true;
// top left
- v_y = pos.y - avoidminus.y;
+ v.y = pos.y - avoidminus.y;
if(m_testtooltipbox(v))
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;
// top right
- v_x = pos.x + avoidplus.x;
+ v.x = pos.x + avoidplus.x;
if(m_testtooltipbox(v))
return true;
menuTooltipState = 1;
menuTooltipItem = it;
- menuTooltipOrigin_x = -1; // unallocated
+ menuTooltipOrigin.x = -1; // unallocated
if (menuTooltipText)
strunzone(menuTooltipText);
if(f > w)
w = f;
}
- menuTooltipSize_x = w + 2 * (SKINMARGIN_TOOLTIP_x / conwidth);
- menuTooltipSize_y = i * fontsize.y + 2 * (SKINMARGIN_TOOLTIP_y / conheight);
- menuTooltipSize_z = 0;
+ menuTooltipSize.x = w + 2 * (SKINMARGIN_TOOLTIP_x / conwidth);
+ menuTooltipSize.y = i * fontsize.y + 2 * (SKINMARGIN_TOOLTIP_y / conheight);
+ menuTooltipSize.z = 0;
}
break;
case 1:
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
menuMousePos = focus.origin + 0.5 * focus.size;
menuMousePos.x *= 1 / conwidth;
menuMousePos.y *= 1 / conheight;
- if(wnd.focused) // why does this never happen?
+ entity par = wnd.parent;
+ if(par.focused)
+ par.setFocus(par, wnd);
+ if(wnd.focused)
m_focus_item_chain(wnd, focus);
}
}
}
}
}
+
+float menuLastFocusSoundTime;
+void m_play_focus_sound()
+{
+ if(cvar("menu_sounds") > 1)
+ if(time - menuLastFocusSoundTime > 0.25)
+ {
+ localsound(MENU_SOUND_FOCUS);
+ menuLastFocusSoundTime = time;
+ }
+}
+
+void m_play_click_sound(string soundfile)
+{
+ if(cvar("menu_sounds"))
+ localsound(soundfile);
+}