📄 mn_menu.c
字号:
//**************************************************************************//**//** mn_menu.c : Heretic 2 : Raven Software, Corp.//**//** $RCSfile: mn_menu.c,v $//** $Revision: 1.32 $//** $Date: 96/01/01 01:51:28 $//** $Author: bgokey $//**//**************************************************************************// HEADER FILES ------------------------------------------------------------#include <ctype.h>#include "h2def.h"#include "p_local.h"#include "r_local.h"#include "soundst.h"// MACROS ------------------------------------------------------------------#define LEFT_DIR 0#define RIGHT_DIR 1#define ITEM_HEIGHT 20#define SELECTOR_XOFFSET (-28)#define SELECTOR_YOFFSET (-1)#define SLOTTEXTLEN 16#define ASCII_CURSOR '['// TYPES -------------------------------------------------------------------typedef enum{ ITT_EMPTY, ITT_EFUNC, ITT_LRFUNC, ITT_SETMENU, ITT_INERT} ItemType_t;typedef enum{ MENU_MAIN, MENU_CLASS, MENU_SKILL, MENU_OPTIONS, MENU_OPTIONS2, MENU_FILES, MENU_LOAD, MENU_SAVE, MENU_NONE} MenuType_t;typedef struct{ ItemType_t type; char *text; void (*func)(int option); int option; MenuType_t menu;} MenuItem_t;typedef struct{ int x; int y; void (*drawFunc)(void); int itemCount; MenuItem_t *items; int oldItPos; MenuType_t prevMenu;} Menu_t;// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------static void InitFonts(void);static void SetMenu(MenuType_t menu);static void SCQuitGame(int option);static void SCClass(int option);static void SCSkill(int option);static void SCMouseSensi(int option);static void SCSfxVolume(int option);static void SCMusicVolume(int option);static void SCScreenSize(int option);static boolean SCNetCheck(int option);static void SCNetCheck2(int option);static void SCLoadGame(int option);static void SCSaveGame(int option);static void SCMessages(int option);static void SCEndGame(int option);static void SCInfo(int option);static void DrawMainMenu(void);static void DrawClassMenu(void);static void DrawSkillMenu(void);static void DrawOptionsMenu(void);static void DrawOptions2Menu(void);static void DrawFileSlots(Menu_t *menu);static void DrawFilesMenu(void);static void MN_DrawInfo(void);static void DrawLoadMenu(void);static void DrawSaveMenu(void);static void DrawSlider(Menu_t *menu, int item, int width, int slot);void MN_LoadSlotText(void);// EXTERNAL DATA DECLARATIONS ----------------------------------------------extern int detailLevel;extern int screenblocks;extern char *SavePath;extern int key_speed, key_strafe;extern boolean gamekeydown[256]; // The NUMKEYS macro is local to g_game// PUBLIC DATA DEFINITIONS -------------------------------------------------boolean MenuActive;int InfoType;boolean messageson;boolean mn_SuicideConsole;// PRIVATE DATA DEFINITIONS ------------------------------------------------static int FontABaseLump;static int FontAYellowBaseLump;static int FontBBaseLump;static int MauloBaseLump;static Menu_t *CurrentMenu;static int CurrentItPos;static int MenuPClass;static int MenuTime;static boolean soundchanged;boolean askforquit;boolean typeofask;static boolean FileMenuKeySteal;static boolean slottextloaded;static char SlotText[6][SLOTTEXTLEN+2];static char oldSlotText[SLOTTEXTLEN+2];static int SlotStatus[6];static int slotptr;static int currentSlot;static int quicksave;static int quickload;static MenuItem_t MainItems[] ={ { ITT_SETMENU, "NEW GAME", SCNetCheck2, 1, MENU_CLASS }, { ITT_SETMENU, "OPTIONS", NULL, 0, MENU_OPTIONS }, { ITT_SETMENU, "GAME FILES", NULL, 0, MENU_FILES }, { ITT_EFUNC, "INFO", SCInfo, 0, MENU_NONE }, { ITT_EFUNC, "QUIT GAME", SCQuitGame, 0, MENU_NONE }};static Menu_t MainMenu ={ 110, 56, DrawMainMenu, 5, MainItems, 0, MENU_NONE};static MenuItem_t ClassItems[] ={ { ITT_EFUNC, "FIGHTER", SCClass, 0, MENU_NONE }, { ITT_EFUNC, "CLERIC", SCClass, 1, MENU_NONE }, { ITT_EFUNC, "MAGE", SCClass, 2, MENU_NONE }};static Menu_t ClassMenu ={ 66, 66, DrawClassMenu, 3, ClassItems, 0, MENU_MAIN};static MenuItem_t FilesItems[] ={ { ITT_SETMENU, "LOAD GAME", SCNetCheck2, 2, MENU_LOAD }, { ITT_SETMENU, "SAVE GAME", NULL, 0, MENU_SAVE }};static Menu_t FilesMenu ={ 110, 60, DrawFilesMenu, 2, FilesItems, 0, MENU_MAIN};static MenuItem_t LoadItems[] ={ { ITT_EFUNC, NULL, SCLoadGame, 0, MENU_NONE }, { ITT_EFUNC, NULL, SCLoadGame, 1, MENU_NONE }, { ITT_EFUNC, NULL, SCLoadGame, 2, MENU_NONE }, { ITT_EFUNC, NULL, SCLoadGame, 3, MENU_NONE }, { ITT_EFUNC, NULL, SCLoadGame, 4, MENU_NONE }, { ITT_EFUNC, NULL, SCLoadGame, 5, MENU_NONE }};static Menu_t LoadMenu ={ 70, 30, DrawLoadMenu, 6, LoadItems, 0, MENU_FILES};static MenuItem_t SaveItems[] ={ { ITT_EFUNC, NULL, SCSaveGame, 0, MENU_NONE }, { ITT_EFUNC, NULL, SCSaveGame, 1, MENU_NONE }, { ITT_EFUNC, NULL, SCSaveGame, 2, MENU_NONE }, { ITT_EFUNC, NULL, SCSaveGame, 3, MENU_NONE }, { ITT_EFUNC, NULL, SCSaveGame, 4, MENU_NONE }, { ITT_EFUNC, NULL, SCSaveGame, 5, MENU_NONE }};static Menu_t SaveMenu ={ 70, 30, DrawSaveMenu, 6, SaveItems, 0, MENU_FILES};static MenuItem_t SkillItems[] ={ { ITT_EFUNC, NULL, SCSkill, sk_baby, MENU_NONE }, { ITT_EFUNC, NULL, SCSkill, sk_easy, MENU_NONE }, { ITT_EFUNC, NULL, SCSkill, sk_medium, MENU_NONE }, { ITT_EFUNC, NULL, SCSkill, sk_hard, MENU_NONE }, { ITT_EFUNC, NULL, SCSkill, sk_nightmare, MENU_NONE }};static Menu_t SkillMenu ={ 120, 44, DrawSkillMenu, 5, SkillItems, 2, MENU_CLASS};static MenuItem_t OptionsItems[] ={ { ITT_EFUNC, "END GAME", SCEndGame, 0, MENU_NONE }, { ITT_EFUNC, "MESSAGES : ", SCMessages, 0, MENU_NONE }, { ITT_LRFUNC, "MOUSE SENSITIVITY", SCMouseSensi, 0, MENU_NONE }, { ITT_EMPTY, NULL, NULL, 0, MENU_NONE }, { ITT_SETMENU, "MORE...", NULL, 0, MENU_OPTIONS2 }};static Menu_t OptionsMenu ={ 88, 30, DrawOptionsMenu, 5, OptionsItems, 0, MENU_MAIN};static MenuItem_t Options2Items[] ={ { ITT_LRFUNC, "SCREEN SIZE", SCScreenSize, 0, MENU_NONE }, { ITT_EMPTY, NULL, NULL, 0, MENU_NONE }, { ITT_LRFUNC, "SFX VOLUME", SCSfxVolume, 0, MENU_NONE }, { ITT_EMPTY, NULL, NULL, 0, MENU_NONE }, { ITT_LRFUNC, "MUSIC VOLUME", SCMusicVolume, 0, MENU_NONE }, { ITT_EMPTY, NULL, NULL, 0, MENU_NONE }};static Menu_t Options2Menu ={ 90, 20, DrawOptions2Menu, 6, Options2Items, 0, MENU_OPTIONS};static Menu_t *Menus[] ={ &MainMenu, &ClassMenu, &SkillMenu, &OptionsMenu, &Options2Menu, &FilesMenu, &LoadMenu, &SaveMenu};#ifdef __WATCOMC__static char *GammaText[] = { TXT_GAMMA_LEVEL_OFF, TXT_GAMMA_LEVEL_1, TXT_GAMMA_LEVEL_2, TXT_GAMMA_LEVEL_3, TXT_GAMMA_LEVEL_4};#endif // CODE --------------------------------------------------------------------//---------------------------------------------------------------------------//// PROC MN_Init////---------------------------------------------------------------------------void MN_Init(void){ InitFonts(); MenuActive = false;// messageson = true; // Set by defaults in .CFG MauloBaseLump = W_GetNumForName("FBULA0"); // ("M_SKL00");}//---------------------------------------------------------------------------//// PROC InitFonts////---------------------------------------------------------------------------static void InitFonts(void){ FontABaseLump = W_GetNumForName("FONTA_S")+1; FontAYellowBaseLump = W_GetNumForName("FONTAY_S")+1; FontBBaseLump = W_GetNumForName("FONTB_S")+1;}//---------------------------------------------------------------------------//// PROC MN_DrTextA//// Draw text using font A.////---------------------------------------------------------------------------void MN_DrTextA(char *text, int x, int y){ char c; patch_t *p; while((c = *text++) != 0) { if(c < 33) { x += 5; } else { p = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE); V_DrawPatch(x, y, p); x += p->width-1; } }}//==========================================================================//// MN_DrTextAYellow////==========================================================================void MN_DrTextAYellow(char *text, int x, int y){ char c; patch_t *p; while((c = *text++) != 0) { if(c < 33) { x += 5; } else { p = W_CacheLumpNum(FontAYellowBaseLump+c-33, PU_CACHE); V_DrawPatch(x, y, p); x += p->width-1; } }}//---------------------------------------------------------------------------//// FUNC MN_TextAWidth//// Returns the pixel width of a string using font A.////---------------------------------------------------------------------------int MN_TextAWidth(char *text){ char c; int width; patch_t *p; width = 0; while((c = *text++) != 0) { if(c < 33) { width += 5; } else { p = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE); width += p->width-1; } } return(width);}//---------------------------------------------------------------------------//// PROC MN_DrTextB//// Draw text using font B.////---------------------------------------------------------------------------void MN_DrTextB(char *text, int x, int y){ char c; patch_t *p; while((c = *text++) != 0) { if(c < 33) { x += 8; } else { p = W_CacheLumpNum(FontBBaseLump+c-33, PU_CACHE); V_DrawPatch(x, y, p); x += p->width-1; } }}//---------------------------------------------------------------------------//// FUNC MN_TextBWidth//// Returns the pixel width of a string using font B.////---------------------------------------------------------------------------int MN_TextBWidth(char *text){ char c; int width; patch_t *p; width = 0; while((c = *text++) != 0) { if(c < 33) { width += 5; } else { p = W_CacheLumpNum(FontBBaseLump+c-33, PU_CACHE); width += p->width-1; } } return(width);}//---------------------------------------------------------------------------//// PROC MN_Ticker////---------------------------------------------------------------------------void MN_Ticker(void){ if(MenuActive == false) { return; } MenuTime++;}//---------------------------------------------------------------------------//// PROC MN_Drawer////---------------------------------------------------------------------------char *QuitEndMsg[] ={ "ARE YOU SURE YOU WANT TO QUIT?", "ARE YOU SURE YOU WANT TO END THE GAME?", "DO YOU WANT TO QUICKSAVE THE GAME NAMED", "DO YOU WANT TO QUICKLOAD THE GAME NAMED", "ARE YOU SURE YOU WANT TO SUICIDE?"};#define BETA_FLASH_TEXT "BETA"void MN_Drawer(void){ int i; int x; int y; MenuItem_t *item; char *selName;#ifdef TIMEBOMB // Beta blinker *** if(leveltime&16) { MN_DrTextA( BETA_FLASH_TEXT, 160-(MN_TextAWidth(BETA_FLASH_TEXT)>>1), 12); }#endif // TIMEBOMB if(MenuActive == false) { if(askforquit) { MN_DrTextA(QuitEndMsg[typeofask-1], 160- MN_TextAWidth(QuitEndMsg[typeofask-1])/2, 80); if(typeofask == 3) { MN_DrTextA(SlotText[quicksave-1], 160- MN_TextAWidth(SlotText[quicksave-1])/2, 90); MN_DrTextA("?", 160+ MN_TextAWidth(SlotText[quicksave-1])/2, 90); } if(typeofask == 4) { MN_DrTextA(SlotText[quickload-1], 160- MN_TextAWidth(SlotText[quickload-1])/2, 90); MN_DrTextA("?", 160+ MN_TextAWidth(SlotText[quicksave-1])/2, 90); } UpdateState |= I_FULLSCRN; } return; } else { UpdateState |= I_FULLSCRN; if(InfoType) { MN_DrawInfo(); return; } if(screenblocks < 10) { BorderNeedRefresh = true; } if(CurrentMenu->drawFunc != NULL) { CurrentMenu->drawFunc(); } x = CurrentMenu->x; y = CurrentMenu->y; item = CurrentMenu->items; for(i = 0; i < CurrentMenu->itemCount; i++) { if(item->type != ITT_EMPTY && item->text) { MN_DrTextB(item->text, x, y);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -