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'));
// 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);
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);
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;
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
{
me.refilter(me);
}
+
void MapList_StringFilter_Change(entity box, entity me)
{
if(me.stringFilter)
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);