Annotation of quake1/menu.c, revision 1.1.1.3

1.1       root        1: #include "quakedef.h"
                      2: 
1.1.1.3 ! root        3: #ifdef _WIN32
        !             4: #include "winquake.h"
        !             5: #endif
        !             6: 
        !             7: void (*vid_menudrawfn)(void);
        !             8: void (*vid_menukeyfn)(int key);
        !             9: 
1.1       root       10: enum {m_none, m_main, m_singleplayer, m_load, m_save, m_multiplayer, m_setup, m_net, m_options, m_video, m_keys, m_help, m_quit, m_serialconfig, m_modemconfig, m_lanconfig, m_gameoptions, m_search, m_slist} m_state;
                     11: 
                     12: void M_Menu_Main_f (void);
                     13:        void M_Menu_SinglePlayer_f (void);
                     14:                void M_Menu_Load_f (void);
                     15:                void M_Menu_Save_f (void);
                     16:        void M_Menu_MultiPlayer_f (void);
                     17:                void M_Menu_Setup_f (void);
                     18:                void M_Menu_Net_f (void);
                     19:        void M_Menu_Options_f (void);
                     20:                void M_Menu_Keys_f (void);
                     21:                void M_Menu_Video_f (void);
                     22:        void M_Menu_Help_f (void);
                     23:        void M_Menu_Quit_f (void);
                     24: void M_Menu_SerialConfig_f (void);
                     25:        void M_Menu_ModemConfig_f (void);
                     26: void M_Menu_LanConfig_f (void);
                     27: void M_Menu_GameOptions_f (void);
                     28: void M_Menu_Search_f (void);
                     29: void M_Menu_ServerList_f (void);
                     30: 
                     31: void M_Main_Draw (void);
                     32:        void M_SinglePlayer_Draw (void);
                     33:                void M_Load_Draw (void);
                     34:                void M_Save_Draw (void);
                     35:        void M_MultiPlayer_Draw (void);
                     36:                void M_Setup_Draw (void);
                     37:                void M_Net_Draw (void);
                     38:        void M_Options_Draw (void);
                     39:                void M_Keys_Draw (void);
                     40:                void M_Video_Draw (void);
                     41:        void M_Help_Draw (void);
                     42:        void M_Quit_Draw (void);
                     43: void M_SerialConfig_Draw (void);
                     44:        void M_ModemConfig_Draw (void);
                     45: void M_LanConfig_Draw (void);
                     46: void M_GameOptions_Draw (void);
                     47: void M_Search_Draw (void);
                     48: void M_ServerList_Draw (void);
                     49: 
                     50: void M_Main_Key (int key);
                     51:        void M_SinglePlayer_Key (int key);
                     52:                void M_Load_Key (int key);
                     53:                void M_Save_Key (int key);
                     54:        void M_MultiPlayer_Key (int key);
                     55:                void M_Setup_Key (int key);
                     56:                void M_Net_Key (int key);
                     57:        void M_Options_Key (int key);
                     58:                void M_Keys_Key (int key);
                     59:                void M_Video_Key (int key);
                     60:        void M_Help_Key (int key);
                     61:        void M_Quit_Key (int key);
                     62: void M_SerialConfig_Key (int key);
                     63:        void M_ModemConfig_Key (int key);
                     64: void M_LanConfig_Key (int key);
                     65: void M_GameOptions_Key (int key);
                     66: void M_Search_Key (int key);
                     67: void M_ServerList_Key (int key);
                     68: 
                     69: qboolean       m_entersound;           // play after drawing a frame, so caching
                     70:                                                                // won't disrupt the sound
                     71: qboolean       m_recursiveDraw;
                     72: 
1.1.1.3 ! root       73: int                    m_return_state;
        !            74: qboolean       m_return_onerror;
        !            75: char           m_return_reason [32];
        !            76: 
1.1       root       77: #define StartingGame   (m_multiplayer_cursor == 1)
                     78: #define JoiningGame            (m_multiplayer_cursor == 0)
                     79: #define SerialConfig   (m_net_cursor == 0)
                     80: #define DirectConfig   (m_net_cursor == 1)
                     81: #define        IPXConfig               (m_net_cursor == 2)
                     82: #define        TCPIPConfig             (m_net_cursor == 3)
                     83: 
                     84: void M_ConfigureNetSubsystem(void);
                     85: 
                     86: /*
                     87: ================
                     88: M_DrawCharacter
                     89: 
                     90: Draws one solid graphics character
                     91: ================
                     92: */
                     93: void M_DrawCharacter (int cx, int line, int num)
                     94: {
                     95:        Draw_Character ( cx + ((vid.width - 320)>>1), line, num);
                     96: }
                     97: 
                     98: void M_Print (int cx, int cy, char *str)
                     99: {
                    100:        while (*str)
                    101:        {
                    102:                M_DrawCharacter (cx, cy, (*str)+128);
                    103:                str++;
                    104:                cx += 8;
                    105:        }
                    106: }
                    107: 
                    108: void M_PrintWhite (int cx, int cy, char *str)
                    109: {
                    110:        while (*str)
                    111:        {
                    112:                M_DrawCharacter (cx, cy, *str);
                    113:                str++;
                    114:                cx += 8;
                    115:        }
                    116: }
                    117: 
                    118: void M_DrawTransPic (int x, int y, qpic_t *pic)
                    119: {
                    120:        Draw_TransPic (x + ((vid.width - 320)>>1), y, pic);
                    121: }
                    122: 
                    123: void M_DrawPic (int x, int y, qpic_t *pic)
                    124: {
                    125:        Draw_Pic (x + ((vid.width - 320)>>1), y, pic);
                    126: }
                    127: 
                    128: byte identityTable[256];
                    129: byte translationTable[256];
                    130: 
                    131: void M_BuildTranslationTable(int top, int bottom)
                    132: {
                    133:        int             j;
                    134:        byte    *dest, *source;
                    135: 
                    136:        for (j = 0; j < 256; j++)
                    137:                identityTable[j] = j;
                    138:        dest = translationTable;
                    139:        source = identityTable;
                    140:        memcpy (dest, source, 256);
                    141: 
                    142:        if (top < 128)  // the artists made some backwards ranges.  sigh.
                    143:                memcpy (dest + TOP_RANGE, source + top, 16);
                    144:        else
                    145:                for (j=0 ; j<16 ; j++)
                    146:                        dest[TOP_RANGE+j] = source[top+15-j];
                    147: 
                    148:        if (bottom < 128)
                    149:                memcpy (dest + BOTTOM_RANGE, source + bottom, 16);
                    150:        else
                    151:                for (j=0 ; j<16 ; j++)
1.1.1.3 ! root      152:                        dest[BOTTOM_RANGE+j] = source[bottom+15-j];
1.1       root      153: }
                    154: 
                    155: 
                    156: void M_DrawTransPicTranslate (int x, int y, qpic_t *pic)
                    157: {
                    158:        Draw_TransPicTranslate (x + ((vid.width - 320)>>1), y, pic, translationTable);
                    159: }
                    160: 
                    161: 
                    162: void M_DrawTextBox (int x, int y, int width, int lines)
                    163: {
                    164:        qpic_t  *p;
                    165:        int             cx, cy;
                    166:        int             n;
                    167: 
                    168:        // draw left side
                    169:        cx = x;
                    170:        cy = y;
1.1.1.3 ! root      171:        p = Draw_CachePic ("gfx/box_tl.lmp");
1.1       root      172:        M_DrawTransPic (cx, cy, p);
1.1.1.3 ! root      173:        p = Draw_CachePic ("gfx/box_ml.lmp");
1.1       root      174:        for (n = 0; n < lines; n++)
                    175:        {
                    176:                cy += 8;
                    177:                M_DrawTransPic (cx, cy, p);
                    178:        }
1.1.1.3 ! root      179:        p = Draw_CachePic ("gfx/box_bl.lmp");
1.1       root      180:        M_DrawTransPic (cx, cy+8, p);
                    181: 
                    182:        // draw middle
                    183:        cx += 8;
                    184:        while (width > 0)
                    185:        {
                    186:                cy = y;
1.1.1.3 ! root      187:                p = Draw_CachePic ("gfx/box_tm.lmp");
1.1       root      188:                M_DrawTransPic (cx, cy, p);
1.1.1.3 ! root      189:                p = Draw_CachePic ("gfx/box_mm.lmp");
1.1       root      190:                for (n = 0; n < lines; n++)
                    191:                {
                    192:                        cy += 8;
                    193:                        if (n == 1)
1.1.1.3 ! root      194:                                p = Draw_CachePic ("gfx/box_mm2.lmp");
1.1       root      195:                        M_DrawTransPic (cx, cy, p);
                    196:                }
1.1.1.3 ! root      197:                p = Draw_CachePic ("gfx/box_bm.lmp");
1.1       root      198:                M_DrawTransPic (cx, cy+8, p);
                    199:                width -= 2;
                    200:                cx += 16;
                    201:        }
                    202: 
                    203:        // draw right side
                    204:        cy = y;
1.1.1.3 ! root      205:        p = Draw_CachePic ("gfx/box_tr.lmp");
1.1       root      206:        M_DrawTransPic (cx, cy, p);
1.1.1.3 ! root      207:        p = Draw_CachePic ("gfx/box_mr.lmp");
1.1       root      208:        for (n = 0; n < lines; n++)
                    209:        {
                    210:                cy += 8;
                    211:                M_DrawTransPic (cx, cy, p);
                    212:        }
1.1.1.3 ! root      213:        p = Draw_CachePic ("gfx/box_br.lmp");
1.1       root      214:        M_DrawTransPic (cx, cy+8, p);
                    215: }
                    216: 
                    217: //=============================================================================
                    218: 
                    219: int m_save_demonum;
1.1.1.3 ! root      220: 
1.1       root      221: /*
                    222: ================
                    223: M_ToggleMenu_f
                    224: ================
                    225: */
                    226: void M_ToggleMenu_f (void)
                    227: {
                    228:        m_entersound = true;
                    229: 
                    230:        if (key_dest == key_menu)
                    231:        {
                    232:                if (m_state != m_main)
                    233:                {
                    234:                        M_Menu_Main_f ();
                    235:                        return;
                    236:                }
                    237:                key_dest = key_game;
                    238:                m_state = m_none;
                    239:                return;
                    240:        }
                    241:        if (key_dest == key_console)
                    242:        {
                    243:                Con_ToggleConsole_f ();
                    244:        }
                    245:        else
                    246:        {
                    247:                M_Menu_Main_f ();
                    248:        }
                    249: }
                    250: 
1.1.1.3 ! root      251: 
1.1       root      252: //=============================================================================
                    253: /* MAIN MENU */
                    254: 
                    255: int    m_main_cursor;
                    256: #define        MAIN_ITEMS      5
                    257: 
                    258: 
                    259: void M_Menu_Main_f (void)
                    260: {
                    261:        if (key_dest != key_menu)
                    262:        {
                    263:                m_save_demonum = cls.demonum;
                    264:                cls.demonum = -1;
                    265:        }
                    266:        key_dest = key_menu;
                    267:        m_state = m_main;
                    268:        m_entersound = true;
                    269: }
1.1.1.3 ! root      270: 
1.1       root      271: 
                    272: void M_Main_Draw (void)
                    273: {
                    274:        int             f;
                    275:        qpic_t  *p;
                    276: 
1.1.1.3 ! root      277:        M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
        !           278:        p = Draw_CachePic ("gfx/ttl_main.lmp");
1.1       root      279:        M_DrawPic ( (320-p->width)/2, 4, p);
1.1.1.3 ! root      280:        M_DrawTransPic (72, 32, Draw_CachePic ("gfx/mainmenu.lmp") );
1.1       root      281: 
                    282:        f = (int)(host_time * 10)%6;
1.1.1.3 ! root      283: 
        !           284:        M_DrawTransPic (54, 32 + m_main_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
1.1       root      285: }
                    286: 
                    287: 
                    288: void M_Main_Key (int key)
                    289: {
                    290:        switch (key)
                    291:        {
                    292:        case K_ESCAPE:
                    293:                key_dest = key_game;
                    294:                m_state = m_none;
                    295:                cls.demonum = m_save_demonum;
                    296:                if (cls.demonum != -1 && !cls.demoplayback && cls.state != ca_connected)
                    297:                        CL_NextDemo ();
                    298:                break;
1.1.1.3 ! root      299: 
1.1       root      300:        case K_DOWNARROW:
                    301:                S_LocalSound ("misc/menu1.wav");
                    302:                if (++m_main_cursor >= MAIN_ITEMS)
                    303:                        m_main_cursor = 0;
                    304:                break;
                    305: 
                    306:        case K_UPARROW:
                    307:                S_LocalSound ("misc/menu1.wav");
                    308:                if (--m_main_cursor < 0)
                    309:                        m_main_cursor = MAIN_ITEMS - 1;
                    310:                break;
                    311: 
                    312:        case K_ENTER:
                    313:                m_entersound = true;
                    314: 
                    315:                switch (m_main_cursor)
                    316:                {
                    317:                case 0:
                    318:                        M_Menu_SinglePlayer_f ();
                    319:                        break;
                    320: 
                    321:                case 1:
                    322:                        M_Menu_MultiPlayer_f ();
                    323:                        break;
                    324: 
                    325:                case 2:
                    326:                        M_Menu_Options_f ();
                    327:                        break;
                    328: 
                    329:                case 3:
                    330:                        M_Menu_Help_f ();
                    331:                        break;
                    332: 
                    333:                case 4:
                    334:                        M_Menu_Quit_f ();
                    335:                        break;
                    336:                }
                    337:        }
                    338: }
                    339: 
                    340: //=============================================================================
                    341: /* SINGLE PLAYER MENU */
                    342: 
                    343: int    m_singleplayer_cursor;
                    344: #define        SINGLEPLAYER_ITEMS      3
                    345: 
                    346: 
                    347: void M_Menu_SinglePlayer_f (void)
                    348: {
                    349:        key_dest = key_menu;
                    350:        m_state = m_singleplayer;
                    351:        m_entersound = true;
                    352: }
1.1.1.3 ! root      353: 
1.1       root      354: 
                    355: void M_SinglePlayer_Draw (void)
                    356: {
                    357:        int             f;
                    358:        qpic_t  *p;
                    359: 
1.1.1.3 ! root      360:        M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
        !           361:        p = Draw_CachePic ("gfx/ttl_sgl.lmp");
1.1       root      362:        M_DrawPic ( (320-p->width)/2, 4, p);
1.1.1.3 ! root      363:        M_DrawTransPic (72, 32, Draw_CachePic ("gfx/sp_menu.lmp") );
1.1       root      364: 
                    365:        f = (int)(host_time * 10)%6;
1.1.1.3 ! root      366: 
        !           367:        M_DrawTransPic (54, 32 + m_singleplayer_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
1.1       root      368: }
                    369: 
                    370: 
                    371: void M_SinglePlayer_Key (int key)
                    372: {
                    373:        switch (key)
                    374:        {
                    375:        case K_ESCAPE:
                    376:                M_Menu_Main_f ();
                    377:                break;
1.1.1.3 ! root      378: 
1.1       root      379:        case K_DOWNARROW:
                    380:                S_LocalSound ("misc/menu1.wav");
                    381:                if (++m_singleplayer_cursor >= SINGLEPLAYER_ITEMS)
                    382:                        m_singleplayer_cursor = 0;
                    383:                break;
                    384: 
                    385:        case K_UPARROW:
                    386:                S_LocalSound ("misc/menu1.wav");
                    387:                if (--m_singleplayer_cursor < 0)
                    388:                        m_singleplayer_cursor = SINGLEPLAYER_ITEMS - 1;
                    389:                break;
                    390: 
                    391:        case K_ENTER:
                    392:                m_entersound = true;
                    393: 
                    394:                switch (m_singleplayer_cursor)
                    395:                {
                    396:                case 0:
                    397:                        if (sv.active)
                    398:                                if (!SCR_ModalMessage("Are you sure you want to\nstart a new game?\n"))
                    399:                                        break;
                    400:                        key_dest = key_game;
                    401:                        if (sv.active)
                    402:                                Cbuf_AddText ("disconnect\n");
                    403:                        Cbuf_AddText ("maxplayers 1\n");
                    404:                        Cbuf_AddText ("map start\n");
                    405:                        break;
                    406: 
                    407:                case 1:
                    408:                        M_Menu_Load_f ();
                    409:                        break;
                    410: 
                    411:                case 2:
                    412:                        M_Menu_Save_f ();
                    413:                        break;
                    414:                }
                    415:        }
                    416: }
                    417: 
                    418: //=============================================================================
                    419: /* LOAD/SAVE MENU */
                    420: 
                    421: int            load_cursor;            // 0 < load_cursor < MAX_SAVEGAMES
                    422: 
                    423: #define        MAX_SAVEGAMES           12
                    424: char   m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1];
                    425: int            loadable[MAX_SAVEGAMES];
                    426: 
                    427: void M_ScanSaves (void)
                    428: {
                    429:        int             i, j;
                    430:        char    name[MAX_OSPATH];
                    431:        FILE    *f;
                    432:        int             version;
                    433: 
                    434:        for (i=0 ; i<MAX_SAVEGAMES ; i++)
                    435:        {
                    436:                strcpy (m_filenames[i], "--- UNUSED SLOT ---");
                    437:                loadable[i] = false;
                    438:                sprintf (name, "%s/s%i.sav", com_gamedir, i);
                    439:                f = fopen (name, "r");
                    440:                if (!f)
                    441:                        continue;
                    442:                fscanf (f, "%i\n", &version);
                    443:                fscanf (f, "%79s\n", name);
                    444:                strncpy (m_filenames[i], name, sizeof(m_filenames[i])-1);
                    445: 
                    446:        // change _ back to space
                    447:                for (j=0 ; j<SAVEGAME_COMMENT_LENGTH ; j++)
                    448:                        if (m_filenames[i][j] == '_')
                    449:                                m_filenames[i][j] = ' ';
                    450:                loadable[i] = true;
1.1.1.3 ! root      451:                fclose (f);
1.1       root      452:        }
                    453: }
                    454: 
                    455: void M_Menu_Load_f (void)
                    456: {
                    457:        m_entersound = true;
                    458:        m_state = m_load;
                    459:        key_dest = key_menu;
                    460:        M_ScanSaves ();
                    461: }
1.1.1.3 ! root      462: 
1.1       root      463: 
                    464: void M_Menu_Save_f (void)
                    465: {
                    466:        if (!sv.active)
                    467:                return;
                    468:        if (cl.intermission)
                    469:                return;
                    470:        if (svs.maxclients != 1)
                    471:                return;
                    472:        m_entersound = true;
                    473:        m_state = m_save;
                    474:        key_dest = key_menu;
                    475:        M_ScanSaves ();
                    476: }
                    477: 
                    478: 
                    479: void M_Load_Draw (void)
                    480: {
                    481:        int             i;
                    482:        qpic_t  *p;
1.1.1.3 ! root      483: 
        !           484:        p = Draw_CachePic ("gfx/p_load.lmp");
1.1       root      485:        M_DrawPic ( (320-p->width)/2, 4, p);
1.1.1.3 ! root      486: 
1.1       root      487:        for (i=0 ; i< MAX_SAVEGAMES; i++)
                    488:                M_Print (16, 32 + 8*i, m_filenames[i]);
                    489: 
                    490: // line cursor
                    491:        M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
                    492: }
                    493: 
                    494: 
                    495: void M_Save_Draw (void)
                    496: {
                    497:        int             i;
                    498:        qpic_t  *p;
1.1.1.3 ! root      499: 
        !           500:        p = Draw_CachePic ("gfx/p_save.lmp");
1.1       root      501:        M_DrawPic ( (320-p->width)/2, 4, p);
                    502: 
                    503:        for (i=0 ; i<MAX_SAVEGAMES ; i++)
                    504:                M_Print (16, 32 + 8*i, m_filenames[i]);
                    505: 
                    506: // line cursor
                    507:        M_DrawCharacter (8, 32 + load_cursor*8, 12+((int)(realtime*4)&1));
                    508: }
                    509: 
                    510: 
                    511: void M_Load_Key (int k)
1.1.1.3 ! root      512: {
1.1       root      513:        switch (k)
                    514:        {
                    515:        case K_ESCAPE:
                    516:                M_Menu_SinglePlayer_f ();
                    517:                break;
                    518: 
                    519:        case K_ENTER:
                    520:                S_LocalSound ("misc/menu2.wav");
                    521:                if (!loadable[load_cursor])
                    522:                        return;
                    523:                m_state = m_none;
                    524:                key_dest = key_game;
                    525: 
                    526:        // Host_Loadgame_f can't bring up the loading plaque because too much
                    527:        // stack space has been used, so do it now
                    528:                SCR_BeginLoadingPlaque ();
                    529: 
                    530:        // issue the load command
                    531:                Cbuf_AddText (va ("load s%i\n", load_cursor) );
                    532:                return;
1.1.1.3 ! root      533: 
1.1       root      534:        case K_UPARROW:
                    535:        case K_LEFTARROW:
                    536:                S_LocalSound ("misc/menu1.wav");
                    537:                load_cursor--;
                    538:                if (load_cursor < 0)
                    539:                        load_cursor = MAX_SAVEGAMES-1;
                    540:                break;
                    541: 
                    542:        case K_DOWNARROW:
                    543:        case K_RIGHTARROW:
                    544:                S_LocalSound ("misc/menu1.wav");
                    545:                load_cursor++;
                    546:                if (load_cursor >= MAX_SAVEGAMES)
                    547:                        load_cursor = 0;
                    548:                break;
                    549:        }
                    550: }
                    551: 
                    552: 
                    553: void M_Save_Key (int k)
                    554: {
                    555:        switch (k)
                    556:        {
                    557:        case K_ESCAPE:
                    558:                M_Menu_SinglePlayer_f ();
                    559:                break;
                    560: 
                    561:        case K_ENTER:
                    562:                m_state = m_none;
                    563:                key_dest = key_game;
                    564:                Cbuf_AddText (va("save s%i\n", load_cursor));
                    565:                return;
1.1.1.3 ! root      566: 
1.1       root      567:        case K_UPARROW:
                    568:        case K_LEFTARROW:
                    569:                S_LocalSound ("misc/menu1.wav");
                    570:                load_cursor--;
                    571:                if (load_cursor < 0)
                    572:                        load_cursor = MAX_SAVEGAMES-1;
                    573:                break;
                    574: 
                    575:        case K_DOWNARROW:
                    576:        case K_RIGHTARROW:
                    577:                S_LocalSound ("misc/menu1.wav");
                    578:                load_cursor++;
                    579:                if (load_cursor >= MAX_SAVEGAMES)
                    580:                        load_cursor = 0;
1.1.1.3 ! root      581:                break;
1.1       root      582:        }
                    583: }
                    584: 
                    585: //=============================================================================
                    586: /* MULTIPLAYER MENU */
                    587: 
                    588: int    m_multiplayer_cursor;
                    589: #define        MULTIPLAYER_ITEMS       3
                    590: 
                    591: 
                    592: void M_Menu_MultiPlayer_f (void)
                    593: {
                    594:        key_dest = key_menu;
                    595:        m_state = m_multiplayer;
                    596:        m_entersound = true;
                    597: }
1.1.1.3 ! root      598: 
1.1       root      599: 
                    600: void M_MultiPlayer_Draw (void)
                    601: {
                    602:        int             f;
                    603:        qpic_t  *p;
                    604: 
1.1.1.3 ! root      605:        M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
        !           606:        p = Draw_CachePic ("gfx/p_multi.lmp");
1.1       root      607:        M_DrawPic ( (320-p->width)/2, 4, p);
1.1.1.3 ! root      608:        M_DrawTransPic (72, 32, Draw_CachePic ("gfx/mp_menu.lmp") );
1.1       root      609: 
                    610:        f = (int)(host_time * 10)%6;
1.1.1.3 ! root      611: 
        !           612:        M_DrawTransPic (54, 32 + m_multiplayer_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
        !           613: 
        !           614:        if (serialAvailable || ipxAvailable || tcpipAvailable)
        !           615:                return;
        !           616:        M_PrintWhite ((320/2) - ((27*8)/2), 148, "No Communications Available");
1.1       root      617: }
                    618: 
                    619: 
                    620: void M_MultiPlayer_Key (int key)
                    621: {
                    622:        switch (key)
                    623:        {
                    624:        case K_ESCAPE:
                    625:                M_Menu_Main_f ();
                    626:                break;
1.1.1.3 ! root      627: 
1.1       root      628:        case K_DOWNARROW:
                    629:                S_LocalSound ("misc/menu1.wav");
                    630:                if (++m_multiplayer_cursor >= MULTIPLAYER_ITEMS)
                    631:                        m_multiplayer_cursor = 0;
                    632:                break;
                    633: 
                    634:        case K_UPARROW:
                    635:                S_LocalSound ("misc/menu1.wav");
                    636:                if (--m_multiplayer_cursor < 0)
                    637:                        m_multiplayer_cursor = MULTIPLAYER_ITEMS - 1;
                    638:                break;
                    639: 
                    640:        case K_ENTER:
                    641:                m_entersound = true;
                    642:                switch (m_multiplayer_cursor)
                    643:                {
                    644:                case 0:
1.1.1.3 ! root      645:                        if (serialAvailable || ipxAvailable || tcpipAvailable)
        !           646:                                M_Menu_Net_f ();
1.1       root      647:                        break;
                    648: 
                    649:                case 1:
1.1.1.3 ! root      650:                        if (serialAvailable || ipxAvailable || tcpipAvailable)
        !           651:                                M_Menu_Net_f ();
1.1       root      652:                        break;
                    653: 
                    654:                case 2:
                    655:                        M_Menu_Setup_f ();
                    656:                        break;
                    657:                }
                    658:        }
                    659: }
                    660: 
                    661: //=============================================================================
                    662: /* SETUP MENU */
                    663: 
                    664: int            setup_cursor = 4;
                    665: int            setup_cursor_table[] = {40, 56, 80, 104, 140};
                    666: 
                    667: char   setup_hostname[16];
                    668: char   setup_myname[16];
                    669: int            setup_oldtop;
                    670: int            setup_oldbottom;
                    671: int            setup_top;
                    672: int            setup_bottom;
                    673: 
                    674: #define        NUM_SETUP_CMDS  5
                    675: 
                    676: void M_Menu_Setup_f (void)
                    677: {
                    678:        key_dest = key_menu;
                    679:        m_state = m_setup;
                    680:        m_entersound = true;
                    681:        Q_strcpy(setup_myname, cl_name.string);
                    682:        Q_strcpy(setup_hostname, hostname.string);
                    683:        setup_top = setup_oldtop = ((int)cl_color.value) >> 4;
                    684:        setup_bottom = setup_oldbottom = ((int)cl_color.value) & 15;
                    685: }
1.1.1.3 ! root      686: 
1.1       root      687: 
                    688: void M_Setup_Draw (void)
                    689: {
                    690:        qpic_t  *p;
                    691: 
1.1.1.3 ! root      692:        M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
        !           693:        p = Draw_CachePic ("gfx/p_multi.lmp");
1.1       root      694:        M_DrawPic ( (320-p->width)/2, 4, p);
1.1.1.3 ! root      695: 
1.1       root      696:        M_Print (64, 40, "Hostname");
                    697:        M_DrawTextBox (160, 32, 16, 1);
                    698:        M_Print (168, 40, setup_hostname);
                    699: 
                    700:        M_Print (64, 56, "Your name");
                    701:        M_DrawTextBox (160, 48, 16, 1);
                    702:        M_Print (168, 56, setup_myname);
                    703: 
                    704:        M_Print (64, 80, "Shirt color");
                    705:        M_Print (64, 104, "Pants color");
1.1.1.3 ! root      706: 
1.1       root      707:        M_DrawTextBox (64, 140-8, 14, 1);
                    708:        M_Print (72, 140, "Accept Changes");
                    709: 
1.1.1.3 ! root      710:        p = Draw_CachePic ("gfx/bigbox.lmp");
1.1       root      711:        M_DrawTransPic (160, 64, p);
1.1.1.3 ! root      712:        p = Draw_CachePic ("gfx/menuplyr.lmp");
1.1       root      713:        M_BuildTranslationTable(setup_top*16, setup_bottom*16);
                    714:        M_DrawTransPicTranslate (172, 72, p);
                    715: 
                    716:        M_DrawCharacter (56, setup_cursor_table [setup_cursor], 12+((int)(realtime*4)&1));
                    717: 
                    718:        if (setup_cursor == 0)
                    719:                M_DrawCharacter (168 + 8*strlen(setup_hostname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
                    720: 
                    721:        if (setup_cursor == 1)
                    722:                M_DrawCharacter (168 + 8*strlen(setup_myname), setup_cursor_table [setup_cursor], 10+((int)(realtime*4)&1));
                    723: }
                    724: 
                    725: 
                    726: void M_Setup_Key (int k)
                    727: {
                    728:        int                     l;
                    729: 
                    730:        switch (k)
                    731:        {
                    732:        case K_ESCAPE:
                    733:                M_Menu_MultiPlayer_f ();
                    734:                break;
                    735: 
                    736:        case K_UPARROW:
                    737:                S_LocalSound ("misc/menu1.wav");
                    738:                setup_cursor--;
                    739:                if (setup_cursor < 0)
                    740:                        setup_cursor = NUM_SETUP_CMDS-1;
                    741:                break;
                    742: 
                    743:        case K_DOWNARROW:
                    744:                S_LocalSound ("misc/menu1.wav");
                    745:                setup_cursor++;
                    746:                if (setup_cursor >= NUM_SETUP_CMDS)
                    747:                        setup_cursor = 0;
                    748:                break;
                    749: 
                    750:        case K_LEFTARROW:
                    751:                if (setup_cursor < 2)
                    752:                        return;
                    753:                S_LocalSound ("misc/menu3.wav");
                    754:                if (setup_cursor == 2)
                    755:                        setup_top = setup_top - 1;
                    756:                if (setup_cursor == 3)
                    757:                        setup_bottom = setup_bottom - 1;
                    758:                break;
                    759:        case K_RIGHTARROW:
                    760:                if (setup_cursor < 2)
                    761:                        return;
                    762: forward:
                    763:                S_LocalSound ("misc/menu3.wav");
                    764:                if (setup_cursor == 2)
                    765:                        setup_top = setup_top + 1;
                    766:                if (setup_cursor == 3)
                    767:                        setup_bottom = setup_bottom + 1;
                    768:                break;
                    769: 
                    770:        case K_ENTER:
                    771:                if (setup_cursor == 0 || setup_cursor == 1)
                    772:                        return;
                    773: 
                    774:                if (setup_cursor == 2 || setup_cursor == 3)
                    775:                        goto forward;
                    776: 
                    777:                // setup_cursor == 4 (OK)
                    778:                if (Q_strcmp(cl_name.string, setup_myname) != 0)
                    779:                        Cbuf_AddText ( va ("name \"%s\"\n", setup_myname) );
                    780:                if (Q_strcmp(hostname.string, setup_hostname) != 0)
                    781:                        Cvar_Set("hostname", setup_hostname);
                    782:                if (setup_top != setup_oldtop || setup_bottom != setup_oldbottom)
                    783:                        Cbuf_AddText( va ("color %i %i\n", setup_top, setup_bottom) );
                    784:                m_entersound = true;
                    785:                M_Menu_MultiPlayer_f ();
                    786:                break;
1.1.1.3 ! root      787: 
1.1       root      788:        case K_BACKSPACE:
                    789:                if (setup_cursor == 0)
                    790:                {
                    791:                        if (strlen(setup_hostname))
                    792:                                setup_hostname[strlen(setup_hostname)-1] = 0;
                    793:                }
                    794: 
                    795:                if (setup_cursor == 1)
                    796:                {
                    797:                        if (strlen(setup_myname))
                    798:                                setup_myname[strlen(setup_myname)-1] = 0;
                    799:                }
                    800:                break;
1.1.1.3 ! root      801: 
1.1       root      802:        default:
                    803:                if (k < 32 || k > 127)
                    804:                        break;
                    805:                if (setup_cursor == 0)
                    806:                {
                    807:                        l = strlen(setup_hostname);
                    808:                        if (l < 15)
                    809:                        {
                    810:                                setup_hostname[l+1] = 0;
                    811:                                setup_hostname[l] = k;
                    812:                        }
                    813:                }
                    814:                if (setup_cursor == 1)
                    815:                {
                    816:                        l = strlen(setup_myname);
                    817:                        if (l < 15)
                    818:                        {
                    819:                                setup_myname[l+1] = 0;
                    820:                                setup_myname[l] = k;
                    821:                        }
                    822:                }
                    823:        }
                    824: 
                    825:        if (setup_top > 13)
                    826:                setup_top = 0;
                    827:        if (setup_top < 0)
                    828:                setup_top = 13;
                    829:        if (setup_bottom > 13)
                    830:                setup_bottom = 0;
                    831:        if (setup_bottom < 0)
                    832:                setup_bottom = 13;
                    833: }
                    834: 
                    835: //=============================================================================
                    836: /* NET MENU */
                    837: 
                    838: int    m_net_cursor;
                    839: int m_net_items;
                    840: int m_net_saveHeight;
                    841: 
1.1.1.3 ! root      842: char *net_helpMessage [] =
1.1       root      843: {
                    844: /* .........1.........2.... */
                    845:   "                        ",
                    846:   " Two computers connected",
                    847:   "   through two modems.  ",
                    848:   "                        ",
1.1.1.3 ! root      849: 
1.1       root      850:   "                        ",
                    851:   " Two computers connected",
                    852:   " by a null-modem cable. ",
                    853:   "                        ",
                    854: 
                    855:   " Novell network LANs    ",
                    856:   " or Windows 95 DOS-box. ",
                    857:   "                        ",
                    858:   "(LAN=Local Area Network)",
                    859: 
                    860:   " Commonly used to play  ",
                    861:   " over the Internet, but ",
                    862:   " also used on a Local   ",
1.1.1.3 ! root      863:   " Area Network.          "
1.1       root      864: };
                    865: 
                    866: void M_Menu_Net_f (void)
                    867: {
                    868:        key_dest = key_menu;
                    869:        m_state = m_net;
                    870:        m_entersound = true;
1.1.1.3 ! root      871:        m_net_items = 4;
1.1       root      872: 
                    873:        if (m_net_cursor >= m_net_items)
                    874:                m_net_cursor = 0;
                    875:        m_net_cursor--;
                    876:        M_Net_Key (K_DOWNARROW);
                    877: }
                    878: 
                    879: 
                    880: void M_Net_Draw (void)
                    881: {
                    882:        int             f;
                    883:        qpic_t  *p;
                    884: 
1.1.1.3 ! root      885:        M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
        !           886:        p = Draw_CachePic ("gfx/p_multi.lmp");
1.1       root      887:        M_DrawPic ( (320-p->width)/2, 4, p);
                    888: 
                    889:        f = 32;
1.1.1.3 ! root      890: 
1.1       root      891:        if (serialAvailable)
1.1.1.3 ! root      892:        {
        !           893:                p = Draw_CachePic ("gfx/netmen1.lmp");
        !           894:        }
1.1       root      895:        else
1.1.1.3 ! root      896:        {
        !           897: #ifdef _WIN32
        !           898:                p = NULL;
        !           899: #else
        !           900:                p = Draw_CachePic ("gfx/dim_modm.lmp");
        !           901: #endif
        !           902:        }
        !           903: 
        !           904:        if (p)
        !           905:                M_DrawTransPic (72, f, p);
1.1       root      906: 
                    907:        f += 19;
1.1.1.3 ! root      908: 
1.1       root      909:        if (serialAvailable)
1.1.1.3 ! root      910:        {
        !           911:                p = Draw_CachePic ("gfx/netmen2.lmp");
        !           912:        }
1.1       root      913:        else
1.1.1.3 ! root      914:        {
        !           915: #ifdef _WIN32
        !           916:                p = NULL;
        !           917: #else
        !           918:                p = Draw_CachePic ("gfx/dim_drct.lmp");
        !           919: #endif
        !           920:        }
        !           921: 
        !           922:        if (p)
        !           923:                M_DrawTransPic (72, f, p);
1.1       root      924: 
                    925:        f += 19;
                    926:        if (ipxAvailable)
1.1.1.3 ! root      927:                p = Draw_CachePic ("gfx/netmen3.lmp");
1.1       root      928:        else
1.1.1.3 ! root      929:                p = Draw_CachePic ("gfx/dim_ipx.lmp");
1.1       root      930:        M_DrawTransPic (72, f, p);
                    931: 
                    932:        f += 19;
                    933:        if (tcpipAvailable)
1.1.1.3 ! root      934:                p = Draw_CachePic ("gfx/netmen4.lmp");
1.1       root      935:        else
1.1.1.3 ! root      936:                p = Draw_CachePic ("gfx/dim_tcp.lmp");
1.1       root      937:        M_DrawTransPic (72, f, p);
                    938: 
                    939:        if (m_net_items == 5)   // JDC, could just be removed
                    940:        {
                    941:                f += 19;
1.1.1.3 ! root      942:                p = Draw_CachePic ("gfx/netmen5.lmp");
1.1       root      943:                M_DrawTransPic (72, f, p);
                    944:        }
                    945: 
                    946:        f = (320-26*8)/2;
                    947:        M_DrawTextBox (f, 134, 24, 4);
                    948:        f += 8;
                    949:        M_Print (f, 142, net_helpMessage[m_net_cursor*4+0]);
                    950:        M_Print (f, 150, net_helpMessage[m_net_cursor*4+1]);
                    951:        M_Print (f, 158, net_helpMessage[m_net_cursor*4+2]);
                    952:        M_Print (f, 166, net_helpMessage[m_net_cursor*4+3]);
                    953: 
                    954:        f = (int)(host_time * 10)%6;
1.1.1.3 ! root      955:        M_DrawTransPic (54, 32 + m_net_cursor * 20,Draw_CachePic( va("gfx/menudot%i.lmp", f+1 ) ) );
1.1       root      956: }
                    957: 
                    958: 
                    959: void M_Net_Key (int k)
                    960: {
                    961: again:
                    962:        switch (k)
                    963:        {
                    964:        case K_ESCAPE:
                    965:                M_Menu_MultiPlayer_f ();
                    966:                break;
1.1.1.3 ! root      967: 
1.1       root      968:        case K_DOWNARROW:
                    969:                S_LocalSound ("misc/menu1.wav");
                    970:                if (++m_net_cursor >= m_net_items)
                    971:                        m_net_cursor = 0;
                    972:                break;
                    973: 
                    974:        case K_UPARROW:
                    975:                S_LocalSound ("misc/menu1.wav");
                    976:                if (--m_net_cursor < 0)
                    977:                        m_net_cursor = m_net_items - 1;
                    978:                break;
                    979: 
                    980:        case K_ENTER:
                    981:                m_entersound = true;
                    982: 
                    983:                switch (m_net_cursor)
                    984:                {
                    985:                case 0:
                    986:                        M_Menu_SerialConfig_f ();
                    987:                        break;
                    988: 
                    989:                case 1:
                    990:                        M_Menu_SerialConfig_f ();
                    991:                        break;
                    992: 
                    993:                case 2:
                    994:                        M_Menu_LanConfig_f ();
                    995:                        break;
                    996: 
                    997:                case 3:
                    998:                        M_Menu_LanConfig_f ();
                    999:                        break;
                   1000: 
                   1001:                case 4:
                   1002: // multiprotocol
                   1003:                        break;
                   1004:                }
                   1005:        }
                   1006: 
                   1007:        if (m_net_cursor == 0 && !serialAvailable)
                   1008:                goto again;
                   1009:        if (m_net_cursor == 1 && !serialAvailable)
                   1010:                goto again;
                   1011:        if (m_net_cursor == 2 && !ipxAvailable)
                   1012:                goto again;
                   1013:        if (m_net_cursor == 3 && !tcpipAvailable)
                   1014:                goto again;
                   1015: }
                   1016: 
                   1017: //=============================================================================
                   1018: /* OPTIONS MENU */
                   1019: 
1.1.1.3 ! root     1020: #ifdef _WIN32
        !          1021: #define        OPTIONS_ITEMS   14
        !          1022: #else
1.1       root     1023: #define        OPTIONS_ITEMS   13
1.1.1.3 ! root     1024: #endif
        !          1025: 
1.1       root     1026: #define        SLIDER_RANGE    10
                   1027: 
                   1028: int            options_cursor;
                   1029: 
                   1030: void M_Menu_Options_f (void)
                   1031: {
                   1032:        key_dest = key_menu;
                   1033:        m_state = m_options;
                   1034:        m_entersound = true;
                   1035: }
                   1036: 
                   1037: 
                   1038: void M_AdjustSliders (int dir)
                   1039: {
                   1040:        S_LocalSound ("misc/menu3.wav");
                   1041: 
                   1042:        switch (options_cursor)
                   1043:        {
                   1044:        case 3: // screen size
                   1045:                scr_viewsize.value += dir * 10;
                   1046:                if (scr_viewsize.value < 30)
                   1047:                        scr_viewsize.value = 30;
                   1048:                if (scr_viewsize.value > 120)
                   1049:                        scr_viewsize.value = 120;
                   1050:                Cvar_SetValue ("viewsize", scr_viewsize.value);
                   1051:                break;
                   1052:        case 4: // gamma
                   1053:                v_gamma.value -= dir * 0.05;
                   1054:                if (v_gamma.value < 0.5)
                   1055:                        v_gamma.value = 0.5;
                   1056:                if (v_gamma.value > 1)
                   1057:                        v_gamma.value = 1;
                   1058:                Cvar_SetValue ("gamma", v_gamma.value);
                   1059:                break;
                   1060:        case 5: // mouse speed
                   1061:                sensitivity.value += dir * 0.5;
                   1062:                if (sensitivity.value < 1)
                   1063:                        sensitivity.value = 1;
1.1.1.3 ! root     1064:                if (sensitivity.value > 11)
        !          1065:                        sensitivity.value = 11;
1.1       root     1066:                Cvar_SetValue ("sensitivity", sensitivity.value);
                   1067:                break;
                   1068:        case 6: // music volume
1.1.1.3 ! root     1069: #ifdef _WIN32
        !          1070:                bgmvolume.value += dir * 1.0;
        !          1071: #else
1.1       root     1072:                bgmvolume.value += dir * 0.1;
1.1.1.3 ! root     1073: #endif
1.1       root     1074:                if (bgmvolume.value < 0)
                   1075:                        bgmvolume.value = 0;
                   1076:                if (bgmvolume.value > 1)
                   1077:                        bgmvolume.value = 1;
                   1078:                Cvar_SetValue ("bgmvolume", bgmvolume.value);
                   1079:                break;
                   1080:        case 7: // sfx volume
                   1081:                volume.value += dir * 0.1;
                   1082:                if (volume.value < 0)
                   1083:                        volume.value = 0;
                   1084:                if (volume.value > 1)
                   1085:                        volume.value = 1;
                   1086:                Cvar_SetValue ("volume", volume.value);
                   1087:                break;
1.1.1.3 ! root     1088: 
1.1       root     1089:        case 8: // allways run
                   1090:                if (cl_forwardspeed.value > 200)
                   1091:                {
                   1092:                        Cvar_SetValue ("cl_forwardspeed", 200);
                   1093:                        Cvar_SetValue ("cl_backspeed", 200);
                   1094:                }
                   1095:                else
                   1096:                {
                   1097:                        Cvar_SetValue ("cl_forwardspeed", 400);
                   1098:                        Cvar_SetValue ("cl_backspeed", 400);
                   1099:                }
                   1100:                break;
1.1.1.3 ! root     1101: 
1.1       root     1102:        case 9: // invert mouse
                   1103:                Cvar_SetValue ("m_pitch", -m_pitch.value);
                   1104:                break;
1.1.1.3 ! root     1105: 
1.1       root     1106:        case 10:        // lookspring
                   1107:                Cvar_SetValue ("lookspring", !lookspring.value);
                   1108:                break;
1.1.1.3 ! root     1109: 
1.1       root     1110:        case 11:        // lookstrafe
                   1111:                Cvar_SetValue ("lookstrafe", !lookstrafe.value);
                   1112:                break;
1.1.1.3 ! root     1113: 
        !          1114: #ifdef _WIN32
        !          1115:        case 13:        // _windowed_mouse
        !          1116:                Cvar_SetValue ("_windowed_mouse", !_windowed_mouse.value);
        !          1117:                break;
        !          1118: #endif
1.1       root     1119:        }
                   1120: }
                   1121: 
                   1122: 
                   1123: void M_DrawSlider (int x, int y, float range)
                   1124: {
                   1125:        int     i;
                   1126: 
                   1127:        if (range < 0)
                   1128:                range = 0;
                   1129:        if (range > 1)
                   1130:                range = 1;
                   1131:        M_DrawCharacter (x-8, y, 128);
                   1132:        for (i=0 ; i<SLIDER_RANGE ; i++)
                   1133:                M_DrawCharacter (x + i*8, y, 129);
                   1134:        M_DrawCharacter (x+i*8, y, 130);
                   1135:        M_DrawCharacter (x + (SLIDER_RANGE-1)*8 * range, y, 131);
                   1136: }
                   1137: 
                   1138: void M_DrawCheckbox (int x, int y, int on)
                   1139: {
                   1140: #if 0
                   1141:        if (on)
                   1142:                M_DrawCharacter (x, y, 131);
                   1143:        else
                   1144:                M_DrawCharacter (x, y, 129);
                   1145: #endif
                   1146:        if (on)
                   1147:                M_Print (x, y, "on");
                   1148:        else
                   1149:                M_Print (x, y, "off");
                   1150: }
                   1151: 
                   1152: void M_Options_Draw (void)
                   1153: {
                   1154:        float           r;
                   1155:        qpic_t  *p;
1.1.1.3 ! root     1156: 
        !          1157:        M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
        !          1158:        p = Draw_CachePic ("gfx/p_option.lmp");
1.1       root     1159:        M_DrawPic ( (320-p->width)/2, 4, p);
1.1.1.3 ! root     1160: 
1.1       root     1161:        M_Print (16, 32, "    Customize controls");
                   1162:        M_Print (16, 40, "         Go to console");
                   1163:        M_Print (16, 48, "     Reset to defaults");
                   1164: 
                   1165:        M_Print (16, 56, "           Screen size");
                   1166:        r = (scr_viewsize.value - 30) / (120 - 30);
                   1167:        M_DrawSlider (220, 56, r);
                   1168: 
                   1169:        M_Print (16, 64, "            Brightness");
                   1170:        r = (1.0 - v_gamma.value) / 0.5;
                   1171:        M_DrawSlider (220, 64, r);
                   1172: 
                   1173:        M_Print (16, 72, "           Mouse Speed");
1.1.1.3 ! root     1174:        r = (sensitivity.value - 1)/10;
1.1       root     1175:        M_DrawSlider (220, 72, r);
                   1176: 
                   1177:        M_Print (16, 80, "       CD Music Volume");
                   1178:        r = bgmvolume.value;
                   1179:        M_DrawSlider (220, 80, r);
                   1180: 
                   1181:        M_Print (16, 88, "          Sound Volume");
                   1182:        r = volume.value;
                   1183:        M_DrawSlider (220, 88, r);
                   1184: 
                   1185:        M_Print (16, 96,  "            Always Run");
                   1186:        M_DrawCheckbox (220, 96, cl_forwardspeed.value > 200);
                   1187: 
                   1188:        M_Print (16, 104, "          Invert Mouse");
                   1189:        M_DrawCheckbox (220, 104, m_pitch.value < 0);
                   1190: 
                   1191:        M_Print (16, 112, "            Lookspring");
                   1192:        M_DrawCheckbox (220, 112, lookspring.value);
                   1193: 
                   1194:        M_Print (16, 120, "            Lookstrafe");
                   1195:        M_DrawCheckbox (220, 120, lookstrafe.value);
                   1196: 
                   1197:        if (vid_menudrawfn)
                   1198:                M_Print (16, 128, "         Video Options");
                   1199: 
1.1.1.3 ! root     1200: #ifdef _WIN32
        !          1201:        if (modestate == MS_WINDOWED)
        !          1202:        {
        !          1203:                M_Print (16, 136, "             Use Mouse");
        !          1204:                M_DrawCheckbox (220, 136, _windowed_mouse.value);
        !          1205:        }
        !          1206: #endif
        !          1207: 
1.1       root     1208: // cursor
                   1209:        M_DrawCharacter (200, 32 + options_cursor*8, 12+((int)(realtime*4)&1));
                   1210: }
                   1211: 
                   1212: 
                   1213: void M_Options_Key (int k)
                   1214: {
                   1215:        switch (k)
                   1216:        {
                   1217:        case K_ESCAPE:
                   1218:                M_Menu_Main_f ();
                   1219:                break;
1.1.1.3 ! root     1220: 
1.1       root     1221:        case K_ENTER:
                   1222:                m_entersound = true;
                   1223:                switch (options_cursor)
                   1224:                {
                   1225:                case 0:
                   1226:                        M_Menu_Keys_f ();
                   1227:                        break;
                   1228:                case 1:
                   1229:                        m_state = m_none;
                   1230:                        Con_ToggleConsole_f ();
                   1231:                        break;
                   1232:                case 2:
                   1233:                        Cbuf_AddText ("exec default.cfg\n");
                   1234:                        break;
                   1235:                case 12:
                   1236:                        M_Menu_Video_f ();
                   1237:                        break;
                   1238:                default:
                   1239:                        M_AdjustSliders (1);
                   1240:                        break;
                   1241:                }
                   1242:                return;
1.1.1.3 ! root     1243: 
1.1       root     1244:        case K_UPARROW:
                   1245:                S_LocalSound ("misc/menu1.wav");
                   1246:                options_cursor--;
                   1247:                if (options_cursor < 0)
                   1248:                        options_cursor = OPTIONS_ITEMS-1;
                   1249:                break;
                   1250: 
                   1251:        case K_DOWNARROW:
                   1252:                S_LocalSound ("misc/menu1.wav");
                   1253:                options_cursor++;
                   1254:                if (options_cursor >= OPTIONS_ITEMS)
                   1255:                        options_cursor = 0;
1.1.1.3 ! root     1256:                break;
1.1       root     1257: 
                   1258:        case K_LEFTARROW:
                   1259:                M_AdjustSliders (-1);
                   1260:                break;
                   1261: 
                   1262:        case K_RIGHTARROW:
                   1263:                M_AdjustSliders (1);
                   1264:                break;
                   1265:        }
                   1266: 
                   1267:        if (options_cursor == 12 && vid_menudrawfn == NULL)
1.1.1.3 ! root     1268:        {
1.1       root     1269:                if (k == K_UPARROW)
                   1270:                        options_cursor = 11;
                   1271:                else
                   1272:                        options_cursor = 0;
1.1.1.3 ! root     1273:        }
        !          1274: 
        !          1275: #ifdef _WIN32
        !          1276:        if ((options_cursor == 13) && (modestate != MS_WINDOWED))
        !          1277:        {
        !          1278:                if (k == K_UPARROW)
        !          1279:                        options_cursor = 12;
        !          1280:                else
        !          1281:                        options_cursor = 0;
        !          1282:        }
        !          1283: #endif
1.1       root     1284: }
                   1285: 
                   1286: //=============================================================================
                   1287: /* KEYS MENU */
                   1288: 
                   1289: char *bindnames[][2] =
                   1290: {
                   1291: {"+attack",            "attack"},
                   1292: {"impulse 10",                 "change weapon"},
                   1293: {"+jump",                      "jump / swim up"},
                   1294: {"+forward",           "walk forward"},
                   1295: {"+back",                      "backpedal"},
                   1296: {"+left",                      "turn left"},
                   1297: {"+right",                     "turn right"},
                   1298: {"+speed",                     "run"},
                   1299: {"+moveleft",          "step left"},
                   1300: {"+moveright",                 "step right"},
                   1301: {"+strafe",            "sidestep"},
                   1302: {"+lookup",            "look up"},
                   1303: {"+lookdown",          "look down"},
                   1304: {"centerview",                 "center view"},
                   1305: {"+mlook",                     "mouse look"},
                   1306: {"+klook",                     "keyboard look"},
                   1307: {"+moveup",                    "swim up"},
                   1308: {"+movedown",          "swim down"}
                   1309: };
                   1310: 
                   1311: #define        NUMCOMMANDS     (sizeof(bindnames)/sizeof(bindnames[0]))
                   1312: 
                   1313: int            keys_cursor;
                   1314: int            bind_grab;
                   1315: 
                   1316: void M_Menu_Keys_f (void)
                   1317: {
                   1318:        key_dest = key_menu;
                   1319:        m_state = m_keys;
                   1320:        m_entersound = true;
                   1321: }
                   1322: 
                   1323: 
                   1324: void M_FindKeysForCommand (char *command, int *twokeys)
                   1325: {
                   1326:        int             count;
                   1327:        int             j;
                   1328:        int             l;
                   1329:        char    *b;
                   1330: 
                   1331:        twokeys[0] = twokeys[1] = -1;
                   1332:        l = strlen(command);
                   1333:        count = 0;
                   1334: 
                   1335:        for (j=0 ; j<256 ; j++)
                   1336:        {
                   1337:                b = keybindings[j];
                   1338:                if (!b)
                   1339:                        continue;
                   1340:                if (!strncmp (b, command, l) )
                   1341:                {
                   1342:                        twokeys[count] = j;
                   1343:                        count++;
                   1344:                        if (count == 2)
                   1345:                                break;
                   1346:                }
                   1347:        }
                   1348: }
                   1349: 
                   1350: void M_UnbindCommand (char *command)
                   1351: {
                   1352:        int             j;
                   1353:        int             l;
                   1354:        char    *b;
                   1355: 
                   1356:        l = strlen(command);
                   1357: 
                   1358:        for (j=0 ; j<256 ; j++)
                   1359:        {
                   1360:                b = keybindings[j];
                   1361:                if (!b)
                   1362:                        continue;
                   1363:                if (!strncmp (b, command, l) )
                   1364:                        Key_SetBinding (j, "");
                   1365:        }
                   1366: }
                   1367: 
                   1368: 
                   1369: void M_Keys_Draw (void)
                   1370: {
                   1371:        int             i, l;
                   1372:        int             keys[2];
                   1373:        char    *name;
                   1374:        int             x, y;
                   1375:        qpic_t  *p;
                   1376: 
1.1.1.3 ! root     1377:        p = Draw_CachePic ("gfx/ttl_cstm.lmp");
1.1       root     1378:        M_DrawPic ( (320-p->width)/2, 4, p);
                   1379: 
                   1380:        if (bind_grab)
                   1381:                M_Print (12, 32, "Press a key or button for this action");
                   1382:        else
                   1383:                M_Print (18, 32, "Enter to change, backspace to clear");
1.1.1.3 ! root     1384: 
1.1       root     1385: // search for known bindings
                   1386:        for (i=0 ; i<NUMCOMMANDS ; i++)
                   1387:        {
                   1388:                y = 48 + 8*i;
                   1389: 
                   1390:                M_Print (16, y, bindnames[i][1]);
                   1391: 
                   1392:                l = strlen (bindnames[i][0]);
1.1.1.3 ! root     1393: 
1.1       root     1394:                M_FindKeysForCommand (bindnames[i][0], keys);
1.1.1.3 ! root     1395: 
1.1       root     1396:                if (keys[0] == -1)
                   1397:                {
                   1398:                        M_Print (140, y, "???");
                   1399:                }
                   1400:                else
                   1401:                {
                   1402:                        name = Key_KeynumToString (keys[0]);
                   1403:                        M_Print (140, y, name);
                   1404:                        x = strlen(name) * 8;
                   1405:                        if (keys[1] != -1)
                   1406:                        {
                   1407:                                M_Print (140 + x + 8, y, "or");
                   1408:                                M_Print (140 + x + 32, y, Key_KeynumToString (keys[1]));
                   1409:                        }
                   1410:                }
                   1411:        }
1.1.1.3 ! root     1412: 
1.1       root     1413:        if (bind_grab)
                   1414:                M_DrawCharacter (130, 48 + keys_cursor*8, '=');
                   1415:        else
                   1416:                M_DrawCharacter (130, 48 + keys_cursor*8, 12+((int)(realtime*4)&1));
                   1417: }
                   1418: 
                   1419: 
                   1420: void M_Keys_Key (int k)
                   1421: {
                   1422:        char    cmd[80];
                   1423:        int             keys[2];
1.1.1.3 ! root     1424: 
1.1       root     1425:        if (bind_grab)
                   1426:        {       // defining a key
                   1427:                S_LocalSound ("misc/menu1.wav");
                   1428:                if (k == K_ESCAPE)
                   1429:                {
                   1430:                        bind_grab = false;
                   1431:                }
                   1432:                else if (k != '`')
                   1433:                {
1.1.1.3 ! root     1434:                        sprintf (cmd, "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]);
1.1       root     1435:                        Cbuf_InsertText (cmd);
                   1436:                }
1.1.1.3 ! root     1437: 
1.1       root     1438:                bind_grab = false;
                   1439:                return;
                   1440:        }
1.1.1.3 ! root     1441: 
1.1       root     1442:        switch (k)
                   1443:        {
                   1444:        case K_ESCAPE:
                   1445:                M_Menu_Options_f ();
                   1446:                break;
                   1447: 
                   1448:        case K_LEFTARROW:
                   1449:        case K_UPARROW:
                   1450:                S_LocalSound ("misc/menu1.wav");
                   1451:                keys_cursor--;
                   1452:                if (keys_cursor < 0)
                   1453:                        keys_cursor = NUMCOMMANDS-1;
                   1454:                break;
                   1455: 
                   1456:        case K_DOWNARROW:
                   1457:        case K_RIGHTARROW:
                   1458:                S_LocalSound ("misc/menu1.wav");
                   1459:                keys_cursor++;
                   1460:                if (keys_cursor >= NUMCOMMANDS)
                   1461:                        keys_cursor = 0;
                   1462:                break;
                   1463: 
                   1464:        case K_ENTER:           // go into bind mode
                   1465:                M_FindKeysForCommand (bindnames[keys_cursor][0], keys);
                   1466:                S_LocalSound ("misc/menu2.wav");
                   1467:                if (keys[1] != -1)
                   1468:                        M_UnbindCommand (bindnames[keys_cursor][0]);
                   1469:                bind_grab = true;
                   1470:                break;
                   1471: 
                   1472:        case K_BACKSPACE:               // delete bindings
                   1473:        case K_DEL:                             // delete bindings
                   1474:                S_LocalSound ("misc/menu2.wav");
                   1475:                M_UnbindCommand (bindnames[keys_cursor][0]);
                   1476:                break;
                   1477:        }
                   1478: }
                   1479: 
                   1480: //=============================================================================
                   1481: /* VIDEO MENU */
                   1482: 
                   1483: void M_Menu_Video_f (void)
                   1484: {
                   1485:        key_dest = key_menu;
                   1486:        m_state = m_video;
                   1487:        m_entersound = true;
                   1488: }
                   1489: 
                   1490: 
                   1491: void M_Video_Draw (void)
                   1492: {
                   1493:        (*vid_menudrawfn) ();
                   1494: }
                   1495: 
                   1496: 
                   1497: void M_Video_Key (int key)
                   1498: {
                   1499:        (*vid_menukeyfn) (key);
                   1500: }
                   1501: 
                   1502: //=============================================================================
                   1503: /* HELP MENU */
                   1504: 
                   1505: int            help_page;
                   1506: #define        NUM_HELP_PAGES  6
                   1507: 
                   1508: 
                   1509: void M_Menu_Help_f (void)
                   1510: {
                   1511:        key_dest = key_menu;
                   1512:        m_state = m_help;
                   1513:        m_entersound = true;
                   1514:        help_page = 0;
                   1515: }
                   1516: 
                   1517: 
                   1518: 
                   1519: void M_Help_Draw (void)
                   1520: {
1.1.1.3 ! root     1521:        M_DrawPic (0, 0, Draw_CachePic ( va("gfx/help%i.lmp", help_page)) );
1.1       root     1522: }
                   1523: 
                   1524: 
                   1525: void M_Help_Key (int key)
                   1526: {
                   1527:        switch (key)
                   1528:        {
                   1529:        case K_ESCAPE:
                   1530:                M_Menu_Main_f ();
                   1531:                break;
1.1.1.3 ! root     1532: 
1.1       root     1533:        case K_UPARROW:
                   1534:        case K_RIGHTARROW:
                   1535:                m_entersound = true;
                   1536:                if (++help_page >= NUM_HELP_PAGES)
                   1537:                        help_page = 0;
                   1538:                break;
                   1539: 
                   1540:        case K_DOWNARROW:
                   1541:        case K_LEFTARROW:
                   1542:                m_entersound = true;
                   1543:                if (--help_page < 0)
                   1544:                        help_page = NUM_HELP_PAGES-1;
                   1545:                break;
                   1546:        }
                   1547: 
                   1548: }
                   1549: 
                   1550: //=============================================================================
                   1551: /* QUIT MENU */
                   1552: 
                   1553: int            msgNumber;
                   1554: int            m_quit_prevstate;
                   1555: qboolean       wasInMenus;
                   1556: 
1.1.1.3 ! root     1557: #ifndef        _WIN32
1.1       root     1558: char *quitMessage [] = 
                   1559: {
                   1560: /* .........1.........2.... */
                   1561:   "  Are you gonna quit    ",
                   1562:   "  this game just like   ",
                   1563:   "   everything else?     ",
                   1564:   "                        ",
                   1565:  
                   1566:   " Milord, methinks that  ",
                   1567:   "   thou art a lowly     ",
                   1568:   " quitter. Is this true? ",
                   1569:   "                        ",
                   1570: 
                   1571:   " Do I need to bust your ",
                   1572:   "  face open for trying  ",
                   1573:   "        to quit?        ",
                   1574:   "                        ",
                   1575: 
                   1576:   " Man, I oughta smack you",
                   1577:   "   for trying to quit!  ",
                   1578:   "     Press Y to get     ",
                   1579:   "      smacked out.      ",
                   1580:  
                   1581:   " Press Y to quit like a ",
                   1582:   "   big loser in life.   ",
                   1583:   "  Press N to stay proud ",
                   1584:   "    and successful!     ",
                   1585:  
                   1586:   "   If you press Y to    ",
                   1587:   "  quit, I will summon   ",
                   1588:   "  Satan all over your   ",
                   1589:   "      hard drive!       ",
                   1590:  
                   1591:   "  Um, Asmodeus dislikes ",
                   1592:   " his children trying to ",
                   1593:   " quit. Press Y to return",
                   1594:   "   to your Tinkertoys.  ",
                   1595:  
                   1596:   "  If you quit now, I'll ",
                   1597:   "  throw a blanket-party ",
                   1598:   "   for you next time!   ",
                   1599:   "                        "
                   1600: };
1.1.1.3 ! root     1601: #endif
1.1       root     1602: 
                   1603: void M_Menu_Quit_f (void)
                   1604: {
                   1605:        if (m_state == m_quit)
                   1606:                return;
                   1607:        wasInMenus = (key_dest == key_menu);
                   1608:        key_dest = key_menu;
                   1609:        m_quit_prevstate = m_state;
                   1610:        m_state = m_quit;
                   1611:        m_entersound = true;
                   1612:        msgNumber = rand()&7;
                   1613: }
                   1614: 
                   1615: 
                   1616: void M_Quit_Key (int key)
                   1617: {
                   1618:        switch (key)
                   1619:        {
                   1620:        case K_ESCAPE:
                   1621:        case 'n':
                   1622:        case 'N':
                   1623:                if (wasInMenus)
                   1624:                {
                   1625:                        m_state = m_quit_prevstate;
                   1626:                        m_entersound = true;
                   1627:                }
                   1628:                else
                   1629:                {
                   1630:                        key_dest = key_game;
                   1631:                        m_state = m_none;
                   1632:                }
                   1633:                break;
                   1634: 
                   1635:        case 'Y':
                   1636:        case 'y':
                   1637:                key_dest = key_console;
                   1638:                Host_Quit_f ();
                   1639:                break;
                   1640: 
                   1641:        default:
                   1642:                break;
                   1643:        }
                   1644: 
                   1645: }
                   1646: 
                   1647: 
                   1648: void M_Quit_Draw (void)
                   1649: {
                   1650:        if (wasInMenus)
                   1651:        {
                   1652:                m_state = m_quit_prevstate;
                   1653:                m_recursiveDraw = true;
                   1654:                M_Draw ();
                   1655:                m_state = m_quit;
                   1656:        }
1.1.1.3 ! root     1657: 
        !          1658: #ifdef _WIN32
        !          1659:        M_DrawTextBox (0, 0, 38, 23);
        !          1660:        M_PrintWhite (16, 12,  "  Quake version 1.07 by id Software\n\n");
        !          1661:        M_PrintWhite (16, 28,  "Programming        Art \n");
        !          1662:        M_Print (16, 36,  " John Carmack       Adrian Carmack\n");
        !          1663:        M_Print (16, 44,  " Michael Abrash     Kevin Cloud\n");
        !          1664:        M_Print (16, 52,  " John Cash          Paul Steed\n");
        !          1665:        M_PrintWhite (16, 60,  "Design             Biz\n");
        !          1666:        M_Print (16, 68,  " John Romero        Jay Wilbur\n");
        !          1667:        M_Print (16, 76,  " Sandy Petersen     Mike Wilson\n");
        !          1668:        M_Print (16, 84,  " American McGee     Donna Jackson\n");
        !          1669:        M_Print (16, 92,  " Tim Willits        Todd Hollenshead\n");
        !          1670:        M_PrintWhite (16, 100, "Support            Projects\n");
        !          1671:        M_Print (16, 108, " Barrett Alexander  Shawn Green\n");
        !          1672:        M_PrintWhite (16, 116, "Sound Effects\n");
        !          1673:        M_Print (16, 124, " Trent Reznor and Nine Inch Nails\n\n");
        !          1674:        M_PrintWhite (16, 140, "Quake is a trademark of Id Software,\n");
        !          1675:        M_PrintWhite (16, 148, "inc., (c)1996 Id Software, inc. All\n");
        !          1676:        M_PrintWhite (16, 156, "rights reserved. NIN logo is a\n");
        !          1677:        M_PrintWhite (16, 164, "registered trademark licensed to\n");
        !          1678:        M_PrintWhite (16, 172, "Nothing Interactive, Inc. All rights\n");
        !          1679:        M_PrintWhite (16, 180, "reserved. Press y to exit\n");
        !          1680: #else
1.1       root     1681:        M_DrawTextBox (56, 76, 24, 4);
                   1682:        M_Print (64, 84,  quitMessage[msgNumber*4+0]);
                   1683:        M_Print (64, 92,  quitMessage[msgNumber*4+1]);
                   1684:        M_Print (64, 100, quitMessage[msgNumber*4+2]);
                   1685:        M_Print (64, 108, quitMessage[msgNumber*4+3]);
1.1.1.3 ! root     1686: #endif
1.1       root     1687: }
                   1688: 
                   1689: //=============================================================================
                   1690: 
                   1691: /* SERIAL CONFIG MENU */
                   1692: 
                   1693: int            serialConfig_cursor;
                   1694: int            serialConfig_cursor_table[] = {48, 64, 80, 96, 112, 132};
                   1695: #define        NUM_SERIALCONFIG_CMDS   6
                   1696: 
                   1697: static int ISA_uarts[] = {0x3f8,0x2f8,0x3e8,0x2e8};
                   1698: static int ISA_IRQs[]  = {4,3,4,3};
                   1699: int serialConfig_baudrate[] = {9600,14400,19200,28800,38400,57600};
                   1700: 
                   1701: int            serialConfig_comport;
                   1702: int            serialConfig_irq ;
                   1703: int            serialConfig_baud;
                   1704: char   serialConfig_phone[16];
                   1705: 
                   1706: void M_Menu_SerialConfig_f (void)
                   1707: {
                   1708:        int             n;
                   1709:        int             port;
                   1710:        int             baudrate;
                   1711:        qboolean        useModem;
                   1712: 
                   1713:        key_dest = key_menu;
                   1714:        m_state = m_serialconfig;
                   1715:        m_entersound = true;
                   1716:        if (JoiningGame && SerialConfig)
                   1717:                serialConfig_cursor = 4;
                   1718:        else
                   1719:                serialConfig_cursor = 5;
                   1720: 
                   1721:        (*GetComPortConfig) (0, &port, &serialConfig_irq, &baudrate, &useModem);
                   1722: 
                   1723:        // map uart's port to COMx
                   1724:        for (n = 0; n < 4; n++)
                   1725:                if (ISA_uarts[n] == port)
                   1726:                        break;
                   1727:        if (n == 4)
                   1728:        {
                   1729:                n = 0;
                   1730:                serialConfig_irq = 4;
                   1731:        }
                   1732:        serialConfig_comport = n + 1;
                   1733: 
                   1734:        // map baudrate to index
                   1735:        for (n = 0; n < 6; n++)
                   1736:                if (serialConfig_baudrate[n] == baudrate)
                   1737:                        break;
                   1738:        if (n == 6)
                   1739:                n = 5;
                   1740:        serialConfig_baud = n;
1.1.1.3 ! root     1741: 
        !          1742:        m_return_onerror = false;
        !          1743:        m_return_reason[0] = 0;
1.1       root     1744: }
1.1.1.3 ! root     1745: 
1.1       root     1746: 
                   1747: void M_SerialConfig_Draw (void)
                   1748: {
                   1749:        qpic_t  *p;
                   1750:        int             basex;
                   1751:        char    *startJoin;
                   1752:        char    *directModem;
                   1753: 
1.1.1.3 ! root     1754:        M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
        !          1755:        p = Draw_CachePic ("gfx/p_multi.lmp");
1.1       root     1756:        basex = (320-p->width)/2;
                   1757:        M_DrawPic (basex, 4, p);
                   1758: 
                   1759:        if (StartingGame)
                   1760:                startJoin = "New Game";
                   1761:        else
                   1762:                startJoin = "Join Game";
                   1763:        if (SerialConfig)
                   1764:                directModem = "Modem";
                   1765:        else
                   1766:                directModem = "Direct Connect";
                   1767:        M_Print (basex, 32, va ("%s - %s", startJoin, directModem));
                   1768:        basex += 8;
                   1769: 
                   1770:        M_Print (basex, serialConfig_cursor_table[0], "Port");
                   1771:        M_DrawTextBox (160, 40, 4, 1);
                   1772:        M_Print (168, serialConfig_cursor_table[0], va("COM%u", serialConfig_comport));
                   1773: 
                   1774:        M_Print (basex, serialConfig_cursor_table[1], "IRQ");
                   1775:        M_DrawTextBox (160, serialConfig_cursor_table[1]-8, 1, 1);
                   1776:        M_Print (168, serialConfig_cursor_table[1], va("%u", serialConfig_irq));
                   1777: 
                   1778:        M_Print (basex, serialConfig_cursor_table[2], "Baud");
                   1779:        M_DrawTextBox (160, serialConfig_cursor_table[2]-8, 5, 1);
                   1780:        M_Print (168, serialConfig_cursor_table[2], va("%u", serialConfig_baudrate[serialConfig_baud]));
                   1781: 
                   1782:        if (SerialConfig)
                   1783:        {
                   1784:                M_Print (basex, serialConfig_cursor_table[3], "Modem Setup...");
                   1785:                if (JoiningGame)
                   1786:                {
                   1787:                        M_Print (basex, serialConfig_cursor_table[4], "Phone number");
                   1788:                        M_DrawTextBox (160, serialConfig_cursor_table[4]-8, 16, 1);
                   1789:                        M_Print (168, serialConfig_cursor_table[4], serialConfig_phone);
                   1790:                }
                   1791:        }
                   1792: 
                   1793:        if (JoiningGame)
                   1794:        {
                   1795:                M_DrawTextBox (basex, serialConfig_cursor_table[5]-8, 7, 1);
                   1796:                M_Print (basex+8, serialConfig_cursor_table[5], "Connect");
                   1797:        }
                   1798:        else
                   1799:        {
                   1800:                M_DrawTextBox (basex, serialConfig_cursor_table[5]-8, 2, 1);
                   1801:                M_Print (basex+8, serialConfig_cursor_table[5], "OK");
                   1802:        }
                   1803: 
                   1804:        M_DrawCharacter (basex-8, serialConfig_cursor_table [serialConfig_cursor], 12+((int)(realtime*4)&1));
                   1805: 
                   1806:        if (serialConfig_cursor == 4)
                   1807:                M_DrawCharacter (168 + 8*strlen(serialConfig_phone), serialConfig_cursor_table [serialConfig_cursor], 10+((int)(realtime*4)&1));
1.1.1.3 ! root     1808: 
        !          1809:        if (*m_return_reason)
        !          1810:                M_PrintWhite (basex, 148, m_return_reason);
1.1       root     1811: }
                   1812: 
                   1813: 
                   1814: void M_SerialConfig_Key (int key)
                   1815: {
                   1816:        int             l;
                   1817: 
                   1818:        switch (key)
                   1819:        {
                   1820:        case K_ESCAPE:
                   1821:                M_Menu_Net_f ();
                   1822:                break;
                   1823: 
                   1824:        case K_UPARROW:
                   1825:                S_LocalSound ("misc/menu1.wav");
                   1826:                serialConfig_cursor--;
                   1827:                if (serialConfig_cursor < 0)
                   1828:                        serialConfig_cursor = NUM_SERIALCONFIG_CMDS-1;
                   1829:                break;
                   1830: 
                   1831:        case K_DOWNARROW:
                   1832:                S_LocalSound ("misc/menu1.wav");
                   1833:                serialConfig_cursor++;
                   1834:                if (serialConfig_cursor >= NUM_SERIALCONFIG_CMDS)
                   1835:                        serialConfig_cursor = 0;
                   1836:                break;
                   1837: 
                   1838:        case K_LEFTARROW:
                   1839:                if (serialConfig_cursor > 2)
                   1840:                        break;
                   1841:                S_LocalSound ("misc/menu3.wav");
                   1842: 
                   1843:                if (serialConfig_cursor == 0)
                   1844:                {
                   1845:                        serialConfig_comport--;
                   1846:                        if (serialConfig_comport == 0)
                   1847:                                serialConfig_comport = 4;
                   1848:                        serialConfig_irq = ISA_IRQs[serialConfig_comport-1];
                   1849:                }
                   1850: 
                   1851:                if (serialConfig_cursor == 1)
                   1852:                {
                   1853:                        serialConfig_irq--;
                   1854:                        if (serialConfig_irq == 6)
                   1855:                                serialConfig_irq = 5;
                   1856:                        if (serialConfig_irq == 1)
                   1857:                                serialConfig_irq = 7;
                   1858:                }
                   1859: 
                   1860:                if (serialConfig_cursor == 2)
                   1861:                {
                   1862:                        serialConfig_baud--;
                   1863:                        if (serialConfig_baud < 0)
                   1864:                                serialConfig_baud = 5;
                   1865:                }
                   1866: 
                   1867:                break;
                   1868: 
                   1869:        case K_RIGHTARROW:
                   1870:                if (serialConfig_cursor > 2)
                   1871:                        break;
                   1872: forward:
                   1873:                S_LocalSound ("misc/menu3.wav");
                   1874: 
                   1875:                if (serialConfig_cursor == 0)
                   1876:                {
                   1877:                        serialConfig_comport++;
                   1878:                        if (serialConfig_comport > 4)
                   1879:                                serialConfig_comport = 1;
                   1880:                        serialConfig_irq = ISA_IRQs[serialConfig_comport-1];
                   1881:                }
                   1882: 
                   1883:                if (serialConfig_cursor == 1)
                   1884:                {
                   1885:                        serialConfig_irq++;
                   1886:                        if (serialConfig_irq == 6)
                   1887:                                serialConfig_irq = 7;
                   1888:                        if (serialConfig_irq == 8)
                   1889:                                serialConfig_irq = 2;
                   1890:                }
                   1891: 
                   1892:                if (serialConfig_cursor == 2)
                   1893:                {
                   1894:                        serialConfig_baud++;
                   1895:                        if (serialConfig_baud > 5)
                   1896:                                serialConfig_baud = 0;
                   1897:                }
                   1898: 
                   1899:                break;
                   1900: 
                   1901:        case K_ENTER:
                   1902:                if (serialConfig_cursor < 3)
                   1903:                        goto forward;
                   1904: 
                   1905:                m_entersound = true;
                   1906: 
                   1907:                if (serialConfig_cursor == 3)
                   1908:                {
                   1909:                        (*SetComPortConfig) (0, ISA_uarts[serialConfig_comport-1], serialConfig_irq, serialConfig_baudrate[serialConfig_baud], SerialConfig);
                   1910: 
                   1911:                        M_Menu_ModemConfig_f ();
                   1912:                        break;
                   1913:                }
                   1914: 
                   1915:                if (serialConfig_cursor == 4)
                   1916:                {
                   1917:                        serialConfig_cursor = 5;
                   1918:                        break;
                   1919:                }
                   1920: 
                   1921:                // serialConfig_cursor == 5 (OK/CONNECT)
                   1922:                (*SetComPortConfig) (0, ISA_uarts[serialConfig_comport-1], serialConfig_irq, serialConfig_baudrate[serialConfig_baud], SerialConfig);
                   1923: 
                   1924:                M_ConfigureNetSubsystem ();
                   1925: 
                   1926:                if (StartingGame)
                   1927:                {
                   1928:                        M_Menu_GameOptions_f ();
                   1929:                        break;
                   1930:                }
                   1931: 
1.1.1.3 ! root     1932:                m_return_state = m_state;
        !          1933:                m_return_onerror = true;
1.1       root     1934:                key_dest = key_game;
                   1935:                m_state = m_none;
                   1936: 
                   1937:                if (SerialConfig)
                   1938:                        Cbuf_AddText (va ("connect \"%s\"\n", serialConfig_phone));
                   1939:                else
                   1940:                        Cbuf_AddText ("connect\n");
                   1941:                break;
1.1.1.3 ! root     1942: 
1.1       root     1943:        case K_BACKSPACE:
                   1944:                if (serialConfig_cursor == 4)
                   1945:                {
                   1946:                        if (strlen(serialConfig_phone))
                   1947:                                serialConfig_phone[strlen(serialConfig_phone)-1] = 0;
                   1948:                }
                   1949:                break;
1.1.1.3 ! root     1950: 
1.1       root     1951:        default:
                   1952:                if (key < 32 || key > 127)
                   1953:                        break;
                   1954:                if (serialConfig_cursor == 4)
                   1955:                {
                   1956:                        l = strlen(serialConfig_phone);
                   1957:                        if (l < 15)
                   1958:                        {
                   1959:                                serialConfig_phone[l+1] = 0;
                   1960:                                serialConfig_phone[l] = key;
                   1961:                        }
                   1962:                }
                   1963:        }
                   1964: 
                   1965:        if (DirectConfig && (serialConfig_cursor == 3 || serialConfig_cursor == 4))
                   1966:                if (key == K_UPARROW)
                   1967:                        serialConfig_cursor = 2;
                   1968:                else
                   1969:                        serialConfig_cursor = 5;
                   1970: 
                   1971:        if (SerialConfig && StartingGame && serialConfig_cursor == 4)
                   1972:                if (key == K_UPARROW)
                   1973:                        serialConfig_cursor = 3;
                   1974:                else
                   1975:                        serialConfig_cursor = 5;
                   1976: }
                   1977: 
                   1978: //=============================================================================
                   1979: /* MODEM CONFIG MENU */
                   1980: 
                   1981: int            modemConfig_cursor;
                   1982: int            modemConfig_cursor_table [] = {40, 56, 88, 120, 156};
                   1983: #define NUM_MODEMCONFIG_CMDS   5
                   1984: 
                   1985: char   modemConfig_dialing;
                   1986: char   modemConfig_clear [16];
                   1987: char   modemConfig_init [32];
                   1988: char   modemConfig_hangup [16];
                   1989: 
                   1990: void M_Menu_ModemConfig_f (void)
                   1991: {
                   1992:        key_dest = key_menu;
                   1993:        m_state = m_modemconfig;
                   1994:        m_entersound = true;
                   1995:        (*GetModemConfig) (0, &modemConfig_dialing, modemConfig_clear, modemConfig_init, modemConfig_hangup);
                   1996: }
1.1.1.3 ! root     1997: 
1.1       root     1998: 
                   1999: void M_ModemConfig_Draw (void)
                   2000: {
                   2001:        qpic_t  *p;
                   2002:        int             basex;
                   2003: 
1.1.1.3 ! root     2004:        M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
        !          2005:        p = Draw_CachePic ("gfx/p_multi.lmp");
1.1       root     2006:        basex = (320-p->width)/2;
                   2007:        M_DrawPic (basex, 4, p);
                   2008:        basex += 8;
                   2009: 
                   2010:        if (modemConfig_dialing == 'P')
                   2011:                M_Print (basex, modemConfig_cursor_table[0], "Pulse Dialing");
                   2012:        else
                   2013:                M_Print (basex, modemConfig_cursor_table[0], "Touch Tone Dialing");
                   2014: 
                   2015:        M_Print (basex, modemConfig_cursor_table[1], "Clear");
                   2016:        M_DrawTextBox (basex, modemConfig_cursor_table[1]+4, 16, 1);
                   2017:        M_Print (basex+8, modemConfig_cursor_table[1]+12, modemConfig_clear);
                   2018:        if (modemConfig_cursor == 1)
                   2019:                M_DrawCharacter (basex+8 + 8*strlen(modemConfig_clear), modemConfig_cursor_table[1]+12, 10+((int)(realtime*4)&1));
                   2020: 
                   2021:        M_Print (basex, modemConfig_cursor_table[2], "Init");
                   2022:        M_DrawTextBox (basex, modemConfig_cursor_table[2]+4, 30, 1);
                   2023:        M_Print (basex+8, modemConfig_cursor_table[2]+12, modemConfig_init);
                   2024:        if (modemConfig_cursor == 2)
                   2025:                M_DrawCharacter (basex+8 + 8*strlen(modemConfig_init), modemConfig_cursor_table[2]+12, 10+((int)(realtime*4)&1));
                   2026: 
                   2027:        M_Print (basex, modemConfig_cursor_table[3], "Hangup");
                   2028:        M_DrawTextBox (basex, modemConfig_cursor_table[3]+4, 16, 1);
                   2029:        M_Print (basex+8, modemConfig_cursor_table[3]+12, modemConfig_hangup);
                   2030:        if (modemConfig_cursor == 3)
                   2031:                M_DrawCharacter (basex+8 + 8*strlen(modemConfig_hangup), modemConfig_cursor_table[3]+12, 10+((int)(realtime*4)&1));
                   2032: 
                   2033:        M_DrawTextBox (basex, modemConfig_cursor_table[4]-8, 2, 1);
                   2034:        M_Print (basex+8, modemConfig_cursor_table[4], "OK");
                   2035: 
                   2036:        M_DrawCharacter (basex-8, modemConfig_cursor_table [modemConfig_cursor], 12+((int)(realtime*4)&1));
                   2037: }
                   2038: 
                   2039: 
                   2040: void M_ModemConfig_Key (int key)
                   2041: {
                   2042:        int             l;
                   2043: 
                   2044:        switch (key)
                   2045:        {
                   2046:        case K_ESCAPE:
                   2047:                M_Menu_SerialConfig_f ();
                   2048:                break;
                   2049: 
                   2050:        case K_UPARROW:
                   2051:                S_LocalSound ("misc/menu1.wav");
                   2052:                modemConfig_cursor--;
                   2053:                if (modemConfig_cursor < 0)
                   2054:                        modemConfig_cursor = NUM_MODEMCONFIG_CMDS-1;
                   2055:                break;
                   2056: 
                   2057:        case K_DOWNARROW:
                   2058:                S_LocalSound ("misc/menu1.wav");
                   2059:                modemConfig_cursor++;
                   2060:                if (modemConfig_cursor >= NUM_MODEMCONFIG_CMDS)
                   2061:                        modemConfig_cursor = 0;
                   2062:                break;
                   2063: 
                   2064:        case K_LEFTARROW:
                   2065:        case K_RIGHTARROW:
                   2066:                if (modemConfig_cursor == 0)
                   2067:                {
                   2068:                        if (modemConfig_dialing == 'P')
                   2069:                                modemConfig_dialing = 'T';
                   2070:                        else
                   2071:                                modemConfig_dialing = 'P';
                   2072:                        S_LocalSound ("misc/menu1.wav");
                   2073:                }
                   2074:                break;
                   2075: 
                   2076:        case K_ENTER:
                   2077:                if (modemConfig_cursor == 0)
                   2078:                {
                   2079:                        if (modemConfig_dialing == 'P')
                   2080:                                modemConfig_dialing = 'T';
                   2081:                        else
                   2082:                                modemConfig_dialing = 'P';
                   2083:                        m_entersound = true;
                   2084:                }
                   2085: 
                   2086:                if (modemConfig_cursor == 4)
                   2087:                {
                   2088:                        (*SetModemConfig) (0, va ("%c", modemConfig_dialing), modemConfig_clear, modemConfig_init, modemConfig_hangup);
                   2089:                        m_entersound = true;
                   2090:                        M_Menu_SerialConfig_f ();
                   2091:                }
                   2092:                break;
1.1.1.3 ! root     2093: 
1.1       root     2094:        case K_BACKSPACE:
                   2095:                if (modemConfig_cursor == 1)
                   2096:                {
                   2097:                        if (strlen(modemConfig_clear))
                   2098:                                modemConfig_clear[strlen(modemConfig_clear)-1] = 0;
                   2099:                }
                   2100: 
                   2101:                if (modemConfig_cursor == 2)
                   2102:                {
                   2103:                        if (strlen(modemConfig_init))
                   2104:                                modemConfig_init[strlen(modemConfig_init)-1] = 0;
                   2105:                }
                   2106: 
                   2107:                if (modemConfig_cursor == 3)
                   2108:                {
                   2109:                        if (strlen(modemConfig_hangup))
                   2110:                                modemConfig_hangup[strlen(modemConfig_hangup)-1] = 0;
                   2111:                }
                   2112:                break;
1.1.1.3 ! root     2113: 
1.1       root     2114:        default:
                   2115:                if (key < 32 || key > 127)
                   2116:                        break;
                   2117: 
                   2118:                if (modemConfig_cursor == 1)
                   2119:                {
                   2120:                        l = strlen(modemConfig_clear);
                   2121:                        if (l < 15)
                   2122:                        {
                   2123:                                modemConfig_clear[l+1] = 0;
                   2124:                                modemConfig_clear[l] = key;
                   2125:                        }
                   2126:                }
                   2127: 
                   2128:                if (modemConfig_cursor == 2)
                   2129:                {
                   2130:                        l = strlen(modemConfig_init);
                   2131:                        if (l < 29)
                   2132:                        {
                   2133:                                modemConfig_init[l+1] = 0;
                   2134:                                modemConfig_init[l] = key;
                   2135:                        }
                   2136:                }
                   2137: 
                   2138:                if (modemConfig_cursor == 3)
                   2139:                {
                   2140:                        l = strlen(modemConfig_hangup);
                   2141:                        if (l < 15)
                   2142:                        {
                   2143:                                modemConfig_hangup[l+1] = 0;
                   2144:                                modemConfig_hangup[l] = key;
                   2145:                        }
                   2146:                }
                   2147:        }
                   2148: }
                   2149: 
                   2150: //=============================================================================
                   2151: /* LAN CONFIG MENU */
                   2152: 
                   2153: int            lanConfig_cursor = -1;
                   2154: int            lanConfig_cursor_table [] = {72, 92, 124};
                   2155: #define NUM_LANCONFIG_CMDS     3
                   2156: 
                   2157: int    lanConfig_port;
                   2158: char   lanConfig_portname[6];
                   2159: char   lanConfig_joinname[22];
                   2160: 
                   2161: void M_Menu_LanConfig_f (void)
                   2162: {
                   2163:        key_dest = key_menu;
                   2164:        m_state = m_lanconfig;
                   2165:        m_entersound = true;
                   2166:        if (lanConfig_cursor == -1)
                   2167:        {
                   2168:                if (JoiningGame && TCPIPConfig)
                   2169:                        lanConfig_cursor = 2;
                   2170:                else
                   2171:                        lanConfig_cursor = 1;
                   2172:        }
                   2173:        if (StartingGame && lanConfig_cursor == 2)
                   2174:                lanConfig_cursor = 1;
1.1.1.3 ! root     2175:        lanConfig_port = DEFAULTnet_hostport;
1.1       root     2176:        sprintf(lanConfig_portname, "%u", lanConfig_port);
1.1.1.3 ! root     2177: 
        !          2178:        m_return_onerror = false;
        !          2179:        m_return_reason[0] = 0;
1.1       root     2180: }
1.1.1.3 ! root     2181: 
1.1       root     2182: 
                   2183: void M_LanConfig_Draw (void)
                   2184: {
                   2185:        qpic_t  *p;
                   2186:        int             basex;
                   2187:        char    *startJoin;
                   2188:        char    *protocol;
                   2189: 
1.1.1.3 ! root     2190:        M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
        !          2191:        p = Draw_CachePic ("gfx/p_multi.lmp");
1.1       root     2192:        basex = (320-p->width)/2;
                   2193:        M_DrawPic (basex, 4, p);
                   2194: 
                   2195:        if (StartingGame)
                   2196:                startJoin = "New Game";
                   2197:        else
                   2198:                startJoin = "Join Game";
                   2199:        if (IPXConfig)
                   2200:                protocol = "IPX";
                   2201:        else
                   2202:                protocol = "TCP/IP";
                   2203:        M_Print (basex, 32, va ("%s - %s", startJoin, protocol));
                   2204:        basex += 8;
                   2205: 
                   2206:        M_Print (basex, 52, "Address:");
                   2207:        if (IPXConfig)
                   2208:                M_Print (basex+9*8, 52, my_ipx_address);
                   2209:        else
                   2210:                M_Print (basex+9*8, 52, my_tcpip_address);
                   2211: 
                   2212:        M_Print (basex, lanConfig_cursor_table[0], "Port");
                   2213:        M_DrawTextBox (basex+8*8, lanConfig_cursor_table[0]-8, 6, 1);
                   2214:        M_Print (basex+9*8, lanConfig_cursor_table[0], lanConfig_portname);
                   2215: 
                   2216:        if (JoiningGame)
                   2217:        {
                   2218:                M_Print (basex, lanConfig_cursor_table[1], "Search for local games...");
                   2219:                M_Print (basex, 108, "Join game at:");
                   2220:                M_DrawTextBox (basex+8, lanConfig_cursor_table[2]-8, 22, 1);
                   2221:                M_Print (basex+16, lanConfig_cursor_table[2], lanConfig_joinname);
                   2222:        }
                   2223:        else
                   2224:        {
                   2225:                M_DrawTextBox (basex, lanConfig_cursor_table[1]-8, 2, 1);
                   2226:                M_Print (basex+8, lanConfig_cursor_table[1], "OK");
                   2227:        }
                   2228: 
                   2229:        M_DrawCharacter (basex-8, lanConfig_cursor_table [lanConfig_cursor], 12+((int)(realtime*4)&1));
                   2230: 
                   2231:        if (lanConfig_cursor == 0)
                   2232:                M_DrawCharacter (basex+9*8 + 8*strlen(lanConfig_portname), lanConfig_cursor_table [0], 10+((int)(realtime*4)&1));
                   2233: 
                   2234:        if (lanConfig_cursor == 2)
                   2235:                M_DrawCharacter (basex+16 + 8*strlen(lanConfig_joinname), lanConfig_cursor_table [2], 10+((int)(realtime*4)&1));
1.1.1.3 ! root     2236: 
        !          2237:        if (*m_return_reason)
        !          2238:                M_PrintWhite (basex, 148, m_return_reason);
1.1       root     2239: }
                   2240: 
                   2241: 
                   2242: void M_LanConfig_Key (int key)
                   2243: {
                   2244:        int             l;
                   2245: 
                   2246:        switch (key)
                   2247:        {
                   2248:        case K_ESCAPE:
                   2249:                M_Menu_Net_f ();
                   2250:                break;
                   2251: 
                   2252:        case K_UPARROW:
                   2253:                S_LocalSound ("misc/menu1.wav");
                   2254:                lanConfig_cursor--;
                   2255:                if (lanConfig_cursor < 0)
                   2256:                        lanConfig_cursor = NUM_LANCONFIG_CMDS-1;
                   2257:                break;
                   2258: 
                   2259:        case K_DOWNARROW:
                   2260:                S_LocalSound ("misc/menu1.wav");
                   2261:                lanConfig_cursor++;
                   2262:                if (lanConfig_cursor >= NUM_LANCONFIG_CMDS)
                   2263:                        lanConfig_cursor = 0;
                   2264:                break;
                   2265: 
                   2266:        case K_ENTER:
                   2267:                if (lanConfig_cursor == 0)
                   2268:                        break;
                   2269: 
                   2270:                m_entersound = true;
                   2271: 
                   2272:                M_ConfigureNetSubsystem ();
                   2273: 
                   2274:                if (lanConfig_cursor == 1)
                   2275:                {
                   2276:                        if (StartingGame)
                   2277:                        {
                   2278:                                M_Menu_GameOptions_f ();
                   2279:                                break;
                   2280:                        }
                   2281:                        M_Menu_Search_f();
                   2282:                        break;
                   2283:                }
                   2284: 
                   2285:                if (lanConfig_cursor == 2)
                   2286:                {
1.1.1.3 ! root     2287:                        m_return_state = m_state;
        !          2288:                        m_return_onerror = true;
1.1       root     2289:                        key_dest = key_game;
                   2290:                        m_state = m_none;
                   2291:                        Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname) );
                   2292:                        break;
                   2293:                }
                   2294: 
                   2295:                break;
1.1.1.3 ! root     2296: 
1.1       root     2297:        case K_BACKSPACE:
                   2298:                if (lanConfig_cursor == 0)
                   2299:                {
                   2300:                        if (strlen(lanConfig_portname))
                   2301:                                lanConfig_portname[strlen(lanConfig_portname)-1] = 0;
                   2302:                }
                   2303: 
                   2304:                if (lanConfig_cursor == 2)
                   2305:                {
                   2306:                        if (strlen(lanConfig_joinname))
                   2307:                                lanConfig_joinname[strlen(lanConfig_joinname)-1] = 0;
                   2308:                }
                   2309:                break;
1.1.1.3 ! root     2310: 
1.1       root     2311:        default:
                   2312:                if (key < 32 || key > 127)
                   2313:                        break;
                   2314: 
                   2315:                if (lanConfig_cursor == 2)
                   2316:                {
                   2317:                        l = strlen(lanConfig_joinname);
                   2318:                        if (l < 21)
                   2319:                        {
                   2320:                                lanConfig_joinname[l+1] = 0;
                   2321:                                lanConfig_joinname[l] = key;
                   2322:                        }
                   2323:                }
                   2324: 
                   2325:                if (key < '0' || key > '9')
                   2326:                        break;
                   2327:                if (lanConfig_cursor == 0)
                   2328:                {
                   2329:                        l = strlen(lanConfig_portname);
                   2330:                        if (l < 5)
                   2331:                        {
                   2332:                                lanConfig_portname[l+1] = 0;
                   2333:                                lanConfig_portname[l] = key;
                   2334:                        }
                   2335:                }
                   2336:        }
                   2337: 
                   2338:        if (StartingGame && lanConfig_cursor == 2)
                   2339:                if (key == K_UPARROW)
                   2340:                        lanConfig_cursor = 1;
                   2341:                else
                   2342:                        lanConfig_cursor = 0;
                   2343: 
                   2344:        l =  Q_atoi(lanConfig_portname);
                   2345:        if (l > 65535)
                   2346:                l = lanConfig_port;
                   2347:        else
                   2348:                lanConfig_port = l;
                   2349:        sprintf(lanConfig_portname, "%u", lanConfig_port);
                   2350: }
                   2351: 
                   2352: //=============================================================================
                   2353: /* GAME OPTIONS MENU */
                   2354: 
1.1.1.3 ! root     2355: typedef struct
1.1       root     2356: {
                   2357:        char    *name;
                   2358:        char    *description;
1.1.1.3 ! root     2359: } level_t;
        !          2360: 
        !          2361: level_t                levels[] =
1.1       root     2362: {
                   2363:        {"start", "Entrance"},  // 0
                   2364: 
                   2365:        {"e1m1", "Slipgate Complex"},                           // 1
                   2366:        {"e1m2", "Castle of the Damned"},
                   2367:        {"e1m3", "The Necropolis"},
                   2368:        {"e1m4", "The Grisly Grotto"},
                   2369:        {"e1m5", "Gloom Keep"},
                   2370:        {"e1m6", "The Door To Chthon"},
                   2371:        {"e1m7", "The House of Chthon"},
                   2372:        {"e1m8", "Ziggurat Vertigo"},
                   2373: 
                   2374:        {"e2m1", "The Installation"},                           // 9
                   2375:        {"e2m2", "Ogre Citadel"},
                   2376:        {"e2m3", "Crypt of Decay"},
                   2377:        {"e2m4", "The Ebon Fortress"},
                   2378:        {"e2m5", "The Wizard's Manse"},
                   2379:        {"e2m6", "The Dismal Oubliette"},
                   2380:        {"e2m7", "Underearth"},
                   2381: 
                   2382:        {"e3m1", "Termination Central"},                        // 16
                   2383:        {"e3m2", "The Vaults of Zin"},
                   2384:        {"e3m3", "The Tomb of Terror"},
                   2385:        {"e3m4", "Satan's Dark Delight"},
                   2386:        {"e3m5", "Wind Tunnels"},
                   2387:        {"e3m6", "Chambers of Torment"},
                   2388:        {"e3m7", "The Haunted Halls"},
                   2389: 
                   2390:        {"e4m1", "The Sewage System"},                          // 23
                   2391:        {"e4m2", "The Tower of Despair"},
                   2392:        {"e4m3", "The Elder God Shrine"},
                   2393:        {"e4m4", "The Palace of Hate"},
                   2394:        {"e4m5", "Hell's Atrium"},
1.1.1.3 ! root     2395:        {"e4m6", "The Pain Maze"},
1.1       root     2396:        {"e4m7", "Azure Agony"},
                   2397:        {"e4m8", "The Nameless City"},
                   2398: 
                   2399:        {"end", "Shub-Niggurath's Pit"},                        // 31
                   2400: 
                   2401:        {"dm1", "Place of Two Deaths"},                         // 32
                   2402:        {"dm2", "Claustrophobopolis"},
                   2403:        {"dm3", "The Abandoned Base"},
                   2404:        {"dm4", "The Bad Place"},
                   2405:        {"dm5", "The Cistern"},
                   2406:        {"dm6", "The Dark Zone"}
                   2407: };
                   2408: 
1.1.1.3 ! root     2409: //MED 01/06/97 added hipnotic levels
        !          2410: level_t     hipnoticlevels[] =
        !          2411: {
        !          2412:    {"start", "Command HQ"},  // 0
        !          2413: 
        !          2414:    {"hip1m1", "The Pumping Station"},          // 1
        !          2415:    {"hip1m2", "Storage Facility"},
        !          2416:    {"hip1m3", "The Lost Mine"},
        !          2417:    {"hip1m4", "Research Facility"},
        !          2418:    {"hip1m5", "Military Complex"},
        !          2419: 
        !          2420:    {"hip2m1", "Ancient Realms"},          // 6
        !          2421:    {"hip2m2", "The Black Cathedral"},
        !          2422:    {"hip2m3", "The Catacombs"},
        !          2423:    {"hip2m4", "The Crypt"},
        !          2424:    {"hip2m5", "Mortum's Keep"},
        !          2425:    {"hip2m6", "The Gremlin's Domain"},
        !          2426: 
        !          2427:    {"hip3m1", "Tur Torment"},       // 12
        !          2428:    {"hip3m2", "Pandemonium"},
        !          2429:    {"hip3m3", "Limbo"},
        !          2430:    {"hip3m4", "The Gauntlet"},
        !          2431: 
        !          2432:    {"hipend", "Armagon's Lair"},       // 16
        !          2433: 
        !          2434:    {"hipdm1", "The Edge of Oblivion"}           // 17
        !          2435: };
        !          2436: 
        !          2437: //PGM 01/07/97 added rogue levels
        !          2438: level_t                roguelevels[] =
        !          2439: {
        !          2440:        {"start",       "Split Decision"},
        !          2441:        {"level1",      "Deviant's Domain"},
        !          2442:        {"level2",      "Dread Portal"},
        !          2443:        {"level3",      "Judgement Call"},
        !          2444:        {"level4",      "Cave of Death"},
        !          2445:        {"level5",      "Towers of Wrath"},
        !          2446:        {"level6",      "Temple of Pain"},
        !          2447:        {"level7",      "Tomb of the Overlord"},
        !          2448:        {"level8",      "Tempus Fugit"},
        !          2449:        {"level9",      "Fury of the Elements"},
        !          2450:        {"level10",     "Curse of Osiris"},
        !          2451:        {"level11",     "Wizard's Keep"},
        !          2452:        {"level12",     "Blood Sacrifice"},
        !          2453:        {"level13",     "Last Bastion"},
        !          2454:        {"level14",     "Source of Evil"}
        !          2455: };
        !          2456: 
1.1       root     2457: typedef struct
                   2458: {
                   2459:        char    *description;
                   2460:        int             firstLevel;
                   2461:        int             levels;
                   2462: } episode_t;
                   2463: 
                   2464: episode_t      episodes[] =
                   2465: {
                   2466:        {"Welcome to Quake", 0, 1},
                   2467:        {"Doomed Dimension", 1, 8},
                   2468:        {"Realm of Black Magic", 9, 7},
                   2469:        {"Netherworld", 16, 7},
                   2470:        {"The Elder World", 23, 8},
                   2471:        {"Final Level", 31, 1},
                   2472:        {"Deathmatch Arena", 32, 6}
                   2473: };
                   2474: 
1.1.1.3 ! root     2475: //MED 01/06/97  added hipnotic episodes
        !          2476: episode_t   hipnoticepisodes[] =
        !          2477: {
        !          2478:    {"Scourge of Armagon", 0, 1},
        !          2479:    {"Fortress of the Dead", 1, 5},
        !          2480:    {"Dominion of Darkness", 6, 6},
        !          2481:    {"The Rift", 12, 4},
        !          2482:    {"Final Level", 16, 1},
        !          2483:    {"Deathmatch Arena", 17, 1}
        !          2484: };
        !          2485: 
        !          2486: //PGM 01/07/97 added rogue episodes
        !          2487: episode_t      rogueepisodes[] =
        !          2488: {
        !          2489:        {"Introduction", 0, 1},
        !          2490:        {"Hell's Fortress", 1, 7},
        !          2491:        {"Corridors of Time", 8, 7}
        !          2492: };
        !          2493: 
1.1       root     2494: int    startepisode;
                   2495: int    startlevel;
                   2496: int maxplayers;
                   2497: qboolean m_serverInfoMessage = false;
                   2498: double m_serverInfoMessageTime;
                   2499: 
                   2500: void M_Menu_GameOptions_f (void)
                   2501: {
                   2502:        key_dest = key_menu;
                   2503:        m_state = m_gameoptions;
                   2504:        m_entersound = true;
                   2505:        if (maxplayers == 0)
                   2506:                maxplayers = svs.maxclients;
                   2507:        if (maxplayers < 2)
                   2508:                maxplayers = svs.maxclientslimit;
                   2509: }
                   2510: 
1.1.1.3 ! root     2511: 
1.1       root     2512: int gameoptions_cursor_table[] = {40, 56, 64, 72, 80, 88, 96, 112, 120};
                   2513: #define        NUM_GAMEOPTIONS 9
                   2514: int            gameoptions_cursor;
                   2515: 
                   2516: void M_GameOptions_Draw (void)
                   2517: {
                   2518:        qpic_t  *p;
                   2519:        int             x;
                   2520: 
1.1.1.3 ! root     2521:        M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
        !          2522:        p = Draw_CachePic ("gfx/p_multi.lmp");
1.1       root     2523:        M_DrawPic ( (320-p->width)/2, 4, p);
                   2524: 
                   2525:        M_DrawTextBox (152, 32, 10, 1);
                   2526:        M_Print (160, 40, "begin game");
1.1.1.3 ! root     2527: 
1.1       root     2528:        M_Print (0, 56, "      Max players");
                   2529:        M_Print (160, 56, va("%i", maxplayers) );
                   2530: 
                   2531:        M_Print (0, 64, "        Game Type");
                   2532:        if (coop.value)
                   2533:                M_Print (160, 64, "Cooperative");
                   2534:        else
                   2535:                M_Print (160, 64, "Deathmatch");
                   2536: 
                   2537:        M_Print (0, 72, "        Teamplay");
1.1.1.3 ! root     2538:        if (rogue)
        !          2539:        {
        !          2540:                char *msg;
        !          2541: 
        !          2542:                switch((int)teamplay.value)
        !          2543:                {
        !          2544:                        case 1: msg = "No Friendly Fire"; break;
        !          2545:                        case 2: msg = "Friendly Fire"; break;
        !          2546:                        case 3: msg = "Tag"; break;
        !          2547:                        case 4: msg = "Capture the Flag"; break;
        !          2548:                        case 5: msg = "One Flag CTF"; break;
        !          2549:                        case 6: msg = "Three Team CTF"; break;
        !          2550:                        default: msg = "Off"; break;
        !          2551:                }
        !          2552:                M_Print (160, 72, msg);
        !          2553:        }
1.1       root     2554:        else
1.1.1.3 ! root     2555:        {
        !          2556:                char *msg;
        !          2557: 
        !          2558:                switch((int)teamplay.value)
        !          2559:                {
        !          2560:                        case 1: msg = "No Friendly Fire"; break;
        !          2561:                        case 2: msg = "Friendly Fire"; break;
        !          2562:                        default: msg = "Off"; break;
        !          2563:                }
        !          2564:                M_Print (160, 72, msg);
        !          2565:        }
1.1       root     2566: 
                   2567:        M_Print (0, 80, "            Skill");
                   2568:        if (skill.value == 0)
                   2569:                M_Print (160, 80, "Easy difficulty");
                   2570:        else if (skill.value == 1)
                   2571:                M_Print (160, 80, "Normal difficulty");
                   2572:        else if (skill.value == 2)
                   2573:                M_Print (160, 80, "Hard difficulty");
                   2574:        else
                   2575:                M_Print (160, 80, "Nightmare difficulty");
                   2576: 
                   2577:        M_Print (0, 88, "       Frag Limit");
                   2578:        if (fraglimit.value == 0)
                   2579:                M_Print (160, 88, "none");
                   2580:        else
                   2581:                M_Print (160, 88, va("%i frags", (int)fraglimit.value));
                   2582: 
                   2583:        M_Print (0, 96, "       Time Limit");
                   2584:        if (timelimit.value == 0)
                   2585:                M_Print (160, 96, "none");
                   2586:        else
                   2587:                M_Print (160, 96, va("%i minutes", (int)timelimit.value));
                   2588: 
                   2589:        M_Print (0, 112, "         Episode");
1.1.1.3 ! root     2590:    //MED 01/06/97 added hipnotic episodes
        !          2591:    if (hipnotic)
        !          2592:       M_Print (160, 112, hipnoticepisodes[startepisode].description);
        !          2593:    //PGM 01/07/97 added rogue episodes
        !          2594:    else if (rogue)
        !          2595:       M_Print (160, 112, rogueepisodes[startepisode].description);
        !          2596:    else
        !          2597:       M_Print (160, 112, episodes[startepisode].description);
1.1       root     2598: 
                   2599:        M_Print (0, 120, "           Level");
1.1.1.3 ! root     2600:    //MED 01/06/97 added hipnotic episodes
        !          2601:    if (hipnotic)
        !          2602:    {
        !          2603:       M_Print (160, 120, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].description);
        !          2604:       M_Print (160, 128, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].name);
        !          2605:    }
        !          2606:    //PGM 01/07/97 added rogue episodes
        !          2607:    else if (rogue)
        !          2608:    {
        !          2609:       M_Print (160, 120, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].description);
        !          2610:       M_Print (160, 128, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].name);
        !          2611:    }
        !          2612:    else
        !          2613:    {
        !          2614:       M_Print (160, 120, levels[episodes[startepisode].firstLevel + startlevel].description);
        !          2615:       M_Print (160, 128, levels[episodes[startepisode].firstLevel + startlevel].name);
        !          2616:    }
1.1       root     2617: 
                   2618: // line cursor
                   2619:        M_DrawCharacter (144, gameoptions_cursor_table[gameoptions_cursor], 12+((int)(realtime*4)&1));
                   2620: 
                   2621:        if (m_serverInfoMessage)
                   2622:        {
                   2623:                if ((realtime - m_serverInfoMessageTime) < 5.0)
                   2624:                {
                   2625:                        x = (320-26*8)/2;
                   2626:                        M_DrawTextBox (x, 138, 24, 4);
                   2627:                        x += 8;
                   2628:                        M_Print (x, 146, "  More than 4 players   ");
                   2629:                        M_Print (x, 154, " requires using command ");
                   2630:                        M_Print (x, 162, "line parameters; please ");
                   2631:                        M_Print (x, 170, "   see techinfo.txt.    ");
                   2632:                }
                   2633:                else
                   2634:                {
                   2635:                        m_serverInfoMessage = false;
                   2636:                }
                   2637:        }
                   2638: }
                   2639: 
                   2640: 
                   2641: void M_NetStart_Change (int dir)
                   2642: {
                   2643:        int count;
                   2644: 
                   2645:        switch (gameoptions_cursor)
                   2646:        {
                   2647:        case 1:
                   2648:                maxplayers += dir;
                   2649:                if (maxplayers > svs.maxclientslimit)
                   2650:                {
                   2651:                        maxplayers = svs.maxclientslimit;
                   2652:                        m_serverInfoMessage = true;
                   2653:                        m_serverInfoMessageTime = realtime;
                   2654:                }
                   2655:                if (maxplayers < 2)
                   2656:                        maxplayers = 2;
                   2657:                break;
                   2658: 
                   2659:        case 2:
                   2660:                Cvar_SetValue ("coop", coop.value ? 0 : 1);
                   2661:                break;
                   2662: 
                   2663:        case 3:
1.1.1.3 ! root     2664:                if (rogue)
        !          2665:                        count = 6;
        !          2666:                else
        !          2667:                        count = 2;
        !          2668: 
        !          2669:                Cvar_SetValue ("teamplay", teamplay.value + dir);
        !          2670:                if (teamplay.value > count)
        !          2671:                        Cvar_SetValue ("teamplay", 0);
        !          2672:                else if (teamplay.value < 0)
        !          2673:                        Cvar_SetValue ("teamplay", count);
1.1       root     2674:                break;
                   2675: 
                   2676:        case 4:
                   2677:                Cvar_SetValue ("skill", skill.value + dir);
                   2678:                if (skill.value > 3)
                   2679:                        Cvar_SetValue ("skill", 0);
                   2680:                if (skill.value < 0)
                   2681:                        Cvar_SetValue ("skill", 3);
                   2682:                break;
                   2683: 
                   2684:        case 5:
                   2685:                Cvar_SetValue ("fraglimit", fraglimit.value + dir*10);
                   2686:                if (fraglimit.value > 100)
                   2687:                        Cvar_SetValue ("fraglimit", 0);
                   2688:                if (fraglimit.value < 0)
                   2689:                        Cvar_SetValue ("fraglimit", 100);
                   2690:                break;
                   2691: 
                   2692:        case 6:
                   2693:                Cvar_SetValue ("timelimit", timelimit.value + dir*5);
                   2694:                if (timelimit.value > 60)
                   2695:                        Cvar_SetValue ("timelimit", 0);
                   2696:                if (timelimit.value < 0)
                   2697:                        Cvar_SetValue ("timelimit", 60);
                   2698:                break;
                   2699: 
                   2700:        case 7:
                   2701:                startepisode += dir;
1.1.1.3 ! root     2702:        //MED 01/06/97 added hipnotic count
        !          2703:                if (hipnotic)
        !          2704:                        count = 6;
        !          2705:        //PGM 01/07/97 added rogue count
        !          2706:                else if (rogue)
        !          2707:                        count = 3;
        !          2708:                else if (registered.value)
1.1       root     2709:                        count = 7;
                   2710:                else
                   2711:                        count = 2;
1.1.1.3 ! root     2712: 
1.1       root     2713:                if (startepisode < 0)
                   2714:                        startepisode = count - 1;
1.1.1.3 ! root     2715: 
1.1       root     2716:                if (startepisode >= count)
                   2717:                        startepisode = 0;
1.1.1.3 ! root     2718: 
1.1       root     2719:                startlevel = 0;
                   2720:                break;
                   2721: 
                   2722:        case 8:
                   2723:                startlevel += dir;
1.1.1.3 ! root     2724:     //MED 01/06/97 added hipnotic episodes
        !          2725:                if (hipnotic)
        !          2726:                        count = hipnoticepisodes[startepisode].levels;
        !          2727:        //PGM 01/06/97 added hipnotic episodes
        !          2728:                else if (rogue)
        !          2729:                        count = rogueepisodes[startepisode].levels;
        !          2730:                else
        !          2731:                        count = episodes[startepisode].levels;
        !          2732: 
1.1       root     2733:                if (startlevel < 0)
                   2734:                        startlevel = count - 1;
1.1.1.3 ! root     2735: 
1.1       root     2736:                if (startlevel >= count)
                   2737:                        startlevel = 0;
                   2738:                break;
                   2739:        }
                   2740: }
                   2741: 
                   2742: void M_GameOptions_Key (int key)
                   2743: {
                   2744:        switch (key)
                   2745:        {
                   2746:        case K_ESCAPE:
                   2747:                M_Menu_Net_f ();
                   2748:                break;
                   2749: 
                   2750:        case K_UPARROW:
                   2751:                S_LocalSound ("misc/menu1.wav");
                   2752:                gameoptions_cursor--;
                   2753:                if (gameoptions_cursor < 0)
                   2754:                        gameoptions_cursor = NUM_GAMEOPTIONS-1;
                   2755:                break;
                   2756: 
                   2757:        case K_DOWNARROW:
                   2758:                S_LocalSound ("misc/menu1.wav");
                   2759:                gameoptions_cursor++;
                   2760:                if (gameoptions_cursor >= NUM_GAMEOPTIONS)
                   2761:                        gameoptions_cursor = 0;
                   2762:                break;
                   2763: 
                   2764:        case K_LEFTARROW:
                   2765:                if (gameoptions_cursor == 0)
                   2766:                        break;
                   2767:                S_LocalSound ("misc/menu3.wav");
                   2768:                M_NetStart_Change (-1);
                   2769:                break;
                   2770: 
                   2771:        case K_RIGHTARROW:
                   2772:                if (gameoptions_cursor == 0)
                   2773:                        break;
                   2774:                S_LocalSound ("misc/menu3.wav");
                   2775:                M_NetStart_Change (1);
                   2776:                break;
                   2777: 
                   2778:        case K_ENTER:
                   2779:                S_LocalSound ("misc/menu2.wav");
                   2780:                if (gameoptions_cursor == 0)
                   2781:                {
                   2782:                        if (sv.active)
                   2783:                                Cbuf_AddText ("disconnect\n");
1.1.1.3 ! root     2784:                        Cbuf_AddText ("listen 0\n");    // so host_netport will be re-examined
1.1       root     2785:                        Cbuf_AddText ( va ("maxplayers %u\n", maxplayers) );
                   2786:                        SCR_BeginLoadingPlaque ();
1.1.1.3 ! root     2787: 
        !          2788:                        if (hipnotic)
        !          2789:                                Cbuf_AddText ( va ("map %s\n", hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].name) );
        !          2790:                        else if (rogue)
        !          2791:                                Cbuf_AddText ( va ("map %s\n", roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].name) );
        !          2792:                        else
        !          2793:                                Cbuf_AddText ( va ("map %s\n", levels[episodes[startepisode].firstLevel + startlevel].name) );
        !          2794: 
1.1       root     2795:                        return;
                   2796:                }
1.1.1.3 ! root     2797: 
1.1       root     2798:                M_NetStart_Change (1);
1.1.1.3 ! root     2799:                break;
1.1       root     2800:        }
                   2801: }
                   2802: 
                   2803: //=============================================================================
                   2804: /* SEARCH MENU */
                   2805: 
                   2806: qboolean       searchComplete = false;
                   2807: double         searchCompleteTime;
                   2808: 
                   2809: void M_Menu_Search_f (void)
                   2810: {
                   2811:        key_dest = key_menu;
                   2812:        m_state = m_search;
                   2813:        m_entersound = false;
                   2814:        slistSilent = true;
                   2815:        slistLocal = false;
                   2816:        searchComplete = false;
                   2817:        NET_Slist_f();
                   2818: 
                   2819: }
                   2820: 
                   2821: 
                   2822: void M_Search_Draw (void)
                   2823: {
                   2824:        qpic_t  *p;
1.1.1.3 ! root     2825:        int x;
1.1       root     2826: 
1.1.1.3 ! root     2827:        p = Draw_CachePic ("gfx/p_multi.lmp");
1.1       root     2828:        M_DrawPic ( (320-p->width)/2, 4, p);
1.1.1.3 ! root     2829:        x = (320/2) - ((12*8)/2) + 4;
        !          2830:        M_DrawTextBox (x-8, 32, 12, 1);
        !          2831:        M_Print (x, 40, "Searching...");
        !          2832: 
1.1       root     2833:        if(slistInProgress)
                   2834:        {
                   2835:                NET_Poll();
                   2836:                return;
                   2837:        }
                   2838: 
                   2839:        if (! searchComplete)
                   2840:        {
                   2841:                searchComplete = true;
                   2842:                searchCompleteTime = realtime;
                   2843:        }
                   2844: 
                   2845:        if (hostCacheCount)
                   2846:        {
                   2847:                M_Menu_ServerList_f ();
                   2848:                return;
                   2849:        }
                   2850: 
1.1.1.3 ! root     2851:        M_PrintWhite ((320/2) - ((22*8)/2), 64, "No Quake servers found");
1.1       root     2852:        if ((realtime - searchCompleteTime) < 3.0)
                   2853:                return;
                   2854: 
                   2855:        M_Menu_LanConfig_f ();
                   2856: }
                   2857: 
                   2858: 
                   2859: void M_Search_Key (int key)
                   2860: {
                   2861: }
                   2862: 
                   2863: //=============================================================================
                   2864: /* SLIST MENU */
                   2865: 
                   2866: int            slist_cursor;
1.1.1.3 ! root     2867: qboolean slist_sorted;
1.1       root     2868: 
                   2869: void M_Menu_ServerList_f (void)
                   2870: {
                   2871:        key_dest = key_menu;
                   2872:        m_state = m_slist;
                   2873:        m_entersound = true;
                   2874:        slist_cursor = 0;
1.1.1.3 ! root     2875:        m_return_onerror = false;
        !          2876:        m_return_reason[0] = 0;
        !          2877:        slist_sorted = false;
1.1       root     2878: }
                   2879: 
                   2880: 
                   2881: void M_ServerList_Draw (void)
                   2882: {
                   2883:        int             n;
                   2884:        char    string [64];
                   2885:        qpic_t  *p;
                   2886: 
1.1.1.3 ! root     2887:        if (!slist_sorted)
        !          2888:        {
        !          2889:                if (hostCacheCount > 1)
        !          2890:                {
        !          2891:                        int     i,j;
        !          2892:                        hostcache_t temp;
        !          2893:                        for (i = 0; i < hostCacheCount; i++)
        !          2894:                                for (j = i+1; j < hostCacheCount; j++)
        !          2895:                                        if (strcmp(hostcache[j].name, hostcache[i].name) < 0)
        !          2896:                                        {
        !          2897:                                                Q_memcpy(&temp, &hostcache[j], sizeof(hostcache_t));
        !          2898:                                                Q_memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t));
        !          2899:                                                Q_memcpy(&hostcache[i], &temp, sizeof(hostcache_t));
        !          2900:                                        }
        !          2901:                }
        !          2902:                slist_sorted = true;
        !          2903:        }
        !          2904: 
        !          2905:        p = Draw_CachePic ("gfx/p_multi.lmp");
1.1       root     2906:        M_DrawPic ( (320-p->width)/2, 4, p);
                   2907:        for (n = 0; n < hostCacheCount; n++)
                   2908:        {
                   2909:                if (hostcache[n].maxusers)
                   2910:                        sprintf(string, "%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers);
                   2911:                else
                   2912:                        sprintf(string, "%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map);
                   2913:                M_Print (16, 32 + 8*n, string);
                   2914:        }
                   2915:        M_DrawCharacter (0, 32 + slist_cursor*8, 12+((int)(realtime*4)&1));
1.1.1.3 ! root     2916: 
        !          2917:        if (*m_return_reason)
        !          2918:                M_PrintWhite (16, 148, m_return_reason);
1.1       root     2919: }
                   2920: 
                   2921: 
                   2922: void M_ServerList_Key (int k)
                   2923: {
                   2924:        switch (k)
                   2925:        {
                   2926:        case K_ESCAPE:
                   2927:                M_Menu_LanConfig_f ();
                   2928:                break;
                   2929: 
1.1.1.3 ! root     2930:        case K_SPACE:
        !          2931:                M_Menu_Search_f ();
        !          2932:                break;
        !          2933: 
1.1       root     2934:        case K_UPARROW:
                   2935:        case K_LEFTARROW:
                   2936:                S_LocalSound ("misc/menu1.wav");
                   2937:                slist_cursor--;
                   2938:                if (slist_cursor < 0)
                   2939:                        slist_cursor = hostCacheCount - 1;
                   2940:                break;
                   2941: 
                   2942:        case K_DOWNARROW:
                   2943:        case K_RIGHTARROW:
                   2944:                S_LocalSound ("misc/menu1.wav");
                   2945:                slist_cursor++;
                   2946:                if (slist_cursor >= hostCacheCount)
                   2947:                        slist_cursor = 0;
                   2948:                break;
                   2949: 
                   2950:        case K_ENTER:
                   2951:                S_LocalSound ("misc/menu2.wav");
1.1.1.3 ! root     2952:                m_return_state = m_state;
        !          2953:                m_return_onerror = true;
        !          2954:                slist_sorted = false;
1.1       root     2955:                key_dest = key_game;
                   2956:                m_state = m_none;
                   2957:                Cbuf_AddText ( va ("connect \"%s\"\n", hostcache[slist_cursor].cname) );
                   2958:                break;
                   2959: 
                   2960:        default:
                   2961:                break;
                   2962:        }
                   2963: 
                   2964: }
                   2965: 
                   2966: //=============================================================================
                   2967: /* Menu Subsystem */
                   2968: 
                   2969: 
                   2970: void M_Init (void)
                   2971: {
                   2972:        Cmd_AddCommand ("togglemenu", M_ToggleMenu_f);
                   2973: 
                   2974:        Cmd_AddCommand ("menu_main", M_Menu_Main_f);
                   2975:        Cmd_AddCommand ("menu_singleplayer", M_Menu_SinglePlayer_f);
                   2976:        Cmd_AddCommand ("menu_load", M_Menu_Load_f);
                   2977:        Cmd_AddCommand ("menu_save", M_Menu_Save_f);
                   2978:        Cmd_AddCommand ("menu_multiplayer", M_Menu_MultiPlayer_f);
                   2979:        Cmd_AddCommand ("menu_setup", M_Menu_Setup_f);
                   2980:        Cmd_AddCommand ("menu_options", M_Menu_Options_f);
                   2981:        Cmd_AddCommand ("menu_keys", M_Menu_Keys_f);
                   2982:        Cmd_AddCommand ("menu_video", M_Menu_Video_f);
                   2983:        Cmd_AddCommand ("help", M_Menu_Help_f);
                   2984:        Cmd_AddCommand ("menu_quit", M_Menu_Quit_f);
                   2985: }
                   2986: 
                   2987: 
                   2988: void M_Draw (void)
                   2989: {
                   2990:        if (m_state == m_none || key_dest != key_menu)
                   2991:                return;
                   2992: 
                   2993:        if (!m_recursiveDraw)
                   2994:        {
                   2995:                scr_copyeverything = 1;
                   2996: 
                   2997:                if (scr_con_current)
                   2998:                {
                   2999:                        Draw_ConsoleBackground (vid.height);
1.1.1.3 ! root     3000:                        VID_UnlockBuffer ();
1.1       root     3001:                        S_ExtraUpdate ();
1.1.1.3 ! root     3002:                        VID_LockBuffer ();
1.1       root     3003:                }
                   3004:                else
                   3005:                        Draw_FadeScreen ();
                   3006: 
                   3007:                scr_fullupdate = 0;
                   3008:        }
                   3009:        else
                   3010:        {
                   3011:                m_recursiveDraw = false;
                   3012:        }
                   3013: 
                   3014:        switch (m_state)
                   3015:        {
                   3016:        case m_none:
                   3017:                break;
                   3018: 
                   3019:        case m_main:
                   3020:                M_Main_Draw ();
                   3021:                break;
                   3022: 
                   3023:        case m_singleplayer:
                   3024:                M_SinglePlayer_Draw ();
                   3025:                break;
                   3026: 
                   3027:        case m_load:
                   3028:                M_Load_Draw ();
                   3029:                break;
                   3030: 
                   3031:        case m_save:
                   3032:                M_Save_Draw ();
                   3033:                break;
                   3034: 
                   3035:        case m_multiplayer:
                   3036:                M_MultiPlayer_Draw ();
                   3037:                break;
                   3038: 
                   3039:        case m_setup:
                   3040:                M_Setup_Draw ();
                   3041:                break;
                   3042: 
                   3043:        case m_net:
                   3044:                M_Net_Draw ();
                   3045:                break;
                   3046: 
                   3047:        case m_options:
                   3048:                M_Options_Draw ();
                   3049:                break;
                   3050: 
                   3051:        case m_keys:
                   3052:                M_Keys_Draw ();
                   3053:                break;
                   3054: 
                   3055:        case m_video:
                   3056:                M_Video_Draw ();
                   3057:                break;
                   3058: 
                   3059:        case m_help:
                   3060:                M_Help_Draw ();
                   3061:                break;
                   3062: 
                   3063:        case m_quit:
                   3064:                M_Quit_Draw ();
                   3065:                break;
                   3066: 
                   3067:        case m_serialconfig:
                   3068:                M_SerialConfig_Draw ();
                   3069:                break;
                   3070: 
                   3071:        case m_modemconfig:
                   3072:                M_ModemConfig_Draw ();
                   3073:                break;
                   3074: 
                   3075:        case m_lanconfig:
                   3076:                M_LanConfig_Draw ();
                   3077:                break;
                   3078: 
                   3079:        case m_gameoptions:
                   3080:                M_GameOptions_Draw ();
                   3081:                break;
                   3082: 
                   3083:        case m_search:
                   3084:                M_Search_Draw ();
                   3085:                break;
                   3086: 
                   3087:        case m_slist:
                   3088:                M_ServerList_Draw ();
                   3089:                break;
                   3090:        }
                   3091: 
                   3092:        if (m_entersound)
                   3093:        {
                   3094:                S_LocalSound ("misc/menu2.wav");
                   3095:                m_entersound = false;
                   3096:        }
1.1.1.3 ! root     3097: 
        !          3098:        VID_UnlockBuffer ();
1.1       root     3099:        S_ExtraUpdate ();
1.1.1.3 ! root     3100:        VID_LockBuffer ();
1.1       root     3101: }
                   3102: 
                   3103: 
                   3104: void M_Keydown (int key)
                   3105: {
                   3106:        switch (m_state)
                   3107:        {
                   3108:        case m_none:
                   3109:                return;
                   3110: 
                   3111:        case m_main:
                   3112:                M_Main_Key (key);
                   3113:                return;
                   3114: 
                   3115:        case m_singleplayer:
                   3116:                M_SinglePlayer_Key (key);
                   3117:                return;
                   3118: 
                   3119:        case m_load:
                   3120:                M_Load_Key (key);
                   3121:                return;
                   3122: 
                   3123:        case m_save:
                   3124:                M_Save_Key (key);
                   3125:                return;
                   3126: 
                   3127:        case m_multiplayer:
                   3128:                M_MultiPlayer_Key (key);
                   3129:                return;
                   3130: 
                   3131:        case m_setup:
                   3132:                M_Setup_Key (key);
                   3133:                return;
                   3134: 
                   3135:        case m_net:
                   3136:                M_Net_Key (key);
                   3137:                return;
                   3138: 
                   3139:        case m_options:
                   3140:                M_Options_Key (key);
                   3141:                return;
                   3142: 
                   3143:        case m_keys:
                   3144:                M_Keys_Key (key);
                   3145:                return;
                   3146: 
                   3147:        case m_video:
                   3148:                M_Video_Key (key);
                   3149:                return;
                   3150: 
                   3151:        case m_help:
                   3152:                M_Help_Key (key);
                   3153:                return;
                   3154: 
                   3155:        case m_quit:
                   3156:                M_Quit_Key (key);
                   3157:                return;
                   3158: 
                   3159:        case m_serialconfig:
                   3160:                M_SerialConfig_Key (key);
                   3161:                return;
                   3162: 
                   3163:        case m_modemconfig:
                   3164:                M_ModemConfig_Key (key);
                   3165:                return;
                   3166: 
                   3167:        case m_lanconfig:
                   3168:                M_LanConfig_Key (key);
                   3169:                return;
                   3170: 
                   3171:        case m_gameoptions:
                   3172:                M_GameOptions_Key (key);
                   3173:                return;
                   3174: 
                   3175:        case m_search:
                   3176:                M_Search_Key (key);
                   3177:                break;
                   3178: 
                   3179:        case m_slist:
                   3180:                M_ServerList_Key (key);
                   3181:                return;
                   3182:        }
                   3183: }
                   3184: 
                   3185: 
                   3186: void M_ConfigureNetSubsystem(void)
                   3187: {
                   3188: // enable/disable net systems to match desired config
                   3189: 
                   3190:        Cbuf_AddText ("stopdemo\n");
                   3191:        if (SerialConfig || DirectConfig)
                   3192:        {
                   3193:                Cbuf_AddText ("com1 enable\n");
                   3194:        }
                   3195: 
1.1.1.3 ! root     3196:        if (IPXConfig || TCPIPConfig)
        !          3197:                net_hostport = lanConfig_port;
        !          3198: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.