[go: up one dir, main page]

Menu

[r87]: / engine / gui / bigmap.cpp  Maximize  Restore  History

Download this file

657 lines (545 with data), 13.0 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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
/*
* - Large view of the world
*/
#include <stdio.h>
#include "igui.hpp"
#include "../ithelib.h"
#include "../console.h"
#include "../core.hpp"
#include "../gamedata.h"
#include "../object.hpp"
#include "../oscli.h"
#include "../init.h"
#include "menusys.h"
// defines
//#define PATHBUILDER
#define MAX_PATH_SQUARES 4096
#define MicroX 512
#define MicroY 288
// variables
static int pmx=0,pmy=0,path1x=0,path1y=0;
static int BrushMode=0,ShowSolid=0,ShowEggs=0,ShowRoof=0;
static int CN_Id,CS_Id,CE_Id,CW_Id,BR_Id;
static char ConnNstr[]="None ";
static char ConnSstr[]="None ";
static char ConnWstr[]="None ";
static char ConnEstr[]="None ";
static char *Brushes[]= {
"No editing ",
"1x1 brush ",
"2x2 brush ",
"4x4 brush ",
"8x8 brush ",
"32x32 brush ",
"Spraycan ",
"Roof 8x8 ",
"Roof 32x32 ",
NULL,
};
static int BrushType[]={0,1,2,4,8,32,-1,-8,-32}; // MUST MATCH Brushes[]
extern int focus,BM_Id;
extern int L_bgtile,L_rooftile;
//static int PathMode=0;
extern long M_core; // Total amount of core, from memory.cc
extern int s_proj; // Flag, are sprites being displayed?
extern int l_proj; // Flag, are layers being displayed?
// functions
extern void WriteRoof(int x,int y,int tile);
extern int ReadRoof(int x,int y);
extern int ReadMap(int x,int y);
extern void WriteMap(int x,int y, int tile);
extern void Toolbar();
extern void (*EdUpdateFunc)(void);
extern void DrawMap(int x,int y,char s_proj,char l_proj,char f_proj);
static void OneToOne();
static void PanMap();
static void PanUp();
static void PanDown();
static void PanLeft();
static void PanRight();
static void SetL();
static void Spray();
static void SetRoofL(int WIDF);
static void GoMap();
static void GetBrush();
static void Nothing();
static void Connections();
static void Connections_Update();
static void ConnN();
static void ConnS();
static void ConnE();
static void ConnW();
static void Finish();
#ifdef PATHBUILDER
static void PathMaker();
#endif
extern void PathMe();
// GoFocal - The menu tab function. This is called from the toolbar
void BM_GoFocal()
{
int temp; // Used to get button handles
if(focus==4) // Make sure we don't redraw if the user clicks again
return;
focus=4; // This is now the focus
Toolbar(); // Build up the menu system again from scratch
IG_SetFocus(BM_Id); // And make the button stick inwards
// Add Panning buttons
IG_TextButton(516,104,__up,PanUp,NULL,NULL); // Pan up button
IG_TextButton(500,128,__left,PanLeft,NULL,NULL); // Pan left button
IG_TextButton(532,128,__right,PanRight,NULL,NULL); // Pan right button
IG_TextButton(516,150,__down,PanDown,NULL,NULL); // Pan down button
BR_Id = IG_InputButton(472,256,Brushes[BrushMode],GetBrush,NULL,NULL);
IG_SetInText(BR_Id,Brushes[BrushMode]);
temp = IG_ToggleButton(472,192,"Normal View ",Nothing,NULL,NULL,&ShowSolid);
IG_SetInText(temp,"Solid Objects");
temp = IG_ToggleButton(472,224,"Eggs off",Nothing,NULL,NULL,&ShowEggs);
IG_SetInText(temp,"Eggs on ");
temp = IG_ToggleButton(556,224,"Roof off",Nothing,NULL,NULL,&ShowRoof);
IG_SetInText(temp,"Roof on ");
// Set up Map windows
IG_BlackPanel(MicroX-2,MicroY-2,68,68);
if(curmap->w>=384 || curmap->h>=384)
{
IG_BlackPanel(62,62,386,386);
PanMap();
IG_AddKey(KEY_UP,PanUp);
IG_AddKey(KEY_DOWN,PanDown);
IG_AddKey(KEY_LEFT,PanLeft);
IG_AddKey(KEY_RIGHT,PanRight);
}
else
OneToOne();
EdUpdateFunc=NULL;
IG_Region(64,64,384,384,SetL,NULL,GoMap);
IG_TextButton(496,384,"Connections",Connections,NULL,NULL);
#ifdef PATHBUILDER
temp = IG_TextButton(496,416,"PathMaker",PathMaker,NULL,NULL);
#endif
}
void OneToOne()
{
int temp,cx,cy,div,rx,ry,blockx,blocky,blockw,blockh;
OBJECT *ob;
IG_BlackPanel(62,62,386,386);
for(cy=0;cy<curmap->h;cy++)
for(cx=0;cx<curmap->w;cx++)
{
temp=ReadMap(cx,cy);
if(temp==RANDOM_TILE)
putpixel(swapscreen,cx+64,cy+64,ITG_BLUE);
else
putpixel(swapscreen,cx+64,cy+64,TIlist[temp].form->seq[0]->thumbcol);
}
if(ShowSolid || ShowEggs || ShowRoof)
for(cy=0;cy<curmap->h;cy++)
for(cx=0;cx<curmap->w;cx++)
{
ob=GetRawObjectBase(cx,cy);
for(;ob;ob=ob->next)
{
if(ShowSolid && ob->flags&IS_SOLID)
{
if(ob->flags & IS_LARGE)
{
if(ob->curdir > CHAR_D) //(U,D,L,R) > D = L,R
{
blockx=ob->hblock[BLK_X];
blocky=ob->hblock[BLK_Y];
blockw=ob->hblock[BLK_W];
blockh=ob->hblock[BLK_H];
}
else
{
blockx=ob->vblock[BLK_X];
blocky=ob->vblock[BLK_Y];
blockw=ob->vblock[BLK_W];
blockh=ob->vblock[BLK_H];
}
rectfill(swapscreen,cx+64+blockx,cy+64+blocky,cx+64+blockx+(blockw-1),cy+64+blocky+(blockh-1),ITG_BLUE);
}
else
putpixel(swapscreen,cx+64,cy+64,ITG_BLUE);
}
// Show eggs
if(ShowEggs)
if(!istricmp_fuzzy(ob->name,"egg*"))
putpixel(swapscreen,cx+64,cy+64,ITG_YELLOW);
}
// Show roof
if(ShowRoof)
if(ReadRoof(cx,cy))
putpixel(swapscreen,cx+64,cy+64,ITG_RED);
}
div = curmap->w>>6; //div64
rx=0;
ry=0;
for(cy=0;cy<64;cy++)
{
for(cx=0;cx<64;cx++)
{
temp = ReadMap(rx,ry);
if(temp==RANDOM_TILE)
putpixel(swapscreen,MicroX+cx,MicroY+cy,ITG_BLUE);
else
putpixel(swapscreen,MicroX+cx,MicroY+cy,TIlist[temp].form->seq[0]->thumbcol);
rx+=div;
}
rx=0;
ry+=div;
}
}
void PanMap()
{
int temp,cx,cy,cw,ch,div,rx,ry,blockx,blocky,blockw,blockh;
OBJECT *ob;
if(pmx+384 > curmap->w)
pmx = (curmap->w-384);
if(pmy+384 > curmap->h)
pmy = (curmap->h-384);
if(pmx < 0)
pmx = 0;
if(pmy < 0)
pmy = 0;
cw=curmap->w;
if(cw>384)
cw=384;
ch=curmap->h;
if(ch>384)
ch=384;
for(cy=0;cy<ch;cy++)
for(cx=0;cx<cw;cx++)
{
temp=ReadMap(cx+pmx,cy+pmy);
if(temp==RANDOM_TILE)
putpixel(swapscreen,cx+64,cy+64,ITG_BLUE);
else
putpixel(swapscreen,cx+64,cy+64,TIlist[temp].form->seq[0]->thumbcol);
}
if(ShowSolid || ShowEggs || ShowRoof)
for(cy=0;cy<ch;cy++)
for(cx=0;cx<cw;cx++)
{
ob=GetRawObjectBase(cx+pmx,cy+pmy);
for(;ob;ob=ob->next)
{
if(ShowSolid && ob->flags & IS_SOLID)
{
if(ob->flags & IS_LARGE)
{
if(ob->curdir > CHAR_D) //(U,D,L,R) > D = L,R
{
blockx=ob->hblock[BLK_X];
blocky=ob->hblock[BLK_Y];
blockw=ob->hblock[BLK_W];
blockh=ob->hblock[BLK_H];
}
else
{
blockx=ob->vblock[BLK_X];
blocky=ob->vblock[BLK_Y];
blockw=ob->vblock[BLK_W];
blockh=ob->vblock[BLK_H];
}
rectfill(swapscreen,cx+64+blockx,cy+64+blocky,cx+64+blockx+(blockw-1),cy+64+blocky+(blockh-1),ITG_BLUE);
}
else
putpixel(swapscreen,cx+64,cy+64,ITG_BLUE);
}
// Show eggs
if(ShowEggs)
if(!istricmp_fuzzy(ob->name,"egg*"))
putpixel(swapscreen,cx+64,cy+64,ITG_YELLOW);
}
// Show roof
if(ShowRoof)
if(ReadRoof(cx+pmx,cy+pmy))
putpixel(swapscreen,cx+64,cy+64,ITG_RED);
}
// Path point
if(path1x)
if(path1y)
if(path1x-pmx>0)
if(path1y-pmy>0)
if((path1x-pmx)+64<384)
if((path1y-pmy)+64<384)
{
circlefill(swapscreen,(path1x-pmx)+64,(path1y-pmy)+64,3,ITG_RED);
}
div = curmap->w>>6; // div64
rx=0;
ry=0;
for(cy=0;cy<64;cy++)
{
for(cx=0;cx<64;cx++)
{
temp = ReadMap(rx,ry);
if(temp==RANDOM_TILE)
putpixel(swapscreen,MicroX+cx,MicroY+cy,ITG_BLUE);
else
putpixel(swapscreen,MicroX+cx,MicroY+cy,TIlist[temp].form->seq[0]->thumbcol);
rx+=div;
}
rx=0;
ry+=div;
}
}
void PanUp()
{
pmy-=16;
PanMap();
}
void PanDown()
{
pmy+=16;
PanMap();
}
void PanLeft()
{
pmx-=16;
PanMap();
}
void PanRight()
{
pmx+=16;
PanMap();
}
void SetL()
{
int hx,hy,xx,yy,nodraw=0,col,div;
static int lastx=666,lasty=666;
int WIDF;
if(!BrushMode)
return;
WIDF=BrushType[BrushMode]; // Width of the brush
if(WIDF < 1) // Is it a special brush?
{
if(WIDF == -1)
{
Spray();
return;
}
// If it isn't the spraycan, it's probably a roof paint job
SetRoofL(-WIDF);
return;
}
hx = (x-64)+pmx;
hy = (y-64)+pmy;
nodraw=0;
if(hx==lastx && hy==lasty)
nodraw=1;
lastx=hx;lasty=hy;
if(L_bgtile==RANDOM_TILE)
col=ITG_BLUE;
else
col=TIlist[L_bgtile].form->seq[0]->thumbcol;
if(hx>(curmap->w-WIDF))
hx=(curmap->w-WIDF);
if(hy>(curmap->h-WIDF))
hy=(curmap->h-WIDF);
for(xx=0;xx<WIDF;xx++)
for(yy=0;yy<WIDF;yy++)
{
WriteMap(hx+xx,hy+yy,L_bgtile);
if(x+xx<448 && y+yy<448)
putpixel(swapscreen,x+xx,y+yy,col);
}
div=curmap->w>>6; // divide by 64
putpixel(swapscreen,MicroX+(hx/div),MicroY+(hy/div),col);
}
void GoMap()
{
mapx = (x-64)+pmx;
mapy = (y-64)+pmy;
}
void Spray()
{
int hx,hy,xx,yy,nodraw=0,col;
static int lastx=666,lasty=666;
hx = (x-64)+pmx;
hy = (y-64)+pmy;
nodraw=0;
if(hx==lastx && hy==lasty)
nodraw=1;
lastx=hx;lasty=hy;
if(L_bgtile==RANDOM_TILE)
col=ITG_BLUE;
else
col=TIlist[L_bgtile].form->seq[0]->thumbcol;
if(hx>(curmap->w-8))
hx=(curmap->w-8);
if(hy>(curmap->h-8))
hy=(curmap->h-8);
for(xx=0;xx<8;xx++)
for(yy=0;yy<8;yy++)
{
if(rand()%100>95)
{
WriteMap(hx+xx,hy+yy,L_bgtile);
if(x+xx<448 && y+yy<448)
putpixel(swapscreen,x+xx,y+yy,col);
}
}
//div=curmap->w>>6; // divide by 64
//putpixel(swapscreen,MicroX+(hx/div),MicroY+(hy/div),col);
}
void SetRoofL(int WIDF)
{
int hx,hy,xx,yy,nodraw=0,temp;
static int lastx=666,lasty=666;
hx = (x-64)+pmx;
hy = (y-64)+pmy;
nodraw=0;
if(hx==lastx && hy==lasty)
nodraw=1;
lastx=hx;lasty=hy;
if(hx>(curmap->w-WIDF))
hx=(curmap->w-WIDF);
if(hy>(curmap->h-WIDF))
hy=(curmap->h-WIDF);
for(xx=0;xx<WIDF;xx++)
for(yy=0;yy<WIDF;yy++)
{
WriteRoof(hx+xx,hy+yy,L_rooftile);
if(x+xx<448 && y+yy<448)
{
if(L_rooftile)
putpixel(swapscreen,x+xx,y+yy,ITG_RED);
else
{
temp = ReadMap(hx+xx,hy+yy);
if(temp==RANDOM_TILE)
putpixel(swapscreen,x+xx,y+y,ITG_BLUE);
else
putpixel(swapscreen,x+xx,y+yy,TIlist[temp].form->seq[0]->thumbcol);
}
}
}
//div=curmap->w>>6; // divide by 64
//putpixel(swapscreen,MicroX+(hx/div),MicroY+(hy/div),col);
}
void Nothing()
{
PanMap();
}
void Connections()
{
focus=0;
IG_KillAll();
DrawScreenBox3D(128,128,384,320);
setcolor(ITG_WHITE);
DrawScreenText(144,160,"Map to the North");
CN_Id = IG_InputButton(280,152,ConnNstr,ConnN,NULL,NULL);
DrawScreenText(144,192,"Map to the South:");
CS_Id = IG_InputButton(280,184,ConnSstr,ConnS,NULL,NULL);
DrawScreenText(144,224,"Map to the East:");
CE_Id = IG_InputButton(280,216,ConnEstr,ConnE,NULL,NULL);
DrawScreenText(144,256,"Map to the West:");
CW_Id = IG_InputButton(280,248,ConnWstr,ConnW,NULL,NULL);
IG_TextButton(160,288,"Finish",Finish,NULL,NULL);
IG_AddKey(KEY_ESC,Finish); // ESC to quit this menu
//IG_AddKey(KEY_F10,Snap); // Add key binding for shift-F10
Connections_Update();
IG_WaitForRelease();
}
void Connections_Update()
{
if(curmap->con_n)
sprintf(ConnNstr,"%6d",curmap->con_n);
else
strcpy(ConnNstr,"None ");
IG_UpdateText(CN_Id,ConnNstr);
if(curmap->con_s)
sprintf(ConnSstr,"%6d",curmap->con_s);
else
strcpy(ConnSstr,"None ");
IG_UpdateText(CS_Id,ConnSstr);
if(curmap->con_e)
sprintf(ConnEstr,"%6d",curmap->con_e);
else
strcpy(ConnEstr,"None ");
IG_UpdateText(CE_Id,ConnEstr);
if(curmap->con_w)
sprintf(ConnWstr,"%6d",curmap->con_w);
else
strcpy(ConnWstr,"None ");
IG_UpdateText(CW_Id,ConnWstr);
IG_WaitForRelease();
}
void ConnN()
{
int ret;
ret=0;
ret=InputIntegerValueP(-1,-1,0,9999,curmap->con_n,"Enter map number ");
if(ret<0)
return;
if(ret==mapnumber)
if(!Confirm(-1,-1,"That's this map.","Are you sure you want to link this map to itself?"))
return;
curmap->con_n=ret;
Connections_Update();
}
void ConnS()
{
int ret;
ret=0;
ret=InputIntegerValueP(-1,-1,0,9999,curmap->con_s,"Enter map number ");
if(ret<0)
return;
if(ret==mapnumber)
if(!Confirm(-1,-1,"That's this map.","Are you sure you want to link this map to itself?"))
return;
curmap->con_s=ret;
Connections_Update();
}
void ConnE()
{
int ret;
ret=0;
ret=InputIntegerValueP(-1,-1,0,9999,curmap->con_e,"Enter map number ");
if(ret<0)
return;
if(ret==mapnumber)
if(!Confirm(-1,-1,"That's this map.","Are you sure you want to link this map to itself?"))
return;
curmap->con_e=ret;
Connections_Update();
}
void ConnW()
{
int ret;
ret=0;
ret=InputIntegerValueP(-1,-1,0,9999,curmap->con_w,"Enter map number ");
if(ret<0)
return;
if(ret==mapnumber)
if(!Confirm(-1,-1,"That's this map.","Are you sure you want to link this map to itself?"))
return;
curmap->con_w=ret;
Connections_Update();
}
void Finish()
{
IG_WaitForRelease();
BM_GoFocal();
}
#ifdef PATHBUILDER
void PathMaker()
{
//PathMode=1;
}
#endif
void GetBrush()
{
int ctr;
char brush[256];
for(ctr=0;Brushes[ctr];ctr++);
strcpy(brush,Brushes[BrushMode]);
InputNameFromList(-1,-1, "Choose a brush type:", ctr, Brushes, brush);
for(ctr=0;Brushes[ctr];ctr++)
if(!strcmp(brush,Brushes[ctr]))
{
BrushMode=ctr;
IG_UpdateText(BR_Id,Brushes[BrushMode]);
return;
}
}