-
Notifications
You must be signed in to change notification settings - Fork 4
/
rmapi.pas
273 lines (224 loc) · 6.64 KB
/
rmapi.pas
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
unit rmapi;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,Dialogs,rmxgfcore,mapcore, rmcodegen,rmcore,rmtools,rmthumb,gwbasic;
procedure rm_putpixel(x,y,color : integer);
function rm_getpixel(x,y : integer) : integer;
function rm_getwidth : integer;
function rm_getheight : integer;
procedure rm_showmessage(const aMsg : string);
function rm_cg_open(filename : string) : boolean;
procedure rm_cg_options(name, value : string);
procedure rm_cg_close;
procedure rm_cg_write(Line : string);
procedure rm_cg_writeln;
procedure rm_cg_write_byte(value : byte);
procedure rm_cg_write_integer(value : integer);
procedure rm_getselectarea(var active,x1,y1,x2,y2 : integer);
function rm_getmaxcolor : integer;
procedure rm_getcolorrgb(index : integer;var r,g,b : byte);
procedure rm_setcolorrgb(index : integer; r,g,b : byte);
procedure rm_SetPaletteMode(mode : integer);
function rm_GetPaletteMode : integer;
implementation
var
cg : CodeGenRec;
cgfile : text;
procedure rm_putpixel(x,y,color : integer);
begin
putpixel(x,y,color);
end;
function rm_getpixel(x,y : integer) : integer;
begin
rm_getpixel:=getpixel(x,y);
end;
function rm_getwidth : integer;
begin
rm_getwidth:=GetWidth;
end;
function rm_getheight : integer;
begin
rm_getheight:=GetHeight;
end;
function rm_getmaxcolor : integer;
begin
rm_getmaxcolor:=GetMaxColor;
end;
procedure rm_getcolorrgb(index : integer;var r,g,b : byte);
begin
GetColorRGB(index,r,g,b);
end;
procedure rm_setcolorrgb(index : integer; r,g,b : byte);
begin
SetColorRGB(index,r,g,b);
end;
function rm_cg_open(filename : string) : boolean;
begin
Assign(cgfile,filename);
{$I-}
Rewrite(cgfile);
{$I+}
if IORESULT = 0 then
begin
MWInit(cg,cgfile);
rm_cg_open:=true;
end
else
begin
rm_cg_open:=false;
end;
end;
procedure rm_cg_close;
begin
close(cgfile);
end;
procedure rm_cg_options(name, value : string);
begin
name:=UpperCase(name);
value:=UpperCase(value);
Case Name of 'LAN':begin
Case value of 'BASICLAN': MWSetLan(cg,BasicLan);
'BASICLNLAN': MWSetLan(cg,BasicLnLan);
'PASCALLAN': MWSetLan(cg,PascalLan);
'CLAN': MWSetLan(cg,CLan);
else
begin
try
MWSetLan(cg,StrToInt(value));
except
MWSetLan(cg,PascalLan);
end;
end;
end;
end;
'VALUESPERLINE':begin
try
MWSetValuesPerLine(cg,StrToInt(value));
except
MWSetValuesPerLine(cg,20);
end;
end;
'VALUESTOTAL':begin
try
MWSetValuesTotal(cg,StrToInt(value));
except
MWSetValuesTotal(cg,0);
end;
end;
'VALUEFORMAT': begin
Case value of 'HEX': MWSetValueFormat(cg,ValueFormatHex);
'DECIMAL': MWSetValueFormat(cg,ValueFormatDecimal);
end;
end;
'INDENT': begin
try
MWSetIndent(cg,StrToInt(value));
except
MWSetIndent(cg,10);
end;
end;
'INDENTONFIRSTLINE': MWSetIndentOnFirstLine(cg,Value='YES');
'LINENUMBERSTART':begin
try
SetGWStartLineNumber(StrToInt(value))
except
SetGWStartLineNumber(1000)
end;
end;
end;
end;
procedure rm_cg_write(Line : string);
begin
write(cgfile,line);
end;
procedure rm_cg_writeln;
begin
writeln(cgfile);
end;
procedure rm_cg_write_byte(value : byte);
begin
MWWriteByte(cg,value);
end;
procedure rm_cg_write_integer(value : integer);
begin
MWWriteInteger(cg,value);
end;
procedure rm_getselectarea(var active,x1,y1,x2,y2 : integer);
var
ca : TClipAreaRec;
begin
active:=0;
x1:=0;
x2:=0;
y1:=0;
y2:=0;
RMDrawTools.GetClipAreaCoords(ca);
if (ca.sized=1) and (RMDrawTools.GetClipStatus=1) then
begin
active:=1;
x1:=ca.x;
x2:=ca.x2;
y1:=ca.y;
y2:=ca.y2;
end;
end;
function rm_getmapwidth : integer;
begin
rm_getmapwidth:=MapCoreBase.GetMapWidth(MapCoreBase.GetCurrentMap);
end;
function rm_getmapheight(index : integer) : integer;
begin
rm_getmapheight:=MapCoreBase.GetMapHeight(MapCoreBase.GetCurrentMap);
end;
function rm_gettilewidth : integer;
begin
rm_gettilewidth:=MapCoreBase.GetMapTileWidth(MapCoreBase.GetCurrentMap);
end;
function rm_gettileheight(index : integer) : integer;
begin
rm_gettileheight:=MapCoreBase.GetMapTileHeight(MapCoreBase.GetCurrentMap);
end;
function rm_gettileproperty(x,y : integer;tilepropertyname : string) : string;
var
Tile : TileRec;
begin
if UpperCase(tilepropertyname) = 'IMAGEINDEX' then
begin
MapCoreBase.GetMapTile(MapCoreBase.GetCurrentMap,x,y,Tile);
rm_gettileproperty:=IntToStr(Tile.ImageIndex);
end
else
begin
rm_gettileproperty:='';
end;
end;
procedure rm_settileproperty(x,y : integer;tilepropertyname,value : string);
var
Tile : TileRec;
begin
if UpperCase(tilepropertyname) = 'IMAGEINDEX' then
begin
MapCoreBase.GetMapTile(MapCoreBase.GetCurrentMap,x,y,Tile);
try
Tile.ImageIndex :=StrToInt(value);
except
Tile.ImageIndex :=-1;
end;
if Tile.ImageIndex > -1 then Tile.ImageUID :=ImageThumbBase.GetUID(Tile.ImageIndex); //fetch the GUID
MapCoreBase.SetMapTile(MapCoreBase.GetCurrentMap,x,y,Tile);
end;
end;
procedure rm_showmessage(const aMsg : string);
begin
showmessage(aMsg);
end;
procedure rm_SetPaletteMode(mode : integer);
begin
SetPaletteMode(mode);
end;
function rm_GetPaletteMode : integer;
begin
rm_GetPaletteMode:=GetPaletteMode;
end;
end.