mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
first use of client side QuakeC :) (and having more than one progs instance
seems to work, too). The menu code gets loaded, but is currently otherwise unused as of yet.
This commit is contained in:
parent
bff69d1cb2
commit
bb96a5b736
13 changed files with 244 additions and 10 deletions
|
@ -78,6 +78,7 @@ typedef struct {
|
|||
|
||||
extern int con_linewidth;
|
||||
extern struct plugin_s *con_module;
|
||||
extern struct console_data_s con_data;
|
||||
|
||||
//extern int con_totallines;
|
||||
//extern qboolean con_initialized;
|
||||
|
@ -120,6 +121,7 @@ void Con_Shutdown (void);
|
|||
void Con_ProcessInput (void);
|
||||
void Con_KeyEvent (knum_t key, short unicode, qboolean down);
|
||||
void Con_SetOrMask (int mask);
|
||||
void Con_NewMap (void);
|
||||
|
||||
void Con_Maplist_f (void);
|
||||
void Con_Skinlist_f (void);
|
||||
|
@ -127,4 +129,7 @@ void Con_Skyboxlist_f (void);
|
|||
void Con_Demolist_QWD_f (void);
|
||||
void Con_Demolist_DEM_f (void);
|
||||
|
||||
void Menu_Init (void);
|
||||
void Menu_Load (void);
|
||||
|
||||
#endif // __console_h
|
||||
|
|
|
@ -40,6 +40,7 @@ typedef void (QFPLUGIN *P_C_ProcessInput) (void);
|
|||
typedef void (QFPLUGIN *P_C_KeyEvent) (key_t key, short unicode, qboolean down);
|
||||
typedef void (QFPLUGIN *P_C_DrawConsole) (int lines);
|
||||
typedef void (QFPLUGIN *P_C_CheckResize) (void);
|
||||
typedef void (QFPLUGIN *P_C_NewMap) (void);
|
||||
|
||||
typedef struct console_func_s {
|
||||
P_C_Print pC_Print;
|
||||
|
@ -47,6 +48,7 @@ typedef struct console_func_s {
|
|||
P_C_KeyEvent pC_KeyEvent;
|
||||
P_C_DrawConsole pC_DrawConsole;
|
||||
P_C_CheckResize pC_CheckResize;
|
||||
P_C_NewMap pC_NewMap;
|
||||
} console_funcs_t;
|
||||
|
||||
typedef struct console_data_s {
|
||||
|
|
|
@ -167,7 +167,7 @@ pr_type_t *GetEdictFieldValue(progs_t *pr, edict_t *ed, const char *field);
|
|||
|
||||
void PR_AddBuiltin (progs_t *pr, const char *name, builtin_proc builtin, int num);
|
||||
builtin_t *PR_FindBuiltin (progs_t *pr, const char *name);
|
||||
void PR_RelocateBuiltins (progs_t *pr);
|
||||
int PR_RelocateBuiltins (progs_t *pr);
|
||||
|
||||
//
|
||||
// PR Strings stuff
|
||||
|
|
|
@ -8,7 +8,7 @@ noinst_LTLIBRARIES= @SERVER_PLUGIN_STATIC@ @CLIENT_PLUGIN_STATIC@
|
|||
EXTRA_LTLIBRARIES= libconsole_server.la libconsole_client.la
|
||||
|
||||
common_sources= buffer.c complete.c console.c inputline.c list.c filelist.c
|
||||
client_sources= client.c
|
||||
client_sources= client.c menu.c
|
||||
server_sources= server.c
|
||||
|
||||
libQFconsole_la_LDFLAGS= $(plugin_LDFLAGS) -version-info 1:0:0
|
||||
|
|
|
@ -57,8 +57,7 @@ static const char rcsid[] =
|
|||
#include "compat.h"
|
||||
|
||||
static general_data_t plugin_info_general_data;
|
||||
static console_data_t plugin_info_console_data;
|
||||
#define con_data plugin_info_console_data
|
||||
console_data_t con_data;
|
||||
|
||||
static old_console_t con_main;
|
||||
static old_console_t con_chat;
|
||||
|
@ -298,6 +297,8 @@ C_SayTeam (const char *line)
|
|||
static void
|
||||
C_Init (void)
|
||||
{
|
||||
Menu_Init ();
|
||||
|
||||
con_notifytime = Cvar_Get ("con_notifytime", "3", CVAR_NONE, NULL,
|
||||
"How long in seconds messages are displayed "
|
||||
"on screen");
|
||||
|
@ -705,6 +706,15 @@ C_ProcessInput (void)
|
|||
{
|
||||
}
|
||||
|
||||
static void
|
||||
C_NewMap (void)
|
||||
{
|
||||
static char old_gamedir[MAX_OSPATH];
|
||||
|
||||
if (!strequal (old_gamedir, com_gamedir))
|
||||
Menu_Load ();
|
||||
}
|
||||
|
||||
static general_funcs_t plugin_info_general_funcs = {
|
||||
C_Init,
|
||||
C_Shutdown,
|
||||
|
@ -716,6 +726,7 @@ static console_funcs_t plugin_info_console_funcs = {
|
|||
C_KeyEvent,
|
||||
C_DrawConsole,
|
||||
C_CheckResize,
|
||||
C_NewMap,
|
||||
};
|
||||
|
||||
static plugin_funcs_t plugin_info_funcs = {
|
||||
|
@ -729,7 +740,7 @@ static plugin_data_t plugin_info_data = {
|
|||
&plugin_info_general_data,
|
||||
0,
|
||||
0,
|
||||
&plugin_info_console_data,
|
||||
&con_data,
|
||||
};
|
||||
|
||||
static plugin_t plugin_info = {
|
||||
|
|
|
@ -156,3 +156,10 @@ Con_CheckResize (void)
|
|||
if (con_module)
|
||||
con_module->functions->console->pC_CheckResize ();
|
||||
}
|
||||
|
||||
void
|
||||
Con_NewMap (void)
|
||||
{
|
||||
if (con_module)
|
||||
con_module->functions->console->pC_NewMap ();
|
||||
}
|
||||
|
|
193
libs/console/menu.c
Normal file
193
libs/console/menu.c
Normal file
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
menu.c
|
||||
|
||||
Menu support code and interface to QC
|
||||
|
||||
Copyright (C) 2001 Bill Currie
|
||||
|
||||
Author: Bill Currie
|
||||
Date: 2002/1/18
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "QF/console.h"
|
||||
#include "QF/plugin.h"
|
||||
#include "QF/progs.h"
|
||||
#include "QF/vfs.h"
|
||||
|
||||
typedef struct menu_pic_s {
|
||||
struct menu_pic_s *next;
|
||||
int x, y;
|
||||
const char *name;
|
||||
} menu_pic_t;
|
||||
|
||||
typedef struct menu_item_s {
|
||||
struct menu_item_s *parent;
|
||||
struct menu_item_s **items;
|
||||
int num_items;
|
||||
int max_items;
|
||||
int x, y;
|
||||
func_t func;
|
||||
func_t cursor;
|
||||
const char *text;
|
||||
menu_pic_t *pics;
|
||||
} menu_item_t;
|
||||
|
||||
static progs_t menu_pr_state;
|
||||
static menu_item_t *menu;
|
||||
|
||||
static void
|
||||
menu_add_item (menu_item_t *m, menu_item_t *i)
|
||||
{
|
||||
if (m->num_items == m->max_items) {
|
||||
m->items = realloc (m->items,
|
||||
(m->max_items + 8) * sizeof (menu_item_t *));
|
||||
m->max_items += 8;
|
||||
}
|
||||
m->items[m->num_items++] = i;
|
||||
}
|
||||
|
||||
static void
|
||||
bi_Menu_Begin (progs_t *pr)
|
||||
{
|
||||
int x = G_INT (pr, OFS_PARM0);
|
||||
int y = G_INT (pr, OFS_PARM1);
|
||||
const char *text = G_STRING (pr, OFS_PARM2);
|
||||
menu_item_t *m = calloc (sizeof (menu_item_t), 1);
|
||||
|
||||
m->x = x;
|
||||
m->y = y;
|
||||
m->text = text;
|
||||
m->parent = menu;
|
||||
menu_add_item (menu, m);
|
||||
menu = m;
|
||||
}
|
||||
|
||||
static void
|
||||
bi_Menu_Pic (progs_t *pr)
|
||||
{
|
||||
int x = G_INT (pr, OFS_PARM0);
|
||||
int y = G_INT (pr, OFS_PARM1);
|
||||
const char *name = G_STRING (pr, OFS_PARM2);
|
||||
menu_pic_t *pic = malloc (sizeof (menu_pic_t));
|
||||
|
||||
pic->x = x;
|
||||
pic->y = y;
|
||||
pic->name = strdup (name);
|
||||
pic->next = menu->pics;
|
||||
menu->pics = pic;
|
||||
}
|
||||
|
||||
static void
|
||||
bi_Menu_CenterPic (progs_t *pr)
|
||||
{
|
||||
int x = G_INT (pr, OFS_PARM0);
|
||||
int y = G_INT (pr, OFS_PARM1);
|
||||
const char *name = G_STRING (pr, OFS_PARM2);
|
||||
menu_pic_t *pic = malloc (sizeof (menu_pic_t));
|
||||
|
||||
pic->x = x;
|
||||
pic->y = y;
|
||||
pic->name = strdup (name);
|
||||
pic->next = menu->pics;
|
||||
menu->pics = pic;
|
||||
}
|
||||
|
||||
static void
|
||||
bi_Menu_Item (progs_t *pr)
|
||||
{
|
||||
int x = G_INT (pr, OFS_PARM0);
|
||||
int y = G_INT (pr, OFS_PARM1);
|
||||
const char *text = G_STRING (pr, OFS_PARM2);
|
||||
func_t func = G_FUNCTION (pr, OFS_PARM3);
|
||||
menu_item_t *mi = calloc (sizeof (menu_item_t), 1);
|
||||
|
||||
mi->x = x;
|
||||
mi->y = y;
|
||||
mi->text = text;
|
||||
mi->func = func;
|
||||
mi->parent = menu;
|
||||
menu_add_item (menu, mi);
|
||||
}
|
||||
|
||||
static void
|
||||
bi_Menu_Cursor (progs_t *pr)
|
||||
{
|
||||
func_t func = G_FUNCTION (pr, OFS_PARM3);
|
||||
menu->cursor = func;
|
||||
}
|
||||
|
||||
static void
|
||||
bi_Menu_End (progs_t *pr)
|
||||
{
|
||||
menu = menu->parent;
|
||||
}
|
||||
|
||||
void
|
||||
Menu_Init (void)
|
||||
{
|
||||
menu_pr_state.progs_name = "menu.dat";
|
||||
|
||||
PR_AddBuiltin (&menu_pr_state, "Menu_Begin", bi_Menu_Begin, -1);
|
||||
PR_AddBuiltin (&menu_pr_state, "Menu_Pic", bi_Menu_Pic, -1);
|
||||
PR_AddBuiltin (&menu_pr_state, "Menu_CenterPic", bi_Menu_CenterPic, -1);
|
||||
PR_AddBuiltin (&menu_pr_state, "Menu_Item", bi_Menu_Item, -1);
|
||||
PR_AddBuiltin (&menu_pr_state, "Menu_Cursor", bi_Menu_Cursor, -1);
|
||||
PR_AddBuiltin (&menu_pr_state, "Menu_End", bi_Menu_End, -1);
|
||||
}
|
||||
|
||||
void
|
||||
Menu_Load (void)
|
||||
{
|
||||
int size;
|
||||
VFile *file;
|
||||
|
||||
menu_pr_state.time = con_data.realtime;
|
||||
|
||||
if (menu_pr_state.progs) {
|
||||
free (menu_pr_state.progs);
|
||||
menu_pr_state.progs = 0;
|
||||
}
|
||||
|
||||
if ((size = COM_FOpenFile ("menu.dat", &file)) != -1) {
|
||||
menu_pr_state.progs = malloc (size + 256 * 1024);
|
||||
Qread (file, menu_pr_state.progs, size);
|
||||
Qclose (file);
|
||||
memset ((char *)menu_pr_state.progs + size, 0, 256 * 1024);
|
||||
PR_LoadProgs (&menu_pr_state, 0);
|
||||
if (!PR_RelocateBuiltins (&menu_pr_state)) {
|
||||
free (menu_pr_state.progs);
|
||||
menu_pr_state.progs = 0;
|
||||
}
|
||||
}
|
||||
if (!menu_pr_state.progs) {
|
||||
// Not a fatal error, just means no menus
|
||||
Con_SetOrMask (0x80);
|
||||
Con_Printf ("Menu_Load: could not load menu.dat\n");
|
||||
Con_SetOrMask (0x00);
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -437,6 +437,7 @@ static console_funcs_t plugin_info_console_funcs = {
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
static console_data_t plugin_info_console_data;
|
||||
|
||||
|
|
|
@ -1075,7 +1075,7 @@ PR_LoadProgsFile (progs_t * pr, const char *progsname)
|
|||
if (progsname)
|
||||
pr->progs = (dprograms_t *) COM_LoadHunkFile (progsname);
|
||||
else
|
||||
progsname = "(preloaded)";
|
||||
progsname = pr->progs_name;
|
||||
if (!pr->progs)
|
||||
return;
|
||||
|
||||
|
@ -1373,7 +1373,7 @@ PR_AccessField (progs_t *pr, const char *name, etype_t type,
|
|||
return def->ofs;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
PR_RelocateBuiltins (progs_t *pr)
|
||||
{
|
||||
int i;
|
||||
|
@ -1387,8 +1387,12 @@ PR_RelocateBuiltins (progs_t *pr)
|
|||
continue;
|
||||
bi_name = PR_GetString (pr, func->s_name);
|
||||
bi = PR_FindBuiltin (pr, bi_name);
|
||||
if (!bi)
|
||||
PR_Error (pr, "undefined builtin %s", bi_name);
|
||||
if (!bi) {
|
||||
Sys_Printf ("PR_RelocateBuiltins: %s: undefined builtin %s\n",
|
||||
pr->progs_name, bi_name);
|
||||
return 0;
|
||||
}
|
||||
func->first_statement = -(bi - pr->builtins);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -311,6 +311,7 @@ CL_ParseServerInfo (void)
|
|||
cl_entities[0].model = cl.worldmodel = cl.model_precache[1];
|
||||
|
||||
R_NewMap (cl.worldmodel, cl.model_precache, MAX_MODELS);
|
||||
Con_NewMap ();
|
||||
|
||||
Hunk_Check (); // make sure nothing is hurt
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ static const char rcsid[] =
|
|||
#include "QF/keys.h"
|
||||
#include "QF/msg.h"
|
||||
#include "QF/plugin.h"
|
||||
#include "QF/progs.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/screen.h"
|
||||
#include "QF/sys.h"
|
||||
|
@ -934,6 +935,8 @@ Host_Init (quakeparms_t *parms)
|
|||
Cmd_StuffCmds_f ();
|
||||
Cbuf_Execute_Sets ();
|
||||
|
||||
PR_Init ();
|
||||
|
||||
V_Init ();
|
||||
COM_Filesystem_Init ();
|
||||
Game_Init ();
|
||||
|
@ -960,7 +963,6 @@ Host_Init (quakeparms_t *parms)
|
|||
Mod_Init ();
|
||||
// FIXME: MENUCODE
|
||||
// M_Init ();
|
||||
PR_Init ();
|
||||
SV_Progs_Init ();
|
||||
SV_Init ();
|
||||
|
||||
|
@ -1005,6 +1007,7 @@ Host_Init (quakeparms_t *parms)
|
|||
host_initialized = true;
|
||||
|
||||
Con_Printf ("\x80\x81\x81\x81\x81\x81\x81\x81%s Initialized\x81\x81\x81\x81\x81\x81\x81\x81\x82\n", PROGRAM);
|
||||
Con_NewMap ();
|
||||
|
||||
CL_UpdateScreen (cl.time);
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ static const char rcsid[] =
|
|||
#include "QF/model.h"
|
||||
#include "QF/msg.h"
|
||||
#include "QF/plugin.h"
|
||||
#include "QF/progs.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/qendian.h"
|
||||
#include "QF/screen.h"
|
||||
|
@ -1658,6 +1659,7 @@ Host_Init (void)
|
|||
Key_Init_Cvars ();
|
||||
Mod_Init_Cvars ();
|
||||
Netchan_Init_Cvars ();
|
||||
PR_Init_Cvars ();
|
||||
Pmove_Init_Cvars ();
|
||||
R_Init_Cvars ();
|
||||
R_Particles_Init_Cvars ();
|
||||
|
@ -1666,6 +1668,8 @@ Host_Init (void)
|
|||
V_Init_Cvars ();
|
||||
VID_Init_Cvars ();
|
||||
|
||||
PR_Init ();
|
||||
|
||||
cl_Cmd_Init ();
|
||||
V_Init ();
|
||||
COM_Filesystem_Init ();
|
||||
|
@ -1746,6 +1750,8 @@ Host_Init (void)
|
|||
|
||||
Con_Printf ("\x80\x81\x81\x82 %s initialized \x80\x81\x81\x82\n", PROGRAM);
|
||||
|
||||
Con_NewMap (); // force the menus to be loaded
|
||||
|
||||
CL_UpdateScreen (realtime);
|
||||
}
|
||||
|
||||
|
|
|
@ -321,6 +321,7 @@ Model_NextDownload (void)
|
|||
|
||||
R_NewMap (cl.worldmodel, cl.model_precache, MAX_MODELS);
|
||||
Team_NewMap ();
|
||||
Con_NewMap ();
|
||||
Hunk_Check (); // make sure nothing is hurt
|
||||
|
||||
// done with modellist, request first of static signon messages
|
||||
|
|
Loading…
Reference in a new issue