Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/Panels/MapPreview.js
class MapPreview | class MapPreview | ||||
{ | { | ||||
constructor(gameSettingsControl, mapCache) | constructor(gameSettingsControl, mapCache) | ||||
{ | { | ||||
this.gameSettingsControl = gameSettingsControl; | |||||
this.mapCache = mapCache; | this.mapCache = mapCache; | ||||
this.mapInfoName = Engine.GetGUIObjectByName("mapInfoName"); | this.mapInfoName = Engine.GetGUIObjectByName("mapInfoName"); | ||||
this.mapPreview = Engine.GetGUIObjectByName("mapPreview"); | this.mapPreview = Engine.GetGUIObjectByName("mapPreview"); | ||||
gameSettingsControl.registerMapChangeHandler(this.onMapChange.bind(this)); | |||||
gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this)); | gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this)); | ||||
} | } | ||||
onMapChange(mapData) | |||||
{ | |||||
let preview = mapData && mapData.settings && mapData.settings.Preview; | |||||
if (!g_GameAttributes.settings.Preview || g_GameAttributes.settings.Preview != preview) | |||||
{ | |||||
g_GameAttributes.settings.Preview = preview; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
onGameAttributesBatchChange() | onGameAttributesBatchChange() | ||||
{ | { | ||||
if (!g_GameAttributes.map || !g_GameAttributes.mapType) | if (!g_GameAttributes.map || !g_GameAttributes.mapType) | ||||
return; | return; | ||||
this.mapInfoName.caption = this.mapCache.translateMapName( | this.mapInfoName.caption = this.mapCache.translateMapName( | ||||
this.mapCache.getTranslatableMapName(g_GameAttributes.mapType, g_GameAttributes.map)); | this.mapCache.getTranslatableMapName(g_GameAttributes.mapType, g_GameAttributes.map)); | ||||
this.mapPreview.sprite = | this.mapPreview.sprite = | ||||
this.mapCache.getMapPreview(g_GameAttributes.mapType, g_GameAttributes.map, g_GameAttributes); | this.mapCache.getMapPreview(g_GameAttributes.mapType, g_GameAttributes.map, g_GameAttributes); | ||||
} | } | ||||
} | } |
Wildfire Games · Phabricator