#include "quakedef.h"
#include "image.h"
+#include "mprogdefs.h"
#define TYPE_DEMO 1
#define TYPE_GAME 2
//=============================================================================
/* Menu Subsystem */
+void M_Keydown(int key);
+void M_Draw(void);
+void M_ToggleMenu_f(void);
+void M_Shutdown(void);
void M_Init (void)
{
+ // set menu router function pointer
+ MR_Keydown = M_Keydown;
+ MR_Draw = M_Draw;
+ MR_ToggleMenu_f = M_ToggleMenu_f;
+ MR_Shutdown = M_Shutdown;
+
+ // init
menu_mempool = Mem_AllocPool("Menu");
menuplyr_load = true;
menuplyr_pixels = NULL;
{
if (key_dest != key_menu)
m_state = m_none;
+
if (m_state == m_none)
return;
}
}
+void M_Shutdown(void)
+{
+}
+
+//============================================================================
+// Menu prog handling
+mfunction_t *PRVM_ED_FindFunction(const char *);
+
+#define M_F_INIT "m_init"
+#define M_F_KEYDOWN "m_keydown"
+#define M_F_DRAW "m_draw"
+#define M_F_TOGGLE "m_toggle"
+#define M_F_SHUTDOWN "m_shutdown"
+
+static char *m_required_func[] = {
+M_F_INIT,
+M_F_KEYDOWN,
+M_F_DRAW,
+M_F_TOGGLE,
+M_F_SHUTDOWN,
+};
+
+static int m_numrequiredfunc = sizeof(m_required_func) / sizeof(char*);
+
+static func_t m_draw,m_keydown;
+
+void MP_Error(void)
+{
+ // fall back to the normal menu
+
+ // say it
+ Con_Printf("Falling back to normal menu.\n Error :");
+
+ // init the normal menu now -> this will also correct the menu router pointers
+ M_Init();
+}
+
+void MP_Keydown (int key)
+{
+ PRVM_Begin;
+ PRVM_SetProg(PRVM_MENUPROG);
+
+ // pass key
+ prog->globals[OFS_PARM0] = (float) key;
+ PRVM_ExecuteProgram(m_keydown, M_F_KEYDOWN"(float key) required\n");
+
+ PRVM_End;
+}
+void MP_Draw (void)
+{
+ PRVM_Begin;
+ PRVM_SetProg(PRVM_MENUPROG);
+
+ PRVM_ExecuteProgram(m_draw,"");
+
+ PRVM_End;
+}
+
+void MP_ToggleMenu_f (void)
+{
+ PRVM_Begin;
+ PRVM_SetProg(PRVM_MENUPROG);
+
+ PRVM_ExecuteProgram((func_t) (PRVM_ED_FindFunction(M_F_TOGGLE) - prog->functions),"");
+
+ PRVM_End;
+}
+
+void MP_Shutdown (void)
+{
+ PRVM_Begin;
+ PRVM_SetProg(PRVM_MENUPROG);
+
+ PRVM_ExecuteProgram((func_t) (PRVM_ED_FindFunction(M_F_SHUTDOWN) - prog->functions),"");
+
+ // reset key_dest
+ key_dest = key_game;
+
+ // AK not using this cause Im not sure whether this is useful at all instead :
+/* // free mempools
+ Mem_FreePool(prog->edicts_mempool);
+ Mem_FreePool(prog->edictstring_mempool);
+ Mem_FreePool(prog->progs_mempool);*/
+ PRVM_ResetProg();
+
+ PRVM_End;
+}
+
+void MP_Init (void)
+{
+ MR_Keydown = MP_Keydown;
+ MR_Draw = MP_Draw;
+ MR_ToggleMenu_f = MP_ToggleMenu_f;
+ MR_Shutdown = MP_Shutdown;
+
+ PRVM_Begin;
+ PRVM_InitProg(PRVM_MENUPROG);
+
+ prog->crc = M_PROGHEADER_CRC;
+ prog->edictprivate_size = 0; // no private struct used
+ prog->name = M_NAME;
+ prog->limit_edicts = M_MAX_EDICTS;
+ prog->extensionstring = vm_m_extensions;
+ prog->builtins = vm_m_builtins;
+ prog->numbuiltins = vm_m_numbuiltins;
+ prog->init_cmd = VM_M_Cmd_Init;
+ prog->reset_cmd = VM_M_Cmd_Reset;
+ prog->error_cmd = MP_Error;
+
+ // allocate the mempools
+ prog->edicts_mempool = Mem_AllocPool(M_NAME " edicts mempool");
+ prog->edictstring_mempool = Mem_AllocPool( M_NAME " edict string mempool");
+ prog->progs_mempool = Mem_AllocPool(M_PROG_FILENAME);
+
+ PRVM_LoadProgs(M_PROG_FILENAME, m_numrequiredfunc, m_required_func);
+
+ // set m_draw and m_keydown
+ m_draw = (func_t) (PRVM_ED_FindFunction(M_F_DRAW) - prog->functions);
+ m_keydown = (func_t) (PRVM_ED_FindFunction(M_F_KEYDOWN) - prog->functions);
+
+ // call the prog init
+ PRVM_ExecuteProgram((func_t) (PRVM_ED_FindFunction(M_F_INIT) - prog->functions),"");
+
+ PRVM_End;
+}
+
+//============================================================================
+// Menu router
+
+static cvar_t forceqmenu = { 0, "forceqmenu", "0" };
+
+void MR_ChooseInit(void)
+{
+ if(!FS_FileExists(M_PROG_FILENAME) || forceqmenu.integer)
+ M_Init();
+ else
+ MP_Init();
+}
+
+void MR_Restart_f(void)
+{
+ MR_Shutdown ();
+ MR_ChooseInit ();
+}
+
+void MR_Init()
+{
+ // set router console commands
+ Cvar_RegisterVariable (&forceqmenu);
+ Cmd_AddCommand ("menu_restart",MR_Restart_f);
+
+ MR_ChooseInit ();
+}
+
+
+
+
int i;
numsbarpics = 0;
-
+
sb_disc = Sbar_NewPic("gfx/disc");
for (i = 0;i < 10;i++)
- {
sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
- sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i));
- }
sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus");
sb_colon = Sbar_NewPic ("gfx/num_colon");
sb_slash = Sbar_NewPic ("gfx/num_slash");
- //AK NEX uses its own hud
+ //AK NX uses its own hud
if(gamemode == GAME_NEXUIZ)
{
sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
sb_ammo[1] = Sbar_NewPic ("gfx/sb_bullets");
sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
-
+
sb_items[2] = Sbar_NewPic ("gfx/sb_slowmo");
sb_items[3] = Sbar_NewPic ("gfx/sb_invinc");
sb_items[4] = Sbar_NewPic ("gfx/sb_energy");
sb_items[5] = Sbar_NewPic ("gfx/sb_str");
-
+
sb_sbar = Sbar_NewPic("gfx/sbar");
sb_sbar_overlay = Sbar_NewPic("gfx/sbar_overlay");
sb_weapons[0][i] = Sbar_NewPic(va("gfx/inv_weapon%i",i));
return;
- }
+ }
sb_weapons[0][0] = Sbar_NewPic ("gfx/inv_shotgun");
sb_weapons[0][1] = Sbar_NewPic ("gfx/inv_sshotgun");
Sbar_DrawPic (x, y, sb_nums[color][frame]);
x += 24;
+
+ ptr++;
+ }
+}
+
+/*
+=============
+Sbar_DrawXNum
+=============
+*/
+
+void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r, float g, float b, float a, int flags)
+{
+ char str[32], *ptr;
+ int l, frame;
+
+ l = sprintf(str, "%i", num);
+ ptr = str;
+ if (l > digits)
+ ptr += (l-digits);
+ if (l < digits)
+ x += (digits-l) * lettersize;
+
+ while (*ptr)
+ {
+ if (*ptr == '-')
+ frame = STAT_MINUS;
+ else
+ frame = *ptr -'0';
+
+ DrawQ_Pic (sbar_x + x, sbar_y + y, sb_nums[0][frame]->name,lettersize,lettersize,r,g,b,a,flags);
+ x += lettersize;
+
ptr++;
}
}
{
if (scr_con_current == vid.conheight)
return; // console is full screen
-
+
if (cl.intermission == 1)
{
Sbar_IntermissionOverlay();
{
sbar_y = vid.conheight - 47;
sbar_x = (vid.conwidth - 640)/2;
-
- if (sb_lines > 24)
- Sbar_DrawFrags ();
-
+
+ if (sb_lines)
+ {
+ Sbar_DrawInventory();
+ if (!cl.islocalgame)
+ Sbar_DrawFrags ();
+ }
+
if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
{
- if (gamemode != GAME_GOODVSBAD2)
- Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
+ Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
Sbar_DrawScoreboard ();
}
else if (sb_lines)
{
Sbar_DrawPic (0, 0, sb_sbar);
-
+
// special items
if (cl.items & IT_INVULNERABILITY)
{
- Sbar_DrawNum (24, 0, 666, 3, 1);
+ Sbar_DrawNum (36, 0, 666, 3, 1);
Sbar_DrawPic (0, 0, sb_disc);
}
// armor
- Sbar_DrawNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
-
+ Sbar_DrawXNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, 24, 0.6,0.7,0.8,1,0);
+
// health
- Sbar_DrawNum ((154-3*24), 12, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
-
- if (cl.items & NEX_IT_SHELLS)
- Sbar_DrawPic (519, 0, sb_ammo[0]);
- else if (cl.items & NEX_IT_BULLETS)
- Sbar_DrawPic (519, 0, sb_ammo[1]);
- else if (cl.items & NEX_IT_ROCKETS)
- Sbar_DrawPic (519, 0, sb_ammo[2]);
- else if (cl.items & NEX_IT_CELLS)
- Sbar_DrawPic (519, 0, sb_ammo[3]);
-
- Sbar_DrawNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
+ if(cl.stats[STAT_HEALTH] > 100)
+ Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,1,1,1,1,0);
+ else if(cl.stats[STAT_HEALTH] <= 25 && cl.time - (int)cl.time > 0.5)
+ Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0);
+ else
+ Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0);
+
+ // AK dont draw ammo for the laser
+ if(cl.stats[STAT_ACTIVEWEAPON] != 12)
+ {
+ if (cl.items & NEX_IT_SHELLS)
+ Sbar_DrawPic (519, 0, sb_ammo[0]);
+ else if (cl.items & NEX_IT_BULLETS)
+ Sbar_DrawPic (519, 0, sb_ammo[1]);
+ else if (cl.items & NEX_IT_ROCKETS)
+ Sbar_DrawPic (519, 0, sb_ammo[2]);
+ else if (cl.items & NEX_IT_CELLS)
+ Sbar_DrawPic (519, 0, sb_ammo[3]);
+
+ if(cl.stats[STAT_AMMO] <= 10)
+ Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.7, 0,0,1,0);
+ else
+ Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.6, 0.7,0.8,1,0);
+
+ }
- //Sbar_DrawAlphaPic(0,0,sb_sbar_overlay,0.5);
DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE);
}
}
}
}
-
if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
Sbar_MiniDeathmatchOverlay ();
int i, x, y, numlines;
// decide where to print
- x = 324;
- y = vid.conheight - sb_lines;
+ x = 0;
+ // AK Nex wants its scores on the upper left
+ if(gamemode == GAME_NEXUIZ)
+ y = 0;
+ else
+ y = vid.conheight - sb_lines;
+
numlines = (vid.conheight - y) / 8;
// give up if there isn't room
if (x + (6 + 15) * 8 > vid.conwidth || numlines < 1)