void XonoticPlayerModelSelector_go(entity me, float d) { me.idxModels = mod(me.idxModels + d + me.numModels, me.numModels); if(me.currentModel) strunzone(me.currentModel); if(me.currentModelTitle) strunzone(me.currentModelTitle); if(me.currentModelImage) strunzone(me.currentModelImage); if(me.currentModelDescription) strunzone(me.currentModelDescription); // select model #i! me.currentModelTitle = strzone(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_TITLE)); me.currentModelImage = strzone(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_IMAGE)); me.currentSkin = stof(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_SKIN)); me.currentModel = strzone(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_MODEL)); me.currentModelDescription = strzone(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_DESC)); // fix the image if(draw_PictureSize(me.currentModelImage) == '0 0 0') me.src = "nopreview_player"; else me.src = me.currentModelImage; me.updateAspect(me); }
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 refilterNexuizMapList(entity me) { float i, j, n; string s; float gt, f; gt = gametype_ID_to_MapID(gametype_GetMenu()); f = MapInfo_CurrentFeatures(); MapInfo_FilterGametype(gt, f, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); me.nItems = MapInfo_count; for(i = 0; i < MapInfo_count; ++i) draw_PreloadPicture(strcat("/maps/", MapInfo_BSPName_ByID(i))); if(me.g_maplistCache) strunzone(me.g_maplistCache); s = "0"; for(i = 1; i < MapInfo_count; i *= 2) s = strcat(s, s); n = tokenize_console(CVAR_STR(g_maplist)); for(i = 0; i < n; ++i) { j = MapInfo_FindName(argv(i)); if(j >= 0) s = strcat( substring(s, 0, j), "1", substring(s, j+1, MapInfo_count - (j+1)) ); } me.g_maplistCache = strzone(s); if(gt != me.lastGametype || f != me.lastFeatures) { me.lastGametype = gt; me.lastFeatures = f; me.setSelected(me, 0); } }
void setSelectedNexuizCvarList(entity me, float i) { string s; setSelectedListBox(me, i); if(me.nItems == 0) return; if(me.cvarName) strunzone(me.cvarName); if(me.cvarDescription) strunzone(me.cvarDescription); if(me.cvarType) strunzone(me.cvarType); if(me.cvarDefault) strunzone(me.cvarDefault); me.cvarName = strzone(bufstr_get(me.handle, me.selectedItem)); me.cvarDescription = strzone(cvar_description(me.cvarName)); me.cvarDefault = strzone(cvar_defstring(me.cvarName)); float t; t = cvar_type(me.cvarName); me.cvarType = ""; if(t & CVAR_TYPEFLAG_SAVED) me.cvarType = strcat(me.cvarType, ", will be saved to config.cfg"); else me.cvarType = strcat(me.cvarType, ", will not be saved"); if(t & CVAR_TYPEFLAG_PRIVATE) me.cvarType = strcat(me.cvarType, ", private"); if(t & CVAR_TYPEFLAG_ENGINE) me.cvarType = strcat(me.cvarType, ", engine setting"); if(t & CVAR_TYPEFLAG_READONLY) me.cvarType = strcat(me.cvarType, ", read only"); me.cvarType = strzone(substring(me.cvarType, 2, strlen(me.cvarType) - 2)); me.cvarNameBox.setText(me.cvarNameBox, me.cvarName); me.cvarDescriptionBox.setText(me.cvarDescriptionBox, me.cvarDescription); me.cvarTypeBox.setText(me.cvarTypeBox, me.cvarType); me.cvarDefaultBox.setText(me.cvarDefaultBox, me.cvarDefault); // this one can handle tempstrings s = cvar_string(me.cvarName); me.cvarValueBox.setText(me.cvarValueBox, s); me.cvarValueBox.cursorPos = strlen(s); }
void DemoList_Filter_Change(entity box, entity me) { if(me.filterString) strunzone(me.filterString); if(box.text != "") me.filterString = strzone(box.text); else me.filterString = string_null; me.getDemos(me); }
string WeaponArenaString() { string s; float n, i, j; entity e; s = cvar_string("g_weaponarena"); if(s == "0") return ""; if(s == "all") return "All Weapons Arena"; if(s == "most") return "Most Weapons Arena"; if(s == weaponarenastring_cvar) return weaponarenastring; if(weaponarenastring) strunzone(weaponarenastring); if(weaponarenastring_cvar) strunzone(weaponarenastring_cvar); weaponarenastring_cvar = strzone(s); n = tokenize_console(s); s = ""; for(i = 0; i < n; ++i) { for(j = WEP_FIRST; j <= WEP_LAST; ++j) { e = get_weaponinfo(j); if(argv(i) == e.netname) s = strcat(s, " & ", e.message); } } s = strcat(substring(s, 3, strlen(s) - 3), " Arena"); weaponarenastring = strzone(s); return weaponarenastring; }
void ServerList_Filter_Change(entity box, entity me) { if(me.filterString) strunzone(me.filterString); if(box.text != "") me.filterString = strzone(box.text); else me.filterString = string_null; me.refreshServerList(me, 0); me.ipAddressBox.setText(me.ipAddressBox, ""); me.ipAddressBox.cursorPos = 0; me.ipAddressBoxFocused = -1; }
void XonoticServerList_setSortOrder(entity me, float field, float direction) { if(me.currentSortField == field) direction = -me.currentSortOrder; me.currentSortOrder = direction; me.currentSortField = field; me.sortButton1.forcePressed = (field == SLIST_FIELD_PING); me.sortButton2.forcePressed = (field == SLIST_FIELD_NAME); me.sortButton3.forcePressed = (field == SLIST_FIELD_MAP); me.sortButton4.forcePressed = 0; me.sortButton5.forcePressed = (field == SLIST_FIELD_NUMHUMANS); me.selectedItem = 0; if(me.selectedServer) strunzone(me.selectedServer); me.selectedServer = string_null; me.refreshServerList(me, 0); }
void XonoticCrosshairButton_draw(entity me) { vector sz, rgb; float a; rgb = stov(cvar_string("crosshair_color")); a = cvar("crosshair_alpha"); if(!me.checked && !me.focused && me.cvarValueFloat != -1) { a *= me.disabledAlpha; rgb = '1 1 1'; } if(me.cvarValueFloat == -1) // update the preview if this is the preview button { if(me.src3) strunzone(me.src3); me.src3 = strzone(strcat("/gfx/crosshair", cvar_string("crosshair"))); me.focused = 1; me.checked = 0; } SUPER(XonoticCrosshairButton).draw(me); sz = draw_PictureSize(me.src3); sz = globalToBoxSize(sz, draw_scale); if(me.cvarValueFloat == -1) { sz = (6 * '1 1 0' + sz * cvar("crosshair_size")) * 0.08; // (6 * '1 1 0' + ...) * 0.08 here to make visible size changes happen also at bigger sizes if(sz_x > 0.95) sz = sz * (0.95 / sz_x); if(sz_y > 0.95) sz = sz * (0.95 / sz_y); } else // show the crosshair picker at full size sz = '0.95 0.95 0'; draw_Picture('0.5 0.5 0' - 0.5 * sz, me.src3, sz, rgb, a); if(cvar("crosshair_dot")) { if(cvar_string("crosshair_dot_color") != "0") rgb = stov(cvar_string("crosshair_dot_color")); draw_Picture('0.5 0.5 0' - 0.5 * sz * cvar("crosshair_dot_size"), me.src4, sz * cvar("crosshair_dot_size"), rgb, a * cvar("crosshair_dot_alpha")); } }
void XonoticServerList_setSelected(entity me, float i) { float save; save = me.selectedItem; SUPER(XonoticServerList).setSelected(me, i); /* if(me.selectedItem == save) return; */ if(me.nItems == 0) return; if(gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT) != me.nItems) return; // sorry, it would be wrong if(me.selectedServer) strunzone(me.selectedServer); me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem)); me.ipAddressBox.setText(me.ipAddressBox, me.selectedServer); me.ipAddressBox.cursorPos = strlen(me.selectedServer); me.ipAddressBoxFocused = -1; }
void XonoticMapInfoDialog_loadMapInfo(entity me, float i, entity mlb) { me.currentMapIndex = i; me.startButton.onClickEntity = mlb; MapInfo_Get_ByID(i); if(me.currentMapBSPName) { strunzone(me.currentMapBSPName); strunzone(me.currentMapTitle); strunzone(me.currentMapAuthor); strunzone(me.currentMapDescription); strunzone(me.currentMapPreviewImage); strunzone(me.currentMapFeaturesText); } me.currentMapBSPName = strzone(MapInfo_Map_bspname); me.currentMapTitle = strzone(MapInfo_Map_title); me.currentMapAuthor = strzone(MapInfo_Map_author); me.currentMapDescription = strzone(MapInfo_Map_description); me.currentMapFeaturesText = strzone((MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_WEAPONS) ? "Full item placement" : "MinstaGib only"); me.currentMapPreviewImage = strzone(strcat("/maps/", MapInfo_Map_bspname)); me.frame.setText(me.frame, me.currentMapBSPName); me.titleLabel.setText(me.titleLabel, me.currentMapTitle); me.authorLabel.setText(me.authorLabel, me.currentMapAuthor); me.descriptionLabel.setText(me.descriptionLabel, me.currentMapDescription); me.featuresLabel.setText(me.featuresLabel, me.currentMapFeaturesText); me.previewImage.src = me.currentMapPreviewImage; me.typeDeathmatchLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH); me.typeTDMLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_TEAM_DEATHMATCH); me.typeLMSLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_LMS); me.typeArenaLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ARENA); me.typeDominationLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DOMINATION); me.typeRuneLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_RUNEMATCH); me.typeKeyHuntLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_KEYHUNT); me.typeCTFLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_CTF); me.typeCALabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_CA); me.typeAssaultLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ASSAULT); me.typeOnslaughtLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ONSLAUGHT); me.typeRaceLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_RACE); me.typeCTSLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_CTS); me.typeNexballLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_NEXBALL); MapInfo_ClearTemps(); }
void rewrapCampaign(float w, float l0, float emptyheight) { float i, j; float n, l; string r, s; for(i = 0; i < campaign_entries; ++i) { l = l0; if(campaign_longdesc_wrapped[i]) strunzone(campaign_longdesc_wrapped[i]); n = tokenizebyseparator(campaign_longdesc[i], "\n"); r = ""; for(j = 0; j < n; ++j) { s = argv(j); if(s == "") { l -= emptyheight; r = strcat(r, "\n"); continue; } getWrappedLine_remaining = s; while(getWrappedLine_remaining) { s = getWrappedLine(w, draw_TextWidth_WithoutColors); if(--l < 0) goto toolong; r = strcat(r, s, "\n"); } } goto nottoolong; :toolong while(substring(r, strlen(r) - 1, 1) == "\n") r = substring(r, 0, strlen(r) - 1); r = strcat(r, "...\n"); :nottoolong
void XonoticServerList_draw(entity me) { float i, found, owned; if(me.currentSortField == -1) { me.setSortOrder(me, SLIST_FIELD_PING, +1); me.refreshServerList(me, 2); } else if(me.needsRefresh == 1) { me.needsRefresh = 2; // delay by one frame to make sure "slist" has been executed } else if(me.needsRefresh == 2) { me.needsRefresh = 0; me.refreshServerList(me, 0); } owned = ((me.selectedServer == me.ipAddressBox.text) && (me.ipAddressBox.text != "")); me.nItems = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT); me.connectButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == "")); me.infoButton.disabled = ((me.nItems == 0) || !owned); me.favoriteButton.disabled = ((me.nItems == 0) && (me.ipAddressBox.text == "")); found = 0; if(me.selectedServer) { for(i = 0; i < me.nItems; ++i) if(gethostcachestring(SLIST_FIELD_CNAME, i) == me.selectedServer) { if(i != me.selectedItem) { me.lastClickedServer = -1; me.selectedItem = i; } found = 1; break; } } if(!found) if(me.nItems > 0) { if(me.selectedItem >= me.nItems) me.selectedItem = me.nItems - 1; if(me.selectedServer) strunzone(me.selectedServer); me.selectedServer = strzone(gethostcachestring(SLIST_FIELD_CNAME, me.selectedItem)); } if(owned) { if(me.selectedServer != me.ipAddressBox.text) { me.ipAddressBox.setText(me.ipAddressBox, me.selectedServer); me.ipAddressBox.cursorPos = strlen(me.selectedServer); me.ipAddressBoxFocused = -1; } } if(me.ipAddressBoxFocused != me.ipAddressBox.focused) { if(me.ipAddressBox.focused || me.ipAddressBoxFocused < 0) ServerList_Update_favoriteButton(NULL, me); me.ipAddressBoxFocused = me.ipAddressBox.focused; } SUPER(XonoticServerList).draw(me); }
void InputBox_setText(entity me, string txt) { if(me.text) strunzone(me.text); SUPER(InputBox).setText(me, strzone(txt)); }
void XonoticServerInfoDialog_loadServerInfo(entity me, float i) { float m, pure, freeslots, j, numh, maxp, numb; string s, typestr, versionstr, k, v; if(me.currentServerName) strunzone(me.currentServerName); me.currentServerName = string_null; if(me.currentServerCName) strunzone(me.currentServerCName); me.currentServerCName = string_null; if(me.currentServerType) strunzone(me.currentServerType); me.currentServerType = string_null; if(me.currentServerMap) strunzone(me.currentServerMap); me.currentServerMap = string_null; if(me.currentServerPlayers) strunzone(me.currentServerPlayers); me.currentServerPlayers = string_null; if(me.currentServerNumPlayers) strunzone(me.currentServerNumPlayers); me.currentServerNumPlayers = string_null; if(me.currentServerNumBots) strunzone(me.currentServerNumBots); me.currentServerNumBots = string_null; if(me.currentServerMod) strunzone(me.currentServerMod); me.currentServerMod = string_null; if(me.currentServerVersion) strunzone(me.currentServerVersion); me.currentServerVersion = string_null; if(me.currentServerPing) strunzone(me.currentServerPing); me.currentServerPing = string_null; if(me.currentServerKey) strunzone(me.currentServerKey); me.currentServerKey = string_null; if(me.currentServerID) strunzone(me.currentServerID); me.currentServerID = string_null; // not zoned! //if(me.currentServerEncrypt) // strunzone(me.currentServerEncrypt); //me.currentServerEncrypt = string_null; if(me.currentServerPure) strunzone(me.currentServerPure); me.currentServerPure = string_null; SLIST_FIELD_NAME = gethostcacheindexforkey("name"); me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i)); me.nameLabel.setText(me.nameLabel, me.currentServerName); SLIST_FIELD_CNAME = gethostcacheindexforkey("cname"); me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i)); me.cnameLabel.setText(me.cnameLabel, me.currentServerCName); pure = -1; typestr = _("N/A"); versionstr = _("N/A"); SLIST_FIELD_QCSTATUS = gethostcacheindexforkey("qcstatus"); s = gethostcachestring(SLIST_FIELD_QCSTATUS, i); m = tokenizebyseparator(s, ":"); if(m >= 2) { typestr = argv(0); versionstr = argv(1); } freeslots = -1; for(j = 2; j < m; ++j) { if(argv(j) == "") break; k = substring(argv(j), 0, 1); v = substring(argv(j), 1, -1); if(k == "P") pure = stof(v); else if(k == "S") freeslots = stof(v); } me.currentServerType = strzone(typestr); me.typeLabel.setText(me.typeLabel, me.currentServerType); SLIST_FIELD_MAP = gethostcacheindexforkey("map"); me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i)); me.mapLabel.setText(me.mapLabel, me.currentServerMap); SLIST_FIELD_PLAYERS = gethostcacheindexforkey("players"); me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i)); me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers); SLIST_FIELD_NUMHUMANS = gethostcacheindexforkey("numhumans"); numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i); SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey("maxplayers"); maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i); SLIST_FIELD_NUMBOTS = gethostcacheindexforkey("numbots"); numb = gethostcachenumber(SLIST_FIELD_NUMBOTS, i); if(freeslots < 0) freeslots = maxp - numh - numb; me.currentServerNumPlayers = strzone(sprintf(_("%d/%d, %d free player slots"), numh, maxp, freeslots)); me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers); s = ftos(numb); me.currentServerNumBots = strzone(s); me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots); SLIST_FIELD_MOD = gethostcacheindexforkey("mod"); me.currentServerMod = strzone(gethostcachestring(SLIST_FIELD_MOD, i)); me.modLabel.setText(me.modLabel, me.currentServerMod); me.currentServerVersion = strzone(versionstr); me.versionLabel.setText(me.versionLabel, me.currentServerVersion); me.currentServerPure = ((pure < 0) ? "N/A" : (pure == 0) ? _("Official settings") : sprintf(_("%d modified settings"), pure)); me.currentServerPure = strzone(me.currentServerPure); me.pureLabel.setText(me.pureLabel, me.currentServerPure); SLIST_FIELD_PING = gethostcacheindexforkey("ping"); s = ftos(gethostcachenumber(SLIST_FIELD_PING, i)); me.currentServerPing = strzone(s); me.pingLabel.setText(me.pingLabel, me.currentServerPing); s = crypto_getidfp(me.currentServerCName); if not(s) s = _("N/A"); me.currentServerID = strzone(s); me.idLabel.setText(me.idLabel, me.currentServerID); s = crypto_getkeyfp(me.currentServerCName); if not(s) s = _("N/A"); me.currentServerKey = strzone(s); me.keyLabel.setText(me.keyLabel, me.currentServerKey); s = crypto_getencryptlevel(me.currentServerCName); if(s == "") { if(cvar("crypto_aeslevel") >= 3) me.currentServerEncrypt = _("N/A (can't connect)"); else me.currentServerEncrypt = _("N/A"); } else switch(stof(substring(s, 0, 1))) { case 0: if(cvar("crypto_aeslevel") >= 3) me.currentServerEncrypt = _("not supported (can't connect)"); else me.currentServerEncrypt = _("not supported (won't encrypt)"); break; case 1: if(cvar("crypto_aeslevel") >= 2) me.currentServerEncrypt = _("supported (will encrypt)"); else me.currentServerEncrypt = _("supported (won't encrypt)"); break; case 2: if(cvar("crypto_aeslevel") >= 1) me.currentServerEncrypt = _("requested (will encrypt)"); else me.currentServerEncrypt = _("requested (won't encrypt)"); break; case 3: if(cvar("crypto_aeslevel") <= 0) me.currentServerEncrypt = _("required (can't connect)"); else me.currentServerEncrypt = _("required (will encrypt)"); break; } me.encryptLabel.setText(me.encryptLabel, me.currentServerEncrypt); }
void setTextInputBox(entity me, string txt) { if(me.text) strunzone(me.text); setTextLabel(me, strzone(txt)); }