Xonotic
util.qc File Reference
#include "util.qh"
#include "dialog.qh"
#include "../item.qh"
#include "../menu.qh"
#include <common/campaign_common.qh>
#include <common/constants.qh>
#include <common/gamemodes/_mod.qh>
#include <common/util.qh>
#include <common/command/_mod.qh>
+ Include dependency graph for util.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GAMETYPE(it)   { if (i++ == cnt) return it; }
 
#define GAMETYPE(id)   ++i;
 
#define GAMETYPE(it)   { if (dev > 0) ++i; }
 
#define GAMETYPE(id)   ++i;
 
#define GAMETYPES
 
#define HIDDEN_GAMETYPES
 

Functions

void CheckSendCvars (entity me, string cvarnamestring)
 
void clearTooltip (entity e)
 
void dialog_hudpanel_main_checkbox (entity me, string panelname)
 
void dialog_hudpanel_main_settings (entity me, string panelname)
 
void DialogOpenButton_Click_withCoords (entity button, entity tab, vector theOrigin, vector theSize)
 
void DisableServerBackwardsCompatibility ()
 
 float (entity) func_setDependent
 
void forAllDescendants (entity root, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
 
int GameType_GetCount ()
 
string GameType_GetIcon (int cnt)
 
Gametype GameType_GetID (int cnt)
 
string GameType_GetName (int cnt)
 
int GameType_GetTotalCount ()
 
string getCvarsMulti (entity me)
 
float getFadedAlpha (float currentAlpha, float startAlpha, float targetAlpha)
 
float GL_CheckExtension (string ext)
 
float GL_Have_TextureCompression ()
 
void loadAllCvars (entity root)
 
void loadCvarsOf (entity ignore, entity e)
 
void makeCallback (entity e, entity cbent, void(entity, entity) cbfunc)
 
void makeMulti (entity e, string otherCvars)
 
entity makeXonoticCheckBox (float, string, string)
 
entity makeXonoticCheckBoxString (string, string, string, string)
 
entity makeXonoticColorpickerString (string theCvar, string theDefaultCvar)
 
entity makeXonoticTextLabel (float theAlign, string theText)
 
entity makeXonoticTextSlider (string)
 
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...
 
string resolvemod (string m)
 
void saveAllCvars (entity root)
 
void saveCvarsCallback (entity me)
 
void saveCvarsMulti (entity me)
 
void saveCvarsOf (entity ignore, entity e)
 
void setDependent (entity e, string theCvarName, float theCvarMin, float theCvarMax)
 
void setDependent_Check (entity e)
 
void setDependent_Draw (entity e)
 
void setDependentAND (entity e, string theCvarName, float theCvarMin, float theCvarMax, string theCvar2Name, float theCvar2Min, float theCvar2Max)
 
void setDependentAND3 (entity e, string theCvarName, float theCvarMin, float theCvarMax, string theCvar2Name, float theCvar2Min, float theCvar2Max, string theCvar3Name, float theCvar3Min, float theCvar3Max)
 
void setDependentOR (entity e, string theCvarName, float theCvarMin, float theCvarMax, string theCvar2Name, float theCvar2Min, float theCvar2Max)
 
void setDependentStringNotEqual (entity e, string theCvarName, string theCvarValue)
 
void setDependentWeird (entity e, float(entity) func)
 
void setZonedTooltip (entity e, string theTooltip, string theCvar)
 
void SUB_Null_ee (entity e1, entity e2)
 
void updateCheck ()
 
float updateCompression ()
 
void UpdateNotification_URI_Get_Callback (float id, float status, string data)
 
void URI_Get_Callback (float id, float status, string data)
 engine callback More...
 
 void (entity) saveCvars
 
 void (entity me, entity cb) saveCvars_Callback_func
 
 void (entity, float, float, entity) TD
 
 void (entity, float) TDempty
 
 void (entity, float, float) gotoRC
 
 void (entity, string, string) addValue
 

Variables

string _Nex_ExtResponseSystem_Packs
 
float _Nex_ExtResponseSystem_PacksStep
 
float _Nex_ExtResponseSystem_Queried
 
string _Nex_ExtResponseSystem_UpdateTo
 
string _Nex_ExtResponseSystem_UpdateToURL
 
string campaign_name_previous
 
float campaign_won_previous
 
string controlledCvar
 
string controlledCvars_Multi
 
string cvar2_setDependent
 
float cvar2Max_setDependent
 
float cvar2Min_setDependent
 
string cvar3_setDependent
 
float cvar3Max_setDependent
 
float cvar3Min_setDependent
 
string cvar_setDependent
 
float cvarMax_setDependent
 
float cvarMin_setDependent
 
string cvarString_setDependent
 
string cvarValue_setDependent
 
bool disabled
 
entity firstChild
 
entity nextSibling
 
float op_setDependent
 
entity parent
 
entity saveCvars_Callback_ent
 
bool sendCvars
 
bool show_propermenu = false
 
entity winnerDialog
 

Macro Definition Documentation

◆ GAMETYPE [1/4]

#define GAMETYPE (   it)    { if (i++ == cnt) return it; }

◆ GAMETYPE [2/4]

#define GAMETYPE (   id)    ++i;

◆ GAMETYPE [3/4]

#define GAMETYPE (   it)    { if (dev > 0) ++i; }

◆ GAMETYPE [4/4]

#define GAMETYPE (   id)    ++i;

◆ GAMETYPES

#define GAMETYPES
Value:
GAMETYPE(MAPINFO_TYPE_DEATHMATCH) \
GAMETYPE(MAPINFO_TYPE_TEAM_DEATHMATCH) \
GAMETYPE(MAPINFO_TYPE_CTF) \
GAMETYPE(MAPINFO_TYPE_CA) \
GAMETYPE(MAPINFO_TYPE_FREEZETAG) \
GAMETYPE(MAPINFO_TYPE_KEEPAWAY) \
GAMETYPE(MAPINFO_TYPE_KEYHUNT) \
GAMETYPE(MAPINFO_TYPE_LMS) \
GAMETYPE(MAPINFO_TYPE_DOMINATION) \
GAMETYPE(MAPINFO_TYPE_NEXBALL) \
GAMETYPE(MAPINFO_TYPE_ONSLAUGHT) \
GAMETYPE(MAPINFO_TYPE_ASSAULT) \
/* GAMETYPE(MAPINFO_TYPE_DUEL) */ \
/* GAMETYPE(MAPINFO_TYPE_INVASION) */ \

Definition at line 683 of file util.qc.

Referenced by GameType_GetCount(), GameType_GetID(), and GameType_GetTotalCount().

◆ HIDDEN_GAMETYPES

#define HIDDEN_GAMETYPES
Value:
GAMETYPE(MAPINFO_TYPE_RACE) \
GAMETYPE(MAPINFO_TYPE_CTS) \

Definition at line 701 of file util.qc.

Referenced by GameType_GetCount(), GameType_GetID(), and GameType_GetTotalCount().

Function Documentation

◆ CheckSendCvars()

void CheckSendCvars ( entity  me,
string  cvarnamestring 
)

Definition at line 841 of file util.qc.

References cmd(), cvar_string(), GAME_CONNECTED, GAME_ISSERVER, gamestatus, and LOG_INFOF.

Referenced by saveCvarsMulti(), XonoticCheckBox_saveCvars(), XonoticCheckBoxString_saveCvars(), XonoticInputBox_saveCvars(), XonoticSlider_saveCvars(), and XonoticTextSlider_saveCvars().

842 {
843  if(me.sendCvars)
844  {
846  {
847  LOG_INFOF("Sending cvar: %s -> %s", cvarnamestring, cvar_string(cvarnamestring));
848  cmd(sprintf("\nsendcvar %s\n", cvarnamestring));
849  }
850  }
851 }
#define LOG_INFOF(...)
Definition: log.qh:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearTooltip()

void clearTooltip ( entity  e)

Definition at line 277 of file util.qc.

References setZonedTooltip(), and string_null.

Referenced by XonoticGametypeList_focusedItemChangeNotify(), XonoticRegisteredSettingsList_getTooltip_cb(), XonoticServerList_focusedItemChangeNotify(), and XonoticServerList_mouseMove().

278 {
280 }
string string_null
Definition: nil.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dialog_hudpanel_main_checkbox()

void dialog_hudpanel_main_checkbox ( entity  me,
string  panelname 
)

Definition at line 764 of file util.qc.

References entity(), makeXonoticCheckBox(), strcat(), and strzone().

Referenced by XonoticHUDAmmoDialog_fill(), XonoticHUDCenterprintDialog_fill(), XonoticHUDChatDialog_fill(), XonoticHUDEngineInfoDialog_fill(), XonoticHUDHealthArmorDialog_fill(), XonoticHUDInfoMessagesDialog_fill(), XonoticHUDModIconsDialog_fill(), XonoticHUDNotificationDialog_fill(), XonoticHUDPowerupsDialog_fill(), XonoticHUDRaceTimerDialog_fill(), XonoticHUDScoreDialog_fill(), XonoticHUDTimerDialog_fill(), XonoticHUDVoteDialog_fill(), and XonoticHUDWeaponsDialog_fill().

765 {
766  entity e;
767 
768  me.TR(me);
769  me.TDempty(me, 1.5);
770  me.TD(me, 1, 2.5, e = makeXonoticCheckBox(0, strzone(strcat("hud_panel_", panelname)), _("Enable")));
771 }
entity() spawn
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"))
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dialog_hudpanel_main_settings()

void dialog_hudpanel_main_settings ( entity  me,
string  panelname 
)

Definition at line 773 of file util.qc.

References entity(), and makeXonoticTextLabel().

Referenced by XonoticHUDAmmoDialog_fill(), XonoticHUDCenterprintDialog_fill(), XonoticHUDChatDialog_fill(), XonoticHUDEngineInfoDialog_fill(), XonoticHUDHealthArmorDialog_fill(), XonoticHUDInfoMessagesDialog_fill(), XonoticHUDModIconsDialog_fill(), XonoticHUDNotificationDialog_fill(), XonoticHUDPowerupsDialog_fill(), XonoticHUDQuickMenuDialog_fill(), XonoticHUDRaceTimerDialog_fill(), XonoticHUDScoreDialog_fill(), XonoticHUDTimerDialog_fill(), XonoticHUDVoteDialog_fill(), and XonoticHUDWeaponsDialog_fill().

774 {
775  float i;
776  entity e;
777 
778  me.gotoRC(me, me.currentRow + 1.5, 0);
779  me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("Background:")));
780  me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg"))));
781  e.addValue(e, _("Default"), "");
782  e.addValue(e, _("Disable"), "0");
783  e.addValue(e, strzone(strcat("border_", panelname)), strzone(strcat("border_", panelname)));
784  e.configureXonoticTextSliderValues(e);
785  me.TR(me);
786  me.TDempty(me, 0.2);
787  me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Color:")));
788  me.TD(me, 2, 2.6, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
789  setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
790  me.TR(me);
791  me.TDempty(me, 0.2);
792  me.TD(me, 1, 1.0, e = makeXonoticCheckBoxString("", "1 1 1", strzone(strcat("hud_panel_", panelname, "_bg_color")), _("Use default")));
793  me.TR(me);
794  me.TDempty(me, 0.2);
795  me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Border size:")));
796  me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_border"))));
797  e.addValue(e, _("Default"), "");
798  e.addValue(e, _("Disable"), "0");
799  for(i = 1; i <= 10; ++i)
800  e.addValue(e, strzone(ftos_decimals(i * 2, 0)), strzone(ftos(i * 2)));
801  e.configureXonoticTextSliderValues(e);
802  me.TR(me);
803  me.TDempty(me, 0.2);
804  me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Alpha:")));
805  me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_alpha"))));
806  e.addValue(e, _("Default"), "");
807  for(i = 1; i <= 10; ++i)
808  e.addValue(e, strzone(ftos_decimals(i/10, 1)), strzone(ftos(i/10)));
809  e.configureXonoticTextSliderValues(e);
810  me.TR(me);
811  me.TDempty(me, 0.2);
812  me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Team Color:")));
813  me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_color_team"))));
814  e.addValue(e, _("Default"), "");
815  e.addValue(e, _("Disable"), "0");
816  for(i = 1; i <= 10; ++i)
817  e.addValue(e, strzone(ftos_decimals(i/10, 1)), strzone(ftos(i/10)));
818  e.configureXonoticTextSliderValues(e);
819  me.TR(me);
820  me.TDempty(me, 0.4);
821  me.TD(me, 1, 3.6, e = makeXonoticCheckBox(0, "hud_configure_teamcolorforced", _("Test team color in configure mode")));
822  me.TR(me);
823  me.TDempty(me, 0.2);
824  me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Padding:")));
825  me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_padding"))));
826  e.addValue(e, _("Default"), "");
827  for(i = 0; i <= 10; ++i)
828  e.addValue(e, strzone(ftos_decimals(i - 5, 0)), strzone(ftos(i - 5)));
829  e.configureXonoticTextSliderValues(e);
830 }
ERASEABLE string ftos_decimals(float number, int decimals)
converts a number to a string with the indicated number of decimals
Definition: string.qh:450
entity() spawn
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"))
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DialogOpenButton_Click_withCoords()

void DialogOpenButton_Click_withCoords ( entity  button,
entity  tab,
vector  theOrigin,
vector  theSize 
)

Definition at line 35 of file modalcontroller.qc.

Referenced by DemoConfirm_ListClick_Check_Gamestatus(), DialogOpenButton_Click(), MainWindow_draw(), postMenuDraw(), ServerList_Info_Click(), XonoticMapList_doubleClickListBoxItem(), XonoticMapList_keyDown(), XonoticScreenshotList_startScreenshot(), and XonoticServerList_keyDown().

36  {
37  if (tab.ModalController_state) return;
38  if (button) button.forcePressed = 1;
39  if (tab.parent.focusedChild) tab.parent.focusedChild.saveFocus(tab.parent.focusedChild);
40  tab.ModalController_controllingButton = button;
41  tab.parent.showChild(tab.parent, tab, theOrigin, theSize, 0);
42  }
+ Here is the caller graph for this function:

◆ DisableServerBackwardsCompatibility()

void DisableServerBackwardsCompatibility ( )

Definition at line 316 of file util.qc.

References cvar(), cvar_set(), floor(), and ftos().

317 {
318  cvar_set("gameversion_min", ftos(100 * floor(cvar("gameversion") / 100)));
319 }
+ Here is the call graph for this function:

◆ float()

float ( entity  )

◆ forAllDescendants()

void forAllDescendants ( entity  root,
void(entity, entity funcPre,
void(entity, entity funcPost,
entity  pass 
)

Definition at line 24 of file util.qc.

References depthfirst(), firstChild, nextSibling, and parent.

Referenced by loadAllCvars(), and saveAllCvars().

25 {
26  depthfirst(root, parent, firstChild, nextSibling, funcPre, funcPost, pass);
27 }
void depthfirst(entity start,.entity up,.entity downleft,.entity right, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
Definition: util.qc:281
#define pass(name, colormin, colormax)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameType_GetCount()

int GameType_GetCount ( )

Definition at line 716 of file util.qc.

References cvar(), GAMETYPES, and HIDDEN_GAMETYPES.

Referenced by XonoticGametypeList_configureXonoticGametypeList(), XonoticGametypeList_draw(), and XonoticGametypeList_loadCvars().

717 {
718  int i = 0;
719  int dev = cvar("developer");
720  #define GAMETYPE(id) ++i;
721  GAMETYPES
722  #undef GAMETYPE
723  #define GAMETYPE(it) { if (dev > 0) ++i; }
725  #undef GAMETYPE
726  return i;
727 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameType_GetIcon()

string GameType_GetIcon ( int  cnt)

Definition at line 745 of file util.qc.

References entity(), GameType_GetID(), makeXonoticCheckBox(), makeXonoticCheckBoxString(), makeXonoticColorpickerString(), makeXonoticTextLabel(), makeXonoticTextSlider(), MapInfo_Type_ToString(), and strcat().

Referenced by XonoticGametypeList_configureXonoticGametypeList(), and XonoticGametypeList_drawListBoxItem().

746 {
748  return i ? strcat("gametype_", MapInfo_Type_ToString(i)) : "";
749 }
string MapInfo_Type_ToString(Gametype t)
Definition: mapinfo.qc:616
float cnt
Definition: powerups.qc:24
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"))
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameType_GetID()

Gametype GameType_GetID ( int  cnt)

Definition at line 706 of file util.qc.

References GAMETYPES, HIDDEN_GAMETYPES, and NULL.

Referenced by GameType_GetIcon(), GameType_GetName(), XonoticGametypeList_drawListBoxItem(), XonoticGametypeList_focusedItemChangeNotify(), XonoticGametypeList_loadCvars(), XonoticGametypeList_saveCvars(), and XonoticMapInfoDialog_loadMapInfo().

707 {
708  int i = 0;
709  #define GAMETYPE(it) { if (i++ == cnt) return it; }
710  GAMETYPES
712  #undef GAMETYPE
713  return NULL;
714 }
#define NULL
Definition: post.qh:17
+ Here is the caller graph for this function:

◆ GameType_GetName()

string GameType_GetName ( int  cnt)

Definition at line 739 of file util.qc.

References GameType_GetID(), and MapInfo_Type_ToText().

Referenced by XonoticGametypeList_drawListBoxItem().

740 {
742  return i ? MapInfo_Type_ToText(i) : "";
743 }
string MapInfo_Type_ToText(Gametype t)
Definition: mapinfo.qc:621
float cnt
Definition: powerups.qc:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameType_GetTotalCount()

int GameType_GetTotalCount ( )

Definition at line 729 of file util.qc.

References GAMETYPES, and HIDDEN_GAMETYPES.

Referenced by XonoticGametypeList_configureXonoticGametypeList(), and XonoticMapInfoDialog_loadMapInfo().

730 {
731  int i = 0;
732  #define GAMETYPE(id) ++i;
733  GAMETYPES
735  #undef GAMETYPE
736  return i;
737 }
+ Here is the caller graph for this function:

◆ getCvarsMulti()

string getCvarsMulti ( entity  me)

Definition at line 58 of file util.qc.

References string_null.

Referenced by gettooltip().

59 {
60  if (me.controlledCvars_Multi)
61  return me.controlledCvars_Multi;
62  return string_null;
63 }
string string_null
Definition: nil.qh:9
+ Here is the caller graph for this function:

◆ getFadedAlpha()

float getFadedAlpha ( float  currentAlpha,
float  startAlpha,
float  targetAlpha 
)

Definition at line 832 of file util.qc.

References frametime, max(), and min().

Referenced by XonoticCampaignList_drawListBoxItem(), XonoticCvarList_drawListBoxItem(), XonoticDemoList_drawListBoxItem(), XonoticGametypeList_drawListBoxItem(), XonoticHUDSkinList_drawListBoxItem(), XonoticKeyBinder_drawListBoxItem(), XonoticLanguageList_drawListBoxItem(), XonoticMapList_drawListBoxItem(), XonoticPicker_draw(), XonoticPlayList_drawListBoxItem(), XonoticRegisteredSettingsList_getTooltip_cb(), XonoticScreenshotList_drawListBoxItem(), XonoticServerList_drawListBoxItem(), XonoticSkinList_drawListBoxItem(), XonoticSoundList_drawListBoxItem(), XonoticStatsList_drawListBoxItem(), and XonoticWeaponsList_drawListBoxItem().

833 {
834  if(startAlpha < targetAlpha)
835  currentAlpha = min(currentAlpha + frametime * 0.5, targetAlpha);
836  else
837  currentAlpha = max(currentAlpha - frametime * 0.5, targetAlpha);
838  return currentAlpha;
839 }
float frametime
Definition: csprogsdefs.qc:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GL_CheckExtension()

float GL_CheckExtension ( string  ext)

Definition at line 13 of file util.qc.

References cvar_string(), and strhasword.

Referenced by GL_Have_TextureCompression().

14 {
15  return strhasword(cvar_string("gl_info_extensions"), ext);
16 }
#define strhasword(s, w)
Definition: string.qh:352
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GL_Have_TextureCompression()

float GL_Have_TextureCompression ( )

Definition at line 18 of file util.qc.

References GL_CheckExtension().

Referenced by updateCompression().

19 {
20  return GL_CheckExtension("GL_EXT_texture_compression_s3tc");
21 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadAllCvars()

void loadAllCvars ( entity  root)

Definition at line 51 of file util.qc.

References forAllDescendants(), loadCvarsOf(), NULL, and SUB_Null_ee().

Referenced by m_sync(), XonoticCvarsDialog_showNotify(), XonoticDamageTextSettings::XonoticDamageTextSettings ::showNotify(), XonoticGameCrosshairSettingsTab_showNotify(), XonoticGameHUDSettingsTab_showNotify(), XonoticGameMessageSettingsTab_showNotify(), XonoticGameModelSettingsTab_showNotify(), XonoticGameViewSettingsTab_showNotify(), XonoticGameWeaponsSettingsTab_showNotify(), XonoticMutatorsDialog_showNotify(), XonoticRootDialog_showNotify(), and XonoticTab_showNotify().

52 {
54 }
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadCvarsOf()

void loadCvarsOf ( entity  ignore,
entity  e 
)

Definition at line 42 of file util.qc.

Referenced by loadAllCvars().

43 {
44  if(e.loadCvars)
45  e.loadCvars(e);
46 }
+ Here is the caller graph for this function:

◆ makeCallback()

void makeCallback ( entity  e,
entity  cbent,
void(entity, entity cbfunc 
)

Definition at line 105 of file util.qc.

References entity(), and saveCvarsCallback().

106 {
107  e.saveCvars_Callback = e.saveCvars;
108  e.saveCvars = saveCvarsCallback;
109  e.saveCvars_Callback_ent = cbent;
110  e.saveCvars_Callback_func = cbfunc;
111 }
+ Here is the call graph for this function:

◆ makeMulti()

void makeMulti ( entity  e,
string  otherCvars 
)

Definition at line 90 of file util.qc.

References entity(), and saveCvarsMulti().

91 {
92  e.controlledCvars_Multi = otherCvars;
93  e.saveCvars_Multi = e.saveCvars;
94  e.saveCvars = saveCvarsMulti;
95 }
+ Here is the call graph for this function:

◆ makeXonoticCheckBox()

entity makeXonoticCheckBox ( float  ,
string  ,
string   
)

Definition at line 28 of file checkbox.qc.

References makeXonoticCheckBox_T(), and string_null.

Referenced by dialog_hudpanel_main_checkbox(), GameType_GetIcon(), XonoticDamageTextSettings::XonoticDamageTextSettings ::fill(), XonoticHUDHealthArmorDialog_fill(), XonoticHUDPowerupsDialog_fill(), and XonoticServerListTab_fill().

29 {
30  return makeXonoticCheckBox_T(isInverted, theCvar, theText, string_null);
31 }
string string_null
Definition: nil.qh:9
entity makeXonoticCheckBox_T(float isInverted, string theCvar, string theText, string theTooltip)
Definition: checkbox.qc:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeXonoticCheckBoxString()

entity makeXonoticCheckBoxString ( string  ,
string  ,
string  ,
string   
)

Definition at line 3 of file checkbox_string.qc.

References entity(), and NEW.

Referenced by GameType_GetIcon().

4 {
5  entity me;
7  me.configureXonoticCheckBoxString(me, theYesValue, theNoValue, theCvar, theText);
8  return me;
9 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeXonoticColorpickerString()

entity makeXonoticColorpickerString ( string  theCvar,
string  theDefaultCvar 
)

Definition at line 5 of file colorpicker_string.qc.

References entity(), and NEW.

Referenced by GameType_GetIcon().

6 {
7  entity me;
9  me.configureXonoticColorpickerString(me, theCvar, theDefaultCvar);
10  return me;
11 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeXonoticTextLabel()

entity makeXonoticTextLabel ( float  theAlign,
string  theText 
)

Definition at line 3 of file textlabel.qc.

References entity(), and NEW.

Referenced by dialog_hudpanel_main_settings(), GameType_GetIcon(), makeXonoticHeaderLabel(), XonoticBindingsResetDialog_fill(), XonoticCvarsDialog_fill(), XonoticDemoBrowserTab_fill(), XonoticDemoStartConfirmDialog_fill(), XonoticDemoTimeConfirmDialog_fill(), XonoticDisconnectDialog_fill(), XonoticFirstRunDialog_fill(), XonoticHUDAmmoDialog_fill(), XonoticHUDCenterprintDialog_fill(), XonoticHUDChatDialog_fill(), XonoticHUDConfirmDialog_fill(), XonoticHUDEngineInfoDialog_fill(), XonoticHUDInfoMessagesDialog_fill(), XonoticHUDNotificationDialog_fill(), XonoticHUDQuickMenuDialog_fill(), XonoticHUDScoreDialog_fill(), XonoticHUDTimerDialog_fill(), XonoticHUDVoteDialog_fill(), XonoticHUDWeaponsDialog_fill(), XonoticLanguageWarningDialog_fill(), XonoticMapInfoDialog_fill(), XonoticMonsterToolsDialog_fill(), XonoticMusicPlayerTab_fill(), XonoticMutatorsDialog_fill(), XonoticQuitDialog_fill(), XonoticResetDialog_fill(), XonoticSandboxToolsDialog_fill(), XonoticScreenshotBrowserTab_fill(), XonoticServerInfoTab_fill(), XonoticUid2NameDialog_fill(), and XonoticUserbindEditDialog_fill().

4 {
5  entity me;
6  me = NEW(XonoticTextLabel);
7  me.configureXonoticTextLabel(me, theAlign, theText);
8  return me;
9 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeXonoticTextSlider()

entity makeXonoticTextSlider ( string  )

Definition at line 10 of file textslider.qc.

References makeXonoticTextSlider_T(), and string_null.

Referenced by GameType_GetIcon(), XonoticHUDItemsTimeDialog_fill(), XonoticHUDPhysicsDialog_fill(), XonoticHUDPressedKeysDialog_fill(), XonoticHUDRadarDialog_fill(), and XonoticHUDStrafeHUDDialog_fill().

11 {
12  return makeXonoticTextSlider_T(theCvar, string_null);
13 }
string string_null
Definition: nil.qh:9
entity makeXonoticTextSlider_T(string theCvar, string theTooltip)
Definition: textslider.qc:3
+ 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:

◆ resolvemod()

string resolvemod ( string  m)

Definition at line 620 of file util.qc.

References getcurrentmod().

Referenced by XonoticServerList_refreshServerList().

621 {
622  if(m == "=")
623  return getcurrentmod();
624  else
625  return m;
626 }
string getcurrentmod()
Definition: util.qc:1191
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAllCvars()

void saveAllCvars ( entity  root)

Definition at line 47 of file util.qc.

References forAllDescendants(), NULL, saveCvarsOf(), and SUB_Null_ee().

48 {
50 }
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:

◆ saveCvarsCallback()

void saveCvarsCallback ( entity  me)

Definition at line 100 of file util.qc.

Referenced by makeCallback().

101 {
102  me.saveCvars_Callback(me);
103  me.saveCvars_Callback_func(me.saveCvars_Callback_ent, me);
104 }
+ Here is the caller graph for this function:

◆ saveCvarsMulti()

void saveCvarsMulti ( entity  me)

Definition at line 64 of file util.qc.

References argv(), CheckSendCvars(), cvar_set(), cvar_string(), strlen(), substring(), and tokenize_console.

Referenced by makeMulti().

65 {
66  float n, i;
67  string s, cvarname;
68 
69  me.saveCvars_Multi(me);
70  s = cvar_string(me.controlledCvar);
71 
72  n = tokenize_console(me.controlledCvars_Multi);
73  for(i = 0; i < n; ++i)
74  {
75  // cvars prefixed with ! get saved with the inverted value
76  if(substring(argv(i), 0, 1) == "!")
77  {
78  cvarname = substring(argv(i), 1, strlen(argv(i)));
79  cvar_set(cvarname, ((s == "0") ? "1" : "0"));
80  }
81  else
82  {
83  cvarname = argv(i);
84  cvar_set(cvarname, s);
85  }
86 
87  CheckSendCvars(me, cvarname);
88  }
89 }
#define tokenize_console
Definition: dpextensions.qh:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveCvarsOf()

void saveCvarsOf ( entity  ignore,
entity  e 
)

Definition at line 35 of file util.qc.

References entity().

Referenced by saveAllCvars().

36 {
37  if(e.saveCvars)
38  e.saveCvars(e);
39 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDependent()

void setDependent ( entity  e,
string  theCvarName,
float  theCvarMin,
float  theCvarMax 
)

Definition at line 178 of file util.qc.

References func_null(), setDependent_Check(), setDependent_Draw(), and string_null.

179 {
180  e.draw_setDependent = e.draw;
181  e.cvar_setDependent = theCvarName;
182  e.cvarMin_setDependent = theCvarMin;
183  e.cvarMax_setDependent = theCvarMax;
184  e.cvar2_setDependent = string_null;
185  e.cvar3_setDependent = string_null;
186  e.func_setDependent = func_null;
187  e.draw = setDependent_Draw;
189 }
string string_null
Definition: nil.qh:9
var void func_null()
+ Here is the call graph for this function:

◆ setDependent_Check()

void setDependent_Check ( entity  e)

Definition at line 128 of file util.qc.

References cvar(), and cvar_string().

Referenced by setDependent(), setDependent_Draw(), setDependentAND(), setDependentAND3(), setDependentOR(), setDependentStringNotEqual(), and setDependentWeird().

129 {
130  bool disabled_prev = e.disabled;
131  float f;
132  string s;
133  if(e.func_setDependent)
134  {
135  e.disabled = !(e.func_setDependent(e));
136  }
137  else if(e.cvarString_setDependent)
138  {
139  s = cvar_string(e.cvarString_setDependent);
140  e.disabled = (cvar_string(e.cvarString_setDependent) == e.cvarValue_setDependent);
141  }
142  else
143  {
144  if(e.cvar_setDependent)
145  {
146  f = cvar(e.cvar_setDependent);
147  if(e.cvarMin_setDependent <= e.cvarMax_setDependent)
148  e.disabled = ((f < e.cvarMin_setDependent) || (f > e.cvarMax_setDependent));
149  else
150  e.disabled = ((f >= e.cvarMax_setDependent) && (f <= e.cvarMin_setDependent));
151  }
152  if(e.cvar2_setDependent)
153  {
154  f = cvar(e.cvar2_setDependent);
155  if(e.cvar2Min_setDependent <= e.cvar2Max_setDependent)
156  e.disabled = (e.disabled + ((f < e.cvar2Min_setDependent) || (f > e.cvar2Max_setDependent)) > e.op_setDependent);
157  else
158  e.disabled = (e.disabled + ((f >= e.cvar2Max_setDependent) && (f <= e.cvar2Min_setDependent)) > e.op_setDependent);
159  }
160  if(e.cvar3_setDependent)
161  {
162  f = cvar(e.cvar3_setDependent);
163  if(e.cvar3Min_setDependent <= e.cvar3Max_setDependent)
164  e.disabled = (e.disabled + ((f < e.cvar3Min_setDependent) || (f > e.cvar3Max_setDependent)) > e.op_setDependent);
165  else
166  e.disabled = (e.disabled + ((f >= e.cvar3Max_setDependent) && (f <= e.cvar3Min_setDependent)) > e.op_setDependent);
167  }
168  }
169  if (disabled_prev != e.disabled && e.loadCvars)
170  e.loadCvars(e);
171 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDependent_Draw()

void setDependent_Draw ( entity  e)

Definition at line 172 of file util.qc.

References entity(), and setDependent_Check().

Referenced by setDependent(), setDependentAND(), setDependentAND3(), setDependentOR(), setDependentStringNotEqual(), and setDependentWeird().

173 {
175  e.draw_setDependent(e);
176 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDependentAND()

void setDependentAND ( entity  e,
string  theCvarName,
float  theCvarMin,
float  theCvarMax,
string  theCvar2Name,
float  theCvar2Min,
float  theCvar2Max 
)

Definition at line 202 of file util.qc.

References func_null(), setDependent_Check(), setDependent_Draw(), and string_null.

203 {
204  e.draw_setDependent = e.draw;
205  e.cvar_setDependent = theCvarName;
206  e.cvarMin_setDependent = theCvarMin;
207  e.cvarMax_setDependent = theCvarMax;
208  e.cvar2_setDependent = theCvar2Name;
209  e.cvar2Min_setDependent = theCvar2Min;
210  e.cvar2Max_setDependent = theCvar2Max;
211  e.cvar3_setDependent = string_null;
212  e.op_setDependent = 0;
213  e.func_setDependent = func_null;
214  e.draw = setDependent_Draw;
216 }
string string_null
Definition: nil.qh:9
var void func_null()
+ Here is the call graph for this function:

◆ setDependentAND3()

void setDependentAND3 ( entity  e,
string  theCvarName,
float  theCvarMin,
float  theCvarMax,
string  theCvar2Name,
float  theCvar2Min,
float  theCvar2Max,
string  theCvar3Name,
float  theCvar3Min,
float  theCvar3Max 
)

Definition at line 232 of file util.qc.

References func_null(), setDependent_Check(), and setDependent_Draw().

233 {
234  e.draw_setDependent = e.draw;
235  e.cvar_setDependent = theCvarName;
236  e.cvarMin_setDependent = theCvarMin;
237  e.cvarMax_setDependent = theCvarMax;
238  e.cvar2_setDependent = theCvar2Name;
239  e.cvar2Min_setDependent = theCvar2Min;
240  e.cvar2Max_setDependent = theCvar2Max;
241  e.cvar3_setDependent = theCvar3Name;
242  e.cvar3Min_setDependent = theCvar3Min;
243  e.cvar3Max_setDependent = theCvar3Max;
244  e.op_setDependent = 0;
245  e.func_setDependent = func_null;
246  e.draw = setDependent_Draw;
248 }
var void func_null()
+ Here is the call graph for this function:

◆ setDependentOR()

void setDependentOR ( entity  e,
string  theCvarName,
float  theCvarMin,
float  theCvarMax,
string  theCvar2Name,
float  theCvar2Min,
float  theCvar2Max 
)

Definition at line 217 of file util.qc.

References func_null(), setDependent_Check(), setDependent_Draw(), and string_null.

218 {
219  e.draw_setDependent = e.draw;
220  e.cvar_setDependent = theCvarName;
221  e.cvarMin_setDependent = theCvarMin;
222  e.cvarMax_setDependent = theCvarMax;
223  e.cvar2_setDependent = theCvar2Name;
224  e.cvar2Min_setDependent = theCvar2Min;
225  e.cvar2Max_setDependent = theCvar2Max;
226  e.cvar3_setDependent = string_null;
227  e.op_setDependent = 1;
228  e.func_setDependent = func_null;
229  e.draw = setDependent_Draw;
231 }
string string_null
Definition: nil.qh:9
var void func_null()
+ Here is the call graph for this function:

◆ setDependentStringNotEqual()

void setDependentStringNotEqual ( entity  e,
string  theCvarName,
string  theCvarValue 
)

Definition at line 190 of file util.qc.

References func_null(), setDependent_Check(), setDependent_Draw(), and string_null.

191 {
192  e.draw_setDependent = e.draw;
193  e.cvarString_setDependent = theCvarName;
194  e.cvarValue_setDependent = theCvarValue;
195  e.cvar_setDependent = string_null;
196  e.cvar2_setDependent = string_null;
197  e.cvar3_setDependent = string_null;
198  e.func_setDependent = func_null;
199  e.draw = setDependent_Draw;
201 }
string string_null
Definition: nil.qh:9
var void func_null()
+ Here is the call graph for this function:

◆ setDependentWeird()

void setDependentWeird ( entity  e,
float(entity func 
)

Definition at line 249 of file util.qc.

References setDependent_Check(), and setDependent_Draw().

250 {
251  e.draw_setDependent = e.draw;
252  e.func_setDependent = func;
253  e.draw = setDependent_Draw;
255 }
+ Here is the call graph for this function:

◆ setZonedTooltip()

void setZonedTooltip ( entity  e,
string  theTooltip,
string  theCvar 
)

Definition at line 257 of file util.qc.

References prvm_language, strfree, string_null, and strzone().

Referenced by clearTooltip(), XonoticButton_configureXonoticButton(), XonoticCheckBox_configureXonoticCheckBox(), XonoticGametypeList_focusedItemChangeNotify(), XonoticInputBox_configureXonoticInputBox(), XonoticRadioButton_configureXonoticRadioButton(), XonoticRegisteredSettingsList_getTooltip_cb(), XonoticSlider_configureXonoticSlider(), and XonoticTextSlider_configureXonoticTextSlider().

258 {
259  if(theTooltip == "") // no tooltip, use cvar description then
260  {
261  if(theCvar != "" && prvm_language == "en")
262  {
263  string t = cvar_description(theCvar);
264  if(t != "" && t != "custom cvar")
265  theTooltip = t;
266  }
267  }
268  else if(theTooltip == "-") // no cvar description as tooltip
269  {
270  theTooltip = string_null;
271  }
272 
273  strfree(e.tooltip);
274  e.tooltip = (theTooltip != "") ? strzone(theTooltip) : string_null;
275 }
string string_null
Definition: nil.qh:9
string prvm_language
Definition: i18n.qh:8
#define strfree(this)
Definition: string.qh:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SUB_Null_ee()

void SUB_Null_ee ( entity  e1,
entity  e2 
)

Definition at line 30 of file util.qc.

References entity().

Referenced by loadAllCvars(), and saveAllCvars().

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

◆ updateCheck()

void updateCheck ( )

Definition at line 473 of file util.qc.

References argv(), cvar(), cvar_set(), cvar_string(), fexists(), floor(), ftos(), localcmd, Menu_Active, random(), tokenize_console, and URI_GET_UPDATENOTIFICATION.

Referenced by preMenuDraw(), and preMenuInit().

474 {
476  {
478  float startcnt;
479  string uri;
480 
481  cvar_set("cl_startcount", ftos(startcnt = cvar("cl_startcount") + 1));
482 
483  // for privacy, munge the start count a little
484  startcnt = floor((floor(startcnt / 10) + random()) * 10);
485  uri = sprintf("http://update.xonotic.org/checkupdate.txt?version=%s&cnt=%d", uri_escape(cvar_string("g_xonoticversion")), startcnt);
486  uri_get(uri, URI_GET_UPDATENOTIFICATION);
487  }
488 
490  {
491  float n, i;
492  float allgood;
494  allgood = true;
495  for(i = 0; i+1 < n; i += 2)
496  {
497  if(fexists(argv(i+1)))
498  continue;
499  allgood = false;
500  if(_Nex_ExtResponseSystem_PacksStep == 1) // first run
501  localcmd("\ncurl --pak \"", argv(i), "\"\n");
502  }
503  if(allgood)
504  {
506  {
507  if(!Menu_Active)
508  cvar_set("_menu_initialized", "0");
509  // HACK: cause m_hide call on next start
510  localcmd("\nmenu_restart\n");
511  }
513  }
514  else
516  }
517 
518 }
const int URI_GET_UPDATENOTIFICATION
Definition: urllib.qh:9
#define tokenize_console
Definition: dpextensions.qh:24
ERASEABLE bool fexists(string f)
Definition: file.qh:4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateCompression()

float updateCompression ( )

Definition at line 628 of file util.qc.

References cvar_set(), fexists(), GL_Have_TextureCompression(), and LOG_INFO.

Referenced by m_init(), and m_sync().

629 {
630  float have_dds, have_jpg, have_tga;
631  float can_dds;
632  have_dds = (fexists("dds/particles/particlefont.dds"));
633  have_jpg = (fexists("particles/particlefont.jpg"));
634  have_tga = (fexists("particles/particlefont.tga"));
635  can_dds = GL_Have_TextureCompression();
636  if(have_dds && (have_jpg || have_tga))
637  {
638  // both? Let's only use good quality precompressed files
639  // but ONLY if we actually support it!
640  if(can_dds)
641  {
642  // these builds are meant to have GOOD quality, so let's not compress non-skinframes
643  cvar_set("gl_texturecompression", "0");
644  return 1;
645 
646  //cvar_set("gl_texturecompression", cvar_string("r_texture_dds_load"));
647  //return 2;
648  }
649  else
650  {
651  cvar_set("gl_texturecompression", "0");
652  cvar_set("r_texture_dds_load", "0");
653  return 0;
654  }
655  }
656  else if(have_dds)
657  {
658  // DDS only? We probably always want texture compression
659  cvar_set("gl_texturecompression", "1");
660  cvar_set("r_texture_dds_load", "1");
661  if(!can_dds)
662  LOG_INFO(_("^1ERROR: Texture compression is required but not supported.\n^1Expect visual problems."));
663  return 0;
664  }
665  else
666  {
667  // TGA only? Allow runtime compression
668  if(can_dds)
669  {
670  cvar_set("gl_texturecompression", cvar_string("r_texture_dds_load"));
671  return 2;
672  }
673  else
674  {
675  cvar_set("gl_texturecompression", "0");
676  cvar_set("r_texture_dds_load", "0");
677  return 0;
678  }
679  }
680 }
#define LOG_INFO(...)
Definition: log.qh:70
ERASEABLE bool fexists(string f)
Definition: file.qh:4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateNotification_URI_Get_Callback()

void UpdateNotification_URI_Get_Callback ( float  id,
float  status,
string  data 
)

Definition at line 321 of file util.qc.

References APPEND_TO_STRING, argv(), cvar(), cvar_string(), LOG_INFO, LOG_TRACE, LOG_TRACEF, strstrofs, strzone(), substring(), tokenizebyseparator, and vercmp().

Referenced by URI_Get_Callback().

322 {
323  float n;
324 
326  {
327  LOG_TRACE("error: UpdateNotification_URI_Get_Callback has been called before");
328  return;
329  }
330  if(status != 0)
331  {
332  LOG_TRACEF("error receiving update notification: status is %d", status);
333  return;
334  }
335  if(substring(data, 0, 1) == "<")
336  {
337  LOG_TRACE("error: received HTML instead of an update notification");
338  return;
339  }
340  if(strstrofs(data, "\r", 0) != -1)
341  {
342  LOG_TRACE("error: received carriage returns from update notification server");
343  return;
344  }
345 
346  if(data == "")
347  n = 0;
348  else
349  n = tokenizebyseparator(data, "\n");
350 
351  float i;
352  string s;
353 
354  string un_version = "";
355  string un_tosversion = "";
356  string un_download = "";
357  string un_url = "";
358  string un_bannedservers = "";
359  string un_emergency_pk3s = "";
360  string un_promoted = "";
361  string un_recommended = "";
362  string un_compatexpire = "";
363 
364  for(i = 0; i < n; ++i)
365  {
366  s = substring(argv(i), 2, -1);
367  if(s == "") { continue; } // ignore empty lines
368 
369  switch(substring(argv(i), 0, 1))
370  {
371  case "V":
372  {
373  un_version = s;
374  break;
375  }
376  case "T":
377  {
378  un_tosversion = s;
379  break;
380  }
381  case "C":
382  {
383  un_compatexpire = s;
384  break;
385  }
386  case "D":
387  {
388  un_download = s;
389  break;
390  }
391  case "U":
392  {
393  un_url = s;
394  break;
395  }
396  case "B":
397  {
398  APPEND_TO_STRING(un_bannedservers, " ", s);
399  break;
400  }
401  case "E":
402  {
403  if(cvar("menu_updatecheck_getpacks"))
404  APPEND_TO_STRING(un_emergency_pk3s, " ", s);
405  break;
406  }
407  case "P":
408  {
409  APPEND_TO_STRING(un_promoted, " ", s);
410  break;
411  }
412  case "R":
413  {
414  APPEND_TO_STRING(un_recommended, " ", s);
415  break;
416  }
417  }
418  }
419 
420  if(un_version != "")
421  {
422  if(vercmp(cvar_string("g_xonoticversion"), un_version) < 0)
423  {
424  // update needed
426  if(un_download) { LOG_INFO(_("Update can be downloaded at:"), "\n", un_download); }
427  if(un_url) { _Nex_ExtResponseSystem_UpdateToURL = strzone(un_url); }
429  }
430  else if(cvar_string("g_xonoticversion") == un_version)
431  {
432  if(un_compatexpire != "")
433  {
434  string curdate = strftime(false, "%Y%m%d%H%M%S");
435  if (strcmp(curdate, un_compatexpire) >= 0)
437  }
438  }
439  }
440 
441  if(un_tosversion != "")
442  {
443  _Nex_ExtResponseSystem_NewToS = stof(un_tosversion);
444  }
445 
446  if(un_bannedservers != "")
447  {
448  _Nex_ExtResponseSystem_BannedServers = strzone(un_bannedservers);
450  }
451 
452  if(un_emergency_pk3s != "")
453  {
454  _Nex_ExtResponseSystem_Packs = strzone(un_emergency_pk3s);
456  }
457 
458  if(un_promoted != "")
459  {
462  }
463 
464  if(un_recommended != "")
465  {
468  }
469 }
#define APPEND_TO_STRING(list, sep, add)
Definition: util.qh:225
#define strcmp
Definition: dpextensions.qh:51
ERASEABLE int vercmp(string v1, string v2)
Definition: string.qh:488
#define LOG_INFO(...)
Definition: log.qh:70
#define LOG_TRACEF(...)
Definition: log.qh:82
#define strstrofs
Definition: dpextensions.qh:42
#define LOG_TRACE(...)
Definition: log.qh:81
#define tokenizebyseparator
Definition: dpextensions.qh:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ URI_Get_Callback()

void URI_Get_Callback ( float  id,
float  status,
string  data 
)

engine callback

Definition at line 291 of file util.qc.

References Curl_URI_Get_Callback(), LOG_INFOF, UpdateNotification_URI_Get_Callback(), URI_GET_CURL, URI_GET_CURL_END, URI_GET_DISCARD, URI_GET_UPDATENOTIFICATION, and url_URI_Get_Callback().

292 {
293  if(url_URI_Get_Callback(id, status, data))
294  {
295  // handled
296  }
297  else if (id == URI_GET_DISCARD)
298  {
299  // discard
300  }
301  else if (id >= URI_GET_CURL && id <= URI_GET_CURL_END)
302  {
303  // sv_cmd curl
304  Curl_URI_Get_Callback(id, status, data);
305  }
306  else if (id == URI_GET_UPDATENOTIFICATION)
307  {
308  UpdateNotification_URI_Get_Callback(id, status, data);
309  }
310  else
311  {
312  LOG_INFOF("Received HTTP request data for an invalid id %d.", id);
313  }
314 }
void Curl_URI_Get_Callback(int id, float status, string data)
Definition: generic.qc:31
ERASEABLE float url_URI_Get_Callback(int id, float status, string data)
Definition: urllib.qc:28
const int URI_GET_DISCARD
Definition: urllib.qh:4
const int URI_GET_CURL
Definition: urllib.qh:7
const int URI_GET_UPDATENOTIFICATION
Definition: urllib.qh:9
#define LOG_INFOF(...)
Definition: log.qh:71
const int URI_GET_CURL_END
Definition: urllib.qh:8
+ Here is the call graph for this function:

◆ void() [1/6]

void ( entity  )

◆ void() [2/6]

void ( entity  me,
entity  cb 
)

◆ void() [3/6]

void ( entity  ,
float  ,
float  ,
entity   
)

◆ void() [4/6]

void ( entity  ,
float   
)

◆ void() [5/6]

void ( entity  ,
float  ,
float   
)

◆ void() [6/6]

void ( entity  ,
string  ,
string   
)

Variable Documentation

◆ _Nex_ExtResponseSystem_Packs

string _Nex_ExtResponseSystem_Packs

Definition at line 287 of file util.qc.

◆ _Nex_ExtResponseSystem_PacksStep

float _Nex_ExtResponseSystem_PacksStep

Definition at line 288 of file util.qc.

◆ _Nex_ExtResponseSystem_Queried

float _Nex_ExtResponseSystem_Queried

Definition at line 284 of file util.qc.

◆ _Nex_ExtResponseSystem_UpdateTo

string _Nex_ExtResponseSystem_UpdateTo

Definition at line 285 of file util.qc.

◆ _Nex_ExtResponseSystem_UpdateToURL

string _Nex_ExtResponseSystem_UpdateToURL

Definition at line 286 of file util.qc.

◆ campaign_name_previous

string campaign_name_previous

Definition at line 557 of file util.qc.

◆ campaign_won_previous

float campaign_won_previous

Definition at line 558 of file util.qc.

◆ controlledCvar

string controlledCvar

Definition at line 29 of file util.qc.

◆ controlledCvars_Multi

string controlledCvars_Multi

Definition at line 56 of file util.qc.

◆ cvar2_setDependent

string cvar2_setDependent

Definition at line 117 of file util.qc.

◆ cvar2Max_setDependent

float cvar2Max_setDependent

Definition at line 119 of file util.qc.

◆ cvar2Min_setDependent

float cvar2Min_setDependent

Definition at line 118 of file util.qc.

◆ cvar3_setDependent

string cvar3_setDependent

Definition at line 120 of file util.qc.

◆ cvar3Max_setDependent

float cvar3Max_setDependent

Definition at line 122 of file util.qc.

◆ cvar3Min_setDependent

float cvar3Min_setDependent

Definition at line 121 of file util.qc.

◆ cvar_setDependent

string cvar_setDependent

Definition at line 114 of file util.qc.

◆ cvarMax_setDependent

float cvarMax_setDependent

Definition at line 116 of file util.qc.

◆ cvarMin_setDependent

float cvarMin_setDependent

Definition at line 115 of file util.qc.

◆ cvarString_setDependent

string cvarString_setDependent

Definition at line 124 of file util.qc.

◆ cvarValue_setDependent

string cvarValue_setDependent

Definition at line 125 of file util.qc.

◆ disabled

bool disabled

Definition at line 127 of file util.qc.

◆ firstChild

entity firstChild

Definition at line 23 of file util.qc.

Referenced by forAllDescendants().

◆ nextSibling

entity nextSibling

Definition at line 23 of file util.qc.

Referenced by forAllDescendants().

◆ op_setDependent

float op_setDependent

Definition at line 123 of file util.qc.

◆ parent

entity parent

Definition at line 23 of file util.qc.

Referenced by forAllDescendants().

◆ saveCvars_Callback_ent

entity saveCvars_Callback_ent

Definition at line 98 of file util.qc.

◆ sendCvars

bool sendCvars

Definition at line 762 of file util.qc.

◆ show_propermenu

bool show_propermenu = false

Definition at line 520 of file util.qc.

◆ winnerDialog

entity winnerDialog

Definition at line 561 of file util.qc.