summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2013-01-21 18:43:26 +0400
committerAndrey Nazarov <skuller@skuller.net>2013-01-21 18:47:49 +0400
commit1a1e47c7dd60ec97783abd7ef267c203c65ba39b (patch)
tree72e0b844534d97d044c03ae8b9386b091baeb279
parent5624ccc5c981f09303a71c69be37ba1c81cb3ace (diff)
Re-introduce savegame and loadgame menus.
Also add ‘single player’ entry to in-game menu.
-rw-r--r--src/baseq2/p_client.c2
-rw-r--r--src/client/ui/menu.c46
-rw-r--r--src/client/ui/q2pro.menu48
-rw-r--r--src/client/ui/script.c43
-rw-r--r--src/client/ui/ui.h4
5 files changed, 136 insertions, 7 deletions
diff --git a/src/baseq2/p_client.c b/src/baseq2/p_client.c
index 8da4177..1d2a024 100644
--- a/src/baseq2/p_client.c
+++ b/src/baseq2/p_client.c
@@ -958,7 +958,7 @@ void respawn(edict_t *self)
}
// restart the entire server
- gi.AddCommandString("menu_loadgame\n");
+ gi.AddCommandString("pushmenu loadgame\n");
}
/*
diff --git a/src/client/ui/menu.c b/src/client/ui/menu.c
index ec8fbf6..32c9d7f 100644
--- a/src/client/ui/menu.c
+++ b/src/client/ui/menu.c
@@ -17,6 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "ui.h"
+#include "server/server.h"
/*
===================================================================
@@ -77,7 +78,13 @@ static void Action_Draw(menuAction_t *a)
}
}
+ if (a->generic.flags & QMF_GRAYED) {
+ R_SetColor(uis.color.disabled.u32);
+ }
UI_DrawString(a->generic.x, a->generic.y, flags, a->generic.name);
+ if (a->generic.flags & QMF_GRAYED) {
+ R_ClearColor();
+ }
}
/*
@@ -1513,6 +1520,33 @@ static void Separator_Draw(menuSeparator_t *s)
/*
===================================================================
+SAVEGAME CONTROL
+
+===================================================================
+*/
+
+static void Savegame_Push(menuAction_t *a)
+{
+ char *info;
+
+ Z_Free(a->generic.name);
+
+ info = SV_GetSaveInfo(a->cmd);
+ if (info) {
+ a->generic.name = info;
+ a->generic.flags &= ~QMF_GRAYED;
+ } else {
+ a->generic.name = Z_CopyString("<EMPTY>");
+ if (a->generic.type == MTYPE_LOADGAME)
+ a->generic.flags |= QMF_GRAYED;
+ }
+
+ UI_StringDimensions(&a->generic.rect, a->generic.uiFlags, a->generic.name);
+}
+
+/*
+===================================================================
+
MISC
===================================================================
@@ -1610,6 +1644,8 @@ void Menu_Init(menuFrameWork_t *menu)
SpinControl_Init(item);
break;
case MTYPE_ACTION:
+ case MTYPE_SAVEGAME:
+ case MTYPE_LOADGAME:
Action_Init(item);
break;
case MTYPE_SEPARATOR:
@@ -1933,6 +1969,8 @@ void Menu_Draw(menuFrameWork_t *menu)
SpinControl_Draw(item);
break;
case MTYPE_ACTION:
+ case MTYPE_SAVEGAME:
+ case MTYPE_LOADGAME:
Action_Draw(item);
break;
case MTYPE_SEPARATOR:
@@ -1991,6 +2029,8 @@ menuSound_t Menu_SelectItem(menuFrameWork_t *s)
case MTYPE_ACTION:
case MTYPE_LIST:
case MTYPE_BITMAP:
+ case MTYPE_SAVEGAME:
+ case MTYPE_LOADGAME:
return Common_DoEnter(item);
default:
return QMS_NOTHANDLED;
@@ -2195,6 +2235,10 @@ qboolean Menu_Push(menuFrameWork_t *menu)
case MTYPE_FIELD:
Field_Push(item);
break;
+ case MTYPE_SAVEGAME:
+ case MTYPE_LOADGAME:
+ Savegame_Push(item);
+ break;
default:
break;
}
@@ -2249,6 +2293,8 @@ void Menu_Free(menuFrameWork_t *menu)
switch (((menuCommon_t *)item)->type) {
case MTYPE_ACTION:
+ case MTYPE_SAVEGAME:
+ case MTYPE_LOADGAME:
Action_Free(item);
break;
case MTYPE_SLIDER:
diff --git a/src/client/ui/q2pro.menu b/src/client/ui/q2pro.menu
index 118cb55..6173805 100644
--- a/src/client/ui/q2pro.menu
+++ b/src/client/ui/q2pro.menu
@@ -40,6 +40,8 @@ begin <menuname>
bind <name> <command>
action <name> <command>
bitmap <image> <command>
+ savegame <slot>
+ loadgame <slot>
blank
field [options] <name> <cvar>
@@ -209,9 +211,48 @@ begin singleplayer
action medium "skill 1; deathmatch 0; coop 0; maxclients 1; newgame"
action hard "skill 2; deathmatch 0; coop 0; maxclients 1; newgame"
action nightmare "skill 3; deathmatch 0; coop 0; maxclients 1; newgame"
- //blank
- //action "load game" pushmenu loadgame
- //action "save game" pushmenu savegame
+ blank
+ action "load game..." pushmenu loadgame
+ action "save game..." pushmenu savegame
+end
+
+begin loadgame
+ banner m_banner_load_game
+ loadgame save0
+ blank
+ loadgame save1
+ loadgame save2
+ loadgame save3
+ loadgame save4
+ loadgame save5
+ loadgame save6
+ loadgame save7
+ loadgame save8
+ loadgame save9
+ loadgame save10
+ loadgame save11
+ loadgame save12
+ loadgame save13
+ loadgame save14
+ loadgame save15
+end
+
+begin savegame
+ banner m_banner_save_game
+ savegame save1
+ savegame save2
+ savegame save3
+ savegame save4
+ savegame save5
+ savegame save6
+ savegame save7
+ savegame save8
+ savegame save10
+ savegame save11
+ savegame save12
+ savegame save13
+ savegame save14
+ savegame save15
end
begin main
@@ -229,6 +270,7 @@ begin game
action "browse q2servers.com" pushmenu servers "+http://q2servers.com/?raw=2"
action "browse address book" pushmenu servers "favorites://" "file:///servers.lst" "broadcast://"
action "browse demos" pushmenu demos
+ action "single player" pushmenu singleplayer
action "options" pushmenu options
action "disconnect" disconnect
action "quit" quit
diff --git a/src/client/ui/script.c b/src/client/ui/script.c
index a35292d..657e57f 100644
--- a/src/client/ui/script.c
+++ b/src/client/ui/script.c
@@ -21,10 +21,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
static menuSound_t Activate(menuCommon_t *self)
{
- if (self->type == MTYPE_ACTION) {
+ switch (self->type) {
+ case MTYPE_ACTION:
Cbuf_AddText(&cmd_buffer, ((menuAction_t *)self)->cmd);
- } else if (self->type == MTYPE_BITMAP) {
+ break;
+ case MTYPE_BITMAP:
Cbuf_AddText(&cmd_buffer, ((menuBitmap_t *)self)->cmd);
+ break;
+ case MTYPE_SAVEGAME:
+ Cbuf_AddText(&cmd_buffer, va("savegame \"%s\"; forcemenuoff\n", ((menuAction_t *)self)->cmd));
+ break;
+ case MTYPE_LOADGAME:
+ Cbuf_AddText(&cmd_buffer, va("loadgame \"%s\"\n", ((menuAction_t *)self)->cmd));
+ break;
+ default:
+ break;
}
return QMS_NOTHANDLED;
@@ -211,6 +222,30 @@ static void Parse_Bind(menuFrameWork_t *menu)
Menu_AddItem(menu, k);
}
+static void Parse_Savegame(menuFrameWork_t *menu, menuType_t type)
+{
+ menuAction_t *a;
+
+ if (Cmd_Argc() < 2) {
+ Com_Printf("Usage: %s <dir>\n", Cmd_Argv(0));
+ return;
+ }
+
+ CHECK_NITEMS
+
+ a = UI_Mallocz(sizeof(*a));
+ a->generic.type = type;
+ a->generic.name = Z_CopyString("<EMPTY>");
+ a->generic.uiFlags = UI_CENTER;
+ a->generic.activate = Activate;
+ a->cmd = UI_CopyString(Cmd_Argv(1));
+
+ if (type == MTYPE_LOADGAME)
+ a->generic.flags |= QMF_GRAYED;
+
+ Menu_AddItem(menu, a);
+}
+
static void Parse_Toggle(menuFrameWork_t *menu)
{
static const char *yes_no_names[] = { "no", "yes", NULL };
@@ -457,6 +492,10 @@ static qboolean Parse_File(const char *path, int depth)
Parse_Bitmap(menu);
} else if (!strcmp(cmd, "bind")) {
Parse_Bind(menu);
+ } else if (!strcmp(cmd, "savegame")) {
+ Parse_Savegame(menu, MTYPE_SAVEGAME);
+ } else if (!strcmp(cmd, "loadgame")) {
+ Parse_Savegame(menu, MTYPE_LOADGAME);
} else if (!strcmp(cmd, "toggle")) {
Parse_Toggle(menu);
} else if (!strcmp(cmd, "field")) {
diff --git a/src/client/ui/ui.h b/src/client/ui/ui.h
index eece618..7b80331 100644
--- a/src/client/ui/ui.h
+++ b/src/client/ui/ui.h
@@ -50,7 +50,9 @@ typedef enum {
MTYPE_TOGGLE,
MTYPE_STATIC,
MTYPE_KEYBIND,
- MTYPE_BITMAP
+ MTYPE_BITMAP,
+ MTYPE_SAVEGAME,
+ MTYPE_LOADGAME
} menuType_t;
#define QMF_LEFT_JUSTIFY 0x00000001