19 extern Boolean play_sounds
,cursor_shown
,dialog_not_toast
,block_erase
;
20 extern HBITMAP mixed_gworld
, pc_stats_gworld
, item_stats_gworld
, text_area_gworld
;
21 extern HBITMAP storage_gworld
,terrain_screen_gworld
,text_bar_gworld
,orig_text_bar_gworld
,buttons_gworld
;
22 extern HBITMAP party_template_gworld
,items_gworld
,tiny_obj_gworld
,fields_gworld
;
23 extern HBITMAP dlg_buttons_gworld
,spec_scen_g
;
24 extern HBITMAP pcs_gworld
,dlogpics_gworld
;
25 extern HFONT fantasy_font
,font
,italic_font
,underline_font
,bold_font
,tiny_font
,small_bold_font
;
29 extern HANDLE store_hInstance
;
30 long FAR PASCAL _export
WndProc (HWND
, UINT
, UINT
, LONG
);
31 extern Boolean modeless_exists
[18];
32 extern HWND modeless_dialogs
[18];
36 extern HBITMAP anim_gworld
,pcs_gworld
;
37 extern HBITMAP map_gworld
,mixed_gworld
;
38 extern HBITMAP button_num_gworld
;
39 extern HBITMAP terrain_screen_gworld
, buttons_gworld
, text_screen_gworld
,text_bar_gworld
,orig_text_bar_gworld
;
40 extern HBITMAP pc_info_screen_gworld
,orig_pc_info_screen_gworld
,terrain_gworld
, party_template_gworld
;
41 extern HBITMAP monster_template_gworld
;
42 extern HBITMAP startmsc_gworld
;
43 extern short far terrain_pic
[256];
47 extern unsigned char m_pic_index_x
[200];
48 extern unsigned char m_pic_index_y
[200];
49 extern unsigned char m_pic_index
[200];
51 short current_key
= 0;
52 short far dlg_keys
[ND
];
53 short far dlg_types
[ND
];
56 short far dlg_highest_item
[ND
];
57 Boolean dlg_draw_ready
[ND
];
59 short far item_dlg
[NI
];
60 short far item_number
[NI
];
61 char far item_type
[NI
];
62 RECT far item_rect
[NI
];
63 short far item_flag
[NI
];
64 char far item_active
[NI
];
65 char far item_key
[NI
];
66 short far item_label
[NI
];
67 short far item_label_loc
[NI
];
69 char far text_long_str
[10][256];
70 char far text_short_str
[140][35];
71 char far labels
[NL
][25];
72 Boolean far label_taken
[NL
];
75 HWND store_edit_parent
; // kludgy
76 FARPROC edit_proc
,old_edit_proc
;
78 HDC dlg_force_dc
= NULL
; // save HDCs when dealing with dlogs
80 short store_free_slot
,store_dlog_num
;
83 short available_dlog_buttons
[NUM_DLOG_B
] = {0,63,64,65,1,4,5,8,
90 66,69,70, 71,72,73,74,79,
91 80,83,86,87,88, 91,92,93,99,100,
92 101,102,104, 129,130,131,132,133,134,135,136,137};
93 short button_type
[150] = {1,1,4,5,1,1,0,0,1,1,
94 1,1,1,1,1,1,1,1,8,8,
95 9,9,9,1,1,2,1,6,7,1,
96 1,12,1,1,2,0,0,0,0,0,
97 0,0,0,0,0,0,0,0,0,0,
98 0,1,1,1,2,1,1,1,2,2, // 50
99 1,1,1,1,1,1,2,3,1,1,
100 1,1,1,1,2,2,2,2,2,1,
101 1,1,1,1,2,2,1,1,1,2,
102 0,1,1,1,14,13,12,12,12,1,
103 1,1,1,2,1,2,2,2,2,1, // 100
104 2,2,2,2,2,2,2,2,2,2,
105 2,2,2,2,2,2,2,2,1,1,
106 1,1,1,1,1,1,1,1,0,0,
107 0,0,0,0,0,0,0,0,0,0};
108 char *button_strs
[150] = {"Done ","Ask"," "," ","Keep", "Cancel","+","-","Buy","Leave",
109 "Get","1","2","3","4","5","6","Cast"," "," ",
110 " "," "," ","Buy","Sell","Other Spells","Buy x10"," "," ","Save",
111 "Race","Train","Items","Spells","Heal Party","1","2","3","4","5",
112 "6","7","8","9","10","11","12","13","14","15",
113 /*50*/ "16","Take","Create","Delete","Race/Special","Skill","Name","Graphic","Bash Door","Pick Lock",
114 "Leave","Steal","Attack","OK","Yes","No","Step In"," ","Record","Climb",
115 "Flee","Onward","Answer","Drink","Approach","Mage Spells","Priest Spells","Advantages","New Game","Land",
116 "Under","Restore","Restart","Quit","Save First","Just Quit","Rest","Read","Pull","Alchemy",
117 "17","Push","Pray","Wait","","","Delete","Graphic","Create","Give",
118 /*100*/ "Destroy","Pay","Free","Next Tip","Touch", "Select Icon","Create/Edit","Clear Special","Edit Abilities","Choose",
119 "Go Back","Create New","General","One Shots","Affect PCs","If-Thens","Town Specs","Out Specs","Advanced","Weapon Abil",
120 "General Abil.","NonSpell Use","Spell Usable","Reagents","Missiles","Abilities","Pick Picture","Animated","Enter","Burn",
121 "Insert","Remove","Accept","Refuse","Open","Close","Sit","Stand","","",
122 "18","19","20","Invisible!","","","","","",""};
124 short far button_left_adj
[150] = {0,0,0,0,0, 0,0,0,0,0,
125 0,0,0,0,0, 0,0,0,0,0,
126 0,0,0,0,0, 0,0,0,0,0,
127 0,0,0,0,0, 0,0,0,0,0,
128 0,0,0,0,0, 0,0,0,0,0,
129 0,0,0,0,0, 0,0,0,0,0, // 50
130 0,0,0,0,0, 0,0,0,0,0,
131 0,0,0,0,0, 0,0,0,0,0,
132 0,0,0,0,0, 0,0,0,0,0,
133 0,0,0,0,0, 0,0,0,0,0,
134 0,0,0,0,0, 0,0,0,0,0,
135 0,0,0,0,0, 0,0,0,0,0,
136 0,0,0,0,0, 0,0,0,0,0,
137 0,0,0,0,0, 0,0,0,0,0,
138 0,0,0,0,0, 0,0,0,0,0};
139 char button_def_key
[150] = {0,0,20,21,'k', 24,0,0,0,0,
140 'g','1','2','3','4', '5','6',0,0,0,
141 0,0,0,0,0,' ',0,22,23,0,
142 0,0,0,0,0,'1','2','3','4','5',
143 '6','7','8','9','a', 'b','c','d','e','f',
144 'g',0,0,0,0,0,0,0,0,0,
145 0,0,0,0,'y','n',0,'?','r',0,
146 0,0,0,0,0,0,0,0,0, 0,
147 0,0,0,0,0,0,0,0,0,0,
148 'g',0,0,0,0,0,0,0,0,0,
149 0,0,0,0,0,0,0,0,0,0,
150 0,0,0,0,0,0,0,0,0,0,
151 0,0,0,0,0,0,0,0,0,0,
152 0,0,0,0,0,0,0,0,0,0,
155 // specials ... 20 - <- 21 - -> 22 up 23 down 24 esc
156 // 25-30 ctrl 1-6 31 - return\
158 short button_ul_x
[15] = {0,46,0,126,0, 0,126,126,126,138, 166,0,0,126,172};
159 short button_ul_y
[15] = {0,0,132,23,46, 69,46,69,36,36, 36,23,92,92,0};
160 short button_width
[15] = {23,63,102,16,63, 63,63,63,6,14, 14,63,63,63,30};
161 short button_height
[15] = {23,23,23,13,23, 23,23,23,6,10,10,23,40,40,30};
163 BOOL FAR PASCAL _export dummy_dialog_proc
164 (HWND hDlg
, UINT message
, UINT wParam
, LONG lParam
);
165 long FAR PASCAL _export
fresh_edit_proc(HWND hwnd
, UINT message
, UINT wParam
, LONG lParam
);
170 extern char szAppName
[];
171 extern char szWinName
[];
173 void cd_init_dialogs()
177 for (i
= 0; i
< ND
; i
++) {
181 dlg_highest_item
[i
] = 0;
183 for (i
= 0; i
< NI
; i
++) {
186 for (i
= 0; i
< NL
; i
++) {
187 label_taken
[i
] = FALSE
;
189 d_proc
= MakeProcInstance((FARPROC
) dummy_dialog_proc
,store_hInstance
);
190 edit_proc
= MakeProcInstance ((FARPROC
) fresh_edit_proc
,store_hInstance
);
193 long FAR PASCAL _export
fresh_edit_proc(HWND hwnd
, UINT message
, UINT wParam
, LONG lParam
)
198 if (wParam
== VK_RETURN
)
199 SendMessage(store_edit_parent
,WM_COMMAND
,9,0);
200 if (wParam
== VK_ESCAPE
)
201 SendMessage(store_edit_parent
,WM_COMMAND
,8,0);
204 return CallWindowProc(old_edit_proc
,hwnd
,message
,wParam
,lParam
);
207 short cd_create_dialog_parent_num(short dlog_num
,short parent
)
211 if ((parent
== 0) || (parent
== 1))
212 return cd_create_dialog(dlog_num
,mainPtr
);
213 i
= cd_get_dlg_index(parent
);
216 return cd_create_dialog(dlog_num
,dlgs
[i
]);
220 short cd_create_custom_dialog(HWND parent
,
221 char *str_block
,short pic_num
,short buttons
[3])
224 short i
,j
,free_slot
= -1,free_item
= -1,str_width
,cur_but_right
= 0;
232 short cur_item
= 1,cur_bottom
= 8;
233 short but_items
[3] = {-1,-1,-1};
234 RECT measure_rect
,pic_rect
= {8,8,44,44},cur_text_rect
= {50,2,0,0};
235 short win_width
= 100, win_height
= 100;
237 for (i
= 0; i
< 256; i
++) {
238 strs
[0][i
] = str_block
[i
];
239 strs
[1][i
] = str_block
[i
+ 256];
240 strs
[2][i
] = str_block
[i
+ 512];
241 strs
[3][i
] = str_block
[i
+ 768];
242 strs
[4][i
] = str_block
[i
+ 1024];
243 strs
[5][i
] = str_block
[i
+ 1280];
246 if (parent
!= NULL
) {
247 if (IsWindowEnabled(parent
) == 0)
250 store_dlog_num
= 900;
251 //store_parent = parent;
252 for (i
= 0; i
< ND
; i
++) {
253 if ((dlg_keys
[i
] >= 0) && (dlg_types
[i
] == 900))
256 for (i
= 0; i
< ND
; i
++) {
257 if (dlg_keys
[i
] < 0) {
265 // quick check, to make sure there's at least 1 button
266 if ((buttons
[0] < 0) && (buttons
[1] < 0) && (buttons
[2] < 0))
269 dlg_keys
[free_slot
] = current_key
;
270 dlg_types
[free_slot
] = 900;
271 dlg_highest_item
[free_slot
] = 1;
272 dlg_draw_ready
[free_slot
] = FALSE
;
273 dlgs
[free_slot
] = NULL
;
275 // first, create dummy dlog
276 store_free_slot
= free_slot
;
277 // dlg = GetNewDialog (900, NIL, IN_FRONT);
278 // dlgs[free_slot] = dlg;
279 // if (dlgs[free_slot] == NULL) {
284 dlgs
[free_slot
] = CreateWindow (szWinName
,
295 if (dlgs
[free_slot
] == NULL
) {
300 dlg_parent
[free_slot
] = parent
;
302 //process_new_window (dlgs[free_slot]);
303 // instead of this, custom make items
306 // first, do 1-3 buttons
307 for (i
= 0; i
< 3; i
++)
308 if (buttons
[i
] >= 0) {// buttons
309 for (j
= 150; j
< NI
; j
++)
310 if (item_dlg
[j
] < 0) {
314 item_dlg
[free_item
] = store_dlog_num
;
315 item_type
[free_item
] = (i
== 0) ? 1 : 0;
316 item_number
[free_item
] = cur_item
;
317 //item_rect[free_item] = get_item_rect(hDlg,i + 1);
319 item_flag
[free_item
] = available_dlog_buttons
[buttons
[i
]];
320 item_active
[free_item
] = 1;
321 item_label
[free_item
] = 0;
322 item_label_loc
[free_item
] = -1;
323 item_key
[free_item
] = button_def_key
[available_dlog_buttons
[buttons
[i
]]];
325 item_key
[free_item
] = 31;
326 but_items
[i
] = free_item
; // remember this to set item rect later
329 // next, the upper left picture (always there)
330 for (j
= 150; j
< NI
; j
++)
331 if (item_dlg
[j
] < 0) {
335 item_dlg
[free_item
] = store_dlog_num
;
336 item_type
[free_item
] = 5;
337 item_number
[free_item
] = cur_item
;
338 item_rect
[free_item
] = pic_rect
;
341 item_flag
[free_item
] = pic_num
* -1;
343 else //if (pic_num < 1000)
344 item_flag
[free_item
] = pic_num
;
345 // else item_flag[free_item] = (pic_num % 1000) + 2400;
346 // if (pic_num >= 2000)
347 // item_flag[free_item] += 300;
348 item_active
[free_item
] = 1;
349 item_label
[free_item
] = 0;
350 item_label_loc
[free_item
] = -1;
351 item_key
[free_item
] = 0;
354 // finally, 0-6 text, first do preprocessing to find out how much room we need
355 for (i
= 0; i
< 6; i
++)
356 total_len
+= string_length((char *) strs
[i
],main_dc
);
357 total_len
= total_len
* 12;
358 str_width
= 100 + 20;
359 //print_nums(0,total_len,str_width);
362 cur_text_rect
.right
= cur_text_rect
.left
+ str_width
;
363 // finally, 0-6 text, then create the items
364 for (i
= 0; i
< 6; i
++)
365 if (strlen((char *) strs
[i
]) > 0) {// text
366 for (j
= 0; j
< 10; j
++)
367 if (item_dlg
[j
] < 0) {
371 item_dlg
[free_item
] = store_dlog_num
;
372 item_type
[free_item
] = 9;
373 item_number
[free_item
] = cur_item
;
374 item_rect
[free_item
] = cur_text_rect
;
375 measure_rect
.top
= 0; measure_rect
.bottom
= 0;
376 measure_rect
.left
= 0; measure_rect
.right
= 340;
377 DrawText(main_dc
, (char *) strs
[i
],strlen((char *) strs
[i
]),
378 &measure_rect
,DT_CALCRECT
| DT_WORDBREAK
);
379 item_rect
[free_item
].bottom
= item_rect
[free_item
].top
+
380 (measure_rect
.bottom
- measure_rect
.top
) + 16;
381 //((string_length((char *) strs[i],main_dc) + 60) / str_width) * 12 + 16;
382 //item_rect[free_item].right += 20;
384 //print_nums(i,string_length((char *) strs[i]),str_width);
385 cur_text_rect
.top
= item_rect
[free_item
].bottom
+ 8;
386 item_flag
[free_item
] = 0;
387 item_active
[free_item
] = 1;
388 item_label
[free_item
] = 0;
389 item_label_loc
[free_item
] = -1;
390 item_key
[free_item
] = 0;
391 sprintf(text_long_str
[free_item
],"%s",
396 dlg_highest_item
[free_slot
] = cur_item
- 1;
398 // finally, do button rects
399 cur_but_right
= cur_text_rect
.right
+ 30;
400 //cur_text_rect.top += 8;
401 for (i
= 0; i
< 3; i
++)
402 if (buttons
[i
] >= 0) {
403 item_rect
[but_items
[i
]].right
= cur_but_right
;
404 item_rect
[but_items
[i
]].top
= cur_text_rect
.top
;
405 item_rect
[but_items
[i
]].bottom
= item_rect
[but_items
[i
]].top
+ 23;
406 if (button_type
[available_dlog_buttons
[buttons
[i
]]] == 1)
407 item_rect
[but_items
[i
]].left
= item_rect
[but_items
[i
]].right
- 63;
408 else item_rect
[but_items
[i
]].left
= item_rect
[but_items
[i
]].right
- 110;
409 cur_but_right
= item_rect
[but_items
[i
]].left
- 4;
411 win_width
= item_rect
[but_items
[i
]].right
+ 6;
412 win_height
= item_rect
[but_items
[i
]].bottom
+ 6;
416 //MoveWindow(dlgs[free_slot],(windRect.right - win_width) / 2,(windRect.bottom - win_width) / 2 + 20,FALSE);
417 //SizeWindow(dlgs[free_slot],win_width,win_height,FALSE);
420 MoveWindow(dlgs
[free_slot
],0,0,win_width
,win_height
,FALSE
);
421 center_window(dlgs
[free_slot
]);
422 ShowWindow(dlgs
[free_slot
],SW_SHOW
);
424 if (dlg_parent
[free_slot
] != NULL
) {
425 EnableWindow(dlg_parent
[free_slot
],FALSE
);
426 if (dlg_parent
[free_slot
] == mainPtr
)
427 for (i
= 0; i
< 18; i
++)
428 if (modeless_exists
[i
] == TRUE
)
429 EnableWindow(modeless_dialogs
[i
],FALSE
);
431 dialog_not_toast
= TRUE
;
436 short cd_create_dialog(short dlog_num
,HWND parent
)
438 short i
,j
,free_slot
= -1,free_item
= -1;
445 if (parent
!= NULL
) {
446 if (IsWindowEnabled(parent
) == 0)
450 store_dlog_num
= dlog_num
;
451 store_parent
= parent
;
453 for (i
= 0; i
< ND
; i
++) {
454 if ((dlg_keys
[i
] >= 0) && (dlg_types
[i
] == dlog_num
))
457 for (i
= 0; i
< ND
; i
++) {
458 if (dlg_keys
[i
] < 0) {
466 dlg_keys
[free_slot
] = current_key
;
467 dlg_types
[free_slot
] = dlog_num
;
468 dlg_highest_item
[free_slot
] = 1;
469 dlg_draw_ready
[free_slot
] = FALSE
;
470 dlgs
[free_slot
] = NULL
;
472 // first, create dummy dlog
473 store_free_slot
= free_slot
;
474 dlg
= CreateDialog(store_hInstance
,MAKEINTRESOURCE(dlog_num
),0,d_proc
);
476 if (dlgs
[free_slot
] == NULL
) {
480 center_window(dlgs
[free_slot
]);
484 dlg_parent
[free_slot
] = parent
;
487 case 958: SetWindowText(dlgs
[free_slot
],"Tip of the Day"); break;
488 case 959: SetWindowText(dlgs
[free_slot
],"Getting a Job"); break;
489 case 960: SetWindowText(dlgs
[free_slot
],"Talking Notes"); break;
490 case 961: SetWindowText(dlgs
[free_slot
],"Adventure Notes"); break;
491 case 962: SetWindowText(dlgs
[free_slot
],"Adventure Journal"); break;
492 case 970: case 971: case 972: case 973: SetWindowText(dlgs
[free_slot
],"Blades of Exile"); break;
493 case 987: SetWindowText(dlgs
[free_slot
],"Getting Items"); break;
494 case 988: SetWindowText(dlgs
[free_slot
],"Casting Simulacrum"); break;
495 case 989: SetWindowText(dlgs
[free_slot
],"Create a Party"); break;
496 case 991: SetWindowText(dlgs
[free_slot
],"Character Statistics"); break;
497 case 996: SetWindowText(dlgs
[free_slot
],"Known Alchemy"); break;
498 case 997: SetWindowText(dlgs
[free_slot
],"Getting Help"); break;
499 case 998: SetWindowText(dlgs
[free_slot
],"Item Information"); break;
500 case 999: SetWindowText(dlgs
[free_slot
],"Monster Stats"); break;
501 case 1012: SetWindowText(dlgs
[free_slot
],"How many?"); break;
502 case 1013: SetWindowText(dlgs
[free_slot
],"Race/Advantages/Disadvantages"); break;
504 case 1010: SetWindowText(dlgs
[free_slot
],"Training a PC"); break;
505 case 1014: SetWindowText(dlgs
[free_slot
],"Reading a Sign"); break;
506 case 1017: SetWindowText(dlgs
[free_slot
],"Blades of Exile"); break;
507 case 1018: SetWindowText(dlgs
[free_slot
],"Select a PC"); break;
508 case 1019: SetWindowText(dlgs
[free_slot
],"Character Statistics"); break;
509 case 1020: SetWindowText(dlgs
[free_slot
],"In a Shop"); break;
510 case 1021: SetWindowText(dlgs
[free_slot
],"Buying Food"); break;
511 case 1047: SetWindowText(dlgs
[free_slot
],"Select Alchemy"); break;
512 case 1048: SetWindowText(dlgs
[free_slot
],"Visiting the Healer"); break;
513 case 1050: SetWindowText(dlgs
[free_slot
],"Pick PC Graphic"); break;
514 case 1051: SetWindowText(dlgs
[free_slot
],"Pick PC Name"); break;
515 case 1073: SetWindowText(dlgs
[free_slot
],"How to Order"); break;
516 case 1075: SetWindowText(dlgs
[free_slot
],"Register Blades of Exile"); break;
517 case 1096: SetWindowText(dlgs
[free_slot
],"Spells Help"); break;
518 case 1097: SetWindowText(dlgs
[free_slot
],"Skills Help"); break;
519 case 1098: SetWindowText(dlgs
[free_slot
],"Cast a Spell"); break;
520 case 1099: SetWindowText(dlgs
[free_slot
],"Preferences"); break;
521 default: SetWindowText(dlgs
[free_slot
],"Blades of Exile"); break;
523 ShowWindow(dlgs
[free_slot
],SW_SHOW
);
524 DestroyWindow(dlg
); //Necesary? Dunno.
526 if (dlg_parent
[free_slot
] != NULL
) {
527 EnableWindow(dlg_parent
[free_slot
],FALSE
);
528 if (dlg_parent
[free_slot
] == mainPtr
)
529 for (i
= 0; i
< 18; i
++)
530 if (modeless_exists
[i
] == TRUE
)
531 EnableWindow(modeless_dialogs
[i
],FALSE
);
533 dialog_not_toast
= TRUE
;
537 BOOL FAR PASCAL _export dummy_dialog_proc
538 (HWND hDlg
, UINT message
, UINT wParam
, LONG lParam
) {
539 short i
,j
,k
,free_slot
= -1,free_item
= -1,type
,flag
;
541 Boolean str_stored
= FALSE
;
543 short win_height
= 0, win_width
= 0;
544 short str_offset
= 1;
546 free_slot
= store_free_slot
;
551 // now, make a window, matching dialog
552 GetWindowRect(hDlg
,&dlg_rect
);
553 dlgs
[store_free_slot
] = CreateWindow (szWinName
,
554 "Blades of Exile Dialog",
558 dlg_rect
.right
- dlg_rect
.left
,
559 dlg_rect
.bottom
- dlg_rect
.top
,
564 // Now, give the window its items
565 for (i
= 0; i
< 200; i
++)
566 if (GetDlgItem(hDlg
,i
) != NULL
) {
567 GetDlgItemText(hDlg
,i
,item_str
,256);
569 dlg_highest_item
[free_slot
] = i
;
571 if (strlen((char *)item_str
) == 0) {
572 sprintf((char *) item_str
, "+");
577 else if (item_str
[0] == '+') { // default is framed text
582 else if (item_str
[0] == '*') {
587 else if (item_str
[0] == '~') {
592 else if (item_str
[0] == '!') {
597 else if (item_str
[0] == '=') {
602 else if (((item_str
[0] >= 65) && (item_str
[0] <= 122)) || (item_str
[0] == '"')) {
608 else if ((item_str
[0] == '^') || (item_str
[0] == '&')) {
609 type
= (item_str
[0] == '^') ? 10 : 11;
611 //if (string_length((char *) item_str) > 55)
615 else sscanf(item_str
,"%d_%d",&type
,&flag
);
620 case 0: case 1: case 2: case 5: case 6:
621 for (j
= 150; j
< NI
; j
++)
622 if (item_dlg
[j
] < 0) {
629 ((str_stored
== TRUE
) && (strlen((char *) item_str
) > 35))) {
630 for (j
= 0; j
< 10; j
++)
631 if (item_dlg
[j
] < 0) {
637 for (j
= 10; j
< 140; j
++)
638 if (item_dlg
[j
] < 0) {
646 if (free_item
>= 0) {
647 item_dlg
[free_item
] = store_dlog_num
;
648 item_type
[free_item
] = type
;
649 item_number
[free_item
] = i
;
651 item_rect
[free_item
] = get_item_rect(hDlg
,i
);
652 item_rect
[free_item
].top
= item_rect
[free_item
].top
/ 2;
653 item_rect
[free_item
].left
= item_rect
[free_item
].left
/ 2;
654 item_rect
[free_item
].bottom
= item_rect
[free_item
].bottom
/ 2;
655 item_rect
[free_item
].right
= item_rect
[free_item
].right
/ 2;
657 if ((type
!= 5) && ((store_dlog_num
>= 2000) || (store_dlog_num
== 986))) {
658 item_rect
[free_item
].top
=
659 (item_rect
[free_item
].top
* 11) / 10;
660 item_rect
[free_item
].bottom
=
661 (item_rect
[free_item
].bottom
* 11) / 10;
664 item_flag
[free_item
] = flag
;
665 item_active
[free_item
] = 1;
666 item_label
[free_item
] = 0;
667 item_label_loc
[free_item
] = -1;
668 item_key
[free_item
] = 0;
672 if (item_flag
[free_item
] != 143) {
673 item_rect
[free_item
].right
= item_rect
[free_item
].left
+ button_width
[button_type
[flag
]];
674 item_rect
[free_item
].bottom
= item_rect
[free_item
].top
+ button_height
[button_type
[flag
]];
676 item_key
[free_item
] = button_def_key
[flag
];
678 item_key
[free_item
] = 31;
682 item_rect
[free_item
].right
= item_rect
[free_item
].left
+ 14;
683 item_rect
[free_item
].bottom
= item_rect
[free_item
].top
+ 10;
684 item_key
[free_item
] = 255;
686 case 3: case 4: case 7: case 8: case 9: case 10: case 11:
687 sprintf(((free_item
< 10) ? text_long_str
[free_item
] : text_short_str
[free_item
- 10]),"");
688 if (str_stored
== TRUE
) {
689 if (free_item
< 10) {
690 sprintf(text_long_str
[free_item
],"%s",
691 (char *) (item_str
+ str_offset
));
692 for (k
= 0; k
< 256; k
++) {
693 if (text_long_str
[free_item
][k
] == '|')
694 text_long_str
[free_item
][k
] = 13;
695 if (text_long_str
[free_item
][k
] == '_')
696 text_long_str
[free_item
][k
] = '"';
698 // give text a little extra room
699 //if ((store_dlog_num >= 2000) || (store_dlog_num == 986))
700 // item_rect[free_item].right += 20;
703 sprintf(text_short_str
[free_item
- 10],"%-34s",
704 (char *) (item_str
+ str_offset
));
705 for (k
= 0; k
< 35; k
++) {
706 if (text_short_str
[free_item
][k
] == '|')
707 text_short_str
[free_item
][k
] = 13;
708 if (text_short_str
[free_item
][k
] == '_')
709 text_short_str
[free_item
][k
] = '"';
713 item_key
[free_item
] = 255;
714 if (type
>= 10) { // never got used
716 //store_rect = dlg_buttons_gworld[1][0]->portRect;
717 //item_rect[free_item].right = item_rect[free_item].left + store_rect.right;
718 //item_rect[free_item].bottom = item_rect[free_item].top + store_rect.bottom;
720 // item_key[free_item] = 31;
725 edit_box
= CreateWindow("edit",NULL
,WS_CHILD
| WS_BORDER
| WS_VISIBLE
,
726 item_rect
[free_item
].left
,item_rect
[free_item
].top
,
727 item_rect
[free_item
].right
- item_rect
[free_item
].left
,
728 item_rect
[free_item
].bottom
- item_rect
[free_item
].top
,
729 dlgs
[free_slot
],150,store_hInstance
,NULL
);
730 store_edit_parent
= dlgs
[free_slot
];
731 old_edit_proc
= (FARPROC
) GetWindowLong(edit_box
,GWL_WNDPROC
);
732 SetWindowLong(edit_box
,GWL_WNDPROC
,(LONG
) edit_proc
);
736 win_height
= max(win_height
, item_rect
[free_item
].bottom
+ 28);
737 win_width
= max(win_width
, item_rect
[free_item
].right
+ 11);
742 MoveWindow(dlgs
[free_slot
],0,0,win_width
,win_height
,FALSE
);
749 void cd_set_edit_focus()
750 { if (edit_box
!= NULL
)
754 short cd_kill_dialog(short dlog_num
,short parent_message
)
756 short i
,which_dlg
= -1;
758 for (i
= 0; i
< ND
; i
++)
759 if ((dlg_keys
[i
] >= 0) && (dlg_types
[i
] == dlog_num
))
764 for (i
= 0; i
< NI
; i
++)
765 if (item_dlg
[i
] == dlog_num
) {
766 if (item_type
[i
] == 6) {
767 DestroyWindow(edit_box
);
770 if (item_label
[i
] > 0)
771 label_taken
[item_label_loc
[i
]] = FALSE
;
775 if (dlg_parent
[which_dlg
] != NULL
) {
776 EnableWindow(dlg_parent
[which_dlg
],TRUE
);
777 if (dlg_parent
[which_dlg
] == mainPtr
)
778 for (i
= 0; i
< 18; i
++)
779 if (modeless_exists
[i
] == TRUE
)
780 EnableWindow(modeless_dialogs
[i
],TRUE
);
781 SetFocus(dlg_parent
[which_dlg
]);
782 SetWindowPos(dlg_parent
[which_dlg
],HWND_TOP
,0,0,100,100,
783 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOREDRAW
);
787 if (parent_message
> 0)
788 SendMessage(dlg_parent
[which_dlg
],WM_COMMAND
,parent_message
,0);
790 DestroyWindow(dlgs
[which_dlg
]);
791 dlg_keys
[which_dlg
] = -1;
792 dialog_not_toast
= TRUE
;
797 short cd_process_click(HWND window
,POINT the_point
, UINT wparam
, LONG lparam
,short *item
)
799 short i
,which_dlg
,dlg_num
,item_id
;
802 if ((which_dlg
= cd_find_dlog(window
,&dlg_num
,&dlog_key
)) < 0)
806 for (i
= 0; i
< dlg_highest_item
[which_dlg
] + 1; i
++)
807 if ((item_id
= cd_get_item_id(dlg_num
,i
)) >= 0) {
808 if ((PtInRect(&item_rect
[item_id
],the_point
)) && (item_active
[item_id
] > 0)
809 && ((item_type
[item_id
] < 3) || (item_type
[item_id
] == 8)
810 || (item_type
[item_id
] == 10)|| (item_type
[item_id
] == 11))) {
812 if (MK_CONTROL
& wparam
)
814 if (item_type
[item_id
] != 8)
815 cd_press_button(dlg_num
,i
);
822 short cd_process_syskeystroke(HWND window
,UINT wparam
, LONG lparam
,short *item
)
824 short i
,which_dlg
,dlg_num
,dlg_key
,item_id
;
828 if ((which_dlg
= cd_find_dlog(window
,&dlg_num
,&dlg_key
)) < 0)
830 // specials ... 20 - <- 21 - -> 22 up 23 down 24 esc
859 for (i
= 0; i
< dlg_highest_item
[which_dlg
] + 1; i
++)
860 if ((item_id
= cd_get_item_id(dlg_num
,i
)) >= 0) {
861 if ((item_key
[item_id
] == char_hit
) && (item_active
[item_id
] > 0)
862 && ((item_type
[item_id
] < 3) || (item_type
[item_id
] == 8))) {
864 if (item_type
[item_id
] != 8)
865 cd_press_button(dlg_num
,i
);
869 // kludgy. If you get an escape and is isn't processed, make it an enter
870 if (wparam
== VK_ESCAPE
) {
872 for (i
= 0; i
< dlg_highest_item
[which_dlg
] + 1; i
++)
873 if ((item_id
= cd_get_item_id(dlg_num
,i
)) >= 0) {
874 if ((item_key
[item_id
] == char_hit
) && (item_active
[item_id
] > 0)
875 && ((item_type
[item_id
] < 3) || (item_type
[item_id
] == 8))) {
877 if (item_type
[item_id
] != 8)
878 cd_press_button(dlg_num
,i
);
887 short cd_process_keystroke(HWND window
,UINT wparam
, LONG lparam
,short *item
)
889 short i
,which_dlg
,dlg_num
,dlg_key
,item_id
;
892 if ((which_dlg
= cd_find_dlog(window
,&dlg_num
,&dlg_key
)) < 0)
894 // specials ... 20 - <- 21 - -> 22 up 23 down 24 esc
897 char_hit
= (char) wparam
;
899 for (i
= 0; i
< dlg_highest_item
[which_dlg
] + 1; i
++)
900 if ((item_id
= cd_get_item_id(dlg_num
,i
)) >= 0) {
901 if ((item_key
[item_id
] == char_hit
) && (item_active
[item_id
] > 0)
902 && ((item_type
[item_id
] < 3) || (item_type
[item_id
] == 8))) {
904 if (item_type
[item_id
] != 8)
905 cd_press_button(dlg_num
,i
);
912 void cd_init_button(short dlog_num
,short item_num
, short button_num
, short status
)
914 short dlg_index
,item_index
;
916 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
918 if (item_type
[item_index
] > 1) {
922 item_flag
[item_index
] = button_num
;
923 item_active
[item_index
] = status
;
924 item_rect
[item_index
].right
= item_rect
[item_index
].left
+ button_width
[button_num
];
925 item_rect
[item_index
].bottom
= item_rect
[item_index
].top
+ button_width
[button_num
];
926 item_key
[item_index
] = button_def_key
[button_num
];
927 cd_draw_item(dlog_num
,item_num
);
930 void cd_attach_key(short dlog_num
,short item_num
,char key
)
932 short dlg_index
,item_index
;
934 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
937 if ((item_type
[item_index
] > 2) && (item_type
[item_index
] != 8)) {
941 item_key
[item_index
] = key
;
944 void cd_set_pict(short dlog_num
, short item_num
, short pict_num
)
946 short dlg_index
,item_index
;
947 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
949 if (item_type
[item_index
] != 5) {
953 item_flag
[item_index
] = pict_num
;
955 cd_erase_item(dlog_num
,item_num
);
956 else cd_draw_item(dlog_num
,item_num
);
959 void cd_activate_item(short dlog_num
, short item_num
, short status
)
961 short dlg_index
,item_index
;
962 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
965 item_active
[item_index
] = status
;
966 cd_draw_item(dlog_num
,item_num
);
969 short cd_get_active(short dlog_num
, short item_num
)
971 short dlg_index
,item_index
;
972 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
975 return item_active
[item_index
];
979 void cd_get_item_text(short dlog_num
, short item_num
, char *str
)
981 short dlg_index
,item_index
;
982 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
984 if (item_type
[item_index
] == 6) {
985 //print_nums(0,0,GetWindowText(edit_box,str,255));
986 if (edit_box
!= NULL
)
987 GetWindowText(edit_box
,str
,255);
988 else sprintf(str
,"");
989 //add_string_to_buf(str);
992 if (item_index
>= 150) {
997 sprintf(str
,"%s",text_long_str
[item_index
]);
998 else sprintf(str
,"%s",text_short_str
[item_index
- 10]);
1001 void cd_get_text_edit_str(short dlog_num
, char *str
)
1003 if (edit_box
!= NULL
)
1004 GetWindowText(edit_box
,str
,255);
1007 // NOTE!!! Expects a c string
1008 void cd_set_text_edit_str(short dlog_num
, char *str
)
1010 if (edit_box
!= NULL
)
1011 SetWindowText(edit_box
,str
);
1013 void cdsin(short dlog_num
, short item_num
, short num
)
1015 cd_set_item_num( dlog_num
, item_num
, num
);
1017 void csit(short dlog_num
, short item_num
, char *str
)
1019 cd_set_item_text( dlog_num
, item_num
, str
);
1021 void csp(short dlog_num
, short item_num
, short pict_num
)
1023 cd_set_pict( dlog_num
, item_num
, pict_num
);
1027 void cd_set_item_text(short dlog_num
, short item_num
, char *str
)
1029 short k
,dlg_index
,item_index
;
1030 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1032 if (item_type
[item_index
] == 6) {
1033 if (edit_box
!= NULL
)
1034 SetWindowText(edit_box
,str
);
1037 if (item_index
>= 150) {
1041 if (item_index
< 10) {
1042 sprintf(text_long_str
[item_index
],"%s",str
);
1043 for (k
= 0; k
< 256; k
++) {
1044 if (text_long_str
[item_index
][k
] == '|')
1045 text_long_str
[item_index
][k
] = 13;
1046 if (text_long_str
[item_index
][k
] == '_')
1047 text_long_str
[item_index
][k
] = '"';
1051 else sprintf(text_short_str
[item_index
- 10],"%-34s",str
);
1052 cd_draw_item( dlog_num
,item_num
);
1055 void cd_set_item_num(short dlog_num
, short item_num
, short num
)
1057 short dlg_index
,item_index
;
1058 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1060 if (item_index
>= 150) {
1064 if (item_index
< 10)
1065 sprintf(text_long_str
[item_index
],"%d",num
);
1066 else sprintf(text_short_str
[item_index
- 10],"%d",num
);
1067 cd_draw_item( dlog_num
,item_num
);
1070 void cd_set_flag(short dlog_num
,short item_num
,short flag
)
1072 short dlg_index
,item_index
;
1074 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1077 item_flag
[item_index
] = flag
;
1078 cd_draw_item(dlog_num
,item_num
);
1081 void cd_set_led(short dlog_num
,short item_num
,short state
)
1083 short dlg_index
,item_index
;
1085 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1088 if (item_type
[item_index
] != 2) {
1092 item_flag
[item_index
] = state
;
1093 cd_draw_item(dlog_num
,item_num
);
1096 short cd_get_led(short dlog_num
,short item_num
)
1098 short dlg_index
,item_index
;
1100 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1103 if (item_type
[item_index
] != 2) {
1107 return item_flag
[item_index
];
1111 void cd_text_frame(short dlog_num
,short item_num
,short frame
)
1113 short dlg_index
,item_index
;
1115 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1118 if (item_index
>= 150) {
1122 item_flag
[item_index
] = frame
;
1123 cd_draw_item(dlog_num
,item_num
);
1126 void cd_add_label(short dlog_num
, short item_num
, char *label
, short label_flag
)
1128 short dlg_index
,item_index
,label_loc
= -1;
1131 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1134 if (item_label_loc
[item_index
] < 0) {
1135 item_label
[item_index
] = label_flag
;
1136 for (i
= 0; i
< 100; i
++)
1137 if (label_taken
[i
] == FALSE
) {
1139 label_taken
[i
] = TRUE
;
1142 if (label_loc
< 0) {
1146 item_label_loc
[item_index
] = label_loc
;
1148 else cd_erase_item(dlog_num
,item_num
+ 100);
1149 label_loc
= item_label_loc
[item_index
];
1150 sprintf((char *) labels
[label_loc
],"%-24s",label
);
1151 if (item_active
[item_index
] > 0)
1152 cd_draw_item(dlog_num
,item_num
);
1155 void cd_take_label(short dlog_num
, short item_num
)
1157 short dlg_index
,item_index
;
1159 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1161 item_label
[item_index
] = 0;
1162 label_taken
[item_label_loc
[item_index
]] = FALSE
;
1165 void cd_key_label(short dlog_num
, short item_num
,short loc
)
1167 short dlg_index
,item_index
;
1169 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1171 sprintf((char *) str
," ");
1172 str
[0] = item_key
[item_index
];
1173 cd_add_label(dlog_num
,item_num
, str
, 7 + loc
* 100);
1176 void cd_draw_item(short dlog_num
,short item_num
)
1178 short dlg_index
,item_index
,store_label
;
1180 COLORREF colors
[4] = {RGB(0,0,0),RGB(255,0,0),RGB(0,0,102),RGB(255,255,255)};
1182 RECT from_rect
,to_rect
;
1185 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1187 if (dlg_draw_ready
[dlg_index
] == FALSE
)
1190 c
[0] = GetNearestPaletteIndex(hpal
,colors
[0]);
1191 c
[1] = GetNearestPaletteIndex(hpal
,colors
[1]);
1192 c
[2] = GetNearestPaletteIndex(hpal
,colors
[2]);
1193 c
[3] = GetNearestPaletteIndex(hpal
,colors
[3]);
1194 win_dc
= cd_get_dlog_dc(dlg_index
);
1195 old_font
= SelectObject(win_dc
,small_bold_font
);
1196 dlg_force_dc
= win_dc
;
1198 if (item_active
[item_index
] == 0) {
1199 cd_erase_item(dlog_num
,item_num
);
1200 cd_erase_item(dlog_num
,item_num
+ 100);
1203 switch (item_type
[item_index
]) {
1204 case 0: case 1: case 10: case 11:
1205 if (item_flag
[item_index
] == 143)
1207 from_rect
.top
= button_ul_y
[button_type
[item_flag
[item_index
]]];
1208 from_rect
.left
= button_ul_x
[button_type
[item_flag
[item_index
]]];
1209 from_rect
.bottom
= from_rect
.top
+ button_height
[button_type
[item_flag
[item_index
]]];
1210 from_rect
.right
= from_rect
.left
+ button_width
[button_type
[item_flag
[item_index
]]];
1211 rect_draw_some_item(dlg_buttons_gworld
,from_rect
,win_dc
,item_rect
[item_index
],0,2);
1213 SelectObject(win_dc
,bold_font
);
1214 SetTextColor(win_dc
,PALETTEINDEX(c
[2]));
1215 if (item_type
[item_index
] < 2)
1216 OffsetRect(&item_rect
[item_index
],-1 * button_left_adj
[item_flag
[item_index
]],0);
1217 if (item_type
[item_index
] < 2) {
1218 char_win_draw_string(win_dc
,item_rect
[item_index
],
1219 (char *) (button_strs
[item_flag
[item_index
]]),1,8);
1222 char_win_draw_string(win_dc
,item_rect
[item_index
],
1223 (char *) ((item_index
< 10) ? text_long_str
[item_index
] :
1224 text_short_str
[item_index
- 10]),1,8);
1226 if (item_type
[item_index
] < 2)
1227 OffsetRect(&item_rect
[item_index
],button_left_adj
[item_flag
[item_index
]],0);
1228 SetTextColor(win_dc
,PALETTEINDEX(c
[0]));
1233 switch (item_flag
[item_index
]) {
1234 case 0: from_rect
.left
= 166; from_rect
.top
= 36; break;
1235 case 1: from_rect
.left
= 152; from_rect
.top
= 36; break;
1236 case 2: from_rect
.left
= 138; from_rect
.top
= 36; break;
1238 from_rect
.right
= from_rect
.left
+ 14;
1239 from_rect
.bottom
= from_rect
.top
+ 10;
1240 rect_draw_some_item( dlg_buttons_gworld
,from_rect
, win_dc
,item_rect
[item_index
],0,2); break;
1243 case 3: case 4: case 7: case 8: case 9:
1244 cd_erase_item(dlog_num
,item_num
);
1245 SetTextColor(win_dc
,PALETTEINDEX(c
[3]));
1246 if ((item_type
[item_index
] == 3) || (item_type
[item_index
] == 9))
1247 SelectObject(win_dc
,small_bold_font
);
1248 if (item_type
[item_index
] == 4)
1249 SelectObject(win_dc
,tiny_font
);
1250 if (item_type
[item_index
] == 7)
1251 SelectObject(win_dc
,bold_font
);
1252 if (item_flag
[item_index
] % 10 == 1)
1253 cd_frame_item(dlog_num
,item_num
,2);
1254 if (item_flag
[item_index
] >= 10) {
1255 SetTextColor(win_dc
,PALETTEINDEX(c
[1]));
1258 if (item_rect
[item_index
].bottom
- item_rect
[item_index
].top
< 20) {
1259 item_rect
[item_index
].left
+= 3;
1260 DrawText(win_dc
,(char *) ((item_index
< 10) ? text_long_str
[item_index
] :
1261 text_short_str
[item_index
- 10]), -1, &item_rect
[item_index
],
1262 DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
| DT_NOCLIP
);
1263 item_rect
[item_index
].left
-= 3;
1266 InflateRect(&item_rect
[item_index
],-4,-4);
1267 DrawText(win_dc
,(char *) ((item_index
< 10) ? text_long_str
[item_index
] :
1268 text_short_str
[item_index
- 10]), -1, &item_rect
[item_index
],
1269 DT_LEFT
| DT_WORDBREAK
| DT_NOCLIP
);
1270 InflateRect(&item_rect
[item_index
],4,4);
1272 SetTextColor(win_dc
,PALETTEINDEX(c
[0]));
1275 if (item_flag
[item_index
] == -1)
1276 cd_erase_item(dlog_num
,item_num
);
1277 else draw_dialog_graphic(dlgs
[dlg_index
], item_rect
[item_index
],
1278 item_flag
[item_index
],(item_flag
[item_index
] >= 2000) ? FALSE
: TRUE
,0);
1283 if (item_label
[item_index
] != 0) {
1284 store_label
= item_label
[item_index
];
1285 if (store_label
>= 1000) {
1286 store_label
-= 1000;
1287 SelectObject(win_dc
,bold_font
);
1289 else SelectObject(win_dc
,tiny_font
);
1290 to_rect
= item_rect
[item_index
];
1291 switch (store_label
/ 100) {
1293 to_rect
.right
= to_rect
.left
;
1294 to_rect
.left
-= 2 * (store_label
% 100);
1297 to_rect
.bottom
= to_rect
.top
;
1298 to_rect
.top
-= 2 * (store_label
% 100);
1301 to_rect
.left
= to_rect
.right
;
1302 to_rect
.right
+= 2 * (store_label
% 100);
1305 to_rect
.top
= to_rect
.bottom
;
1306 to_rect
.bottom
+= 2 * (store_label
% 100);
1310 if (to_rect
.bottom
- to_rect
.top
< 14) {
1311 to_rect
.bottom
+= (14 - (to_rect
.bottom
- to_rect
.top
)) / 2 + 1;
1312 to_rect
.top
-= (14 - (to_rect
.bottom
- to_rect
.top
)) / 2 + 1;
1314 //cd_erase_rect(dlog_num,to_rect);
1315 if (item_active
[item_index
] != 0) {
1316 SetTextColor(win_dc
,PALETTEINDEX(c
[3]));
1318 DrawText(win_dc
, (char *) labels
[item_label_loc
[item_index
]],
1319 -1, &to_rect
, DT_LEFT
| DT_SINGLELINE
| DT_VCENTER
);
1320 SetTextColor(win_dc
,PALETTEINDEX(c
[0]));
1325 // hook in special stuff. kludgy
1326 if ((dlog_num
== 1098) && ((item_num
>= 18) && (item_num
<= 23))) {
1327 draw_pc_effects(10 + item_num
- 18,win_dc
);
1330 SelectObject(win_dc
,old_font
);
1331 cd_kill_dc(dlg_index
,win_dc
);
1332 dlg_force_dc
= NULL
;
1335 void cd_initial_draw(short dlog_num
)
1337 short i
,which_dlg
= -1;
1339 for (i
= 0; i
< ND
; i
++)
1340 if ((dlg_keys
[i
] >= 0) && (dlg_types
[i
] == dlog_num
))
1344 dlg_draw_ready
[which_dlg
] = TRUE
;
1346 cd_erase_item(dlog_num
, 0);
1350 void cd_draw(short dlog_num
)
1352 short i
,which_dlg
= -1;
1354 for (i
= 0; i
< ND
; i
++)
1355 if ((dlg_keys
[i
] >= 0) && (dlg_types
[i
] == dlog_num
))
1360 for (i
= 0; i
< dlg_highest_item
[which_dlg
] + 1; i
++) {
1361 cd_draw_item(dlog_num
,i
);
1365 void cd_redraw(HWND window
)
1367 short which_dlg
,dlg_num
,dlg_key
;
1369 if ((which_dlg
= cd_find_dlog(window
,&dlg_num
,&dlg_key
)) < 0)
1371 dlg_draw_ready
[which_dlg
] = TRUE
;
1372 cd_initial_draw(dlg_num
);
1375 void cd_frame_item(short dlog_num
, short item_num
, short width
)
1377 short dlg_index
,item_index
;
1379 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1381 frame_dlog_rect(dlgs
[dlg_index
], item_rect
[item_index
], width
);
1384 void cd_erase_item(short dlog_num
, short item_num
)
1385 // if item_num is 0, nail whole window
1386 // item_num + 100 just erase label
1388 short i
,dlg_index
,item_index
,store_label
;
1393 Boolean just_label
= FALSE
;
1395 if (item_num
>= 100) {
1400 if (item_num
== 0) {
1401 for (i
= 0; i
< ND
; i
++)
1402 if ((dlg_keys
[i
] >= 0) && (dlg_types
[i
] == dlog_num
))
1404 GetWindowRect(dlgs
[dlg_index
],&to_fry
);
1405 OffsetRect(&to_fry
,-1 * to_fry
.left
,-1 * to_fry
.top
);
1408 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1410 to_fry
= item_rect
[item_index
];
1411 if (just_label
== TRUE
) {
1412 if (item_label
[item_index
] != 0) {
1413 store_label
= item_label
[item_index
];
1414 if (store_label
>= 1000)
1415 store_label
-= 1000;
1417 switch (store_label
/ 100) {
1419 to_fry
.right
= to_fry
.left
;
1420 to_fry
.left
-= 2 * (store_label
% 100);
1423 to_fry
.bottom
= to_fry
.top
;
1424 to_fry
.top
-= 2 * (store_label
% 100);
1427 to_fry
.left
= to_fry
.right
;
1428 to_fry
.right
+= 2 * (store_label
% 100);
1431 to_fry
.top
= to_fry
.bottom
;
1432 to_fry
.bottom
+= 2 * (store_label
% 100);
1435 if ((i
= 12 - (to_fry
.bottom
- to_fry
.top
)) > 0) {
1436 // adjust rect ... but doesn't work for bold letters
1437 to_fry
.bottom
+= i
/ 2;
1438 to_fry
.bottom
++; // extra pixel to get dangly letters
1439 to_fry
.top
-= i
/ 2;
1443 InflateRect(&to_fry
,1,1);
1446 if (dlg_draw_ready
[dlg_index
] == FALSE
)
1448 win_dc
= cd_get_dlog_dc(dlg_index
);
1449 /* old_brush = SelectObject(win_dc,bg[4]);
1450 old_pen = SelectObject(win_dc,GetStockObject(NULL_PEN));
1451 Rectangle(win_dc,to_fry.left, to_fry.top,to_fry.right,to_fry.bottom);
1452 SelectObject(win_dc,old_brush);
1453 SelectObject(win_dc,old_pen); */
1454 paint_pattern(win_dc
,2,to_fry
,0);
1455 cd_kill_dc(dlg_index
,win_dc
);
1461 void cd_erase_rect(short dlog_num
,RECT to_fry
)
1463 short i
,dlg_index
,item_index
,store_label
;
1468 if ((dlg_index
= cd_get_dlg_index(dlog_num
)) < 0)
1470 if (dlg_draw_ready
[dlg_index
] == FALSE
)
1473 win_dc
= cd_get_dlog_dc(dlg_index
);
1474 /* old_brush = SelectObject(win_dc,bg[4]);
1475 old_pen = SelectObject(win_dc,GetStockObject(NULL_PEN));
1476 Rectangle(win_dc,to_fry.left, to_fry.top,to_fry.right,to_fry.bottom);
1477 SelectObject(win_dc,old_brush);
1478 SelectObject(win_dc,old_pen); */
1479 paint_pattern(win_dc
,2,to_fry
,0);
1480 cd_kill_dc(dlg_index
,win_dc
);
1482 // paint_pattern(dlgs[dlg_index],2,to_fry,0);
1485 void cd_press_button(short dlog_num
, short item_num
)
1487 short dlg_index
,item_index
;
1490 RECT from_rect
,to_rect
;
1491 COLORREF colors
[3] = {RGB(0,0,0),RGB(0,0,112),RGB(0,255,255)};
1494 if (cd_get_indices(dlog_num
,item_num
,&dlg_index
,&item_index
) < 0)
1496 // no press action for redio buttons
1497 if ((item_type
[item_index
] == 2) || (item_flag
[item_index
] == 143)) {
1502 c
[0] = GetNearestPaletteIndex(hpal
,colors
[0]);
1503 c
[1] = GetNearestPaletteIndex(hpal
,colors
[1]);
1504 c
[2] = GetNearestPaletteIndex(hpal
,colors
[2]);
1505 win_dc
= cd_get_dlog_dc(dlg_index
);
1506 /* from_rect.top = button_uly[item_flag[item_index]];
1507 from_rect.left = button_ulx[item_flag[item_index]];
1508 from_rect.bottom = from_rect.top + button_height[item_flag[item_index]];
1509 from_rect.right = from_rect.left + button_width[item_flag[item_index]];
1510 OffsetRect(&from_rect,button_width[item_flag[item_index]],0);
1511 rect_draw_some_item(dlgbtns_gworld,from_rect,win_dc,item_rect[item_index],0,2);
1513 if (play_sounds == TRUE) {
1517 else Delay(14,&dummy);
1519 OffsetRect(&from_rect,-1 * button_width[item_flag[item_index]],0);
1520 rect_draw_some_item(dlgbtns_gworld,from_rect,win_dc,item_rect[item_index],0,2);
1523 from_rect
.top
= button_ul_y
[button_type
[item_flag
[item_index
]]];
1524 from_rect
.left
= button_ul_x
[button_type
[item_flag
[item_index
]]];
1525 from_rect
.bottom
= from_rect
.top
+ button_height
[button_type
[item_flag
[item_index
]]];
1526 from_rect
.right
= from_rect
.left
+ button_width
[button_type
[item_flag
[item_index
]]];
1527 OffsetRect(&from_rect
,button_width
[button_type
[item_flag
[item_index
]]],0);
1529 rect_draw_some_item(dlg_buttons_gworld
,from_rect
,win_dc
,item_rect
[item_index
],0,2);
1531 SelectObject(win_dc
,bold_font
);
1532 SetTextColor(win_dc
,PALETTEINDEX(c
[2]));
1533 if (item_type
[item_index
] < 2)
1534 OffsetRect(&item_rect
[item_index
],-1 * button_left_adj
[item_flag
[item_index
]],0);
1535 if (item_type
[item_index
] < 2) {
1536 char_win_draw_string(win_dc
,item_rect
[item_index
],
1537 (char *) (button_strs
[item_flag
[item_index
]]),1,8);
1540 char_win_draw_string(win_dc
,item_rect
[item_index
],
1541 (char *) ((item_index
< 10) ? text_long_str
[item_index
] :
1542 text_short_str
[item_index
- 10]),1,8);
1544 if (item_type
[item_index
] < 2)
1545 OffsetRect(&item_rect
[item_index
],button_left_adj
[item_flag
[item_index
]],0);
1547 if (play_sounds
== TRUE
) {
1551 else Delay(10,&dummy
);
1553 OffsetRect(&from_rect
,-1 * button_width
[button_type
[item_flag
[item_index
]]],0);
1554 rect_draw_some_item(dlg_buttons_gworld
,from_rect
,win_dc
,item_rect
[item_index
],0,2);
1556 SelectObject(win_dc
,bold_font
);
1557 SetTextColor(win_dc
,PALETTEINDEX(c
[1]));
1558 if (item_type
[item_index
] < 2)
1559 OffsetRect(&item_rect
[item_index
],-1 * button_left_adj
[item_flag
[item_index
]],0);
1560 if (item_type
[item_index
] < 2) {
1561 char_win_draw_string(win_dc
,item_rect
[item_index
],
1562 (char *) (button_strs
[item_flag
[item_index
]]),1,8);
1565 char_win_draw_string(win_dc
,item_rect
[item_index
],
1566 (char *) ((item_index
< 10) ? text_long_str
[item_index
] :
1567 text_short_str
[item_index
- 10]),1,8);
1569 if (item_type
[item_index
] < 2)
1570 OffsetRect(&item_rect
[item_index
],button_left_adj
[item_flag
[item_index
]],0);
1572 SelectObject(win_dc
,font
);
1573 SetTextColor(win_dc
,PALETTEINDEX(c
[0]));
1575 cd_kill_dc(dlg_index
,win_dc
);
1580 short cd_get_indices(short dlg_num
, short item_num
, short *dlg_index
, short *item_index
)
1582 if ((*dlg_index
= cd_get_dlg_index(dlg_num
)) < 0) {
1583 //print_nums(1234,dlg_num,item_num);
1587 if ((*item_index
= cd_get_item_id(dlg_num
,item_num
)) < 0) {
1589 //print_nums(5678,dlg_num,item_num);
1595 short cd_get_dlg_index(short dlog_num
)
1599 for (i
= 0; i
< ND
; i
++)
1600 if ((dlg_keys
[i
] >= 0) && (dlg_types
[i
] == dlog_num
))
1605 short cd_find_dlog(HWND window
, short *dlg_num
, short *dlg_key
)
1608 for (i
= 0; i
< ND
; i
++)
1609 if ((dlg_keys
[i
] >= 0) && (dlgs
[i
] == window
)) {
1610 *dlg_num
= dlg_types
[i
];
1611 *dlg_key
= dlg_keys
[i
];
1617 short cd_get_item_id(short dlg_num
, short item_num
)
1621 for (i
= 0; i
< NI
; i
++)
1622 if ((item_dlg
[i
] == dlg_num
) && (item_number
[i
] == item_num
))
1627 HDC
cd_get_dlog_dc(short which_slot
)
1631 win_dc
= GetDC(dlgs
[which_slot
]);
1632 //SelectObject(win_dc,font);
1633 SelectPalette(win_dc
,hpal
,0);
1634 SetBkMode(win_dc
,TRANSPARENT
);
1638 void cd_kill_dc(short which_slot
,HDC hdc
)
1640 fry_dc(dlgs
[which_slot
],hdc
);
1643 // External graphics tools (huh huh huh ... tool ... huh huh huh)
1645 void center_window(HWND window
)
1647 RECT main_rect
,wind_rect
;
1650 cursor_shown
= TRUE
;
1653 GetWindowRect(GetDesktopWindow(),&main_rect
);
1654 GetWindowRect(window
,&wind_rect
);
1655 width
= wind_rect
.right
- wind_rect
.left
;
1656 height
= wind_rect
.bottom
- wind_rect
.top
;
1657 MoveWindow(window
,((main_rect
.right
- main_rect
.left
) - width
) / 2,
1658 ((main_rect
.bottom
- main_rect
.top
) - height
) / 2,width
,height
,TRUE
);
1662 RECT
get_item_rect(HWND hDlg
, short item_num
)
1665 RECT big_rect
,small_rect
;
1667 item
= GetDlgItem(hDlg
, item_num
);
1668 GetWindowRect(hDlg
,&big_rect
);
1669 GetWindowRect(item
,&small_rect
);
1670 OffsetRect(&small_rect
, -1 * big_rect
.left
- 7, -1 * big_rect
.top
- 7);
1671 small_rect
.right
+= 2;
1672 small_rect
.bottom
+= 2;
1677 void frame_dlog_rect(HWND hDlg
, RECT rect
, short val
)
1680 HPEN dpen
,lpen
,old_pen
;
1681 COLORREF x
= RGB(0,204,255),y
= RGB(0,204,255);//y = RGB(119,119,119);
1683 Boolean keep_dc
= FALSE
;
1685 InflateRect(&rect
,val
,val
);
1687 if (hDlg
== mainPtr
) {
1691 else if (dlg_force_dc
!= NULL
) {
1695 else hdc
= GetDC(hDlg
);
1700 SelectPalette(hdc
,hpal
,0);
1701 c
= GetNearestPaletteIndex(hpal
,x
);
1702 lpen
= CreatePen(PS_SOLID
,1,PALETTEINDEX(c
));
1703 c
= GetNearestPaletteIndex(hpal
,y
);
1704 dpen
= CreatePen(PS_SOLID
,1,PALETTEINDEX(c
));
1705 old_pen
= SelectObject(hdc
,dpen
);
1706 MoveTo(hdc
,rect
.left
,rect
.top
);
1707 LineTo(hdc
,rect
.right
,rect
.top
);
1708 SelectObject(hdc
,lpen
);
1709 LineTo(hdc
,rect
.right
,rect
.bottom
);
1710 LineTo(hdc
,rect
.left
,rect
.bottom
);
1711 SelectObject(hdc
,dpen
);
1712 LineTo(hdc
,rect
.left
,rect
.top
);
1713 SelectObject(hdc
,old_pen
);
1714 if (keep_dc
== FALSE
)
1720 void draw_dialog_graphic(HWND hDlg
, RECT rect
, short which_g
, Boolean do_frame
,short win_or_gworld
)
1721 // win_or_gworld: 0 - window 1 - an HBITMAP
1722 // 1 means hDlg is actually an HBITMAP variable!
1723 // 0 - 300 number of terrain graphic
1724 // 400 + x - monster graphic num
1725 // 600 + x item graphic
1726 // 700 + x dlog graphic
1727 // 800 + x pc graphic
1728 // 900 + x B&W graphic
1730 // 1000 + x Talking face
1731 // 1100 - item info help
1732 // 1200 - pc screen help
1734 // 1400-1402 - button help
1735 // 1500 - stat symbols help
1736 // 1600 + x - B&W maps
1737 // 1700 + x - anim graphic
1740 RECT from1
= {0,0,36,28},from2
= {0,0,36,36},from3
= {0,0,72,72},tiny_obj_rect
= {0,0,18,18};
1741 RECT from_rect
= {0,0,28, 36};
1742 RECT face_from
= {0,0,32,32};
1743 RECT death_to
= {6,6,78,78};
1744 RECT to_rect
= {6,6,42,42};
1745 RECT m_to_rect
= {10,6,38,42};
1746 RECT bw_from
= {0,0,120,120};
1747 RECT map_from
= {0,0,240,240};
1749 RECT pc_info_from
= {0,127,106,157};
1750 RECT item_info_from
= {174,0,312,112};
1751 RECT button_help_from
= {0,0,320,100};
1752 RECT combat_ap_from
= {0,0,275,100};
1753 RECT stat_symbols_from
= {0,0,386,94}; /**/
1754 RECT small_monst_rect
= {0,0,14,18};
1755 RECT large_scen_from
= {0,0,64,64};
1757 HBITMAP from_gworld
;
1758 short draw_dest
= 2;
1761 short m_start_pic
= 0,square_size
= 32;
1763 if (win_or_gworld
== 1)
1769 if (which_g
>= 3000)
1771 which_g
= which_g
% 3000;
1773 if (win_or_gworld
== 0) {
1774 if (dlg_force_dc
!= NULL
)
1776 else hdc
= GetDC(hDlg
);
1777 SelectPalette(hdc
,hpal
,0);
1779 if (which_g
== 950) { // Empty. Maybe clear space.
1780 if (win_or_gworld
== 0) {
1781 paint_pattern(hdc
,2,rect
,0);
1783 //old_brush = SelectObject(hdc,bg[5]);
1784 //Rectangle(hdc,rect.left,rect.top,rect.right,rect.bottom);
1785 //SelectObject(hdc,old_brush);
1787 //FillCRect(&rect,bg[5]); // don't forget to nail dc!!!
1788 if (dlg_force_dc
== NULL
)
1793 switch (which_g
/ 100) {
1794 case 0: case 1: case 2: // terrain
1795 from_gworld
= load_pict(800 + which_g
/ 50,main_dc
);
1796 which_g
= which_g
% 50;
1797 from_rect
= calc_rect(which_g
% 10, which_g
/ 10);
1798 if (rect
.right
- rect
.left
!= 28) {
1800 rect
.right
= rect
.left
+ 28;
1802 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
) (hDlg
): hdc
)
1804 DeleteObject(from_gworld
);
1806 case 3: // animated terrain
1808 from_gworld
= load_pict(820,main_dc
);
1809 from_rect
= calc_rect(4 * (which_g
/ 5), which_g
% 5);
1810 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
)hDlg
: hdc
)
1812 DeleteObject(from_gworld
);
1814 case 4: case 5: // monster
1815 // There are 4 different ways to draw, depending on size of monster
1817 m_start_pic
= m_pic_index
[which_g
];
1818 if ((m_pic_index_x
[which_g
] == 1) && (m_pic_index_y
[which_g
] == 1)) {
1819 from_gworld
= load_pict(1100 + m_start_pic
/ 20,main_dc
);
1820 m_start_pic
= m_start_pic
% 20;
1821 from_rect
= calc_rect(2 * (m_start_pic
/ 10), m_start_pic
% 10);
1822 rect
.right
= rect
.left
+ 28; rect
.bottom
= rect
.top
+ 36;
1823 if (win_or_gworld
== 0) {
1824 old_brush
= SelectObject(hdc
,GetStockObject(BLACK_BRUSH
));
1825 Rectangle(hdc
,rect
.left
,rect
.top
,rect
.right
,rect
.bottom
);
1826 SelectObject(hdc
,old_brush
);
1828 if (win_or_gworld
== 1)
1829 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,rect
,0,0);
1830 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,rect
,0,draw_dest
);
1831 DeleteObject(from_gworld
);
1833 if ((m_pic_index_x
[which_g
] == 2) && (m_pic_index_y
[which_g
] == 1)) {
1834 rect
.right
= rect
.left
+ 28; rect
.bottom
= rect
.top
+ 36;
1835 if (win_or_gworld
== 0) {
1836 old_brush
= SelectObject(hdc
,GetStockObject(BLACK_BRUSH
));
1837 Rectangle(hdc
,rect
.left
,rect
.top
,rect
.right
,rect
.bottom
);
1838 SelectObject(hdc
,old_brush
);
1840 from_gworld
= load_pict(1100 + m_start_pic
/ 20,main_dc
);
1841 m_start_pic
= m_start_pic
% 20;
1842 from_rect
= calc_rect(2 * (m_start_pic
/ 10), m_start_pic
% 10);
1843 OffsetRect(&small_monst_rect
,rect
.left
,rect
.top
+ 7);
1845 if (win_or_gworld
== 1)
1846 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,small_monst_rect
,0,0);
1847 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,small_monst_rect
,0,draw_dest
);
1849 m_start_pic
= m_pic_index
[which_g
] + 1;
1850 DeleteObject(from_gworld
);
1851 from_gworld
= load_pict(1100 + m_start_pic
/ 20,main_dc
);
1852 m_start_pic
= m_start_pic
% 20;
1853 from_rect
= calc_rect(2 * (m_start_pic
/ 10), m_start_pic
% 10);
1854 OffsetRect(&small_monst_rect
,14,0);
1856 if (win_or_gworld
== 1)
1857 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,small_monst_rect
,0,0);
1858 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,small_monst_rect
,0,draw_dest
);
1859 DeleteObject(from_gworld
);
1861 if ((m_pic_index_x
[which_g
] == 1) && (m_pic_index_y
[which_g
] == 2)) {
1862 rect
.right
= rect
.left
+ 28; rect
.bottom
= rect
.top
+ 36;
1863 if (win_or_gworld
== 0) {
1864 old_brush
= SelectObject(hdc
,GetStockObject(BLACK_BRUSH
));
1865 Rectangle(hdc
,rect
.left
,rect
.top
,rect
.right
,rect
.bottom
);
1866 SelectObject(hdc
,old_brush
);
1869 from_gworld
= load_pict(1100 + m_start_pic
/ 20,main_dc
);
1870 m_start_pic
= m_start_pic
% 20;
1871 from_rect
= calc_rect(2 * (m_start_pic
/ 10), m_start_pic
% 10);
1872 OffsetRect(&small_monst_rect
,rect
.left
+ 7,rect
.top
);
1874 if (win_or_gworld
== 1)
1875 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,small_monst_rect
,0,0);
1876 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,small_monst_rect
,0,draw_dest
);
1877 m_start_pic
= m_pic_index
[which_g
] + 1;
1878 DeleteObject(from_gworld
);
1879 from_gworld
= load_pict(1100 + m_start_pic
/ 20,main_dc
);
1880 m_start_pic
= m_start_pic
% 20;
1881 from_rect
= calc_rect(2 * (m_start_pic
/ 10), m_start_pic
% 10);
1882 OffsetRect(&small_monst_rect
,0,18);
1884 if (win_or_gworld
== 1)
1885 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,small_monst_rect
,0,0);
1886 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,small_monst_rect
,0,draw_dest
);
1887 DeleteObject(from_gworld
);
1890 if ((m_pic_index_x
[which_g
] == 2) && (m_pic_index_y
[which_g
] == 2)) {
1891 rect
.right
= rect
.left
+ 28; rect
.bottom
= rect
.top
+ 36;
1892 if (win_or_gworld
== 0) {
1893 old_brush
= SelectObject(hdc
,GetStockObject(BLACK_BRUSH
));
1894 Rectangle(hdc
,rect
.left
,rect
.top
,rect
.right
,rect
.bottom
);
1895 SelectObject(hdc
,old_brush
);
1897 from_gworld
= load_pict(1100 + m_start_pic
/ 20,main_dc
);
1898 m_start_pic
= m_start_pic
% 20;
1899 from_rect
= calc_rect(2 * (m_start_pic
/ 10), m_start_pic
% 10);
1900 OffsetRect(&small_monst_rect
,rect
.left
,rect
.top
);
1902 if (win_or_gworld
== 1)
1903 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,small_monst_rect
,0,0);
1904 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,small_monst_rect
,0,draw_dest
);
1906 m_start_pic
= m_pic_index
[which_g
] + 1;
1907 DeleteObject(from_gworld
);
1908 from_gworld
= load_pict(1100 + m_start_pic
/ 20,main_dc
);
1909 m_start_pic
= m_start_pic
% 20;
1910 from_rect
= calc_rect(2 * (m_start_pic
/ 10), m_start_pic
% 10);
1911 OffsetRect(&small_monst_rect
,14,0);
1913 if (win_or_gworld
== 1)
1914 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,small_monst_rect
,0,0);
1915 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,small_monst_rect
,0,draw_dest
);
1917 m_start_pic
= m_pic_index
[which_g
] + 2;
1918 DeleteObject(from_gworld
);
1919 from_gworld
= load_pict(1100 + m_start_pic
/ 20,main_dc
);
1920 m_start_pic
= m_start_pic
% 20;
1921 from_rect
= calc_rect(2 * (m_start_pic
/ 10), m_start_pic
% 10);
1922 OffsetRect(&small_monst_rect
,-14,18);
1924 if (win_or_gworld
== 1)
1925 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,small_monst_rect
,0,0);
1926 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,small_monst_rect
,0,draw_dest
);
1927 m_start_pic
= m_pic_index
[which_g
] + 3;
1928 DeleteObject(from_gworld
);
1929 from_gworld
= load_pict(1100 + m_start_pic
/ 20,main_dc
);
1930 m_start_pic
= m_start_pic
% 20;
1931 from_rect
= calc_rect(2 * (m_start_pic
/ 10), m_start_pic
% 10);
1932 OffsetRect(&small_monst_rect
,14,0);
1934 if (win_or_gworld
== 1)
1935 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,small_monst_rect
,0,0);
1936 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,small_monst_rect
,0,draw_dest
);
1938 DeleteObject(from_gworld
);
1940 case 18: case 19: // item
1944 from_gworld
= items_gworld
;
1945 from_rect
= calc_rect(which_g
% 5, which_g
/ 5);
1948 from_gworld
= tiny_obj_gworld
;
1949 //rect.top += 4; rect.bottom -= 4;
1950 //InflateRect(&to_rect,-5,-9);
1953 to_rect
.right
= to_rect
.left
+ 18;
1954 to_rect
.bottom
= to_rect
.top
+ 18;
1955 from_rect
= tiny_obj_rect
;
1956 OffsetRect(&from_rect
,18 * (which_g
% 10), 18 * (which_g
/ 10));
1958 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
)hDlg
: hdc
)
1959 ,to_rect
,1,draw_dest
);
1963 from_gworld
= dlogpics_gworld
;
1964 OffsetRect(&from2
,36 * (which_g
% 4),36 * (which_g
/ 4));
1965 rect_draw_some_item(from_gworld
,from2
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
)hDlg
: hdc
)
1969 if (pcs_gworld
!= NULL
)
1970 from_gworld
= pcs_gworld
;
1971 else from_gworld
= load_pict(902,main_dc
);
1973 from_rect
= calc_rect(2 * (which_g
/ 8), which_g
% 8);
1974 old_brush
= SelectObject(hdc
,GetStockObject(BLACK_BRUSH
));
1975 Rectangle(hdc
,rect
.left
,rect
.top
,rect
.right
,rect
.bottom
);
1976 SelectObject(hdc
,old_brush
);
1978 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
)hDlg
: hdc
)
1980 if (pcs_gworld
== NULL
)
1981 DeleteObject(from_gworld
);
1985 from_gworld
= load_pict(875,main_dc
);
1986 from_rect
= bw_from
;
1987 OffsetRect(&from_rect
,120 * ((which_g
) % 3),120 * ((which_g
) / 3));
1988 if (win_or_gworld
== 1)
1989 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,rect
,0,0);
1990 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,rect
,0,draw_dest
);
1991 DeleteObject(from_gworld
);
1993 case 10: // talk face
1995 from_gworld
= load_pict(860,main_dc
);
1996 from_rect
= face_from
;
1997 OffsetRect(&from_rect
,32 * ((which_g
- 1) % 10),32 * ((which_g
- 1) / 10));
1998 if (win_or_gworld
== 1)
1999 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) hDlg
,rect
,0,0);
2000 else rect_draw_some_item(from_gworld
,from_rect
,hdc
,rect
,0,draw_dest
);
2001 DeleteObject(from_gworld
);
2003 case 11: // item info help
2004 from_rect
= item_info_from
;
2005 rect
.right
= rect
.left
+ from_rect
.right
- from_rect
.left
;
2006 rect
.bottom
= rect
.top
+ from_rect
.bottom
- from_rect
.top
;
2007 rect_draw_some_item(mixed_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
)hDlg
: hdc
)
2010 case 12: // item info help
2011 from_rect
= pc_info_from
;
2012 rect
.right
= rect
.left
+ pc_info_from
.right
- pc_info_from
.left
;
2013 rect
.bottom
= rect
.top
+ pc_info_from
.bottom
- pc_info_from
.top
;
2014 rect_draw_some_item(mixed_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
)hDlg
: hdc
)
2017 case 14: // button help
2019 if (which_g
>= 10) {
2020 from_gworld
= load_pict(900 + which_g
,main_dc
);
2021 from_rect
= large_scen_from
;
2022 OffsetRect(&from_rect
,64 * (which_g
% 10),0);
2023 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
)hDlg
: hdc
)
2025 DeleteObject(from_gworld
);
2028 from_gworld
= load_pict(1401,main_dc
);
2029 from_rect
= button_help_from
;
2031 rect
.right
= rect
.left
+ from_rect
.right
;
2032 rect
.bottom
= rect
.top
+ from_rect
.bottom
;
2033 OffsetRect(&from_rect
,0,100 * which_g
);
2034 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
)hDlg
: hdc
)
2036 DeleteObject(from_gworld
);
2038 case 13: // combat ap help
2039 from_gworld
= load_pict(1402,main_dc
);
2040 from_rect
= combat_ap_from
;
2041 rect
.right
= rect
.left
+ from_rect
.right
;
2042 rect
.bottom
= rect
.top
+ from_rect
.bottom
;
2043 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
) (hDlg
): hdc
)
2045 DeleteObject(from_gworld
);
2047 case 15: // stat symbols help
2048 from_gworld
= load_pict(1400,main_dc
);
2049 from_rect
= stat_symbols_from
;
2050 rect
.right
= rect
.left
+ from_rect
.right
;
2051 rect
.bottom
= rect
.top
+ from_rect
.bottom
;
2052 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
) (hDlg
): hdc
)
2054 DeleteObject(from_gworld
);
2058 from_gworld
= load_pict(851,main_dc
);
2059 from_rect
.right
= 32;
2060 from_rect
.bottom
= 32;
2061 OffsetRect(&from_rect
,32 * (which_g
% 5),32 * (which_g
/ 5));
2062 rect
.right
= rect
.left
+ 32;
2063 rect
.bottom
= rect
.top
+ 32;
2064 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
) (hDlg
): hdc
)
2066 DeleteObject(from_gworld
);
2070 from_gworld
= fields_gworld
;
2071 from_rect
= calc_rect(which_g
% 8, which_g
/ 8);
2072 if (win_or_gworld
== 0) {
2073 old_brush
= SelectObject(hdc
,GetStockObject(BLACK_BRUSH
));
2074 Rectangle(hdc
,rect
.left
,rect
.top
,rect
.right
,rect
.bottom
);
2075 SelectObject(hdc
,old_brush
);
2079 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
)hDlg
: hdc
)
2082 case 20: case 21: case 22: case 23: // dialog
2084 rect
.right
= rect
.left
+ 28;
2085 rect
.bottom
= rect
.top
+ 36;
2086 from_gworld
= spec_scen_g
;
2087 from_rect
= get_custom_rect(which_g
);
2088 if ((win_or_gworld
== 0) && (do_frame
== TRUE
)) {
2089 old_brush
= SelectObject(hdc
,GetStockObject(BLACK_BRUSH
));
2090 Rectangle(hdc
,rect
.left
,rect
.top
,rect
.right
,rect
.bottom
);
2091 SelectObject(hdc
,old_brush
);
2094 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
) (hDlg
): hdc
)
2095 ,rect
,(do_frame
== FALSE
) ? 1 : 0,draw_dest
);
2097 case 24: case 25: case 26: case 27: // dialog
2099 if (rect
.right
- rect
.left
>= 36)
2101 from_gworld
= spec_scen_g
;
2102 from_rect
= get_custom_rect(which_g
);
2104 to_rect
.right
= to_rect
.left
+ square_size
/ 2;
2105 to_rect
.bottom
= to_rect
.top
+ square_size
;
2106 from_rect
.right
= from_rect
.left
+ square_size
/ 2;
2107 from_rect
.bottom
= from_rect
.top
+ square_size
;
2108 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
) (hDlg
): hdc
)
2109 ,to_rect
,1,draw_dest
);
2110 from_rect
= get_custom_rect(which_g
+ 1);
2111 OffsetRect(&to_rect
,square_size
/ 2,0);
2112 from_rect
.right
= from_rect
.left
+ square_size
/ 2;
2113 from_rect
.bottom
= from_rect
.top
+ square_size
;
2114 rect_draw_some_item(from_gworld
,from_rect
,(HBITMAP
) ((win_or_gworld
== 1) ? (HBITMAP
) (hDlg
): hdc
)
2115 ,to_rect
,1,draw_dest
);
2119 if ((win_or_gworld
== 0) && (dlg_force_dc
== NULL
))
2121 if ((win_or_gworld
== 0) && (do_frame
== TRUE
)){
2122 rect
.bottom
--; rect
.right
--;
2123 frame_dlog_rect(hDlg
,rect
,3);
2127 void showcursor(Boolean a
)
2133 i
= ShowCursor(FALSE
);
2136 i
= ShowCursor(TRUE
);
2143 while ((dialog_not_toast
== TRUE
) && (GetMessage(&msg
,NULL
,0,0))) {
2144 if (!TranslateAccelerator(mainPtr
, accel
, &msg
)) {
2145 TranslateMessage(&msg
);
2146 DispatchMessage(&msg
);
2151 RECT
calc_rect(short i
, short j
)
2153 RECT base_rect
= {0,0,28,36};
2155 OffsetRect(&base_rect
,i
* 28, j
* 36);