rename GRAV back to PGRV, fix formatting in generator, remove useless file

This commit is contained in:
jacob1 2013-05-16 20:04:39 -04:00
parent fd97e923f3
commit 7b6ded50dc
13 changed files with 65 additions and 67 deletions

View File

@ -92,13 +92,13 @@ public:
virtual ~{0}(); virtual ~{0}();
{2} {2}
}}; }};
""".format(className, elementBase, string.join(classMembers, "\n\t")) """.format(className, elementBase, string.join(classMembers, "\n\t"))
elementHeader += """ elementHeader += """
std::vector<Element> GetElements(); std::vector<Element> GetElements();
#endif #endif
""" """
elementContent = """#include "ElementClasses.h" elementContent = """#include "ElementClasses.h"
@ -122,7 +122,7 @@ std::vector<Element> GetElements()
elementContent += """return elements; elementContent += """return elements;
} }
"""; """;
outputPath, outputFile = os.path.split(outputH) outputPath, outputFile = os.path.split(outputH)
if not os.path.exists(outputPath): if not os.path.exists(outputPath):
@ -140,11 +140,13 @@ def generateTools(toolFiles, outputCpp, outputH):
toolClasses = {} toolClasses = {}
toolHeader = """#ifndef TOOLCLASSES_H toolHeader = """#ifndef TOOLCLASSES_H
#define TOOLCLASSES_H #define TOOLCLASSES_H
#include <vector>
#include "simulation/Tools.h" #include <vector>
#include "simulation/tools/SimTool.h"
""" #include "simulation/tools/SimTool.h"
"""
directives = [] directives = []
@ -176,34 +178,36 @@ def generateTools(toolFiles, outputCpp, outputH):
toolClasses[d[1]].append(string.join(d[2:], " ")+";") toolClasses[d[1]].append(string.join(d[2:], " ")+";")
for className, classMembers in toolClasses.items(): for className, classMembers in toolClasses.items():
toolHeader += """class {0}: public SimTool toolHeader += """
{{ class {0}: public SimTool
public: {{
{0}(); public:
virtual ~{0}(); {0}();
virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength); virtual ~{0}();
{1} virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength);
}}; }};
""".format(className, string.join(classMembers, "\n")) """.format(className, string.join(classMembers, "\n"))
toolHeader += """std::vector<SimTool*> GetTools(); toolHeader += """
#endif std::vector<SimTool*> GetTools();
"""
#endif
"""
toolContent = """#include "ToolClasses.h" toolContent = """#include "ToolClasses.h"
std::vector<SimTool*> GetTools() std::vector<SimTool*> GetTools()
{ {
std::vector<SimTool*> tools; std::vector<SimTool*> tools;
"""; """;
toolIDs = sorted(classDirectives, key=lambda directive: directive[3]) toolIDs = sorted(classDirectives, key=lambda directive: directive[3])
for d in toolIDs: for d in toolIDs:
toolContent += """ tools.push_back(new %s()); toolContent += """ tools.push_back(new %s());
""" % (d[1]) """ % (d[1])
toolContent += """ return tools; toolContent += """ return tools;
} }
"""; """;
outputPath, outputFile = os.path.split(outputH) outputPath, outputFile = os.path.split(outputH)
if not os.path.exists(outputPath): if not os.path.exists(outputPath):

View File

@ -15,6 +15,7 @@
#include "gui/dialogues/TextPrompt.h" #include "gui/dialogues/TextPrompt.h"
#include "gui/dialogues/ConfirmPrompt.h" #include "gui/dialogues/ConfirmPrompt.h"
#include "simulation/Simulation.h" #include "simulation/Simulation.h"
#include "ToolClasses.h"
#include "gui/game/GameModel.h" #include "gui/game/GameModel.h"
#include "gui/game/Tool.h" #include "gui/game/Tool.h"
#include "LuaScriptHelper.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, MAX_TEMP); lua_setfield(l, simulationAPI, "MAX_TEMP");
lua_pushinteger(l, MIN_TEMP); lua_setfield(l, simulationAPI, "MIN_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, TOOL_HEAT); lua_setfield(l, simulationAPI, "TOOL_HEAT");
lua_pushinteger(l, 1); lua_setfield(l, simulationAPI, "TOOL_COOL"); lua_pushinteger(l, TOOL_COOL); lua_setfield(l, simulationAPI, "TOOL_COOL");
lua_pushinteger(l, 2); lua_setfield(l, simulationAPI, "TOOL_VAC"); lua_pushinteger(l, TOOL_VAC); lua_setfield(l, simulationAPI, "TOOL_VAC");
lua_pushinteger(l, 3); lua_setfield(l, simulationAPI, "TOOL_AIR"); lua_pushinteger(l, TOOL_AIR); lua_setfield(l, simulationAPI, "TOOL_AIR");
lua_pushinteger(l, 4); lua_setfield(l, simulationAPI, "TOOL_PGRV"); lua_pushinteger(l, TOOL_PGRV); lua_setfield(l, simulationAPI, "TOOL_PGRV");
lua_pushinteger(l, 5); lua_setfield(l, simulationAPI, "TOOL_NGRV"); 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_DRAW); lua_setfield(l, simulationAPI, "DECO_DRAW");
lua_pushinteger(l, DECO_CLEAR); lua_setfield(l, simulationAPI, "DECO_CLEAR"); lua_pushinteger(l, DECO_CLEAR); lua_setfield(l, simulationAPI, "DECO_CLEAR");
lua_pushinteger(l, DECO_ADD); lua_setfield(l, simulationAPI, "DECO_ADD"); lua_pushinteger(l, DECO_ADD); lua_setfield(l, simulationAPI, "DECO_ADD");

View File

@ -3,7 +3,7 @@
#include "GameView.h" #include "GameView.h"
#include "simulation/Simulation.h" #include "simulation/Simulation.h"
#include "simulation/Air.h" #include "simulation/Air.h"
#include "simulation/Tools.h" #include "ToolClasses.h"
#include "graphics/Renderer.h" #include "graphics/Renderer.h"
#include "gui/interface/Point.h" #include "gui/interface/Point.h"
#include "Brush.h" #include "Brush.h"

View File

@ -17,7 +17,7 @@
//#include "graphics/Renderer.h" //#include "graphics/Renderer.h"
//#include "graphics/Graphics.h" //#include "graphics/Graphics.h"
#include "Misc.h" #include "Misc.h"
#include "Tools.h" #include "ToolClasses.h"
#include "gui/game/Brush.h" #include "gui/game/Brush.h"
#include "client/GameSave.h" #include "client/GameSave.h"
#include "Sample.h" #include "Sample.h"

View File

@ -1,7 +0,0 @@
#ifndef TOOLS_H_
#define TOOLS_H_
#include "ToolClasses.h"
#endif

View File

@ -1,4 +1,4 @@
#include "simulation/Tools.h" #include "ToolClasses.h"
#include "simulation/Air.h" #include "simulation/Air.h"
//#TPT-Directive ToolClass Tool_Air TOOL_AIR 3 //#TPT-Directive ToolClass Tool_Air TOOL_AIR 3
Tool_Air::Tool_Air() Tool_Air::Tool_Air()

View File

@ -1,4 +1,4 @@
#include "simulation/Tools.h" #include "ToolClasses.h"
//#TPT-Directive ToolClass Tool_Cool TOOL_COOL 1 //#TPT-Directive ToolClass Tool_Cool TOOL_COOL 1
Tool_Cool::Tool_Cool() Tool_Cool::Tool_Cool()
{ {

View File

@ -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() {}

View File

@ -1,4 +1,4 @@
#include "simulation/Tools.h" #include "ToolClasses.h"
//#TPT-Directive ToolClass Tool_Heat TOOL_HEAT 0 //#TPT-Directive ToolClass Tool_Heat TOOL_HEAT 0
Tool_Heat::Tool_Heat() Tool_Heat::Tool_Heat()
{ {

View File

@ -1,4 +1,4 @@
#include "simulation/Tools.h" #include "ToolClasses.h"
#include "simulation/Simulation.h" #include "simulation/Simulation.h"
//#TPT-Directive ToolClass Tool_NGrv TOOL_NGRV 5 //#TPT-Directive ToolClass Tool_NGrv TOOL_NGRV 5
Tool_NGrv::Tool_NGrv() Tool_NGrv::Tool_NGrv()

View File

@ -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() {}

View File

@ -1,5 +1,5 @@
#include "simulation/Element.h" #include "simulation/Element.h"
#include "simulation/Tools.h" #include "ToolClasses.h"
SimTool::SimTool(): SimTool::SimTool():
Identifier("DEFAULT_TOOL_INVALID"), Identifier("DEFAULT_TOOL_INVALID"),

View File

@ -1,4 +1,4 @@
#include "simulation/Tools.h" #include "ToolClasses.h"
#include "simulation/Air.h" #include "simulation/Air.h"
//#TPT-Directive ToolClass Tool_Vac TOOL_VAC 2 //#TPT-Directive ToolClass Tool_Vac TOOL_VAC 2
Tool_Vac::Tool_Vac() Tool_Vac::Tool_Vac()
@ -6,7 +6,7 @@ Tool_Vac::Tool_Vac()
Identifier = "DEFAULT_TOOL_VAC"; Identifier = "DEFAULT_TOOL_VAC";
Name = "VAC"; Name = "VAC";
Colour = PIXPACK(0x303030); 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) int Tool_Vac::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength)