X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Futil.qc;h=49fe79b011df800f4ef3e553343658abb8bfcce7;hp=76abad81fbe715fcf514c2082e80ae1bfb95380a;hb=20387ff9f8cef7536362de05c76cc0062416a64c;hpb=fca9d306878750e9523e97225c36a4237559b729 diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index 76abad81fb..49fe79b011 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -1,3 +1,5 @@ +#include "../../common/urllib.qh" + float GL_CheckExtension(string ext) { return (strstrofs(strcat(" ", cvar_string("gl_info_extensions"), " "), strcat(" ", ext, " "), 0) >= 0); @@ -92,6 +94,8 @@ void saveCvarsMulti(entity me) cvar_set(substring(argv(i), 1, strlen(argv(i))), ((s == "0") ? "1" : "0")); else cvar_set(argv(i), s); + + CheckSendCvars(me, argv(i)); } } void makeMulti(entity e, string otherCvars) @@ -305,17 +309,17 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data) } if(status != 0) { - printf(_("error receiving update notification: status is %d\n"), status); + dprintf("error receiving update notification: status is %d\n", status); return; } if(substring(data, 0, 1) == "<") { - print(_("error: received HTML instead of an update notification\n")); + dprint("error: received HTML instead of an update notification\n"); return; } if(strstrofs(data, "\r", 0) != -1) { - print(_("error: received carriage returns from update notification server\n")); + dprint("error: received carriage returns from update notification server\n"); return; } @@ -325,8 +329,8 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data) n = tokenizebyseparator(data, "\n"); float i; - string s; - + string s; + string un_version = ""; string un_download = ""; string un_url = ""; @@ -335,12 +339,12 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data) string un_promoted = ""; string un_recommended = ""; string un_compatexpire = ""; - + for(i = 0; i < n; ++i) { s = substring(argv(i), 2, -1); if(s == "") { continue; } // ignore empty lines - + switch(substring(argv(i), 0, 1)) { case "V": @@ -401,13 +405,13 @@ void UpdateNotification_URI_Get_Callback(float id, float status, string data) { if(un_compatexpire != "") { - string curdate = strftime(FALSE, "%Y%m%d%H%M%S"); + string curdate = strftime(false, "%Y%m%d%H%M%S"); if (strcmp(curdate, un_compatexpire) >= 0) DisableServerBackwardsCompatibility(); } } } - + if(un_emergency_pk3s != "") { _Nex_ExtResponseSystem_Packs = strzone(un_emergency_pk3s); @@ -453,12 +457,12 @@ void updateCheck() float n, i; float allgood; n = tokenize_console(_Nex_ExtResponseSystem_Packs); - allgood = TRUE; + allgood = true; for(i = 0; i+1 < n; i += 2) { if(fexists(argv(i+1))) continue; - allgood = FALSE; + allgood = false; if(_Nex_ExtResponseSystem_PacksStep == 1) // first run localcmd("\ncurl --pak \"", argv(i), "\"\n"); } @@ -492,11 +496,11 @@ float preMenuInit() { draw_reset_cropped(); - sz = eX * 0.025 + eY * 0.025 * (draw_scale_x / draw_scale_y); - draw_CenterText('0.5 0.5 0' - 1.25 * sz_y * eY, _("Autogenerating mapinfo for newly added maps..."), sz, '1 1 1', 1, 0); + sz = eX * 0.025 + eY * 0.025 * (draw_scale.x / draw_scale.y); + draw_CenterText('0.5 0.5 0' - 1.25 * sz.y * eY, _("Autogenerating mapinfo for newly added maps..."), sz, '1 1 1', 1, 0); - boxA = '0.05 0.5 0' + 0.25 * sz_y * eY; - boxB = '0.95 0.5 0' + 1.25 * sz_y * eY; + boxA = '0.05 0.5 0' + 0.25 * sz.y * eY; + boxB = '0.95 0.5 0' + 1.25 * sz.y * eY; draw_Fill(boxA, boxB - boxA, '1 1 1', 1); boxA += sz * 0.1; @@ -506,17 +510,17 @@ float preMenuInit() boxB_x = boxA_x * (1 - MapInfo_progress) + boxB_x * MapInfo_progress; draw_Fill(boxA, boxB - boxA, '0 0 1', 1); - return FALSE; + return false; } - return TRUE; + return true; } string campaign_name_previous; float campaign_won_previous; #ifdef WATERMARK -var string autocvar_menu_watermark = WATERMARK; +string autocvar_menu_watermark = WATERMARK; #else -var string autocvar_menu_watermark = ""; +string autocvar_menu_watermark = ""; #endif void postMenuDraw() { @@ -534,8 +538,8 @@ void preMenuDraw() if(_Nex_ExtResponseSystem_UpdateTo != "") { // TODO rather turn this into a dialog - fs = ((1/draw_scale_x) * eX + (1/draw_scale_y) * eY) * 12; - line = eY * fs_y; + fs = ((1/draw_scale.x) * eX + (1/draw_scale.y) * eY) * 12; + line = eY * fs.y; string l1, l2; l1 = sprintf(_("Update to %s now!"), _Nex_ExtResponseSystem_UpdateTo); l2 = "http://www.xonotic.org/"; @@ -546,11 +550,11 @@ void preMenuDraw() draw_TextWidth(l1, 0, fs), draw_TextWidth(l2, 0, fs) ); - sz_y = 3 * fs_y; + sz_y = 3 * fs.y; draw_alpha = bound(0, sin(time * 0.112 - 0.3) * 10, 1); - mid = eX * (0.5 + 0.5 * (1 - sz_x) * cos(time * 0.071)) - + eY * (0.5 + 0.5 * (1 - sz_y) * sin(time * 0.071)); + mid = eX * (0.5 + 0.5 * (1 - sz.x) * cos(time * 0.071)) + + eY * (0.5 + 0.5 * (1 - sz.y) * sin(time * 0.071)); draw_Fill(mid - 0.5 * sz, sz, '1 1 0', 1); draw_CenterText(mid - 1 * line, l1, fs, '1 0 0', 1, 0); @@ -655,18 +659,17 @@ float updateCompression() GAMETYPE(MAPINFO_TYPE_LMS) \ GAMETYPE(MAPINFO_TYPE_NEXBALL) \ GAMETYPE(MAPINFO_TYPE_ONSLAUGHT) \ - GAMETYPE(MAPINFO_TYPE_RACE) \ + if (cvar("developer")) GAMETYPE(MAPINFO_TYPE_RACE) \ GAMETYPE(MAPINFO_TYPE_CTS) \ GAMETYPE(MAPINFO_TYPE_TEAM_DEATHMATCH) \ //GAMETYPE(MAPINFO_TYPE_INVASION) \ /* nothing */ -float GameType_GetID(float cnt) +int GameType_GetID(int cnt) { - float i; - i = 0; + int i = 0; - #define GAMETYPE(id) if(i++ == cnt) return id; + #define GAMETYPE(id) { if (i++ == cnt) return id; } GAMETYPES #undef GAMETYPE @@ -675,10 +678,9 @@ float GameType_GetID(float cnt) return 0; } -float GameType_GetCount() +int GameType_GetCount() { - float i; - i = 0; + int i = 0; #define GAMETYPE(id) ++i; GAMETYPES @@ -687,9 +689,9 @@ float GameType_GetCount() return i; } -string GameType_GetName(float cnt) +string GameType_GetName(int cnt) { - float i = GameType_GetID(cnt); + int i = GameType_GetID(cnt); if(i) return MapInfo_Type_ToText(i); @@ -697,9 +699,9 @@ string GameType_GetName(float cnt) return ""; } -string GameType_GetIcon(float cnt) +string GameType_GetIcon(int cnt) { - float i = GameType_GetID(cnt); + int i = GameType_GetID(cnt); if(i) return strcat("gametype_", MapInfo_Type_ToString(i)); @@ -707,22 +709,6 @@ string GameType_GetIcon(float cnt) return ""; } -/*string GameType_GetTeams(float cnt) // poor implementation, later something else could be done that's better? -{ - float i = GameType_GetID(cnt); - string s = _MapInfo_GetDefaultEx(i); - - if(i) - { - if(strstrofs(s, "teams", 0) >= 0) - return _("teamplay"); - else - return _("free for all"); - } - - return _("tuba for all"); -}*/ - void dialog_hudpanel_common_notoggle(entity me, string panelname) { float i; @@ -781,3 +767,31 @@ void dialog_hudpanel_common_notoggle(entity me, string panelname) e.addValue(e, strzone(ftos_decimals(i - 5, 0)), strzone(ftos(i - 5))); e.configureXonoticTextSliderValues(e); } + +#define FADE_TIME 0.5 +#define MAX_ALPHA_INCREASE 0.1 +#define TRESHOLD_TIME 0.1 +float getHighlightAlpha(float baseAlpha, float highlightedTime) +{ + float alphaIncrease; + if (time - highlightedTime - TRESHOLD_TIME < FADE_TIME) + { + alphaIncrease = max(0, (time - highlightedTime - TRESHOLD_TIME) / FADE_TIME); + alphaIncrease = (1 - alphaIncrease) * MAX_ALPHA_INCREASE; + } + else + alphaIncrease = 0; + return baseAlpha + alphaIncrease; +} + +void CheckSendCvars(entity me, string cvarnamestring) +{ + if(me.sendCvars) + { + printf("Sending cvar: %s -> %s\n", cvarnamestring, cvar_string(cvarnamestring)); + if(gamestatus & (GAME_CONNECTED | GAME_ISSERVER)) + { + cmd(sprintf("\nsendcvar %s\n", cvarnamestring)); + } + } +}