/
LuaScriptInterface.h
173 lines (153 loc) · 6.44 KB
/
LuaScriptInterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#ifndef LUASCRIPTINTERFACE_H_
#define LUASCRIPTINTERFACE_H_
#include "LuaCompat.h"
#include "CommandInterface.h"
#include "simulation/Simulation.h"
namespace ui
{
class Window;
}
class Tool;
//Because lua only has bindings for C, we're going to have to go outside "outside" the LuaScriptInterface, this means we can only have one instance :(
#define LOCAL_LUA_DIR "Lua"
#define LUACON_MDOWN 1
#define LUACON_MUP 2
#define LUACON_MPRESS 3
#define LUACON_KDOWN 1
#define LUACON_KUP 2
//Bitmasks for things that might need recalculating after changes to tpt.el
#define LUACON_EL_MODIFIED_CANMOVE 0x1
#define LUACON_EL_MODIFIED_GRAPHICS 0x2
#define LUACON_EL_MODIFIED_MENUS 0x4
// idea from mniip, makes things much simpler
#define SETCONST(L, NAME)\
lua_pushinteger(L, NAME);\
lua_setfield(L, -2, #NAME)
class TPTScriptInterface;
class LuaScriptInterface: public CommandInterface
{
int luacon_mousex, luacon_mousey, luacon_mousebutton, luacon_brushx, luacon_brushy;
std::string luacon_selectedl, luacon_selectedr, luacon_selectedalt, luacon_selectedreplace;
bool luacon_mousedown;
bool currentCommand;
TPTScriptInterface * legacy;
//Simulation
static StructProperty * particleProperties;
static int particlePropertiesCount;
//
void initSimulationAPI();
static void set_map(int x, int y, int width, int height, float value, int mapType);
static int simulation_partNeighbours(lua_State * l);
static int simulation_partChangeType(lua_State * l);
static int simulation_partCreate(lua_State * l);
static int simulation_partProperty(lua_State * l);
static int simulation_partPosition(lua_State * l);
static int simulation_partID(lua_State * l);
static int simulation_partKill(lua_State * l);
static int simulation_pressure(lua_State * l);
static int simulation_velocityX(lua_State * l);
static int simulation_velocityY(lua_State * l);
static int simulation_gravMap(lua_State * l);
static int simulation_ambientHeat(lua_State * l);
static int simulation_createParts(lua_State * l);
static int simulation_createLine(lua_State * l);
static int simulation_createBox(lua_State * l);
static int simulation_floodParts(lua_State * l);
static int simulation_createWalls(lua_State * l);
static int simulation_createWallLine(lua_State * l);
static int simulation_createWallBox(lua_State * l);
static int simulation_floodWalls(lua_State * l);
static int simulation_toolBrush(lua_State * l);
static int simulation_toolLine(lua_State * l);
static int simulation_toolBox(lua_State * l);
static int simulation_floodProp(lua_State * l);
static int simulation_decoBrush(lua_State * l);
static int simulation_decoLine(lua_State * l);
static int simulation_decoBox(lua_State * l);
static int simulation_decoColor(lua_State * l);
static int simulation_clearSim(lua_State * l);
static int simulation_resetTemp(lua_State * l);
static int simulation_resetPressure(lua_State * l);
static int simulation_saveStamp(lua_State * l);
static int simulation_loadStamp(lua_State * l);
static int simulation_deleteStamp(lua_State * l);
static int simulation_loadSave(lua_State * l);
static int simulation_reloadSave(lua_State * l);
static int simulation_getSaveID(lua_State * l);
static int simulation_adjustCoords(lua_State * l);
static int simulation_prettyPowders(lua_State * l);
static int simulation_gravityGrid(lua_State * l);
static int simulation_edgeMode(lua_State * l);
static int simulation_gravityMode(lua_State * l);
static int simulation_airMode(lua_State * l);
static int simulation_waterEqualisation(lua_State * l);
static int simulation_ambientAirTemp(lua_State * l);
static int simulation_elementCount(lua_State * l);
static int simulation_canMove(lua_State * l);
static int simulation_parts(lua_State * l);
static int simulation_pmap(lua_State * l);
static int simulation_photons(lua_State * l);
static int simulation_neighbours(lua_State * l);
//Renderer
void initRendererAPI();
static int renderer_renderModes(lua_State * l);
static int renderer_displayModes(lua_State * l);
static int renderer_colourMode(lua_State * l);
static int renderer_decorations(lua_State * l);
static int renderer_grid(lua_State * l);
static int renderer_debugHUD(lua_State * l);
//Elements
void initElementsAPI();
static int elements_allocate(lua_State * l);
static int elements_element(lua_State * l);
static int elements_property(lua_State * l);
static int elements_loadDefault(lua_State * l);
static int elements_free(lua_State * l);
//Interface
void initInterfaceAPI();
static int interface_showWindow(lua_State * l);
static int interface_closeWindow(lua_State * l);
static int interface_addComponent(lua_State * l);
static int interface_removeComponent(lua_State * l);
void initGraphicsAPI();
static int graphics_textSize(lua_State * l);
static int graphics_drawText(lua_State * l);
static int graphics_drawLine(lua_State * l);
static int graphics_drawRect(lua_State * l);
static int graphics_fillRect(lua_State * l);
static int graphics_drawCircle(lua_State * l);
static int graphics_fillCircle(lua_State * l);
static int graphics_getColors(lua_State * l);
static int graphics_getHexColor(lua_State * l);
void initFileSystemAPI();
static int fileSystem_list(lua_State * l);
static int fileSystem_exists(lua_State * l);
static int fileSystem_isFile(lua_State * l);
static int fileSystem_isDirectory(lua_State * l);
static int fileSystem_makeDirectory(lua_State * l);
static int fileSystem_removeDirectory(lua_State * l);
static int fileSystem_removeFile(lua_State * l);
static int fileSystem_move(lua_State * l);
static int fileSystem_copy(lua_State * l);
public:
int tpt_index(lua_State *l);
int tpt_newIndex(lua_State *l);
ui::Window * Window;
lua_State *l;
LuaScriptInterface(GameController * c, GameModel * m);
virtual bool OnBrushChanged(int brushType, int rx, int ry);
virtual bool OnActiveToolChanged(int toolSelection, Tool * tool);
virtual bool OnMouseMove(int x, int y, int dx, int dy);
virtual bool OnMouseDown(int x, int y, unsigned button);
virtual bool OnMouseUp(int x, int y, unsigned button);
virtual bool OnMouseWheel(int x, int y, int d);
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnTick();
virtual void Init();
virtual void SetWindow(ui::Window * window);
virtual int Command(std::string command);
virtual std::string FormatCommand(std::string command);
virtual ~LuaScriptInterface();
};
#endif /* LUASCRIPTINTERFACE_H_ */