diff --git a/binaries/data/mods/public/simulation/components/Armour.js b/binaries/data/mods/public/simulation/components/Armour.js index f64b49d8b9..049360e9db 100644 --- a/binaries/data/mods/public/simulation/components/Armour.js +++ b/binaries/data/mods/public/simulation/components/Armour.js @@ -1,13 +1,19 @@ function Armour() {} Armour.prototype.Schema = - "" + + "Controls the damage resistance of the unit." + + "" + + "10.0" + + "0.0" + + "5.0" + + "" + + "" + "" + "" + - "" + + "" + "" + "" + - "" + + "" + "" + ""; diff --git a/binaries/data/mods/public/simulation/components/Attack.js b/binaries/data/mods/public/simulation/components/Attack.js index 98f993ca36..6676b91ef3 100644 --- a/binaries/data/mods/public/simulation/components/Attack.js +++ b/binaries/data/mods/public/simulation/components/Attack.js @@ -1,35 +1,44 @@ function Attack() {} Attack.prototype.Schema = - "" + + "Controls the attack abilities and strengths of the unit." + + "" + + "10.0" + + "0.0" + + "5.0" + + "10.0" + + "0.0" + + "800" + + "1600" + + "50.0" + + "" + + "" + "" + "" + - "" + + "" + "" + "" + - "" + + "" + "" + "" + - "" + + "" + + "" + + "" + + "" + "" + "" + "" + - "" + - "" + - "" + - "" + - "" + - "" + + "" + "" + "" + "" + "" + - "" + + "" + "" + "" + "" + "" + - "" + + "" + "" + "" + ""; @@ -64,8 +73,8 @@ Attack.prototype.GetAttackStrengths = function() Attack.prototype.GetRange = function() { - var max = +this.template.Range; - var min = +(this.template.MinRange || 0); + var max = +this.template.MaxRange; + var min = +this.template.MinRange; return { "max": max, "min": min }; } diff --git a/binaries/data/mods/public/simulation/components/Builder.js b/binaries/data/mods/public/simulation/components/Builder.js index 9bd114fcee..800c20a08c 100644 --- a/binaries/data/mods/public/simulation/components/Builder.js +++ b/binaries/data/mods/public/simulation/components/Builder.js @@ -1,12 +1,18 @@ function Builder() {} Builder.prototype.Schema = - "" + - "tokens" + - "" + - "" + - "" + + "Allows the unit to construct and repair buildings." + + "" + + "1.0" + + "" + + "\n structures/{civ}_barracks\n structures/{civ}_civil_centre\n structures/celt_sb1\n " + + "" + + "" + + "" + "" + + "" + + "" + + "" + ""; Builder.prototype.Init = function() @@ -15,7 +21,7 @@ Builder.prototype.Init = function() Builder.prototype.GetEntitiesList = function() { - var string = this.template.Entities._string; + var string = this.template.Entities; // Replace the "{civ}" codes with this entity's civ ID var cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); diff --git a/binaries/data/mods/public/simulation/components/Cost.js b/binaries/data/mods/public/simulation/components/Cost.js index 93cc7f6bd7..6e9dcc1e0e 100644 --- a/binaries/data/mods/public/simulation/components/Cost.js +++ b/binaries/data/mods/public/simulation/components/Cost.js @@ -1,22 +1,34 @@ function Cost() {} Cost.prototype.Schema = + "Specifies the construction/training costs of this entity." + + "" + + "1" + + "15" + + "20.0" + + "" + + "50" + + "0" + + "0" + + "25" + + "" + + "" + "" + - "" + + "" + "" + "" + "" + "" + - "" + + "" + "" + "" + "" + "" + - "" + + "" + "" + "" + "" + - "" + + "" + "" + "" + "" + diff --git a/binaries/data/mods/public/simulation/components/Foundation.js b/binaries/data/mods/public/simulation/components/Foundation.js index d950c6b48d..c0a66d1f04 100644 --- a/binaries/data/mods/public/simulation/components/Foundation.js +++ b/binaries/data/mods/public/simulation/components/Foundation.js @@ -1,5 +1,8 @@ function Foundation() {} +Foundation.prototype.Schema = + ""; + Foundation.prototype.Init = function() { this.buildProgress = 0.0; // 0 <= progress <= 1 diff --git a/binaries/data/mods/public/simulation/components/GuiInterface.js b/binaries/data/mods/public/simulation/components/GuiInterface.js index 0ab028ff2b..f213f2a8c6 100644 --- a/binaries/data/mods/public/simulation/components/GuiInterface.js +++ b/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -1,5 +1,8 @@ function GuiInterface() {} +GuiInterface.prototype.Schema = + ""; + GuiInterface.prototype.Init = function() { // TODO: need to not serialise this value diff --git a/binaries/data/mods/public/simulation/components/Health.js b/binaries/data/mods/public/simulation/components/Health.js index 14e2a4497e..4c034883cf 100644 --- a/binaries/data/mods/public/simulation/components/Health.js +++ b/binaries/data/mods/public/simulation/components/Health.js @@ -1,24 +1,31 @@ function Health() {} Health.prototype.Schema = - "" + + "Deals with hitpoints and death." + + "" + + "100" + + "1.0" + + "corpse" + + "" + + "" + "" + "" + "" + - "" + + "" + "" + "" + "" + "" + - "" + + "" + "" + "" + "" + - "" + - "" + - "corpse" + - "" + - ""; + "" + + "" + + "vanish" + + "corpse" + + "" + + ""; Health.prototype.Init = function() { diff --git a/binaries/data/mods/public/simulation/components/Identity.js b/binaries/data/mods/public/simulation/components/Identity.js index f448a123eb..2475297bf2 100644 --- a/binaries/data/mods/public/simulation/components/Identity.js +++ b/binaries/data/mods/public/simulation/components/Identity.js @@ -1,23 +1,44 @@ function Identity() {} Identity.prototype.Schema = - "" + - "" + // TODO: ? + "Specifies various names and values associated with the unit type, typically for GUI display to users." + + "" + + "hele" + + "Infantry Spearman" + + "Hoplite" + + "3" + + "PortraitSheet" + + "" + + "" + + "" + + "gaia" + + "cart" + + "celt" + + "hele" + + "iber" + + "pers" + + "rome" + + "" + "" + - "" + + "" + "" + "" + "" + - "" + + "" + "" + "" + "" + - "" + - "" + - "" + - "" + - "" + - ""; + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + Identity.prototype.Init = function() { diff --git a/binaries/data/mods/public/simulation/components/MotionBall.js b/binaries/data/mods/public/simulation/components/MotionBall.js index e985b9d719..4eed7ae2ac 100644 --- a/binaries/data/mods/public/simulation/components/MotionBall.js +++ b/binaries/data/mods/public/simulation/components/MotionBall.js @@ -1,5 +1,8 @@ function MotionBallScripted() {} +MotionBallScripted.prototype.Schema = + ""; + MotionBallScripted.prototype.Init = function() { this.speedX = 0; this.speedZ = 0; diff --git a/binaries/data/mods/public/simulation/components/Player.js b/binaries/data/mods/public/simulation/components/Player.js index d4d41c7b4d..c6ca8342ca 100644 --- a/binaries/data/mods/public/simulation/components/Player.js +++ b/binaries/data/mods/public/simulation/components/Player.js @@ -1,5 +1,8 @@ function Player() {} +Player.prototype.Schema = + ""; + Player.prototype.Init = function() { this.playerID = undefined; diff --git a/binaries/data/mods/public/simulation/components/PlayerManager.js b/binaries/data/mods/public/simulation/components/PlayerManager.js index e76afdb858..6cff901f8f 100644 --- a/binaries/data/mods/public/simulation/components/PlayerManager.js +++ b/binaries/data/mods/public/simulation/components/PlayerManager.js @@ -1,5 +1,8 @@ function PlayerManager() {} +PlayerManager.prototype.Schema = + ""; + PlayerManager.prototype.Init = function() { this.playerEntities = []; // list of player entity IDs diff --git a/binaries/data/mods/public/simulation/components/ResourceGatherer.js b/binaries/data/mods/public/simulation/components/ResourceGatherer.js index 3af00175f8..84d0ea4b81 100644 --- a/binaries/data/mods/public/simulation/components/ResourceGatherer.js +++ b/binaries/data/mods/public/simulation/components/ResourceGatherer.js @@ -1,21 +1,31 @@ function ResourceGatherer() {} ResourceGatherer.prototype.Schema = - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + + "Lets the unit gather resources from entities that have the ResourceSupply component." + + "" + + "1.0" + + "" + + "1" + + "3" + + "3" + + "2" + + "" + + "" + + "" + + "" + "" + - "" + - "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + ""; ResourceGatherer.prototype.Init = function() diff --git a/binaries/data/mods/public/simulation/components/ResourceSupply.js b/binaries/data/mods/public/simulation/components/ResourceSupply.js index 21189c81f6..29900a64cf 100644 --- a/binaries/data/mods/public/simulation/components/ResourceSupply.js +++ b/binaries/data/mods/public/simulation/components/ResourceSupply.js @@ -1,34 +1,26 @@ function ResourceSupply() {} ResourceSupply.prototype.Schema = - "" + + "Provides a supply of one particular type of resource." + + "" + + "1000" + + "food.meat" + + "" + + "" + "" + "" + - "" + - "" + - "food" + - "fish" + - "" + - "" + - "food" + - "fruit" + - "" + - "" + - "food" + - "grain" + - "" + - "" + - "food" + - "meat" + - "" + - "" + - "food" + - "milk" + - "" + - "wood" + - "stone" + - "metal" + - ""; + "" + + "" + + "wood" + + "stone" + + "metal" + + "food.fish" + + "food.fruit" + + "food.grain" + + "food.meat" + + "food.milk" + + "" + + ""; ResourceSupply.prototype.Init = function() { @@ -54,7 +46,7 @@ ResourceSupply.prototype.TakeResources = function(rate) // difference between rounded values: var old = this.amount; - this.amount = Math.max(0, old - rate/1000); + this.amount = Math.max(0, old - rate); var change = Math.ceil(old) - Math.ceil(this.amount); // (use ceil instead of floor so that we continue returning non-zero values even if // 0 < amount < 1) @@ -63,10 +55,15 @@ ResourceSupply.prototype.TakeResources = function(rate) ResourceSupply.prototype.GetType = function() { - if (this.template.Subtype) - return { "generic": this.template.Type, "specific": this.template.Subtype }; - else + if (this.template.Type.indexOf('.') == -1) + { return { "generic": this.template.Type }; + } + else + { + var [type, subtype] = this.template.Type.split('.'); + return { "generic": type, "specific": subtype }; + } }; Engine.RegisterComponentType(IID_ResourceSupply, "ResourceSupply", ResourceSupply); diff --git a/binaries/data/mods/public/simulation/components/Sound.js b/binaries/data/mods/public/simulation/components/Sound.js index 2518b7fb45..f6e080eea4 100644 --- a/binaries/data/mods/public/simulation/components/Sound.js +++ b/binaries/data/mods/public/simulation/components/Sound.js @@ -1,8 +1,17 @@ function Sound() {} Sound.prototype.Schema = + "Lists the sound groups associated with this unit." + + "" + + "" + + "actor/human/movement/walk.xml" + + "actor/human/movement/walk.xml" + + "attack/weapon/sword.xml" + + "actor/human/death/death.xml" + + "" + + "" + "" + - "" + + "" + /* TODO: make this more specific, like a list of specific elements */ "" + "" + "" + diff --git a/binaries/data/mods/public/simulation/components/Timer.js b/binaries/data/mods/public/simulation/components/Timer.js index da23a4fa3e..f630fa46fa 100644 --- a/binaries/data/mods/public/simulation/components/Timer.js +++ b/binaries/data/mods/public/simulation/components/Timer.js @@ -1,5 +1,8 @@ function Timer() {} +Timer.prototype.Schema = + ""; + Timer.prototype.Init = function() { this.id = 0; diff --git a/binaries/data/mods/public/simulation/components/TrainingQueue.js b/binaries/data/mods/public/simulation/components/TrainingQueue.js index dce4fae74e..9df10cfdb5 100644 --- a/binaries/data/mods/public/simulation/components/TrainingQueue.js +++ b/binaries/data/mods/public/simulation/components/TrainingQueue.js @@ -3,8 +3,13 @@ var g_ProgressInterval = 1000; function TrainingQueue() {} TrainingQueue.prototype.Schema = - "" + - "tokens" + + "Allows the building to train new units." + + "" + + "" + + "\n units/{civ}_support_female_citizen\n units/{civ}_support_trader\n units/celt_infantry_spearman_b\n " + + "" + + "" + + "" + "" + ""; @@ -28,7 +33,7 @@ TrainingQueue.prototype.Init = function() TrainingQueue.prototype.GetEntitiesList = function() { - var string = this.template.Entities._string; + var string = this.template.Entities; // Replace the "{civ}" codes with this entity's civ ID var cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 2a9db9d0e7..1cf9ddcd90 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -34,6 +34,11 @@ const STATE_GATHERING = 4; function UnitAI() {} +UnitAI.prototype.Schema = + "Controls the unit's movement, attacks, etc, in response to commands from the player." + + "" + + ""; + UnitAI.prototype.Init = function() { this.state = STATE_IDLE; diff --git a/source/simulation2/components/CCmpCommandQueue.cpp b/source/simulation2/components/CCmpCommandQueue.cpp index 6b462c270b..fda174274f 100644 --- a/source/simulation2/components/CCmpCommandQueue.cpp +++ b/source/simulation2/components/CCmpCommandQueue.cpp @@ -41,6 +41,11 @@ public: std::vector m_CmdQueue; + static std::string GetSchema() + { + return ""; + } + virtual void Init(const CSimContext& context, const CParamNode& UNUSED(paramNode)) { m_Context = &context; diff --git a/source/simulation2/components/CCmpFootprint.cpp b/source/simulation2/components/CCmpFootprint.cpp index 491822709e..26b9ce843d 100644 --- a/source/simulation2/components/CCmpFootprint.cpp +++ b/source/simulation2/components/CCmpFootprint.cpp @@ -44,16 +44,32 @@ public: static std::string GetSchema() { return + "Approximation of the entity's shape, for collision detection and outline rendering. " + "Shapes are flat horizontal squares or circles, extended vertically to a given height." + "" + "" + "0.0" + "" + "" + "" + "0.0" + "" "" - "" - "" - "" + "" + "" + "" + "" + "" + "" + "" "" - "" - "" + "" + "" + "" + "" "" "" - "" + "" "" ""; } diff --git a/source/simulation2/components/CCmpMotionBall.cpp b/source/simulation2/components/CCmpMotionBall.cpp index d586bd4d91..4b4abd7955 100644 --- a/source/simulation2/components/CCmpMotionBall.cpp +++ b/source/simulation2/components/CCmpMotionBall.cpp @@ -38,6 +38,11 @@ public: // Current speed in metres per second float m_SpeedX, m_SpeedZ; + static std::string GetSchema() + { + return ""; + } + virtual void Init(const CSimContext& UNUSED(context), const CParamNode& UNUSED(paramNode)) { m_SpeedX = 0; diff --git a/source/simulation2/components/CCmpObstruction.cpp b/source/simulation2/components/CCmpObstruction.cpp index b5a1f3d5fb..2efd530e74 100644 --- a/source/simulation2/components/CCmpObstruction.cpp +++ b/source/simulation2/components/CCmpObstruction.cpp @@ -49,10 +49,15 @@ public: static std::string GetSchema() { return + "" + "Causes this entity's footprint to obstruct the motion of other units." "" - "" + "" + "" + "" ""; } + virtual void Init(const CSimContext& context, const CParamNode& paramNode) { m_Context = &context; diff --git a/source/simulation2/components/CCmpObstructionManager.cpp b/source/simulation2/components/CCmpObstructionManager.cpp index 2a1aa9e7dc..75da0b87c6 100644 --- a/source/simulation2/components/CCmpObstructionManager.cpp +++ b/source/simulation2/components/CCmpObstructionManager.cpp @@ -78,6 +78,11 @@ public: u32 m_CircleNext; // next allocated id u32 m_SquareNext; + static std::string GetSchema() + { + return ""; + } + virtual void Init(const CSimContext& context, const CParamNode& UNUSED(paramNode)) { m_DebugOverlayEnabled = false; diff --git a/source/simulation2/components/CCmpOwnership.cpp b/source/simulation2/components/CCmpOwnership.cpp index 10e9181c38..ae1436e8cf 100644 --- a/source/simulation2/components/CCmpOwnership.cpp +++ b/source/simulation2/components/CCmpOwnership.cpp @@ -39,6 +39,14 @@ public: int32_t m_Owner; + static std::string GetSchema() + { + return + "" + "Allows this entity to be owned by players." + ""; + } + virtual void Init(const CSimContext& context, const CParamNode& UNUSED(paramNode)) { m_Context = &context; diff --git a/source/simulation2/components/CCmpPathfinder.cpp b/source/simulation2/components/CCmpPathfinder.cpp index 8fa2791e28..66e0cd8b28 100644 --- a/source/simulation2/components/CCmpPathfinder.cpp +++ b/source/simulation2/components/CCmpPathfinder.cpp @@ -84,6 +84,11 @@ public: Path* m_DebugPath; PathfinderOverlay* m_DebugOverlay; + static std::string GetSchema() + { + return ""; + } + virtual void Init(const CSimContext& context, const CParamNode& UNUSED(paramNode)) { m_Context = &context; diff --git a/source/simulation2/components/CCmpPosition.cpp b/source/simulation2/components/CCmpPosition.cpp index 663f426cf8..7e24e1ded9 100644 --- a/source/simulation2/components/CCmpPosition.cpp +++ b/source/simulation2/components/CCmpPosition.cpp @@ -78,6 +78,12 @@ public: static std::string GetSchema() { return + "Allows this entity to exist at a location (and orientation) in the world, and defines some details of the positioning." + "" + "upright" + "0.0" + "false" + "" "" "" "upright" diff --git a/source/simulation2/components/CCmpProjectileManager.cpp b/source/simulation2/components/CCmpProjectileManager.cpp index 0ca7bc2b19..15fffa3931 100644 --- a/source/simulation2/components/CCmpProjectileManager.cpp +++ b/source/simulation2/components/CCmpProjectileManager.cpp @@ -45,6 +45,11 @@ public: DEFAULT_COMPONENT_ALLOCATOR(ProjectileManager) + static std::string GetSchema() + { + return ""; + } + virtual void Init(const CSimContext& context, const CParamNode& UNUSED(paramNode)) { m_Context = &context; diff --git a/source/simulation2/components/CCmpSelectable.cpp b/source/simulation2/components/CCmpSelectable.cpp index 778b45deb3..dee758563e 100644 --- a/source/simulation2/components/CCmpSelectable.cpp +++ b/source/simulation2/components/CCmpSelectable.cpp @@ -48,6 +48,14 @@ public: m_Overlay.m_Color = CColor(0, 0, 0, 0); } + static std::string GetSchema() + { + return + "Allows this entity to be selected by the player." + "" + ""; + } + virtual void Init(const CSimContext& UNUSED(context), const CParamNode& UNUSED(paramNode)) { } diff --git a/source/simulation2/components/CCmpSoundManager.cpp b/source/simulation2/components/CCmpSoundManager.cpp index 2a62376400..378f4899af 100644 --- a/source/simulation2/components/CCmpSoundManager.cpp +++ b/source/simulation2/components/CCmpSoundManager.cpp @@ -39,6 +39,11 @@ public: std::map m_SoundGroups; + static std::string GetSchema() + { + return ""; + } + virtual void Init(const CSimContext& context, const CParamNode& UNUSED(paramNode)) { m_Context = &context; diff --git a/source/simulation2/components/CCmpTemplateManager.cpp b/source/simulation2/components/CCmpTemplateManager.cpp index 45bbdcabf5..a89372aeb4 100644 --- a/source/simulation2/components/CCmpTemplateManager.cpp +++ b/source/simulation2/components/CCmpTemplateManager.cpp @@ -41,6 +41,11 @@ public: DEFAULT_COMPONENT_ALLOCATOR(TemplateManager) + static std::string GetSchema() + { + return ""; + } + virtual void Init(const CSimContext& context, const CParamNode& UNUSED(paramNode)) { m_Validator.LoadGrammar(context.GetComponentManager().GenerateSchema()); @@ -380,6 +385,7 @@ void CCmpTemplateManager::CopyPreviewSubset(CParamNode& out, const CParamNode& i out.CopyFilteredChildrenOfChild(in, "Entity", permittedComponentTypes); // Disable the Obstruction component (if there is one) so it doesn't affect pathfinding + // (but can still be used for testing this entity for collisions against others) if (out.GetChild("Entity").GetChild("Obstruction").IsOk()) CParamNode::LoadXMLString(out, ""); } diff --git a/source/simulation2/components/CCmpTerrain.cpp b/source/simulation2/components/CCmpTerrain.cpp index 703ec86033..1163797b45 100644 --- a/source/simulation2/components/CCmpTerrain.cpp +++ b/source/simulation2/components/CCmpTerrain.cpp @@ -33,6 +33,11 @@ public: CTerrain* m_Terrain; // not null + static std::string GetSchema() + { + return ""; + } + virtual void Init(const CSimContext& context, const CParamNode& UNUSED(paramNode)) { m_Terrain = &context.GetTerrain(); diff --git a/source/simulation2/components/CCmpTest.cpp b/source/simulation2/components/CCmpTest.cpp index 92ba50ffb9..18d927f73d 100644 --- a/source/simulation2/components/CCmpTest.cpp +++ b/source/simulation2/components/CCmpTest.cpp @@ -38,7 +38,7 @@ public: static std::string GetSchema() { - return ""; + return ""; } virtual void Init(const CSimContext&, const CParamNode& paramNode) @@ -100,6 +100,11 @@ public: int32_t m_x; + static std::string GetSchema() + { + return ""; + } + virtual void Init(const CSimContext&, const CParamNode&) { m_x = 12000; @@ -156,6 +161,11 @@ public: int32_t m_x; + static std::string GetSchema() + { + return ""; + } + virtual void Init(const CSimContext&, const CParamNode&) { m_x = 21000; diff --git a/source/simulation2/components/CCmpUnitMotion.cpp b/source/simulation2/components/CCmpUnitMotion.cpp index a19017239f..fd62a830f9 100644 --- a/source/simulation2/components/CCmpUnitMotion.cpp +++ b/source/simulation2/components/CCmpUnitMotion.cpp @@ -59,10 +59,15 @@ public: static std::string GetSchema() { return - "" + "Provides the unit with the ability to move around the world by itself." + "" + "7.0" + "" + "" "" ""; } + virtual void Init(const CSimContext& context, const CParamNode& paramNode) { m_Context = &context; diff --git a/source/simulation2/components/CCmpVisualActor.cpp b/source/simulation2/components/CCmpVisualActor.cpp index 5f49e876b9..d0ad5ce83f 100644 --- a/source/simulation2/components/CCmpVisualActor.cpp +++ b/source/simulation2/components/CCmpVisualActor.cpp @@ -63,13 +63,27 @@ public: static std::string GetSchema() { return + "Display the unit using the engine's actor system." + "" + "units/hellenes/infantry_spearman_b.xml" + "" + "" + "structures/hellenes/barracks.xml" + "structures/fndn_4x4.xml" + "" + "" + "" + "" "" - "" + "" + "" + "" "" "" - "" - "" - ""; + "" + "" + "" + ""; } virtual void Init(const CSimContext& context, const CParamNode& paramNode) diff --git a/source/simulation2/system/Component.h b/source/simulation2/system/Component.h index 831319a6ad..69e0120478 100644 --- a/source/simulation2/system/Component.h +++ b/source/simulation2/system/Component.h @@ -56,6 +56,10 @@ delete static_cast (cmp); \ } \ CCmp##cname(ScriptInterface& scriptInterface, jsval instance) : m_Script(scriptInterface, instance) { } \ + static std::string GetSchema() \ + { \ + return ""; \ + } \ virtual void Init(const CSimContext& context, const CParamNode& paramNode) \ { \ m_Script.Init(context, paramNode, GetEntityId()); \ diff --git a/source/simulation2/system/ComponentManager.cpp b/source/simulation2/system/ComponentManager.cpp index 07acd9a0fb..76a77a2c0b 100644 --- a/source/simulation2/system/ComponentManager.cpp +++ b/source/simulation2/system/ComponentManager.cpp @@ -754,6 +754,8 @@ std::string CComponentManager::GenerateSchema() std::map > interfaceComponentTypes; + std::vector componentTypes; + for (std::map::const_iterator it = m_ComponentTypesById.begin(); it != m_ComponentTypesById.end(); ++it) { schema += @@ -764,8 +766,10 @@ std::string CComponentManager::GenerateSchema() ""; interfaceComponentTypes[it->second.iid].push_back(it->second.name); + componentTypes.push_back(it->second.name); } + // Declare the implementation of each interface, for documentation for (std::map::const_iterator it = m_InterfaceIdsByName.begin(); it != m_InterfaceIdsByName.end(); ++it) { schema += ""; @@ -775,15 +779,18 @@ std::string CComponentManager::GenerateSchema() schema += ""; } + // List all the component types, in alphabetical order (to match the reordering performed by CParamNode). + // (We do it this way, rather than ing all the interface definitions (which would additionally perform + // a check that we don't use multiple component types of the same interface in one file), because libxml2 gives + // useless error messages in the latter case; this way lets it report the real error.) + std::sort(componentTypes.begin(), componentTypes.end()); schema += "" "" - "" - ""; - for (std::map::const_iterator it = m_InterfaceIdsByName.begin(); it != m_InterfaceIdsByName.end(); ++it) - schema += ""; + ""; + for (std::vector::const_iterator it = componentTypes.begin(); it != componentTypes.end(); ++it) + schema += ""; schema += - "" "" ""; diff --git a/source/tools/entdocs/build.sh b/source/tools/entdocs/build.sh new file mode 100644 index 0000000000..1ac2eee8a2 --- /dev/null +++ b/source/tools/entdocs/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +xsltproc convertrng.xsl ../../../binaries/system/entity.rng >entity-docs.html diff --git a/source/tools/entdocs/convertrng.xsl b/source/tools/entdocs/convertrng.xsl new file mode 100644 index 0000000000..5767146db7 --- /dev/null +++ b/source/tools/entdocs/convertrng.xsl @@ -0,0 +1,294 @@ + + + + + + + + + <!DOCTYPE html> + + + + 0 A.D. entity XML documentation + + + +

Entity component documentation

+

+ In 0 A.D., + entities (units and buildings and other world objects) + consist of a collection of components, each of which determines + part of the entity's behaviour. + Entity template XML files specify the list of components that are loaded for + each entity type, plus initialisation data for the components. +

+

+ This page lists the components that can be added to entities + and the XML syntax for their initialisation data. +

+

+ Available components: +

+ + Display RELAX NG grammar fragments + + + +
+ + + +
    + + + +
+
+ + + + + + + +
  • + +
      + +
    +
  • +
    +
    +
    + + + +
  • + + + #component. + + + + + +
  • +
    + + + + + + + + + + + +
    + + +

    + + +

    +
    + +

    Example

    +

    Examples

    + + + + + + + + +
    +

    RELAX NG Grammar

    +
    +        
    +      
    +
    +
    +
    + + + + +
    +    
    +      
    +        <
    +        
    +        />
    
    +      
    +      
    +        <
    +        
    +        >
    
    +        
    +          
    +        
    +        </
    +        
    +        >
    
    +      
    +    
    +  
    +
    + + + + + + + + +

    + +

    Optional.

    +
    + +

    .

    +
    + + +
    + + +

    + +

    .

    +
    + +
    + + + + + +

    Value is one of:

    +
    + +
    +
    + +
    + +
    .
    +
    +
    + + + +

    Required value: + +

    +
    + + + +

    Value type: text.

    +
    + + + +

    Value type: + + .

    +
    + + + +

    Value type: + + .

    +
    + + + + + + + non-negative decimal (e.g. 0.0 or 2.5) + positive decimal (e.g. 1.0 or 2.5) + decimal (e.g. -10.0 or 0.0 or 2.5) + non-negative integer (e.g. 0 or 5) + positive integer (e.g. 1 or 5) + boolean (true or false) + + + + + + + + + + + + 0 + + + < + + + + + /> + + + > + + + + + + + + + + + + + </ + + > + + + + + + + =" + + " + + + + + + + + + + + + + + + + + + + +
    + diff --git a/source/tools/entdocs/entity-docs.css b/source/tools/entdocs/entity-docs.css new file mode 100644 index 0000000000..1b4943d64d --- /dev/null +++ b/source/tools/entdocs/entity-docs.css @@ -0,0 +1,24 @@ +body { font-family: sans-serif; font-size: 10pt; } + +section { display: block; padding-bottom: 1em; border-top: 2px #aaa solid; } +p, dl, pre { margin-top: 0.2em; margin-bottom: 0.2em; } +h1, h2, h3 { margin-left: 0; } +h2, h3 { margin-top: 0.4em; margin-bottom: 0.2em; } +h1 { font-size: 2em; } +h2 { font-size: 1.8em; } +h3 { font-size: 1.2em; } + +p, dl { margin-left: 18px; } +dt { font-weight: bold; } +dd { margin-left: 1em; } + +pre.grammar, pre.example { font-size: 8pt; margin: 1em 2em 1em 2em; padding: 0.5em; } +pre.example { background-color: #ffd; } +pre.grammar { background-color: #f8f8f8; } +pre.example span.n { font-weight: bold; } + +code { color: orangered; } + +#show-grammar { margin-bottom: 1em; } +div.grammar-box { display: none; } +#show-grammar:checked ~ * div.grammar-box { display: inherit; } diff --git a/source/tools/entvalidate/entvalidate.pl b/source/tools/entvalidate/entvalidate.pl index c5bbada2a7..c2151765d5 100644 --- a/source/tools/entvalidate/entvalidate.pl +++ b/source/tools/entvalidate/entvalidate.pl @@ -148,17 +148,22 @@ sub check_all find({ wanted => $find_process }, "$vfsroot/public/simulation/templates"); find({ wanted => $find_process }, "$vfsroot/internal/simulation/templates") if -e "$vfsroot/internal"; + my $count = 0; + my $failed = 0; for my $f (sort @files) { next if $f =~ /^template_/; print "# $f...\n"; + ++$count; eval { validate($f); }; if ($@) { + ++$failed; print $@; eval { print to_xml(load_inherited($f)), "\n"; } } } + print "\nTotal: $count; failed: $failed\n"; } check_all();