1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 1997, 2005 - 3D Realms Entertainment
4 
5 This file is part of Shadow Warrior version 1.2
6 
7 Shadow Warrior is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 
16 See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 
22 Original Source: 1997 - Frank Maddin and Jim Norwood
23 Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
24 */
25 //-------------------------------------------------------------------------
26 
27 // MENUS.H
28 // Contains type definitions for all pop up menus
29 
30 #ifndef _MENUS_PUBLIC_
31 #define _MENUS_PUBLIC_
32 
33 #define MENU_SHADE_DEFAULT 0
34 #define MENU_SHADE_INACTIVE 20
35 
36 typedef enum {
37         ct_mainmenu, ct_savemenu, ct_loadmenu, ct_soundmenu, ct_optionmenu, ct_quickloadmenu,
38         ct_quitmenu, ct_ordermenu, ct_episodemenu, ct_max
39 } CTLType;
40 
41 extern BOOL UsingMenus;
42 extern BOOL ForceMenus;     // Force menus to be opened in lieu of user instigation.
43 extern int SENSITIVITY;
44 extern CTLType ControlPanelType;
45 extern SHORT MenuTextShade;
46 extern SHORT MenuTextPalette;
47 
48 // Prototypes
49 //void MNU_DoMenu( CTLType type, PLAYERp pp );
50 void MNU_InitMenus( void );
51 //void (*CustomRefresh)(void);
52 //void MNU_Refresh( void );
53 void MNU_DrawMenu( void );  // This is used in drawscreen to refresh menus in
54                             // multiplay situations.
55 void MNU_CheckForMenus( void );
56 void MNU_CheckForMenusAnyKey(void );
57 void MNU_MeasureString(const char *string, short *w, short *h);
58 void MNU_DrawString(short x, short y, const char *string, short shade, short pal);
59 void MNU_MeasureSmallString(const char *string,short *w,short *h);
60 void MNU_DrawSmallString(short x,short y,const char *string,short shade,short pal);
61 void MNU_MeasureStringLarge(const char *string, short *w, short *h);
62 void MNU_DrawStringLarge(short x, short y, const char *string);
63 
64 // Functions from my other engine
65 //void Get_Palette (unsigned char *pal);
66 //void Set_Palette(unsigned char *buff);
67 //void Fade_Timer(int clicks);
68 void FadeIn( unsigned char targetcolor, unsigned int clicks );
69 void FadeOut( unsigned char targetcolor, unsigned int clicks );
70 VOID ResetPalette(PLAYERp pp);
71 
72 void ExitMenus(void );
73 VOID ResetMenuInput(VOID);
74 
75 #define BUTTONSET(x,value) \
76     (\
77     ((x)>31) ?\
78     (CONTROL_ButtonState2 |= (value<<((x)-32)))  :\
79     (CONTROL_ButtonState1 |= (value<<(x)))\
80     )
81 
82 extern BOOL BorderAdjust;
83 extern int FXDevice,MusicDevice;
84 extern BOOL MultiPlayQuitFlag;
85 
86 // Make memcpy an intrinsic function for an easy frame rate boost
87 //#pragma intrinsic( memcpy );
88 
89 // L O C A L   V A R I A B L E S ////////////////////////////////////////////////////////////////
90 
91 // Default menu pic brightness
92 #define m_defshade      2
93 
94 #define FLASHTIME       60      // One second per icon flash
95 
96 // Defines for permanentwritesprite clipping box
97 #define M_CX1   0
98 #define M_CY1   0
99 #define M_CX2   319
100 #define M_CY2   199
101 
102 #define MZ              65536
103 
104 #define asc_Esc         27
105 #define asc_Enter       13
106 #define asc_Space       32
107 
108 
109 #define pic_none 0
110 #define pic_radiobuttn1 2816
111 #define pic_radiobuttn2 2817
112 #define pic_newgame 2819
113 #define pic_load 2820
114 #define pic_save 2821
115 #define pic_options 2822
116 #define pic_orderinfo 2823
117 #define pic_todemo 2824
118 #define pic_togame 2825
119 #define pic_quit 2826
120 #define pic_newgametitl 2827
121 #define pic_training 2828
122 #define pic_easy 2829
123 #define pic_normal 2830
124 #define pic_hard 2831
125 #define pic_impossible 2832
126 #define pic_optionstitl 2833
127 #define pic_endgame 2834
128 #define pic_detail 2835
129 #define pic_high 2836
130 #define pic_low 2837
131 #define pic_mousesense 2838
132 #define pic_soundvol 2839
133 #define pic_toggles 2845
134 #define pic_togglestitl 2844
135 #define pic_mousenable 2840
136 #define pic_joyenable 2841
137 #define pic_bobbing 2842
138 #define pic_slidelend 2846
139 #define pic_slidebar 2847
140 #define pic_sliderend 2848
141 #define pic_sliderknob 2849
142 #define pic_shuriken1 2850
143 #define pic_yinyang 2870
144 #define pic_soundtitl 2870
145 #define pic_sndfxvol 2871
146 #define pic_musicvol 2872
147 #define pic_episode1 2873
148 #define pic_episode2 2874
149 #define pic_episode3 2875
150 #define pic_modem 2876
151 #define pic_scrsize 2877
152 #define pic_loadsavecursor 2918
153 #define pic_loadgame 2915
154 #define pic_savegame 2916
155 #define pic_loading 2917
156 #define pic_loadsavescreen 2919
157 #define pic_loadsavescreenbak 2922
158 #define pic_savedescr 2924
159 #define pic_shadow_warrior 2366
160 
161 // This is the current values set with all slider bar functions
162 #define SENSE_DEFAULT   10  // Default mouse sensitivity ** should be 5!!!
163 #define FXVOL_DEFAULT   8   // Default sound fx volume
164 #define MUSIC_DEFAULT   8   // Default music volume
165 #define SCRSIZE_DEFAULT 9   // Default screen size, max is 10
166 #define BRIGHTNESS_DEFAULT 0 // Default is no gamma-correction
167 #define BORDERTILE_DEFAULT 0 // Default is no gamma-correction
168 #define GAMETYPE_DEFAULT 0  // Regular DeathMatch
169 #define NETLEVEL_DEFAULT 0  // Default is level 1 (0)
170 #define MONSTERS_DEFAULT 0  // No Monsters
171 #define KILLLIMIT_DEFAULT 0 // No kill limit
172 #define TIMELIMIT_DEFAULT 0 // None
173 #define PLAYERCOLOR_DEFAULT 0
174 #define PANELSCALE_DEFAULT (8-1)
175 
176 typedef enum
177     {
178     sldr_none,
179     sldr_mouse, sldr_sndfxvolume, sldr_musicvolume, sldr_scrsize, sldr_brightness,
180     sldr_bordertile, sldr_gametype, sldr_netlevel, sldr_monsters, sldr_killlimit,
181     sldr_timelimit, sldr_playercolor, sldr_videores, sldr_videobpp,
182     sldr_mousescalex, sldr_mousescaley,
183     sldr_joyaxisscale, sldr_joyaxisanalog, sldr_joyaxisdead, sldr_joyaxissatur,
184     sldr_panelscale,
185     sldr_max
186     } SLDRType;
187 
188 
189 #define MAX_SLDR_WIDTH	16	// maximum size of slider before x is compressed
190 
191 #define SLDR_MOUSESENSEMAX              20
192 #define SLDR_SNDFXVOLMAX                16
193 #define SLDR_MUSICVOLMAX                16
194 #define SLDR_SCRSIZEMAX                 14
195 #define SLDR_BRIGHTNESSMAX              8
196 #define SLDR_BORDERTILEMAX              (isShareware ? 21 : 38)	// counted from border.c
197 #define SLDR_GAMETYPEMAX                3
198 #define SLDR_PANELSCALEMAX              8
199 
200 #define SLDR_NETLEVELMAX_REG             28
201 #define SLDR_NETLEVELMAX_SW              4
202 #define SLDR_NETLEVELMAX                (isShareware ? SLDR_NETLEVELMAX_SW : SLDR_NETLEVELMAX_REG)
203 
204 #define SLDR_MONSTERSMAX                5   // Skill Levels
205 #define SLDR_KILLLIMITMAX               11  // Increments of 10 up to 100, 1 is no limit
206 #define SLDR_TIMELIMITMAX               9
207 #define SLDR_PLAYERCOLORMAX             8   // Up to 8 players different colors
208 
209 
210 #define MOUSE_SENS_MAX_VALUE (1<<16)
211 #define MUSIC_VOL_MAX_VALUE 255
212 #define FX_VOL_MAX_VALUE 255
213 
214 // These are all the toggle button settings
215 typedef enum
216     {
217     btn_none, btn_auto_run, btn_crosshair, btn_auto_aim,
218     btn_mouse_aim, btn_messages, btn_mouse_invert, btn_bobbing, btn_shadows,
219     btn_sound, btn_music, btn_talking, btn_ambience, btn_flipstereo,
220     btn_res0, btn_res1, btn_res2, btn_res3, btn_res4, btn_res5, btn_res6,
221     btn_markers, btn_teamplay, btn_friendlyfire,btn_parental,btn_nuke,
222     btn_voxels, btn_stats, btn_playcd,
223     btn_videofs, btn_texfilter,
224     btn_joyaxis_invert,
225     btn_max
226     } BTNType;
227 
228 typedef enum
229     {
230     mf_normal = BIT(0),
231     mf_pushed = BIT(1),
232     mf_selected = BIT(2),
233     mf_disabled = BIT(3),
234     mf_separated = BIT(4)
235     } MenuFlags;
236 
237 #define MenuSelectFlags (mf_pushed | mf_selected | mf_disabled)
238 #define MenuDrawFlags (ROTATE_SPRITE_SCREEN_CLIP)
239 
240 typedef enum
241     {
242     mt_none,
243     mt_inert, mt_slider, mt_button, mt_option, mt_layer
244     } MenuTag;
245 
246 typedef enum
247     {
248     uc_setup,
249     uc_draw,        // Draw the menu from scratch.
250     uc_touchup,     // Draw adornments on a conventional menu.
251     uc_hit
252     } UserCall;
253 
254 typedef struct MENU_ITEM
255     {
256     MenuTag type;                       // What kind of item is this on the
257                                         // menu?
258     MenuFlags flags;                    // Menu item flags
259     SLDRType slider;                    // Slider type, if any
260     BTNType button;                     // Button state, if any
261     unsigned char hotkey;               // First letter of item
262     char *text;                         // Text appearing in item, if any.
263     void *child;                        // Should be menugroup, used to spawn
264                                         // sub-groups from items.
265     int x, y;                          // x,y position on screen.
266     short pic;                        // Startpic to use
267     char shade;                         // Shade of pic
268     int tics;                          // Ticcount for item
269      BOOL(*custom) (void);              // Work function on item select
270 
271      BOOL (*preprocess)(struct MENU_ITEM *);
272      BOOL (*postprocess)(struct MENU_ITEM *); // Can do things on items select
273     } MenuItem, *MenuItem_p;
274 
275 typedef struct
276     {
277     int x, y;                          // Menu x,y position on screen.
278     char *text;
279     MenuItem_p items;                   // Array of menu items for this menu.
280     short titlepic;                   // Used to draw title on menu with.
281     short cursorpic;                  // Pic used for menu cursor, 1st in
282                                         // anim sequence if animated.
283     char shade;                         // Title pic shade
284 
285      BOOL(*draw_custom) (UserCall, MenuItem *);      // Custom routine
286      BOOL(*move_custom) (UserCall, MenuItem *);      // Custom routine
287 
288     short cursor;                       // This is the current menu item the
289                                         // cursor is resting on.
290     } MenuGroup, *MenuGroup_p;
291 
292 // Custom Routine Prototypes ////////////////////////////////////////////////////////////////////
293 
294 BOOL MNU_QuitCustom(UserCall call, MenuItem * item);
295 BOOL MNU_QuickLoadCustom(UserCall call, MenuItem * item);
296 BOOL MNU_LoadSaveTouchupCustom(UserCall call, MenuItem * item);
297 BOOL MNU_DoParentalPassword(UserCall call, MenuItem * item);
298 BOOL MNU_DoPlayerName(UserCall call, MenuItem * item);
299 BOOL MNU_OrderCustom(UserCall call, MenuItem * item);
300 BOOL MNU_DoEpisodeSelect(UserCall call, MenuItem * item);
301 
302 BOOL MNU_MusicFxCheck(MenuItem_p item);
303 BOOL MNU_MusicCheck(MenuItem_p item);
304 BOOL MNU_FxCheck(MenuItem_p item);
305 BOOL MNU_TexFilterCheck(MenuItem_p item);
306 BOOL MNU_MouseCheck(MenuItem_p item);
307 BOOL MNU_JoystickCheck(MenuItem_p item);
308 BOOL MNU_BorderCheck(MenuItem_p item);
309 BOOL MNU_ShareWareCheck(MenuItem_p item);
310 BOOL MNU_MenuLevelCheck(MenuItem_p item);
311 BOOL MNU_ShareWareMessage(MenuItem_p item);
312 
313 // Custom MenuItem Routines /////////////////////////////////////////////////////////////////////
314 
315 BOOL MNU_StartGame(void);
316 BOOL MNU_StartNetGame(void);
317 BOOL MNU_EpisodeCustom(void);
318 BOOL MNU_GetDescripCustom(void);
319 BOOL MNU_LoadGameCustom(void);
320 BOOL MNU_SaveGameCustom(void);
321 BOOL MNU_GetLoadCustom(void);
322 BOOL MNU_GetSaveCustom(void);
323 BOOL MNU_PlayerNameCustom(void);
324 BOOL MNU_ParentalCustom(void);
325 BOOL MNU_KeySetupCustom(UserCall call, MenuItem *item);
326 BOOL MNU_LoadModernDefaults(void);
327 BOOL MNU_LoadClassicDefaults(void);
328 BOOL MNU_ApplyVideoModeSettings(void);
329 
330 // Menu Definitions /////////////////////////////////////////////////////////////////////////////
331 
332 #define DefInert(key,text)          mt_inert,mf_normal,sldr_none,btn_none,key,text,NULL
333 #define DefSlider(slider,key,text)  mt_slider,mf_normal,slider,btn_none,key,text,NULL
334 #define DefOption(key,text)         mt_option,mf_normal,sldr_none,btn_none,key,text,NULL
335 #define DefButton(button,key,text)  mt_button,mf_normal,sldr_none,button,key,text,NULL
336 #define DefLayer(key,text,child)    mt_layer,mf_normal,sldr_none,btn_none,key,text,child
337 
338 #define DefDisabled(key,text,child)    mt_layer,mf_disabled,sldr_none,btn_none,key,text,child
339 #define DefNone mt_none,0,0,0,0,NULL,NULL,0,0,0,0,0,NULL,NULL,NULL
340 
341 #define OPT_XS 30
342 #define OPT_YS 30
343 #define OPT_XSIDE (OPT_XS + 120)
344 #define OPT_YINC 10
345 #define OPT_LINE(line) (OPT_YS + (OPT_YINC * (line)))
346 
347 typedef struct
348 {
349 int x,y,bpp,fs;
350 }VMODE;
351 
352 #endif
353