Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/MapBrowserPage/MapBrowserPage.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/MapBrowserPage/MapBrowserPage.js
+++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/MapBrowserPage/MapBrowserPage.js
@@ -27,7 +27,7 @@
openPage()
{
- super.openPage();
+ super.openPage(g_IsController);
this.controls.MapFiltering.select(
this.gameSettingsController.guiData.mapFilter.filter,
Index: ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/MapBrowser.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/MapBrowser.js
+++ ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/MapBrowser.js
@@ -19,6 +19,9 @@
submitMapSelection()
{
+ if (!this.allowSelection)
+ return;
+
let file = this.gridBrowser.getSelected();
let type = this.controls.MapFiltering.getSelectedMapType();
let filter = this.controls.MapFiltering.getSelectedMapFilter();
@@ -47,12 +50,14 @@
this.closePageHandlers.add(handler);
}
- openPage()
+ openPage(allowSelection)
{
if (this.open)
return;
for (let handler of this.openPageHandlers)
- handler();
+ handler(allowSelection);
+
+ this.allowSelection = allowSelection;
this.open = true;
}
Index: ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/MapBrowserPage.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/MapBrowserPage.js
+++ ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/MapBrowserPage.js
@@ -1,10 +1,7 @@
/**
* TODO: better global state handling in the GUI.
- * In particular a bunch of those shadow gamesetup/gamesettings stuff.
*/
-const g_IsController = false;
const g_MapTypes = prepareForDropdown(g_Settings && g_Settings.MapTypes);
-var g_SetupWindow;
function init()
{
@@ -12,6 +9,6 @@
let filters = new MapFilters(cache);
let browser = new MapBrowser(cache, filters);
browser.registerClosePageHandler(() => Engine.PopGuiPage());
- browser.openPage();
+ browser.openPage(false);
browser.controls.MapFiltering.select("default", "skirmish");
}
Index: ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/controls/MapBrowserControls.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/controls/MapBrowserControls.js
+++ ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/controls/MapBrowserControls.js
@@ -14,8 +14,6 @@
setupButtons()
{
this.pickRandom = Engine.GetGUIObjectByName("mapBrowserPagePickRandom");
- if (!g_IsController)
- this.pickRandom.hidden = true;
this.pickRandom.onPress = () => {
let index = randIntInclusive(0, this.gridBrowser.itemCount - 1);
this.gridBrowser.setSelectedIndex(index);
@@ -26,25 +24,24 @@
this.select.onPress = () => this.onSelect();
this.close = Engine.GetGUIObjectByName("mapBrowserPageClose");
- if (g_SetupWindow)
- this.close.tooltip = colorizeHotkey(
- translate("%(hotkey)s: Close map browser and discard the selection."), "cancel");
- else
- {
- this.close.caption = translate("Close");
- this.close.tooltip = colorizeHotkey(
- translate("%(hotkey)s: Close map browser."), "cancel");
- }
-
this.close.onPress = () => this.mapBrowserPage.closePage();
- this.select.hidden = !g_IsController;
- if (!g_IsController)
- this.close.size = this.select.size;
-
+ this.mapBrowserPage.registerOpenPageHandler(this.onOpenPage.bind(this));
this.gridBrowser.registerSelectionChangeHandler(() => this.onSelectionChange());
}
+ onOpenPage(allowSelection)
+ {
+ this.pickRandom.hidden = !allowSelection;
+ this.select.hidden = !allowSelection;
+
+ const usedCaptions = allowSelection ? MapBrowserPageControls.Captions.cancel :
+ MapBrowserPageControls.Captions.close;
+
+ this.close.caption = usedCaptions.caption;
+ this.close.tooltip = colorizeHotkey(usedCaptions.tooltip, "cancel");
+ }
+
onSelectionChange()
{
this.select.enabled = this.gridBrowser.selected != -1;
@@ -54,4 +51,18 @@
{
this.mapBrowserPage.submitMapSelection();
}
+
+ static Captions =
+ {
+ "close":
+ {
+ "caption": translate("Close"),
+ "tooltip": translate("%(hotkey)s: Close map browser.")
+ },
+ "cancel":
+ {
+ "caption": translate("Cancel"),
+ "tooltip": translate("%(hotkey)s: Close map browser and discard the selection.")
+ }
+ };
}
Index: ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/controls/MapBrowserControls.xml
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/controls/MapBrowserControls.xml
+++ ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/controls/MapBrowserControls.xml
@@ -47,9 +47,7 @@
-
+
Index: ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/grid/MapGridBrowserItem.js
===================================================================
--- ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/grid/MapGridBrowserItem.js
+++ ps/trunk/binaries/data/mods/public/gui/maps/mapbrowser/grid/MapGridBrowserItem.js
@@ -12,8 +12,7 @@
mapGridBrowser.registerSelectionChangeHandler(this.onSelectionChange.bind(this));
mapGridBrowser.registerPageChangeHandler(this.onGridResize.bind(this));
- if (g_IsController)
- this.imageObject.onMouseLeftDoubleClick = this.onMouseLeftDoubleClick.bind(this);
+ this.imageObject.onMouseLeftDoubleClick = this.onMouseLeftDoubleClick.bind(this);
}
onSelectionChange()