-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graphics.cpp
executable file
·7086 lines (6330 loc) · 292 KB
/
Graphics.cpp
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
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "stdafx.h"
#include "global.h"
#include "dibengine.h"
// Constant
// 3D clipping range
const int kTer3DTopClip = 1;
const int kTer3DBottomClip = 3;
// Global variables
HDC main_dc;
HDC main_dc2;
HDC main_dc3;
HDC main_dc4;
HDC main_dc5;
HDIB mixed_gworld = NULL;
HDIB ed_pattern_gworld = NULL;
HBITMAP bw_bitmap = NULL;
HFONT font;
HFONT small_bold_font;
HFONT italic_font;
HFONT underline_font;
HFONT bold_font;
HFONT tiny_font;
RECT terrain_buttons_rect = {0,0,260,639}; /* was 550 */
Boolean showed_graphics_error = FALSE;
// external global variables
extern HWND mainPtr;
extern HWND right_sbar;
extern RECT right_sbar_rect;
extern scenario_data_type scenario;
extern zone_names_data_type zone_names;
extern town_record_type town;
extern big_tr_type t_d;
extern outdoor_record_type current_terrain;
extern scen_item_data_type scen_data;
extern outdoor_record_type border_terrains[3][3];
extern short cur_town;
extern location cur_out;
extern short current_drawing_mode;
extern short town_type;
extern short current_height_mode;
extern Boolean editing_town;
extern short cur_viewing_mode;
extern short ulx,uly;
extern short cen_x, cen_y;
extern short available_dlog_buttons[NUM_DLOG_B];
extern short max_dim[3];
extern RECT windRect;
extern RECT world_screen;
extern Boolean file_is_loaded;
extern char *button_strs[140];
extern short current_floor_drawn;
extern short current_terrain_drawn;
// border rects order: top, left, bottom, right //
extern RECT border_rect[4];
extern RECT terrain_rects[330];
extern RECT terrain_rects_3D[330];
extern short hill_c_heights[12][4];
extern RECT palette_buttons[9][6];
extern RECT small_edit_ter_rects[MAX_TOWN_SIZE][MAX_TOWN_SIZE];
extern RECT medium_edit_ter_rects[32][32];
extern RECT large_edit_ter_rects[9][9];
extern RECT left_text_lines[14];
extern RECT right_text_lines[7];
extern short selected_item_number;
char hintbook_mode0 = 0;
char hintbook_mode1 = 1;
char hintbook_mode2 = 0;
char hintbook_mode3 = 0;
char hintbook_mode4 = 0;
char hintbook_mode5 = 0;
char hintbook_mode6 = 0;
char hintbook_mode7 = 0;
char hintbook_mode8 = 0;
char hintbook_mode9 = 0;
char grid_mode = 0;
char *numerical_display_captions[5] = {"(Null Display)","Display Floor Type",
"Display Terrain Type","Display Height","Display Screen Coordinates"};
char *group_display_captions[12] = {"(Null Display)","Creature Types","Terrain Scripts","Item Types",
"Placed Specials","Area Descriptions","Town Boundary","Signs",
"Wandering Locations","Preset Fields","Waypoints","Horses and Boats"};
char *out_group_display_captions[12] = {"(Null Display)","(Null Display)","(Null Display)","(Null Display)",
"Placed Specials","Area Descriptions","Towns Entered","Signs",
"Wandering Locations","Wandering Encounters","Special Encounters","Preset Encounters"};
char *object_display_mode_towncaptions3[12] = {"(Null Display)","Creature Name","Script Name","Item Name","(Null Display)",
"Area Name","Current Town","Sign Text","(Null Display)","Preset Field Type","(Null Display)","Horse or Boat"};
char *object_display_mode_outcaptions3[12] = {"(Null Display)","(Null Display)","(Null Display)","(Null Display)","(Null Display)",
"Area Name","Town Entered","Sign Text","(Null Display)","First Hostile Monster","First Hostile Monster","First Hostile Monster"};
char *object_display_mode_towncaptions4[12] = {"(Null Display)","Creature Type","Memory Cell 0","Item Type","Special Called",
"(Null Display)","Town Number","(Null Display)","(Null Display)","(Null Display)","(Null Display)","Party Property"};
char *object_display_mode_outcaptions4[12] = {"(Null Display)","(Null Display)","(Null Display)","(Null Display)","Special Called",
"(Null Display)","Town Entered","(Null Display)","(Null Display)","First Hostile Monster Amount","First Hostile Monster Amount","First Hostile Monster Amount"};
extern char *BOAFieldnames[22];
extern Boolean small_any_drawn;
extern short numerical_display_mode;
extern short object_display_mode;
// local variables
HBITMAP main_bitmap = NULL;
HBITMAP main_bitmap_save;
HDIB editor_mixed = NULL;
HDIB terrain_buttons_gworld = NULL;
HDIB ter_draw_gworld = NULL;
HDIB dlog_horiz_border_bottom_gworld = NULL;
HDIB dlog_horiz_border_top_gworld = NULL;
HDIB dlog_vert_border_gworld = NULL;
HDIB pattern_gworld = NULL;
HDIB dialog_pattern_gworld = NULL;
HDIB pat_source_gworld = NULL;
HDIB buttons_gworld = NULL;
HDIB ter_resize_buffer_gworld = NULL;
extern location selected_square;
// Other game rectangles
RECT terrain_rect_gr_size = {0,0,512,512};
// RECT blue_button_from = {91,112,107,126}; /**/
// RECT start_button_from = {70,112,91,119};
RECT base_small_button_from = {0,103,10,113};
RECT base_small_3D_button_from = {0,143,16,154};
RECT palette_button_base = {0,0,25,18};
extern const RECT terrain_viewport_3d = {5,5,501,420};
RECT buttons_from[NUM_BUTTONS] = {{0,0,23,23},{46,0,108,23},{0,132,102,155},{126,23,142,36},
{0,92,62,115},{0,69,62,92},{126,46,188,69},{126,69,188,92}, // l, r, u, d
{172,30,184,42},{172,30,184,42},{196,30,208,42},{0,23,62,46}, // small, small, , done
{0,46,62,69},{208,30,226,46},{204,132,222,148},{172,0,202,30}}; // cancel, up arrow down arrow
// Palette UL x = 525 y = 382
// graphics library
HDIB graphics_library[MAX_NUM_SHEETS_IN_LIBRARY];
graphic_id_type graphics_library_index[MAX_NUM_SHEETS_IN_LIBRARY];
short num_sheets_in_library = 0;
char current_string[256] = "";
char current_string2[256] = "";
char *attitude_types[4] = {"Friendly","Neutral","Hostile, Type A","Hostile, Type B"};
char *facings[4] = {"North","West","South","East"};
short small_what_drawn[64][64];
short small_what_floor_drawn[64][64];
HDIB tint_area;
RECT tint_rect = {0,0,PICT_BOX_WIDTH_3D,PICT_BOX_HEIGHT_3D};
// function prototypes
// PARTIAL TABLE OF CONTENTS
void load_main_screen();
void delete_graphic(HDIB *to_delete);
void draw_wall_3D_sidebar(short t_to_draw, RECT to_rect);
Boolean place_icon_into_3D_sidebar(graphic_id_type icon, RECT to_rect, short unscaled_offset_x, short unscaled_offset_y);
Boolean place_icon_into_ter_3D_large(graphic_id_type icon,short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect,short lighting);
Boolean place_creature_icon_into_ter_3D_large(graphic_id_type icon,short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect,short lighting,short r,short g,short b);
Boolean place_cliff_icon_into_ter_3D_large(short sheet,short at_point_center_x,short at_point_center_y, short direction,RECT *to_whole_area_rect,short lighting);
Boolean place_item_icon_into_ter_3D_large(graphic_id_type icon,short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect,short lighting);
Boolean place_outdoor_creature_icon_into_ter_3D_large(graphic_id_type icon,short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect,short lighting);
Boolean place_corner_wall_icon_into_ter_3D_large(graphic_id_type icon,short at_point_center_x,short at_point_center_y,Boolean left_side_of_template,RECT *to_whole_area_rect,short lighting);
void place_ter_icon_on_tile_3D(short at_point_center_x,short at_point_center_y,short position,short which_icon,RECT *to_whole_area_rect);
void draw_ter_script_3D(short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect);
void place_ter_icons_3D(location which_outdoor_sector, outdoor_record_type *drawing_terrain, short square_x, short square_y,short t_to_draw, short floor_to_draw, short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect);
void draw_ter_icon_3D(short terrain_number,short icon_number,short x,short y,graphic_id_type a,short t_to_draw,RECT *to_whole_area_rect,short lighting,short height);
void draw_terrain_3D(short t_to_draw, short x, short y, short sector_x, short sector_y, short at_x, short at_y, Boolean see_in_neighbors[3][3], Boolean is_wall_corner,RECT *to_whole_area_rect,short lighting);
void draw_creature_3D(short creature_num,short at_point_center_x,short at_point_center_y, short square_x, short square_y,RECT *to_whole_area_rect,short lighting);
void draw_item_3D(short item_num,short at_point_center_x,short at_point_center_y, short square_x, short square_y,RECT *to_whole_area_rect,short lighting);
void put_line_segment_in_gworld_3D(HDC line_gworld,outdoor_record_type *drawing_terrain,short at_point_center_3D_x,short at_point_center_3D_y,short square_2D_x, short square_2D_y, short line_on_2D_x_side, short line_on_2D_y_side, Boolean corner_label_x,Boolean corner_label_y, short inset_3D_y, short offset_3D_y,short r,short g, short b,RECT *to_whole_area_rect);
void maybe_draw_part_of_3D_rect(outdoor_record_type *drawing_terrain, short center_of_current_square_x, short center_of_current_square_y, short x, short y,macRECT rect, short inset, short r, short g, short b,RECT *to_whole_area_rect);
void draw_town_objects_3D(short x, short y, short at_point_center_x, short at_point_center_y,RECT *to_whole_area_rect,short lighting);
void draw_ter_3D_large();
void draw_ter_large();
void draw_ter_medium();
void draw_ter_small();
Boolean place_terrain_icon_into_ter_large(graphic_id_type icon,short in_square_x,short in_square_y);
Boolean place_terrain_icon_into_ter_medium(graphic_id_type icon,short in_square_x,short in_square_y);
Boolean place_terrain_icon_into_ter_small(graphic_id_type icon,short in_square_x,short in_square_y);
void place_ter_icon_on_tile(short tile_x,short tile_y,short position,short which_icon);
void draw_creature(HDC ter_hdc,HBITMAP store_bmp,short creature_num,location loc_drawn,short in_square_x,short in_square_y);
void draw_creature_medium(HDC ter_hdc,HBITMAP store_bmp,short creature_num,location loc_drawn,short in_square_x,short in_square_y);
void draw_item(HDC ter_hdc,HBITMAP store_bmp,short item_num,location loc_drawn,short in_square_x,short in_square_y);
void draw_ter_script(short script_num,location loc_drawn,short in_square_x,short in_square_y);
void place_left_text();
void win_draw_string_outline(HDC dest_hdc,RECT dest_rect,char *str,short mode,short line_height);
void win_draw_string(HDC dest_hdc,RECT dest_rect,char *str,short mode);
Boolean load_sheet_into_library(graphic_id_type *new_sheet);
short get_index_of_sheet(graphic_id_type *sheet);
short safe_get_index_of_sheet(graphic_id_type *sheet);
void put_rect_in_gworld(HDC hdc,RECT rect,short r,short g, short b);
void fill_rect_in_gworld(HDC line_gworld,RECT to_rect,short r,short g, short b);
void put_line_in_gworld(HDC line_gworld,short from_x,short from_y,short to_x,short to_y,short r,short g, short b);
void put_rect_on_screen(HDC win,RECT to_rect,short r,short g, short b);
void put_clipped_rect_in_gworld(HDC line_gworld,RECT to_rect,RECT clip_rect,short r,short g, short b);
Boolean is_field_type(short i,short j,short field_type);
void make_field_type(short i,short j,short field_type);
void take_field_type(short i,short j,short field_type);
Boolean is_fire_barrier(short i,short j);
Boolean is_force_barrier(short i,short j);
Boolean is_blocked(short i,short j);
Boolean is_sfx(short i,short j,short type);
void place_dlog_border_on_win(HDIB to_gworld,HWND win,RECT border_to_rect,short horiz_or_vert,short bottom_or_top);
void cant_draw_graphics_error(graphic_id_type a,char *bonus_string,short bonus_num);
void adjust_graphic(HDIB *src_gworld_ptr, RECT *from_rect_ptr, short graphic_adjust);
void apply_lighting_to_graphic(HDIB *src_gworld_ptr, RECT *from_rect_ptr, short lighting);
void add_border_to_graphic(HDIB *src_gworld_ptr, RECT *from_rect_ptr, short border_r, short border_g, short border_b);
//void make_Boat(short i,short j);
// declared elsewhere but still found here:
// void set_blitter_color(UInt16 color);
// void tint_graphic( GWorldPtr dest,short tint_strength);
// void hue_graphic( GWorldPtr dest,short up_or_down,short red_shift,short green_shift,short blue_shift);
// void refresh_graphics_on_screen();
void Set_up_win ()
{
short i,j;
font = CreateFont(12,0,0,0,0, 0,0,0, 0,0, 0,0,0,"MS Sans Serif");
small_bold_font = CreateFont(12,0,0,0,700, 0,0,0, 0,0, 0,0,0,"MS Sans Serif");
italic_font = CreateFont(12,0,0,0,0, 1,0,0, 0,0, 0,0,0,"MS Sans Serif");
underline_font = CreateFont(12,0,0,0,0, 0,1,0, 0,0, 0,0,0,"MS Sans Serif");
bold_font = CreateFont(14,0,0,0,700, 0,0,0, 0,0, 0,0,0,"MS Sans Serif");
tiny_font = font;
for (i = 0; i < 9; i++){
for (j = 0; j < 6; j++){
palette_buttons[i][j] = palette_button_base;
OffsetRect(&palette_buttons[i][j],i * 25 + PALETTE_BUT_UL_X, j * 17 + PALETTE_BUT_UL_Y);
}
}
for (i = 0; i < MAX_TOWN_SIZE; i++){
for (j = 0; j < MAX_TOWN_SIZE; j++){
SetRECT(small_edit_ter_rects[i][j], i * SMALL_SPACE_SIZE, j * SMALL_SPACE_SIZE,
(i + 1) * SMALL_SPACE_SIZE, (j + 1) * SMALL_SPACE_SIZE);
}
}
for (i = 0; i < MAX_TOWN_SIZE; i++){
for (j = 0; j < MAX_TOWN_SIZE; j++){
SetRECT(medium_edit_ter_rects[i][j], i * MEDIUM_SPACE_SIZE, j * MEDIUM_SPACE_SIZE,
(i + 1) * MEDIUM_SPACE_SIZE, (j + 1) * MEDIUM_SPACE_SIZE);
}
}
for (i = 0; i < 9; i++){
for (j = 0; j < 9; j++){
SetRECT(large_edit_ter_rects[i][j],TERRAIN_BORDER_WIDTH + i * BIG_SPACE_SIZE,TERRAIN_BORDER_WIDTH + j * BIG_SPACE_SIZE,
TERRAIN_BORDER_WIDTH + (i + 1) * BIG_SPACE_SIZE,TERRAIN_BORDER_WIDTH + (j + 1) * BIG_SPACE_SIZE);
}
}
for (i = 0; i < 330; i++)
SetRECT(terrain_rects[i],3 + (i % 15) * (TER_BUTTON_SIZE + 1),2 + (i / 15) * (TER_BUTTON_SIZE + 1),
3 + (i % 15) * (TER_BUTTON_SIZE + 1) + TER_BUTTON_SIZE,2 + (i / 15) * (TER_BUTTON_SIZE + 1) + TER_BUTTON_SIZE);
for (i = 0; i < 285; i++)
SetRECT(terrain_rects_3D[i],3 + (i % 15) * (TER_BUTTON_SIZE + 1),2 + (i / 15) * (TER_BUTTON_HEIGHT_3D + 1),
3 + (i % 15) * (TER_BUTTON_SIZE + 1) + TER_BUTTON_SIZE,2 + (i / 15) * (TER_BUTTON_HEIGHT_3D + 1) + TER_BUTTON_HEIGHT_3D);
for (i = 0; i < MAX_NUM_SHEETS_IN_LIBRARY; i++) {
graphics_library[i] = NULL;
}
RECT world_screen = {large_edit_ter_rects[0][0].left,large_edit_ter_rects[0][0].top,
large_edit_ter_rects[8][8].right,large_edit_ter_rects[8][8].bottom}; /**/
MacInsetRect(&world_screen,-15,-15);
OffsetRect(&world_screen,TER_RECT_UL_X,TER_RECT_UL_Y);
for (i = 0; i < 4; i++)
border_rect[i] = world_screen;
border_rect[0].bottom = border_rect[0].top + 15;
border_rect[1].right = border_rect[1].left + 15;
border_rect[2].top = border_rect[2].bottom - 15;
border_rect[3].left = border_rect[3].right - 15;
load_main_screen();
}
void load_main_screen()
{
main_dc = GetDC(mainPtr);
SelectObject(main_dc,font);
SetBkMode(main_dc,TRANSPARENT);
SetStretchBltMode(main_dc,STRETCH_DELETESCANS);
main_dc2 = CreateCompatibleDC(main_dc);
SetMapMode(main_dc2,GetMapMode(main_dc));
SetStretchBltMode(main_dc2,STRETCH_DELETESCANS);
main_dc3 = CreateCompatibleDC(main_dc);
SetMapMode(main_dc3,GetMapMode(main_dc));
SetStretchBltMode(main_dc3,STRETCH_DELETESCANS);
main_dc4 = CreateCompatibleDC(main_dc);
SetMapMode(main_dc4,GetMapMode(main_dc));
SetStretchBltMode(main_dc4,STRETCH_DELETESCANS);
main_dc5 = CreateCompatibleDC(main_dc);
SetMapMode(main_dc5,GetMapMode(main_dc));
SetStretchBltMode(main_dc5,STRETCH_DELETESCANS);
terrain_buttons_gworld = DibCreate (terrain_buttons_rect.right,terrain_buttons_rect.bottom, 16,0);
ter_draw_gworld = DibCreate (terrain_rect_gr_size.right,terrain_rect_gr_size.bottom, 16,0);
ter_resize_buffer_gworld = DibCreate (100,100, 16,0);
tint_area = DibCreate (tint_rect.right,tint_rect.bottom, 16,0);
buttons_gworld = load_pict(2000);
bw_bitmap = CreateBitmap(72,72,1,1,NULL);
pattern_gworld = DibCreate (192,256, 16,0);
dialog_pattern_gworld = DibCreate (192,256, 16,0);
pat_source_gworld = load_pict(4900);
editor_mixed = load_pict(4919);
mixed_gworld = load_pict(903);
if (dlog_horiz_border_bottom_gworld == NULL)
dlog_horiz_border_bottom_gworld = load_pict(842);//(52);
if (dlog_horiz_border_top_gworld == NULL)
dlog_horiz_border_top_gworld = load_pict(841);//(51);
if (dlog_vert_border_gworld == NULL)
dlog_vert_border_gworld = load_pict(840);//(850);
if (ed_pattern_gworld == NULL)
ed_pattern_gworld = load_pict(4901);//(850);
}
// lose other graphics
void lose_graphics()
{
if (bw_bitmap != NULL) {
DeleteObject(bw_bitmap);
bw_bitmap = NULL;
}
if (main_bitmap != NULL) {
SelectObject( main_dc, main_bitmap_save );
DeleteObject( main_bitmap );
main_bitmap = NULL;
}
refresh_graphics_library();
delete_graphic(&ed_pattern_gworld);
delete_graphic(&dlog_vert_border_gworld);
delete_graphic(&dlog_horiz_border_top_gworld);
delete_graphic(&dlog_horiz_border_bottom_gworld);
delete_graphic(&mixed_gworld);
delete_graphic(&editor_mixed);
delete_graphic(&pat_source_gworld);
delete_graphic(&dialog_pattern_gworld);
delete_graphic(&pattern_gworld);
delete_graphic(&buttons_gworld);
delete_graphic(&tint_area);
delete_graphic(&ter_resize_buffer_gworld);
delete_graphic(&ter_draw_gworld);
delete_graphic(&terrain_buttons_gworld);
ReleaseDC( mainPtr, main_dc );
DeleteDC(main_dc2);
DeleteDC(main_dc3);
DeleteDC(main_dc4);
DeleteDC(main_dc5);
DeleteObject(font);
DeleteObject(small_bold_font);
DeleteObject(italic_font);
DeleteObject(underline_font);
DeleteObject(bold_font);
}
void redraw_screen()
{
// fill left with pattern
RECT to_rect = windRect;
to_rect.right = RIGHT_BUTTONS_X_SHIFT;
paint_pattern(NULL,1,to_rect,0);
// fill lower right corner
to_rect = windRect;
to_rect.left = terrain_buttons_rect.right + RIGHT_BUTTONS_X_SHIFT;
to_rect.top = 22 * (TER_BUTTON_SIZE + 1) + 1;
paint_pattern(NULL,1,to_rect,0);
small_any_drawn = TRUE;
draw_main_screen();
}
void draw_main_screen()
{
place_right_buttons();
draw_terrain();
}
void set_up_terrain_buttons()
{
short i,j;
RECT ter_from,ter_from_base = {0,0,16,16};
HBITMAP store_bmp;
HFONT store_font;
paint_pattern(terrain_buttons_gworld,0,terrain_buttons_rect,2);
// frame rect around buttons
SetBkMode(main_dc5,TRANSPARENT);
store_font = (HFONT)SelectObject(main_dc5,bold_font);
store_bmp = (HBITMAP) SelectObject(main_dc5,DibBitmapHandle(terrain_buttons_gworld));
put_rect_in_gworld(main_dc5,terrain_buttons_rect,0,0,0);
if (file_is_loaded == FALSE) {
SelectObject(main_dc5,store_font);
SelectObject(main_dc5,store_bmp);
return;
}
// first make terrain buttons
for (i = 0; i < ((cur_viewing_mode >= 10 && current_drawing_mode > 0) ? 285 : 330); i++){
if ((i < 256) || (current_drawing_mode > 0)) {
ter_from = ter_from_base;
graphic_id_type a;
Boolean do_this_item = TRUE;
short store_ter_type = 0;
if(cur_viewing_mode == 10 || cur_viewing_mode == 11) {
SetRECT(ter_from,0,0,PICT_BOX_WIDTH_3D,PICT_BOX_HEIGHT_3D);
switch (current_drawing_mode) {
case 0:
a = scen_data.scen_floors[i].pic;
OffsetRect(&ter_from,(1 + PICT_BOX_WIDTH_3D) * (a.which_icon % 10) + 1,(1 + PICT_BOX_HEIGHT_3D) * (a.which_icon / 10) + 1);
if (a.not_legit())
do_this_item = FALSE;
break;
case 1: case 2:
short sbar_pos = GetControlValue(right_sbar);
store_ter_type = sbar_pos * 15 + i;
if(store_ter_type == 0)
fill_rect_in_gworld(main_dc5,terrain_rects_3D[i],255,255,255);
if (store_ter_type < 512) {
a = scen_data.scen_ter_types[store_ter_type].pic;
//if a wall (or fence - at least one move block, but not all)
//this doesn't include open fence gates, but perhaps that's good - they can
//stick out of a square unpredictably
if( (store_ter_type >= 2 && store_ter_type <= 73)
|| ( !(scen_data.scen_ter_types[store_ter_type].move_block[0] == 1
&& scen_data.scen_ter_types[store_ter_type].move_block[1] == 1
&& scen_data.scen_ter_types[store_ter_type].move_block[2] == 1
&& scen_data.scen_ter_types[store_ter_type].move_block[3] == 1)
&& (scen_data.scen_ter_types[store_ter_type].move_block[0] == 1
|| scen_data.scen_ter_types[store_ter_type].move_block[1] == 1
|| scen_data.scen_ter_types[store_ter_type].move_block[2] == 1
|| scen_data.scen_ter_types[store_ter_type].move_block[3] == 1) ) ) {
SelectObject(main_dc5,store_bmp);
draw_wall_3D_sidebar(store_ter_type, terrain_rects_3D[i]);
SelectObject(main_dc5,DibBitmapHandle(terrain_buttons_gworld));
do_this_item = FALSE;
}
OffsetRect(&ter_from,(1 + PICT_BOX_WIDTH_3D) * (a.which_icon % 10) + 1,(1 + PICT_BOX_HEIGHT_3D) * (a.which_icon / 10) + 1);
if (a.not_legit())
do_this_item = FALSE;
}
else do_this_item = FALSE;
break;
}
}
else {
switch (current_drawing_mode) {
case 0:
a = scen_data.scen_floors[i].ed_pic;
OffsetRect(&ter_from,(1 + TER_BUTTON_SIZE) * (a.which_icon % 10) + 1,(1 + TER_BUTTON_SIZE) * (a.which_icon / 10) + 1);
if (a.not_legit())
do_this_item = FALSE;
break;
case 1: case 2:
short sbar_pos = GetControlValue(right_sbar);
store_ter_type = sbar_pos * 15 + i;
if (store_ter_type < 512) {
a = scen_data.scen_ter_types[store_ter_type].ed_pic;
OffsetRect(&ter_from,(1 + TER_BUTTON_SIZE) * (a.which_icon % 10) + 1,(1 + TER_BUTTON_SIZE) * (a.which_icon / 10) + 1);
if (a.not_legit())
do_this_item = FALSE;
}
else do_this_item = FALSE;
break;
}
}
if (do_this_item == TRUE) {
short index = safe_get_index_of_sheet(&a);
if (index < 0) {
SelectObject(main_dc5,store_bmp);
if (current_drawing_mode == 0)
cant_draw_graphics_error(a,"Error was for floor type",i);
else
cant_draw_graphics_error(a,"Error was for terrain type",store_ter_type);
return;
}
if((cur_viewing_mode >= 10) && (current_drawing_mode == 0))
ter_from.top += (PICT_BOX_HEIGHT_3D - PICT_BOX_WIDTH_3D);
SelectObject(main_dc5,store_bmp);
rect_draw_some_item(graphics_library[index],
ter_from,terrain_buttons_gworld,(cur_viewing_mode >= 10 && current_drawing_mode > 0) ?
terrain_rects_3D[i] : terrain_rects[i],0,0);
SelectObject(main_dc5,DibBitmapHandle(terrain_buttons_gworld));
}
}
}
SelectObject(main_dc5,store_font);
SelectObject(main_dc5,store_bmp);
// palette buttons
const RECT kBlankButtonRect = {PALETTE_BUT_WIDTH * 5,PALETTE_BUT_HEIGHT * 6,
PALETTE_BUT_WIDTH * 6,PALETTE_BUT_HEIGHT * 7 + 1};
const RECT kCreateTownButtonRect = {PALETTE_BUT_WIDTH * 6,PALETTE_BUT_HEIGHT * 6,
PALETTE_BUT_WIDTH * 7,PALETTE_BUT_HEIGHT * 7 + 1};
const RECT kEditTownButtonRect = {PALETTE_BUT_WIDTH * 7,PALETTE_BUT_HEIGHT * 6,
PALETTE_BUT_WIDTH * 8,PALETTE_BUT_HEIGHT * 7 + 1};
const RECT kRealisticButtonRect = {PALETTE_BUT_WIDTH * 8,PALETTE_BUT_HEIGHT * 6,
PALETTE_BUT_WIDTH * 9,PALETTE_BUT_HEIGHT * 7 + 1};
for (i = 0; i < 9; i++){
for (j = 0; j < ((editing_town == TRUE) ? 6 : 4); j++) {
RECT from_rect = {PALETTE_BUT_WIDTH * i,PALETTE_BUT_HEIGHT * j,
PALETTE_BUT_WIDTH * (i + 1),PALETTE_BUT_HEIGHT * (j + 1) + 1}; /**/
RECT to_rect = palette_buttons[i][j];
if(cur_viewing_mode >= 10 && i == 0 && j == 1) // realistic mode palette icon
from_rect = kRealisticButtonRect;
if(editing_town == FALSE && i == 0 && j == 3)
from_rect = kCreateTownButtonRect;
if(editing_town == FALSE && i == 1 && j == 3)
from_rect = kEditTownButtonRect;
if(editing_town == FALSE && i > 1 && j == 3)
from_rect = kBlankButtonRect;
to_rect.right++;
from_rect.right++;
rect_draw_some_item(editor_mixed,
from_rect,terrain_buttons_gworld,to_rect,0,0);
}
}
}
void delete_graphic(HDIB *to_delete)
{
if (*to_delete == NULL)
return;
DibDelete(*to_delete);
*to_delete = NULL;
}
void draw_wall_3D_sidebar(short t_to_draw, RECT to_rect)
{
graphic_id_type a;
short temp_t_to_draw;
HBITMAP store_bmp;
SetBkMode(main_dc4,TRANSPARENT);
store_bmp = (HBITMAP) SelectObject(main_dc4,DibBitmapHandle(terrain_buttons_gworld));
fill_rect_in_gworld(main_dc4,to_rect,255,255,255);
SelectObject(main_dc4,store_bmp);
//use cutaway when possible, so user can see better
//but not in sidebar
//a = scen_data.scen_ter_types[t_to_draw].cut_away_pic;
//if (a.not_legit())
a = scen_data.scen_ter_types[t_to_draw].pic;
//walls
if(t_to_draw >= 2 && t_to_draw <= 73) {
if(editing_town == FALSE) {
a.which_sheet = ((current_terrain.is_on_surface) ? 616 : 614);
}
else if(t_to_draw >= 2 && t_to_draw <= 37) {
a.which_sheet = town.wall_1_sheet;
}
else if(t_to_draw >= 38 && t_to_draw <= 73) {
a.which_sheet = town.wall_2_sheet;
}
}
//draw L (2-side) walls
if(t_to_draw == 6 || t_to_draw == 42) {//NW
a.which_icon = 5;
if (a.not_legit() == FALSE)
if (place_icon_into_3D_sidebar(a,to_rect,scen_data.scen_ter_types[t_to_draw].icon_offset_x,
scen_data.scen_ter_types[t_to_draw].icon_offset_y - 10) == FALSE)
cant_draw_graphics_error(a,"Error was for terrain type",t_to_draw);
}
else if(t_to_draw == 7 || t_to_draw == 43) {//SW
temp_t_to_draw = t_to_draw;
temp_t_to_draw = 3;//west
a.which_icon = 1;
if (a.not_legit() == FALSE)
if (place_icon_into_3D_sidebar(a,to_rect,scen_data.scen_ter_types[temp_t_to_draw].icon_offset_x,
scen_data.scen_ter_types[temp_t_to_draw].icon_offset_y) == FALSE)
cant_draw_graphics_error(a,"Error was for terrain type",t_to_draw);
temp_t_to_draw = 4;//south
a.which_icon = 0;
if (a.not_legit() == FALSE)
if (place_icon_into_3D_sidebar(a,to_rect,scen_data.scen_ter_types[temp_t_to_draw].icon_offset_x,
scen_data.scen_ter_types[temp_t_to_draw].icon_offset_y) == FALSE)
cant_draw_graphics_error(a,"Error was for terrain type",t_to_draw);
}
else if(t_to_draw == 8 || t_to_draw == 44) {//SE
a.which_icon = 4;
if (a.not_legit() == FALSE)
if (place_icon_into_3D_sidebar(a,to_rect,scen_data.scen_ter_types[t_to_draw].icon_offset_x,
scen_data.scen_ter_types[t_to_draw].icon_offset_y) == FALSE)
cant_draw_graphics_error(a,"Error was for terrain type",t_to_draw);
}
else if(t_to_draw == 9 || t_to_draw == 45) {//NE
temp_t_to_draw = t_to_draw;
temp_t_to_draw = 2;//north wall
a.which_icon = 0;
if (a.not_legit() == FALSE)
if (place_icon_into_3D_sidebar(a,to_rect,scen_data.scen_ter_types[temp_t_to_draw].icon_offset_x,
scen_data.scen_ter_types[temp_t_to_draw].icon_offset_y) == FALSE)
cant_draw_graphics_error(a,"Error was for terrain type",t_to_draw);
temp_t_to_draw = 5;//east wall
a.which_icon = 1;
if (a.not_legit() == FALSE)
if (place_icon_into_3D_sidebar(a,to_rect,scen_data.scen_ter_types[temp_t_to_draw].icon_offset_x,
scen_data.scen_ter_types[temp_t_to_draw].icon_offset_y) == FALSE)
cant_draw_graphics_error(a,"Error was for terrain type",t_to_draw);
}
else {
if (a.not_legit() == FALSE)
if (place_icon_into_3D_sidebar(a,to_rect,scen_data.scen_ter_types[t_to_draw].icon_offset_x,
scen_data.scen_ter_types[t_to_draw].icon_offset_y) == FALSE)
cant_draw_graphics_error(a,"Error was for terrain type",t_to_draw);
//draw second icon if it exists
/* a.which_icon = scen_data.scen_ter_types[t_to_draw].second_icon;
if (a.not_legit() == FALSE)
if (place_icon_into_ter_3D_large(a,at_point_center_x + scen_data.scen_ter_types[t_to_draw].second_icon_offset_x,
at_point_center_y + scen_data.scen_ter_types[t_to_draw].second_icon_offset_y) == FALSE)
cant_draw_graphics_error(a,"Error was for terrain type",t_to_draw);
*/
}
}
Boolean place_icon_into_3D_sidebar(graphic_id_type icon, RECT to_rect, short unscaled_offset_x, short unscaled_offset_y)
{
RECT from_rect;
graphic_id_type a = icon;
OffsetRect(&to_rect,(unscaled_offset_x * TER_BUTTON_SIZE) / PICT_BOX_WIDTH_3D,
(unscaled_offset_y * TER_BUTTON_SIZE) / PICT_BOX_HEIGHT_3D);
short index = safe_get_index_of_sheet(&a);
if (index < 0) {
return FALSE;
}
SetRECT(from_rect,1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 10),1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 10),
1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 10) + PICT_BOX_WIDTH_3D,1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 10) + PICT_BOX_HEIGHT_3D);
HDIB src_gworld = graphics_library[index];
if ( from_rect.top >= DibHeight( src_gworld ) ) // check the icon exists on the sheet, simplified version
return TRUE; // actually FALSE
adjust_graphic(&src_gworld,&from_rect,a.graphic_adjust);
rect_draw_some_item(src_gworld,from_rect,terrain_buttons_gworld,to_rect,1,0);
return TRUE;
}
Boolean place_icon_into_ter_3D_large(graphic_id_type icon,short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect,short lighting)
{
RECT to_rect;
RECT from_rect;
graphic_id_type a;
SetRECT(to_rect,at_point_center_x,at_point_center_y,
at_point_center_x + PICT_BOX_WIDTH_3D,at_point_center_y + PICT_BOX_HEIGHT_3D);
OffsetRect(&to_rect, -PICT_BOX_WIDTH_3D / 2, -PICT_BOX_HEIGHT_3D / 2);
if(!rects_touch(&to_rect,to_whole_area_rect))
return TRUE;
a = icon;
short index = safe_get_index_of_sheet(&a);
if (index < 0) {
//cant_draw_graphics_error(a);
return FALSE;
}
SetRECT(from_rect,1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 10),1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 10),
1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 10) + PICT_BOX_WIDTH_3D,1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 10) + PICT_BOX_HEIGHT_3D);
HDIB src_gworld = graphics_library[index];
adjust_graphic(&src_gworld,&from_rect,a.graphic_adjust);
apply_lighting_to_graphic(&src_gworld,&from_rect,lighting);
rect_draw_some_item(src_gworld,from_rect,ter_draw_gworld,to_rect,1,0);
return TRUE;
}
Boolean place_creature_icon_into_ter_3D_large(graphic_id_type icon,short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect,short lighting,short r,short g,short b)
{
RECT to_rect;
RECT from_rect;
graphic_id_type a;
SetRECT(to_rect,at_point_center_x,at_point_center_y,
at_point_center_x + PICT_BOX_WIDTH_3D,at_point_center_y + PICT_BOX_HEIGHT_3D);
OffsetRect(&to_rect, -PICT_BOX_WIDTH_3D / 2, -PICT_BOX_HEIGHT_3D / 2);
if(!rects_touch(&to_rect,to_whole_area_rect))
return TRUE;
a = icon;
short index = safe_get_index_of_sheet(&a);
if (index < 0) {
//cant_draw_graphics_error(a);
return FALSE;
}
SetRECT(from_rect,1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 10),1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 10),
1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 10) + PICT_BOX_WIDTH_3D,1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 10) + PICT_BOX_HEIGHT_3D);
HDIB src_gworld = graphics_library[index];
adjust_graphic(&src_gworld,&from_rect,a.graphic_adjust);
apply_lighting_to_graphic(&src_gworld,&from_rect,lighting);
if(cur_viewing_mode != 11)
add_border_to_graphic(&src_gworld,&from_rect,r,g,b);
rect_draw_some_item(src_gworld,from_rect,ter_draw_gworld,to_rect,1,0);
return TRUE;
}
Boolean place_cliff_icon_into_ter_3D_large(short sheet,short at_point_center_x,short at_point_center_y, short direction,RECT *to_whole_area_rect,short lighting)//direction: 0: east/west 1: NW/SE 2:north/south
{
RECT to_rect;
RECT from_rect;
graphic_id_type a;
SetRECT(to_rect,at_point_center_x,at_point_center_y,
at_point_center_x + PICT_BOX_WIDTH_3D,at_point_center_y + PICT_BOX_HEIGHT_3D);
OffsetRect(&to_rect, -PICT_BOX_WIDTH_3D / 2, -PICT_BOX_HEIGHT_3D / 2);
if(!rects_touch(&to_rect,to_whole_area_rect))
return TRUE;
a.which_sheet = sheet;
if(direction == 2) {//north/south
a.which_icon = 0;
}
else {
a.which_icon = 1;
}
short index = safe_get_index_of_sheet(&a);
if (index < 0) {
//cant_draw_graphics_error(a);
return FALSE;
}
SetRECT(from_rect,1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 10),1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 10),
1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 10) + PICT_BOX_WIDTH_3D,1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 10) + PICT_BOX_HEIGHT_3D);
if(direction == 1) {//NW/SE
from_rect.right = from_rect.right - PICT_BOX_WIDTH_3D + 4;
to_rect.right = to_rect.right - PICT_BOX_WIDTH_3D + 4;
OffsetRect(&to_rect,22,0);
}
else if(direction == 0) {//east/west
from_rect.left = from_rect.left + 4;
to_rect.left = to_rect.left + 4;
}
HDIB src_gworld = graphics_library[index];
apply_lighting_to_graphic(&src_gworld,&from_rect,lighting);
rect_draw_some_item(src_gworld,from_rect,ter_draw_gworld,to_rect,1,0);
return TRUE;
}
Boolean place_item_icon_into_ter_3D_large(graphic_id_type icon,short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect,short lighting)
{
RECT to_rect;
RECT from_rect;
graphic_id_type a;
SetRECT(to_rect,at_point_center_x,at_point_center_y,
at_point_center_x + ITEM_BOX_SIZE_3D,at_point_center_y + ITEM_BOX_SIZE_3D);
OffsetRect(&to_rect, -ITEM_BOX_SIZE_3D / 2, -ITEM_BOX_SIZE_3D / 2);
if(!rects_touch(&to_rect,to_whole_area_rect))
return TRUE;
a = icon;
short index = safe_get_index_of_sheet(&a);
if (index < 0) {
//cant_draw_graphics_error(a);
return FALSE;
}
SetRECT(from_rect,1 + (ITEM_BOX_SIZE_3D + 1) * (a.which_icon % 10),1 + (ITEM_BOX_SIZE_3D + 1) * (a.which_icon / 10),
1 + (ITEM_BOX_SIZE_3D + 1) * (a.which_icon % 10) + ITEM_BOX_SIZE_3D,1 + (ITEM_BOX_SIZE_3D + 1) * (a.which_icon / 10) + ITEM_BOX_SIZE_3D);
HDIB src_gworld = graphics_library[index];
adjust_graphic(&src_gworld,&from_rect,a.graphic_adjust);
apply_lighting_to_graphic(&src_gworld,&from_rect,lighting);
rect_draw_some_item(src_gworld,from_rect,ter_draw_gworld,to_rect,1,0);
return TRUE;
}
Boolean place_outdoor_creature_icon_into_ter_3D_large(graphic_id_type icon,short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect,short lighting)
{
RECT to_rect;
RECT from_rect;
graphic_id_type a;
SetRECT(to_rect,at_point_center_x,at_point_center_y + PICT_BOX_HEIGHT_3D - OUTDOOR_CREATURE_HEIGHT_3D,
at_point_center_x + OUTDOOR_CREATURE_WIDTH_3D,at_point_center_y + PICT_BOX_HEIGHT_3D);
OffsetRect(&to_rect, -PICT_BOX_WIDTH_3D / 2, -PICT_BOX_HEIGHT_3D / 2);
if(!rects_touch(&to_rect,to_whole_area_rect))
return TRUE;
a = icon;
short index = safe_get_index_of_sheet(&a);
if (index < 0) {
//cant_draw_graphics_error(a);
return FALSE;
}
SetRECT(from_rect,1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 4),1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 4),
1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 4) + OUTDOOR_CREATURE_WIDTH_3D,1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 4) + OUTDOOR_CREATURE_HEIGHT_3D);
HDIB src_gworld = graphics_library[index];
adjust_graphic(&src_gworld,&from_rect,a.graphic_adjust);
apply_lighting_to_graphic(&src_gworld,&from_rect,lighting);
rect_draw_some_item(src_gworld,from_rect,ter_draw_gworld,to_rect,1,0);
return TRUE;
}
Boolean place_corner_wall_icon_into_ter_3D_large(graphic_id_type icon,short at_point_center_x,short at_point_center_y,Boolean left_side_of_template,RECT *to_whole_area_rect,short lighting)
{
RECT to_rect;
RECT from_rect;
graphic_id_type a;
SetRECT(to_rect,at_point_center_x,at_point_center_y,
at_point_center_x + PICT_BOX_WIDTH_3D,at_point_center_y + PICT_BOX_HEIGHT_3D);
OffsetRect(&to_rect, -PICT_BOX_WIDTH_3D / 2, -PICT_BOX_HEIGHT_3D / 2);
if(!rects_touch(&to_rect,to_whole_area_rect))
return TRUE;
a = icon;
short index = safe_get_index_of_sheet(&a);
if (index < 0) {
//cant_draw_graphics_error(a);
return FALSE;
}
SetRECT(from_rect,1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 10),1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 10),
1 + (PICT_BOX_WIDTH_3D + 1) * (a.which_icon % 10) + PICT_BOX_WIDTH_3D,1 + (PICT_BOX_HEIGHT_3D + 1) * (a.which_icon / 10) + PICT_BOX_HEIGHT_3D);
if(left_side_of_template) {
from_rect.right -= PICT_BOX_WIDTH_3D / 2;
to_rect.right -= PICT_BOX_WIDTH_3D / 2;
}
else {
from_rect.left += PICT_BOX_WIDTH_3D / 2;
to_rect.left += PICT_BOX_WIDTH_3D / 2;
}
HDIB src_gworld = graphics_library[index];
apply_lighting_to_graphic(&src_gworld,&from_rect,lighting);
rect_draw_some_item(src_gworld,from_rect,ter_draw_gworld,to_rect,1,0);
return TRUE;
}
void place_ter_icon_on_tile_3D(short at_point_center_x,short at_point_center_y,short position,short which_icon,RECT *to_whole_area_rect)
{
//too bad, there's no room left
if(position > 9)
return;
RECT tiny_to = {at_point_center_x - 8, at_point_center_y - 4, at_point_center_x -8 + 16, at_point_center_y - 4 + 11};
OffsetRect(&tiny_to,-8 * (position % 3) + 8 * (position / 3),6 * (position % 3) + 6 * (position / 3));
if(!rects_touch(&tiny_to,to_whole_area_rect))
return;
RECT tiny_from = base_small_3D_button_from;
OffsetRect(&tiny_from,16 * (which_icon % 10),11 * (which_icon / 10));
rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,1,0);
}
void draw_ter_script_3D(short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect)
{
RECT ter_script_icon_from = {160,143,183,157};
RECT to_rect = {at_point_center_x, at_point_center_y + 7, at_point_center_x + 23, at_point_center_y + 7 + 14};
if(rects_touch(&to_rect,to_whole_area_rect))
rect_draw_some_item(editor_mixed,ter_script_icon_from,ter_draw_gworld,to_rect,1,0);
}
void place_ter_icons_3D(location which_outdoor_sector, outdoor_record_type *drawing_terrain, short square_x, short square_y,short t_to_draw, short floor_to_draw, short at_point_center_x,short at_point_center_y,RECT *to_whole_area_rect)
{
location loc_drawn;
loc_drawn.x = (char)square_x;
loc_drawn.y = (char)square_y;
short i;
short small_icon_position = 0;
if (editing_town) {
// draw ter scripts
for (i = 0; i < NUM_TER_SCRIPTS; i++) {
if (town.ter_scripts[i].exists && same_point(town.ter_scripts[i].loc,loc_drawn) ) {
draw_ter_script_3D(at_point_center_x,at_point_center_y,to_whole_area_rect);
}
}
}
// now place the tiny icons in the lower right corner
// first, stuff that is done for both town and outdoors
/*
//I don't think either of these is necessary for users understanding. Their only 'purpose' is to look bad.
// signs
if (scen_data.scen_ter_types[t_to_draw].special == 39) {
place_ter_icon_on_tile_3D(at_point_center_x,at_point_center_y,small_icon_position,20);
small_icon_position++;
}
//containers
if (scen_data.scen_ter_types[t_to_draw].special == 40) {
place_ter_icon_on_tile_3D(at_point_center_x,at_point_center_y,small_icon_position,21);
small_icon_position++;
} */
// icons for secret doors
if (((t_to_draw >= 18) && (t_to_draw <= 21)) || ((t_to_draw >= 54) && (t_to_draw <= 57))) {
place_ter_icon_on_tile_3D(at_point_center_x,at_point_center_y,small_icon_position,26,to_whole_area_rect);
small_icon_position++;
}
// icons for floor damage
if ((scen_data.scen_ter_types[t_to_draw].special == 1) ||
(scen_data.scen_floors[floor_to_draw].special == 1)) {
place_ter_icon_on_tile_3D(at_point_center_x,at_point_center_y,small_icon_position,37,to_whole_area_rect);
small_icon_position++;
}
if ((scen_data.scen_ter_types[t_to_draw].special == 2) ||
(scen_data.scen_floors[floor_to_draw].special == 2)) {
place_ter_icon_on_tile_3D(at_point_center_x,at_point_center_y,small_icon_position,38,to_whole_area_rect);
small_icon_position++;
}
if ((scen_data.scen_ter_types[t_to_draw].special == 3) ||
(scen_data.scen_floors[floor_to_draw].special == 3)) {
place_ter_icon_on_tile_3D(at_point_center_x,at_point_center_y,small_icon_position,39,to_whole_area_rect);
small_icon_position++;
}
if ((scen_data.scen_ter_types[t_to_draw].special == 6) ||
(scen_data.scen_floors[floor_to_draw].special == 6)) {
place_ter_icon_on_tile_3D(at_point_center_x,at_point_center_y,small_icon_position,22,to_whole_area_rect);
small_icon_position++;
}
// then town only tiny icons
if (editing_town) {
for (i = 0; i < 4; i++) {
if (same_point(loc_drawn,town.start_locs[i])) {
place_ter_icon_on_tile_3D(at_point_center_x,at_point_center_y,small_icon_position,i,to_whole_area_rect);