Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
menu.qh File Reference
#include "draw.qh"
#include "skin.qh"
#include "xonotic/util.qh"
#include <common/constants.qh>
#include <common/util.qh>
Include dependency graph for menu.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void draw_reset_cropped ()
void m_display ()
void m_goto (string name, bool hide_menu_on_close)
void m_hide ()
void m_play_click_sound (string soundfile)
void m_play_focus_sound ()
void m_sync ()
void postMenuDraw ()
 this is run just after the menu is drawn (or not).
void preMenuDraw ()
 this is run before the menu is drawn.
float preMenuInit ()
 you have to define this for pre-menu initialization.
 void (entity this, float key, float ascii) keyGrabbed

Variables

entity anim
float conheight
float conwidth
float frametime
const int GAME_CONNECTED = BIT(1)
const int GAME_DEVELOPER = BIT(2)
const int GAME_ISSERVER = BIT(0)
int gamestatus
entity keyGrabber
entity main
bool Menu_Active
const string MENU_SOUND_CLEAR = "sound/menu/clear.wav"
const string MENU_SOUND_CLOSE = "sound/menu/close.wav"
const string MENU_SOUND_EXECUTE = "sound/menu/execute.wav"
const string MENU_SOUND_FOCUS = "sound/menu/focus.wav"
const string MENU_SOUND_OPEN = "sound/menu/open.wav"
const string MENU_SOUND_SELECT = "sound/menu/select.wav"
const string MENU_SOUND_SLIDE = "sound/menu/slide.wav"
const string MENU_SOUND_WINNER = "sound/menu/winner.wav"
string name
const int S_ALT = 4
const int S_CTRL = 2
const int S_SHIFT = 1
float time

Function Documentation

◆ draw_reset_cropped()

void draw_reset_cropped ( )

Definition at line 115 of file menu.qc.

116{
118}
void draw_reset(float cw, float ch, float ox, float oy)
Definition draw.qc:21
float realconwidth
Definition menu.qc:43
float realconheight
Definition menu.qc:43
float conwidth
Definition menu.qh:36
float conheight
Definition menu.qh:36

References conheight, conwidth, draw_reset(), realconheight, and realconwidth.

Referenced by m_draw(), m_init_delayed(), m_keydown(), m_keyup(), preMenuInit(), and UpdateConWidthHeight().

◆ m_display()

void m_display ( )

Definition at line 954 of file menu.qc.

955{
956 Menu_Active = true;
959
960 if (!menuInitialized) return;
961
962 if (mouseButtonsPressed) main.mouseRelease(main, menuMousePos);
964
965 main.focusEnter(main);
966 main.showNotify(main);
967}
#define main
Definition _all.inc:202
vector menuMousePos
Definition menu.qc:27
bool menuInitialized
Definition menu.qc:33
int menuMouseMode
Definition menu.qc:34
int mouseButtonsPressed
Definition menu.qc:26
bool Menu_Active
Definition menu.qh:15
float MT_CLIENT
Definition menudefs.qc:64
void setmousetarget(float trg)
float KEY_MENU
Definition menudefs.qc:30
float MT_MENU
Definition menudefs.qc:63
void setkeydest(float dest)

References KEY_MENU, main, Menu_Active, menuInitialized, menuMouseMode, menuMousePos, mouseButtonsPressed, MT_CLIENT, MT_MENU, setkeydest(), and setmousetarget().

Referenced by m_goto(), m_init(), m_init_delayed(), m_toggle(), and preMenuDraw().

◆ m_goto()

void m_goto ( string name,
bool hide_menu_on_close )

Definition at line 1056 of file menu.qc.

1057{
1058 if (!menuInitialized)
1059 {
1060 strcpy(m_goto_buffer, itemname);
1061 return;
1062 }
1063 if (itemname == "") // this can be called by GameCommand
1064 {
1066 {
1067 m_hide();
1068 return;
1069 }
1070 itemname = "nexposee";
1071 }
1072
1073 if (itemname == "nexposee")
1074 {
1075 // unlike 'togglemenu 1', this closes modal and root dialogs if opened
1076 m_activate_window(main.mainNexposee);
1077 m_display();
1078 }
1079 else
1080 {
1081 entity e;
1082 for (e = NULL; (e = find(e, name, itemname)); )
1083 if (e.classname != "vtbl") break;
1084
1085 if ((e) && (!e.requiresConnection || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))))
1086 {
1087 m_hide();
1090 m_display();
1091 if (hide_menu_on_close)
1092 {
1093 while(e.parent && !(e.instanceOfDialog && e.isTabRoot))
1094 e = e.parent;
1095 if (e.instanceOfDialog)
1096 e.hideMenuOnClose = true;
1097 }
1098 }
1099 }
1100}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void m_hide()
Definition menu.qc:969
void m_display()
Definition menu.qc:954
void m_activate_window(entity wnd)
Definition menu.qc:1015
void m_setpointerfocus(entity wnd)
Definition menu.qc:1043
string m_goto_buffer
Definition menu.qc:164
const int GAME_ISSERVER
Definition menu.qh:11
string name
Definition menu.qh:30
const int GAME_CONNECTED
Definition menu.qh:12
int gamestatus
Definition menu.qh:16
entity find(entity start,.string field, string match)
#define NULL
Definition post.qh:14
#define strcpy(this, s)
Definition string.qh:52

References entity(), find(), GAME_CONNECTED, GAME_ISSERVER, gamestatus, m_activate_window(), m_display(), m_goto_buffer, m_hide(), m_setpointerfocus(), main, menuInitialized, name, NULL, and strcpy.

Referenced by Dialog_close(), GameCommand(), m_init_delayed(), XonoticNexposee_close(), and XonoticRootDialog_close().

◆ m_hide()

void m_hide ( )

Definition at line 969 of file menu.qc.

970{
971 Menu_Active = false;
974
975 if (!menuInitialized) return;
976
977 main.focusLeave(main);
978 main.hideNotify(main);
979}
float KEY_GAME
Definition menudefs.qc:29

References KEY_GAME, main, Menu_Active, menuInitialized, MT_CLIENT, setkeydest(), and setmousetarget().

Referenced by m_draw(), m_goto(), m_init(), m_keydown(), m_toggle(), and Shutdown().

◆ m_play_click_sound()

◆ m_play_focus_sound()

void m_play_focus_sound ( )

Definition at line 1102 of file menu.qc.

1103{
1104 static float menuLastFocusSoundTime;
1105 if (cvar("menu_sounds") < 2) return;
1106 if (time - menuLastFocusSoundTime <= 0.25) return;
1108 menuLastFocusSoundTime = time;
1109}
float time
const string MENU_SOUND_FOCUS
Definition menu.qh:52

◆ m_sync()

void m_sync ( )

Definition at line 45 of file menu.qc.

46{
48 vidwidth_s = vidheight_s = vidpixelheight_s = 0; // Force updateConwidths on next draw
49
51}
void loadAllCvars(entity root)
Definition util.qc:53
void updateCompression()
Definition util.qc:604
float vidheight_s
Definition menu.qc:42
float vidwidth_s
Definition menu.qc:42
float vidpixelheight_s
Definition menu.qc:42

References loadAllCvars(), main, updateCompression(), vidheight_s, vidpixelheight_s, and vidwidth_s.

Referenced by GameCommand(), m_draw(), and m_init_delayed().

◆ postMenuDraw()

void postMenuDraw ( )

this is run just after the menu is drawn (or not).

Useful to draw something over everything else.

Definition at line 538 of file util.qc.

538{}

Referenced by m_draw().

◆ preMenuDraw()

void preMenuDraw ( )

this is run before the menu is drawn.

You may put some stuff there that has to be done every frame.

Definition at line 541 of file util.qc.

542{
543 vector fs, sz = '0 0 0', line, mid;
544
545 updateCheck();
546
548 {
549 // TODO rather turn this into a dialog
550 fs = ((1/draw_scale.x) * eX + (1/draw_scale.y) * eY) * 12;
551 line = eY * fs.y;
552 string l1, l2;
553 l1 = sprintf(_("Update to %s now!"), _Nex_ExtResponseSystem_UpdateTo);
554 l2 = "https://xonotic.org";
557
558 sz_x = draw_TextWidth(" ", 0, fs) + max(
559 draw_TextWidth(l1, 0, fs),
560 draw_TextWidth(l2, 0, fs)
561 );
562 sz_y = 3 * fs.y;
563
564 draw_alpha = bound(0, sin(time * 0.112 - 0.3) * 10, 1);
565 mid = eX * (0.5 + 0.5 * (1 - sz.x) * cos(time * 0.071))
566 + eY * (0.5 + 0.5 * (1 - sz.y) * sin(time * 0.071));
567
568 draw_Fill(mid - 0.5 * sz, sz, '1 1 0', 1);
569 draw_CenterText(mid - 1 * line, l1, fs, '1 0 0', 1, 0);
570 draw_CenterText(mid - 0 * line, l2, fs, '0 0 1', 1, 0);
571 }
572
574 campaign_name_previous = strzone(strcat(campaign_name, "x")); // force unequal
576 {
577 if(cvar(strcat("g_campaign", campaign_name, "_won")))
578 {
580 {
581 m_display();
582 DialogOpenButton_Click_withCoords(NULL, main.winnerDialog, '0 0 0', eX * conwidth + eY * conheight);
583 }
585 }
586 else
588 }
589 else
590 {
592 campaign_won_previous = cvar(strcat("g_campaign", campaign_name, "_won"));
593 }
594}
string campaign_name
float draw_TextWidth(string theText, float ICanHasKallerz, vector SizeThxBye)
Definition draw.qc:304
void draw_CenterText(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
Definition draw.qc:298
void draw_Fill(vector theOrigin, vector theSize, vector theColor, float theAlpha)
Definition draw.qc:97
vector draw_scale
Definition draw.qh:8
float draw_alpha
Definition draw.qh:9
float campaign_won_previous
Definition util.qc:537
string _Nex_ExtResponseSystem_UpdateToURL
Definition util.qc:286
void updateCheck()
Definition util.qc:456
void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize)
string _Nex_ExtResponseSystem_UpdateTo
Definition util.qc:285
string campaign_name_previous
Definition util.qc:536
float bound(float min, float value, float max)
float cos(float f)
float sin(float f)
string strzone(string s)
float max(float f,...)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
vector
Definition self.qh:92
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44

References _Nex_ExtResponseSystem_UpdateTo, _Nex_ExtResponseSystem_UpdateToURL, bound(), campaign_name, campaign_name_previous, campaign_won_previous, conheight, conwidth, cos(), cvar(), DialogOpenButton_Click_withCoords(), draw_alpha, draw_CenterText(), draw_Fill(), draw_scale, draw_TextWidth(), eX, eY, GAME_CONNECTED, GAME_ISSERVER, gamestatus, m_display(), main, max(), NULL, sin(), strcat(), strcpy, strzone(), time, updateCheck(), and vector.

Referenced by m_draw().

◆ preMenuInit()

float preMenuInit ( )

you have to define this for pre-menu initialization.

Return 0 if initialization needs to be retried a frame later, 1 if it succeeded.

Definition at line 504 of file util.qc.

505{
506 vector sz;
507 vector boxA, boxB;
508
509 updateCheck();
510
514 {
516
517 sz = eX * 0.025 + eY * 0.025 * (draw_scale.x / draw_scale.y);
518 draw_CenterText('0.5 0.5 0' - 1.25 * sz.y * eY, _("Autogenerating mapinfo for newly added maps..."), sz, '1 1 1', 1, 0);
519
520 boxA = '0.05 0.5 0' + 0.25 * sz.y * eY;
521 boxB = '0.95 0.5 0' + 1.25 * sz.y * eY;
522 draw_Fill(boxA, boxB - boxA, '1 1 1', 1);
523
524 boxA += sz * 0.1;
525 boxB -= sz * 0.1;
526 draw_Fill(boxA, boxB - boxA, '0.1 0.1 0.1', 1);
527
528 boxB_x = boxA_x * (1 - MapInfo_progress) + boxB_x * MapInfo_progress;
529 draw_Fill(boxA, boxB - boxA, '0 0 1', 1);
530
531 return false;
532 }
533 return true;
534}
float _MapInfo_FilterGametype(vector pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition mapinfo.qc:181
void MapInfo_Cache_Create()
Definition mapinfo.qc:53
void MapInfo_Enumerate()
Definition mapinfo.qc:134
vector MAPINFO_TYPE_ALL
Definition mapinfo.qh:27
float MapInfo_progress
Definition mapinfo.qh:173
void draw_reset_cropped()
Definition menu.qc:115

References _MapInfo_FilterGametype(), draw_CenterText(), draw_Fill(), draw_reset_cropped(), draw_scale, eX, eY, MapInfo_Cache_Create(), MapInfo_Enumerate(), MapInfo_progress, MAPINFO_TYPE_ALL, updateCheck(), and vector.

Referenced by m_init_delayed().

◆ void()

void ( entity this,
float key,
float ascii )

References entity().

Variable Documentation

◆ anim

◆ conheight

◆ conwidth

◆ frametime

float frametime

Definition at line 22 of file menu.qh.

◆ GAME_CONNECTED

◆ GAME_DEVELOPER

const int GAME_DEVELOPER = BIT(2)

Definition at line 13 of file menu.qh.

Referenced by m_gamestatus().

◆ GAME_ISSERVER

◆ gamestatus

◆ keyGrabber

entity keyGrabber

Definition at line 32 of file menu.qh.

Referenced by KeyBinder_Bind_Change(), m_draw(), m_keydown(), and XonoticKeyBinder_drawListBoxItem().

◆ main

entity main

Definition at line 26 of file menu.qh.

◆ Menu_Active

bool Menu_Active

Definition at line 15 of file menu.qh.

Referenced by m_display(), m_draw(), m_hide(), m_init_delayed(), m_keydown(), m_keyup(), m_toggle(), and updateCheck().

◆ MENU_SOUND_CLEAR

const string MENU_SOUND_CLEAR = "sound/menu/clear.wav"

Definition at line 49 of file menu.qh.

Referenced by InputBox_keyDown(), InputBox_mouseRelease(), and KeyBinder_Bind_Clear().

◆ MENU_SOUND_CLOSE

const string MENU_SOUND_CLOSE = "sound/menu/close.wav"

◆ MENU_SOUND_EXECUTE

◆ MENU_SOUND_FOCUS

const string MENU_SOUND_FOCUS = "sound/menu/focus.wav"

Definition at line 52 of file menu.qh.

Referenced by m_play_focus_sound().

◆ MENU_SOUND_OPEN

◆ MENU_SOUND_SELECT

◆ MENU_SOUND_SLIDE

const string MENU_SOUND_SLIDE = "sound/menu/slide.wav"

◆ MENU_SOUND_WINNER

const string MENU_SOUND_WINNER = "sound/menu/winner.wav"

Definition at line 56 of file menu.qh.

Referenced by XonoticWinnerDialog_focusEnter().

◆ name

string name

Definition at line 30 of file menu.qh.

Referenced by Client::Client(), ACCUMULATE_call(), addPowerupItem(), CvarStringSource::ATTRIB(), StringSource::ATTRIB(), bot_aim(), bot_setnameandstuff(), CL_WeaponEntity_SetModel(), cvar(), cvar_defstring(), cvar_set(), cvar_string(), deglob_log(), Gametype::display(), GuidePage::display(), Monster::display(), Mutator::display(), Turret::display(), XonoticRegisteredSettingsList::drawListBoxItem(), find_bot_by_name(), float(), float(), freepic(), GameTypeVote_ReadOption(), gecko_create(), gecko_destroy(), gecko_get_texture_extent(), gecko_keyevent(), gecko_mousemove(), gecko_navigate(), gecko_resize(), GetCvars_handleFloat(), GetCvars_handleFloatOnce(), GetCvars_handleString(), GetCvars_handleString_Fixup(), CvarStringSource::getEntry(), DataSource::getEntry(), SettingSource::getEntry(), StringSource::getEntry(), getrecords(), iscachedpic(), m_goto(), minigame_texture(), minigame_texture_skin(), MX_Nick(), precache_pic(), PreviewExists(), registercvar(), RegisterCvars(), RegisterCvars_Save(), RegisterCvars_Set(), REPLICATE_INIT(), Scoreboard_Draw(), str_cvar(), string(), string(), TeamScore_Spawn(), vector(), viewmodel_draw(), void(), void(), W_Guide_DPS(), W_Guide_DPS_bothMultishot(), W_Guide_DPS_onlyOne(), W_Guide_DPS_onlyOne_andDirectHit(), W_Guide_DPS_onlyOne_unnamed(), W_Guide_DPS_onlyOne_unnamed_andDirectHit(), W_Guide_DPS_onlyOneMultishot(), W_Guide_DPS_onlySecondary(), W_Guide_DPS_primaryDPS(), W_Guide_DPS_primaryMultishot(), W_Guide_DPS_secondaryMultishot(), W_Guide_DPS_secondaryMultishotWithCombo(), XonoticPlayerList_drawListBoxItem(), XonoticPlayerList_setPlayerList(), and XonoticSkinList_getSkins().

◆ S_ALT

const int S_ALT = 4

Definition at line 20 of file menu.qh.

◆ S_CTRL

const int S_CTRL = 2

Definition at line 19 of file menu.qh.

◆ S_SHIFT

const int S_SHIFT = 1

Definition at line 18 of file menu.qh.

◆ time

float time

Definition at line 23 of file menu.qh.