# Update to technologies.
Made CTechnology inherit from CJSComplex, so that properties such as resources can be added dynamically instead of being hardcoded in it. Also removed some excessive debug output from GUI. This was SVN commit r4980.
This commit is contained in:
parent
1fc080f556
commit
1fea26a0e9
@ -609,11 +609,9 @@ function refreshCommandButtons()
|
||||
// Update production lists (both types of Construction, Train). (Tab button, persistent buttons, click them to do things.)
|
||||
if (validProperty ("selection[0].actions.create.list"))
|
||||
{
|
||||
console.write("Got actions.create.list");
|
||||
listRoot = selection[0].actions.create.list;
|
||||
for (listTab in listRoot)
|
||||
{
|
||||
console.write("Updating " + listTab);
|
||||
if (listTab != "research") // Do research later.
|
||||
updateTab (listTab, "production", "Tab", "listRoot[listTab]", "");
|
||||
}
|
||||
|
@ -997,7 +997,10 @@ int CXMLReader::ProgressiveRead()
|
||||
ReadTriggers(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_printf("Invalid XML element in map file: %s\n", name.c_str());
|
||||
debug_warn("Invalid map XML data");
|
||||
}
|
||||
|
||||
node_idx++;
|
||||
}
|
||||
|
@ -120,11 +120,7 @@ bool CTechnology::loadELReq( XMBElement Req, CXeromyces& XeroFile )
|
||||
|
||||
EL(time);
|
||||
EL(resource);
|
||||
EL(food);
|
||||
EL(tech);
|
||||
EL(stone);
|
||||
EL(metal);
|
||||
EL(wood);
|
||||
EL(entity);
|
||||
|
||||
#undef EL
|
||||
@ -144,29 +140,21 @@ bool CTechnology::loadELReq( XMBElement Req, CXeromyces& XeroFile )
|
||||
for ( int j=0; j<resChildren.Count; ++j )
|
||||
{
|
||||
XMBElement resElement = resChildren.item(j);
|
||||
int resName = resElement.getNodeName();
|
||||
CStrW resName = XeroFile.getElementString( resElement.getNodeName() );
|
||||
CStrW resValue = resElement.getText();
|
||||
|
||||
if ( resName == el_food ) //NOT LOADED-GET CHILD NODES
|
||||
m_ReqFood = resValue.ToFloat();
|
||||
else if ( resName == el_wood )
|
||||
m_ReqWood = resValue.ToFloat();
|
||||
else if ( resName == el_stone )
|
||||
m_ReqStone = resValue.ToFloat();
|
||||
else if ( resName == el_metal )
|
||||
m_ReqMetal = resValue.ToFloat();
|
||||
else
|
||||
{
|
||||
const char* tagName = XeroFile.getElementString(name).c_str();
|
||||
LOG( ERROR, LOG_CATEGORY, "CTechnology: invalid tag %s for XML file", tagName );
|
||||
return false;
|
||||
}
|
||||
// Add each resource as a property using its name in the XML file
|
||||
AddProperty( resName.LowerCase(), resValue);
|
||||
}
|
||||
}
|
||||
else if ( name == el_entity )
|
||||
{
|
||||
m_ReqEntities.push_back( value );
|
||||
}
|
||||
else if ( name == el_tech )
|
||||
{
|
||||
m_ReqTechs.push_back( value );
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* tagName = XeroFile.getElementString(name).c_str();
|
||||
@ -419,21 +407,17 @@ void CTechnology::apply( CEntity* entity )
|
||||
|
||||
void CTechnology::ScriptingInit()
|
||||
{
|
||||
AddProperty(L"name", &CTechnology::m_Name, true);
|
||||
AddProperty(L"player", &CTechnology::m_player, true);
|
||||
AddProperty(L"generic", &CTechnology::m_Generic, true);
|
||||
AddProperty(L"specific", &CTechnology::m_Specific, true);
|
||||
AddProperty(L"icon", &CTechnology::m_Icon); //GUI might want to change this...?
|
||||
AddProperty<int>(L"icon_cell", &CTechnology::m_IconCell);
|
||||
AddProperty(L"classes", &CTechnology::m_Classes, true);
|
||||
AddProperty(L"history", &CTechnology::m_History, true);
|
||||
AddClassProperty(L"name", &CTechnology::m_Name, true);
|
||||
AddClassProperty(L"player", &CTechnology::m_player, true);
|
||||
AddClassProperty(L"generic", &CTechnology::m_Generic, true);
|
||||
AddClassProperty(L"specific", &CTechnology::m_Specific, true);
|
||||
AddClassProperty(L"icon", &CTechnology::m_Icon); //GUI might want to change this...?
|
||||
AddClassProperty(L"icon_cell", &CTechnology::m_IconCell);
|
||||
AddClassProperty(L"classes", &CTechnology::m_Classes, true);
|
||||
AddClassProperty(L"history", &CTechnology::m_History, true);
|
||||
|
||||
AddProperty<float>(L"time", &CTechnology::m_ReqTime); //Techs may upgrade research time and cost of other techs
|
||||
AddProperty<float>(L"food", &CTechnology::m_ReqFood);
|
||||
AddProperty<float>(L"wood", &CTechnology::m_ReqWood);
|
||||
AddProperty<float>(L"stone", &CTechnology::m_ReqStone);
|
||||
AddProperty<float>(L"metal", &CTechnology::m_ReqMetal);
|
||||
AddProperty<bool>(L"in_progress", &CTechnology::m_inProgress);
|
||||
AddClassProperty(L"time", &CTechnology::m_ReqTime); //Techs may upgrade research time and cost of other techs
|
||||
AddClassProperty(L"in_progress", &CTechnology::m_inProgress);
|
||||
|
||||
AddMethod<jsval, &CTechnology::ApplyEffects>( "applyEffects", 2 );
|
||||
AddMethod<jsval, &CTechnology::IsExcluded>( "isExcluded", 0 );
|
||||
@ -441,7 +425,7 @@ void CTechnology::ScriptingInit()
|
||||
AddMethod<jsval, &CTechnology::IsResearched>( "isResearched", 0 );
|
||||
AddMethod<jsval, &CTechnology::GetPlayerID>( "getPlayerID", 0 );
|
||||
|
||||
CJSObject<CTechnology>::ScriptingInit("Technology");
|
||||
CJSComplex<CTechnology>::ScriptingInit("Technology");
|
||||
}
|
||||
|
||||
jsval CTechnology::ApplyEffects( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) )
|
||||
|
@ -1,12 +1,17 @@
|
||||
//Andrew aka pyrolink
|
||||
//ajdecker1022@msn.com
|
||||
//Holds template information for technologies and research
|
||||
// Andrew aka pyrolink
|
||||
// ajdecker1022@msn.com
|
||||
//
|
||||
// Holds effects of a technology (research item), as well as its status
|
||||
// (unavailable, researched, in progress, etc).
|
||||
//
|
||||
// There is a separate CTechnology object for each tech for each player,
|
||||
// because the status can be different for different players.
|
||||
|
||||
#ifndef TECHNOLOGY_INCLUDED
|
||||
#define TECHNOLOGY_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
#include "scripting/ScriptableObject.h"
|
||||
#include "scripting/ScriptableComplex.h"
|
||||
#include "simulation/ScriptObject.h"
|
||||
#include "ps/Game.h"
|
||||
|
||||
@ -14,7 +19,7 @@ class XMBElement;
|
||||
class CXeromyces;
|
||||
class CEntity;
|
||||
|
||||
class CTechnology : public CJSObject<CTechnology>
|
||||
class CTechnology : public CJSComplex<CTechnology>
|
||||
{
|
||||
friend class CTechnologyCollection;
|
||||
|
||||
@ -63,19 +68,15 @@ private:
|
||||
CStrW m_History;
|
||||
|
||||
float m_ReqTime;
|
||||
float m_ReqWood;
|
||||
float m_ReqFood;
|
||||
float m_ReqStone;
|
||||
float m_ReqMetal;
|
||||
|
||||
std::vector<CStr> m_ReqEntities;
|
||||
std::vector<CStr> m_ReqTechs;
|
||||
|
||||
std::vector<CStr> m_Pairs;
|
||||
std::vector<CStr> m_Targets;
|
||||
std::vector<Modifier> m_Modifiers;
|
||||
std::vector<Modifier> m_Sets;
|
||||
|
||||
CPlayer* m_player; //Which player this tech belongs to
|
||||
CPlayer* m_player; //Which player this tech object belongs to
|
||||
|
||||
CScriptObject m_effectFunction;
|
||||
|
||||
@ -85,6 +86,9 @@ private:
|
||||
|
||||
bool hasReqEntities();
|
||||
bool hasReqTechs();
|
||||
|
||||
// Hack: shouldn't be part of CJSComplex
|
||||
void rebuildClassSet() {};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user