Codebase list lgeneral / debian/1.4.3-1 src / gui.h
debian/1.4.3-1

Tree @debian/1.4.3-1 (Download .tar.gz)

gui.h @debian/1.4.3-1raw · history · blame

  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
/***************************************************************************
                          gui.h  -  description
                             -------------------
    begin                : Sun Mar 31 2002
    copyright            : (C) 2001 by Michael Speck
    email                : kulkanie@gmx.net
 ***************************************************************************/

/***************************************************************************
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef __GUI_H
#define __GUI_H

#include "unit.h"
#include "windows.h"

struct _List;

/*
====================================================================
Button ids
====================================================================
*/
enum {
    ID_INTERN_UP = -1000,
    ID_INTERN_DOWN,
    ID_MENU = 0,
    ID_SCEN_INFO,
    ID_AIR_MODE,
    ID_UNIT_LIST,
    ID_DEPLOY,
    ID_STRAT_MAP,
    ID_END_TURN,
    ID_CONDITIONS,
    ID_PURCHASE,
    ID_OK,
    ID_CANCEL,
    ID_SUPPLY,
    ID_EMBARK_AIR,
    ID_MERGE,
    ID_UNDO,
    ID_RENAME,
    ID_DISBAND,
    ID_SPLIT,
    ID_SPLIT_1,
    ID_SPLIT_2,
    ID_SPLIT_3,
    ID_SPLIT_4,
    ID_SPLIT_5,
    ID_SPLIT_6,
    ID_SPLIT_7,
    ID_SPLIT_8,
    ID_SPLIT_9,
    ID_SPLIT_10,
    ID_APPLY_DEPLOY,
    ID_CANCEL_DEPLOY,
    ID_DEPLOY_UP,
    ID_DEPLOY_DOWN,
    ID_SAVE,
    ID_LOAD,
    ID_RESTART,
    ID_CAMP,
    ID_SCEN,
    ID_OPTIONS,
    ID_QUIT,
    ID_LOAD_0,
    ID_LOAD_1,
    ID_LOAD_2,
    ID_LOAD_3,
    ID_LOAD_4,
    ID_LOAD_5,
    ID_LOAD_6,
    ID_LOAD_7,
    ID_LOAD_8,
    ID_LOAD_9,
    ID_LOAD_10,
    ID_SAVE_0,
    ID_SAVE_1,
    ID_SAVE_2,
    ID_SAVE_3,
    ID_SAVE_4,
    ID_SAVE_5,
    ID_SAVE_6,
    ID_SAVE_7,
    ID_SAVE_8,
    ID_SAVE_9,
    ID_SAVE_10,
    ID_C_SUPPLY,
    ID_C_WEATHER,
    ID_C_SHOW_CPU,
    ID_C_SHOW_STRENGTH,
    ID_C_SOUND,
    ID_C_SOUND_INC,
    ID_C_SOUND_DEC,
    ID_C_MUSIC,
    ID_C_GRID,
    ID_C_VMODE,
    ID_SCEN_OK,
    ID_SCEN_CANCEL,
    ID_SCEN_FOG,
    ID_SCEN_SUPPLY,
    ID_SCEN_WEATHER,
    ID_SCEN_DEPLOYTURN,
    ID_SCEN_PURCHASE,
    ID_SCEN_SWITCHCTRL1,
    ID_SCEN_SWITCHCTRL2,
    ID_CAMP_OK,
    ID_CAMP_CANCEL,
    ID_SETUP_OK, /* old setup dialog now in scenario */
    ID_SETUP_FOG,
    ID_SETUP_SUPPLY,
    ID_SETUP_WEATHER,
    ID_SETUP_DEPLOYTURN,
    ID_SETUP_PURCHASE,
    ID_SETUP_CTRL,
    ID_SETUP_MODULE,
    ID_MODULE_OK,
    ID_MODULE_CANCEL,
    ID_PURCHASE_OK,
    ID_PURCHASE_EXIT,
    ID_PURCHASE_REFUND,
    ID_VMODE_OK,
    ID_VMODE_CANCEL
};

/*
====================================================================
GUI graphics, fonts and windows.
====================================================================
*/
typedef struct {
    char *name;         /* directory name of gui */
    Font *font_std;
    Font *font_status;
    Font *font_error;
    Font *font_turn_info;
    Font *font_brief;
    Image *cursors;
    Label *label, *label2;
    Frame *qinfo1, *qinfo2; /* unit quick infos */
    Frame *finfo; /* full unit info */
    Frame *sinfo; /* scenario information */
    Frame *unit_list;
    Frame *panel;
    MMView *minimap;
    Group *unit_buttons; /* unit action buttons */
    Group *split_menu; /* menu of number of units to split up */
    Group *confirm; /* confirmation window */
    PurchaseDlg *purchase_dlg;
    Group *deploy_window;
    Edit *edit;
    Group *base_menu; /* basic menu (switch airmode, deploy, end turn, menu ...) */
    Group *main_menu; /* main game menu */
    Group *opt_menu;  /* options */
    Group *load_menu;
    Group *save_menu;
    SelectDlg *vmode_dlg;
    SDlg *scen_dlg;    /* scenario selection */
    FDlg *camp_dlg;    /* campaign selection */
    /* frame tiles */
    SDL_Surface *fr_luc, *fr_llc, *fr_ruc, *fr_rlc, *fr_hori, *fr_vert;
    SDL_Surface *brief_frame;   /* briefing window */
    SDL_Surface *bkgnd;         /* background for briefing window and main menu */
    SDL_Surface *wallpaper;     /* wallpaper used if background doesn't fill the whole screen */
    SDL_Surface *folder_icon;   /* folder icon for file list */
    /* sounds */
#ifdef WITH_SOUND
    Wav *wav_click;
    Wav *wav_edit;
#endif
    /* misc */
    int mirror_asymm; /* mirror asymmetric windows to look behind */
} GUI;

struct MessagePane;

/*
====================================================================
Create the gui and use the graphics in gfx/themes/path
====================================================================
*/
SDL_Surface *gui_create_frame( int w, int h );
int gui_load( const char *path );
void gui_delete();

/*
====================================================================
Move all windows to there proper position according to screen's
measurements.
====================================================================
*/
void gui_adjust();

/*
====================================================================
Change all GUI graphics to the one found in gfx/theme/path.
====================================================================
*/
int gui_change( const char *path );

/*
====================================================================
Hide/draw from/to screen or get backgrounds
====================================================================
*/
void gui_get_bkgnds();
void gui_draw_bkgnds();
void gui_draw();

/*
====================================================================
Set cursor.
====================================================================
*/
enum {
    CURSOR_STD = 0,
    CURSOR_SELECT,
    CURSOR_ATTACK,
    CURSOR_MOVE,
    CURSOR_MOUNT,
    CURSOR_DEBARK,
    CURSOR_EMBARK,
    CURSOR_MERGE,
    CURSOR_DEPLOY,
    CURSOR_UNDEPLOY,
    CURSOR_UP,
    CURSOR_DOWN,
    CURSOR_LEFT,
    CURSOR_RIGHT,
    CURSOR_COUNT
};
void gui_set_cursor( int type );

/*
====================================================================
Handle events.
====================================================================
*/
int gui_handle_motion( int cx, int cy );
int  gui_handle_button( int button_id, int cx, int cy, Button **button );
void gui_update( int ms );

/*
====================================================================
Set quick info frame with information on this unit and set hide = 0.
====================================================================
*/
void gui_show_quick_info( Frame *qinfo, Unit *unit );

/*
====================================================================
Draw the expected losses to the label.
====================================================================
*/
void gui_show_expected_losses( Unit *att, Unit *def, int att_dam, int def_dam );

/*
====================================================================
Draw the actual losses to the label.
====================================================================
*/
void gui_show_actual_losses( Unit *att, Unit *def, 
    int att_suppr, int att_dam, int def_suppr, int def_dam );
    
/*
====================================================================
Draw the given unit's strength or suppression to the given label
====================================================================
*/
void gui_show_unit_results( Unit *unit, Label *label, int is_str, int dam );

/*
====================================================================
Show full info window.
====================================================================
*/
void gui_show_full_info( Unit *unit );

/*
====================================================================
Show scenario info window.
====================================================================
*/
void gui_show_scen_info();

/*
====================================================================
Show explicit victory conditions and use scenario info window for
this.
====================================================================
*/
void gui_show_conds();

/*
====================================================================
Show confirmation window.
====================================================================
*/
void gui_show_confirm( const char *text );

/*
====================================================================
Show unit buttons at screen x,y (does not include the button check)
====================================================================
*/
void gui_show_unit_buttons( int x, int y );

/** Show unit purchase dialogue. */
void gui_show_purchase_window();

/*
====================================================================
Show deploy window and select first unit as 'deploy_unit'.
====================================================================
*/
void gui_show_deploy_window();

/*
====================================================================
Handle deploy window.
  gui_handle_deploy_motion: 'unit' is the unit the cursor is 
      currently above
  gui_handle_deploy_click: 'new_unit' is set True if a new unit was
      selected (which is 'deploy_unit' ) else False
      return True if something happended
====================================================================
*/
int gui_handle_deploy_click( int button, int cx, int cy );
void gui_handle_deploy_motion( int cx, int cy, Unit **unit );

/*
====================================================================
Scroll deploy list up/down.
====================================================================
*/
void gui_scroll_deploy_up();
void gui_scroll_deploy_down();

/*
====================================================================
Update deploy list. Unit is either removed or added to 
left_deploy_units and the deploy window is updated.
====================================================================
*/
void gui_remove_deploy_unit( Unit *unit );
void gui_add_deploy_unit( Unit *unit );

/*
====================================================================
Show base menu at screen x,y (does not include the button check)
====================================================================
*/
void gui_show_menu( int x, int y );

/*
====================================================================
Update save slot names.
====================================================================
*/
void gui_update_slot_tooltips();

/*
====================================================================
Render the file name to surface. (directories start with an
asteriks)
====================================================================
*/
void gui_render_file_name( void *item, SDL_Surface *buffer );

/*
====================================================================
Handle the selection of a scenario file (display info and 
load scen_info from full path)
====================================================================
*/
void gui_render_scen_info( const char *path, SDL_Surface *buffer );

/*
====================================================================
Handle the selection of a campaign file (display info and 
load scen_info from full path)
====================================================================
*/
void gui_render_camp_info( const char *path, SDL_Surface *buffer );

/*
====================================================================
Creates a new message pane structure.
====================================================================
*/
struct MessagePane *gui_create_message_pane();

/*
====================================================================
Deletes the given message pane structure.
====================================================================
*/
void gui_delete_message_pane(struct MessagePane *pane);

/*
====================================================================
Sets the text for the message pane.
====================================================================
*/
void gui_set_message_pane_text( struct MessagePane *pane, const char *text );

/*
====================================================================
Sets the default id for the message pane.
====================================================================
*/
void gui_set_message_pane_default( struct MessagePane *pane, const char *default_id );

/*
====================================================================
Returns the currently selected id or 0 if nothing is selected.
====================================================================
*/
const char *gui_get_message_pane_selection( struct MessagePane *pane );

/*
====================================================================
Fills in options for the given message pane.
ids const char * list of ids
descs const char * list of textual description being mapped to ids.
====================================================================
*/
void gui_set_message_pane_options( struct MessagePane *pane, struct _List *ids, struct _List *descs );

/*
====================================================================
Draws and fills with text the message pane.
====================================================================
*/
void gui_draw_message_pane( struct MessagePane *pane );

/*
====================================================================
Handles events on the message pane.
pane - message pane data
mx, my - screen coordinates of mouse
button - mouse button
pressed - 1 if mouse button was pressed, 0 if released (undefined
	if button is BUTTON_NONE)
====================================================================
*/
void gui_handle_message_pane_event( struct MessagePane *pane, int mx, int my, int button, int pressed );

/*
====================================================================
Open scenario setup and set first player as selected.
====================================================================
*/
void gui_open_scen_setup();

/*
====================================================================
Render the player name in the scenario setup
====================================================================
*/
void gui_render_player_name( void *item, SDL_Surface *buffer );

/*
====================================================================
Handle the selection of a player in setup.
====================================================================
*/
void gui_handle_player_select( void *item );

/*
====================================================================
Load a module's info
====================================================================
*/
void gui_render_module_info( const char *path, SDL_Surface *buffer );

/*
====================================================================
Mirror position of asymmetric windows.
====================================================================
*/
void gui_mirror_asymm_windows();

/** Show video mode selection */
void gui_vmode_dlg_show();

/*
====================================================================
Unit list stuff
TODO: use a proper list for displaying and scrolling through units
XXX: gui_unit_list_unit_clicked doubles the code from gui_render_unit_list
XXX: in some functions tags is now character array, that's more simple than
     list but that may cause stack smashing
====================================================================
*/
SDL_Surface * gui_prepare_unit_list();
void gui_show_unit_list();
void gui_hide_unit_list();
void gui_render_unit_list(SDL_Surface * contents,List * units);
void gui_scroll_unit_list_up(List * units);
void gui_scroll_unit_list_down(List * units);
Unit *gui_unit_list_unit_clicked(List * units,int cx,int cy);

/** Show/hide GUI. Buttons are not checked */
void gui_panel_hide();
void gui_panel_show();
void gui_resize_panel();

/* Update(=render) minimap */
void gui_init_minimap();
void gui_update_minimap(int full);

#endif