ref: 90da953b2310151b5a56f3ea78d8528100fd1fa0
parent: 439a4b158b47c635100b0006470a7ed1e44e29f3
author: Simon Howard <[email protected]>
date: Sat Sep 6 16:18:50 EDT 2008
Remove dependencies of i_video.c on doom/ code. Subversion-branch: /branches/raven-branch Subversion-revision: 1205
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -107,11 +107,6 @@
boolean singletics = false; // debug flag to cancel adaptiveness
-// If true, game is running as a screensaver
-
-boolean screensaver_mode = false;
-
-
//extern int soundVolume;
//extern int sfxVolume;
//extern int musicVolume;
@@ -340,8 +335,29 @@
} while (!done);
}
+//
+// D_GrabMouseCallback
+//
+// Called to determine whether to grab the mouse pointer
+//
+boolean D_GrabMouseCallback(void)
+{
+ // Drone players don't need mouse focus
+ if (drone)
+ return false;
+
+ // when menu is active or game is paused, release the mouse
+
+ if (menuactive || paused)
+ return false;
+
+ // only grab mouse when playing levels (but not demos)
+
+ return (gamestate == GS_LEVEL) && !demoplayback;
+}
+
//
// D_DoomLoop
//
@@ -363,6 +379,8 @@
TryRunTics();
I_InitGraphics ();
+ I_SetGrabMouseCallback(D_GrabMouseCallback);
+ I_SetWindowTitle(gamedescription);
R_ExecuteSetViewSize();
@@ -867,6 +885,8 @@
//
devparm = M_CheckParm ("-devparm");
+
+ I_DisplayFPSDots(devparm);
//!
// @category net
--- a/src/doom/doomstat.h
+++ b/src/doom/doomstat.h
@@ -55,8 +55,6 @@
extern boolean devparm; // DEBUG: launched with -devparm
-extern boolean screensaver_mode; // game running as a screensaver?
-
// -----------------------------------------------------
// Game Mode - identify IWAD as shareware, retail etc.
//
@@ -147,7 +145,6 @@
extern boolean viewactive;
extern boolean nodrawers;
-extern boolean noblit;
extern int viewwindowx;
extern int viewwindowy;
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -122,7 +122,6 @@
boolean timingdemo; // if true, exit with report on completion
boolean nodrawers; // for comparative timing purposes
-boolean noblit; // for comparative timing purposes
int starttime; // for comparative timing purposes
boolean viewactive;
@@ -2056,13 +2055,6 @@
nodrawers = M_CheckParm ("-nodraw");
- //!
- // @vanilla
- //
- // Disable blitting the screen.
- //
-
- noblit = M_CheckParm ("-noblit");
timingdemo = true;
singletics = true;
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -145,7 +145,7 @@
// Make sure the new window has the right title and icon
- I_SetWindowCaption();
+ I_SetWindowTitle("Exit screen");
I_SetWindowIcon();
// Write the data to the screen memory
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -36,8 +36,6 @@
#include "deh_main.h"
#include "doomtype.h"
#include "doomkeys.h"
-#include "doomstat.h"
-#include "d_main.h"
#include "i_joystick.h"
#include "i_system.h"
#include "i_swap.h"
@@ -46,7 +44,6 @@
#include "i_scale.h"
#include "m_argv.h"
#include "s_sound.h"
-#include "sounds.h"
#include "v_video.h"
#include "w_wad.h"
#include "z_zone.h"
@@ -137,11 +134,30 @@
int grabmouse = true;
+// If true, game is running as a screensaver
+
+boolean screensaver_mode = false;
+
// Flag indicating whether the screen is currently visible:
// when the screen isnt visible, don't render the screen
boolean screenvisible;
+// If true, we display dots at the bottom of the screen to
+// indicate FPS.
+
+static boolean display_fps_dots;
+
+// If this is true, the screen is rendered but not blitted to the
+// video buffer.
+
+static boolean noblit;
+
+// Callback function to invoke to determine whether to grab the
+// mouse pointer.
+
+static grabmouse_callback_t grabmouse_callback = NULL;
+
// disk image data and background overwritten by the disk to be
// restored by EndRead
@@ -199,26 +215,36 @@
if (!usemouse || nomouse)
return false;
- // Drone players don't need mouse focus
-
- if (drone)
- return false;
-
// if we specify not to grab the mouse, never grab
if (!grabmouse)
return false;
- // when menu is active or game is paused, release the mouse
-
- if (menuactive || paused)
- return false;
+ // Invoke the grabmouse callback function to determine whether
+ // the mouse should be grabbed
- // only grab mouse when playing levels (but not demos)
+ if (grabmouse_callback != NULL)
+ {
+ return grabmouse_callback();
+ }
+ else
+ {
+ return true;
+ }
+}
- return (gamestate == GS_LEVEL) && !demoplayback;
+void I_SetGrabMouseCallback(grabmouse_callback_t func)
+{
+ grabmouse_callback = func;
}
+// Set the variable controlling FPS dots.
+
+void I_DisplayFPSDots(boolean dots_on)
+{
+ display_fps_dots = dots_on;
+}
+
// Update the value of window_focused when we get a focus event
//
// We try to make ourselves be well-behaved: the grab on the mouse
@@ -520,11 +546,13 @@
}
break;
+/* TODO
case SDL_QUIT:
// bring up the "quit doom?" prompt
S_StartSound(NULL,sfx_swtchn);
M_QuitDOOM(0);
break;
+ */
case SDL_ACTIVEEVENT:
// need to update our focus state
@@ -771,9 +799,9 @@
return;
// draws little dots on the bottom of the screen
- if (devparm)
- {
+ if (display_fps_dots)
+ {
i = I_GetTime();
tics = i - lasttic;
lasttic = i;
@@ -783,7 +811,6 @@
screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0xff;
for ( ; i<20*4 ; i+=4)
screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0;
-
}
// draw to screen
@@ -832,16 +859,16 @@
}
//
-// Set the window caption
+// Set the window title
//
-void I_SetWindowCaption(void)
+void I_SetWindowTitle(char *title)
{
char *buf;
- buf = Z_Malloc(strlen(gamedescription) + strlen(PACKAGE_STRING) + 10,
+ buf = Z_Malloc(strlen(title) + strlen(PACKAGE_STRING) + 5,
PU_STATIC, NULL);
- sprintf(buf, "%s - %s", gamedescription, PACKAGE_STRING);
+ sprintf(buf, "%s - %s", title, PACKAGE_STRING);
SDL_WM_SetCaption(buf, NULL);
@@ -1169,6 +1196,14 @@
int i;
//!
+ // @vanilla
+ //
+ // Disable blitting the screen.
+ //
+
+ noblit = M_CheckParm ("-noblit");
+
+ //!
// @category video
//
// Grab the mouse when running in windowed mode.
@@ -1514,9 +1549,6 @@
I_SetPalette(doompal);
SDL_SetColors(screen, palette, 0, 256);
- // Setup title and icon
-
- I_SetWindowCaption();
I_SetWindowIcon();
CreateCursors();
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -69,6 +69,8 @@
boolean poor_quality;
} screen_mode_t;
+typedef boolean (*grabmouse_callback_t)(void);
+
// Called by D_DoomMain,
// determines the hardware configuration
// and sets up the video mode
@@ -91,11 +93,14 @@
void I_BeginRead (void);
void I_EndRead (void);
-void I_SetWindowCaption(void);
+void I_SetWindowTitle(char *title);
void I_SetWindowIcon(void);
void I_CheckIsScreensaver(void);
+void I_SetGrabMouseCallback(grabmouse_callback_t func);
+void I_DisplayFPSDots(boolean dots_on);
+
extern char *video_driver;
extern int autoadjust_video_settings;
extern boolean screenvisible;
@@ -107,6 +112,8 @@
extern int mouse_threshold;
extern int startup_delay;
extern int vanilla_keyboard_mapping;
+extern boolean screensaver_mode;
+
#endif
--- a/src/net_gui.c
+++ b/src/net_gui.c
@@ -267,7 +267,7 @@
exit(-1);
}
- I_SetWindowCaption();
+ I_SetWindowTitle("Waiting for game start");
I_SetWindowIcon();
BuildGUI();