mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-25 05:41:20 +00:00
[console] Start work on a debug UI
It does almost nothing (just puts a non-function button on the screen), but it will help develop the IMUI code and, of course, come to help with debugging in general.
This commit is contained in:
parent
0257165b7d
commit
5099633bc8
8 changed files with 171 additions and 7 deletions
|
@ -59,7 +59,6 @@ typedef enum {
|
|||
|
||||
extern int con_linewidth;
|
||||
extern struct plugin_s *con_module;
|
||||
extern struct console_data_s con_data;
|
||||
|
||||
//extern int con_totallines;
|
||||
//extern bool con_initialized;
|
||||
|
|
13
include/cl_console.h
Normal file
13
include/cl_console.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef __cl_console_h
|
||||
#define __cl_console_h
|
||||
|
||||
extern struct console_data_s con_data;
|
||||
extern bool con_debug;
|
||||
|
||||
void Con_Debug_Init (void);
|
||||
void Con_Debug_InitCvars (void);
|
||||
void Con_Debug_Shutdown (void);
|
||||
void Con_Debug_Draw (void);
|
||||
void Con_Show_Mouse (bool visible);
|
||||
|
||||
#endif//__cl_console_h
|
|
@ -11,10 +11,13 @@ console_common_sources= \
|
|||
libs/console/console.c \
|
||||
libs/console/list.c \
|
||||
libs/console/filelist.c
|
||||
|
||||
client_sources= \
|
||||
libs/console/bi_inputline.c \
|
||||
libs/console/cl_debug.c \
|
||||
libs/console/client.c \
|
||||
libs/console/menu.c
|
||||
|
||||
server_sources= \
|
||||
libs/console/server.c
|
||||
|
||||
|
|
116
libs/console/cl_debug.c
Normal file
116
libs/console/cl_debug.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "QF/cvar.h"
|
||||
|
||||
#include "QF/input/event.h"
|
||||
|
||||
#include "QF/ui/canvas.h"
|
||||
#include "QF/ui/font.h"
|
||||
#include "QF/ui/imui.h"
|
||||
#include "QF/ui/view.h"
|
||||
|
||||
#include "QF/plugin/console.h"
|
||||
#include "QF/plugin/vid_render.h"
|
||||
|
||||
#include "cl_console.h"
|
||||
|
||||
static int debug_event_id;
|
||||
static imui_ctx_t *debug_imui;
|
||||
#define IMUI_context debug_imui
|
||||
|
||||
bool con_debug;
|
||||
static cvar_t con_debug_cvar = {
|
||||
.name = "con_debug",
|
||||
.description =
|
||||
"Enable the debug interface",
|
||||
.default_value = "false",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_bool, .value = &con_debug },
|
||||
};
|
||||
static char *deb_fontname;
|
||||
static cvar_t deb_fontname_cvar = {
|
||||
.name = "deb_fontname",
|
||||
.description =
|
||||
"Font name/patter for debug interface",
|
||||
.default_value = "Consolas",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = 0, .value = &deb_fontname },
|
||||
};
|
||||
static float deb_fontsize;
|
||||
static cvar_t deb_fontsize_cvar = {
|
||||
.name = "deb_fontsize",
|
||||
.description =
|
||||
"Font size for debug interface",
|
||||
.default_value = "22",
|
||||
.flags = CVAR_NONE,
|
||||
.value = { .type = &cexpr_float, .value = &deb_fontsize },
|
||||
};
|
||||
|
||||
static void
|
||||
con_debug_f (void *data, const cvar_t *cvar)
|
||||
{
|
||||
Con_Show_Mouse (con_debug);
|
||||
if (debug_imui) {
|
||||
IMUI_SetVisible (debug_imui, con_debug);
|
||||
}
|
||||
}
|
||||
|
||||
static int deb_xlen = -1;
|
||||
static int deb_ylen = -1;
|
||||
static void
|
||||
debug_app_window (const IE_event_t *ie_event)
|
||||
{
|
||||
if (deb_xlen != ie_event->app_window.xlen
|
||||
|| deb_ylen != ie_event->app_window.ylen) {
|
||||
deb_xlen = ie_event->app_window.xlen;
|
||||
deb_ylen = ie_event->app_window.ylen;
|
||||
IMUI_SetSize (debug_imui, deb_xlen, deb_ylen);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
debug_event_handler (const IE_event_t *ie_event, void *data)
|
||||
{
|
||||
static void (*handlers[ie_event_count]) (const IE_event_t *ie_event) = {
|
||||
[ie_app_window] = debug_app_window,
|
||||
};
|
||||
if ((unsigned) ie_event->type >= ie_event_count
|
||||
|| !handlers[ie_event->type]) {
|
||||
return 0;
|
||||
}
|
||||
handlers[ie_event->type] (ie_event);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
Con_Debug_InitCvars (void)
|
||||
{
|
||||
Cvar_Register (&con_debug_cvar, con_debug_f, 0);
|
||||
Cvar_Register (&deb_fontname_cvar, 0, 0);
|
||||
Cvar_Register (&deb_fontsize_cvar, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
Con_Debug_Init (void)
|
||||
{
|
||||
debug_event_id = IE_Add_Handler (debug_event_handler, 0);
|
||||
debug_imui = IMUI_NewContext (*con_data.canvas_sys,
|
||||
deb_fontname, deb_fontsize);
|
||||
IMUI_SetVisible (debug_imui, con_debug);
|
||||
}
|
||||
|
||||
void
|
||||
Con_Debug_Shutdown (void)
|
||||
{
|
||||
IE_Remove_Handler (debug_event_id);
|
||||
}
|
||||
|
||||
void
|
||||
Con_Debug_Draw (void)
|
||||
{
|
||||
UI_Button ("Hi there!");
|
||||
|
||||
IMUI_Draw (debug_imui);
|
||||
}
|
|
@ -61,6 +61,7 @@
|
|||
#include "QF/ui/inputline.h"
|
||||
#include "QF/ui/view.h"
|
||||
|
||||
#include "cl_console.h"
|
||||
#include "compat.h"
|
||||
|
||||
static con_buffer_t *con;
|
||||
|
@ -155,9 +156,11 @@ static uint32_t canvas_base;
|
|||
static uint32_t view_base;
|
||||
|
||||
static con_state_t con_state;
|
||||
static bool con_hide_mouse;
|
||||
static bool con_hide_mouse; // external requested state
|
||||
static bool con_show_mouse; // local (overrides con_hide_mouse)
|
||||
static bool con_force_mouse_visible;// internal (overrides all for show)
|
||||
static int con_event_id;
|
||||
static int con_saved_focos;
|
||||
static int con_saved_focus;
|
||||
|
||||
static bool con_debuglog;
|
||||
static bool chat_team;
|
||||
|
@ -332,6 +335,21 @@ ClearNotify (void)
|
|||
notify_head = notify_tail = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
con_update_mouse (void)
|
||||
{
|
||||
VID_SetCursor (con_force_mouse_visible
|
||||
|| con_show_mouse
|
||||
|| !con_hide_mouse);
|
||||
}
|
||||
|
||||
void
|
||||
Con_Show_Mouse (bool visible)
|
||||
{
|
||||
con_show_mouse = visible;
|
||||
con_update_mouse ();
|
||||
}
|
||||
|
||||
static void
|
||||
C_SetState (con_state_t state, bool hide_mouse)
|
||||
{
|
||||
|
@ -339,13 +357,14 @@ C_SetState (con_state_t state, bool hide_mouse)
|
|||
con_state = state;
|
||||
con_hide_mouse = hide_mouse;
|
||||
if (con_state == con_inactive) {
|
||||
IE_Set_Focus (con_saved_focos);
|
||||
VID_SetCursor (!con_hide_mouse);
|
||||
IE_Set_Focus (con_saved_focus);
|
||||
con_force_mouse_visible = false;
|
||||
} else if (old_state == con_inactive) {
|
||||
con_saved_focos = IE_Get_Focus ();
|
||||
con_saved_focus = IE_Get_Focus ();
|
||||
IE_Set_Focus (con_event_id);
|
||||
VID_SetCursor (true);
|
||||
con_force_mouse_visible = true;
|
||||
}
|
||||
con_update_mouse ();
|
||||
|
||||
if (state == con_message) {
|
||||
say_line.prompt = "say:";
|
||||
|
@ -769,6 +788,9 @@ setup_console (void)
|
|||
static void
|
||||
C_DrawConsole (void)
|
||||
{
|
||||
if (con_debug) {
|
||||
Con_Debug_Draw ();
|
||||
}
|
||||
setup_console ();
|
||||
view_pos_t screen_len = View_GetLen (screen_view);
|
||||
|
||||
|
@ -1036,6 +1058,7 @@ C_InitCvars (void)
|
|||
Cvar_Register (&con_size_cvar, 0, 0);
|
||||
Cvar_Register (&con_speed_cvar, 0, 0);
|
||||
Cvar_Register (&cl_conmode_cvar, 0, 0);
|
||||
Con_Debug_InitCvars ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1057,6 +1080,8 @@ C_Init (void)
|
|||
// The console will get resized, so assume initial size is 320x200
|
||||
ecs_system_t sys = { con_data.canvas_sys->reg, view_base };
|
||||
screen_canvas = Canvas_New (*con_data.canvas_sys);
|
||||
Con_Debug_Init ();
|
||||
|
||||
screen_view = Canvas_GetRootView (*con_data.canvas_sys, screen_canvas);
|
||||
console_view = View_New (sys, screen_view);
|
||||
buffer_view = View_New (sys, console_view);
|
||||
|
@ -1197,6 +1222,8 @@ C_Init (void)
|
|||
static void
|
||||
C_shutdown (void)
|
||||
{
|
||||
Con_Debug_Shutdown ();
|
||||
|
||||
r_funcs->Draw_DestroyPic (conback);
|
||||
IE_Remove_Handler (con_event_id);
|
||||
Menu_Shutdown ();
|
||||
|
|
|
@ -54,6 +54,8 @@
|
|||
#include "QF/plugin/console.h"
|
||||
#include "QF/plugin/vid_render.h"
|
||||
|
||||
#include "cl_console.h"
|
||||
|
||||
typedef struct menu_pic_s {
|
||||
struct menu_pic_s *next;
|
||||
int x, y;
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "QF/plugin/vid_render.h"
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
#include "QF/ui/font.h"//FIXME
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
|
@ -707,6 +708,7 @@ CL_Init (cbuf_t *cbuf)
|
|||
R_Init ();
|
||||
r_data->lightstyle = cl.lightstyle;
|
||||
S_Init (&cl.viewentity, &host_frametime);
|
||||
Font_Init (); //FIXME not here
|
||||
|
||||
PI_RegisterPlugins (client_plugin_list);
|
||||
Con_Load ("client");
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
|
||||
#include "QF/plugin/console.h"
|
||||
#include "QF/scene/transform.h"
|
||||
#include "QF/ui/font.h"//FIXME
|
||||
|
||||
#include "buildnum.h"
|
||||
#include "compat.h"
|
||||
|
@ -1460,6 +1461,7 @@ CL_Init (void)
|
|||
Mod_Init ();
|
||||
R_Init ();
|
||||
r_data->lightstyle = cl.lightstyle;
|
||||
Font_Init (); //FIXME not here
|
||||
|
||||
PI_RegisterPlugins (client_plugin_list);
|
||||
Con_Load ("client");
|
||||
|
|
Loading…
Reference in a new issue