Iskhodnyy_kod_Doom
.pdfvoid 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 |
231
&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", {1,"M_ROUGH", {1,"M_HURT", {1,"M_ULTRA", {1,"M_NMARE",
M_ChooseSkill, ’i’}, M_ChooseSkill, ’h’}, M_ChooseSkill, ’h’}, M_ChooseSkill, ’u’}, 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’}, |
232
{-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,
233
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’},
234
{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)
{
int |
handle; |
int |
count; |
int |
i; |
char |
name[256]; |
for (i = 0;i < load_end;i++)
{
if (M_CheckParm("-cdrom")) sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",i);
else
sprintf(name,SAVEGAMENAME"%d.dsg",i);
handle = open (name, O_RDONLY | 0, 0666); if (handle == -1)
{
strcpy(&savegamestrings[i][0],EMPTYSTRING); LoadMenu[i].status = 0;
continue;
}
count = read (handle, &savegamestrings[i], SAVESTRINGSIZE); close (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]);
}
}
235
//
// 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]);
}
236
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)
{
G_SaveGame (slot,savegamestrings[slot]);
M_ClearMenus ();
// PICK QUICKSAVE SLOT YET? if (quickSaveSlot == -2)
quickSaveSlot = slot;
}
//
// User wants to save. Start string input for M_Responder
//
void M_SaveSelect(int choice)
{
// we are going to be intercepting all chars saveStringEnter = 1;
saveSlot = choice; strcpy(saveOldString,savegamestrings[choice]);
if (!strcmp(savegamestrings[choice],EMPTYSTRING)) savegamestrings[choice][0] = 0;
saveCharIndex = strlen(savegamestrings[choice]);
}
//
// Selected from DOOM menu
//
void M_SaveGame (int choice)
{
if (!usergame)
{
M_StartMessage(SAVEDEAD,NULL,false); return;
}
if (gamestate != GS_LEVEL) return;
M_SetupNextMenu(&SaveDef);
M_ReadSaveStrings();
}
//
// M_QuickSave
//
char tempstring[80];
void M_QuickSaveResponse(int ch)
{
if (ch == ’y’)
{
237
M_DoSave(quickSaveSlot);
S_StartSound(NULL,sfx_swtchx);
}
}
void M_QuickSave(void)
{
if (!usergame)
{
S_StartSound(NULL,sfx_oof); return;
}
if (gamestate != GS_LEVEL) return;
if (quickSaveSlot < 0)
{
M_StartControlPanel();
M_ReadSaveStrings();
M_SetupNextMenu(&SaveDef);
quickSaveSlot = -2; // means to pick a slot now return;
}
sprintf(tempstring,QSPROMPT,savegamestrings[quickSaveSlot]); M_StartMessage(tempstring,M_QuickSaveResponse,true);
}
//
// M_QuickLoad
//
void M_QuickLoadResponse(int ch)
{
if (ch == ’y’)
{
M_LoadSelect(quickSaveSlot);
S_StartSound(NULL,sfx_swtchx);
}
}
void M_QuickLoad(void)
{
if (netgame)
{
M_StartMessage(QLOADNET,NULL,false); return;
}
if (quickSaveSlot < 0)
{
M_StartMessage(QSAVESPOT,NULL,false); return;
}
sprintf(tempstring,QLPROMPT,savegamestrings[quickSaveSlot]); M_StartMessage(tempstring,M_QuickLoadResponse,true);
}
//
// Read This Menus
238
// Had a "quick hack to fix romero bug"
//
void M_DrawReadThis1(void)
{
inhelpscreens = true; switch ( gamemode )
{
case commercial:
V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP",PU_CACHE)); break;
case shareware: case registered: case retail:
V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP1",PU_CACHE)); break;
default:
break;
}
return;
}
//
// Read This Menus - optional second page.
//
void M_DrawReadThis2(void)
{
inhelpscreens = true; switch ( gamemode )
{
case retail: case commercial:
// This hack keeps us from having to change menus. V_DrawPatchDirect (0,0,0,W_CacheLumpName("CREDIT",PU_CACHE)); break;
case shareware: case registered:
V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP2",PU_CACHE)); break;
default:
break;
}
return;
}
//
// Change Sfx & Music volumes
//
void M_DrawSound(void)
{
V_DrawPatchDirect (60,38,0,W_CacheLumpName("M_SVOL",PU_CACHE));
M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(sfx_vol+1),
16,snd_SfxVolume);
M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(music_vol+1),
16,snd_MusicVolume);
}
void M_Sound(int choice)
{
M_SetupNextMenu(&SoundDef);
}
239
void M_SfxVol(int choice)
{
switch(choice)
{
case 0:
if (snd_SfxVolume) snd_SfxVolume--;
break; case 1:
if (snd_SfxVolume < 15) snd_SfxVolume++;
break;
}
S_SetSfxVolume(snd_SfxVolume /* *8 */);
}
void M_MusicVol(int choice)
{
switch(choice)
{
case 0:
if (snd_MusicVolume) snd_MusicVolume--;
break; case 1:
if (snd_MusicVolume < 15) snd_MusicVolume++;
break;
}
S_SetMusicVolume(snd_MusicVolume /* *8 */);
}
//
// M_DrawMainMenu
//
void M_DrawMainMenu(void)
{
V_DrawPatchDirect (94,2,0,W_CacheLumpName("M_DOOM",PU_CACHE));
}
//
// M_NewGame
//
void M_DrawNewGame(void)
{
V_DrawPatchDirect (96,14,0,W_CacheLumpName("M_NEWG",PU_CACHE));
V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_SKILL",PU_CACHE));
}
void M_NewGame(int choice)
{
if (netgame && !demoplayback)
{
M_StartMessage(NEWGAME,NULL,false); return;
}
240