mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-15 16:41:22 +00:00
Merge branch 'modmenu' into qss-r7-admod
This commit is contained in:
commit
de1c3d40d4
10 changed files with 237 additions and 10 deletions
|
@ -1,4 +1,6 @@
|
|||
INPUT := gfx/conback.lmp \
|
||||
gfx/mainmenu2.lmp \
|
||||
gfx/p_mod.lmp \
|
||||
maps/e1m1.ent \
|
||||
maps/e1m2.ent \
|
||||
maps/e1m4.ent \
|
||||
|
|
BIN
quakespasm/Misc/qs_pak/gfx/mainmenu2.lmp
Executable file
BIN
quakespasm/Misc/qs_pak/gfx/mainmenu2.lmp
Executable file
Binary file not shown.
BIN
quakespasm/Misc/qs_pak/gfx/p_mod.lmp
Executable file
BIN
quakespasm/Misc/qs_pak/gfx/p_mod.lmp
Executable file
Binary file not shown.
|
@ -2510,13 +2510,13 @@ static void COM_Game_f (void)
|
|||
TexMgr_NewGame ();
|
||||
Draw_NewGame ();
|
||||
R_NewGame ();
|
||||
M_NewGame ();
|
||||
}
|
||||
ExtraMaps_NewGame ();
|
||||
DemoList_Rebuild ();
|
||||
|
||||
Con_Printf("\"game\" changed to \"%s\"\n", COM_GetGameNames(true));
|
||||
Con_Printf("enter \"exec quake.rc\" to load new configs\n");
|
||||
//Cbuf_InsertText ("exec quake.rc\n");
|
||||
Cbuf_InsertText ("exec quake.rc\n");
|
||||
}
|
||||
else //Diplay the current gamedir
|
||||
Con_Printf("\"game\" is \"%s\"\n", COM_GetGameNames(true));
|
||||
|
|
|
@ -88,6 +88,10 @@ cvar_t scr_showfps = {"scr_showfps", "0", CVAR_NONE};
|
|||
cvar_t scr_clock = {"scr_clock", "0", CVAR_NONE};
|
||||
//johnfitz
|
||||
|
||||
//quakespasm
|
||||
cvar_t scr_currentmod = {"scr_currentmod", "1", CVAR_NONE};
|
||||
//quakespasm
|
||||
|
||||
cvar_t scr_viewsize = {"viewsize","100", CVAR_ARCHIVE};
|
||||
cvar_t scr_fov = {"fov","90",CVAR_NONE}; // 10 - 170
|
||||
cvar_t scr_fov_adapt = {"fov_adapt","1",CVAR_ARCHIVE};
|
||||
|
@ -412,6 +416,9 @@ void SCR_Init (void)
|
|||
Cvar_RegisterVariable (&scr_showfps);
|
||||
Cvar_RegisterVariable (&scr_clock);
|
||||
//johnfitz
|
||||
//quakespasm
|
||||
Cvar_RegisterVariable (&scr_currentmod);
|
||||
//quakespasm
|
||||
Cvar_SetCallback (&scr_fov, SCR_Callback_refdef);
|
||||
Cvar_SetCallback (&scr_fov_adapt, SCR_Callback_refdef);
|
||||
Cvar_SetCallback (&scr_viewsize, SCR_Callback_refdef);
|
||||
|
|
|
@ -230,6 +230,7 @@ void Modlist_Init (void)
|
|||
{
|
||||
WIN32_FIND_DATA fdat, mod_fdat;
|
||||
HANDLE fhnd, mod_fhnd;
|
||||
DWORD attribs;
|
||||
char dir_string[MAX_OSPATH], mod_string[MAX_OSPATH];
|
||||
|
||||
q_snprintf (dir_string, sizeof(dir_string), "%s/*", com_basedir);
|
||||
|
@ -239,9 +240,17 @@ void Modlist_Init (void)
|
|||
|
||||
do
|
||||
{
|
||||
if (!strcmp(fdat.cFileName, "."))
|
||||
if (!strcmp(fdat.cFileName, ".") || !strcmp(fdat.cFileName, ".."))
|
||||
continue;
|
||||
|
||||
#if 1
|
||||
// treat all subdirectories as mods
|
||||
q_snprintf (mod_string, sizeof(mod_string), "%s/%s", com_basedir, fdat.cFileName);
|
||||
attribs = GetFileAttributes (mod_string);
|
||||
if (attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
Modlist_Add(fdat.cFileName);
|
||||
}
|
||||
#else
|
||||
q_snprintf (mod_string, sizeof(mod_string), "%s/%s/progs.dat", com_basedir, fdat.cFileName);
|
||||
mod_fhnd = FindFirstFile(mod_string, &mod_fdat);
|
||||
if (mod_fhnd != INVALID_HANDLE_VALUE) {
|
||||
|
@ -256,6 +265,7 @@ void Modlist_Init (void)
|
|||
Modlist_Add(fdat.cFileName);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} while (FindNextFile(fhnd, &fdat));
|
||||
|
||||
FindClose(fhnd);
|
||||
|
@ -276,10 +286,13 @@ void Modlist_Init (void)
|
|||
{
|
||||
if (!strcmp(dir_t->d_name, ".") || !strcmp(dir_t->d_name, ".."))
|
||||
continue;
|
||||
if (!q_strcasecmp (COM_FileGetExtension (dir_t->d_name), "app")) // skip .app bundles on macOS
|
||||
continue;
|
||||
q_snprintf(mod_string, sizeof(mod_string), "%s%s/", dir_string, dir_t->d_name);
|
||||
mod_dir_p = opendir(mod_string);
|
||||
if (mod_dir_p == NULL)
|
||||
continue;
|
||||
#if 0
|
||||
// find progs.dat and pak file(s)
|
||||
while ((mod_dir_t = readdir(mod_dir_p)) != NULL)
|
||||
{
|
||||
|
@ -292,6 +305,10 @@ void Modlist_Init (void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// don't bother testing for pak files / progs.dat
|
||||
Modlist_Add(dir_t->d_name);
|
||||
#endif
|
||||
closedir(mod_dir_p);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ void M_Menu_Main_f (void);
|
|||
void M_Menu_GameOptions_f (void);
|
||||
void M_Menu_Search_f (enum slistScope_e scope);
|
||||
void M_Menu_ServerList_f (void);
|
||||
void M_Menu_Mods_f (void);
|
||||
void M_Menu_Options_f (void);
|
||||
void M_Menu_Keys_f (void);
|
||||
void M_Menu_Video_f (void);
|
||||
|
@ -57,6 +58,7 @@ void M_Main_Draw (void);
|
|||
void M_GameOptions_Draw (void);
|
||||
void M_Search_Draw (void);
|
||||
void M_ServerList_Draw (void);
|
||||
void M_Mods_Draw (void);
|
||||
void M_Options_Draw (void);
|
||||
void M_Keys_Draw (void);
|
||||
void M_Video_Draw (void);
|
||||
|
@ -74,6 +76,7 @@ void M_Main_Key (int key);
|
|||
void M_GameOptions_Key (int key);
|
||||
void M_Search_Key (int key);
|
||||
void M_ServerList_Key (int key);
|
||||
void M_Mods_Key (int key);
|
||||
void M_Options_Key (int key);
|
||||
void M_Keys_Key (int key);
|
||||
void M_Video_Key (int key);
|
||||
|
@ -84,6 +87,8 @@ qboolean m_entersound; // play after drawing a frame, so caching
|
|||
// won't disrupt the sound
|
||||
qboolean m_recursiveDraw;
|
||||
|
||||
qboolean m_have_mods_menu;
|
||||
|
||||
enum m_state_e m_return_state;
|
||||
qboolean m_return_onerror;
|
||||
char m_return_reason [32];
|
||||
|
@ -238,7 +243,7 @@ void M_ToggleMenu_f (void)
|
|||
/* MAIN MENU */
|
||||
|
||||
int m_main_cursor;
|
||||
#define MAIN_ITEMS 5
|
||||
#define MAIN_ITEMS (m_have_mods_menu ? 6 : 5)
|
||||
|
||||
|
||||
void M_Menu_Main_f (void)
|
||||
|
@ -263,7 +268,11 @@ void M_Main_Draw (void)
|
|||
M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") );
|
||||
p = Draw_CachePic ("gfx/ttl_main.lmp");
|
||||
M_DrawPic ( (320-p->width)/2, 4, p);
|
||||
M_DrawTransPic (72, 32, Draw_CachePic ("gfx/mainmenu.lmp") );
|
||||
if (m_have_mods_menu)
|
||||
p = Draw_CachePic ("gfx/mainmenu2.lmp");
|
||||
else
|
||||
p = Draw_CachePic ("gfx/mainmenu.lmp");
|
||||
M_DrawTransPic (72, 32, p );
|
||||
|
||||
f = (int)(realtime * 10)%6;
|
||||
|
||||
|
@ -273,6 +282,8 @@ void M_Main_Draw (void)
|
|||
|
||||
void M_Main_Key (int key)
|
||||
{
|
||||
int remapped_cursor;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case K_ESCAPE:
|
||||
|
@ -304,7 +315,13 @@ void M_Main_Key (int key)
|
|||
case K_ABUTTON:
|
||||
m_entersound = true;
|
||||
|
||||
switch (m_main_cursor)
|
||||
// ericw -- remap cursor index 2 (Options) to 3 for the switch statement
|
||||
if (!m_have_mods_menu && m_main_cursor >= 2)
|
||||
remapped_cursor = m_main_cursor + 1;
|
||||
else
|
||||
remapped_cursor = m_main_cursor;
|
||||
|
||||
switch (remapped_cursor)
|
||||
{
|
||||
case 0:
|
||||
M_Menu_SinglePlayer_f ();
|
||||
|
@ -315,14 +332,18 @@ void M_Main_Key (int key)
|
|||
break;
|
||||
|
||||
case 2:
|
||||
M_Menu_Mods_f ();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
M_Menu_Options_f ();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 4:
|
||||
M_Menu_Help_f ();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
M_Menu_Quit_f ();
|
||||
break;
|
||||
}
|
||||
|
@ -969,6 +990,142 @@ again:
|
|||
goto again;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/* MODS MENU */
|
||||
|
||||
#define MAX_MOD_ROWS 1000 /* ericw -- max mods in list */
|
||||
#define MAX_MOD_ROWS_VISBLE 19 /* ericw -- show this many at a time */
|
||||
|
||||
char m_modnames[MAX_MOD_ROWS][MAX_QPATH+1];
|
||||
int m_modnames_len;
|
||||
int m_modnames_cursor;
|
||||
|
||||
static void M_Mods_PopulateMods (void)
|
||||
{
|
||||
filelist_item_t *mod;
|
||||
static qboolean built;
|
||||
|
||||
// NOTE: currently only build the mod list once.
|
||||
if (built)
|
||||
return;
|
||||
|
||||
built = true;
|
||||
|
||||
m_modnames_len = 0;
|
||||
m_modnames_cursor = 0;
|
||||
|
||||
// insert id1 first
|
||||
q_strlcpy(m_modnames[m_modnames_len++], "id1", sizeof(m_modnames[0]));
|
||||
|
||||
for (mod = modlist; mod; mod = mod->next) {
|
||||
if (m_modnames_len >= MAX_MOD_ROWS)
|
||||
break;
|
||||
if (!q_strcasecmp("id1", mod->name))
|
||||
continue;
|
||||
q_strlcpy(m_modnames[m_modnames_len++], mod->name, sizeof(m_modnames[0]));
|
||||
}
|
||||
}
|
||||
|
||||
void M_Menu_Mods_f (void)
|
||||
{
|
||||
m_entersound = true;
|
||||
m_state = m_mods;
|
||||
|
||||
IN_Deactivate(modestate == MS_WINDOWED);
|
||||
key_dest = key_menu;
|
||||
|
||||
M_Mods_PopulateMods();
|
||||
}
|
||||
|
||||
void M_Mods_Draw (void)
|
||||
{
|
||||
int i;
|
||||
qpic_t *p;
|
||||
const char *current_mod;
|
||||
int toprow;
|
||||
int page;
|
||||
int numpages;
|
||||
char page_string[64];
|
||||
|
||||
page = (m_modnames_cursor / MAX_MOD_ROWS_VISBLE);
|
||||
numpages = 1 + ((m_modnames_len - 1) / MAX_MOD_ROWS_VISBLE);
|
||||
toprow = page * MAX_MOD_ROWS_VISBLE;
|
||||
|
||||
if (m_have_mods_menu)
|
||||
{
|
||||
p = Draw_CachePic ("gfx/p_mod.lmp");
|
||||
M_DrawPic ( (320-p->width)/2, 4, p);
|
||||
}
|
||||
|
||||
q_snprintf (page_string, sizeof(page_string), "page:%2i /%2i", page + 1, numpages);
|
||||
M_Print ((320/2) - 8*(strlen(page_string)/2), 32 + (8*MAX_MOD_ROWS_VISBLE), page_string);
|
||||
|
||||
current_mod = COM_SkipPath(com_gamedir);
|
||||
for (i = 0; i < MAX_MOD_ROWS_VISBLE; i++)
|
||||
{
|
||||
if (!Q_strcmp(m_modnames[toprow + i], current_mod))
|
||||
M_PrintWhite (16, 32 + 8*i, m_modnames[toprow + i]);
|
||||
else
|
||||
M_Print (16, 32 + 8*i, m_modnames[toprow + i]);
|
||||
}
|
||||
|
||||
// line cursor
|
||||
M_DrawCharacter (8, 32 + (m_modnames_cursor - toprow)*8, 12+((int)(realtime*4)&1));
|
||||
}
|
||||
|
||||
void M_Mods_Key (int k)
|
||||
{
|
||||
switch (k)
|
||||
{
|
||||
case K_ESCAPE:
|
||||
case K_BBUTTON:
|
||||
M_Menu_Main_f ();
|
||||
break;
|
||||
|
||||
case K_ENTER:
|
||||
case K_KP_ENTER:
|
||||
case K_ABUTTON:
|
||||
M_Menu_Main_f ();
|
||||
|
||||
// issue the load command
|
||||
Cbuf_AddText (va ("game %s\n", m_modnames[m_modnames_cursor]) );
|
||||
return;
|
||||
|
||||
case K_UPARROW:
|
||||
case K_LEFTARROW:
|
||||
S_LocalSound ("misc/menu1.wav");
|
||||
m_modnames_cursor = CLAMP(0, m_modnames_cursor - 1, m_modnames_len - 1);
|
||||
break;
|
||||
|
||||
case K_DOWNARROW:
|
||||
case K_RIGHTARROW:
|
||||
S_LocalSound ("misc/menu1.wav");
|
||||
m_modnames_cursor = CLAMP(0, m_modnames_cursor + 1, m_modnames_len - 1);
|
||||
break;
|
||||
|
||||
case K_PGUP:
|
||||
S_LocalSound ("misc/menu1.wav");
|
||||
m_modnames_cursor = CLAMP(0, m_modnames_cursor - MAX_MOD_ROWS_VISBLE, m_modnames_len - 1);
|
||||
break;
|
||||
|
||||
case K_PGDN:
|
||||
S_LocalSound ("misc/menu1.wav");
|
||||
m_modnames_cursor = CLAMP(0, m_modnames_cursor + MAX_MOD_ROWS_VISBLE, m_modnames_len - 1);
|
||||
break;
|
||||
|
||||
case K_HOME:
|
||||
S_LocalSound ("misc/menu1.wav");
|
||||
m_modnames_cursor = 0;
|
||||
break;
|
||||
|
||||
case K_END:
|
||||
S_LocalSound ("misc/menu1.wav");
|
||||
m_modnames_cursor = m_modnames_len - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
/* OPTIONS MENU */
|
||||
|
||||
|
@ -2668,13 +2825,30 @@ void M_Init (void)
|
|||
Cmd_AddCommand ("menu_save", M_Menu_Save_f);
|
||||
Cmd_AddCommand ("menu_multiplayer", M_Menu_MultiPlayer_f);
|
||||
Cmd_AddCommand ("menu_setup", M_Menu_Setup_f);
|
||||
Cmd_AddCommand ("menu_mods", M_Menu_Mods_f);
|
||||
Cmd_AddCommand ("menu_options", M_Menu_Options_f);
|
||||
Cmd_AddCommand ("menu_keys", M_Menu_Keys_f);
|
||||
Cmd_AddCommand ("menu_video", M_Menu_Video_f);
|
||||
Cmd_AddCommand ("help", M_Menu_Help_f);
|
||||
Cmd_AddCommand ("menu_quit", M_Menu_Quit_f);
|
||||
|
||||
M_NewGame ();
|
||||
}
|
||||
|
||||
void M_NewGame (void)
|
||||
{
|
||||
// ericw -- check for graphics for mods menu
|
||||
if (COM_FileExists ("gfx/p_mod.lmp", NULL)
|
||||
&& COM_FileExists ("gfx/mainmenu2.lmp", NULL)
|
||||
&& !COM_CheckParm ("-nomodmenu"))
|
||||
{
|
||||
m_have_mods_menu = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_have_mods_menu = false;
|
||||
}
|
||||
}
|
||||
|
||||
void M_Draw (void)
|
||||
{
|
||||
|
@ -2772,8 +2946,26 @@ void M_Draw (void)
|
|||
case m_slist:
|
||||
M_ServerList_Draw ();
|
||||
break;
|
||||
|
||||
case m_mods:
|
||||
M_Mods_Draw ();
|
||||
break;
|
||||
}
|
||||
|
||||
// ericw -- print active mod
|
||||
if (scr_currentmod.value)
|
||||
{
|
||||
const char *modname = COM_SkipPath(com_gamedir);
|
||||
if (q_strcasecmp("id1", modname))
|
||||
{
|
||||
char active_mod[1024];
|
||||
q_snprintf(active_mod, sizeof(active_mod), "current mod: %s", modname);
|
||||
|
||||
GL_SetCanvas (CANVAS_BOTTOMLEFT);
|
||||
M_Print(0, 24*8, active_mod);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_entersound)
|
||||
{
|
||||
S_LocalSound ("misc/menu2.wav");
|
||||
|
@ -2854,6 +3046,10 @@ void M_Keydown (int key)
|
|||
case m_slist:
|
||||
M_ServerList_Key (key);
|
||||
return;
|
||||
|
||||
case m_mods:
|
||||
M_Mods_Key(key);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ enum m_state_e {
|
|||
m_lanconfig,
|
||||
m_gameoptions,
|
||||
m_search,
|
||||
m_slist
|
||||
m_slist,
|
||||
m_mods
|
||||
};
|
||||
|
||||
extern enum m_state_e m_state;
|
||||
|
@ -52,6 +53,7 @@ extern qboolean m_entersound;
|
|||
// menus
|
||||
//
|
||||
void M_Init (void);
|
||||
void M_NewGame (void);
|
||||
void M_Keydown (int key);
|
||||
void M_Charinput (int key);
|
||||
qboolean M_TextEntry (void);
|
||||
|
|
Binary file not shown.
|
@ -77,6 +77,9 @@ extern cvar_t scr_conscale;
|
|||
extern cvar_t scr_scale;
|
||||
extern cvar_t scr_crosshairscale;
|
||||
//johnfitz
|
||||
//quakespasm
|
||||
extern cvar_t scr_currentmod;
|
||||
//quakespasm
|
||||
|
||||
extern int scr_tileclear_updates; //johnfitz
|
||||
|
||||
|
|
Loading…
Reference in a new issue