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()`. | ||||
elexis: This GUI Interface copying can be nuked too by just including `JSInterface_VFS.cpp` from the… | |||||
*/ | */ | ||||
function Resources() | function Resources() | ||||
{ | { | ||||
let jsonFiles = []; | |||||
// Simulation context | |||||
if (Engine.FindJSONFiles) | |||||
{ | |||||
jsonFiles = Engine.FindJSONFiles("resources", false); | |||||
for (let file in jsonFiles) | |||||
jsonFiles[file] = "simulation/data/resources/" + jsonFiles[file] + ".json"; | |||||
} | |||||
// GUI context | |||||
else if (Engine.BuildDirEntList) | |||||
jsonFiles = Engine.BuildDirEntList("simulation/data/resources/", "*.json", false); | |||||
else | |||||
{ | |||||
error("Resources: JSON functions are not available"); | |||||
return; | |||||
} | |||||
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 Engine.ListDirectoryFiles("simulation/data/resources/", "*.json", false)) | ||||
{ | { | ||||
let data = Engine.ReadJSONFile(filename); | let data = Engine.ReadJSONFile(filename); | ||||
if (!data) | if (!data) | ||||
continue; | continue; | ||||
if (data.code != data.code.toLowerCase()) | if (data.code != data.code.toLowerCase()) | ||||
warn("Resource codes should use lower case: " + data.code); | warn("Resource codes should use lower case: " + data.code); | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
This GUI Interface copying can be nuked too by just including JSInterface_VFS.cpp from the CCmpAIManager.cpp. In some later diff.