12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589 |
- // MN_menu.c
- #include <ctype.h>
- #include "DoomDef.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_EPISODE,
- MENU_SKILL,
- MENU_OPTIONS,
- MENU_OPTIONS2,
- MENU_FILES,
- MENU_LOAD,
- MENU_SAVE,
- MENU_NONE
- } MenuType_t;
- typedef struct
- {
- ItemType_t type;
- char *text;
- boolean (*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;
- // Private Functions
- static void InitFonts(void);
- static void SetMenu(MenuType_t menu);
- static boolean SCNetCheck(int option);
- static boolean SCQuitGame(int option);
- static boolean SCEpisode(int option);
- static boolean SCSkill(int option);
- static boolean SCMouseSensi(int option);
- static boolean SCSfxVolume(int option);
- static boolean SCMusicVolume(int option);
- static boolean SCScreenSize(int option);
- static boolean SCLoadGame(int option);
- static boolean SCSaveGame(int option);
- static boolean SCMessages(int option);
- static boolean SCEndGame(int option);
- static boolean SCInfo(int option);
- static void DrawMainMenu(void);
- static void DrawEpisodeMenu(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
- extern int detailLevel;
- extern int screenblocks;
- // Public Data
- boolean MenuActive;
- int InfoType;
- boolean messageson;
- // Private Data
- static int FontABaseLump;
- static int FontBBaseLump;
- static int SkullBaseLump;
- static Menu_t *CurrentMenu;
- static int CurrentItPos;
- static int MenuEpisode;
- 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_EFUNC, "NEW GAME", SCNetCheck, 1, MENU_EPISODE },
- { 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 EpisodeItems[] =
- {
- { ITT_EFUNC, "CITY OF THE DAMNED", SCEpisode, 1, MENU_NONE },
- { ITT_EFUNC, "HELL'S MAW", SCEpisode, 2, MENU_NONE },
- { ITT_EFUNC, "THE DOME OF D'SPARIL", SCEpisode, 3, MENU_NONE },
- { ITT_EFUNC, "THE OSSUARY", SCEpisode, 4, MENU_NONE },
- { ITT_EFUNC, "THE STAGNANT DEMESNE", SCEpisode, 5, MENU_NONE }
- };
- static Menu_t EpisodeMenu =
- {
- 80, 50,
- DrawEpisodeMenu,
- 3, EpisodeItems,
- 0,
- MENU_MAIN
- };
- static MenuItem_t FilesItems[] =
- {
- { ITT_EFUNC, "LOAD GAME", SCNetCheck, 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, "THOU NEEDETH A WET-NURSE", SCSkill, sk_baby, MENU_NONE },
- { ITT_EFUNC, "YELLOWBELLIES-R-US", SCSkill, sk_easy, MENU_NONE },
- { ITT_EFUNC, "BRINGEST THEM ONETH", SCSkill, sk_medium, MENU_NONE },
- { ITT_EFUNC, "THOU ART A SMITE-MEISTER", SCSkill, sk_hard, MENU_NONE },
- { ITT_EFUNC, "BLACK PLAGUE POSSESSES THEE",
- SCSkill, sk_nightmare, MENU_NONE }
- };
- static Menu_t SkillMenu =
- {
- 38, 30,
- DrawSkillMenu,
- 5, SkillItems,
- 2,
- MENU_EPISODE
- };
- 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,
- &EpisodeMenu,
- &SkillMenu,
- &OptionsMenu,
- &Options2Menu,
- &FilesMenu,
- &LoadMenu,
- &SaveMenu
- };
- //---------------------------------------------------------------------------
- //
- // PROC MN_Init
- //
- //---------------------------------------------------------------------------
- void MN_Init(void)
- {
- InitFonts();
- MenuActive = false;
- messageson = true;
- SkullBaseLump = W_GetNumForName("M_SKL00");
- if(ExtendedWAD)
- { // Add episodes 4 and 5 to the menu
- EpisodeMenu.itemCount = 5;
- EpisodeMenu.y -= ITEM_HEIGHT;
- }
- }
- //---------------------------------------------------------------------------
- //
- // PROC InitFonts
- //
- //---------------------------------------------------------------------------
- static void InitFonts(void)
- {
- FontABaseLump = W_GetNumForName("FONTA_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;
- }
- }
- }
- //---------------------------------------------------------------------------
- //
- // 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"
- };
- void MN_Drawer(void)
- {
- int i;
- int x;
- int y;
- MenuItem_t *item;
- char *selName;
- 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[quickload-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);
- }
- y += ITEM_HEIGHT;
- item++;
- }
- y = CurrentMenu->y+(CurrentItPos*ITEM_HEIGHT)+SELECTOR_YOFFSET;
- selName = MenuTime&16 ? "M_SLCTR1" : "M_SLCTR2";
- V_DrawPatch(x+SELECTOR_XOFFSET, y,
- W_CacheLumpName(selName, PU_CACHE));
- }
- }
- //---------------------------------------------------------------------------
- //
- // PROC DrawMainMenu
- //
- //---------------------------------------------------------------------------
- static void DrawMainMenu(void)
- {
- int frame;
- frame = (MenuTime/3)%18;
- V_DrawPatch(88, 0, W_CacheLumpName("M_HTIC", PU_CACHE));
- V_DrawPatch(40, 10, W_CacheLumpNum(SkullBaseLump+(17-frame),
- PU_CACHE));
- V_DrawPatch(232, 10, W_CacheLumpNum(SkullBaseLump+frame, PU_CACHE));
- }
- //---------------------------------------------------------------------------
- //
- // PROC DrawEpisodeMenu
- //
- //---------------------------------------------------------------------------
- static void DrawEpisodeMenu(void)
- {
- }
- //---------------------------------------------------------------------------
- //
- // PROC DrawSkillMenu
- //
- //---------------------------------------------------------------------------
- static void DrawSkillMenu(void)
- {
- }
- //---------------------------------------------------------------------------
- //
- // PROC DrawFilesMenu
- //
- //---------------------------------------------------------------------------
- static void DrawFilesMenu(void)
- {
- // clear out the quicksave/quickload stuff
- quicksave = 0;
- quickload = 0;
- players[consoleplayer].message = NULL;
- players[consoleplayer].messageTics = 1;
- }
- //---------------------------------------------------------------------------
- //
- // PROC DrawLoadMenu
- //
- //---------------------------------------------------------------------------
- static void DrawLoadMenu(void)
- {
- MN_DrTextB("LOAD GAME", 160-MN_TextBWidth("LOAD GAME")/2, 10);
- if(!slottextloaded)
- {
- MN_LoadSlotText();
- }
- DrawFileSlots(&LoadMenu);
- }
- //---------------------------------------------------------------------------
- //
- // PROC DrawSaveMenu
- //
- //---------------------------------------------------------------------------
- static void DrawSaveMenu(void)
- {
- MN_DrTextB("SAVE GAME", 160-MN_TextBWidth("SAVE GAME")/2, 10);
- if(!slottextloaded)
- {
- MN_LoadSlotText();
- }
- DrawFileSlots(&SaveMenu);
- }
- //===========================================================================
- //
- // MN_LoadSlotText
- //
- // Loads in the text message for each slot
- //===========================================================================
- void MN_LoadSlotText(void)
- {
- FILE *fp;
- int count;
- int i;
- char name[256];
- for (i = 0; i < 6; i++)
- {
- if(cdrom)
- {
- sprintf(name, SAVEGAMENAMECD"%d.hsg", i);
- }
- else
- {
- sprintf(name, SAVEGAMENAME"%d.hsg", i);
- }
- fp = fopen(name, "rb+");
- if (!fp)
- {
- SlotText[i][0] = 0; // empty the string
- SlotStatus[i] = 0;
- continue;
- }
- count = fread(&SlotText[i], SLOTTEXTLEN, 1, fp);
- fclose(fp);
- SlotStatus[i] = 1;
- }
- slottextloaded = true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC DrawFileSlots
- //
- //---------------------------------------------------------------------------
- static void DrawFileSlots(Menu_t *menu)
- {
- int i;
- int x;
- int y;
- x = menu->x;
- y = menu->y;
- for(i = 0; i < 6; i++)
- {
- V_DrawPatch(x, y, W_CacheLumpName("M_FSLOT", PU_CACHE));
- if(SlotStatus[i])
- {
- MN_DrTextA(SlotText[i], x+5, y+5);
- }
- y += ITEM_HEIGHT;
- }
- }
- //---------------------------------------------------------------------------
- //
- // PROC DrawOptionsMenu
- //
- //---------------------------------------------------------------------------
- static void DrawOptionsMenu(void)
- {
- if(messageson)
- {
- MN_DrTextB("ON", 196, 50);
- }
- else
- {
- MN_DrTextB("OFF", 196, 50);
- }
- DrawSlider(&OptionsMenu, 3, 10, mouseSensitivity);
- }
- //---------------------------------------------------------------------------
- //
- // PROC DrawOptions2Menu
- //
- //---------------------------------------------------------------------------
- static void DrawOptions2Menu(void)
- {
- DrawSlider(&Options2Menu, 1, 9, screenblocks-3);
- DrawSlider(&Options2Menu, 3, 16, snd_MaxVolume);
- DrawSlider(&Options2Menu, 5, 16, snd_MusicVolume);
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCNetCheck
- //
- //---------------------------------------------------------------------------
- static boolean SCNetCheck(int option)
- {
- if(!netgame)
- { // okay to go into the menu
- return true;
- }
- switch(option)
- {
- case 1:
- P_SetMessage(&players[consoleplayer],
- "YOU CAN'T START A NEW GAME IN NETPLAY!", true);
- break;
- case 2:
- P_SetMessage(&players[consoleplayer],
- "YOU CAN'T LOAD A GAME IN NETPLAY!", true);
- break;
- default:
- break;
- }
- MenuActive = false;
- return false;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCQuitGame
- //
- //---------------------------------------------------------------------------
- static boolean SCQuitGame(int option)
- {
- MenuActive = false;
- askforquit = true;
- typeofask = 1; //quit game
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCEndGame
- //
- //---------------------------------------------------------------------------
- static boolean SCEndGame(int option)
- {
- if(demoplayback || netgame)
- {
- return false;
- }
- MenuActive = false;
- askforquit = true;
- typeofask = 2; //endgame
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCMessages
- //
- //---------------------------------------------------------------------------
- static boolean SCMessages(int option)
- {
- messageson ^= 1;
- if(messageson)
- {
- P_SetMessage(&players[consoleplayer], "MESSAGES ON", true);
- }
- else
- {
- P_SetMessage(&players[consoleplayer], "MESSAGES OFF", true);
- }
- S_StartSound(NULL, sfx_chat);
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCLoadGame
- //
- //---------------------------------------------------------------------------
- static boolean SCLoadGame(int option)
- {
- char name[256];
- if(!SlotStatus[option])
- { // slot's empty...don't try and load
- return false;
- }
- if(cdrom)
- {
- sprintf(name, SAVEGAMENAMECD"%d.hsg", option);
- }
- else
- {
- sprintf(name, SAVEGAMENAME"%d.hsg", option);
- }
- G_LoadGame(name);
- MN_DeactivateMenu();
- BorderNeedRefresh = true;
- if(quickload == -1)
- {
- quickload = option+1;
- players[consoleplayer].message = NULL;
- players[consoleplayer].messageTics = 1;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCSaveGame
- //
- //---------------------------------------------------------------------------
- static boolean SCSaveGame(int option)
- {
- char *ptr;
- if(!FileMenuKeySteal)
- {
- FileMenuKeySteal = true;
- strcpy(oldSlotText, SlotText[option]);
- ptr = SlotText[option];
- while(*ptr)
- {
- ptr++;
- }
- *ptr = '[';
- *(ptr+1) = 0;
- SlotStatus[option]++;
- currentSlot = option;
- slotptr = ptr-SlotText[option];
- return false;
- }
- else
- {
- G_SaveGame(option, SlotText[option]);
- FileMenuKeySteal = false;
- MN_DeactivateMenu();
- }
- BorderNeedRefresh = true;
- if(quicksave == -1)
- {
- quicksave = option+1;
- players[consoleplayer].message = NULL;
- players[consoleplayer].messageTics = 1;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCEpisode
- //
- //---------------------------------------------------------------------------
- static boolean SCEpisode(int option)
- {
- if(shareware && option > 1)
- {
- P_SetMessage(&players[consoleplayer],
- "ONLY AVAILABLE IN THE REGISTERED VERSION", true);
- }
- else
- {
- MenuEpisode = option;
- SetMenu(MENU_SKILL);
- }
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCSkill
- //
- //---------------------------------------------------------------------------
- static boolean SCSkill(int option)
- {
- G_DeferedInitNew(option, MenuEpisode, 1);
- MN_DeactivateMenu();
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCMouseSensi
- //
- //---------------------------------------------------------------------------
- static boolean SCMouseSensi(int option)
- {
- if(option == RIGHT_DIR)
- {
- if(mouseSensitivity < 9)
- {
- mouseSensitivity++;
- }
- }
- else if(mouseSensitivity)
- {
- mouseSensitivity--;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCSfxVolume
- //
- //---------------------------------------------------------------------------
- static boolean SCSfxVolume(int option)
- {
- if(option == RIGHT_DIR)
- {
- if(snd_MaxVolume < 15)
- {
- snd_MaxVolume++;
- }
- }
- else if(snd_MaxVolume)
- {
- snd_MaxVolume--;
- }
- S_SetMaxVolume(false); // don't recalc the sound curve, yet
- soundchanged = true; // we'll set it when we leave the menu
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCMusicVolume
- //
- //---------------------------------------------------------------------------
- static boolean SCMusicVolume(int option)
- {
- if(option == RIGHT_DIR)
- {
- if(snd_MusicVolume < 15)
- {
- snd_MusicVolume++;
- }
- }
- else if(snd_MusicVolume)
- {
- snd_MusicVolume--;
- }
- S_SetMusicVolume();
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCScreenSize
- //
- //---------------------------------------------------------------------------
- static boolean SCScreenSize(int option)
- {
- if(option == RIGHT_DIR)
- {
- if(screenblocks < 11)
- {
- screenblocks++;
- }
- }
- else if(screenblocks > 3)
- {
- screenblocks--;
- }
- R_SetViewSize(screenblocks, detailLevel);
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // PROC SCInfo
- //
- //---------------------------------------------------------------------------
- static boolean SCInfo(int option)
- {
- InfoType = 1;
- S_StartSound(NULL, sfx_dorcls);
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- //
- // FUNC MN_Responder
- //
- //---------------------------------------------------------------------------
- boolean MN_Responder(event_t *event)
- {
- int key;
- int i;
- MenuItem_t *item;
- extern boolean automapactive;
- static boolean shiftdown;
- extern void D_StartTitle(void);
- extern void G_CheckDemoStatus(void);
- char *textBuffer;
- if(event->data1 == KEY_RSHIFT)
- {
- shiftdown = (event->type == ev_keydown);
- }
- if(event->type != ev_keydown)
- {
- return(false);
- }
- key = event->data1;
- if(InfoType)
- {
- if(shareware)
- {
- InfoType = (InfoType+1)%5;
- }
- else
- {
- InfoType = (InfoType+1)%4;
- }
- if(key == KEY_ESCAPE)
- {
- InfoType = 0;
- }
- if(!InfoType)
- {
- paused = false;
- MN_DeactivateMenu();
- SB_state = -1; //refresh the statbar
- BorderNeedRefresh = true;
- }
- S_StartSound(NULL, sfx_dorcls);
- return(true); //make the info screen eat the keypress
- }
- if(ravpic && key == KEY_F1)
- {
- G_ScreenShot();
- return(true);
- }
- if(askforquit)
- {
- switch(key)
- {
- case 'y':
- if(askforquit)
- {
- switch(typeofask)
- {
- case 1:
- G_CheckDemoStatus();
- I_Quit();
- break;
- case 2:
- players[consoleplayer].messageTics = 0;
- //set the msg to be cleared
- players[consoleplayer].message = NULL;
- typeofask = 0;
- askforquit = false;
- paused = false;
- I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE));
- D_StartTitle(); // go to intro/demo mode.
- break;
- case 3:
- P_SetMessage(&players[consoleplayer], "QUICKSAVING....", false);
- FileMenuKeySteal = true;
- SCSaveGame(quicksave-1);
- askforquit = false;
- typeofask = 0;
- BorderNeedRefresh = true;
- return true;
- case 4:
- P_SetMessage(&players[consoleplayer], "QUICKLOADING....", false);
- SCLoadGame(quickload-1);
- askforquit = false;
- typeofask = 0;
- BorderNeedRefresh = true;
- return true;
- default:
- return true; // eat the 'y' keypress
- }
- }
- return false;
- case 'n':
- case KEY_ESCAPE:
- if(askforquit)
- {
- players[consoleplayer].messageTics = 1; //set the msg to be cleared
- askforquit = false;
- typeofask = 0;
- paused = false;
- UpdateState |= I_FULLSCRN;
- BorderNeedRefresh = true;
- return true;
- }
- return false;
- }
- return false; // don't let the keys filter thru
- }
- if(MenuActive == false && !chatmodeon)
- {
- switch(key)
- {
- case KEY_MINUS:
- if(automapactive)
- { // Don't screen size in automap
- return(false);
- }
- SCScreenSize(LEFT_DIR);
- S_StartSound(NULL, sfx_keyup);
- BorderNeedRefresh = true;
- UpdateState |= I_FULLSCRN;
- return(true);
- case KEY_EQUALS:
- if(automapactive)
- { // Don't screen size in automap
- return(false);
- }
- SCScreenSize(RIGHT_DIR);
- S_StartSound(NULL, sfx_keyup);
- BorderNeedRefresh = true;
- UpdateState |= I_FULLSCRN;
- return(true);
- #ifndef __NeXT__
- case KEY_F1: // help screen
- SCInfo(0); // start up info screens
- MenuActive = true;
- return(true);
- case KEY_F2: // save game
- if(gamestate == GS_LEVEL && !demoplayback)
- {
- MenuActive = true;
- FileMenuKeySteal = false;
- MenuTime = 0;
- CurrentMenu = &SaveMenu;
- CurrentItPos = CurrentMenu->oldItPos;
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- S_StartSound(NULL, sfx_dorcls);
- slottextloaded = false; //reload the slot text, when needed
- }
- return true;
- case KEY_F3: // load game
- if(SCNetCheck(2))
- {
- MenuActive = true;
- FileMenuKeySteal = false;
- MenuTime = 0;
- CurrentMenu = &LoadMenu;
- CurrentItPos = CurrentMenu->oldItPos;
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- S_StartSound(NULL, sfx_dorcls);
- slottextloaded = false; //reload the slot text, when needed
- }
- return true;
- case KEY_F4: // volume
- MenuActive = true;
- FileMenuKeySteal = false;
- MenuTime = 0;
- CurrentMenu = &Options2Menu;
- CurrentItPos = CurrentMenu->oldItPos;
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- S_StartSound(NULL, sfx_dorcls);
- slottextloaded = false; //reload the slot text, when needed
- return true;
- case KEY_F5: // F5 isn't used in Heretic. (detail level)
- return true;
- case KEY_F6: // quicksave
- if(gamestate == GS_LEVEL && !demoplayback)
- {
- if(!quicksave || quicksave == -1)
- {
- MenuActive = true;
- FileMenuKeySteal = false;
- MenuTime = 0;
- CurrentMenu = &SaveMenu;
- CurrentItPos = CurrentMenu->oldItPos;
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- S_StartSound(NULL, sfx_dorcls);
- slottextloaded = false; //reload the slot text, when needed
- quicksave = -1;
- P_SetMessage(&players[consoleplayer],
- "CHOOSE A QUICKSAVE SLOT", true);
- }
- else
- {
- askforquit = true;
- typeofask = 3;
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- S_StartSound(NULL, sfx_chat);
- }
- }
- return true;
- case KEY_F7: // endgame
- if(gamestate == GS_LEVEL && !demoplayback)
- {
- S_StartSound(NULL, sfx_chat);
- SCEndGame(0);
- }
- return true;
- case KEY_F8: // toggle messages
- SCMessages(0);
- return true;
- case KEY_F9: // quickload
- if(!quickload || quickload == -1)
- {
- MenuActive = true;
- FileMenuKeySteal = false;
- MenuTime = 0;
- CurrentMenu = &LoadMenu;
- CurrentItPos = CurrentMenu->oldItPos;
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- S_StartSound(NULL, sfx_dorcls);
- slottextloaded = false; //reload the slot text, when needed
- quickload = -1;
- P_SetMessage(&players[consoleplayer],
- "CHOOSE A QUICKLOAD SLOT", true);
- }
- else
- {
- askforquit = true;
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- typeofask = 4;
- S_StartSound(NULL, sfx_chat);
- }
- return true;
- case KEY_F10: // quit
- if(gamestate == GS_LEVEL)
- {
- SCQuitGame(0);
- S_StartSound(NULL, sfx_chat);
- }
- return true;
- case KEY_F11: // F11 - gamma mode correction
- usegamma++;
- if(usegamma > 4)
- {
- usegamma = 0;
- }
- I_SetPalette((byte *)W_CacheLumpName("PLAYPAL", PU_CACHE));
- return true;
- #endif
- }
- }
- if(MenuActive == false)
- {
- if(key == KEY_ESCAPE || gamestate == GS_DEMOSCREEN || demoplayback)
- {
- MN_ActivateMenu();
- return(true);
- }
- return(false);
- }
- if(!FileMenuKeySteal)
- {
- item = &CurrentMenu->items[CurrentItPos];
- switch(key)
- {
- case KEY_DOWNARROW:
- do
- {
- if(CurrentItPos+1 > CurrentMenu->itemCount-1)
- {
- CurrentItPos = 0;
- }
- else
- {
- CurrentItPos++;
- }
- } while(CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
- S_StartSound(NULL, sfx_switch);
- return(true);
- break;
- case KEY_UPARROW:
- do
- {
- if(CurrentItPos == 0)
- {
- CurrentItPos = CurrentMenu->itemCount-1;
- }
- else
- {
- CurrentItPos--;
- }
- } while(CurrentMenu->items[CurrentItPos].type == ITT_EMPTY);
- S_StartSound(NULL, sfx_switch);
- return(true);
- break;
- case KEY_LEFTARROW:
- if(item->type == ITT_LRFUNC && item->func != NULL)
- {
- item->func(LEFT_DIR);
- S_StartSound(NULL, sfx_keyup);
- }
- return(true);
- break;
- case KEY_RIGHTARROW:
- if(item->type == ITT_LRFUNC && item->func != NULL)
- {
- item->func(RIGHT_DIR);
- S_StartSound(NULL, sfx_keyup);
- }
- return(true);
- break;
- case KEY_ENTER:
- if(item->type == ITT_SETMENU)
- {
- SetMenu(item->menu);
- }
- else if(item->func != NULL)
- {
- CurrentMenu->oldItPos = CurrentItPos;
- if(item->type == ITT_LRFUNC)
- {
- item->func(RIGHT_DIR);
- }
- else if(item->type == ITT_EFUNC)
- {
- if(item->func(item->option))
- {
- if(item->menu != MENU_NONE)
- {
- SetMenu(item->menu);
- }
- }
- }
- }
- S_StartSound(NULL, sfx_dorcls);
- return(true);
- break;
- case KEY_ESCAPE:
- MN_DeactivateMenu();
- return(true);
- case KEY_BACKSPACE:
- S_StartSound(NULL, sfx_switch);
- if(CurrentMenu->prevMenu == MENU_NONE)
- {
- MN_DeactivateMenu();
- }
- else
- {
- SetMenu(CurrentMenu->prevMenu);
- }
- return(true);
- default:
- for(i = 0; i < CurrentMenu->itemCount; i++)
- {
- if(CurrentMenu->items[i].text)
- {
- if(toupper(key)
- == toupper(CurrentMenu->items[i].text[0]))
- {
- CurrentItPos = i;
- return(true);
- }
- }
- }
- break;
- }
- return(false);
- }
- else
- { // Editing file names
- textBuffer = &SlotText[currentSlot][slotptr];
- if(key == KEY_BACKSPACE)
- {
- if(slotptr)
- {
- *textBuffer-- = 0;
- *textBuffer = ASCII_CURSOR;
- slotptr--;
- }
- return(true);
- }
- if(key == KEY_ESCAPE)
- {
- memset(SlotText[currentSlot], 0, SLOTTEXTLEN+2);
- strcpy(SlotText[currentSlot], oldSlotText);
- SlotStatus[currentSlot]--;
- MN_DeactivateMenu();
- return(true);
- }
- if(key == KEY_ENTER)
- {
- SlotText[currentSlot][slotptr] = 0; // clear the cursor
- item = &CurrentMenu->items[CurrentItPos];
- CurrentMenu->oldItPos = CurrentItPos;
- if(item->type == ITT_EFUNC)
- {
- item->func(item->option);
- if(item->menu != MENU_NONE)
- {
- SetMenu(item->menu);
- }
- }
- return(true);
- }
- if(slotptr < SLOTTEXTLEN && key != KEY_BACKSPACE)
- {
- if((key >= 'a' && key <= 'z'))
- {
- *textBuffer++ = key-32;
- *textBuffer = ASCII_CURSOR;
- slotptr++;
- return(true);
- }
- if(((key >= '0' && key <= '9') || key == ' '
- || key == ',' || key == '.' || key == '-')
- && !shiftdown)
- {
- *textBuffer++ = key;
- *textBuffer = ASCII_CURSOR;
- slotptr++;
- return(true);
- }
- if(shiftdown && key == '1')
- {
- *textBuffer++ = '!';
- *textBuffer = ASCII_CURSOR;
- slotptr++;
- return(true);
- }
- }
- return(true);
- }
- return(false);
- }
- //---------------------------------------------------------------------------
- //
- // PROC MN_ActivateMenu
- //
- //---------------------------------------------------------------------------
- void MN_ActivateMenu(void)
- {
- if(MenuActive)
- {
- return;
- }
- if(paused)
- {
- S_ResumeSound();
- }
- MenuActive = true;
- FileMenuKeySteal = false;
- MenuTime = 0;
- CurrentMenu = &MainMenu;
- CurrentItPos = CurrentMenu->oldItPos;
- if(!netgame && !demoplayback)
- {
- paused = true;
- }
- S_StartSound(NULL, sfx_dorcls);
- slottextloaded = false; //reload the slot text, when needed
- }
- //---------------------------------------------------------------------------
- //
- // PROC MN_DeactivateMenu
- //
- //---------------------------------------------------------------------------
- void MN_DeactivateMenu(void)
- {
- CurrentMenu->oldItPos = CurrentItPos;
- MenuActive = false;
- if(!netgame)
- {
- paused = false;
- }
- S_StartSound(NULL, sfx_dorcls);
- if(soundchanged)
- {
- S_SetMaxVolume(true); //recalc the sound curve
- soundchanged = false;
- }
- players[consoleplayer].message = NULL;
- players[consoleplayer].messageTics = 1;
- }
- //---------------------------------------------------------------------------
- //
- // PROC MN_DrawInfo
- //
- //---------------------------------------------------------------------------
- void MN_DrawInfo(void)
- {
- I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE));
- memcpy(screen, (byte *)W_CacheLumpNum(W_GetNumForName("TITLE")+InfoType,
- PU_CACHE), SCREENWIDTH*SCREENHEIGHT);
- // V_DrawPatch(0, 0, W_CacheLumpNum(W_GetNumForName("TITLE")+InfoType,
- // PU_CACHE));
- }
- //---------------------------------------------------------------------------
- //
- // PROC SetMenu
- //
- //---------------------------------------------------------------------------
- static void SetMenu(MenuType_t menu)
- {
- CurrentMenu->oldItPos = CurrentItPos;
- CurrentMenu = Menus[menu];
- CurrentItPos = CurrentMenu->oldItPos;
- }
- //---------------------------------------------------------------------------
- //
- // PROC DrawSlider
- //
- //---------------------------------------------------------------------------
- static void DrawSlider(Menu_t *menu, int item, int width, int slot)
- {
- int x;
- int y;
- int x2;
- int count;
- x = menu->x+24;
- y = menu->y+2+(item*ITEM_HEIGHT);
- V_DrawPatch(x-32, y, W_CacheLumpName("M_SLDLT", PU_CACHE));
- for(x2 = x, count = width; count--; x2 += 8)
- {
- V_DrawPatch(x2, y, W_CacheLumpName(count&1 ? "M_SLDMD1"
- : "M_SLDMD2", PU_CACHE));
- }
- V_DrawPatch(x2, y, W_CacheLumpName("M_SLDRT", PU_CACHE));
- V_DrawPatch(x+4+slot*8, y+7, W_CacheLumpName("M_SLDKB", PU_CACHE));
- }
|