Xonotic
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)
 
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). More...
 
void preMenuDraw ()
 this is run before the menu is drawn. More...
 
float preMenuInit ()
 you have to define this for pre-menu initialization. More...
 
 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 109 of file menu.qc.

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

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

110 {
112 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ m_display()

void m_display ( )

Definition at line 854 of file menu.qc.

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(), and m_toggle().

855 {
856  Menu_Active = true;
859 
860  if (!menuInitialized) return;
861 
862  if (mouseButtonsPressed) main.mouseRelease(main, menuMousePos);
864 
865  main.focusEnter(main);
866  main.showNotify(main);
867 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ m_goto()

void m_goto ( string  name)

Definition at line 951 of file menu.qc.

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

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

952 {
953  if (!menuInitialized)
954  {
955  strcpy(m_goto_buffer, itemname);
956  return;
957  }
958  if (itemname == "") // this can be called by GameCommand
959  {
961  {
962  m_hide();
963  }
964  else
965  {
966  m_activate_window(main.mainNexposee);
967  m_display();
968  }
969  }
970  else
971  {
972  entity e;
973  for (e = NULL; (e = find(e, name, itemname)); )
974  if (e.classname != "vtbl") break;
975 
976  if ((e) && (!e.requiresConnection || (gamestatus & (GAME_ISSERVER | GAME_CONNECTED))))
977  {
978  if(!Menu_Active)
979  e.hideMenuOnClose = true;
980  m_hide();
983  m_display();
984  }
985  }
986 }
entity() spawn
#define strcpy(this, s)
Definition: string.qh:49
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ m_hide()

void m_hide ( )

Definition at line 869 of file menu.qc.

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

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

870 {
871  Menu_Active = false;
874 
875  if (!menuInitialized) return;
876 
877  main.focusLeave(main);
878  main.hideNotify(main);
879 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ m_play_click_sound()

void m_play_click_sound ( string  soundfile)

Definition at line 997 of file menu.qc.

References cvar(), and localsound().

Referenced by Button_playClickSound(), CheckBox_playClickSound(), Dialog_keyDown(), GameCommand(), InputBox_keyDown(), InputBox_mouseRelease(), KeyBinder_Bind_Clear(), Nexposee_draw(), Nexposee_keyDown(), ServerList_Favorite_Click(), Slider_keyUp(), Slider_mouseRelease(), XonoticColorpicker_mouseRelease(), XonoticColorpickerString_mouseRelease(), XonoticGametypeList_clickListBoxItem(), XonoticGametypeList_keyDown(), XonoticHUDSkinList_doubleClickListBoxItem(), XonoticKeyBinder_keyGrabbed(), XonoticLanguageList_doubleClickListBoxItem(), XonoticLanguageList_keyDown(), XonoticMapList_clickListBoxItem(), XonoticMapList_doubleClickListBoxItem(), XonoticMapList_keyDown(), XonoticServerList_keyDown(), XonoticSkinList_doubleClickListBoxItem(), XonoticSkinList_keyDown(), and XonoticWinnerDialog_focusEnter().

998 {
999  if (!cvar("menu_sounds")) return;
1000  localsound(soundfile);
1001 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ m_play_focus_sound()

void m_play_focus_sound ( )

Definition at line 988 of file menu.qc.

References cvar(), localsound(), MENU_SOUND_FOCUS, and time.

989 {
990  static float menuLastFocusSoundTime;
991  if (cvar("menu_sounds") < 2) return;
992  if (time - menuLastFocusSoundTime <= 0.25) return;
994  menuLastFocusSoundTime = time;
995 }
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:

◆ m_sync()

void m_sync ( )

Definition at line 40 of file menu.qc.

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

Referenced by GameCommand(), and m_init_delayed().

41 {
43  vidwidth_s = vidheight_s = vidpixelheight_s = 0; // Force updateConwidths on next draw
44 
46 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ postMenuDraw()

void postMenuDraw ( )

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

Useful to draw something over everything else.

Definition at line 559 of file util.qc.

References DialogOpenButton_Click_withCoords(), entity(), and vector().

Referenced by m_draw().

559 {}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 562 of file util.qc.

References draw_scale, eX, eY, GAME_CONNECTED, GAME_ISSERVER, gamestatus, updateCheck(), and vector().

Referenced by m_draw().

563 {
564  vector fs, sz = '0 0 0', line, mid;
565 
566  updateCheck();
567 
569  {
570  // TODO rather turn this into a dialog
571  fs = ((1/draw_scale.x) * eX + (1/draw_scale.y) * eY) * 12;
572  line = eY * fs.y;
573  string l1, l2;
574  if(show_propermenu)
575  l1 = sprintf("Jeff pay 4 new weapons for %s", _Nex_ExtResponseSystem_UpdateTo);
576  else
577  l1 = sprintf(_("Update to %s now!"), _Nex_ExtResponseSystem_UpdateTo);
578  l2 = "http://www.xonotic.org/";
581 
582  sz_x = draw_TextWidth(" ", 0, fs) + max(
583  draw_TextWidth(l1, 0, fs),
584  draw_TextWidth(l2, 0, fs)
585  );
586  sz_y = 3 * fs.y;
587 
588  draw_alpha = bound(0, sin(time * 0.112 - 0.3) * 10, 1);
589  mid = eX * (0.5 + 0.5 * (1 - sz.x) * cos(time * 0.071))
590  + eY * (0.5 + 0.5 * (1 - sz.y) * sin(time * 0.071));
591 
592  draw_Fill(mid - 0.5 * sz, sz, '1 1 0', 1);
593  draw_CenterText(mid - 1 * line, l1, fs, '1 0 0', 1, 0);
594  draw_CenterText(mid - 0 * line, l2, fs, '0 0 1', 1, 0);
595  }
596 
598  campaign_name_previous = strzone(strcat(campaign_name, "x")); // force unequal
600  {
601  if(cvar(strcat("g_campaign", campaign_name, "_won")))
602  {
604  {
605  m_display();
606  DialogOpenButton_Click_withCoords(NULL, main.winnerDialog, '0 0 0', eX * conwidth + eY * conheight);
607  }
609  }
610  else
612  }
613  else
614  {
616  campaign_won_previous = cvar(strcat("g_campaign", campaign_name, "_won"));
617  }
618 }
string campaign_name
const vector eY
Definition: vector.qh:45
#define strcpy(this, s)
Definition: string.qh:49
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define NULL
Definition: post.qh:17
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const vector eX
Definition: vector.qh:44
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 522 of file util.qc.

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

Referenced by m_init_delayed().

523 {
524  vector sz;
525  vector boxA, boxB;
526 
527  if(random() < 0.1)
528  show_propermenu = true;
529 
530  updateCheck();
531 
534  if(!_MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
535  {
537 
538  sz = eX * 0.025 + eY * 0.025 * (draw_scale.x / draw_scale.y);
539  draw_CenterText('0.5 0.5 0' - 1.25 * sz.y * eY, _("Autogenerating mapinfo for newly added maps..."), sz, '1 1 1', 1, 0);
540 
541  boxA = '0.05 0.5 0' + 0.25 * sz.y * eY;
542  boxB = '0.95 0.5 0' + 1.25 * sz.y * eY;
543  draw_Fill(boxA, boxB - boxA, '1 1 1', 1);
544 
545  boxA += sz * 0.1;
546  boxB -= sz * 0.1;
547  draw_Fill(boxA, boxB - boxA, '0.1 0.1 0.1', 1);
548 
549  boxB_x = boxA_x * (1 - MapInfo_progress) + boxB_x * MapInfo_progress;
550  draw_Fill(boxA, boxB - boxA, '0 0 1', 1);
551 
552  return false;
553  }
554  return true;
555 }
const vector eY
Definition: vector.qh:45
int MAPINFO_TYPE_ALL
Definition: mapinfo.qh:26
float MapInfo_progress
Definition: mapinfo.qh:151
void MapInfo_Cache_Create()
Definition: mapinfo.qc:34
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const vector eX
Definition: vector.qh:44
float _MapInfo_FilterGametype(int pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition: mapinfo.qc:162
void MapInfo_Enumerate()
Definition: mapinfo.qc:115
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ void()

void ( entity  this,
float  key,
float  ascii 
)

Variable Documentation

◆ anim

entity anim

Definition at line 25 of file menu.qh.

Referenced by m_draw(), m_init_delayed(), makeHostedEasing(), makeHostedKeyframe(), and Slider_draw().

◆ 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

◆ Menu_Active

bool Menu_Active

◆ 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"

Definition at line 50 of file menu.qh.

Referenced by Button_playClickSound(), Dialog_keyDown(), Nexposee_draw(), and Nexposee_keyDown().

◆ 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

◆ 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.