⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m_menu.c

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 C
📖 第 1 页 / 共 3 页
字号:
// Emacs style mode select   -*- C++ -*- //-----------------------------------------------------------------------------//// $Id: m_menu.c,v 1.2 2003/09/08 22:34:29 jasonk Exp $//// Copyright (C) 1993-1996 by id Software, Inc.//// This source is available for distribution and/or modification// only under the terms of the DOOM Source Code License as// published by id Software. All rights reserved.//// The source is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License// for more details.//// $Log: m_menu.c,v $// Revision 1.2  2003/09/08 22:34:29  jasonk// Updated files because this fucker won't build for no fucking good reason.//// Revision 1.1.1.1  2003/09/04 21:08:13  jasonk// Initial import//// Revision 1.1  2000/12/08 21:07:53  jeffw// nxdoom initial entry -- No nxdoom/Makefile so it won't build automatically////// DESCRIPTION://	DOOM selection menu, options, episode etc.//	Sliders and icons. Kinda widget stuff.////-----------------------------------------------------------------------------static const charrcsid[] = "$Id: m_menu.c,v 1.2 2003/09/08 22:34:29 jasonk Exp $";#include <stdio.h>#include <ctype.h>#include "m_swap.h"#include "doomdef.h"#include "dstrings.h"#include "d_main.h"#include "i_system.h"#include "i_video.h"#include "z_zone.h"#include "v_video.h"#include "w_wad.h"#include "r_local.h"#include "hu_stuff.h"#include "g_game.h"#include "m_argv.h"#include "s_sound.h"#include "doomstat.h"// Data.#include "sounds.h"#include "m_menu.h"extern patch_t*		hu_font[HU_FONTSIZE];extern boolean		message_dontfuckwithme;extern boolean		chat_on;		// in heads-up code//// defaulted values//int			mouseSensitivity;       // has default// Show messages has default, 0 = off, 1 = onint			showMessages;	// Blocky mode, has default, 0 = high, 1 = normalint			detailLevel;		int			screenblocks;		// has default// temp for screenblocks (0-9)int			screenSize;		// -1 = no quicksave slot picked!int			quickSaveSlot;           // 1 = message to be printedint			messageToPrint;// ...and here is the message string!char*			messageString;		// message x & yint			messx;			int			messy;int			messageLastMenuActive;// timed message = no input from userboolean			messageNeedsInput;     void    (*messageRoutine)(int response);#define SAVESTRINGSIZE 	24char gammamsg[5][26] ={    GAMMALVL0,    GAMMALVL1,    GAMMALVL2,    GAMMALVL3,    GAMMALVL4};// we are going to be entering a savegame stringint			saveStringEnter;              int             	saveSlot;	// which slot to save inint			saveCharIndex;	// which char we're editing// old save description before editchar			saveOldString[SAVESTRINGSIZE];  boolean			inhelpscreens;boolean			menuactive;#define SKULLXOFF		-32#define LINEHEIGHT		16extern boolean		sendpause;char			savegamestrings[10][SAVESTRINGSIZE];char	endstring[160];//// MENU TYPEDEFS//typedef struct{    // 0 = no cursor here, 1 = ok, 2 = arrows ok    short	status;        char	name[10];        // choice = menu item #.    // if status = 2,    //   choice=0:leftarrow,1:rightarrow    void	(*routine)(int choice);        // hotkey in menu    char	alphaKey;			} menuitem_t;typedef struct menu_s{    short		numitems;	// # of menu items    struct menu_s*	prevMenu;	// previous menu    menuitem_t*		menuitems;	// menu items    void		(*routine)();	// draw routine    short		x;    short		y;		// x,y of menu    short		lastOn;		// last item user was on in menu} menu_t;short		itemOn;			// menu item skull is onshort		skullAnimCounter;	// skull animation countershort		whichSkull;		// which skull to draw// graphic name of skulls// warning: initializer-string for array of chars is too longchar    skullName[2][/*8*/9] = {"M_SKULL1","M_SKULL2"};// current menudefmenu_t*	currentMenu;                          //// PROTOTYPES//void M_NewGame(int choice);void M_Episode(int choice);void M_ChooseSkill(int choice);void M_LoadGame(int choice);void M_SaveGame(int choice);void M_Options(int choice);void M_EndGame(int choice);void M_ReadThis(int choice);void M_ReadThis2(int choice);void M_QuitDOOM(int choice);void M_ChangeMessages(int choice);void M_ChangeSensitivity(int choice);void M_SfxVol(int choice);void M_MusicVol(int choice);void M_ChangeDetail(int choice);void M_SizeDisplay(int choice);void M_StartGame(int choice);void M_Sound(int choice);void M_FinishReadThis(int choice);void M_LoadSelect(int choice);void M_SaveSelect(int choice);void M_ReadSaveStrings(void);void M_QuickSave(void);void M_QuickLoad(void);void M_DrawMainMenu(void);void M_DrawReadThis1(void);void M_DrawReadThis2(void);void M_DrawNewGame(void);void M_DrawEpisode(void);void M_DrawOptions(void);void M_DrawSound(void);void M_DrawLoad(void);void M_DrawSave(void);void M_DrawSaveLoadBorder(int x,int y);void M_SetupNextMenu(menu_t *menudef);void M_DrawThermo(int x,int y,int thermWidth,int thermDot);void M_DrawEmptyCell(menu_t *menu,int item);void M_DrawSelCell(menu_t *menu,int item);void M_WriteText(int x, int y, char *string);int  M_StringWidth(char *string);int  M_StringHeight(char *string);void M_StartControlPanel(void);void M_StartMessage(char *string,void *routine,boolean input);void M_StopMessage(void);void M_ClearMenus (void);//// DOOM MENU//enum{    newgame = 0,    options,    loadgame,    savegame,    readthis,    quitdoom,    main_end} main_e;menuitem_t MainMenu[]={    {1,"M_NGAME",M_NewGame,'n'},    {1,"M_OPTION",M_Options,'o'},    {1,"M_LOADG",M_LoadGame,'l'},    {1,"M_SAVEG",M_SaveGame,'s'},    // Another hickup with Special edition.    {1,"M_RDTHIS",M_ReadThis,'r'},    {1,"M_QUITG",M_QuitDOOM,'q'}};menu_t  MainDef ={    main_end,    NULL,    MainMenu,    M_DrawMainMenu,    97,64,    0};//// EPISODE SELECT//enum{    ep1,    ep2,    ep3,    ep4,    ep_end} episodes_e;menuitem_t EpisodeMenu[]={    {1,"M_EPI1", M_Episode,'k'},    {1,"M_EPI2", M_Episode,'t'},    {1,"M_EPI3", M_Episode,'i'},    {1,"M_EPI4", M_Episode,'t'}};menu_t  EpiDef ={    ep_end,		// # of menu items    &MainDef,		// previous menu    EpisodeMenu,	// menuitem_t ->    M_DrawEpisode,	// drawing routine ->    48,63,              // x,y    ep1			// lastOn};//// NEW GAME//enum{    killthings,    toorough,    hurtme,    violence,    nightmare,    newg_end} newgame_e;menuitem_t NewGameMenu[]={    {1,"M_JKILL",	M_ChooseSkill, 'i'},    {1,"M_ROUGH",	M_ChooseSkill, 'h'},    {1,"M_HURT",	M_ChooseSkill, 'h'},    {1,"M_ULTRA",	M_ChooseSkill, 'u'},    {1,"M_NMARE",	M_ChooseSkill, 'n'}};menu_t  NewDef ={    newg_end,		// # of menu items    &EpiDef,		// previous menu    NewGameMenu,	// menuitem_t ->    M_DrawNewGame,	// drawing routine ->    48,63,              // x,y    hurtme		// lastOn};//// OPTIONS MENU//enum{    endgame,    messages,    detail,    scrnsize,    option_empty1,    mousesens,    option_empty2,    soundvol,    opt_end} options_e;menuitem_t OptionsMenu[]={    {1,"M_ENDGAM",	M_EndGame,'e'},    {1,"M_MESSG",	M_ChangeMessages,'m'},    {1,"M_DETAIL",	M_ChangeDetail,'g'},    {2,"M_SCRNSZ",	M_SizeDisplay,'s'},    {-1,"",0},    {2,"M_MSENS",	M_ChangeSensitivity,'m'},    {-1,"",0},    {1,"M_SVOL",	M_Sound,'s'}};menu_t  OptionsDef ={    opt_end,    &MainDef,    OptionsMenu,    M_DrawOptions,    60,37,    0};//// Read This! MENU 1 & 2//enum{    rdthsempty1,    read1_end} read_e;menuitem_t ReadMenu1[] ={    {1,"",M_ReadThis2,0}};menu_t  ReadDef1 ={    read1_end,    &MainDef,    ReadMenu1,    M_DrawReadThis1,    280,185,    0};enum{    rdthsempty2,    read2_end} read_e2;menuitem_t ReadMenu2[]={    {1,"",M_FinishReadThis,0}};menu_t  ReadDef2 ={    read2_end,    &ReadDef1,    ReadMenu2,    M_DrawReadThis2,    330,175,    0};//// SOUND VOLUME MENU//enum{    sfx_vol,    sfx_empty1,    music_vol,    sfx_empty2,    sound_end} sound_e;menuitem_t SoundMenu[]={    {2,"M_SFXVOL",M_SfxVol,'s'},    {-1,"",0},    {2,"M_MUSVOL",M_MusicVol,'m'},    {-1,"",0}};menu_t  SoundDef ={    sound_end,    &OptionsDef,    SoundMenu,    M_DrawSound,    80,64,    0};//// LOAD GAME MENU//enum{    load1,    load2,    load3,    load4,    load5,    load6,    load_end} load_e;menuitem_t LoadMenu[]={    {1,"", M_LoadSelect,'1'},    {1,"", M_LoadSelect,'2'},    {1,"", M_LoadSelect,'3'},    {1,"", M_LoadSelect,'4'},    {1,"", M_LoadSelect,'5'},    {1,"", M_LoadSelect,'6'}};menu_t  LoadDef ={    load_end,    &MainDef,    LoadMenu,    M_DrawLoad,    80,54,    0};//// SAVE GAME MENU//menuitem_t SaveMenu[]={    {1,"", M_SaveSelect,'1'},    {1,"", M_SaveSelect,'2'},    {1,"", M_SaveSelect,'3'},    {1,"", M_SaveSelect,'4'},    {1,"", M_SaveSelect,'5'},    {1,"", M_SaveSelect,'6'}};menu_t  SaveDef ={    load_end,    &MainDef,    SaveMenu,    M_DrawSave,    80,54,    0};//// M_ReadSaveStrings//  read the strings from the savegame files//void M_ReadSaveStrings(void){    FILE           *handle;    int             count;    int             i;    char    name[256];	    for (i = 0;i < load_end;i++)    {	sprintf(name,SAVEGAMENAME"%d.dsg",i);	handle = fopen (name, "r");	if (handle == NULL)	{	    strcpy(&savegamestrings[i][0],EMPTYSTRING);	    LoadMenu[i].status = 0;	    continue;	}	count = fread (&savegamestrings[i], 1, SAVESTRINGSIZE, handle);	fclose (handle);	LoadMenu[i].status = 1;    }}//// M_LoadGame & Cie.//void M_DrawLoad(void){    int             i;	    V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_LOADG",PU_CACHE));    for (i = 0;i < load_end; i++)    {	M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i);	M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]);    }}//// Draw border for the savegame description//void M_DrawSaveLoadBorder(int x,int y){    int             i;	    V_DrawPatchDirect (x-8,y+7,0,W_CacheLumpName("M_LSLEFT",PU_CACHE));	    for (i = 0;i < 24;i++)    {	V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSCNTR",PU_CACHE));	x += 8;    }    V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSRGHT",PU_CACHE));}//// User wants to load this game//void M_LoadSelect(int choice){    char    name[256];	    if (M_CheckParm("-cdrom"))	sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",choice);    else	sprintf(name,SAVEGAMENAME"%d.dsg",choice);    G_LoadGame (name);    M_ClearMenus ();}//// Selected from DOOM menu//void M_LoadGame (int choice){    if (netgame)    {	M_StartMessage(LOADNET,NULL,false);	return;    }	    M_SetupNextMenu(&LoadDef);    M_ReadSaveStrings();}////  M_SaveGame & Cie.//void M_DrawSave(void){    int             i;	    V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_SAVEG",PU_CACHE));    for (i = 0;i < load_end; i++)    {	M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i);	M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]);    }	    if (saveStringEnter)    {	i = M_StringWidth(savegamestrings[saveSlot]);	M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*saveSlot,"_");    }}//// M_Responder calls this when user is finished//void M_DoSave(int slot)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -