Ticket #3909: renameTechMan.diff
File renameTechMan.diff, 21.1 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/Auras.js
8 8 9 9 Auras.prototype.Init = function() 10 10 { 11 let cmp TechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);11 let cmpJsonTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager); 12 12 this.auras = {}; 13 13 this.affectedPlayers = {}; 14 14 let auraNames = this.GetAuraNames(); … … 15 15 for (let name of auraNames) 16 16 { 17 17 this.affectedPlayers[name] = []; 18 this.auras[name] = cmp TechnologyTemplateManager.GetAuraTemplate(name);18 this.auras[name] = cmpJsonTemplateManager.GetAuraTemplate(name); 19 19 } 20 20 // In case of autogarrisoning, this component can be called before ownership is set. 21 21 // So it needs to be completely initialised from the start. -
binaries/data/mods/public/simulation/components/GuiInterface.js
591 591 592 592 // Add aura name and description loaded from JSON file 593 593 let auraNames = template.Auras._string.split(/\s+/); 594 let cmp TechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);594 let cmpJsonTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager); 595 595 for (let name of auraNames) 596 596 { 597 let auraTemplate = cmp TechnologyTemplateManager.GetAuraTemplate(name);597 let auraTemplate = cmpJsonTemplateManager.GetAuraTemplate(name); 598 598 if (!auraTemplate) 599 599 { 600 // the following warning is perhaps useless since it's yet done in TechnologyTemplateManager600 // the following warning is perhaps useless since it's yet done in JsonTemplateManager 601 601 warn("Tried to get data for invalid aura: " + name); 602 602 continue; 603 603 } … … 610 610 611 611 GuiInterface.prototype.GetTechnologyData = function(player, name) 612 612 { 613 let cmp TechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);614 let template = cmp TechnologyTemplateManager.GetTemplate(name);613 let cmpJsonTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager); 614 let template = cmpJsonTemplateManager.GetTechnologyTemplate(name); 615 615 616 616 if (!template) 617 617 { -
binaries/data/mods/public/simulation/components/JsonTemplateManager.js
1 1 /** 2 2 * System component which loads the technology and the aura data files 3 3 */ 4 function TechnologyTemplateManager() {}4 function JsonTemplateManager() {} 5 5 6 TechnologyTemplateManager.prototype.Schema =6 JsonTemplateManager.prototype.Schema = 7 7 "<a:component type='system'/><empty/>"; 8 8 9 TechnologyTemplateManager.prototype.Init = function()9 JsonTemplateManager.prototype.Init = function() 10 10 { 11 11 this.allTechs = {}; 12 12 this.allAuras = {}; 13 13 var techNames = this.ListAllTechs(); 14 14 for (var i in techNames) 15 this.GetTe mplate(techNames[i]);15 this.GetTechnologyTemplate(techNames[i]); 16 16 }; 17 17 18 TechnologyTemplateManager.prototype.GetTemplate = function(template) 18 JsonTemplateManager.prototype.Serialize = null; // we have no dynamic state to save 19 20 JsonTemplateManager.prototype.GetTechnologyTemplate = function(template) 19 21 { 20 22 if (!this.allTechs[template]) 21 23 { … … 27 29 return this.allTechs[template]; 28 30 }; 29 31 30 TechnologyTemplateManager.prototype.GetAuraTemplate = function(template)32 JsonTemplateManager.prototype.GetAuraTemplate = function(template) 31 33 { 32 34 if (!this.allAuras[template]) 33 35 { … … 39 41 return this.allAuras[template]; 40 42 }; 41 43 42 TechnologyTemplateManager.prototype.ListAllTechs = function()44 JsonTemplateManager.prototype.ListAllTechs = function() 43 45 { 44 46 return Engine.FindJSONFiles("technologies", true); 45 47 }; 46 48 47 TechnologyTemplateManager.prototype.GetAllTechs = function()49 JsonTemplateManager.prototype.GetAllTechs = function() 48 50 { 49 51 return this.allTechs; 50 52 }; 51 53 52 Engine.RegisterSystemComponentType(IID_ TechnologyTemplateManager, "TechnologyTemplateManager", TechnologyTemplateManager);54 Engine.RegisterSystemComponentType(IID_JsonTemplateManager, "JsonTemplateManager", JsonTemplateManager); -
binaries/data/mods/public/simulation/components/ProductionQueue.js
159 159 160 160 // Remove any technologies that can't be searched by this civ (after capture for example) 161 161 techs = techs.filter(tech => { 162 let reqs = cmpTechnologyManager.GetTe chnologyTemplate(tech).requirements || null;162 let reqs = cmpTechnologyManager.GetTemplate(tech).requirements || null; 163 163 return cmpTechnologyManager.CheckTechnologyRequirements(reqs, true); 164 164 }); 165 165 … … 175 175 var tech = techs[i]; 176 176 if (disabledTechnologies && disabledTechnologies[tech]) 177 177 continue; 178 var template = cmpTechnologyManager.GetTe chnologyTemplate(tech);178 var template = cmpTechnologyManager.GetTemplate(tech); 179 179 if (!template.supersedes || techs.indexOf(template.supersedes) === -1) 180 180 techList.push(tech); 181 181 else … … 206 206 continue; 207 207 } 208 208 209 var template = cmpTechnologyManager.GetTe chnologyTemplate(tech);209 var template = cmpTechnologyManager.GetTemplate(tech); 210 210 if (template.top) 211 211 ret[i] = {"pair": true, "top": template.top, "bottom": template.bottom}; 212 212 else … … 223 223 224 224 var cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager); 225 225 226 var template = cmpTechnologyManager.GetTe chnologyTemplate(tech);226 var template = cmpTechnologyManager.GetTemplate(tech); 227 227 if (template.top) 228 228 { 229 229 return (cmpTechnologyManager.IsTechnologyResearched(template.top) || cmpTechnologyManager.IsInProgress(template.top) … … 316 316 else if (type == "technology") 317 317 { 318 318 // Load the technology template 319 var cmp TechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);320 var template = cmp TechnologyTemplateManager.GetTemplate(templateName);319 var cmpJsonTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager); 320 var template = cmpJsonTemplateManager.GetTechnologyTemplate(templateName); 321 321 if (!template) 322 322 return; 323 323 var cmpPlayer = QueryOwnerInterface(this.entity); … … 760 760 var cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager); 761 761 cmpTechnologyManager.ResearchTechnology(item.technologyTemplate); 762 762 763 var template = cmpTechnologyManager.GetTe chnologyTemplate(item.technologyTemplate);763 var template = cmpTechnologyManager.GetTemplate(item.technologyTemplate); 764 764 765 765 if (template && template.soundComplete) 766 766 { -
binaries/data/mods/public/simulation/components/TechnologyManager.js
41 41 // Some technologies are automatically researched when their conditions are met. They have no cost and are 42 42 // researched instantly. This allows civ bonuses and more complicated technologies. 43 43 this.autoResearchTech = {}; 44 var allTechs = Engine.QueryInterface(SYSTEM_ENTITY, IID_ TechnologyTemplateManager).GetAllTechs();44 var allTechs = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager).GetAllTechs(); 45 45 for (var key in allTechs) 46 46 { 47 47 if (allTechs[key].autoResearch || allTechs[key].top) … … 58 58 // This function checks if the requirements of any autoresearch techs are met and if they are it researches them 59 59 TechnologyManager.prototype.UpdateAutoResearch = function() 60 60 { 61 var cmp TechTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);61 var cmpJsonTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager); 62 62 for (var key in this.autoResearchTech) 63 63 { 64 var tech = cmp TechTempMan.GetTemplate(key);64 var tech = cmpJsonTempMan.GetTechnologyTemplate(key); 65 65 if ((tech.autoResearch && this.CanResearch(key)) 66 66 || (tech.top && (this.IsTechnologyResearched(tech.top) || this.IsTechnologyResearched(tech.bottom)))) 67 67 { … … 72 72 } 73 73 }; 74 74 75 TechnologyManager.prototype.GetTe chnologyTemplate = function(tech)75 TechnologyManager.prototype.GetTemplate = function(tech) 76 76 { 77 return Engine.QueryInterface(SYSTEM_ENTITY, IID_ TechnologyTemplateManager).GetTemplate(tech);77 return Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager).GetTechnologyTemplate(tech); 78 78 }; 79 79 80 80 // Checks an entity template to see if its technology requirements have been met … … 97 97 // Checks the requirements for a technology to see if it can be researched at the current time 98 98 TechnologyManager.prototype.CanResearch = function(tech) 99 99 { 100 var template = this.GetTe chnologyTemplate(tech);100 var template = this.GetTemplate(tech); 101 101 if (!template) 102 102 { 103 103 warn("Technology \"" + tech + "\" does not exist"); … … 254 254 { 255 255 this.StoppedResearch(tech); // The tech is no longer being currently researched 256 256 257 var template = this.GetTe chnologyTemplate(tech);257 var template = this.GetTemplate(tech); 258 258 259 259 if (!template) 260 260 { … … 319 319 if (!i || this.IsTechnologyResearched(i)) 320 320 continue; 321 321 322 var template = this.GetTe chnologyTemplate(i);322 var template = this.GetTemplate(i); 323 323 this.researchedTechs[i] = template; 324 324 325 325 // Change the EntityLimit if any -
binaries/data/mods/public/simulation/components/TechnologyTemplateManager.js
1 /**2 * System component which loads the technology and the aura data files3 */4 function TechnologyTemplateManager() {}5 6 TechnologyTemplateManager.prototype.Schema =7 "<a:component type='system'/><empty/>";8 9 TechnologyTemplateManager.prototype.Init = function()10 {11 this.allTechs = {};12 this.allAuras = {};13 var techNames = this.ListAllTechs();14 for (var i in techNames)15 this.GetTemplate(techNames[i]);16 };17 18 TechnologyTemplateManager.prototype.GetTemplate = function(template)19 {20 if (!this.allTechs[template])21 {22 this.allTechs[template] = Engine.ReadJSONFile("technologies/" + template + ".json");23 if (!this.allTechs[template])24 error("Failed to load technology \"" + template + "\"");25 }26 27 return this.allTechs[template];28 };29 30 TechnologyTemplateManager.prototype.GetAuraTemplate = function(template)31 {32 if (!this.allAuras[template])33 {34 this.allAuras[template] = Engine.ReadJSONFile("auras/" + template + ".json");35 if (!this.allAuras[template])36 error("Failed to load aura \"" + template + "\"");37 }38 39 return this.allAuras[template];40 };41 42 TechnologyTemplateManager.prototype.ListAllTechs = function()43 {44 return Engine.FindJSONFiles("technologies", true);45 };46 47 TechnologyTemplateManager.prototype.GetAllTechs = function()48 {49 return this.allTechs;50 };51 52 Engine.RegisterSystemComponentType(IID_TechnologyTemplateManager, "TechnologyTemplateManager", TechnologyTemplateManager); -
binaries/data/mods/public/simulation/components/tests/test_Auras.js
25 25 GetEntityFlagMask: function(identifier) { }, 26 26 }); 27 27 28 AddMock(SYSTEM_ENTITY, IID_ TechnologyTemplateManager, {28 AddMock(SYSTEM_ENTITY, IID_JsonTemplateManager, { 29 29 GetAuraTemplate: function(name) { 30 30 if (name == "test1") 31 31 return { -
binaries/data/mods/public/simulation/helpers/Cheat.js
90 90 return; 91 91 92 92 // check if specialised tech exists (like phase_town_athen) 93 var cmp TechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);94 if (cmp TechnologyTemplateManager.ListAllTechs().indexOf(parameter + "_" + cmpPlayer.civ) > -1)93 var cmpJsonTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager); 94 if (cmpJsonTemplateManager.ListAllTechs().indexOf(parameter + "_" + cmpPlayer.civ) > -1) 95 95 parameter += "_" + cmpPlayer.civ; 96 96 97 97 Cheat({ "player": input.player, "action": "researchTechnology", "parameter": parameter, "selected": input.selected }); -
source/simulation2/TypeList.h
160 160 INTERFACE(ValueModificationManager) 161 161 COMPONENT(ValueModificationManagerScripted) 162 162 163 INTERFACE( TechnologyTemplateManager)164 COMPONENT( TechnologyTemplateManagerScripted)163 INTERFACE(JsonTemplateManager) 164 COMPONENT(JsonTemplateManagerScripted) 165 165 166 166 INTERFACE(Terrain) 167 167 COMPONENT(Terrain) -
source/simulation2/components/CCmpAIManager.cpp
34 34 #include "simulation2/components/ICmpObstructionManager.h" 35 35 #include "simulation2/components/ICmpRangeManager.h" 36 36 #include "simulation2/components/ICmpTemplateManager.h" 37 #include "simulation2/components/ICmp TechnologyTemplateManager.h"37 #include "simulation2/components/ICmpJsonTemplateManager.h" 38 38 #include "simulation2/components/ICmpTerritoryManager.h" 39 39 #include "simulation2/helpers/LongPathfinder.h" 40 40 #include "simulation2/serialization/DebugSerializer.h" … … 979 979 JSAutoRequest rq(cx); 980 980 981 981 // load the technology templates 982 CmpPtr<ICmp TechnologyTemplateManager> cmpTechTemplateManager(GetSystemEntity());983 ENSURE(cmp TechTemplateManager);982 CmpPtr<ICmpJsonTemplateManager> cmpJsonTemplateManager(GetSystemEntity()); 983 ENSURE(cmpJsonTemplateManager); 984 984 985 985 // Get the game state from AIInterface 986 986 JS::RootedValue techTemplates(cx); 987 cmp TechTemplateManager->GetAllTechs(&techTemplates);987 cmpJsonTemplateManager->GetAllTechs(&techTemplates); 988 988 989 989 m_Worker.RegisterTechTemplates(scriptInterface.WriteStructuredClone(techTemplates)); 990 990 m_Worker.TryLoadSharedComponent(true); -
source/simulation2/components/ICmpJsonTemplateManager.cpp
17 17 18 18 #include "precompiled.h" 19 19 20 #include "ICmp TechnologyTemplateManager.h"20 #include "ICmpJsonTemplateManager.h" 21 21 22 22 #include "simulation2/system/InterfaceScripted.h" 23 23 #include "simulation2/scripting/ScriptComponent.h" 24 24 25 BEGIN_INTERFACE_WRAPPER( TechnologyTemplateManager)26 END_INTERFACE_WRAPPER( TechnologyTemplateManager)25 BEGIN_INTERFACE_WRAPPER(JsonTemplateManager) 26 END_INTERFACE_WRAPPER(JsonTemplateManager) 27 27 28 class CCmp TechnologyTemplateManagerScripted : public ICmpTechnologyTemplateManager28 class CCmpJsonTemplateManagerScripted : public ICmpJsonTemplateManager 29 29 { 30 30 public: 31 DEFAULT_SCRIPT_WRAPPER( TechnologyTemplateManagerScripted)31 DEFAULT_SCRIPT_WRAPPER(JsonTemplateManagerScripted) 32 32 33 33 virtual void GetAllTechs(JS::MutableHandleValue ret) 34 34 { … … 36 36 } 37 37 }; 38 38 39 REGISTER_COMPONENT_SCRIPT_WRAPPER( TechnologyTemplateManagerScripted)39 REGISTER_COMPONENT_SCRIPT_WRAPPER(JsonTemplateManagerScripted) -
source/simulation2/components/ICmpJsonTemplateManager.h
15 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 16 */ 17 17 18 #ifndef INCLUDED_ICMP TECHNOLOGYTEMPLATEMANAGER19 #define INCLUDED_ICMP TECHNOLOGYTEMPLATEMANAGER18 #ifndef INCLUDED_ICMPJSONTEMPLATEMANAGER 19 #define INCLUDED_ICMPJSONTEMPLATEMANAGER 20 20 21 21 #include "simulation2/system/Interface.h" 22 22 … … 23 23 #include "maths/Fixed.h" 24 24 25 25 /** 26 * Technologytemplate manager interface.26 * Json template manager interface. 27 27 * (This interface only includes the functions needed by native code for accessing 28 * technologytemplate data, the associated logic is handled in scripts)28 * json template data, the associated logic is handled in scripts) 29 29 */ 30 class ICmp TechnologyTemplateManager : public IComponent30 class ICmpJsonTemplateManager : public IComponent 31 31 { 32 32 public: 33 33 virtual void GetAllTechs(JS::MutableHandleValue ret) = 0; 34 34 35 DECLARE_INTERFACE_TYPE( TechnologyTemplateManager)35 DECLARE_INTERFACE_TYPE(JsonTemplateManager) 36 36 }; 37 37 38 #endif // INCLUDED_ICMP TECHNOLOGYTEMPLATEMANAGER38 #endif // INCLUDED_ICMPJSONTEMPLATEMANAGER -
source/simulation2/components/ICmpTechnologyTemplateManager.cpp
1 /* Copyright (C) 2012 Wildfire Games.2 * This file is part of 0 A.D.3 *4 * 0 A.D. is free software: you can redistribute it and/or modify5 * it under the terms of the GNU General Public License as published by6 * the Free Software Foundation, either version 2 of the License, or7 * (at your option) any later version.8 *9 * 0 A.D. is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU General Public License for more details.13 *14 * You should have received a copy of the GNU General Public License15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.16 */17 18 #include "precompiled.h"19 20 #include "ICmpTechnologyTemplateManager.h"21 22 #include "simulation2/system/InterfaceScripted.h"23 #include "simulation2/scripting/ScriptComponent.h"24 25 BEGIN_INTERFACE_WRAPPER(TechnologyTemplateManager)26 END_INTERFACE_WRAPPER(TechnologyTemplateManager)27 28 class CCmpTechnologyTemplateManagerScripted : public ICmpTechnologyTemplateManager29 {30 public:31 DEFAULT_SCRIPT_WRAPPER(TechnologyTemplateManagerScripted)32 33 virtual void GetAllTechs(JS::MutableHandleValue ret)34 {35 return m_Script.CallRef("GetAllTechs", ret);36 }37 };38 39 REGISTER_COMPONENT_SCRIPT_WRAPPER(TechnologyTemplateManagerScripted) -
source/simulation2/components/ICmpTechnologyTemplateManager.h
Property changes on: source/simulation2/components/ICmpTechnologyTemplateManager.cpp ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property
1 /* Copyright (C) 2012 Wildfire Games.2 * This file is part of 0 A.D.3 *4 * 0 A.D. is free software: you can redistribute it and/or modify5 * it under the terms of the GNU General Public License as published by6 * the Free Software Foundation, either version 2 of the License, or7 * (at your option) any later version.8 *9 * 0 A.D. is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU General Public License for more details.13 *14 * You should have received a copy of the GNU General Public License15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.16 */17 18 #ifndef INCLUDED_ICMPTECHNOLOGYTEMPLATEMANAGER19 #define INCLUDED_ICMPTECHNOLOGYTEMPLATEMANAGER20 21 #include "simulation2/system/Interface.h"22 23 #include "maths/Fixed.h"24 25 /**26 * Technology template manager interface.27 * (This interface only includes the functions needed by native code for accessing28 * technology template data, the associated logic is handled in scripts)29 */30 class ICmpTechnologyTemplateManager : public IComponent31 {32 public:33 virtual void GetAllTechs(JS::MutableHandleValue ret) = 0;34 35 DECLARE_INTERFACE_TYPE(TechnologyTemplateManager)36 };37 38 #endif // INCLUDED_ICMPTECHNOLOGYTEMPLATEMANAGER