2019-12-22 19:55:47 +00:00
|
|
|
/*
|
|
|
|
** st_start.cpp
|
|
|
|
** Handles the startup screen.
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 2006-2007 Randy Heit
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
// HEADER FILES ------------------------------------------------------------
|
|
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
#include "resource.h"
|
|
|
|
|
|
|
|
#include "st_start.h"
|
2020-04-23 19:18:40 +00:00
|
|
|
#include "cmdlib.h"
|
2021-10-30 08:51:03 +00:00
|
|
|
|
2019-12-22 19:55:47 +00:00
|
|
|
#include "i_system.h"
|
|
|
|
#include "i_input.h"
|
|
|
|
#include "hardware.h"
|
2020-04-23 19:18:40 +00:00
|
|
|
#include "filesystem.h"
|
2019-12-22 19:55:47 +00:00
|
|
|
#include "m_argv.h"
|
2020-04-23 19:18:40 +00:00
|
|
|
#include "engineerrors.h"
|
2019-12-22 19:55:47 +00:00
|
|
|
#include "s_music.h"
|
|
|
|
#include "printf.h"
|
2020-04-23 19:18:40 +00:00
|
|
|
#include "startupinfo.h"
|
|
|
|
#include "i_interface.h"
|
2020-09-27 08:27:30 +00:00
|
|
|
#include "texturemanager.h"
|
2022-06-06 09:45:02 +00:00
|
|
|
#include "i_mainwindow.h"
|
2019-12-22 19:55:47 +00:00
|
|
|
|
|
|
|
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
|
|
|
|
|
|
|
void ST_Util_SizeWindowForBitmap (int scale);
|
|
|
|
|
|
|
|
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
|
|
|
|
|
|
|
extern HINSTANCE g_hInst;
|
|
|
|
|
|
|
|
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
|
|
|
|
|
|
|
// CODE --------------------------------------------------------------------
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FStartupScreen :: CreateInstance
|
|
|
|
//
|
|
|
|
// Initializes the startup screen for the detected game.
|
|
|
|
// Sets the size of the progress bar and displays the startup screen.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2022-06-06 09:45:02 +00:00
|
|
|
FStartupScreen *FStartupScreen::CreateInstance(int max_progress, bool showprogress)
|
2019-12-22 19:55:47 +00:00
|
|
|
{
|
2022-06-06 09:45:02 +00:00
|
|
|
return new FBasicStartupScreen(max_progress, showprogress);
|
2019-12-22 19:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FBasicStartupScreen Constructor
|
|
|
|
//
|
|
|
|
// Shows a progress bar at the bottom of the window.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
FBasicStartupScreen::FBasicStartupScreen(int max_progress, bool show_bar)
|
|
|
|
: FStartupScreen(max_progress)
|
|
|
|
{
|
2020-04-23 19:18:40 +00:00
|
|
|
if (show_bar)
|
2019-12-22 19:55:47 +00:00
|
|
|
{
|
2022-06-06 09:45:02 +00:00
|
|
|
mainwindow.ShowProgressBar(MaxPos);
|
2019-12-22 19:55:47 +00:00
|
|
|
}
|
|
|
|
NetMaxPos = 0;
|
|
|
|
NetCurPos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FBasicStartupScreen Destructor
|
|
|
|
//
|
|
|
|
// Called just before entering graphics mode to deconstruct the startup
|
|
|
|
// screen.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
FBasicStartupScreen::~FBasicStartupScreen()
|
|
|
|
{
|
2022-06-06 09:45:02 +00:00
|
|
|
mainwindow.HideProgressBar();
|
|
|
|
KillTimer(mainwindow.GetHandle(), 1337);
|
2019-12-22 19:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FBasicStartupScreen :: Progress
|
|
|
|
//
|
|
|
|
// Bumps the progress meter one notch.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FBasicStartupScreen::Progress()
|
|
|
|
{
|
|
|
|
if (CurPos < MaxPos)
|
|
|
|
{
|
|
|
|
CurPos++;
|
2022-06-06 09:45:02 +00:00
|
|
|
mainwindow.SetProgressPos(CurPos);
|
2019-12-22 19:55:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FBasicStartupScreen :: NetInit
|
|
|
|
//
|
|
|
|
// Shows the network startup pane if it isn't visible. Sets the message in
|
|
|
|
// the pane to the one provided. If numplayers is 0, then the progress bar
|
|
|
|
// is a scrolling marquee style. If numplayers is 1, then the progress bar
|
|
|
|
// is just a full bar. If numplayers is >= 2, then the progress bar is a
|
|
|
|
// normal one, and a progress count is also shown in the pane.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FBasicStartupScreen::NetInit(const char *message, int numplayers)
|
|
|
|
{
|
|
|
|
NetMaxPos = numplayers;
|
2022-06-06 09:45:02 +00:00
|
|
|
mainwindow.ShowNetStartPane(message, numplayers);
|
2019-12-22 19:55:47 +00:00
|
|
|
|
|
|
|
NetMaxPos = numplayers;
|
|
|
|
NetCurPos = 0;
|
|
|
|
NetProgress(1); // You always know about yourself
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FBasicStartupScreen :: NetDone
|
|
|
|
//
|
|
|
|
// Removes the network startup pane.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FBasicStartupScreen::NetDone()
|
|
|
|
{
|
2022-06-06 09:45:02 +00:00
|
|
|
mainwindow.HideNetStartPane();
|
2019-12-22 19:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FBasicStartupScreen :: NetProgress
|
|
|
|
//
|
|
|
|
// Sets the network progress meter. If count is 0, it gets bumped by 1.
|
|
|
|
// Otherwise, it is set to count.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2022-06-06 09:45:02 +00:00
|
|
|
void FBasicStartupScreen::NetProgress(int count)
|
2019-12-22 19:55:47 +00:00
|
|
|
{
|
|
|
|
if (count == 0)
|
|
|
|
{
|
|
|
|
NetCurPos++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NetCurPos = count;
|
|
|
|
}
|
|
|
|
|
2022-06-06 09:45:02 +00:00
|
|
|
mainwindow.SetNetStartProgress(count);
|
2019-12-22 19:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FBasicStartupScreen :: NetLoop
|
|
|
|
//
|
|
|
|
// The timer_callback function is called at least two times per second
|
|
|
|
// and passed the userdata value. It should return true to stop the loop and
|
|
|
|
// return control to the caller or false to continue the loop.
|
|
|
|
//
|
|
|
|
// ST_NetLoop will return true if the loop was halted by the callback and
|
|
|
|
// false if the loop was halted because the user wants to abort the
|
|
|
|
// network synchronization.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
bool FBasicStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata)
|
|
|
|
{
|
2022-06-06 09:45:02 +00:00
|
|
|
return mainwindow.RunMessageLoop(timer_callback, userdata);
|
2020-04-23 19:18:40 +00:00
|
|
|
}
|