Odamex
Setting the Standard in Multiplayer Doom
client/src/m_menu.h
Go to the documentation of this file.
00001 // Emacs style mode select   -*- C++ -*-
00002 //-----------------------------------------------------------------------------
00003 //
00004 // $Id: m_menu.h 1928 2010-09-17 04:39:55Z hypereye $
00005 //
00006 // Copyright (C) 1993-1996 by id Software, Inc.
00007 // Copyright (C) 2006-2010 by The Odamex Team.
00008 //
00009 // This program is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // DESCRIPTION:
00020 //   Menu widget stuff, episode selection and such.
00021 //
00022 //-----------------------------------------------------------------------------
00023 
00024 
00025 #ifndef __M_MENU_H__
00026 #define __M_MENU_H__
00027 
00028 #include "d_event.h"
00029 #include "c_cvars.h"
00030 
00031 // Some defines...
00032 #define LINEHEIGHT      16
00033 #define SKULLXOFF       -32
00034 #define NUM_MENU_ITEMS(m)       (sizeof(m)/sizeof(m[0]))
00035 
00036 //
00037 // MENUS
00038 //
00039 // Called by main loop,
00040 // saves config file and calls I_Quit when user exits.
00041 // Even when the menu is not displayed,
00042 // this can resize the view and change game parameters.
00043 // Does all the real work of the menu interaction.
00044 bool M_Responder (event_t *ev);
00045 
00046 // Called by main loop,
00047 // only used for menu (skull cursor) animation.
00048 void M_Ticker (void);
00049 
00050 // Called by main loop,
00051 // draws the menus directly into the screen buffer.
00052 void M_Drawer (void);
00053 
00054 // Called by D_DoomMain,
00055 // loads the config file.
00056 void M_Init (void);
00057 
00058 // Called by intro code to force menu up upon a keypress,
00059 // does nothing if menu is already up.
00060 void M_StartControlPanel (void);
00061 
00062 // [RH] Setup options menu
00063 bool M_StartOptionsMenu (void);
00064 
00065 // [RH] Handle keys for options menu
00066 void M_OptResponder (event_t *ev);
00067 
00068 // [RH] Draw options menu
00069 void M_OptDrawer (void);
00070 
00071 // [RH] Initialize options menu
00072 void M_OptInit (void);
00073 
00074 void M_PlayerSetup (int choice);
00075 
00076 struct menu_s;
00077 void M_SwitchMenu (struct menu_s *menu);
00078 
00079 void M_PopMenuStack (void);
00080 
00081 // [RH] Called whenever the display mode changes
00082 void M_RefreshModesList ();
00083 
00084 //
00085 // MENU TYPEDEFS
00086 //
00087 typedef enum {
00088         whitetext,
00089         redtext,
00090         bricktext,
00091         more,
00092         slider,
00093         discrete,
00094         cdiscrete,
00095         control,
00096         screenres,
00097         bitflag,
00098         listelement,
00099         joyactive,
00100         joyaxis,
00101         nochoice
00102 } itemtype;
00103 
00104 typedef void (*cvarfunc)(cvar_t *cvar, float newval);
00105 typedef void (*voidfunc)(void);
00106 typedef void (*intfunc)(int);
00107 
00108 typedef struct menuitem_s {
00109         itemtype                  type;
00110         const char                       *label;
00111         union {
00112                 cvar_t                   *cvar;
00113                 int                               selmode;
00114                 int                               flagmask;
00115         } a;
00116         union {
00117                 float                     min;          /* aka numvalues aka invflag */
00118                 int                               key1;
00119                 const char                       *res1;
00120         } b;
00121         union {
00122                 float                     max;
00123                 int                               key2;
00124                 const char                       *res2;
00125         } c;
00126         union {
00127                 float                     step;
00128                 const char                       *res3;
00129         } d;
00130         union {
00131                 struct value_s   *values;
00132                 const char                       *command;
00133         cvarfunc          cfunc;
00134         voidfunc          mfunc;
00135         intfunc           lfunc;
00136                 int                               highlight;
00137                 int                              *flagint;
00138         } e;
00139 } menuitem_t;
00140 
00141 typedef struct menu_s {
00142         char                    title[9];
00143         int                             lastOn;
00144         int                             numitems;
00145         int                             indent;
00146         menuitem_t         *items;
00147         int                             scrolltop;
00148         int                             scrollpos;      
00149 } menu_t;
00150 
00151 typedef struct value_s {
00152         float           value;
00153         const char      *name;
00154 } value_t;
00155 
00156 typedef struct
00157 {
00158         // -1 = no cursor here, 1 = ok, 2 = arrows ok
00159         short           status;
00160 
00161         char            name[10];
00162 
00163         // choice = menu item #.
00164         // if status = 2,
00165         //       choice=0:leftarrow,1:rightarrow
00166         void            (*routine)(int choice);
00167 
00168         // hotkey in menu
00169         char            alphaKey;
00170 } oldmenuitem_t;
00171 
00172 typedef struct oldmenu_s
00173 {
00174         short                           numitems;               // # of menu items
00175         oldmenuitem_t           *menuitems;             // menu items
00176         void                            (*routine)(void);       // draw routine
00177         short                           x;
00178         short                           y;                              // x,y of menu
00179         short                           lastOn;                 // last item user was on in menu
00180 } oldmenu_t;
00181 
00182 typedef struct
00183 {
00184         union {
00185                 menu_t *newmenu;
00186                 oldmenu_t *old;
00187         } menu;
00188         bool isNewStyle;
00189         bool drawSkull;
00190 } menustack_t;
00191 
00192 extern value_t YesNo[2];
00193 extern value_t NoYes[2];
00194 extern value_t OnOff[2];
00195 extern value_t OffOn[2];
00196 extern value_t OnOffAuto[3];
00197 
00198 extern menustack_t MenuStack[16];
00199 extern int MenuStackDepth;
00200 
00201 extern menu_t  *CurrentMenu;
00202 extern int              CurrentItem;
00203 
00204 extern short     itemOn;
00205 extern oldmenu_t *currentMenu;
00206 
00207 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends