diff --git a/generator.py b/generator.py index 952b6fa60..30a4c2322 100644 --- a/generator.py +++ b/generator.py @@ -92,13 +92,13 @@ public: virtual ~{0}(); {2} }}; - """.format(className, elementBase, string.join(classMembers, "\n\t")) +""".format(className, elementBase, string.join(classMembers, "\n\t")) elementHeader += """ std::vector GetElements(); #endif - """ +""" elementContent = """#include "ElementClasses.h" @@ -122,7 +122,7 @@ std::vector GetElements() elementContent += """return elements; } - """; +"""; outputPath, outputFile = os.path.split(outputH) if not os.path.exists(outputPath): @@ -140,11 +140,13 @@ def generateTools(toolFiles, outputCpp, outputH): toolClasses = {} toolHeader = """#ifndef TOOLCLASSES_H - #define TOOLCLASSES_H - #include - #include "simulation/Tools.h" - #include "simulation/tools/SimTool.h" - """ +#define TOOLCLASSES_H + +#include + +#include "simulation/tools/SimTool.h" + +""" directives = [] @@ -176,34 +178,36 @@ def generateTools(toolFiles, outputCpp, outputH): toolClasses[d[1]].append(string.join(d[2:], " ")+";") for className, classMembers in toolClasses.items(): - toolHeader += """class {0}: public SimTool - {{ - public: - {0}(); - virtual ~{0}(); - virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength); - {1} - }}; - """.format(className, string.join(classMembers, "\n")) + toolHeader += """ +class {0}: public SimTool +{{ +public: + {0}(); + virtual ~{0}(); + virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength); +}}; +""".format(className, string.join(classMembers, "\n")) - toolHeader += """std::vector GetTools(); - #endif - """ + toolHeader += """ +std::vector GetTools(); + +#endif +""" toolContent = """#include "ToolClasses.h" - std::vector GetTools() - { - std::vector tools; - """; +std::vector GetTools() +{ + std::vector tools; +"""; toolIDs = sorted(classDirectives, key=lambda directive: directive[3]) for d in toolIDs: toolContent += """ tools.push_back(new %s()); - """ % (d[1]) +""" % (d[1]) toolContent += """ return tools; - } - """; +} +"""; outputPath, outputFile = os.path.split(outputH) if not os.path.exists(outputPath): diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index f25763678..8cb01ee32 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -15,6 +15,7 @@ #include "gui/dialogues/TextPrompt.h" #include "gui/dialogues/ConfirmPrompt.h" #include "simulation/Simulation.h" +#include "ToolClasses.h" #include "gui/game/GameModel.h" #include "gui/game/Tool.h" #include "LuaScriptHelper.h" @@ -482,12 +483,12 @@ void LuaScriptInterface::initSimulationAPI() lua_pushinteger(l, MAX_TEMP); lua_setfield(l, simulationAPI, "MAX_TEMP"); lua_pushinteger(l, MIN_TEMP); lua_setfield(l, simulationAPI, "MIN_TEMP"); - lua_pushinteger(l, 0); lua_setfield(l, simulationAPI, "TOOL_HEAT"); - lua_pushinteger(l, 1); lua_setfield(l, simulationAPI, "TOOL_COOL"); - lua_pushinteger(l, 2); lua_setfield(l, simulationAPI, "TOOL_VAC"); - lua_pushinteger(l, 3); lua_setfield(l, simulationAPI, "TOOL_AIR"); - lua_pushinteger(l, 4); lua_setfield(l, simulationAPI, "TOOL_PGRV"); - lua_pushinteger(l, 5); lua_setfield(l, simulationAPI, "TOOL_NGRV"); + lua_pushinteger(l, TOOL_HEAT); lua_setfield(l, simulationAPI, "TOOL_HEAT"); + lua_pushinteger(l, TOOL_COOL); lua_setfield(l, simulationAPI, "TOOL_COOL"); + lua_pushinteger(l, TOOL_VAC); lua_setfield(l, simulationAPI, "TOOL_VAC"); + lua_pushinteger(l, TOOL_AIR); lua_setfield(l, simulationAPI, "TOOL_AIR"); + lua_pushinteger(l, TOOL_PGRV); lua_setfield(l, simulationAPI, "TOOL_PGRV"); + lua_pushinteger(l, TOOL_NGRV); lua_setfield(l, simulationAPI, "TOOL_NGRV"); lua_pushinteger(l, DECO_DRAW); lua_setfield(l, simulationAPI, "DECO_DRAW"); lua_pushinteger(l, DECO_CLEAR); lua_setfield(l, simulationAPI, "DECO_CLEAR"); lua_pushinteger(l, DECO_ADD); lua_setfield(l, simulationAPI, "DECO_ADD"); diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index b57a7cb9a..59250791d 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -3,7 +3,7 @@ #include "GameView.h" #include "simulation/Simulation.h" #include "simulation/Air.h" -#include "simulation/Tools.h" +#include "ToolClasses.h" #include "graphics/Renderer.h" #include "gui/interface/Point.h" #include "Brush.h" diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 42890162b..4c1a54323 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -17,7 +17,7 @@ //#include "graphics/Renderer.h" //#include "graphics/Graphics.h" #include "Misc.h" -#include "Tools.h" +#include "ToolClasses.h" #include "gui/game/Brush.h" #include "client/GameSave.h" #include "Sample.h" diff --git a/src/simulation/Tools.h b/src/simulation/Tools.h deleted file mode 100644 index 525701e67..000000000 --- a/src/simulation/Tools.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef TOOLS_H_ -#define TOOLS_H_ - -#include "ToolClasses.h" - - -#endif diff --git a/src/simulation/tools/AirTool.cpp b/src/simulation/tools/AirTool.cpp index 23120a024..4e7ebde5a 100644 --- a/src/simulation/tools/AirTool.cpp +++ b/src/simulation/tools/AirTool.cpp @@ -1,4 +1,4 @@ -#include "simulation/Tools.h" +#include "ToolClasses.h" #include "simulation/Air.h" //#TPT-Directive ToolClass Tool_Air TOOL_AIR 3 Tool_Air::Tool_Air() diff --git a/src/simulation/tools/Cool.cpp b/src/simulation/tools/Cool.cpp index 07c24f95b..bc4963432 100644 --- a/src/simulation/tools/Cool.cpp +++ b/src/simulation/tools/Cool.cpp @@ -1,4 +1,4 @@ -#include "simulation/Tools.h" +#include "ToolClasses.h" //#TPT-Directive ToolClass Tool_Cool TOOL_COOL 1 Tool_Cool::Tool_Cool() { diff --git a/src/simulation/tools/GravTool.cpp b/src/simulation/tools/GravTool.cpp deleted file mode 100644 index 3ff30bd7c..000000000 --- a/src/simulation/tools/GravTool.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "simulation/Tools.h" -#include "simulation/Simulation.h" -//#TPT-Directive ToolClass Tool_Grav TOOL_GRAV 4 -Tool_Grav::Tool_Grav() -{ - Identifier = "DEFAULT_TOOL_GRAV"; - Name = "GRAV"; - Colour = PIXPACK(0xCCCCFF); - Description = "Creates a short-lasting gravity well"; -} - -int Tool_Grav::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) -{ - sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] += 0.03f*strength; - return 1; -} - -Tool_Grav::~Tool_Grav() {} diff --git a/src/simulation/tools/Heat.cpp b/src/simulation/tools/Heat.cpp index 2d6510c74..903efe31b 100644 --- a/src/simulation/tools/Heat.cpp +++ b/src/simulation/tools/Heat.cpp @@ -1,4 +1,4 @@ -#include "simulation/Tools.h" +#include "ToolClasses.h" //#TPT-Directive ToolClass Tool_Heat TOOL_HEAT 0 Tool_Heat::Tool_Heat() { diff --git a/src/simulation/tools/NGrv.cpp b/src/simulation/tools/NGrv.cpp index 5e339e63a..65530c58f 100644 --- a/src/simulation/tools/NGrv.cpp +++ b/src/simulation/tools/NGrv.cpp @@ -1,4 +1,4 @@ -#include "simulation/Tools.h" +#include "ToolClasses.h" #include "simulation/Simulation.h" //#TPT-Directive ToolClass Tool_NGrv TOOL_NGRV 5 Tool_NGrv::Tool_NGrv() diff --git a/src/simulation/tools/PGrv.cpp b/src/simulation/tools/PGrv.cpp new file mode 100644 index 000000000..cfa381c06 --- /dev/null +++ b/src/simulation/tools/PGrv.cpp @@ -0,0 +1,18 @@ +#include "ToolClasses.h" +#include "simulation/Simulation.h" +//#TPT-Directive ToolClass Tool_PGrv TOOL_PGRV 4 +Tool_PGrv::Tool_PGrv() +{ + Identifier = "DEFAULT_TOOL_PGRV"; + Name = "PGRV"; + Colour = PIXPACK(0xCCCCFF); + Description = "Creates a short-lasting gravity well"; +} + +int Tool_PGrv::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) +{ + sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] += 0.03f*strength; + return 1; +} + +Tool_PGrv::~Tool_PGrv() {} diff --git a/src/simulation/tools/SimTool.cpp b/src/simulation/tools/SimTool.cpp index 4b3ddeb20..0fdec2b54 100644 --- a/src/simulation/tools/SimTool.cpp +++ b/src/simulation/tools/SimTool.cpp @@ -1,5 +1,5 @@ #include "simulation/Element.h" -#include "simulation/Tools.h" +#include "ToolClasses.h" SimTool::SimTool(): Identifier("DEFAULT_TOOL_INVALID"), diff --git a/src/simulation/tools/Vac.cpp b/src/simulation/tools/Vac.cpp index aa319e2c6..fbf7e85c8 100644 --- a/src/simulation/tools/Vac.cpp +++ b/src/simulation/tools/Vac.cpp @@ -1,4 +1,4 @@ -#include "simulation/Tools.h" +#include "ToolClasses.h" #include "simulation/Air.h" //#TPT-Directive ToolClass Tool_Vac TOOL_VAC 2 Tool_Vac::Tool_Vac() @@ -6,7 +6,7 @@ Tool_Vac::Tool_Vac() Identifier = "DEFAULT_TOOL_VAC"; Name = "VAC"; Colour = PIXPACK(0x303030); - Description = "Removes air pressure"; + Description = "Reduces air pressure"; } int Tool_Vac::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength)