-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRIP.CPP
More file actions
408 lines (323 loc) · 7.8 KB
/
RIP.CPP
File metadata and controls
408 lines (323 loc) · 7.8 KB
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
#include <string.h>
#include <tswin.hpp>
#include "proboard.hpp"
const int MAX_ICONS = 200;
static Window rip_window;
static void
open_sending_rip()
{
tsw_cursoroff();
rip_window.open(tsw_hsize/2-15 , tsw_vsize/2 - 1 , tsw_hsize/2+15 , tsw_vsize/2 + 1 , 0x1F , 0);
tsw_centerline(tsw_vsize/2,"SENDING RIP SEQUENCE",0x9E);
}
static void
close_sending_rip()
{
rip_window.close();
tsw_cursoron();
}
String
meganum( word num )
{
int n[2];
char s[3] = "00";
n[0] = num / 36;
n[1] = num % 36;
for(int i = 0 ; i < 2 ; i++)
{
if(n[i] < 10)
s[i] = '0' + n[i];
else
s[i] = 'A' + n[i] - 10;
}
return String(s);
}
void
rip_text_window( int x0, int y0 , int x1 , int y1 , int font )
{
if(rip_mode)
{
io.show_local = FALSE;
String s;
s << "\r!|w" << meganum(x0)
<< meganum(y0)
<< meganum(x1)
<< meganum(y1)
<< '1'
<< char(font + '0')
<< '\n';
io << s << char(0xFF);
io.show_local = TRUE;
}
}
void
rip_reset()
{
if(rip_mode) rip_send("\r!|1K|*\n");
}
bool
show_rip( char *ripfile , bool reset )
{
if(!rip_mode) return FALSE;
FileName fn(cfg.RIPpath,ripfile);
fn.changeExt("RIP");
if(reset) rip_reset();
open_sending_rip();
io.show_local = FALSE;
io << '\r';
char k = io.sendfile(fn , NULL);
io.show_local = TRUE;
close_sending_rip();
return (k != ANS_NOFILE);
}
void
rip_send( char *s )
{
if(!rip_mode) return;
open_sending_rip();
io.show_local = FALSE;
io << s << char(0xFF);
io.show_local = TRUE;
close_sending_rip();
}
bool
rip_icon_exists( char *fn )
{
String cmd = "\r!|1F010000";
cmd << fn << "\n";
rip_send(cmd);
String response;
dword ticks = clockticks();
while(clockdiff(ticks)<30)
{
char k = io.readkey();
if(k)
{
if(k == '\r')
{
if(response == "0")
{
return FALSE;
}
if(response == "1")
{
return TRUE;
}
}
if(k == '\n') continue;
response << k;
}
}
return FALSE;
}
void
rip_send_icons()
{
if(rip_mode)
{
FileName fn(cfg.iconspath,"*.IC?");
String *icons = new String[MAX_ICONS];
DirScan dir(fn);
for(int i = 0 ; int(dir) && i<MAX_ICONS ; )
{
if(!rip_icon_exists(dir))
{
icons[i++] = (char *)dir;
}
dir++;
}
fn(cfg.iconspath,"*.HI?");
dir.first(fn);
for(; int(dir) && i<MAX_ICONS; )
{
if(!rip_icon_exists(dir))
{
icons[i++] = (char *)dir;
}
dir++;
}
if(i)
{
fn(mypath,"RIPICONS.$$$");
File f(fn,fmode_text | fmode_create);
for( i-- ; i>=0 ; i--)
{
f << cfg.iconspath << (char *)icons[i] << '\n';
}
f.close();
rip_send("\r!|907020000<>\n");
download(form("/F=@%s /K=Z /I /Q /N /T",(char *)fn));
}
}
}
void
rip_query( char *cmd )
{
rip_send(form("\r!|10000%s\n" , cmd));
}
void
rip_color( int color )
{
rip_send(form("\r!|c%02X\n",color));
}
void
rip_fill_color( int pattern , int color)
{
rip_send(form("\r!|S%02X%02X\n",pattern,color));
}
void
rip_bar( int x1 , int y1 , int x2 , int y2 )
{
String cmd = "\r!|B";
cmd << meganum(x1)
<< meganum(y1)
<< meganum(x2)
<< meganum(y2)
<< '\n';
rip_send(cmd);
}
void
rip_kill_mouse_fields()
{
rip_send("\r!|1K\n");
}
void
rip_nomore()
{
rip_send("\r!|#|#|#\n");
}
void
rip_get_image( int x1,int y1,int x2,int y2 )
{
String cmd = "\r!|1C";
cmd << meganum(x1)
<< meganum(y1)
<< meganum(x2)
<< meganum(y2)
<< "0\n";
rip_send(cmd);
}
void
rip_put_image( int x,int y )
{
String cmd = "\r!|1P";
cmd << meganum(x)
<< meganum(y)
<< "000\n";
rip_send(cmd);
}
void
rip_button(int x1,int y1,int x2,int y2,int hotkey,bool def,char *icon,char *text,char *hostcmd)
{
String cmd = "\r!|1U";
cmd << meganum(x1)
<< meganum(y1)
<< meganum(x2)
<< meganum(y2)
<< meganum(hotkey)
<< meganum(def ? 2:0)
<< '0'
<< icon << "<>" << text << "<>" << hostcmd
<< '\n';
rip_send(cmd);
}
void
rip_start_dialog( char *prompt, int max )
{
int width = max;
if(strlen(prompt) > width) width = strlen(prompt);
int offset = width/2 + width%2;
rip_save_textwindow();
rip_get_image(297-offset*8, 50 , 342+offset*8, 108 );
rip_send("\r!|Y00000100|1B0000020PVK030F000F080700000F07000000\n");
rip_button(300-offset*8,53,339+offset*8,105,0,FALSE,"","","");
rip_send("\r!|1B0000020PHK030F000F080700000F07000000\n");
rip_button(310-offset*8,56,329+offset*8,75,0,FALSE,"",prompt,"");
offset = max/2+max%2;
rip_text_window(40-offset,11,39+offset,11,0);
rip_send("\r!|1B00000200LC030B00080F0100080F07000000\n");
rip_button(310-offset*8,87,329+offset*8,98,0,FALSE,"","","");
rip_nomore();
io.show_local = FALSE;
io.color(6);
io.show_local = TRUE;
}
void
rip_end_dialog()
{
rip_paste_clipboard();
rip_restore_textwindow();
}
void
rip_start_yesno_dialog( char *prompt , bool def)
{
int width = 30;
if(strlen(prompt) > width) width = strlen(prompt);
int offset = width/2 + width%2;
rip_save_textwindow();
rip_get_image(297-offset*8, 50 , 358+offset*8, 125 );
rip_send("\r!|Y00000100|1B0000020PVK030F000F080700000F07000000\n");
rip_button(300-offset*8,53,339+offset*8,120,0,FALSE,"","","");
rip_send("\r!|1B0000020PHK030F000F080700000F07000000\n");
rip_button(310-offset*8,56,329+offset*8,75,0,FALSE,"",prompt,"");
rip_send("\r!|1B0000020SAI030E000F080700020F07000000\n");
rip_text_window(0,0,0,0,0);
rip_button(250,85,310,108,'Y',def ,"","Yes","Y");
rip_button(329,85,389,108,'N',!def,"","No" ,"N");
rip_nomore();
}
void
rip_textmode()
{
if(user.screenLength == 38) user.screenLength = 23;
if(rip_mode)
{
if(user.ripFont)
{
rip_screenlines = 22;
rip_text_window(0,0,79,21,2);
}
else
{
rip_screenlines = 38;
rip_text_window(0,0,79,37,0);
}
rip_send("\r!|Y00000100\n"
"!|1B0000020074030F000F080F00000F07000000|1U018OHR9A0000<><>\n"
"!|1B0000020PHC030F000F080700000F07000000|1U028PHR9A0000<><>\n"
"!|#|#|#\n");
rip_show_enter();
}
}
void
rip_clear_status()
{
rip_fill_color(1,7);
rip_color(7);
rip_bar(3,315,637,332);
rip_kill_mouse_fields();
}
void
rip_show_enter()
{
rip_send("\r!|1B0000020QOY030F000B080300000E07000000|1UF58THN960000<>Enter<>^m\n!|#|#|#\n");
}
void
rip_show_more()
{
rip_send(
"\r!|1B0000020QOY020F000B080100020E07000000\n"
"!|1U2T8T47962H00<>Yes<>Y|1U4H8T5V962600<>No<>N|1U658T8N961V00<>Continuous<>C\n"
"!|1B0000020PI8020B000F080700000E07000000|1U0B8S2J970000<>More?<>|#|#|#\n"
);
}
void
rip_show_more_tag()
{
rip_send(
"\r!|1B0000020QOY020F000B080100020E07000000\n"
"!|1U2T8T47962H00<>Yes<>Y|1U4H8T5V962600<>No<>N|1U658T8N961V00<>Continuous<>C\n"
"!|1UAK8TDC961X00<>Edit Tagged<>E|1U8W8TAA962C00<>Tag<>T\n"
"!|1B0000020PI8020B000F080700000E07000000|1U0B8S2J970000<>More?<>|#|#|#\n"
);
}