Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
util.qc File Reference
#include "util.qh"
#include "dialog.qh"
#include "textslider.qh"
#include "../item.qh"
#include "../menu.qh"
#include <common/campaign_common.qh>
#include <common/constants.qh>
#include <common/gametypes/_mod.qh>
#include <common/util.qh>
#include <common/command/_mod.qh>
#include <menu/xonotic/gametypelist.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(id)
#define GAMETYPE(id)
#define GAMETYPE(it)
#define GAMETYPE(it)
#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 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)
bool GL_CheckExtension (string ext)
bool GL_Have_TextureCompression ()
bool isServerSingleplayer ()
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)
void makeServerSingleplayer ()
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).
void preMenuDraw ()
 this is run before the menu is drawn.
float preMenuInit ()
 you have to define this for pre-menu initialization.
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)
void setDependentNOT (entity e, string theCvarName, float theCvarValue)
void setDependentOR (entity e, string theCvarName, float theCvarMin, float theCvarMax)
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 ()
void updateCompression ()
void UpdateNotification_URI_Get_Callback (float id, float status, string data)
void URI_Get_Callback (float id, float status, string data)
 engine callback
 void (entity me, entity cb) saveCvars_Callback_func
 void (entity) saveCvars
 void (entity, float) TDempty
 void (entity, float, float) gotoRC
 void (entity, float, float, entity) TD
 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
entity firstChild
entity nextSibling
entity parent
entity saveCvars_Callback_ent
bool sendCvars
entity winnerDialog

Macro Definition Documentation

◆ GAMETYPE [1/4]

#define GAMETYPE ( id)
Value:
++i;

◆ GAMETYPE [2/4]

#define GAMETYPE ( id)
Value:
++i;

◆ GAMETYPE [3/4]

#define GAMETYPE ( it)
Value:
{ if (i++ == cnt) return it; }
float cnt
Definition powerups.qc:24

◆ GAMETYPE [4/4]

#define GAMETYPE ( it)
Value:
{ if (showall) ++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_MAYHEM) \
GAMETYPE(MAPINFO_TYPE_TEAM_MAYHEM) \
GAMETYPE(MAPINFO_TYPE_KEEPAWAY) \
GAMETYPE(MAPINFO_TYPE_TEAM_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_SURVIVAL) \
/* GAMETYPE(MAPINFO_TYPE_DUEL) */ \
#define GAMETYPE(it)

Definition at line 637 of file util.qc.

637#define GAMETYPES \
638 GAMETYPE(MAPINFO_TYPE_DEATHMATCH) \
639 GAMETYPE(MAPINFO_TYPE_TEAM_DEATHMATCH) \
640 GAMETYPE(MAPINFO_TYPE_CTF) \
641 GAMETYPE(MAPINFO_TYPE_CA) \
642 GAMETYPE(MAPINFO_TYPE_FREEZETAG) \
643 GAMETYPE(MAPINFO_TYPE_MAYHEM) \
644 GAMETYPE(MAPINFO_TYPE_TEAM_MAYHEM) \
645 GAMETYPE(MAPINFO_TYPE_KEEPAWAY) \
646 GAMETYPE(MAPINFO_TYPE_TEAM_KEEPAWAY) \
647 GAMETYPE(MAPINFO_TYPE_KEYHUNT) \
648 GAMETYPE(MAPINFO_TYPE_LMS) \
649 GAMETYPE(MAPINFO_TYPE_DOMINATION) \
650 GAMETYPE(MAPINFO_TYPE_NEXBALL) \
651 GAMETYPE(MAPINFO_TYPE_ONSLAUGHT) \
652 GAMETYPE(MAPINFO_TYPE_ASSAULT) \
653 GAMETYPE(MAPINFO_TYPE_SURVIVAL) \
654 /* GAMETYPE(MAPINFO_TYPE_DUEL) */ \
655 /**/

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

◆ HIDDEN_GAMETYPES

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

Definition at line 658 of file util.qc.

658#define HIDDEN_GAMETYPES \
659 GAMETYPE(MAPINFO_TYPE_RACE) \
660 GAMETYPE(MAPINFO_TYPE_CTS) \
661 GAMETYPE(MAPINFO_TYPE_INVASION) \
662 /**/

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

Function Documentation

◆ CheckSendCvars()

void CheckSendCvars ( entity me,
string cvarnamestring )

Definition at line 825 of file util.qc.

826{
827 if(me.sendCvars)
828 {
830 {
831 LOG_INFOF("Sending cvar: %s -> %s", cvarnamestring, cvar_string(cvarnamestring));
832 localcmd(sprintf("\nsendcvar %s\n", cvarnamestring));
833 }
834 }
835}
#define LOG_INFOF(...)
Definition log.qh:66
const int GAME_ISSERVER
Definition menu.qh:11
const int GAME_CONNECTED
Definition menu.qh:12
int gamestatus
Definition menu.qh:16
void localcmd(string command,...)
const string cvar_string(string name)

References cvar_string(), entity(), GAME_CONNECTED, GAME_ISSERVER, gamestatus, localcmd(), and LOG_INFOF.

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

◆ clearTooltip()

◆ dialog_hudpanel_main_checkbox()

void dialog_hudpanel_main_checkbox ( entity me,
string panelname )

Definition at line 722 of file util.qc.

723{
724 entity e;
725
726 me.TR(me);
727 me.TDempty(me, 1.5);
728 me.TD(me, 1, 2.5, e = makeXonoticCheckBox(0, strzone(strcat("hud_panel_", panelname)), _("Enable")));
729}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity makeXonoticCheckBox(float, string, string)
Definition checkbox.qc:28
string strzone(string s)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

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

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

◆ dialog_hudpanel_main_settings()

void dialog_hudpanel_main_settings ( entity me,
string panelname )

Definition at line 731 of file util.qc.

732{
733 float i;
734 entity e;
735
736 me.gotoRC(me, me.currentRow + 1.5, 0);
737 me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("Background:")));
738 me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg"))));
739 e.setValueSpace(e, e.valueSpace * 1.25);
740 e.addValue(e, _("Default"), "");
741 e.addValue(e, _("Disable"), "0");
742 e.addValue(e, strzone(strcat("border_", panelname)), strzone(strcat("border_", panelname)));
743 e.configureXonoticTextSliderValues(e);
744 me.TR(me);
745 me.TDempty(me, 0.2);
746 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Color:")));
747 setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg")), "0");
748 me.TD(me, 2, 2.6, e = makeXonoticColorpickerString(strzone(strcat("hud_panel_", panelname, "_bg_color")), "hud_panel_bg_color"));
749 setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_bg_color")), "");
750 me.TR(me);
751 me.TDempty(me, 0.4);
752 me.TD(me, 1, 3.6, e = makeXonoticCheckBoxString("", "1 1 1", strzone(strcat("hud_panel_", panelname, "_bg_color")), _("Default")));
753 me.TR(me);
754 me.TDempty(me, 0.2);
755 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Border size:")));
756 me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_border"))));
757 e.addValue(e, _("Default"), "");
758 e.addValue(e, _("Disable"), "0");
759 for(i = 1; i <= 10; ++i)
760 e.addValue(e, strzone(ftos_decimals(i * 2, 0)), strzone(ftos(i * 2)));
761 e.configureXonoticTextSliderValues(e);
762 me.TR(me);
763 me.TDempty(me, 0.2);
764 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Opacity:")));
765 me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_alpha"))));
766 e.addValue(e, _("Default"), "");
767 for(i = 1; i <= 20; ++i)
768 e.addValue(e, strzone(ftos_decimals_percentage(i / 20, 0)), strzone(ftos_mindecimals(i / 20)));
769 e.configureXonoticTextSliderValues(e);
770 me.TR(me);
771 me.TDempty(me, 0.2);
772 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Team color:")));
773 setDependentNOT(e, strzone(strcat("hud_panel_", panelname, "_bg_alpha")), 0);
774 me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_color_team"))));
775 e.addValue(e, _("Default"), "");
776 e.addValue(e, _("Disable"), "0");
777 for(i = 1; i <= 10; ++i)
778 e.addValue(e, strzone(ftos_decimals_percentage(i / 10, 0)), strzone(ftos_mindecimals(i / 10)));
779 e.configureXonoticTextSliderValues(e);
780 setDependentNOT(e, strzone(strcat("hud_panel_", panelname, "_bg_alpha")), 0);
781 me.TR(me);
782 me.TDempty(me, 0.4);
783 me.TD(me, 1, 3.6, e = makeXonoticCheckBox(0, "hud_configure_teamcolorforced", _("Test team color in configure mode")));
784 me.TR(me);
785 me.TDempty(me, 0.2);
786 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Padding:")));
787 me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_bg_padding"))));
788 e.addValue(e, _("Default"), "");
789 for(i = 0; i <= 10; ++i)
790 e.addValue(e, strzone(ftos_decimals(i - 5, 0)), strzone(ftos(i - 5)));
791 e.configureXonoticTextSliderValues(e);
792
793 string hide_ondeath = strcat("hud_panel_", panelname, "_hide_ondeath");
794 if(cvar_type(hide_ondeath) & CVAR_TYPEFLAG_EXISTS)
795 {
796 me.TR(me);
797 me.TDempty(me, 0.2);
798 me.TD(me, 1, 3.8, e = makeXonoticCheckBox(0, strzone(hide_ondeath), _("Hide on death")));
799 }
800
801 me.gotoRC(me, me.currentRow + 0.5, 0); me.setFirstColumn(me, me.currentColumn);
802}
float CVAR_TYPEFLAG_EXISTS
entity makeXonoticTextLabel(float theAlign, string theText)
Definition textlabel.qc:3
void setDependentStringNotEqual(entity e, string theCvarName, string theCvarValue)
Definition util.qc:204
entity makeXonoticTextSlider(string)
Definition textslider.qc:10
entity makeXonoticCheckBoxString(string, string, string, string)
void setDependentNOT(entity e, string theCvarName, float theCvarValue)
Definition util.qc:192
entity makeXonoticColorpickerString(string theCvar, string theDefaultCvar)
string ftos(float f)
ERASEABLE string ftos_decimals(float number, int decimals)
converts a number to a string with the indicated number of decimals
Definition string.qh:469
ERASEABLE string ftos_mindecimals(float number)
Converts a number to a string with the minimum number of decimals It assumes that an extreme accuracy...
Definition string.qh:497
ERASEABLE string ftos_decimals_percentage(float number, int decimals)
converts a percentage to a string with the indicated number of decimals
Definition string.qh:480

References CVAR_TYPEFLAG_EXISTS, entity(), ftos(), ftos_decimals(), ftos_decimals_percentage(), ftos_mindecimals(), makeXonoticCheckBox(), makeXonoticCheckBoxString(), makeXonoticColorpickerString(), makeXonoticTextLabel(), makeXonoticTextSlider(), setDependentNOT(), setDependentStringNotEqual(), strcat(), and strzone().

Referenced by XonoticHUDAmmoDialog_fill(), XonoticHUDCenterprintDialog_fill(), XonoticHUDChatDialog_fill(), XonoticHUDCheckpointsDialog_fill(), XonoticHUDEngineInfoDialog_fill(), XonoticHUDHealthArmorDialog_fill(), XonoticHUDInfoMessagesDialog_fill(), XonoticHUDItemsTimeDialog_fill(), XonoticHUDModIconsDialog_fill(), XonoticHUDNotificationDialog_fill(), XonoticHUDPhysicsDialog_fill(), XonoticHUDPickupDialog_fill(), XonoticHUDPowerupsDialog_fill(), XonoticHUDPressedKeysDialog_fill(), XonoticHUDQuickMenuDialog_fill(), XonoticHUDRaceTimerDialog_fill(), XonoticHUDRadarDialog_fill(), XonoticHUDScoreDialog_fill(), XonoticHUDStrafeHUDDialog_fill(), XonoticHUDTimerDialog_fill(), XonoticHUDVoteDialog_fill(), and XonoticHUDWeaponsDialog_fill().

◆ DialogOpenButton_Click_withCoords()

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

Definition at line 35 of file modalcontroller.qc.

36 {
37 if (tab.ModalController_state) return;
38 if (button) button.forcePressed = true;
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 }

References entity(), and vector.

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

◆ forAllDescendants()

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

Definition at line 26 of file util.qc.

27{
28 depthfirst(root, parent, firstChild, nextSibling, funcPre, funcPost, pass);
29}
entity parent
Definition animhost.qc:7
void depthfirst(entity start,.entity up,.entity downleft,.entity right, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
Definition util.qc:393
#define pass(name, colormin, colormax)
entity nextSibling
Definition menu_cmd.qc:12
entity firstChild
Definition menu_cmd.qc:12

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

Referenced by loadAllCvars(), and saveAllCvars().

◆ GameType_GetCount()

int GameType_GetCount ( )

Definition at line 674 of file util.qc.

675{
676 int i = 0;
677 bool showall = autocvar_menu_create_show_all;
678 #define GAMETYPE(id) ++i;
680 #undef GAMETYPE
681 #define GAMETYPE(it) { if (showall) ++i; }
683 #undef GAMETYPE
684 return i;
685}
bool autocvar_menu_create_show_all
#define GAMETYPES
Definition util.qc:637
#define HIDDEN_GAMETYPES
Definition util.qc:658

References autocvar_menu_create_show_all, GAMETYPES, and HIDDEN_GAMETYPES.

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

◆ GameType_GetIcon()

string GameType_GetIcon ( int cnt)

Definition at line 703 of file util.qc.

704{
706 return i ? strcat("gametype_", MapInfo_Type_ToString(i)) : "";
707}
string MapInfo_Type_ToString(Gametype t)
Definition mapinfo.qc:656
Gametype GameType_GetID(int cnt)
Definition util.qc:664

References cnt, GameType_GetID(), MapInfo_Type_ToString(), and strcat().

Referenced by XonoticGametypeList_configureXonoticGametypeList(), and XonoticGametypeList_drawListBoxItem().

◆ GameType_GetID()

Gametype GameType_GetID ( int cnt)

Definition at line 664 of file util.qc.

665{
666 int i = 0;
667 #define GAMETYPE(it) { if (i++ == cnt) return it; }
670 #undef GAMETYPE
671 return NULL;
672}
#define NULL
Definition post.qh:14

References cnt, GAMETYPES, HIDDEN_GAMETYPES, and NULL.

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

◆ GameType_GetName()

string GameType_GetName ( int cnt)

Definition at line 697 of file util.qc.

698{
700 return i ? MapInfo_Type_ToText(i) : "";
701}
string MapInfo_Type_ToText(Gametype t)
Definition mapinfo.qc:661

References cnt, GameType_GetID(), and MapInfo_Type_ToText().

Referenced by XonoticGametypeList_drawListBoxItem().

◆ GameType_GetTotalCount()

int GameType_GetTotalCount ( )

Definition at line 687 of file util.qc.

688{
689 int i = 0;
690 #define GAMETYPE(id) ++i;
693 #undef GAMETYPE
694 return i;
695}

References GAMETYPES, and HIDDEN_GAMETYPES.

Referenced by XonoticGametypeList_configureXonoticGametypeList(), XonoticMapInfoDialog_fill(), and XonoticMapInfoDialog_loadMapInfo().

◆ getCvarsMulti()

string getCvarsMulti ( entity me)

Definition at line 60 of file util.qc.

61{
62 if (me.controlledCvars_Multi)
63 return me.controlledCvars_Multi;
64 return string_null;
65}

References entity(), and string_null.

Referenced by gettooltip().

◆ getFadedAlpha()

◆ GL_CheckExtension()

bool GL_CheckExtension ( string ext)

Definition at line 15 of file util.qc.

16{
17 return strhasword(cvar_string("gl_info_extensions"), ext);
18}
#define strhasword(s, w)
Definition string.qh:370

References cvar_string(), and strhasword.

Referenced by GL_Have_TextureCompression().

◆ GL_Have_TextureCompression()

bool GL_Have_TextureCompression ( )

Definition at line 20 of file util.qc.

21{
22 return GL_CheckExtension("GL_EXT_texture_compression_s3tc");
23}
bool GL_CheckExtension(string ext)
Definition util.qc:15

References GL_CheckExtension().

Referenced by updateCompression(), XonoticEffectsSettingsTab_fill(), and XonoticPicmipSlider_configureXonoticPicmipSlider().

◆ isServerSingleplayer()

bool isServerSingleplayer ( )

Definition at line 804 of file util.qc.

805{
806 return (cvar_string("net_address") == "127.0.0.1" && cvar_string("net_address_ipv6") == "::1");
807}

References cvar_string().

Referenced by leaveMatchButton_getText(), and leaveMatchButton_getTooltip().

◆ loadAllCvars()

◆ loadCvarsOf()

void loadCvarsOf ( entity ignore,
entity e )

Definition at line 44 of file util.qc.

45{
46 if(e.loadCvars)
47 e.loadCvars(e);
48}

References entity().

Referenced by loadAllCvars().

◆ makeCallback()

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

Definition at line 107 of file util.qc.

108{
109 e.saveCvars_Callback = e.saveCvars;
110 e.saveCvars = saveCvarsCallback;
111 e.saveCvars_Callback_ent = cbent;
112 e.saveCvars_Callback_func = cbfunc;
113}
void saveCvarsCallback(entity me)
Definition util.qc:102

References entity(), and saveCvarsCallback().

Referenced by XonoticServerCreateTab_fill().

◆ makeMulti()

◆ makeServerSingleplayer()

void makeServerSingleplayer ( )

Definition at line 809 of file util.qc.

810{
811 // it doesn't allow clients to connect from different machines
812 localcmd("defer 0.1 \"sv_cmd settemp net_address 127.0.0.1\"\n");
813 localcmd("defer 0.1 \"sv_cmd settemp net_address_ipv6 ::1\"\n");
814}

References localcmd().

Referenced by CampaignSetup(), and InstantAction_LoadMap().

◆ makeXonoticCheckBox()

entity makeXonoticCheckBox ( float isInverted,
string theCvar,
string theText )

Definition at line 28 of file checkbox.qc.

29{
30 return makeXonoticCheckBox_T(isInverted, theCvar, theText, string_null);
31}
entity makeXonoticCheckBox_T(float isInverted, string theCvar, string theText, string theTooltip)
Definition checkbox.qc:3

References entity(), makeXonoticCheckBox_T(), and string_null.

Referenced by dialog_hudpanel_main_checkbox(), dialog_hudpanel_main_settings(), XonoticAudioSettingsTab_fill(), XonoticCvarsDialog_fill(), XonoticDamageTextSettings_fill(), XonoticDemoBrowserTab_fill(), XonoticEffectsSettingsTab_fill(), XonoticGameCrosshairSettingsTab_fill(), XonoticGameHUDSettingsTab_fill(), XonoticGameModelSettingsTab_fill(), XonoticGameViewSettingsTab_fill(), XonoticGameWeaponsSettingsTab_fill(), XonoticHUDAmmoDialog_fill(), XonoticHUDCenterprintDialog_fill(), XonoticHUDChatDialog_fill(), XonoticHUDCheckpointsDialog_fill(), XonoticHUDEngineInfoDialog_fill(), XonoticHUDExitDialog_fill(), XonoticHUDHealthArmorDialog_fill(), XonoticHUDItemsTimeDialog_fill(), XonoticHUDModIconsDialog_fill(), XonoticHUDNotificationDialog_fill(), XonoticHUDPhysicsDialog_fill(), XonoticHUDPowerupsDialog_fill(), XonoticHUDPressedKeysDialog_fill(), XonoticHUDQuickMenuDialog_fill(), XonoticHUDStrafeHUDDialog_fill(), XonoticHUDTimerDialog_fill(), XonoticHUDWeaponsDialog_fill(), XonoticInputSettingsTab_fill(), XonoticMiscSettingsTab_fill(), XonoticMusicPlayerTab_fill(), XonoticProfileTab_fill(), XonoticServerListTab_fill(), XonoticUserSettingsTab_fill(), and XonoticVideoSettingsTab_fill().

◆ makeXonoticCheckBoxString()

entity makeXonoticCheckBoxString ( string theYesValue,
string theNoValue,
string theCvar,
string theText )

Definition at line 3 of file checkbox_string.qc.

4{
5 entity me;
7 me.configureXonoticCheckBoxString(me, theYesValue, theNoValue, theCvar, theText);
8 return me;
9}
#define NEW(cname,...)
Definition oo.qh:117

References entity(), and NEW.

Referenced by dialog_hudpanel_main_settings().

◆ makeXonoticColorpickerString()

entity makeXonoticColorpickerString ( string theCvar,
string theDefaultCvar )

◆ makeXonoticTextLabel()

entity makeXonoticTextLabel ( float theAlign,
string theText )

Definition at line 3 of file textlabel.qc.

4{
5 entity me;
7 me.configureLabel(me, theText, me.fontSize, theAlign);
8 return me;
9}

References entity(), and NEW.

Referenced by dialog_hudpanel_main_settings(), makeXonoticHeaderLabel(), XonoticAudioSettingsTab_fill(), XonoticBindingsResetDialog_fill(), XonoticCvarsDialog_fill(), XonoticDamageTextSettings_fill(), XonoticDemoBrowserTab_fill(), XonoticDemoStartConfirmDialog_fill(), XonoticDemoTimeConfirmDialog_fill(), XonoticEffectsSettingsTab_fill(), XonoticFirstRunDialog_fill(), XonoticGameCrosshairSettingsTab_fill(), XonoticGameHUDSettingsTab_fill(), XonoticGameMessageSettingsTab_fill(), XonoticGameModelSettingsTab_fill(), XonoticGameViewSettingsTab_fill(), XonoticGameWeaponsSettingsTab_fill(), XonoticGuideTab_fill(), XonoticHUDAmmoDialog_fill(), XonoticHUDCenterprintDialog_fill(), XonoticHUDChatDialog_fill(), XonoticHUDCheckpointsDialog_fill(), XonoticHUDConfirmDialog_fill(), XonoticHUDEngineInfoDialog_fill(), XonoticHUDExitDialog_fill(), XonoticHUDHealthArmorDialog_fill(), XonoticHUDInfoMessagesDialog_fill(), XonoticHUDItemsTimeDialog_fill(), XonoticHUDModIconsDialog_fill(), XonoticHUDNotificationDialog_fill(), XonoticHUDPhysicsDialog_fill(), XonoticHUDPickupDialog_fill(), XonoticHUDPowerupsDialog_fill(), XonoticHUDPressedKeysDialog_fill(), XonoticHUDQuickMenuDialog_fill(), XonoticHUDRadarDialog_fill(), XonoticHUDScoreDialog_fill(), XonoticHUDStrafeHUDDialog_fill(), XonoticHUDTimerDialog_fill(), XonoticHUDVoteDialog_fill(), XonoticHUDWeaponsDialog_fill(), XonoticInputSettingsTab_fill(), XonoticLanguageWarningDialog_fill(), XonoticMapInfoDialog_fill(), XonoticMiscSettingsTab_fill(), XonoticMonsterToolsDialog_fill(), XonoticMusicPlayerTab_fill(), XonoticMutatorsDialog_fill(), XonoticProfileTab_fill(), XonoticQuitDialog_fill(), XonoticResetDialog_fill(), XonoticSandboxToolsDialog_fill(), XonoticScreenshotBrowserTab_fill(), XonoticServerCreateTab_fill(), XonoticServerInfoTab_fill(), XonoticServerListTab_fill(), XonoticSingleplayerDialog_fill(), XonoticSkinResetDialog_fill(), XonoticToSDialog_fill(), XonoticUid2NameDialog_fill(), XonoticUserbindEditDialog_fill(), and XonoticVideoSettingsTab_fill().

◆ makeXonoticTextSlider()

entity makeXonoticTextSlider ( string theCvar)

Definition at line 10 of file textslider.qc.

11{
12 return makeXonoticTextSlider_T(theCvar, string_null);
13}
entity makeXonoticTextSlider_T(string theCvar, string theTooltip)
Definition textslider.qc:3

References entity(), makeXonoticTextSlider_T(), and string_null.

Referenced by dialog_hudpanel_main_settings(), XonoticGameModelSettingsTab_fill(), and XonoticHUDExitDialog_fill().

◆ 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 time
#define main
Definition _all.inc:202
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
void m_display()
Definition menu.qc:949
float conwidth
Definition menu.qh:36
float conheight
Definition menu.qh:36
float bound(float min, float value, float max)
float cvar(string name)
float cos(float f)
float sin(float f)
vector
Definition self.qh:92
#define strcpy(this, s)
Definition string.qh:52
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:110

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().

◆ resolvemod()

string resolvemod ( string m)

Definition at line 596 of file util.qc.

597{
598 if(m == "=")
599 return getcurrentmod();
600 else
601 return m;
602}
string getcurrentmod()
Definition util.qc:1327

References getcurrentmod().

Referenced by XonoticServerList_refreshServerList().

◆ saveAllCvars()

void saveAllCvars ( entity root)

Definition at line 49 of file util.qc.

50{
52}
void saveCvarsOf(entity ignore, entity e)
Definition util.qc:37

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

◆ saveCvarsCallback()

void saveCvarsCallback ( entity me)

Definition at line 102 of file util.qc.

103{
104 me.saveCvars_Callback(me);
105 me.saveCvars_Callback_func(me.saveCvars_Callback_ent, me);
106}

References entity().

Referenced by makeCallback().

◆ saveCvarsMulti()

void saveCvarsMulti ( entity me)

Definition at line 66 of file util.qc.

67{
68 float n, i;
69 string s, cvarname;
70
71 me.saveCvars_Multi(me);
72 s = cvar_string(me.controlledCvar);
73
74 n = tokenize_console(me.controlledCvars_Multi);
75 for(i = 0; i < n; ++i)
76 {
77 // cvars prefixed with ! get saved with the inverted value
78 if(substring(argv(i), 0, 1) == "!")
79 {
80 cvarname = substring(argv(i), 1, strlen(argv(i)));
81 cvar_set(cvarname, ((s == "0") ? "1" : "0"));
82 }
83 else
84 {
85 cvarname = argv(i);
86 cvar_set(cvarname, s);
87 }
88
89 CheckSendCvars(me, cvarname);
90 }
91}
#define strlen
#define tokenize_console
void CheckSendCvars(entity me, string cvarnamestring)
Definition util.qc:825
void cvar_set(string name, string value)
string substring(string s, float start, float length)
string argv(float n)

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

Referenced by makeMulti().

◆ saveCvarsOf()

void saveCvarsOf ( entity ignore,
entity e )

Definition at line 37 of file util.qc.

38{
39 if(e.saveCvars)
40 e.saveCvars(e);
41}

References entity().

Referenced by saveAllCvars().

◆ setDependent()

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

◆ setDependent_Check()

void setDependent_Check ( entity e)

Definition at line 127 of file util.qc.

128{
129 bool disabled_prev = e.disabled;
130 float f;
131 string s;
132 if (e.func_setDependent)
133 {
134 e.disabled = !(e.func_setDependent(e));
135 }
136 else if (e.cvarString_setDependent)
137 {
138 s = cvar_string(e.cvarString_setDependent);
139 e.disabled = (cvar_string(e.cvarString_setDependent) == e.cvarValue_setDependent);
140 }
141 else if (e.cvar1_setDependent)
142 {
143 f = cvar(e.cvar1_setDependent);
144 if (e.op_setDependent & BIT(1)) // NOT
145 e.disabled = (f == e.cvar1Min_setDependent);
146 else
147 {
148 if (e.cvar1Min_setDependent <= e.cvar1Max_setDependent)
149 e.disabled = ((f < e.cvar1Min_setDependent) || (f > e.cvar1Max_setDependent));
150 else
151 e.disabled = ((f >= e.cvar1Max_setDependent) && (f <= e.cvar1Min_setDependent));
152 }
153 }
154 int op = e.op_setDependent & BIT(0);
155 if (e.cvar2_setDependent)
156 {
157 f = cvar(e.cvar2_setDependent);
158 if (e.cvar2Min_setDependent <= e.cvar2Max_setDependent)
159 e.disabled = (e.disabled + ((f < e.cvar2Min_setDependent) || (f > e.cvar2Max_setDependent)) > op);
160 else
161 e.disabled = (e.disabled + ((f >= e.cvar2Max_setDependent) && (f <= e.cvar2Min_setDependent)) > op);
162 }
163 if (e.cvar3_setDependent)
164 {
165 f = cvar(e.cvar3_setDependent);
166 if (e.cvar3Min_setDependent <= e.cvar3Max_setDependent)
167 e.disabled = (e.disabled + ((f < e.cvar3Min_setDependent) || (f > e.cvar3Max_setDependent)) > op);
168 else
169 e.disabled = (e.disabled + ((f >= e.cvar3Max_setDependent) && (f <= e.cvar3Min_setDependent)) > op);
170 }
171 if (disabled_prev != e.disabled && e.loadCvars)
172 e.loadCvars(e);
173}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8

References BIT, cvar(), cvar_string(), and entity().

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

◆ setDependent_Draw()

void setDependent_Draw ( entity e)

Definition at line 174 of file util.qc.

175{
177 e.draw_setDependent(e);
178}

References entity(), and setDependent_Check().

Referenced by setDependent(), setDependentNOT(), setDependentStringNotEqual(), and setDependentWeird().

◆ setDependentAND()

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

Definition at line 213 of file util.qc.

214{
215 if (e.cvar2_setDependent)
216 {
217 e.cvar3_setDependent = theCvarName;
218 e.cvar3Min_setDependent = theCvarMin;
219 e.cvar3Max_setDependent = theCvarMax;
220 }
221 else
222 {
223 e.cvar2_setDependent = theCvarName;
224 e.cvar2Min_setDependent = theCvarMin;
225 e.cvar2Max_setDependent = theCvarMax;
226 }
227 e.op_setDependent &= ~BIT(0); // AND
228 e.func_setDependent = func_null;
230}

References BIT, entity(), func_null(), and setDependent_Check().

Referenced by XonoticDamageTextSettings_fill(), XonoticEffectsSettingsTab_fill(), XonoticGameCrosshairSettingsTab_fill(), XonoticGameHUDSettingsTab_fill(), XonoticGameMessageSettingsTab_fill(), XonoticGameViewSettingsTab_fill(), XonoticGameWeaponsSettingsTab_fill(), XonoticHUDAmmoDialog_fill(), XonoticHUDStrafeHUDDialog_fill(), XonoticHUDWeaponsDialog_fill(), and XonoticServerCreateTab_fill().

◆ setDependentNOT()

◆ setDependentOR()

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

Definition at line 231 of file util.qc.

232{
233 if (e.cvar2_setDependent)
234 {
235 e.cvar3_setDependent = theCvarName;
236 e.cvar3Min_setDependent = theCvarMin;
237 e.cvar3Max_setDependent = theCvarMax;
238 }
239 else
240 {
241 e.cvar2_setDependent = theCvarName;
242 e.cvar2Min_setDependent = theCvarMin;
243 e.cvar2Max_setDependent = theCvarMax;
244 }
245 e.op_setDependent |= BIT(0); // OR
246 e.func_setDependent = func_null;
248}

References BIT, entity(), func_null(), and setDependent_Check().

Referenced by XonoticEffectsSettingsTab_fill(), and XonoticHUDPhysicsDialog_fill().

◆ setDependentStringNotEqual()

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

Definition at line 204 of file util.qc.

205{
206 e.draw_setDependent = e.draw;
207 e.cvarString_setDependent = theCvarName;
208 e.cvarValue_setDependent = theCvarValue;
209 e.func_setDependent = func_null;
210 e.draw = setDependent_Draw;
212}

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

Referenced by dialog_hudpanel_main_settings().

◆ setDependentWeird()

void setDependentWeird ( entity e,
float(entity) func )

Definition at line 249 of file util.qc.

250{
251 e.draw_setDependent = e.draw;
252 e.func_setDependent = func;
253 e.draw = setDependent_Draw;
255}

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

Referenced by XonoticEffectsSettingsTab_fill(), XonoticFirstRunDialog_fill(), and XonoticMutatorsDialog_fill().

◆ setZonedTooltip()

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

Definition at line 257 of file util.qc.

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 prvm_language
Definition i18n.qh:8
#define strfree(this)
Definition string.qh:59

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

Referenced by clearTooltip(), XonoticRegisteredSettingsList::focusedItemChangeNotify(), ServerList_Update_favoriteButton(), XonoticButton_configureXonoticButton(), XonoticCheckBox_configureXonoticCheckBox(), XonoticGametypeList_focusedItemChangeNotify(), XonoticInputBox_configureXonoticInputBox(), XonoticLanguageList_focusedItemChangeNotify(), XonoticLeaveMatchButton_draw(), XonoticMixedSlider_configureXonoticMixedSlider(), XonoticRadioButton_configureXonoticRadioButton(), XonoticServerInfoDialog_loadServerInfo(), XonoticServerList_drawListBoxItem(), XonoticSlider_configureXonoticSlider(), and XonoticTextSlider_configureXonoticTextSlider().

◆ SUB_Null_ee()

void SUB_Null_ee ( entity e1,
entity e2 )

Definition at line 32 of file util.qc.

33{
34}

References entity().

Referenced by loadAllCvars(), and saveAllCvars().

◆ updateCheck()

void updateCheck ( )

Definition at line 456 of file util.qc.

457{
459 {
461 cvar_set("cl_startcount", ftos(cvar("cl_startcount") + 1));
462 uri_get("https://update.xonotic.org/checkupdate.txt", URI_GET_UPDATENOTIFICATION);
463 }
464
466 {
467 float n, i;
468 float allgood;
470 allgood = true;
471 for(i = 0; i+1 < n; i += 2)
472 {
473 if(strcmp(argv(i+1), cvar_string("g_xonoticversion"))) // these aren't the versions we're looking for
474 continue;
475 string packfn = whichpack("hotfix-autoexec.cfg");
476 if(packfn) // we have the cfg we're looking for in some pk3
477 {
478 if(!strncmp(packfn, "dlcache/", 8)) // it's in dlcache
479 packfn = substring(packfn, 8, strlen(packfn)); // strip prefix "dlcache/"
480 if(strstrofs(argv(i), packfn, strlen(argv(i)) - strlen(packfn)) > 0) // last chars of url == packfn
481 continue; // the pk3 we're looking for already provides the cfg we're looking for
482 }
483 allgood = false;
484 if(_Nex_ExtResponseSystem_PacksStep == 1) // first run
485 localcmd("\ncurl --pak \"", argv(i), "\"\n");
486 }
487 if(allgood)
488 {
490 {
491 if(!Menu_Active)
492 cvar_set("_menu_initialized", "0");
493 // HACK: cause m_hide call on next start
494 //localcmd("\nmenu_restart\n"); // <= 0.8.5
495 localcmd("\nexec hotfix-autoexec.cfg\n");
496 }
498 }
499 else
501 }
502}
#define strstrofs
#define strcmp
#define strncmp
string _Nex_ExtResponseSystem_Packs
Definition util.qc:287
float _Nex_ExtResponseSystem_PacksStep
Definition util.qc:288
float _Nex_ExtResponseSystem_Queried
Definition util.qc:284
bool Menu_Active
Definition menu.qh:15
const int URI_GET_UPDATENOTIFICATION
Definition urllib.qh:9

References _Nex_ExtResponseSystem_Packs, _Nex_ExtResponseSystem_PacksStep, _Nex_ExtResponseSystem_Queried, argv(), cvar(), cvar_set(), cvar_string(), ftos(), localcmd(), Menu_Active, strcmp, strlen, strncmp, strstrofs, substring(), tokenize_console, and URI_GET_UPDATENOTIFICATION.

Referenced by preMenuDraw(), and preMenuInit().

◆ updateCompression()

void updateCompression ( )

Definition at line 604 of file util.qc.

605{
606 bool have_dds = (fexists("dds/particles/particlefont.dds"));
607 bool have_jpg = (fexists("particles/particlefont.jpg"));
608 bool have_tga = (fexists("particles/particlefont.tga"));
609 bool can_dds = GL_Have_TextureCompression();
610
611 if (!can_dds)
612 cvar_set("gl_texturecompression", "0");
613
614 if(have_dds && (have_jpg || have_tga))
615 {
616 // both? Let's only use good quality precompressed files
617 // but ONLY if we actually support it!
618 // bones_was_here: quality settings moved to effects configs and menu
619 }
620 else if(have_dds)
621 {
622 // DDS only? We _must_ load DDS files!
623 cvar_set("r_texture_dds_load", "1");
624 if(!can_dds)
625 {
626 cvar_set("r_texture_dds_swdecode", "1");
627 LOG_WARN(_("^1ERROR: Texture compression is required but not supported.\n^1Expect visual problems."));
628 }
629 }
630 else
631 {
632 // TGA only? Allow runtime compression
633 }
634}
ERASEABLE bool fexists(string f)
Definition file.qh:4
#define LOG_WARN(...)
Definition log.qh:61
bool GL_Have_TextureCompression()
Definition util.qc:20

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

Referenced by m_init(), and m_sync().

◆ UpdateNotification_URI_Get_Callback()

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

Definition at line 316 of file util.qc.

317{
318 float n;
319
321 {
322 LOG_TRACE("error: UpdateNotification_URI_Get_Callback has been called before");
323 return;
324 }
325 if(status != 0)
326 {
327 LOG_TRACEF("error receiving update notification: status is %d", status);
328 return;
329 }
330 if(substring(data, 0, 1) == "<")
331 {
332 LOG_TRACE("error: received HTML instead of an update notification");
333 return;
334 }
335 if(strstrofs(data, "\r", 0) != -1)
336 {
337 LOG_TRACE("error: received carriage returns from update notification server");
338 return;
339 }
340
341 if(data == "")
342 n = 0;
343 else
344 n = tokenizebyseparator(data, "\n");
345
346 float i;
347 string s;
348
349 string un_version = "";
350 string un_tosversion = "";
351 string un_download = "";
352 string un_url = "";
353 string un_bannedservers = "";
354 string un_emergency_pk3s = "";
355 string un_promoted = "";
356 string un_recommended = "";
357 string un_compatexpire = "";
358
359 for(i = 0; i < n; ++i)
360 {
361 s = substring(argv(i), 2, -1);
362 if(s == "") { continue; } // ignore empty lines
363
364 switch(substring(argv(i), 0, 1))
365 {
366 case "V":
367 {
368 un_version = s;
369 break;
370 }
371 case "T":
372 {
373 un_tosversion = s;
374 break;
375 }
376 case "C":
377 {
378 un_compatexpire = s;
379 break;
380 }
381 case "D":
382 {
383 un_download = s;
384 break;
385 }
386 case "U":
387 {
388 un_url = s;
389 break;
390 }
391 case "B":
392 {
393 APPEND_TO_STRING(un_bannedservers, " ", s);
394 break;
395 }
396 case "H":
397 {
398 // Hotfix (version-specific pk3 supported in >= 0.8.6)
399 // replaces "E" (missing-file-specific pk3 supported in <= 0.8.5)
400 APPEND_TO_STRING(un_emergency_pk3s, " ", s);
401 break;
402 }
403 case "P":
404 {
405 APPEND_TO_STRING(un_promoted, " ", s);
406 break;
407 }
408 case "R":
409 {
410 APPEND_TO_STRING(un_recommended, " ", s);
411 break;
412 }
413 }
414 }
415
416 if(un_version != "" && vercmp(cvar_string("g_xonoticversion"), un_version) < 0)
417 {
418 // update needed
420 if(un_download) { LOG_INFO(_("Update can be downloaded at:"), "\n", un_download); }
421 if(un_url) { _Nex_ExtResponseSystem_UpdateToURL = strzone(un_url); }
422 }
423
424 if(un_tosversion != "")
425 {
426 _Nex_ExtResponseSystem_NewToS = stof(un_tosversion);
427 }
428
429 if(un_bannedservers != "")
430 {
433 }
434
435 if(un_emergency_pk3s != "")
436 {
437 _Nex_ExtResponseSystem_Packs = strzone(un_emergency_pk3s);
439 }
440
441 if(un_promoted != "")
442 {
445 }
446
447 if(un_recommended != "")
448 {
451 }
452}
#define APPEND_TO_STRING(list, sep, add)
Definition util.qh:265
#define tokenizebyseparator
#define LOG_TRACEF(...)
Definition log.qh:77
#define LOG_INFO(...)
Definition log.qh:65
#define LOG_TRACE(...)
Definition log.qh:76
float _Nex_ExtResponseSystem_BannedServersNeedsRefresh
Definition util.qh:63
float _Nex_ExtResponseSystem_RecommendedServersNeedsRefresh
Definition util.qh:67
string _Nex_ExtResponseSystem_BannedServers
Definition util.qh:62
string _Nex_ExtResponseSystem_PromotedServers
Definition util.qh:64
float _Nex_ExtResponseSystem_NewToS
Definition util.qh:68
string _Nex_ExtResponseSystem_RecommendedServers
Definition util.qh:66
float _Nex_ExtResponseSystem_PromotedServersNeedsRefresh
Definition util.qh:65
float stof(string val,...)
ERASEABLE int vercmp(string v1, string v2)
Definition string.qh:557

References _Nex_ExtResponseSystem_BannedServers, _Nex_ExtResponseSystem_BannedServersNeedsRefresh, _Nex_ExtResponseSystem_NewToS, _Nex_ExtResponseSystem_Packs, _Nex_ExtResponseSystem_PacksStep, _Nex_ExtResponseSystem_PromotedServers, _Nex_ExtResponseSystem_PromotedServersNeedsRefresh, _Nex_ExtResponseSystem_RecommendedServers, _Nex_ExtResponseSystem_RecommendedServersNeedsRefresh, _Nex_ExtResponseSystem_UpdateTo, _Nex_ExtResponseSystem_UpdateToURL, APPEND_TO_STRING, argv(), cvar_string(), LOG_INFO, LOG_TRACE, LOG_TRACEF, stof(), strstrofs, strzone(), substring(), tokenizebyseparator, and vercmp().

Referenced by URI_Get_Callback().

◆ URI_Get_Callback()

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

engine callback

Definition at line 291 of file util.qc.

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
void UpdateNotification_URI_Get_Callback(float id, float status, string data)
Definition util.qc:316
ERASEABLE float url_URI_Get_Callback(int id, float status, string data)
Definition urllib.qc:28
const int URI_GET_CURL
Definition urllib.qh:7
const int URI_GET_DISCARD
Definition urllib.qh:4
const int URI_GET_CURL_END
Definition urllib.qh:8

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().

◆ void() [1/6]

void ( entity me,
entity cb )

References entity().

◆ void() [2/6]

void ( entity )

References entity().

◆ void() [3/6]

void ( entity ,
float  )

References entity().

◆ void() [4/6]

void ( entity ,
float ,
float  )

References entity().

◆ void() [5/6]

void ( entity ,
float ,
float ,
entity  )

References entity().

◆ void() [6/6]

void ( entity ,
string ,
string  )

References entity().

Variable Documentation

◆ _Nex_ExtResponseSystem_Packs

string _Nex_ExtResponseSystem_Packs

Definition at line 287 of file util.qc.

Referenced by updateCheck(), and UpdateNotification_URI_Get_Callback().

◆ _Nex_ExtResponseSystem_PacksStep

float _Nex_ExtResponseSystem_PacksStep

Definition at line 288 of file util.qc.

Referenced by updateCheck(), and UpdateNotification_URI_Get_Callback().

◆ _Nex_ExtResponseSystem_Queried

float _Nex_ExtResponseSystem_Queried

Definition at line 284 of file util.qc.

Referenced by updateCheck().

◆ _Nex_ExtResponseSystem_UpdateTo

string _Nex_ExtResponseSystem_UpdateTo

Definition at line 285 of file util.qc.

Referenced by preMenuDraw(), and UpdateNotification_URI_Get_Callback().

◆ _Nex_ExtResponseSystem_UpdateToURL

string _Nex_ExtResponseSystem_UpdateToURL

Definition at line 286 of file util.qc.

Referenced by preMenuDraw(), and UpdateNotification_URI_Get_Callback().

◆ campaign_name_previous

string campaign_name_previous

Definition at line 536 of file util.qc.

Referenced by preMenuDraw().

◆ campaign_won_previous

float campaign_won_previous

Definition at line 537 of file util.qc.

Referenced by preMenuDraw().

◆ controlledCvar

string controlledCvar

Definition at line 31 of file util.qc.

◆ controlledCvars_Multi

string controlledCvars_Multi

Definition at line 58 of file util.qc.

◆ firstChild

entity firstChild

Definition at line 25 of file util.qc.

◆ nextSibling

entity nextSibling

Definition at line 25 of file util.qc.

◆ parent

entity parent

Definition at line 25 of file util.qc.

◆ saveCvars_Callback_ent

entity saveCvars_Callback_ent

Definition at line 100 of file util.qc.

◆ sendCvars

bool sendCvars

Definition at line 720 of file util.qc.

◆ winnerDialog

entity winnerDialog

Definition at line 540 of file util.qc.

Referenced by MainWindow::ATTRIB().