foxygit / doom Log in
commit 7a8b8e57e7bd6b6a61b8492031bf5e995272e6bf
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Mon Oct 17 18:51:27 2011 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Mon Oct 17 18:51:27 2011 +0000

    Always show the Strife intro splash screen in windowed mode, and finish
    the splash screen before network startup.

    Subversion-branch: /branches/v2-branch
    Subversion-revision: 2435
---
 src/doom/d_main.c    |  1 +
 src/heretic/d_main.c |  1 +
 src/hexen/h2_main.c  |  1 +
 src/i_video.c        | 15 +++-----
 src/i_video.h        |  8 ++++-
 src/strife/d_main.c  | 99 +++++++++++++++++++++++++++++++++++++++++-----------
 6 files changed, 93 insertions(+), 32 deletions(-)

diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index c2fee76a..e59802dd 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -420,6 +420,7 @@ void D_DoomLoop (void)
     TryRunTics();

     I_SetWindowTitle(gamedescription);
+    I_GraphicsCheckCommandLine();
     I_InitGraphics();
     I_EnableLoadingDisk();
     I_SetGrabMouseCallback(D_GrabMouseCallback);
diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c
index da4256ee..8bca1db1 100644
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -246,6 +246,7 @@ void D_DoomLoop(void)
         debugfile = fopen(filename, "w");
     }
     I_SetWindowTitle(gamedescription);
+    I_GraphicsCheckCommandLine();
     I_InitGraphics();
     I_SetGrabMouseCallback(D_GrabMouseCallback);

diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c
index d66e27e1..3ed8b580 100644
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -564,6 +564,7 @@ void H2_GameLoop(void)
         debugfile = fopen(filename, "w");
     }
     I_SetWindowTitle("Hexen");
+    I_GraphicsCheckCommandLine();
     I_InitGraphics();
     I_SetGrabMouseCallback(D_GrabMouseCallback);

diff --git a/src/i_video.c b/src/i_video.c
index dfb8086e..3bc15823 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -180,8 +180,8 @@ static boolean native_surface;

 // Screen width and height, from configuration file.

-static int screen_width = SCREENWIDTH;
-static int screen_height = SCREENHEIGHT;
+int screen_width = SCREENWIDTH;
+int screen_height = SCREENHEIGHT;

 // Color depth.

@@ -194,11 +194,11 @@ static int autoadjust_video_settings = 1;

 // Run in full screen mode?  (int type for config code)

-static int fullscreen = true;
+int fullscreen = true;

 // Aspect ratio correction mode

-static int aspect_ratio_correct = true;
+int aspect_ratio_correct = true;

 // Time to wait for the screen to settle on startup before starting the
 // game (ms)
@@ -1581,7 +1581,7 @@ static void SetScaleFactor(int factor)
     }
 }

-static void CheckCommandLine(void)
+void I_GraphicsCheckCommandLine(void)
 {
     int i;

@@ -2033,10 +2033,6 @@ void I_InitGraphics(void)
         I_Error("Failed to initialize video: %s", SDL_GetError());
     }

-    // Check for command-line video-related parameters.
-
-    CheckCommandLine();
-
     // Set up title and icon.  Windows cares about the ordering; this
     // has to be done before the call to SDL_SetVideoMode.

@@ -2212,4 +2208,3 @@ void I_BindVideoVariables(void)
     }
 #endif
 }
-
diff --git a/src/i_video.h b/src/i_video.h
index 272ffb08..7cc45dc9 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -78,6 +78,7 @@ typedef boolean (*grabmouse_callback_t)(void);
 // and sets up the video mode
 void I_InitGraphics (void);

+void I_GraphicsCheckCommandLine(void);

 void I_ShutdownGraphics(void);

@@ -125,5 +126,10 @@ extern boolean screensaver_mode;
 extern int usegamma;
 extern byte *I_VideoBuffer;

-#endif
+extern int screen_width;
+extern int screen_height;
+extern int screen_bpp;
+extern int fullscreen;
+extern int aspect_ratio_correct;

+#endif
diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index 62520e4f..08274636 100644
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -84,6 +84,11 @@

 #include "d_main.h"

+// Size of startup splash screen window.
+
+#define INTRO_SCREEN_W 640
+#define INTRO_SCREEN_H 480
+
 //
 // D-DoomLoop()
 // Not a globally visible function,
@@ -494,11 +499,9 @@ void D_DoomLoop (void)

     TryRunTics();

-    if(!showintro) // [STRIFE]
-    {
-        I_SetWindowTitle(gamedescription);
-        I_InitGraphics();
-    }
+    I_SetWindowTitle(gamedescription);
+    I_InitGraphics();
+
     I_EnableLoadingDisk();
     I_SetGrabMouseCallback(D_GrabMouseCallback);

@@ -1174,10 +1177,38 @@ static void D_IntroBackground(void)
 // [STRIFE] New function
 // haleyjd 20110206: Initialize the graphical introduction sequence
 //
+
+static int saved_screen_width, saved_screen_height;
+static int saved_fullscreen, saved_aspect_ratio_correct;
+
 static void D_InitIntroSequence(void)
 {
     if(showintro)
     {
+        // Intro splash screen runs in a window. We must save the actual
+        // display settings, and temporarily overwrite them with the
+        // windowed-mode settings. The real settings will be restored
+        // when the intro screen finishes.
+
+        saved_screen_width = screen_width;
+        saved_screen_height = screen_height;
+        saved_aspect_ratio_correct = aspect_ratio_correct;
+        saved_fullscreen = fullscreen;
+
+        // If the game display settings are to run in a small window, it
+        // makes no sense to switch to a larger window for the splash
+        // screen, so use the configured settings.
+
+        if (fullscreen
+         || screen_width > INTRO_SCREEN_W || screen_height > INTRO_SCREEN_H)
+        {
+            screen_width = INTRO_SCREEN_W;
+            screen_height = INTRO_SCREEN_H;
+            aspect_ratio_correct = 1;
+        }
+
+        fullscreen = 0;
+
         // In vanilla Strife, Mode 13h was initialized directly in D_DoomMain.
         // We have to be a little more courteous of the low-level code here.
         I_SetWindowTitle(gamedescription);
@@ -1214,6 +1245,23 @@ static void D_InitIntroSequence(void)
     */
 }

+// End of intro splash screen.
+
+static void D_FinishIntroSequence(void)
+{
+    if (showintro)
+    {
+        I_ShutdownGraphics();
+
+        // Restore display settings to the actual ones.
+
+        screen_width = saved_screen_width;
+        screen_height = saved_screen_height;
+        fullscreen = saved_fullscreen;
+        aspect_ratio_correct = saved_aspect_ratio_correct;
+    }
+}
+
 //
 // D_DrawIntroSequence
 //
@@ -1648,6 +1696,8 @@ void D_DoomMain (void)
     D_SetGameDescription();
     SetSaveGameDir(iwadfile);

+    I_GraphicsCheckCommandLine();
+
     // haleyjd 20110206 [STRIFE] Startup the introduction sequence
     D_InitIntroSequence();

@@ -1874,33 +1924,39 @@ void D_DoomMain (void)
     if(devparm)
         DEH_printf("  Play voices = %d\n", disable_voices == 0);

+    // [STRIFE]: This has been rearranged. These intro ticks occur
+    // further down in Vanilla Strife; however, we have to finish
+    // the intro sequence here so that netgame startup can begin.
+    // The original calls to D_IntroTick() are commented-out below.
+
+    D_IntroTick();
+    D_IntroTick();
+    D_IntroTick();
+    D_IntroTick();
+    D_IntroTick();
+    D_IntroTick();
+    D_IntroTick();
+
+    D_FinishIntroSequence();
+
     if(devparm) // [STRIFE]
         DEH_printf("D_CheckNetGame: Checking network game status.\n");
     D_CheckNetGame ();

-    // STRIFE-TODO: This is a temporary hack. The startup splash screen
-    // stuff needs to be reworked.
-    // The netgame waiting screen killed the graphics display. Re-run
-    // I_InitGraphics() to bring it back again.
-    if (showintro && netgame)
-    {
-        I_InitGraphics();
-    }
-
     PrintGameVersion();

     if(devparm)
         DEH_printf("HU_Init: Setting up heads up display.\n");
     HU_Init ();
-    D_IntroTick(); // [STRIFE]
+    //D_IntroTick(); // [STRIFE]

     if(devparm)
         DEH_printf("ST_Init: Init status bar.\n");
     ST_Init ();
-    D_IntroTick(); // [STRIFE]
+    //D_IntroTick(); // [STRIFE]

     // haleyjd [STRIFE] -statcopy used to be here...
-    D_IntroTick();
+    //D_IntroTick(); // [STRIFE]

     // If Doom II without a MAP01 lump, this is a store demo.
     // Moved this here so that MAP01 isn't constantly looked up
@@ -1926,7 +1982,7 @@ void D_DoomMain (void)
         G_RecordDemo (myargv[p+1]);
         autostart = true;
     }
-    D_IntroTick(); // [STRIFE]
+    //D_IntroTick(); // [STRIFE]

     p = M_CheckParmWithArgs("-playdemo", 1);
     if (p)
@@ -1935,7 +1991,7 @@ void D_DoomMain (void)
         G_DeferedPlayDemo (demolumpname);
         D_DoomLoop ();  // never returns
     }
-    D_IntroTick(); // [STRIFE]
+    //D_IntroTick(); // [STRIFE]

     p = M_CheckParmWithArgs("-timedemo", 1);
     if (p)
@@ -1943,14 +1999,15 @@ void D_DoomMain (void)
         G_TimeDemo (demolumpname);
         D_DoomLoop ();  // never returns
     }
-    D_IntroTick(); // [STRIFE]
+    //D_IntroTick(); // [STRIFE]

     if (startloadgame >= 0)
     {
         // [STRIFE]: different, for hubs
         M_LoadSelect(startloadgame);
     }
-    D_IntroTick(); // [STRIFE]
+    //D_IntroTick(); // [STRIFE]
+

     if (gameaction != ga_loadgame )
     {