new view stuff mostly working. just a few visual bugs to iron out

This commit is contained in:
Bill Currie 2003-05-06 02:19:13 +00:00
parent 1bdcd879be
commit 508fb4fb5c
14 changed files with 476 additions and 349 deletions

View file

@ -132,9 +132,10 @@ void Con_Demolist_DEM_f (void);
// in general :P)
void C_DrawInputLine (inputline_t *il);
struct view_s;
void Menu_Init (void);
void Menu_Load (void);
void Menu_Draw (void);
void Menu_Draw (struct view_s *view);
void Menu_KeyEvent (knum_t key, short unicode, qboolean down);
void Menu_Enter (void);
void Menu_Leave (void);

View file

@ -59,6 +59,7 @@ typedef struct console_data_s {
int ormask;
void (*quit)(void);
struct cbuf_s *cbuf;
struct view_s *view;
} console_data_t;
#endif // __QF_plugin_console_h_

View file

@ -57,6 +57,8 @@ struct view_s {
int max_children;
void (*draw)(view_t *view);
unsigned enabled:1;
unsigned resize_x:1;
unsigned resize_y:1;
};
@ -65,5 +67,7 @@ void view_add (view_t *par, view_t *view);
void view_remove (view_t *par, view_t *view);
void view_delete (view_t *view);
void view_draw (view_t *view);
void view_resize (view_t *view, int xl, int yl);
void view_move (view_t *view, int xp, int yp);
#endif//__qf_view_h

View file

@ -47,6 +47,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/cvar.h"
#include "QF/draw.h"
#include "QF/dstring.h"
#include "QF/gib.h"
#include "QF/input.h"
#include "QF/keys.h"
#include "QF/plugin.h"
@ -56,13 +57,14 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/vid.h"
#include "QF/gib.h"
#include "QF/view.h"
#include "compat.h"
// XXX check InputLine.h in ruamoko/include
typedef struct {
int x, y;
int xbase, ybase;
int cursor;
} il_data_t;
@ -83,8 +85,6 @@ static float con_times[NUM_CON_TIMES]; // realtime time the line was generated
// for transparent notify lines
static int con_totallines; // total lines in console scrollback
static int con_vislines;
static int con_notifylines; // scan lines to clear for notify lines
static qboolean con_debuglog;
static qboolean chat_team;
@ -94,6 +94,11 @@ static inputline_t *input_line;
static inputline_t *say_line;
static inputline_t *say_team_line;
static view_t *console_view;
static view_t *say_view;
static view_t *notify_view;
static view_t *menu_view;
static qboolean con_initialized;
@ -219,6 +224,8 @@ Resize (old_console_t *con)
con->current = con_totallines - 1;
con->display = con->current;
view_resize (con_data.view, vid.width, vid.height);
}
/*
@ -351,73 +358,6 @@ C_GIB_Print_Center_f (void)
SCR_CenterPrint (GIB_Argv(1));
}
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");
cl_chatmode = Cvar_Get ("cl_chatmode", "2", CVAR_NONE, NULL,
"Controls when console text will be treated as a "
"chat message: 0 - never, 1 - always, 2 - smart");
con_debuglog = COM_CheckParm ("-condebug");
con = &con_main;
con_linewidth = -1;
input_line = Con_CreateInputLine (32, MAXCMDLINE, ']');
input_line->complete = Con_BasicCompleteCommandLine;
input_line->enter = C_ExecLine;
input_line->width = con_linewidth;
input_line->user_data = 0;
input_line->draw = 0;
say_line = Con_CreateInputLine (32, MAXCMDLINE, ' ');
say_line->complete = 0;
say_line->enter = C_Say;
say_line->width = con_linewidth - 5;
say_line->user_data = 0;
say_line->draw = 0;
say_team_line = Con_CreateInputLine (32, MAXCMDLINE, ' ');
say_team_line->complete = 0;
say_team_line->enter = C_SayTeam;
say_team_line->width = con_linewidth - 10;
say_team_line->user_data = 0;
say_team_line->draw = 0;
C_CheckResize ();
Con_Printf ("Console initialized.\n");
// register our commands
Cmd_AddCommand ("toggleconsole", ToggleConsole_f,
"Toggle the console up and down");
Cmd_AddCommand ("togglechat", ToggleChat_f,
"Toggle the console up and down");
Cmd_AddCommand ("messagemode", MessageMode_f,
"Prompt to send a message to everyone");
Cmd_AddCommand ("messagemode2", MessageMode2_f,
"Prompt to send a message to only people on your team");
Cmd_AddCommand ("clear", Clear_f, "Clear the console");
Cmd_AddCommand ("condump", Condump_f, "dump the console text to a "
"file");
// register GIB builtins
GIB_Builtin_Add ("print::center", C_GIB_Print_Center_f);
con_initialized = true;
}
static void
C_Shutdown (void)
{
}
static void
Linefeed (void)
{
@ -627,120 +567,21 @@ void
C_DrawInputLine (inputline_t *il)
{
il_data_t *data = il->user_data;
DrawInputLine (data->x, data->y, data->cursor, il);
DrawInputLine (data->xbase + data->x, data->xbase + data->y, data->cursor,
il);
}
static void
DrawInput (void)
draw_input (view_t *view)
{
if (key_dest != key_console)// && !con_data.force_commandline)
return; // don't draw anything (always draw if not active)
DrawInputLine (8, con_vislines - 22, 1, input_line);
}
/*
DrawNotify
Draws the last few lines of output transparently over the game top
*/
static void
DrawNotify (void)
{
int i, v;
char *text;
float time;
v = 0;
for (i = con->current - NUM_CON_TIMES + 1; i <= con->current; i++) {
if (i < 0)
continue;
time = con_times[i % NUM_CON_TIMES];
if (time == 0)
continue;
time = *con_data.realtime - time;
if (time > con_notifytime->value)
continue;
text = con->text + (i % con_totallines) * con_linewidth;
clearnotify = 0;
scr_copytop = 1;
Draw_nString (8, v, text, con_linewidth);
v += 8;
}
if (key_dest == key_message) {
clearnotify = 0;
scr_copytop = 1;
if (chat_team) {
Draw_String (8, v, "say_team:");
DrawInputLine (80, v, 1, say_team_line);
} else {
Draw_String (8, v, "say:");
DrawInputLine (40, v, 1, say_line);
}
v += 8;
}
if (v > con_notifylines)
con_notifylines = v;
}
/*
DrawConsole
Draws the console with the solid background
*/
static void
DrawConsole (int lines)
{
char *text;
int row, rows, i, x, y;
if (lines <= 0)
return;
// draw the background
Draw_ConsoleBackground (lines);
// draw the text
con_vislines = lines;
// changed to line things up better
rows = (lines - 22) >> 3; // rows of text to draw
y = lines - 30;
// draw from the bottom up
if (con->display != con->current) {
// draw arrows to show the buffer is backscrolled
for (x = 0; x < con_linewidth; x += 4)
Draw_Character ((x + 1) << 3, y, '^');
y -= 8;
rows--;
}
row = con->display;
for (i = 0; i < rows; i++, y -= 8, row--) {
if (row < 0)
break;
if (con->current - row >= con_totallines)
break; // past scrollback wrap point
text = con->text + (row % con_totallines) * con_linewidth;
Draw_nString(8, y, text, con_linewidth);
}
// draw the input prompt, user text, and cursor if desired
DrawInput ();
DrawInputLine (view->xabs + 8, view->yabs, 1, input_line);
}
static void
DrawDownload (int lines)
draw_download (view_t *view)
{
char dlbar[1024];
const char *text;
@ -781,23 +622,107 @@ DrawDownload (int lines)
" %02d%%", *con_data.dl_percent);
// draw it
y = lines - 22 + 8;
for (i = 0; i < strlen (dlbar); i++)
Draw_Character ((i + 1) << 3, y, dlbar[i]);
Draw_String (view->xabs, view->yabs, dlbar);
}
static void
draw_console_text (view_t *view)
{
char *text;
int row, rows, i, x, y;
rows = view->ylen >> 3; // rows of text to draw
x = view->xabs + 8;
y = view->yabs + view->ylen - 8;
// draw from the bottom up
if (con->display != con->current) {
// draw arrows to show the buffer is backscrolled
for (i = 0; i < con_linewidth; i += 4)
Draw_Character (x + (i << 3), y, '^');
y -= 8;
rows--;
}
row = con->display;
for (i = 0; i < rows; i++, y -= 8, row--) {
if (row < 0)
break;
if (con->current - row >= con_totallines)
break; // past scrollback wrap point
text = con->text + (row % con_totallines) * con_linewidth;
Draw_nString(x, y, text, con_linewidth);
}
}
static void
draw_console (view_t *view)
{
// draw the background
Draw_ConsoleBackground (view->ylen);
// draw everything else
view_draw (view);
}
static void
draw_say (view_t *view)
{
if (key_dest == key_message) {
clearnotify = 0;
scr_copytop = 1;
if (chat_team) {
Draw_String (view->xabs + 8, view->yabs, "say_team:");
DrawInputLine (view->xabs + 80, view->yabs, 1, say_team_line);
} else {
Draw_String (view->xabs + 8, view->yabs, "say:");
DrawInputLine (view->xabs + 40, view->yabs, 1, say_line);
}
}
}
static void
draw_notify (view_t *view)
{
int i, x, y;
char *text;
float time;
x = view->xabs + 8;
y = view->yabs;
for (i = con->current - NUM_CON_TIMES + 1; i <= con->current; i++) {
if (i < 0)
continue;
time = con_times[i % NUM_CON_TIMES];
if (time == 0)
continue;
time = *con_data.realtime - time;
if (time > con_notifytime->value)
continue;
text = con->text + (i % con_totallines) * con_linewidth;
clearnotify = 0;
scr_copytop = 1;
Draw_nString (x, y, text, con_linewidth);
y += 8;
}
}
static void
C_DrawConsole (int lines)
{
if (lines) {
DrawConsole (lines);
DrawDownload (lines);
} else {
if (key_dest == key_game || key_dest == key_message)
DrawNotify (); // only draw notify in game
}
if (key_dest == key_menu)
Menu_Draw ();
if (console_view->ylen != lines)
view_resize (console_view, console_view->xlen, lines);
console_view->enabled = lines != 0;
menu_view->enabled = key_dest == key_menu;
view_draw (con_data.view);
}
static void
@ -818,6 +743,116 @@ C_NewMap (void)
strcpy (old_gamedir, qfs_gamedir->gamedir);
}
static void
C_Init (void)
{
view_t *view;
Menu_Init ();
con_notifytime = Cvar_Get ("con_notifytime", "3", CVAR_NONE, NULL,
"How long in seconds messages are displayed "
"on screen");
cl_chatmode = Cvar_Get ("cl_chatmode", "2", CVAR_NONE, NULL,
"Controls when console text will be treated as a "
"chat message: 0 - never, 1 - always, 2 - smart");
con_debuglog = COM_CheckParm ("-condebug");
con_data.view = view_new (0, 0, 320, 200, grav_northeast);
con_data.view->draw = view_draw;
console_view = view_new (0, 0, 320, 200, grav_northwest);
say_view = view_new (0, 0, 320, 32, grav_northwest);
notify_view = view_new (0, 8, 320, 32, grav_northwest);
menu_view = view_new (0, 0, 320, 200, grav_center);
view_add (con_data.view, say_view);
view_add (con_data.view, notify_view);
view_add (con_data.view, console_view);
view_add (con_data.view, menu_view);
console_view->draw = draw_console;
console_view->enabled = 0;
console_view->resize_x = console_view->resize_y = 1;
say_view->draw = draw_say;
say_view->enabled = 0;
say_view->resize_x = 1;
notify_view->draw = draw_notify;
notify_view->resize_x = 1;
menu_view->draw = Menu_Draw;
menu_view->enabled = 0;
view = view_new (0, 0, 320, 170, grav_northwest);
view->draw = draw_console_text;
view->resize_x = view->resize_y = 1;
view_add (console_view, view);
view = view_new (0, 12, 320, 10, grav_southwest);
view->draw = draw_input;
view->resize_x = 1;
view_add (console_view, view);
view = view_new (0, 2, 320, 11, grav_southwest);
view->draw = draw_download;
view->resize_x = 1;
view_add (console_view, view);
con = &con_main;
con_linewidth = -1;
input_line = Con_CreateInputLine (32, MAXCMDLINE, ']');
input_line->complete = Con_BasicCompleteCommandLine;
input_line->enter = C_ExecLine;
input_line->width = con_linewidth;
input_line->user_data = 0;
input_line->draw = 0;
say_line = Con_CreateInputLine (32, MAXCMDLINE, ' ');
say_line->complete = 0;
say_line->enter = C_Say;
say_line->width = con_linewidth - 5;
say_line->user_data = 0;
say_line->draw = 0;
say_team_line = Con_CreateInputLine (32, MAXCMDLINE, ' ');
say_team_line->complete = 0;
say_team_line->enter = C_SayTeam;
say_team_line->width = con_linewidth - 10;
say_team_line->user_data = 0;
say_team_line->draw = 0;
C_CheckResize ();
Con_Printf ("Console initialized.\n");
// register our commands
Cmd_AddCommand ("toggleconsole", ToggleConsole_f,
"Toggle the console up and down");
Cmd_AddCommand ("togglechat", ToggleChat_f,
"Toggle the console up and down");
Cmd_AddCommand ("messagemode", MessageMode_f,
"Prompt to send a message to everyone");
Cmd_AddCommand ("messagemode2", MessageMode2_f,
"Prompt to send a message to only people on your team");
Cmd_AddCommand ("clear", Clear_f, "Clear the console");
Cmd_AddCommand ("condump", Condump_f, "dump the console text to a "
"file");
// register GIB builtins
GIB_Builtin_Add ("print::center", C_GIB_Print_Center_f);
con_initialized = true;
}
static void
C_Shutdown (void)
{
}
static general_funcs_t plugin_info_general_funcs = {
C_Init,
C_Shutdown,

View file

@ -48,6 +48,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/quakefs.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "QF/view.h"
typedef struct menu_pic_s {
struct menu_pic_s *next;
@ -504,21 +505,26 @@ Menu_Load (void)
}
void
Menu_Draw (void)
Menu_Draw (view_t *view)
{
menu_pic_t *m_pic;
int i;
int i, x, y;
menu_item_t *item;
if (!menu)
return;
x = view->xabs;
y = view->yabs;
if (menu->fadescreen)
Draw_FadeScreen ();
*menu_pr_state.globals.time = *menu_pr_state.time;
if (menu->draw) {
P_INT (&menu_pr_state, 0) = x;
P_INT (&menu_pr_state, 1) = y;
PR_ExecuteProgram (&menu_pr_state, menu->draw);
if (R_INT (&menu_pr_state))
return;
@ -530,14 +536,15 @@ Menu_Draw (void)
if (!pic)
continue;
if (m_pic->width > 0 && m_pic->height > 0)
Draw_SubPic (m_pic->x, m_pic->y, pic, m_pic->srcx, m_pic->srcy,
Draw_SubPic (x + m_pic->x, y + m_pic->y, pic,
m_pic->srcx, m_pic->srcy,
m_pic->width, m_pic->height);
else
Draw_Pic (m_pic->x, m_pic->y, pic);
Draw_Pic (x + m_pic->x, y + m_pic->y, pic);
}
for (i = 0; i < menu->num_items; i++) {
if (menu->items[i]->text) {
Draw_String (menu->items[i]->x + 8, menu->items[i]->y,
Draw_String (x + menu->items[i]->x + 8, y + menu->items[i]->y,
menu->items[i]->text);
}
}
@ -545,11 +552,11 @@ Menu_Draw (void)
return;
item = menu->items[menu->cur_item];
if (menu->cursor) {
P_INT (&menu_pr_state, 0) = item->x;
P_INT (&menu_pr_state, 1) = item->y;
P_INT (&menu_pr_state, 0) = x + item->x;
P_INT (&menu_pr_state, 1) = y + item->y;
PR_ExecuteProgram (&menu_pr_state, menu->cursor);
} else {
Draw_Character (item->x, item->y,
Draw_Character (x + item->x, y + item->y,
12 + ((int) (*con_data.realtime * 4) & 1));
}
}

View file

@ -53,12 +53,24 @@ view_new (int xp, int yp, int xl, int yl, grav_t grav)
view->xlen = xl;
view->ylen = yl;
view->gravity = grav;
view->enabled = 1;
return view;
}
void
view_add (view_t *par, view_t *view)
static void
setgeometry (view_t *view)
{
int i;
view_t *par = view->parent;
if (!par) {
view->xabs = view->xrel = view->xpos;
view->yabs = view->yrel = view->ypos;
for (i = 0; i < view->num_children; i++)
setgeometry (view->children[i]);
return;
}
switch (view->gravity) {
case grav_center:
view->xrel = view->xpos + (par->xlen - view->xlen) / 2;
@ -99,6 +111,13 @@ view_add (view_t *par, view_t *view)
}
view->xabs = par->xabs + view->xrel;
view->yabs = par->yabs + view->yrel;
for (i = 0; i < view->num_children; i++)
setgeometry (view->children[i]);
}
void
view_add (view_t *par, view_t *view)
{
view->parent = par;
if (par->num_children == par->max_children) {
par->max_children += 8;
@ -107,7 +126,8 @@ view_add (view_t *par, view_t *view)
memset (par->children + par->num_children, 0,
(par->max_children - par->num_children) * sizeof (view_t *));
}
par->children[par->max_children++] = view;
par->children[par->num_children++] = view;
setgeometry (view);
}
void
@ -146,3 +166,40 @@ view_draw (view_t *view)
v->draw (v);
}
}
void
view_resize (view_t *view, int xl, int yl)
{
int i, xd, yd;
xd = xl - view->xlen;
yd = yl - view->ylen;
view->xlen = xl;
view->ylen = yl;
setgeometry (view);
for (i = 0; i < view->num_children; i++) {
view_t *v = view->children[i];
if (v->resize_x && v->resize_y) {
view_resize (v, v->xlen + xd, v->ylen + yd);
} else if (v->resize_x) {
view_resize (v, v->xlen + xd, v->ylen);
} else if (v->resize_y) {
view_resize (v, v->xlen, v->ylen + yd);
} else {
setgeometry (v);
}
}
}
void
view_move (view_t *view, int xp, int yp)
{
int i;
view->xpos = xp;
view->ypos = yp;
setgeometry (view);
for (i = 0; i < view->num_children; i++)
setgeometry (view->children[i]);
}

View file

@ -132,25 +132,27 @@ void () load_save_f =
Menu_SelectMenu ("save");
};
integer () load_draw =
integer (integer x, integer y) load_draw =
{
local integer i;
Draw_CenterPic (160, 4, Draw_CachePic ("gfx/p_load.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_load.lmp", 1));
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);
Draw_String (x + 16, y + 32 + 8 * i, filenames[i]);
Draw_Character (x + 8, y + 32 + load_cursor * 8,
12 + (integer) (time * 4) & 1);
return 1;
};
integer () save_draw =
integer (integer x, integer y) save_draw =
{
local integer i;
Draw_CenterPic (160, 4, Draw_CachePic ("gfx/p_save.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_save.lmp", 1));
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);
Draw_String (x + 16, y + 32 + 8 * i, filenames[i]);
Draw_Character (x + 8, y + 32 + save_cursor * 8,
12 + (integer) (time * 4) & 1);
return 1;
};
@ -249,13 +251,13 @@ integer (integer key, integer unicode, integer down) quit_keyevent =
return 0;
};
integer () quit_draw =
integer (integer x, integer y) quit_draw =
{
text_box (56, 76, 24, 4);
Draw_String (64, 84, quitMessage[quit_index * 4 + 0]);
Draw_String (64, 92, quitMessage[quit_index * 4 + 1]);
Draw_String (64, 100, quitMessage[quit_index * 4 + 2]);
Draw_String (64, 108, quitMessage[quit_index * 4 + 3]);
text_box (x + 56, y + 76, 24, 4);
Draw_String (x + 64, y + 84, quitMessage[quit_index * 4 + 0]);
Draw_String (x + 64, y + 92, quitMessage[quit_index * 4 + 1]);
Draw_String (x + 64, y + 100, quitMessage[quit_index * 4 + 2]);
Draw_String (x + 64, y + 108, quitMessage[quit_index * 4 + 3]);
return 1;
};
@ -310,37 +312,40 @@ InputLine lanConfig_port_il;
InputLine lanConfig_join_il;
InputLine input_active;
integer () join_draw =
integer (integer x, integer y) join_draw =
{
local integer f = (320 - 26 * 8) / 2;
text_box (f, 134, 24, 4);
Draw_String (f, 142, " Commonly used to play ");
Draw_String (f, 150, " over the Internet, but ");
Draw_String (f, 158, " also used on a Local ");
Draw_String (f, 166, " Area Network. ");
local integer f = x + (320 - 26 * 8) / 2;
text_box (f, y + 134, 24, 4);
Draw_String (f, y + 142, " Commonly used to play ");
Draw_String (f, y + 150, " over the Internet, but ");
Draw_String (f, y + 158, " also used on a Local ");
Draw_String (f, y + 166, " Area Network. ");
return 0;
};
integer () lanconfig_draw =
integer (integer x, integer y) lanconfig_draw =
{
local integer basex = 54;
local integer basex = 54 + x;
local string startJoin = JoiningGame ? "Join Game" : "New Game";
local string protocol = "UDP";
Draw_String (basex, 32, sprintf ("%s - %s", startJoin, protocol));
Draw_String (basex, y + 32, sprintf ("%s - %s", startJoin, protocol));
basex += 8;
Draw_String (basex, 52, "Address:");
Draw_String (basex + 9 * 8, 52, "127.0.0.1");
Draw_String (basex, lanConfig_cursor_table[0], "Port");
text_box (basex + 8 * 8, lanConfig_cursor_table[0] - 8, 6, 1);
Draw_String (basex, y + 52, "Address:");
Draw_String (basex + 9 * 8, y + 52, "127.0.0.1");
Draw_String (basex, y + lanConfig_cursor_table[0], "Port");
text_box (basex + 8 * 8, y + lanConfig_cursor_table[0] - 8, 6, 1);
[lanConfig_port_il setBasePos:x y:y];
[lanConfig_port_il draw:lanConfig_cursor == 0 && input_active];
Draw_String (basex + 9 * 8, lanConfig_cursor_table[0], lanConfig_portname);
Draw_String (basex + 9 * 8, y + lanConfig_cursor_table[0],
lanConfig_portname);
if (JoiningGame) {
Draw_String (basex, lanConfig_cursor_table[1], "Search for local "
"games...");
Draw_String (basex, 108, "Join game at:");
text_box (basex + 8, lanConfig_cursor_table[2] - 8, 22, 1);
[lanConfig_join_il setBasePos:x y:y];
[lanConfig_join_il draw:lanConfig_cursor == 2 && input_active];
Draw_String (basex + 16, lanConfig_cursor_table[2],
lanConfig_joinname);

View file

@ -267,25 +267,25 @@ CB_ME_basic_control_binding =
Draws the menu for the basic control bindins
*/
integer ()
integer (integer x, integer y)
DRAW_basic_control_binding =
{
local integer cursor_pad = 40, bind_desc_pad, hl, i;
bind_desc_pad = 120;
Draw_String (20, 10, "Backspace/Delete: Del binding");
Draw_String (20, 20, "Enter: New binding");
Draw_String (x + 20, y + 10, "Backspace/Delete: Del binding");
Draw_String (x + 20, y + 20, "Enter: New binding");
hl = [movement_bindings count];
for(i = 0; i < hl; i++) {
local binding_t [] binding = [movement_bindings getItemAt: i];
draw_val_item (20, 40 + ( i * 10), bind_desc_pad,
draw_val_item (x + 20, y + 40 + ( i * 10), bind_desc_pad,
binding.text, binding.keys);
}
opt_cursor (12, (Menu_GetIndex () * 10) + cursor_pad);
opt_cursor (x + 12, y + (Menu_GetIndex () * 10) + cursor_pad);
return 1;
};
@ -344,7 +344,7 @@ CB_ME_misc_control_binding =
Draw the bindings for the misc controls
*/
integer ()
integer (integer x, integer y)
DRAW_misc_control_binding =
{
local integer cursor_pad = 40, bind_desc_pad;
@ -352,17 +352,17 @@ DRAW_misc_control_binding =
bind_desc_pad = 120;
Draw_String (20, 10, "Backspace/Delete: Del binding");
Draw_String (20, 20, "Enter: New binding");
Draw_String (x + 20, y + 10, "Backspace/Delete: Del binding");
Draw_String (x + 20, y + 20, "Enter: New binding");
hl = [misc_bindings count];
for(i=0;i < hl; i++) {
local binding_t [] binding = [misc_bindings getItemAt: i];
draw_val_item (20, 40+(i*10), bind_desc_pad,
draw_val_item (x + 20, y + 40+(i*10), bind_desc_pad,
binding.text, binding.keys);
}
opt_cursor (12, (Menu_GetIndex() * 10) + cursor_pad);
opt_cursor (x + 12, y + (Menu_GetIndex() * 10) + cursor_pad);
return 1;
};
@ -421,24 +421,24 @@ CB_ME_weapon_control_binding =
Draw the weapon binding menu
*/
integer ()
integer (integer x, integer y)
DRAW_weapon_control_binding =
{
local integer cursor_pad = 40, bind_desc_pad, hl, i;
bind_desc_pad = 120;
Draw_String (20, 10, "Backspace/Delete: Del binding");
Draw_String (20, 20, "Enter: New binding");
Draw_String (x + 20, y + 10, "Backspace/Delete: Del binding");
Draw_String (x + 20, y + 20, "Enter: New binding");
hl = [weapon_bindings count];
for(i = 0; i < hl; i++) {
local binding_t [] binding = [weapon_bindings getItemAt: i];
draw_val_item (20, 40 + (i * 10), bind_desc_pad,
draw_val_item (x + 20, y + 40 + (i * 10), bind_desc_pad,
binding.text, binding.keys);
}
opt_cursor (12, (Menu_GetIndex () * 10) + cursor_pad);
opt_cursor (x + 12, y + (Menu_GetIndex () * 10) + cursor_pad);
return 1;
};

View file

@ -3,7 +3,7 @@
@extern void (integer x, integer y, string text) Menu_Begin;
@extern void (integer val) Menu_FadeScreen;
@extern void (integer () func) Menu_Draw;
@extern void (integer (integer x, integer y) func) Menu_Draw;
@extern void (integer () func) Menu_EnterHook;
@extern void (integer () func) Menu_LeaveHook;
@extern void (integer x, integer y, string name) Menu_Pic;

View file

@ -2,7 +2,7 @@
void (integer x, integer y, string text) Menu_Begin = #0;
void (integer val) Menu_FadeScreen = #0;
void (integer () func) Menu_Draw = #0;
void (integer (integer x, integer y) func) Menu_Draw = #0;
void (integer () func) Menu_EnterHook = #0;
void (integer () func) Menu_LeaveHook = #0;
void (integer x, integer y, string name) Menu_Pic = #0;

View file

@ -122,36 +122,40 @@ CB_video_options =
Drawing function for the video options menu
*/
integer ()
integer (integer x, integer y)
DRAW_video_options =
{
local integer bar_pad, spacing = 120;
Draw_Pic (16, 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (160, 4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (54, 40, "Video");
Draw_String (54, 50, "-----");
draw_val_item (70, 60, spacing, "Fullscreen",
Draw_Pic (x + 16, y + 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (x + 54, y + 40, "Video");
Draw_String (x + 54, y + 50, "-----");
draw_val_item (x + 70, y + 60, spacing, "Fullscreen",
cvar ("vid_fullscreen") ? "On" : "Off");
draw_val_item (70, 70, spacing, "Crosshair", ftos (cvar ("crosshair")));
draw_val_item (70, 80, spacing, "Show fps",
draw_val_item (x + 70, y + 70, spacing, "Crosshair",
ftos (cvar ("crosshair")));
draw_val_item (x + 70, y + 80, spacing, "Show fps",
cvar ("show_fps") ? "On" : "Off");
draw_val_item (70, 90, spacing, "Show time",
draw_val_item (x + 70, y + 90, spacing, "Show time",
cvar ("show_time") ? "On" : "Off");
bar_pad = 90;
bar_pad = y + 90;
Draw_String (70, bar_pad + 10, "Gamma:");
draw_perc_bar (118, bar_pad + 10, 15,
to_percentage (MIN_GAMMA, MAX_GAMMA, cvar ("vid_gamma")));
Draw_String (118 + (15 + 4)*8 , bar_pad + 10, ftos (cvar ("vid_gamma")));
Draw_String (x + 70, bar_pad + 10, "Gamma:");
draw_perc_bar (x + 118, bar_pad + 10, 15,
to_percentage (MIN_GAMMA, MAX_GAMMA,
cvar ("vid_gamma")));
Draw_String (x + 118 + (15 + 4)*8 , bar_pad + 10,
ftos (cvar ("vid_gamma")));
Draw_String (70, bar_pad + 20, "Viewsize:");
draw_perc_bar (142, bar_pad + 20, 12,
Draw_String (x + 70, bar_pad + 20, "Viewsize:");
draw_perc_bar (x + 142, bar_pad + 20, 12,
to_percentage (MIN_VIEWSIZE, MAX_VIEWSIZE,
cvar ("viewsize")));
Draw_String (142 + (12 + 4) * 8 , bar_pad + 20, ftos (cvar ("viewsize")));
Draw_String (x + 142 + (12 + 4) * 8 , bar_pad + 20,
ftos (cvar ("viewsize")));
opt_cursor (62, (Menu_GetIndex () * 10) + 60);
opt_cursor (x + 62, y + (Menu_GetIndex () * 10) + 60);
return 1;
};
@ -211,24 +215,24 @@ CB_audio_options =
Draws the audio options menu
*/
integer ()
integer (integer x, integer y)
DRAW_audio_options =
{
local string tmp = ftos (cvar ("crosshair"));
local integer bar_pad, spacing = 120;
Draw_Pic (16, 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (160, 4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (54, 40, "Audio");
Draw_String (54, 50, "-----");
bar_pad = 50;
Draw_Pic (x + 16, y + 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (x + 54, y + 40, "Audio");
Draw_String (x + 54, y + 50, "-----");
bar_pad = y + 50;
Draw_String (70, bar_pad + 10, "Volume:");
draw_perc_bar (126, bar_pad + 10, 15,
Draw_String (x + 70, bar_pad + 10, "Volume:");
draw_perc_bar (x + 126, bar_pad + 10, 15,
to_percentage (MIN_VOLUME, MAX_VOLUME, cvar("volume")) );
Draw_String (126 + (15 + 4)*8 , bar_pad + 10, ftos(cvar("volume")));
Draw_String (x + 126 + (15 + 4)*8 , bar_pad + 10, ftos(cvar("volume")));
opt_cursor (62, (Menu_GetIndex() * 10) + 60);
opt_cursor (x + 62, y + (Menu_GetIndex() * 10) + 60);
return 1;
};
@ -321,40 +325,40 @@ CB_control_options =
Draws the control option menu
*/
integer ()
integer (integer x, integer y)
DRAW_control_options =
{
local integer cursor_pad = 0, spacing = 120, bar_pad;
Draw_Pic (16, 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (160, 4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (54, 40, "Controls");
Draw_String (54, 50, "--------");
Draw_String (70, 60, "Bindings");
Draw_Pic (x + 16, y + 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (x + 54, y + 40, "Controls");
Draw_String (x + 54, y + 50, "--------");
Draw_String (x + 70, y + 60, "Bindings");
draw_val_item (70, 70, spacing, "Grab mouse", cvar ("in_grab") ? "On" :
"Off");
draw_val_item (70, 80, spacing, "Auto run", cvar ("cl_forwardspeed")
< 400 ? "Off" : "On");
draw_val_item (70, 90, spacing, "Mouse Invert", cvar ("m_pitch") < 0 ?
"On" : "Off");
bar_pad = 90;
draw_val_item (x + 70, y + 70, spacing, "Grab mouse",
cvar ("in_grab") ? "On" : "Off");
draw_val_item (x + 70, y + 80, spacing, "Auto run",
cvar ("cl_forwardspeed") < 400 ? "Off" : "On");
draw_val_item (x + 70, y + 90, spacing, "Mouse Invert",
cvar ("m_pitch") < 0 ? "On" : "Off");
bar_pad = y + 90;
Draw_String (70, bar_pad + 10, "Mouse amp:");
draw_perc_bar (150, bar_pad + 10, 12,
Draw_String (x + 70, bar_pad + 10, "Mouse amp:");
draw_perc_bar (x + 150, bar_pad + 10, 12,
to_percentage (MIN_MOUSE_AMP, MAX_MOUSE_AMP,
cvar("in_mouse_amp")));
Draw_String (150 + (12 + 4) * 8 , bar_pad + 10,
Draw_String (x + 150 + (12 + 4) * 8 , bar_pad + 10,
ftos (cvar ("in_mouse_amp")));
draw_val_item (70, 110, spacing, "Freelook", cvar("freelook") ? "On" :
"Off");
draw_val_item (70, 120, spacing, "Lookspring", cvar ("lookspring") ? "On" :
"Off");
draw_val_item (70, 130, spacing, "Lookstrafe", cvar ("lookstrafe") ? "On"
: "Off");
draw_val_item (x + 70, y + 110, spacing, "Freelook",
cvar("freelook") ? "On" : "Off");
draw_val_item (x + 70, y + 120, spacing, "Lookspring",
cvar ("lookspring") ? "On" : "Off");
draw_val_item (x + 70, y + 130, spacing, "Lookstrafe",
cvar ("lookstrafe") ? "On" : "Off");
opt_cursor (62, (Menu_GetIndex () * 10) + 60 + cursor_pad);
opt_cursor (x + 62, y + (Menu_GetIndex () * 10) + 60 + cursor_pad);
return 1;
};
@ -415,22 +419,22 @@ CB_feature_options =
Draws the feature option menu
*/
integer ()
integer (integer x, integer y)
DRAW_feature_options =
{
local integer cursor_pad = 0, spacing = 120;
Draw_Pic (16, 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (160,4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (54, 40, "Features");
Draw_String (54, 50, "--------");
Draw_Pic (x + 16, y + 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (x + 54, y + 40, "Features");
Draw_String (x + 54, y + 50, "--------");
draw_val_item (70, 60, spacing, "Auto Record",
draw_val_item (x + 70, y + 60, spacing, "Auto Record",
cvar ("cl_autorecord") != 0 ? "On" : "Off");
draw_val_item (70, 70, spacing, "Fraglogging",
draw_val_item (x + 70, y + 70, spacing, "Fraglogging",
cvar ("cl_fraglog") != 0 ? "On" : "Off");
opt_cursor (62, (Menu_GetIndex () * 10) + 60 + cursor_pad);
opt_cursor (x + 62, y + (Menu_GetIndex () * 10) + 60 + cursor_pad);
return 1;
};
@ -558,41 +562,43 @@ KEYEV_player_options =
Draws the player option menu
*/
integer ()
integer (integer x, integer y)
DRAW_player_options =
{
local integer cursor_pad = 0, spacing = 120;
Draw_Pic (16, 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (160,4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (54, 40, "Player");
Draw_String (54, 50, "--------");
Draw_Pic (x + 16, y + 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (x + 54, y + 40, "Player");
Draw_String (x + 54, y + 50, "--------");
Draw_String (70, PLAYER_CONF_Y_PAD + 8, "Name..:");
text_box (120, PLAYER_CONF_Y_PAD, 17, 1);
Draw_String (x + 70, y + PLAYER_CONF_Y_PAD + 8, "Name..:");
text_box (x + 120, y + PLAYER_CONF_Y_PAD, 17, 1);
[player_config_plname_il setBasePos:x y:y];
[player_config_plname_il draw: player_config_iactive == player_config_plname_il];
Draw_String (70, PLAYER_CONF_Y_PAD + 20 + 8, "Team..:");
text_box (120, PLAYER_CONF_Y_PAD + 20, 5, 1);
Draw_String (x + 70, y + PLAYER_CONF_Y_PAD + 20 + 8, "Team..:");
text_box (x + 120, y + PLAYER_CONF_Y_PAD + 20, 5, 1);
[player_config_tname_il setBasePos:x y:y];
[player_config_tname_il draw:player_config_iactive == player_config_tname_il];
draw_val_item (70, PLAYER_CONF_Y_PAD + 45, spacing, "Top color",
draw_val_item (x + 70, y + PLAYER_CONF_Y_PAD + 45, spacing, "Top color",
" " + ftos (cvar ("topcolor")));
draw_val_item (70, PLAYER_CONF_Y_PAD + 60, spacing, "Bottom color",
" " + ftos (cvar ("bottomcolor")));
draw_val_item (x + 70, y + PLAYER_CONF_Y_PAD + 60, spacing,
"Bottom color", " " + ftos (cvar ("bottomcolor")));
// Draw nice color boxes
text_box (192, PLAYER_CONF_Y_PAD + 45 - 8, 1, 1);
Draw_Fill (200, PLAYER_CONF_Y_PAD + 45, 16, 8,
text_box (x + 192, y + PLAYER_CONF_Y_PAD + 45 - 8, 1, 1);
Draw_Fill (x + 200, y + PLAYER_CONF_Y_PAD + 45, 16, 8,
ftoi (cvar ("topcolor")) * 16 + 8);
text_box (192, PLAYER_CONF_Y_PAD + 60 - 8, 1, 1);
Draw_Fill (200, PLAYER_CONF_Y_PAD + 60, 16, 8,
text_box (x + 192, y + PLAYER_CONF_Y_PAD + 60 - 8, 1, 1);
Draw_Fill (x + 200, y + PLAYER_CONF_Y_PAD + 60, 16, 8,
ftoi (cvar ("bottomcolor")) * 16 + 8);
opt_cursor (62, player_config_cursor_tbl[player_config_cursor]);
opt_cursor (x + 62, y + player_config_cursor_tbl[player_config_cursor]);
return 1;
};
@ -718,22 +724,23 @@ KEYEV_network_options =
Draws the network option menu
*/
integer ()
integer (integer x, integer y)
DRAW_network_options =
{
local integer cursor_pad = 0, spacing = 120;
Draw_Pic (16, 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (160, 4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (54, 40, "Network");
Draw_String (54, 50, "--------");
Draw_Pic (x + 16, y + 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_option.lmp", 1));
Draw_String (x + 54, y + 40, "Network");
Draw_String (x + 54, y + 50, "--------");
Draw_String (70, NETWORK_CONF_Y_PAD + 8, "Rate..:");
text_box (120, NETWORK_CONF_Y_PAD, 9, 1);
Draw_String (x + 70, y + NETWORK_CONF_Y_PAD + 8, "Rate..:");
text_box (x + 120, y + NETWORK_CONF_Y_PAD, 9, 1);
[network_config_rate_il setBasePos:x y:y];
[network_config_rate_il draw: network_config_iactive == network_config_rate_il];
opt_cursor (62, player_config_cursor_tbl[player_config_cursor]);
opt_cursor (x + 62, y + player_config_cursor_tbl[player_config_cursor]);
return 1;
};

View file

@ -6,19 +6,19 @@
#include "controls_o.h"
#include "client_menu.h"
integer () servlist_favorates_draw =
integer (integer x, integer y) servlist_favorates_draw =
{
Draw_Pic (16, 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (160, 4, Draw_CachePic ("gfx/p_multi.lmp", 1));
Draw_String (54, 40, "Under Construction");
Draw_Pic (x + 16, y + 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_multi.lmp", 1));
Draw_String (x + 54, y + 40, "Under Construction");
return 1;
};
integer () servlist_all_draw =
integer (integer x, integer y) servlist_all_draw =
{
Draw_Pic (16, 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (160, 4, Draw_CachePic ("gfx/p_multi.lmp", 1));
Draw_String (54, 40, "Under Construction");
Draw_Pic (x + 16, y + 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_multi.lmp", 1));
Draw_String (x + 54, y + 40, "Under Construction");
return 1;
};
@ -27,21 +27,22 @@ integer serv_nempty;
InputLine serv_maxping;
InputLine serv_game;
integer () servlist_filter_draw =
integer (integer x, integer y) servlist_filter_draw =
{
Draw_Pic (16, 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (160, 4, Draw_CachePic ("gfx/p_multi.lmp", 1));
Draw_String (62, 40, "Max Ping........:");
text_box (206, 32, 4, 1);
Draw_Pic (x + 16, y + 4, Draw_CachePic ("gfx/qplaque.lmp", 1));
Draw_CenterPic (x + 160, y + 4, Draw_CachePic ("gfx/p_multi.lmp", 1));
Draw_String (x + 62, y + 40, "Max Ping........:");
text_box (x + 206, y + 32, 4, 1);
[serv_maxping setBasePos:x y:y];
[serv_maxping draw:1];
Draw_String (62, 56, "Game Contains...:");
text_box (206, 48, 8, 1);
Draw_String (62, 72, "Server Not Full.:");
Draw_String (206, 72, ((serv_nfull == 0) ? "No" : "Yes"));
Draw_String (62, 88, "Server Not Empty:");
Draw_String (206, 88, ((serv_nempty == 0) ? "No" : "Yes"));
Draw_String (62, 96, "Under Construction");
opt_cursor (54, (Menu_GetIndex () * 16) + 40);
Draw_String (x + 62, y + 56, "Game Contains...:");
text_box (x + 206, y + 48, 8, 1);
Draw_String (x + 62, y + 72, "Server Not Full.:");
Draw_String (x + 206, y + 72, ((serv_nfull == 0) ? "No" : "Yes"));
Draw_String (x + 62, y + 88, "Server Not Empty:");
Draw_String (x + 206, y + 88, ((serv_nempty == 0) ? "No" : "Yes"));
Draw_String (x + 62, y + 96, "Under Construction");
opt_cursor (x + 54, y + (Menu_GetIndex () * 16) + 40);
return 1;
};

View file

@ -18,6 +18,7 @@ typedef _inputline_t [] inputline_t;
struct il_data_t = {
integer x, y;
integer xbase, ybase;
BOOL cursor;
};
@ -33,6 +34,7 @@ struct il_data_t = {
//-initAt:(Point)p HistoryLines:(integer)l LineSize:(integer)s PromptChar:(integer)prompt;
- (void) free;
- (void) setBasePos: (integer) x y: (integer) y;
- (void) setWidth: (integer)width;
- (void) draw: (BOOL)cursor;

View file

@ -19,6 +19,7 @@ string (inputline_t il) InputLine_GetText = #0;
self = [super init];
control.x = aRect.origin.x;
control.y = aRect.origin.y;
control.xbase = control.ybase = 0;
control.cursor = NO;
il = InputLine_Create (aRect.size.height, aRect.size.width, char);
@ -33,6 +34,12 @@ string (inputline_t il) InputLine_GetText = #0;
[super free];
}
- (void) setBasePos: (integer) x y: (integer) y
{
control.xbase = x;
control.ybase = y;
}
- (void) setWidth: (integer)visibleWidth
{
InputLine_SetWidth (il, width);