Ticket #3909: renameTechMan.diff

File renameTechMan.diff, 21.1 KB (added by sanderd17, 8 years ago)
  • binaries/data/mods/public/simulation/components/Auras.js

     
    88
    99Auras.prototype.Init = function()
    1010{
    11     let cmpTechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);
     11    let cmpJsonTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager);
    1212    this.auras = {};
    1313    this.affectedPlayers = {};
    1414    let auraNames = this.GetAuraNames();
     
    1515    for (let name of auraNames)
    1616    {
    1717        this.affectedPlayers[name] = [];
    18         this.auras[name] = cmpTechnologyTemplateManager.GetAuraTemplate(name);
     18        this.auras[name] = cmpJsonTemplateManager.GetAuraTemplate(name);
    1919    }
    2020    // In case of autogarrisoning, this component can be called before ownership is set.
    2121    // So it needs to be completely initialised from the start.
  • binaries/data/mods/public/simulation/components/GuiInterface.js

     
    591591
    592592    // Add aura name and description loaded from JSON file
    593593    let auraNames = template.Auras._string.split(/\s+/);
    594     let cmpTechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);
     594    let cmpJsonTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager);
    595595    for (let name of auraNames)
    596596    {
    597         let auraTemplate = cmpTechnologyTemplateManager.GetAuraTemplate(name);
     597        let auraTemplate = cmpJsonTemplateManager.GetAuraTemplate(name);
    598598        if (!auraTemplate)
    599599        {
    600             // the following warning is perhaps useless since it's yet done in TechnologyTemplateManager
     600            // the following warning is perhaps useless since it's yet done in JsonTemplateManager
    601601            warn("Tried to get data for invalid aura: " + name);
    602602            continue;
    603603        }
     
    610610
    611611GuiInterface.prototype.GetTechnologyData = function(player, name)
    612612{
    613     let cmpTechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);
    614     let template = cmpTechnologyTemplateManager.GetTemplate(name);
     613    let cmpJsonTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager);
     614    let template = cmpJsonTemplateManager.GetTechnologyTemplate(name);
    615615
    616616    if (!template)
    617617    {
  • binaries/data/mods/public/simulation/components/JsonTemplateManager.js

     
    11/**
    22 * System component which loads the technology and the aura data files
    33 */
    4 function TechnologyTemplateManager() {}
     4function JsonTemplateManager() {}
    55
    6 TechnologyTemplateManager.prototype.Schema =
     6JsonTemplateManager.prototype.Schema =
    77    "<a:component type='system'/><empty/>";
    88
    9 TechnologyTemplateManager.prototype.Init = function()
     9JsonTemplateManager.prototype.Init = function()
    1010{
    1111    this.allTechs = {};
    1212    this.allAuras = {};
    1313    var techNames = this.ListAllTechs();
    1414    for (var i in techNames)
    15         this.GetTemplate(techNames[i]);
     15        this.GetTechnologyTemplate(techNames[i]);
    1616};
    1717
    18 TechnologyTemplateManager.prototype.GetTemplate = function(template)
     18JsonTemplateManager.prototype.Serialize = null; // we have no dynamic state to save
     19
     20JsonTemplateManager.prototype.GetTechnologyTemplate = function(template)
    1921{
    2022    if (!this.allTechs[template])
    2123    {
     
    2729    return this.allTechs[template];
    2830};
    2931
    30 TechnologyTemplateManager.prototype.GetAuraTemplate = function(template)
     32JsonTemplateManager.prototype.GetAuraTemplate = function(template)
    3133{
    3234    if (!this.allAuras[template])
    3335    {
     
    3941    return this.allAuras[template];
    4042};
    4143
    42 TechnologyTemplateManager.prototype.ListAllTechs = function()
     44JsonTemplateManager.prototype.ListAllTechs = function()
    4345{
    4446    return Engine.FindJSONFiles("technologies", true);
    4547};
    4648
    47 TechnologyTemplateManager.prototype.GetAllTechs = function()
     49JsonTemplateManager.prototype.GetAllTechs = function()
    4850{
    4951    return this.allTechs;
    5052};
    5153
    52 Engine.RegisterSystemComponentType(IID_TechnologyTemplateManager, "TechnologyTemplateManager", TechnologyTemplateManager);
     54Engine.RegisterSystemComponentType(IID_JsonTemplateManager, "JsonTemplateManager", JsonTemplateManager);
  • binaries/data/mods/public/simulation/components/ProductionQueue.js

     
    159159
    160160    // Remove any technologies that can't be searched by this civ (after capture for example)
    161161    techs = techs.filter(tech => {
    162         let reqs = cmpTechnologyManager.GetTechnologyTemplate(tech).requirements || null;
     162        let reqs = cmpTechnologyManager.GetTemplate(tech).requirements || null;
    163163        return cmpTechnologyManager.CheckTechnologyRequirements(reqs, true);
    164164    });
    165165
     
    175175        var tech = techs[i];
    176176        if (disabledTechnologies && disabledTechnologies[tech])
    177177            continue;
    178         var template = cmpTechnologyManager.GetTechnologyTemplate(tech);
     178        var template = cmpTechnologyManager.GetTemplate(tech);
    179179        if (!template.supersedes || techs.indexOf(template.supersedes) === -1)
    180180            techList.push(tech);
    181181        else
     
    206206            continue;
    207207        }
    208208
    209         var template = cmpTechnologyManager.GetTechnologyTemplate(tech);
     209        var template = cmpTechnologyManager.GetTemplate(tech);
    210210        if (template.top)
    211211            ret[i] = {"pair": true, "top": template.top, "bottom": template.bottom};
    212212        else
     
    223223   
    224224    var cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager);
    225225   
    226     var template = cmpTechnologyManager.GetTechnologyTemplate(tech);
     226    var template = cmpTechnologyManager.GetTemplate(tech);
    227227    if (template.top)
    228228    {
    229229        return (cmpTechnologyManager.IsTechnologyResearched(template.top) || cmpTechnologyManager.IsInProgress(template.top)
     
    316316        else if (type == "technology")
    317317        {
    318318            // Load the technology template
    319             var cmpTechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);
    320             var template = cmpTechnologyTemplateManager.GetTemplate(templateName);
     319            var cmpJsonTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager);
     320            var template = cmpJsonTemplateManager.GetTechnologyTemplate(templateName);
    321321            if (!template)
    322322                return;
    323323            var cmpPlayer = QueryOwnerInterface(this.entity);
     
    760760            var cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager);
    761761            cmpTechnologyManager.ResearchTechnology(item.technologyTemplate);
    762762           
    763             var template = cmpTechnologyManager.GetTechnologyTemplate(item.technologyTemplate);
     763            var template = cmpTechnologyManager.GetTemplate(item.technologyTemplate);
    764764           
    765765            if (template && template.soundComplete)
    766766            {
  • binaries/data/mods/public/simulation/components/TechnologyManager.js

     
    4141    // Some technologies are automatically researched when their conditions are met.  They have no cost and are
    4242    // researched instantly.  This allows civ bonuses and more complicated technologies.
    4343    this.autoResearchTech = {};
    44     var allTechs = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager).GetAllTechs();
     44    var allTechs = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager).GetAllTechs();
    4545    for (var key in allTechs)
    4646    {
    4747        if (allTechs[key].autoResearch || allTechs[key].top)
     
    5858// This function checks if the requirements of any autoresearch techs are met and if they are it researches them
    5959TechnologyManager.prototype.UpdateAutoResearch = function()
    6060{
    61     var cmpTechTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);
     61    var cmpJsonTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager);
    6262    for (var key in this.autoResearchTech)
    6363    {
    64         var tech = cmpTechTempMan.GetTemplate(key);
     64        var tech = cmpJsonTempMan.GetTechnologyTemplate(key);
    6565        if ((tech.autoResearch && this.CanResearch(key))
    6666            || (tech.top && (this.IsTechnologyResearched(tech.top) || this.IsTechnologyResearched(tech.bottom))))
    6767        {
     
    7272    }
    7373};
    7474
    75 TechnologyManager.prototype.GetTechnologyTemplate = function(tech)
     75TechnologyManager.prototype.GetTemplate = function(tech)
    7676{
    77     return Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager).GetTemplate(tech);
     77    return Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager).GetTechnologyTemplate(tech);
    7878};
    7979
    8080// Checks an entity template to see if its technology requirements have been met
     
    9797// Checks the requirements for a technology to see if it can be researched at the current time
    9898TechnologyManager.prototype.CanResearch = function(tech)
    9999{
    100     var template = this.GetTechnologyTemplate(tech);
     100    var template = this.GetTemplate(tech);
    101101    if (!template)
    102102    {
    103103        warn("Technology \"" + tech + "\" does not exist");
     
    254254{
    255255    this.StoppedResearch(tech); // The tech is no longer being currently researched
    256256
    257     var template = this.GetTechnologyTemplate(tech);
     257    var template = this.GetTemplate(tech);
    258258
    259259    if (!template)
    260260    {
     
    319319            if (!i || this.IsTechnologyResearched(i))
    320320                continue;
    321321
    322             var template = this.GetTechnologyTemplate(i);
     322            var template = this.GetTemplate(i);
    323323            this.researchedTechs[i] = template;
    324324
    325325            // 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 files
    3  */
    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

     
    2525    GetEntityFlagMask: function(identifier) { },
    2626});
    2727
    28 AddMock(SYSTEM_ENTITY, IID_TechnologyTemplateManager, {
     28AddMock(SYSTEM_ENTITY, IID_JsonTemplateManager, {
    2929    GetAuraTemplate: function(name) {
    3030        if (name == "test1")
    3131            return {
  • binaries/data/mods/public/simulation/helpers/Cheat.js

     
    9090            return;
    9191
    9292        // check if specialised tech exists (like phase_town_athen)
    93         var cmpTechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager);
    94         if (cmpTechnologyTemplateManager.ListAllTechs().indexOf(parameter + "_" + cmpPlayer.civ) > -1)
     93        var cmpJsonTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_JsonTemplateManager);
     94        if (cmpJsonTemplateManager.ListAllTechs().indexOf(parameter + "_" + cmpPlayer.civ) > -1)
    9595            parameter += "_" + cmpPlayer.civ;
    9696
    9797        Cheat({ "player": input.player, "action": "researchTechnology", "parameter": parameter, "selected": input.selected });
  • source/simulation2/TypeList.h

     
    160160INTERFACE(ValueModificationManager)
    161161COMPONENT(ValueModificationManagerScripted)
    162162
    163 INTERFACE(TechnologyTemplateManager)
    164 COMPONENT(TechnologyTemplateManagerScripted)
     163INTERFACE(JsonTemplateManager)
     164COMPONENT(JsonTemplateManagerScripted)
    165165
    166166INTERFACE(Terrain)
    167167COMPONENT(Terrain)
  • source/simulation2/components/CCmpAIManager.cpp

     
    3434#include "simulation2/components/ICmpObstructionManager.h"
    3535#include "simulation2/components/ICmpRangeManager.h"
    3636#include "simulation2/components/ICmpTemplateManager.h"
    37 #include "simulation2/components/ICmpTechnologyTemplateManager.h"
     37#include "simulation2/components/ICmpJsonTemplateManager.h"
    3838#include "simulation2/components/ICmpTerritoryManager.h"
    3939#include "simulation2/helpers/LongPathfinder.h"
    4040#include "simulation2/serialization/DebugSerializer.h"
     
    979979        JSAutoRequest rq(cx);
    980980
    981981        // load the technology templates
    982         CmpPtr<ICmpTechnologyTemplateManager> cmpTechTemplateManager(GetSystemEntity());
    983         ENSURE(cmpTechTemplateManager);
     982        CmpPtr<ICmpJsonTemplateManager> cmpJsonTemplateManager(GetSystemEntity());
     983        ENSURE(cmpJsonTemplateManager);
    984984
    985985        // Get the game state from AIInterface
    986986        JS::RootedValue techTemplates(cx);
    987         cmpTechTemplateManager->GetAllTechs(&techTemplates);
     987        cmpJsonTemplateManager->GetAllTechs(&techTemplates);
    988988
    989989        m_Worker.RegisterTechTemplates(scriptInterface.WriteStructuredClone(techTemplates));
    990990        m_Worker.TryLoadSharedComponent(true);
  • source/simulation2/components/ICmpJsonTemplateManager.cpp

     
    1717
    1818#include "precompiled.h"
    1919
    20 #include "ICmpTechnologyTemplateManager.h"
     20#include "ICmpJsonTemplateManager.h"
    2121
    2222#include "simulation2/system/InterfaceScripted.h"
    2323#include "simulation2/scripting/ScriptComponent.h"
    2424
    25 BEGIN_INTERFACE_WRAPPER(TechnologyTemplateManager)
    26 END_INTERFACE_WRAPPER(TechnologyTemplateManager)
     25BEGIN_INTERFACE_WRAPPER(JsonTemplateManager)
     26END_INTERFACE_WRAPPER(JsonTemplateManager)
    2727
    28 class CCmpTechnologyTemplateManagerScripted : public ICmpTechnologyTemplateManager
     28class CCmpJsonTemplateManagerScripted : public ICmpJsonTemplateManager
    2929{
    3030public:
    31     DEFAULT_SCRIPT_WRAPPER(TechnologyTemplateManagerScripted)
     31    DEFAULT_SCRIPT_WRAPPER(JsonTemplateManagerScripted)
    3232
    3333    virtual void GetAllTechs(JS::MutableHandleValue ret)
    3434    {
     
    3636    }
    3737};
    3838
    39 REGISTER_COMPONENT_SCRIPT_WRAPPER(TechnologyTemplateManagerScripted)
     39REGISTER_COMPONENT_SCRIPT_WRAPPER(JsonTemplateManagerScripted)
  • source/simulation2/components/ICmpJsonTemplateManager.h

     
    1515 * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
    1616 */
    1717
    18 #ifndef INCLUDED_ICMPTECHNOLOGYTEMPLATEMANAGER
    19 #define INCLUDED_ICMPTECHNOLOGYTEMPLATEMANAGER
     18#ifndef INCLUDED_ICMPJSONTEMPLATEMANAGER
     19#define INCLUDED_ICMPJSONTEMPLATEMANAGER
    2020
    2121#include "simulation2/system/Interface.h"
    2222
     
    2323#include "maths/Fixed.h"
    2424
    2525/**
    26  * Technology template manager interface.
     26 * Json template manager interface.
    2727 * (This interface only includes the functions needed by native code for accessing
    28  *  technology template data, the associated logic is handled in scripts)
     28 *  json template data, the associated logic is handled in scripts)
    2929 */
    30 class ICmpTechnologyTemplateManager : public IComponent
     30class ICmpJsonTemplateManager : public IComponent
    3131{
    3232public:
    3333    virtual void GetAllTechs(JS::MutableHandleValue ret) = 0;
    3434
    35     DECLARE_INTERFACE_TYPE(TechnologyTemplateManager)
     35    DECLARE_INTERFACE_TYPE(JsonTemplateManager)
    3636};
    3737
    38 #endif // INCLUDED_ICMPTECHNOLOGYTEMPLATEMANAGER
     38#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 modify
    5  * it under the terms of the GNU General Public License as published by
    6  * the Free Software Foundation, either version 2 of the License, or
    7  * (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 of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * 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 ICmpTechnologyTemplateManager
    29 {
    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 modify
    5  * it under the terms of the GNU General Public License as published by
    6  * the Free Software Foundation, either version 2 of the License, or
    7  * (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 of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
    16  */
    17 
    18 #ifndef INCLUDED_ICMPTECHNOLOGYTEMPLATEMANAGER
    19 #define INCLUDED_ICMPTECHNOLOGYTEMPLATEMANAGER
    20 
    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 accessing
    28  *  technology template data, the associated logic is handled in scripts)
    29  */
    30 class ICmpTechnologyTemplateManager : public IComponent
    31 {
    32 public:
    33     virtual void GetAllTechs(JS::MutableHandleValue ret) = 0;
    34 
    35     DECLARE_INTERFACE_TYPE(TechnologyTemplateManager)
    36 };
    37 
    38 #endif // INCLUDED_ICMPTECHNOLOGYTEMPLATEMANAGER