From 73f27119add06b37dadc4a62343e1301585a828f Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 24 Sep 2011 16:30:24 +0000 Subject: Rework mouse speed box drawing code and move to common code, so that it can be added to other games. Subversion-branch: /branches/v2-branch Subversion-revision: 2395 --- src/doom/d_main.c | 2 +- src/doom/doomstat.h | 1 + src/doom/g_game.c | 114 ++--------------------------------------- src/i_video.c | 30 +++++++++++ src/i_video.h | 1 + src/v_video.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/v_video.h | 7 +++ 7 files changed, 188 insertions(+), 112 deletions(-) diff --git a/src/doom/d_main.c b/src/doom/d_main.c index 0348c39d..2784c26d 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -283,7 +283,7 @@ void D_Display (void) { // Box showing current mouse speed - G_DrawMouseSpeedBox(); + V_DrawMouseSpeedBox(testcontrols_mousespeed); } menuactivestate = menuactive; diff --git a/src/doom/doomstat.h b/src/doom/doomstat.h index cd626fdf..b0cff548 100644 --- a/src/doom/doomstat.h +++ b/src/doom/doomstat.h @@ -162,6 +162,7 @@ extern int viewwidth; extern int scaledviewwidth; extern boolean testcontrols; +extern int testcontrols_mousespeed; diff --git a/src/doom/g_game.c b/src/doom/g_game.c index d7f86b20..433e35e3 100644 --- a/src/doom/g_game.c +++ b/src/doom/g_game.c @@ -152,6 +152,9 @@ boolean singledemo; // quit after playing a demo from cmdlin boolean precache = true; // if true, load all graphics at start boolean testcontrols = false; // Invoked by setup to test controls +int testcontrols_mousespeed; + + wbstartstruct_t wminfo; // parms for world map / intermission @@ -229,8 +232,6 @@ static boolean *joybuttons = &joyarray[1]; // allow [-1] static int savegameslot; static char savedescription[32]; -static int testcontrols_mousespeed; - #define BODYQUESIZE 32 mobj_t* bodyque[BODYQUESIZE]; @@ -239,115 +240,6 @@ int bodyqueslot; int vanilla_savegame_limit = 1; int vanilla_demo_limit = 1; - -#define MOUSE_SPEED_BOX_WIDTH 16 -#define COLOR_RED 0xb0 -#define COLOR_BLACK 0x00 -#define COLOR_WHITE 0x04 -#define COLOR_YELLOW 0xe7 - -void G_DrawMouseSpeedBox(void) -{ - extern int usemouse; - int i; - int box_x, box_y; - int original_speed; - int x, y; - int redline_x; - int linelen; - char *lumpname; - int color; - - // If the mouse is turned off or acceleration is turned off, don't - // draw the box at all. - - if (!usemouse || fabs(mouse_acceleration - 1) < 0.01) - { - return; - } - - // Calculate box position - - box_x = SCREENWIDTH - MOUSE_SPEED_BOX_WIDTH * 8; - box_y = SCREENHEIGHT - 9; - - // Draw the box. - - x = box_x; - - for (i=0; i MOUSE_SPEED_BOX_WIDTH - 1) + { + linelen = MOUSE_SPEED_BOX_WIDTH - 1; + } + + V_DrawHorizLine(box_x + 1, box_y + 4, MOUSE_SPEED_BOX_WIDTH - 2, black); + + if (linelen < redline_x) + { + V_DrawHorizLine(box_x + 1, box_y + MOUSE_SPEED_BOX_HEIGHT / 2, + linelen, white); + } + else + { + V_DrawHorizLine(box_x + 1, box_y + MOUSE_SPEED_BOX_HEIGHT / 2, + redline_x, white); + V_DrawHorizLine(box_x + redline_x, box_y + MOUSE_SPEED_BOX_HEIGHT / 2, + linelen - redline_x, yellow); + } + + // Draw red line + + V_DrawVertLine(box_x + redline_x, box_y + 1, + MOUSE_SPEED_BOX_HEIGHT - 2, red); +} + diff --git a/src/v_video.h b/src/v_video.h index 01791d6c..93a46552 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -76,6 +76,11 @@ void V_DrawBlock(int x, int y, int width, int height, byte *src); void V_MarkRect(int x, int y, int width, int height); +void V_DrawFilledBox(int x, int y, int w, int h, int c); +void V_DrawHorizLine(int x, int y, int w, int c); +void V_DrawVertLine(int x, int y, int h, int c); +void V_DrawBox(int x, int y, int w, int h, int c); + // Draw a raw screen lump void V_DrawRawScreen(byte *raw); @@ -105,5 +110,7 @@ void V_LoadTintTable(void); void V_LoadXlaTable(void); +void V_DrawMouseSpeedBox(int speed); + #endif -- cgit v1.2.3