Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/reference/common/TemplateLoader.js
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | class TemplateLoader | |||||||||||||||||||
*/ | */ | |||||||||||||||||||
loadTechnologyTemplate(templateName) | loadTechnologyTemplate(templateName) | |||||||||||||||||||
{ | { | |||||||||||||||||||
if (!(templateName in this.technologyData)) | if (!(templateName in this.technologyData)) | |||||||||||||||||||
{ | { | |||||||||||||||||||
let data = Engine.ReadJSONFile(this.TechnologyPath + templateName + ".json"); | let data = Engine.ReadJSONFile(this.TechnologyPath + templateName + ".json"); | |||||||||||||||||||
translateObjectKeys(data, this.TechnologyTranslateKeys); | translateObjectKeys(data, this.TechnologyTranslateKeys); | |||||||||||||||||||
// Translate specificName as in GetTechnologyData() from gui/session/session.js | // Translate specificName[civ] as in GetTechnologyData() from gui/session/session.js | |||||||||||||||||||
if (typeof (data.specificName) === 'object') | ||||||||||||||||||||
for (let civ in data.specificName) | for (let civ in data.specificName) | |||||||||||||||||||
data.specificName[civ] = translate(data.specificName[civ]); | data.specificName[civ] = translate(data.specificName[civ]); | |||||||||||||||||||
wraitii: `instanceof Object` is somewhat wrong, because `instanceof` is intended to check for specific… | ||||||||||||||||||||
wraitiiUnsubmitted Not Done Inline Actions
wraitii: | ||||||||||||||||||||
nwtourAuthorUnsubmitted Done Inline Actions
It doesn't work. There are files in the repository with empty specificName (type == undefined)
Not sure if this is a great idea. Modders complain about brocken of backward compatibility. I found no visible errors to interrupt processing nwtour: > if (typeof (data.specificName) !== 'object')
It doesn't work. There are files in the… | ||||||||||||||||||||
wraitiiUnsubmitted Not Done Inline ActionsIn practice, a warning is already a show-stopper - in SVN, we won't tolerate it, so it's equivalent to a crashing error conceptually. That being said, I don't particularly mind continuing.
Right, good call. wraitii: In practice, a warning is already a show-stopper - in SVN, we won't tolerate it, so it's… | ||||||||||||||||||||
this.technologyData[templateName] = data; | this.technologyData[templateName] = data; | |||||||||||||||||||
} | } | |||||||||||||||||||
return this.technologyData[templateName]; | return this.technologyData[templateName]; | |||||||||||||||||||
} | } | |||||||||||||||||||
/** | /** | |||||||||||||||||||
▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
instanceof Object is somewhat wrong, because instanceof is intended to check for specific Object types already, so it kind of assumes an object. It still works, but I think I'd prefer typeof(X) === "string"