void ToggleFavorite(string srv) { string s, s0, s1, s2, srv_resolved; float i, n; srv_resolved = netaddress_resolve(srv, 26000); s = cvar_string("net_slist_favorites"); n = tokenize_console(s); for(i = 0; i < n; ++i) if(srv_resolved == netaddress_resolve(argv(i), 26000)) { s0 = s1 = s2 = ""; if(i > 0) s0 = substring(s, 0, argv_end_index(i - 1)); if(i < n-1) s2 = substring(s, argv_start_index(i + 1), -1); if(s0 != "" && s2 != "") s1 = " "; print("s0 = >>", s0, "<<\ns1 = >>", s1, "<<\ns2 = >>", s2, "<<\n"); cvar_set("net_slist_favorites", strcat(s0, s1, s2)); return; } s1 = ""; if(s != "") s1 = " "; cvar_set("net_slist_favorites", strcat(s, " ", srv)); resorthostcache(); }
void NexuizTextSlider_saveCvars(entity me) { if not(me.cvarName) return; if(me.value >= 0 && me.value < me.nValues) { var float n = tokenize_console(me.cvarName); if(n == 1) { // this is a special case to allow spaces in the identifiers cvar_set(argv(0), me.getIdentifier(me)); } else { float i; var float m = tokenize_console(strcat(me.cvarName, " ", me.getIdentifier(me))); if(m == n + 1) { for(i = 0; i < n; ++i) cvar_set(argv(i), argv(n)); } else if(m == n * 2) { for(i = 0; i < n; ++i) cvar_set(argv(i), argv(i + n)); } else error("NexuizTextSlider: invalid identifier ", me.getIdentifier(me), " does not match cvar list ", me.cvarName); } } }
void g_maplistCacheToggleNexuizMapList(entity me, float i) { string a, b, c, s, bspname; float n; s = me.g_maplistCache; if not(s) return; b = substring(s, i, 1); if(b == "0") b = "1"; else if(b == "1") b = "0"; else return; // nothing happens a = substring(s, 0, i); c = substring(s, i+1, strlen(s) - (i+1)); strunzone(s); me.g_maplistCache = strzone(strcat(a, b, c)); // TODO also update the actual cvar if not((bspname = MapInfo_BSPName_ByID(i))) return; if(b == "1") cvar_set("g_maplist", strcat(bspname, " ", CVAR_STR(g_maplist))); else { s = ""; n = tokenize_console(CVAR_STR(g_maplist)); for(i = 0; i < n; ++i) if(argv(i) != bspname) s = strcat(s, " ", argv(i)); cvar_set("g_maplist", substring(s, 1, strlen(s) - 1)); } }
void saveCvarsNexuizResolutionSlider(entity me) { if(me.value >= 0 || me.value < me.nValues) { tokenizebyseparator(me.getIdentifier(me), "x"); cvar_set("menu_vid_width", argv(0)); cvar_set("menu_vid_height", argv(1)); } }
void XonoticResolutionSlider_saveCvars(entity me) { if(me.value >= 0 || me.value < me.nValues) { tokenize_console(me.getIdentifier(me)); cvar_set("menu_vid_width", argv(0)); cvar_set("menu_vid_height", argv(1)); cvar_set("menu_vid_pixelheight", argv(2)); } }
void XonoticCheckBoxString_saveCvars(entity me) { if not(me.cvarName) return; if(me.checked) cvar_set(me.cvarName, me.yesString); else cvar_set(me.cvarName, me.noString); }
void XonoticCheckBox_saveCvars(entity me) { if not(me.cvarName) return; if(me.checked) cvar_set(me.cvarName, ftos(me.yesValue)); else cvar_set(me.cvarName, ftos(me.noValue)); }
void saveCvarsNexuizResolutionSlider(entity me) { if(me.value >= 0 || me.value < me.nValues) { tokenize(me.getIdentifier(me)); cvar_set("vid_width", argv(0)); cvar_set("vid_height", argv(1)); cvar_set("vid_conwidth", argv(2)); cvar_set("vid_conheight", argv(3)); } }
void XonoticDecibelsSlider_saveCvars(entity me) { if not(me.cvarName) return; if(me.value >= -0.1) cvar_set(me.cvarName, "1"); if(me.value < -33) cvar_set(me.cvarName, "0"); else cvar_set(me.cvarName, ftos(pow(10, me.value / 10))); }
void saveCvarsLaserWeaponArenaWeaponButton(entity me) { string suffix; suffix = ""; if(me.cvarValue != "laser" && me.cvarValue != "most") if(cvar("menu_weaponarena_with_laser")) suffix = " laser"; if(me.checked) cvar_set("g_weaponarena", strcat(me.cvarValue, suffix)); else cvar_set("g_weaponarena", me.cvarOffValue); }
void ToggleFavorite(string srv) { string s, s0, s1, s2, srv_resolved, p; float i, n, f; srv_resolved = netaddress_resolve(srv, 26000); p = crypto_getidfp(srv_resolved); s = cvar_string("net_slist_favorites"); n = tokenize_console(s); f = 0; for(i = 0; i < n; ++i) { if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0) { if(p) if(argv(i) != p) continue; } else { if(srv_resolved != netaddress_resolve(argv(i), 26000)) continue; } s0 = s1 = s2 = ""; if(i > 0) s0 = substring(s, 0, argv_end_index(i - 1)); if(i < n-1) s2 = substring(s, argv_start_index(i + 1), -1); if(s0 != "" && s2 != "") s1 = " "; cvar_set("net_slist_favorites", strcat(s0, s1, s2)); s = cvar_string("net_slist_favorites"); n = tokenize_console(s); f = 1; --i; } if(!f) { s1 = ""; if(s != "") s1 = " "; if(p) cvar_set("net_slist_favorites", strcat(s, s1, p)); else cvar_set("net_slist_favorites", strcat(s, s1, srv)); } resorthostcache(); }
void saveCvarsNexuizGametypeButton(entity me) { if not(me.cvarName) return; cvar_set(me.cvarName, ftos(me.checked)); }
void saveCvarsNexuizSlider(entity me) { if not(me.cvarName) return; cvar_set(me.cvarName, ftos(me.value)); }
void C_RestoreCVars (void) { for (unsigned int i = 0; i < CVarBackups.Size(); ++i) { cvar_set(CVarBackups[i].Name, CVarBackups[i].String); } C_ForgetCVars(); }
void saveCvarsNexuizTextSlider(entity me) { if not(me.cvarName) return; if(me.value >= 0 && me.value < me.nValues) cvar_set(me.cvarName, me.getIdentifier(me)); }
void WeaponsList_MoveUp_Click(entity box, entity me) { if(me.selectedItem > 0) { cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem - 1, me.selectedItem)); me.selectedItem -= 1; } }
void WeaponsList_MoveDown_Click(entity box, entity me) { if(me.selectedItem < me.nItems - 1) { cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, me.selectedItem + 1)); me.selectedItem += 1; } }
float XonoticWeaponsList_mouseDrag(entity me, vector pos) { float f, i; i = me.selectedItem; f = SUPER(XonoticWeaponsList).mouseDrag(me, pos); if(me.selectedItem != i) cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, i)); return f; }
void FixNoSpecs( void ) { // turn off "no specs" mode if there no players left if ( g_globalvars.time > 10 && !match_in_progress && !CountPlayers() && cvar("_k_nospecs") ) { G_bprint(2, "%s mode turned off\n", redtext("No spectators")); cvar_set("_k_nospecs", "0"); } }
void XonoticCrosshairButton_saveCvars(entity me) { if not(me.cvarName) return; if(me.checked) cvar_set(me.cvarName, ftos(me.cvarValueFloat)); // TODO on an apply button, read _cl_color and execute the color command for it }
float mouseDragNexuizWeaponsList(entity me, vector pos) { float f, i; i = me.selectedItem; f = mouseDragListBox(me, pos); if(me.selectedItem != i) cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, i)); return f; }
void updateConwidths() { vector r, c; float minfactor, maxfactor; float sz, f; r_x = cvar("menu_vid_width"); r_y = cvar("menu_vid_height"); r_z = cvar("menu_vid_pixelheight"); sz = cvar("menu_vid_scale"); // calculate the base resolution c_z = 0; c_x = 800; c_y = c_x * r_y * r_z / r_x; if(c_y < 600) { c_y = 600; c_x = c_y * r_x / (r_y * r_z); } f = min(r_x / c_x, r_y / c_y); if(f < 1) c = c * f; // ensures that c_x <= r_x and c_y <= r_y minfactor = min(1, 640 / c_x); // can be > 1 only if c_x is <640 maxfactor = max3(1, r_x / c_x, r_y / c_y); // can be < 1 only if r_x < c_x and r_y < c_y dprint("min factor: ", ftos(minfactor), "\n"); dprint("max factor: ", ftos(maxfactor), "\n"); if(sz < 0) f = 1 - (maxfactor - 1) * sz; else if(sz > 0) f = 1 + (minfactor - 1) * sz; else f = 1; c = c * f; // fteqcc fail cvar_set("vid_width", ftos(rint(r_x))); cvar_set("vid_height", ftos(rint(r_y))); cvar_set("vid_pixelheight", ftos(rint(r_z))); cvar_set("vid_conwidth", ftos(rint(c_x))); cvar_set("vid_conheight", ftos(rint(c_y))); }
void C_RestoreCVars (void) { struct backup_s *backup = CVarBackups; int i; for (i = numbackedup; i; i--, backup++) { cvar_set (backup->name, backup->string); } C_ForgetCVars(); }
void MapList_All(entity btn, entity me) { float i; string s; MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, MAPINFO_FLAG_FORBIDDEN, 0); // all s = ""; for(i = 0; i < MapInfo_count; ++i) s = strcat(s, " ", MapInfo_BSPName_ByID(i)); cvar_set("g_maplist", substring(s, 1, strlen(s) - 1)); me.refilter(me); }
void cvar_t::C_RestoreCVars (void) { struct backup_s *backup = CVarBackups; int i; for (i = numbackedup; i; i--, backup++) { cvar_set (backup->name.c_str(), backup->string.c_str()); backup->name = backup->string = ""; } numbackedup = 0; }
void drawNexuizWeaponsList(entity me) { // read in cvar? string s, t; s = W_NumberWeaponOrder(cvar_string("cl_weaponpriority")); t = W_FixWeaponOrder(s, 1); if(t != s) { print("AUTOFIXED\n"); cvar_set("cl_weaponpriority", W_NameWeaponOrder(t)); } me.nItems = tokenize_console(t); drawListBox(me); }
void XonoticWeaponsList_draw(entity me) { // read in cvar? string s, t; s = W_NumberWeaponOrder(cvar_string("cl_weaponpriority")); t = W_FixWeaponOrder(s, 1); if(t != s) { print("AUTOFIXED\n"); cvar_set("cl_weaponpriority", W_NameWeaponOrder(t)); } me.nItems = tokenize_console(t); SUPER(XonoticWeaponsList).draw(me); }
void InstantAction_LoadMap(entity btn, entity dummy) { float glob, i, n, fh; string s; glob = search_begin("maps/*.instantaction", TRUE, TRUE); if(glob < 0) return; i = ceil(random() * search_getsize(glob)) - 1; fh = fopen(search_getfilename(glob, i), FILE_READ); search_end(glob); if(fh < 0) return; while((s = fgets(fh))) { if(substring(s, 0, 4) == "set ") s = substring(s, 4, strlen(s) - 4); n = tokenize_console(s); if(argv(0) == "bot_number") cvar_set("bot_number", argv(1)); else if(argv(0) == "skill") cvar_set("skill", argv(1)); else if(argv(0) == "timelimit") cvar_set("timelimit_override", argv(1)); else if(argv(0) == "fraglimit") cvar_set("fraglimit_override", argv(1)); else if(argv(0) == "changelevel") { fclose(fh); localcmd("\nmenu_loadmap_prepare\n"); MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH); MapInfo_LoadMap(argv(1)); cvar_set("lastlevel", "1"); return; } } fclose(fh); }
/* ====== * cmd_parse - Parse an input string * ====== */ void cmd_parse(char *input) { char buffer[CMD_MAX_LENGTH]; char *tokens[CMD_MAX_TOKENS]; int num_tokens; int i, l; Assert(input != NULL); /* Strip leading spaces */ for (i=0; isspace(input[i]); i++) ; strncpy( buffer, &input[i], CMD_MAX_LENGTH ); //printf("lead strip \"%s\"\n",buffer); l = (int) strlen(buffer); /* If command is empty, give up */ if (l==0) return; /* Strip trailing spaces */ for (i=l-1; i>0 && isspace(buffer[i]); i--) ; buffer[i+1] = 0; //printf("trail strip \"%s\"\n",buffer); /* Split into tokens */ l = (int) strlen(buffer); num_tokens = 1; tokens[0] = buffer; for (i=1; i<l; i++) { if (isspace(buffer[i])) { buffer[i] = 0; while (isspace(buffer[i+1]) && (i+1 < l)) i++; tokens[num_tokens++] = &buffer[i+1]; } } /* Check for matching commands */ /* Otherwise */ //printf("n_tokens = %d\n", num_tokens); if (num_tokens>1) { //printf("setting %s %s\n",tokens[0], tokens[1]); cvar_set(tokens[0], tokens[1]); } else { #if TRACE con_printf(CON_NORMAL, "%s: %f\n", tokens[0], cvar(tokens[0])); #endif } }
float XonoticColorpickerString_mouseDrag(entity me, vector coords) { if(me.disabled) return 0; vector margin; margin = me.imagemargin; if(coords_x >= margin_x) if(coords_y >= margin_y) if(coords_x <= 1 - margin_x) if(coords_y <= 1 - margin_y) { cvar_set(me.cvarName, sprintf("%v", hslimage_color(coords, margin))); me.prevcoords = coords; } return 1; }