Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/globalscripts/Resources.js
/** | /** | ||||
* Since the AI context can't access JSON functions, it gets passed an object | * Since the AI context can't access JSON functions, it gets passed an object | ||||
* containing the information from `GuiInterface.js::GetSimulationState()`. | * containing the information from `GuiInterface.js::GetSimulationState()`. | ||||
*/ | */ | ||||
function Resources() | function Resources() | ||||
{ | { | ||||
let jsonFiles = []; | let jsonFiles = []; | ||||
// Simulation context | // Simulation context | ||||
if (Engine.FindJSONFiles) | if (Engine.FindJSONFiles) | ||||
{ | { | ||||
jsonFiles = Engine.FindJSONFiles("resources", false); | jsonFiles = Engine.FindJSONFiles("resources", false); | ||||
for (let file in jsonFiles) | for (let file in jsonFiles) | ||||
jsonFiles[file] = "resources/" + jsonFiles[file] + ".json"; | jsonFiles[file] = "simulation/data/resources/" + jsonFiles[file] + ".json"; | ||||
} | } | ||||
// GUI context | // GUI context | ||||
else if (Engine.BuildDirEntList) | else if (Engine.BuildDirEntList) | ||||
jsonFiles = Engine.BuildDirEntList("simulation/data/resources/", "*.json", false); | jsonFiles = Engine.BuildDirEntList("simulation/data/resources/", "*.json", false); | ||||
else | else | ||||
{ | { | ||||
error("Resources: JSON functions are not available"); | error("Resources: JSON functions are not available"); | ||||
return; | return; | ||||
} | } | ||||
elexis: Above code will have no path separation anymore, i.e. unified.
`loadCivFiles` can have the… | |||||
this.resourceData = []; | this.resourceData = []; | ||||
this.resourceDataObj = {}; | this.resourceDataObj = {}; | ||||
this.resourceCodes = []; | this.resourceCodes = []; | ||||
this.resourceNames = {}; | this.resourceNames = {}; | ||||
for (let filename of jsonFiles) | for (let filename of jsonFiles) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Above code will have no path separation anymore, i.e. unified.
loadCivFiles can have the comment about only being usable from gui/ and rmgen/ removed.
The DataTemplateManager could cache not only two but all three kinds of JSON files read from in the simulation and call that function.
Seems nicer to do in a separate diff to keep this one closer to its essence.