void XonoticPlayerModelSelector_configureXonoticPlayerModelSelector(entity me) { float sortbuf, glob, i; string fn; glob = search_begin(language_filename(get_model_datafilename(string_null, -1, "txt")), TRUE, TRUE); if (glob < 0) return; me.configureXonoticImage(me, string_null, -1); sortbuf = buf_create(); for(i = 0; i < search_getsize(glob); ++i) { // select model #i! fn = search_getfilename(glob, i); if(!get_model_parameters(fn, -1)) continue; bufstr_add(sortbuf, sprintf("%-128s%s", get_model_parameters_name, fn), 1); } search_end(glob); buf_sort(sortbuf, 128, 0); me.numModels = buf_getsize(sortbuf); me.bufModels = buf_create(); for(i = 0; i < me.numModels; ++i) { fn = substring(bufstr_get(sortbuf, i), 128, -1); if(!get_model_parameters(fn, -1)) error("But it JUST worked!"); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_TITLE, get_model_parameters_name); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_IMAGE, strcat("/", substring(get_model_datafilename(get_model_parameters_modelname, get_model_parameters_modelskin, "tga"), 0, -5))); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_MODEL, get_model_parameters_modelname); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_SKIN, ftos(get_model_parameters_modelskin)); get_model_parameters_desc = strcat(get_model_parameters_desc, "\n"); if(get_model_parameters_sex) get_model_parameters_desc = strcat(get_model_parameters_desc, sprintf("\nSex: %s", get_model_parameters_sex)); if(get_model_parameters_weight) get_model_parameters_desc = strcat(get_model_parameters_desc, sprintf("\nWeight: %g kg", get_model_parameters_weight)); if(get_model_parameters_age) get_model_parameters_desc = strcat(get_model_parameters_desc, sprintf("\nAge: %g", get_model_parameters_age)); while(substring(get_model_parameters_desc, -1, 1) == "\n") get_model_parameters_desc = substring(get_model_parameters_desc, 0, -2); bufstr_set(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_DESC, get_model_parameters_desc); } buf_del(sortbuf); get_model_parameters(string_null, 0); me.loadCvars(me); // this will select the initial model, depending on the current cvars me.go(me, 0); // this will set the vars for the selected model }
void NexuizDemoList_getDemos(entity me) { string s; if(me.filterString) //subdirectory in filterString allowed s=strcat("demos/*", me.filterString, "*.dem"); else s="demos/*.dem"; //dprint("Search demos with the pattern ", s, "\n"); if(me.listDemo >= 0) search_end(me.listDemo); me.listDemo = search_begin(s, FALSE, TRUE); if(me.listDemo < 0) me.nItems=0; else me.nItems=search_getsize(me.listDemo); }
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); }