mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 12:52:46 +00:00
the draw api now uses a `real' qpic_t rather than loading the pic every time
This commit is contained in:
parent
c71ce480ad
commit
15e17acc1c
8 changed files with 83 additions and 55 deletions
|
@ -11,7 +11,7 @@ QCPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include
|
|||
|
||||
pkgdata_DATA= menu.dat
|
||||
|
||||
menu_src= menu.qc servlist.qc options.qc cbuf_def.qc cvar_def.qc draw_def.qc file_def.qc game_def.qc inputline_def.qc inputline_util.qc key_defs.qc menu_def.qc options_util.qc string_def.qc controls_o.qc stringh_def.qc
|
||||
menu_src= menu.qc menu_pics.qc servlist.qc options.qc cbuf_def.qc cvar_def.qc draw_def.qc file_def.qc game_def.qc inputline_def.qc inputline_util.qc key_defs.qc menu_def.qc options_util.qc string_def.qc controls_o.qc stringh_def.qc
|
||||
|
||||
menu.dat: menu.src $(menu_src)
|
||||
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -P $<
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
void (integer x, integer y, string name) Draw_Pic = #0;
|
||||
void (integer x, integer y, string name) Draw_CenterPic = #0;
|
||||
struct _qpic_t = {
|
||||
integer width;
|
||||
integer height;
|
||||
};
|
||||
typedef _qpic_t [] qpic_t;
|
||||
|
||||
qpic_t (string name, integer alpha) Draw_CachePic = #0;
|
||||
|
||||
void (integer x, integer y, qpic_t pic) Draw_Pic = #0;
|
||||
void (integer x, integer y, qpic_t pic) Draw_CenterPic = #0;
|
||||
|
||||
void (integer x, integer y, integer chr) Draw_Character = #0;
|
||||
void (integer x, integer y, string text) Draw_String = #0;
|
||||
void (integer x, integer y, string text, integer n) Draw_nString = #0;
|
||||
|
|
|
@ -92,7 +92,7 @@ integer () load_draw =
|
|||
{
|
||||
local integer i;
|
||||
|
||||
Draw_CenterPic (160, 4, "gfx/p_load.lmp");
|
||||
Draw_CenterPic (160, 4, p_load_pic);
|
||||
for (i=0 ; i< MAX_SAVEGAMES; i++)
|
||||
Draw_String (16, 32 + 8 * i, filenames[i]);
|
||||
Draw_Character (8, 32 + load_cursor * 8, 12 + (integer (time * 4) & 1));
|
||||
|
@ -103,7 +103,7 @@ integer () save_draw =
|
|||
{
|
||||
local integer i;
|
||||
|
||||
Draw_CenterPic (160, 4, "gfx/p_save.lmp");
|
||||
Draw_CenterPic (160, 4, p_save_pic);
|
||||
for (i=0 ; i< MAX_SAVEGAMES; i++)
|
||||
Draw_String (16, 32 + 8 * i, filenames[i]);
|
||||
Draw_Character (8, 32 + save_cursor * 8, 12 + (integer (time * 4) & 1));
|
||||
|
@ -429,6 +429,8 @@ void () main_menu =
|
|||
|
||||
void () menu_init =
|
||||
{
|
||||
load_menu_pics ();
|
||||
|
||||
lanConfig_port_il = InputLine_Create (4, 8, ' ');
|
||||
InputLine_SetWidth (lanConfig_port_il, 10);
|
||||
lanConfig_join_il = InputLine_Create (4, 24, ' ');
|
||||
|
|
|
@ -11,6 +11,8 @@ menu.dat
|
|||
@srcdir@/string_def.qc
|
||||
@srcdir@/stringh_def.qc
|
||||
|
||||
@srcdir@/menu_pics.qc
|
||||
|
||||
@srcdir@/inputline_util.qc
|
||||
@srcdir@/menu_util.qc
|
||||
@srcdir@/options_util.qc
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
float time;
|
||||
|
||||
string [6] dot = {
|
||||
"gfx/menudot1.lmp",
|
||||
"gfx/menudot2.lmp",
|
||||
"gfx/menudot3.lmp",
|
||||
"gfx/menudot4.lmp",
|
||||
"gfx/menudot5.lmp",
|
||||
"gfx/menudot6.lmp",
|
||||
};
|
||||
|
||||
void (integer x, integer y) spinner =
|
||||
{
|
||||
Draw_Pic (x, y, dot[integer(time * 10) % 6]);
|
||||
|
@ -17,38 +8,38 @@ void (integer x, integer y) spinner =
|
|||
void (integer x, integer y, integer width, integer lines) text_box =
|
||||
{
|
||||
local integer cx, cy, n;
|
||||
local string p;
|
||||
local qpic_t p;
|
||||
|
||||
cx = x;
|
||||
cy = y;
|
||||
Draw_Pic (cx, cy, "gfx/box_tl.lmp");
|
||||
Draw_Pic (cx, cy, box_tl_pic);
|
||||
for (n = 0; n < lines; n++) {
|
||||
cy += 8;
|
||||
Draw_Pic (cx, cy, "gfx/box_ml.lmp");
|
||||
Draw_Pic (cx, cy, box_ml_pic);
|
||||
}
|
||||
Draw_Pic (cx, cy + 8, "gfx/box_bl.lmp");
|
||||
Draw_Pic (cx, cy + 8, box_bl_pic);
|
||||
|
||||
cx += 8;
|
||||
while (width > 0) {
|
||||
cy = y;
|
||||
Draw_Pic (cx, cy, "gfx/box_tm.lmp");
|
||||
p = "gfx/box_mm.lmp";
|
||||
Draw_Pic (cx, cy, box_tm_pic);
|
||||
p = box_mm_pic;
|
||||
for (n = 0; n < lines; n++) {
|
||||
cy += 8;
|
||||
if (n == 1)
|
||||
p = "gfx/box_mm2.lmp";
|
||||
p = box_mm2_pic;
|
||||
Draw_Pic (cx, cy, p);
|
||||
}
|
||||
Draw_Pic (cx, cy + 8, "gfx/box_bm.lmp");
|
||||
Draw_Pic (cx, cy + 8, box_bm_pic);
|
||||
width -= 2;
|
||||
cx += 16;
|
||||
}
|
||||
|
||||
cy = y;
|
||||
Draw_Pic (cx, cy, "gfx/box_tr.lmp");
|
||||
Draw_Pic (cx, cy, box_tr_pic);
|
||||
for (n = 0; n < lines; n++) {
|
||||
cy += 8;
|
||||
Draw_Pic (cx, cy, "gfx/box_mr.lmp");
|
||||
Draw_Pic (cx, cy, box_mr_pic);
|
||||
}
|
||||
Draw_Pic (cx, cy + 8, "gfx/box_br.lmp");
|
||||
Draw_Pic (cx, cy + 8, box_br_pic);
|
||||
};
|
||||
|
|
|
@ -116,8 +116,8 @@ DRAW_video_options =
|
|||
local integer spacing = 120;
|
||||
local integer bar_pad;
|
||||
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||
Draw_Pic (16, 4, qplaque_pic);
|
||||
Draw_CenterPic (160, 4, p_option_pic);
|
||||
Draw_String (54, 40, "Video");
|
||||
Draw_String (54, 50, "-----");
|
||||
draw_val_item (70, 60, spacing, "Fullscreen",
|
||||
|
@ -206,8 +206,8 @@ DRAW_audio_options =
|
|||
local integer spacing = 120;
|
||||
local integer bar_pad;
|
||||
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||
Draw_Pic (16, 4, qplaque_pic);
|
||||
Draw_CenterPic (160, 4, p_option_pic);
|
||||
Draw_String (54, 40, "Audio");
|
||||
Draw_String (54, 50, "-----");
|
||||
bar_pad = 50;
|
||||
|
@ -315,8 +315,8 @@ DRAW_control_options =
|
|||
{
|
||||
local integer cursor_pad = 0, spacing = 120, bar_pad;
|
||||
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160, 4, "gfx/p_option.lmp");
|
||||
Draw_Pic (16, 4, qplaque_pic);
|
||||
Draw_CenterPic (160, 4, p_option_pic);
|
||||
Draw_String (54, 40, "Controls");
|
||||
Draw_String (54, 50, "--------");
|
||||
Draw_String (70, 60, "Bindings");
|
||||
|
@ -400,8 +400,8 @@ DRAW_feature_options =
|
|||
{
|
||||
local integer cursor_pad = 0, spacing = 120;
|
||||
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160,4, "gfx/p_option.lmp");
|
||||
Draw_Pic (16, 4, qplaque_pic);
|
||||
Draw_CenterPic (160,4, p_option_pic);
|
||||
Draw_String (54, 40, "Features");
|
||||
Draw_String (54, 50, "--------");
|
||||
|
||||
|
@ -545,8 +545,8 @@ DRAW_player_options =
|
|||
{
|
||||
local integer cursor_pad = 0, spacing = 120;
|
||||
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160,4, "gfx/p_option.lmp");
|
||||
Draw_Pic (16, 4, qplaque_pic);
|
||||
Draw_CenterPic (160,4, p_option_pic);
|
||||
Draw_String (54, 40, "Player");
|
||||
Draw_String (54, 50, "--------");
|
||||
|
||||
|
@ -710,8 +710,8 @@ DRAW_network_options =
|
|||
{
|
||||
local integer cursor_pad = 0, spacing = 120;
|
||||
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160,4, "gfx/p_option.lmp");
|
||||
Draw_Pic (16, 4, qplaque_pic);
|
||||
Draw_CenterPic (160,4, p_option_pic);
|
||||
Draw_String (54, 40, "Network");
|
||||
Draw_String (54, 50, "--------");
|
||||
|
||||
|
|
|
@ -2,16 +2,16 @@ void (integer x, integer y, integer width, integer lines) text_box;
|
|||
|
||||
integer () servlist_favorates_draw =
|
||||
{
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160, 4, "gfx/p_multi.lmp");
|
||||
Draw_Pic (16, 4, qplaque_pic);
|
||||
Draw_CenterPic (160, 4, p_multi_pic);
|
||||
Draw_String (54, 40, "Under Construction");
|
||||
return 1;
|
||||
};
|
||||
|
||||
integer () servlist_all_draw =
|
||||
{
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160, 4, "gfx/p_multi.lmp");
|
||||
Draw_Pic (16, 4, qplaque_pic);
|
||||
Draw_CenterPic (160, 4, p_multi_pic);
|
||||
Draw_String (54, 40, "Under Construction");
|
||||
return 1;
|
||||
};
|
||||
|
@ -24,8 +24,8 @@ inputline_t input_active;
|
|||
|
||||
integer () servlist_filter_draw =
|
||||
{
|
||||
Draw_Pic (16, 4, "gfx/qplaque.lmp");
|
||||
Draw_CenterPic (160, 4, "gfx/p_multi.lmp");
|
||||
Draw_Pic (16, 4, qplaque_pic);
|
||||
Draw_CenterPic (160, 4, p_multi_pic);
|
||||
Draw_String (62, 40, "Max Ping........:");
|
||||
text_box (206, 32, 4, 1);
|
||||
InputLine_Draw (serv_maxping, 206, 40, 1);
|
||||
|
|
|
@ -36,18 +36,46 @@ static const char rcsid[] =
|
|||
#include "QF/progs.h"
|
||||
#include "QF/render.h"
|
||||
|
||||
static qpic_t *
|
||||
get_qpic (progs_t *pr, int arg, const char *func)
|
||||
{
|
||||
qpic_t *pic;
|
||||
|
||||
if (arg <= ((pr_type_t *) pr->zone - pr->pr_globals)
|
||||
|| arg >= (pr->zone_size / sizeof (pr_type_t)))
|
||||
PR_RunError (pr, "%s: Invalid qpic_t", func);
|
||||
|
||||
memcpy (&pic, ((qpic_t *)(pr->pr_globals + arg))->data, sizeof (qpic_t *));
|
||||
return pic;
|
||||
}
|
||||
|
||||
static void
|
||||
bi_Draw_CachePic (progs_t *pr)
|
||||
{
|
||||
const char *path = G_STRING (pr, OFS_PARM0);
|
||||
int alpha = G_INT (pr, OFS_PARM1);
|
||||
qpic_t *pic = Draw_CachePic (path, alpha);
|
||||
qpic_t *qpic;
|
||||
|
||||
if (!pic) {
|
||||
Con_DPrintf ("can't load %s\n", path);
|
||||
G_INT (pr, OFS_RETURN) = 0;
|
||||
return;
|
||||
}
|
||||
qpic = PR_Zone_Malloc (pr, sizeof (qpic_t) - 4 + sizeof (qpic_t *));
|
||||
qpic->width = pic->width;
|
||||
qpic->height = pic->height;
|
||||
memcpy (qpic->data, &pic, sizeof (qpic_t *));
|
||||
G_INT (pr, OFS_RETURN) = (pr_type_t *)qpic - pr->pr_globals;
|
||||
}
|
||||
|
||||
static void
|
||||
bi_Draw_Pic (progs_t *pr)
|
||||
{
|
||||
int x = G_INT (pr, OFS_PARM0);
|
||||
int y = G_INT (pr, OFS_PARM1);
|
||||
const char *path = G_STRING (pr, OFS_PARM2);
|
||||
qpic_t *pic = Draw_CachePic (path, 1);
|
||||
qpic_t *pic = get_qpic (pr, G_INT (pr, OFS_PARM2), "Draw_Pic");
|
||||
|
||||
if (!pic) {
|
||||
Con_DPrintf ("can't load %s\n", path);
|
||||
return;
|
||||
}
|
||||
Draw_Pic (x, y, pic);
|
||||
}
|
||||
|
||||
|
@ -56,13 +84,8 @@ bi_Draw_CenterPic (progs_t *pr)
|
|||
{
|
||||
int x = G_INT (pr, OFS_PARM0);
|
||||
int y = G_INT (pr, OFS_PARM1);
|
||||
const char *path = G_STRING (pr, OFS_PARM2);
|
||||
qpic_t *pic = Draw_CachePic (path, 1);
|
||||
qpic_t *pic = get_qpic (pr, G_INT (pr, OFS_PARM2), "Draw_CenterPic");
|
||||
|
||||
if (!pic) {
|
||||
Con_DPrintf ("can't load %s\n", path);
|
||||
return;
|
||||
}
|
||||
Draw_Pic (x - pic->width / 2, y, pic);
|
||||
}
|
||||
|
||||
|
@ -128,6 +151,7 @@ bi_Draw_Fill (progs_t *pr)
|
|||
void
|
||||
R_Progs_Init (progs_t *pr)
|
||||
{
|
||||
PR_AddBuiltin (pr, "Draw_CachePic", bi_Draw_CachePic, -1);
|
||||
PR_AddBuiltin (pr, "Draw_Pic", bi_Draw_Pic, -1);
|
||||
PR_AddBuiltin (pr, "Draw_CenterPic", bi_Draw_CenterPic, -1);
|
||||
PR_AddBuiltin (pr, "Draw_Character", bi_Draw_Character, -1);
|
||||
|
|
Loading…
Reference in a new issue