From: BuddyFriendGuy Date: Thu, 9 Apr 2015 06:49:50 +0000 (-0400) Subject: clearer button labels; still fixing button functions X-Git-Tag: xonotic-v0.8.1~23^2~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c529a5ec2e78f23c3710d0cc0acca92541240151;p=xonotic%2Fxonotic-data.pk3dir.git clearer button labels; still fixing button functions --- diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc index 06a39534e..2da8a4169 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc @@ -137,6 +137,8 @@ void XonoticServerCreateTab_fill(entity me) e0.textEntity = main.mutatorsDialog; e0.allowCut = 1; //e0.allowWrap = 1; + + me.mapListBox = makeXonoticMapList(); me.TR(me); me.TDempty(me, 0.5); me.TD(me, 1, 2, e = makeXonoticButton(_("Mutators"), '0 0 0')); @@ -147,7 +149,6 @@ void XonoticServerCreateTab_fill(entity me) // The right half begins here me.gotoRC(me, 0.5, 3.2); me.setFirstColumn(me, me.currentColumn); - me.mapListBox = makeXonoticMapList(); // the maplistbox me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Maplist"))); makeCallback(e, me.mapListBox, me.mapListBox.refilterCallback); @@ -155,7 +156,7 @@ void XonoticServerCreateTab_fill(entity me) me.TD(me, me.rows - 6, 3, me.mapListBox); me.gotoRC(me, me.rows - 3.5, me.firstColumn); - // map string filter + // string filter label and box me.TD(me, 1, 0.35, e = makeXonoticTextLabel(1, _("Filter:"))); me.mapListBox.stringFilterBox = makeXonoticMapListStringFilterBox(me, 0, string_null); me.TD(me, 1, me.columns - me.firstColumn - 0.35, e = me.mapListBox.stringFilterBox); @@ -165,16 +166,18 @@ void XonoticServerCreateTab_fill(entity me) me.TR(me); // the selection buttons - me.TD(me, 1, 1, e = makeXonoticButton(_("Select shown"), '0 0 0')); - e.onClick = MapList_All; + me.TD(me, 1, 1, e = makeXonoticButton(_("Add shown"), '0 0 0')); + e.onClick = MapList_Add_Shown; e.onClickEntity = me.mapListBox; - me.TD(me, 1, 1, e = makeXonoticButton(_("De-select shown"), '0 0 0')); - e.onClick = MapList_None; + me.TD(me, 1, 1, e = makeXonoticButton(_("Remove shown"), '0 0 0')); + e.onClick = MapList_Remove_Shown; e.onClickEntity = me.mapListBox; - me.TD(me, 1, 1, e = makeXonoticButton(_("Clear everything"), '0 0 0')); - e.onClick = MapList_None; + me.TD(me, 1, 1, e = makeXonoticButton(_("Clear all"), '0 0 0')); + e.onClick = MapList_Clear_All; e.onClickEntity = me.mapListBox; + // The big button at the bottom + me.gotoRC(me, me.rows - 1, 0); me.TD(me, 1, me.columns, e = makeXonoticButton(_("Start Multiplayer!"), '0 0 0')); e.onClick = MapList_LoadMap; diff --git a/qcsrc/menu/xonotic/maplist.qc b/qcsrc/menu/xonotic/maplist.qc index 895d8cd54..a24469e33 100644 --- a/qcsrc/menu/xonotic/maplist.qc +++ b/qcsrc/menu/xonotic/maplist.qc @@ -48,8 +48,9 @@ ENDCLASS(XonoticMapList) entity makeXonoticMapList(); entity makeXonoticMapListStringFilterBox(entity me, float doEditColorCodes, string theCvar); void MapList_StringFilter_Change(entity box, entity me); -void MapList_All(entity btn, entity me); -void MapList_None(entity btn, entity me); +void MapList_Add_Shown(entity btn, entity me); +void MapList_Remove_Shown(entity btn, entity me); +void MapList_Clear_All(entity btn, entity me); void MapList_LoadMap(entity btn, entity me); #endif @@ -255,6 +256,7 @@ void XonoticMapList_refilterCallback(entity me, entity cb) { me.refilter(me); } + void MapList_StringFilter_Change(entity box, entity me) { if(me.stringFilter) @@ -267,22 +269,82 @@ void MapList_StringFilter_Change(entity box, entity me) me.refilter(me); } -void MapList_All(entity btn, entity me) +void MapList_Add_Shown(entity btn, entity me) { - float i; - string s; + float i, j, n, inlist; + string s, bspname; + + localcmd(sprintf("say before %d\n", MapInfo_count)); MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, MapInfo_ForbiddenFlags(), 0); // all + localcmd(sprintf("say and %d\n", MapInfo_count)); if (me.stringFilter) MapInfo_FilterString(me.stringFilter); + localcmd(sprintf("say after %d\n", MapInfo_count)); + s = ""; + n = tokenize_console(cvar_string("g_maplist")); for(i = 0; i < MapInfo_count; ++i) + { + if (!((bspname = MapInfo_BSPName_ByID(i)))) + continue; + // check whether g_maplist already has this map + inlist = 0; + for(j = 0; j < n; ++j) + if(argv(j) == bspname) + { + inlist = 1; + break; + } + if (inlist) + // g_maplist already has this map; no need to do anything + continue; + // g_maplist doesn't have this map; add to the temp string s = strcat(s, " ", MapInfo_BSPName_ByID(i)); - + localcmd(sprintf("say map %d: %s\n", i, MapInfo_BSPName_ByID(i))); + } + // now add those new maps to the existing list + cvar_set("g_maplist", strcat(cvar_string("g_maplist"), substring(s, 1, strlen(s) - 1))); + me.refilter(me); +} + +void MapList_Remove_Shown(entity btn, entity me) +{ + float i, j, n, inlist; + string s, bspname; + + MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, MapInfo_ForbiddenFlags(), 0); // all + if (me.stringFilter) + MapInfo_FilterString(me.stringFilter); + + s = ""; + n = tokenize_console(cvar_string("g_maplist")); + + for (j = 0; j < n; ++j) + { + // check whether this map from g_maplist is in the removal list + inlist = 0; + for(i = 0; i < MapInfo_count; ++i) + { + if (!((bspname = MapInfo_BSPName_ByID(i)))) + continue; + if(argv(j) == bspname) + { + inlist = 1; + break; + } + } + if (inlist) + // this map is on the removal list; don't keep it + continue; + // this map is to be kept + s = strcat(s, " ", argv(j)); + } + cvar_set("g_maplist", substring(s, 1, strlen(s) - 1)); me.refilter(me); } -void MapList_None(entity btn, entity me) +void MapList_Clear_All(entity btn, entity me) { cvar_set("g_maplist", ""); me.refilter(me);