Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesettings/attributes/Landscape.js
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | for (let group of this.data) | ||||
if (item.Id == this.value) | if (item.Id == this.value) | ||||
return item.Preview; | return item.Preview; | ||||
return undefined; | return undefined; | ||||
} | } | ||||
pickRandomItems() | pickRandomItems() | ||||
{ | { | ||||
// If the map is random, we need to wait until it is selected. | // If the map is random, we need to wait until it is selected. | ||||
if (this.settings.map.map === "random") | if (this.settings.map.map === "random" || !this.value || !this.value.startsWith("random")) | ||||
return true; | |||||
if (!this.value || !this.value.startsWith("random")) | |||||
return false; | return false; | ||||
let items = []; | let items = []; | ||||
if (this.value.indexOf("_") !== -1) | if (this.value.indexOf("_") !== -1) | ||||
{ | { | ||||
let subgroup = this.data.find(x => x.Id == this.value); | let subgroup = this.data.find(x => x.Id == this.value); | ||||
items = subgroup.Items.map(x => x.Id); | items = subgroup.Items.map(x => x.Id); | ||||
} | } | ||||
else | else | ||||
items = this.data.map(x => x.Items.map(item => item.Id)).flat(); | items = this.data.map(x => x.Items.map(item => item.Id)).flat(); | ||||
this.value = pickRandom(items); | this.value = pickRandom(items); | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator