Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Iskhodnyy_kod_Doom

.pdf
Скачиваний:
7
Добавлен:
13.02.2015
Размер:
1.01 Mб
Скачать

if ( gamemode == commercial ) M_SetupNextMenu(&NewDef);

else

M_SetupNextMenu(&EpiDef);

}

//

 

//

M_Episode

//

 

int

epi;

void M_DrawEpisode(void)

{

V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_EPISOD",PU_CACHE));

}

void M_VerifyNightmare(int ch)

{

if (ch != ’y’) return;

G_DeferedInitNew(nightmare,epi+1,1);

M_ClearMenus ();

}

void M_ChooseSkill(int choice)

{

if (choice == nightmare)

{

M_StartMessage(NIGHTMARE,M_VerifyNightmare,true); return;

}

G_DeferedInitNew(choice,epi+1,1);

M_ClearMenus ();

}

void M_Episode(int choice)

{

if ( (gamemode == shareware) && choice)

{

M_StartMessage(SWSTRING,NULL,false);

M_SetupNextMenu(&ReadDef1);

return;

}

// Yet another hack...

if ( (gamemode == registered) && (choice > 2))

{

fprintf( stderr,

"M_Episode: 4th episode requires UltimateDOOM\n"); choice = 0;

}

epi = choice; M_SetupNextMenu(&NewDef);

}

//

241

// M_Options

 

//

 

 

char

detailNames[2][9]

= {"M_GDHIGH","M_GDLOW"};

char

msgNames[2][9]

= {"M_MSGOFF","M_MSGON"};

void M_DrawOptions(void)

{

V_DrawPatchDirect (108,15,0,W_CacheLumpName("M_OPTTTL",PU_CACHE));

V_DrawPatchDirect (OptionsDef.x + 175,OptionsDef.y+LINEHEIGHT*detail,0, W_CacheLumpName(detailNames[detailLevel],PU_CACHE));

V_DrawPatchDirect (OptionsDef.x + 120,OptionsDef.y+LINEHEIGHT*messages,0, W_CacheLumpName(msgNames[showMessages],PU_CACHE));

M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(mousesens+1),

10,mouseSensitivity);

M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(scrnsize+1),

9,screenSize);

}

void M_Options(int choice)

{

M_SetupNextMenu(&OptionsDef);

}

//

// Toggle messages on/off

//

void M_ChangeMessages(int choice)

{

// warning: unused parameter ‘int choice’ choice = 0;

showMessages = 1 - showMessages;

if (!showMessages) players[consoleplayer].message = MSGOFF;

else

players[consoleplayer].message = MSGON ;

message_dontfuckwithme = true;

}

//

// M_EndGame

//

void M_EndGameResponse(int ch)

{

if (ch != ’y’) return;

currentMenu->lastOn = itemOn; M_ClearMenus (); D_StartTitle ();

}

void M_EndGame(int choice)

{

choice = 0;

if (!usergame)

242

{

S_StartSound(NULL,sfx_oof); return;

}

if (netgame)

{

M_StartMessage(NETEND,NULL,false); return;

}

M_StartMessage(ENDGAME,M_EndGameResponse,true);

}

//

// M_ReadThis

//

void M_ReadThis(int choice)

{

choice = 0; M_SetupNextMenu(&ReadDef1);

}

void M_ReadThis2(int choice)

{

choice = 0; M_SetupNextMenu(&ReadDef2);

}

void M_FinishReadThis(int choice)

{

choice = 0; M_SetupNextMenu(&MainDef);

}

//

// M_QuitDOOM

//

int quitsounds[8] =

{

sfx_pldeth, sfx_dmpain, sfx_popain, sfx_slop, sfx_telept, sfx_posit1, sfx_posit3, sfx_sgtatk

};

int

quitsounds2[8] =

{

 

sfx_vilact, sfx_getpow, sfx_boscub, sfx_slop, sfx_skeswg, sfx_kntdth, sfx_bspact,

243

sfx_sgtatk

};

void M_QuitResponse(int ch)

{

if (ch != ’y’) return;

if (!netgame)

{

if (gamemode == commercial) S_StartSound(NULL,quitsounds2[(gametic>>2)&7]);

else

S_StartSound(NULL,quitsounds[(gametic>>2)&7]);

I_WaitVBL(105);

}

I_Quit ();

}

void M_QuitDOOM(int choice)

{

//We pick index 0 which is language sensitive,

//or one at random, between 1 and maximum number. if (language != english )

sprintf(endstring,"%s\n\n"DOSY, endmsg[0] ); else

sprintf(endstring,"%s\n\n"DOSY, endmsg[ (gametic%(NUM_QUITMESSAGES-2))+1 ]);

M_StartMessage(endstring,M_QuitResponse,true);

}

void M_ChangeSensitivity(int choice)

{

switch(choice)

{

case 0:

if (mouseSensitivity) mouseSensitivity--;

break; case 1:

if (mouseSensitivity < 9) mouseSensitivity++;

break;

}

}

void M_ChangeDetail(int choice)

{

choice = 0;

detailLevel = 1 - detailLevel;

// FIXME - does not work. Remove anyway?

fprintf( stderr, "M_ChangeDetail: low detail mode n.a.\n");

return;

244

/*R_SetViewSize (screenblocks, detailLevel);

if (!detailLevel) players[consoleplayer].message = DETAILHI;

else

players[consoleplayer].message = DETAILLO;*/

}

void M_SizeDisplay(int choice)

{

switch(choice)

{

case 0:

if (screenSize > 0)

{

screenblocks--; screenSize--;

}

break; case 1:

if (screenSize < 8)

{

screenblocks++;

screenSize++;

}

break;

}

R_SetViewSize (screenblocks, detailLevel);

}

//

 

 

//

Menu

Functions

//

 

 

void

 

 

M_DrawThermo

 

( int

 

x,

int

 

y,

int

 

thermWidth,

int

 

thermDot )

{

 

int

xx;

int

i;

xx = x;

V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERML",PU_CACHE)); xx += 8;

for (i=0;i<thermWidth;i++)

{

V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERMM",PU_CACHE)); xx += 8;

}

V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERMR",PU_CACHE));

V_DrawPatchDirect ((x+8) + thermDot*8,y, 0,W_CacheLumpName("M_THERMO",PU_CACHE));

}

245

void

 

 

M_DrawEmptyCell

 

 

( menu_t*

menu,

 

int

item )

 

{

 

 

V_DrawPatchDirect (menu->x - 10,

menu->y+item*LINEHEIGHT - 1, 0,

 

W_CacheLumpName("M_CELL1",PU_CACHE));

}

 

 

void

 

 

M_DrawSelCell

 

 

( menu_t*

menu,

 

int

item )

 

{

 

 

V_DrawPatchDirect (menu->x - 10,

menu->y+item*LINEHEIGHT - 1, 0,

 

W_CacheLumpName("M_CELL2",PU_CACHE));

}

 

 

void

 

 

M_StartMessage

 

 

( char*

string,

 

void*

routine,

 

boolean

input )

 

{

 

 

messageLastMenuActive = menuactive; messageToPrint = 1;

messageString = string; messageRoutine = routine; messageNeedsInput = input; menuactive = true;

return;

}

void M_StopMessage(void)

{

menuactive = messageLastMenuActive; messageToPrint = 0;

}

//

// Find string width from hu_font chars

//

int M_StringWidth(char* string)

{

int

i;

int

w = 0;

int

c;

for (i = 0;i < strlen(string);i++)

{

c = toupper(string[i]) - HU_FONTSTART; if (c < 0 || c >= HU_FONTSIZE)

w += 4;

else

w += SHORT (hu_font[c]->width);

}

246

return w;

}

//

// Find string height from hu_font chars

//

int M_StringHeight(char* string)

{

int

 

i;

int

 

h;

int

 

height = SHORT(hu_font[0]->height);

h =

height;

 

for

(i = 0;i < strlen(string);i++)

 

if (string[i] == ’\n’)

 

h += height;

return h;

 

}

 

 

//

 

 

//

Write a string using the hu_font

//

 

 

void

 

 

M_WriteText

 

( int

 

x,

int

 

y,

char*

 

string)

{

 

 

int

 

w;

char*

ch;

int

 

c;

int

 

cx;

int

 

cy;

ch = string; cx = x;

cy = y;

while(1)

{

c = *ch++; if (!c)

break;

if (c == ’\n’)

{

cx = x; cy += 12; continue;

}

c = toupper(c) - HU_FONTSTART; if (c < 0 || c>= HU_FONTSIZE)

{

cx += 4; continue;

}

w = SHORT (hu_font[c]->width); if (cx+w > SCREENWIDTH)

break;

247

V_DrawPatchDirect(cx, cy, 0, hu_font[c]); cx+=w;

}

}

//

// CONTROL PANEL

//

//

// M_Responder

//

boolean M_Responder (event_t* ev)

{

int

 

ch;

 

int

 

i;

 

static

int

joywait

= 0;

static

int

mousewait = 0;

static

int

mousey = 0;

static

int

lasty =

0;

static

int

mousex = 0;

static

int

lastx =

0;

ch = -1;

if (ev->type == ev_joystick && joywait < I_GetTime())

{

if (ev->data3 == -1)

{

ch = KEY_UPARROW;

joywait = I_GetTime() + 5;

}

else if (ev->data3 == 1)

{

ch = KEY_DOWNARROW; joywait = I_GetTime() + 5;

}

if (ev->data2 == -1)

{

ch = KEY_LEFTARROW; joywait = I_GetTime() + 2;

}

else if (ev->data2 == 1)

{

ch = KEY_RIGHTARROW; joywait = I_GetTime() + 2;

}

if (ev->data1&1)

{

ch = KEY_ENTER;

joywait = I_GetTime() + 5;

}

if (ev->data1&2)

{

ch = KEY_BACKSPACE; joywait = I_GetTime() + 5;

}

}

else

{

if (ev->type == ev_mouse && mousewait < I_GetTime())

248

{

mousey += ev->data3; if (mousey < lasty-30)

{

ch = KEY_DOWNARROW; mousewait = I_GetTime() + 5; mousey = lasty -= 30;

}

else if (mousey > lasty+30)

{

ch = KEY_UPARROW;

mousewait = I_GetTime() + 5; mousey = lasty += 30;

}

mousex += ev->data2; if (mousex < lastx-30)

{

ch = KEY_LEFTARROW; mousewait = I_GetTime() + 5; mousex = lastx -= 30;

}

else if (mousex > lastx+30)

{

ch = KEY_RIGHTARROW; mousewait = I_GetTime() + 5; mousex = lastx += 30;

}

if (ev->data1&1)

{

ch = KEY_ENTER;

mousewait = I_GetTime() + 15;

}

if (ev->data1&2)

{

ch = KEY_BACKSPACE;

mousewait = I_GetTime() + 15;

}

}

else

if (ev->type == ev_keydown)

{

ch = ev->data1;

}

}

if (ch == -1) return false;

// Save Game string input if (saveStringEnter)

{

switch(ch)

{

case KEY_BACKSPACE:

if (saveCharIndex > 0)

{

saveCharIndex--; savegamestrings[saveSlot][saveCharIndex] = 0;

}

break;

249

case KEY_ESCAPE: saveStringEnter = 0;

strcpy(&savegamestrings[saveSlot][0],saveOldString);

break;

case KEY_ENTER: saveStringEnter = 0;

if (savegamestrings[saveSlot][0]) M_DoSave(saveSlot);

break;

default:

ch = toupper(ch); if (ch != 32)

if (ch-HU_FONTSTART < 0 || ch-HU_FONTSTART >= HU_FONTSIZE) break;

if (ch >= 32 && ch <= 127 && saveCharIndex < SAVESTRINGSIZE-1 &&

M_StringWidth(savegamestrings[saveSlot]) < (SAVESTRINGSIZE-2)*8)

{

savegamestrings[saveSlot][saveCharIndex++] = ch; savegamestrings[saveSlot][saveCharIndex] = 0;

}

break;

}

return true;

}

// Take care of any messages that need input if (messageToPrint)

{

if (messageNeedsInput == true &&

!(ch == ’ ’ || ch == ’n’ || ch == ’y’ || ch == KEY_ESCAPE)) return false;

menuactive = messageLastMenuActive; messageToPrint = 0;

if (messageRoutine) messageRoutine(ch);

menuactive = false; S_StartSound(NULL,sfx_swtchx); return true;

}

if (devparm && ch == KEY_F1)

{

G_ScreenShot (); return true;

}

 

// F-Keys

 

if (!menuactive)

 

switch(ch)

 

{

 

case KEY_MINUS:

// Screen size down

if (automapactive || chat_on) return false;

M_SizeDisplay(0); S_StartSound(NULL,sfx_stnmov); return true;

case KEY_EQUALS: // Screen size up

250

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]