- reduce backend's dependency on game state by using callbacks.

This commit is contained in:
Christoph Oelckers 2020-04-11 18:22:21 +02:00
parent 721b857e5e
commit 56f2b2ac56
29 changed files with 289 additions and 276 deletions

View file

@ -1147,6 +1147,7 @@ set (PCH_SOURCES
common/engine/sc_man.cpp
common/engine/palettecontainer.cpp
common/engine/stringtable.cpp
common/engine/i_interface.cpp
utility/m_random.cpp
utility/nodebuilder/nodebuild.cpp

View file

@ -0,0 +1,3 @@
#include "i_interface.h"
SystemCallbacks *sysCallbacks;

View file

@ -0,0 +1,13 @@
#pragma once
struct SystemCallbacks
{
bool (*WantGuiCapture)();
bool (*WantLeftButton)();
bool (*NetGame)();
bool (*WantNativeMouse)();
bool (*CaptureModeInGame)();
};
extern SystemCallbacks *sysCallbacks;

View file

@ -71,6 +71,7 @@ void PaletteContainer::SetPalette(const uint8_t* colors, int transparent_index)
Remap[i] = i;
}
uniqueRemaps[0]->MakeIdentity(); // update the identity remap.
if (transparent_index >= 0 && transparent_index <= 255)

View file

@ -57,3 +57,10 @@ typedef uint32_t angle_t;
using INTBOOL = int;
using BITFIELD = uint32_t;
#endif
#if defined(_MSC_VER)
#define NOVTABLE __declspec(novtable)
#else
#define NOVTABLE
#endif

View file

@ -106,6 +106,7 @@
#include "md5.h"
#include "c_buttons.h"
#include "d_buttons.h"
#include "i_interface.h"
EXTERN_CVAR(Bool, hud_althud)
EXTERN_CVAR(Int, vr_mode)
@ -2541,6 +2542,19 @@ static const char *DoomButtons[] =
CVAR(Bool, lookspring, true, CVAR_ARCHIVE); // Generate centerview when -mlook encountered?
EXTERN_CVAR(String, language)
CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
{
if (self < 0)
{
self = 0;
}
else if (self > 2)
{
self = 2;
}
}
void Mlook_ReleaseHandler()
{
if (lookspring)
@ -2560,6 +2574,56 @@ bool StrTable_ValidFilter(const char* str)
return stricmp(str, GameNames[gameinfo.gametype]) == 0;
}
bool System_WantGuiCapture()
{
bool wantCapt;
if (menuactive == MENU_Off)
{
wantCapt = ConsoleState == c_down || ConsoleState == c_falling || chatmodeon;
}
else
{
wantCapt = (menuactive == MENU_On || menuactive == MENU_OnNoPause);
}
// [ZZ] check active event handlers that want the UI processing
if (!wantCapt && primaryLevel->localEventManager->CheckUiProcessors())
wantCapt = true;
return wantCapt;
}
bool System_WantLeftButton()
{
return (gamestate == GS_DEMOSCREEN || gamestate == GS_TITLELEVEL);
}
bool System_NetGame()
{
return netgame;
}
bool System_WantNativeMouse()
{
return primaryLevel->localEventManager->CheckRequireMouse();
}
static bool System_CaptureModeInGame()
{
switch (mouse_capturemode)
{
default:
case 0:
return gamestate == GS_LEVEL;
case 1:
return gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_FINALE;
case 2:
return true;
}
}
//==========================================================================
//
// D_DoomMain
@ -2589,6 +2653,16 @@ static int D_DoomMain_Internal (void)
};
GStrings.SetCallbacks(&stblcb);
static SystemCallbacks syscb =
{
System_WantGuiCapture,
System_WantLeftButton,
System_NetGame,
System_WantNativeMouse,
System_CaptureModeInGame,
};
sysCallbacks = &syscb;
std::set_new_handler(NewFailure);
const char *batchout = Args->CheckValue("-errorlog");
@ -2872,7 +2946,6 @@ static int D_DoomMain_Internal (void)
C_InitConback();
StartScreen->Progress();
GPalette.Init(NUM_TRANSLATION_TABLES);
V_InitFonts();
// [CW] Parse any TEAMINFO lumps.

View file

@ -33,13 +33,6 @@
class PClassActor;
typedef TMap<int, PClassActor *> FClassMap;
#if defined(_MSC_VER)
#define NOVTABLE __declspec(novtable)
#else
#define NOVTABLE
#endif
#include "basics.h"
#include "printf.h"

View file

@ -557,6 +557,13 @@ FBaseCVar* G_GetUserCVar(int playernum, const char* cvarname)
return cvar;
}
static ticcmd_t emptycmd;
ticcmd_t* G_BaseTiccmd()
{
return &emptycmd;
}
//
// G_BuildTiccmd
@ -574,7 +581,7 @@ void G_BuildTiccmd (ticcmd_t *cmd)
ticcmd_t *base;
base = I_BaseTiccmd (); // empty, or external driver
base = G_BaseTiccmd ();
*cmd = *base;
cmd->consistancy = consistancy[consoleplayer][(maketic/ticdup)%BACKUPTICS];

View file

@ -470,6 +470,43 @@ void FCajunMaster::ForgetBots ()
botinfo = NULL;
}
#if defined _WIN32 || defined __APPLE__
FString M_GetCajunPath(const char* botfilename)
{
FString path;
path << progdir << "zcajun/" << botfilename;
if (!FileExists(path))
{
path = "";
}
return path;
}
#else
FString M_GetCajunPath(const char* botfilename)
{
FString path;
// Check first in $HOME/.config/zdoom/botfilename.
path = GetUserFile(botfilename);
if (!FileExists(path))
{
// Then check in SHARE_DIR/botfilename.
path = SHARE_DIR;
path << botfilename;
if (!FileExists(path))
{
path = "";
}
}
return path;
}
#endif
bool FCajunMaster::LoadBots ()
{
FScanner sc;

View file

@ -1362,7 +1362,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da
temp = damage < 100 ? damage : 100;
if (player == target->Level->GetConsolePlayer() )
{
I_Tactile (40,10,40+temp*2);
//I_Tactile (40,10,40+temp*2);
}
}
else

View file

@ -47,6 +47,7 @@
#include "events.h"
#include "g_game.h"
#include "g_levellocals.h"
#include "i_interface.h"
EXTERN_CVAR(Int, m_use_mouse)
@ -57,19 +58,6 @@ CVAR(Bool, m_filter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
{
if (self < 0)
{
self = 0;
}
else if (self > 2)
{
self = 2;
}
}
extern int paused, chatmodeon;
extern constate_e ConsoleState;
@ -152,24 +140,6 @@ void CenterCursor()
SetCursorPosition(centerPoint);
}
bool IsInGame()
{
switch (mouse_capturemode)
{
default:
case 0:
return gamestate == GS_LEVEL;
case 1:
return gamestate == GS_LEVEL
|| gamestate == GS_INTERMISSION
|| gamestate == GS_FINALE;
case 2:
return true;
}
}
void CheckNativeMouse()
{
const bool windowed = (NULL == screen) || !screen->IsFullscreen();
@ -187,8 +157,9 @@ void CheckNativeMouse()
}
else
{
bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame();
wantNative = (!m_use_mouse || MENU_WaitKey != menuactive)
&& (!IsInGame() || GUICapture || paused || demoplayback);
&& (!captureModeInGame || GUICapture || paused || demoplayback);
}
}
else

View file

@ -79,8 +79,6 @@ void I_StartTic (void);
// for normal input.
ticcmd_t *I_BaseTiccmd (void);
void I_Tactile (int on, int off, int total);
// Print a console string
void I_PrintStr (const char *str);

View file

@ -32,17 +32,6 @@
#include "x86.h"
void I_Tactile(int /*on*/, int /*off*/, int /*total*/)
{
}
static ticcmd_t emptycmd;
ticcmd_t *I_BaseTiccmd()
{
return &emptycmd;
}
bool I_WriteIniFailed()
{
printf("The config file %s could not be saved:\n%s\n", GameConfig->GetPathName(), strerror(errno));

View file

@ -150,27 +150,6 @@ FString M_GetAutoexecPath()
return path;
}
//===========================================================================
//
// M_GetCajunPath macOS
//
// Returns the location of the Cajun Bot definitions.
//
//===========================================================================
FString M_GetCajunPath(const char *botfilename)
{
FString path;
// Just copies the Windows code. Should this be more Mac-specific?
path << progdir << "zcajun/" << botfilename;
if (!FileExists(path))
{
path = "";
}
return path;
}
//===========================================================================
//
// M_GetConfigPath macOS

View file

@ -48,6 +48,7 @@
#include "g_levellocals.h"
#include "utf8.h"
#include "engineerrors.h"
#include "i_interface.h"
static void I_CheckGUICapture ();
@ -251,32 +252,13 @@ static void MouseRead ()
}
}
CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
{
if (self < 0) self = 0;
else if (self > 2) self = 2;
}
static bool inGame()
{
switch (mouse_capturemode)
{
default:
case 0:
return gamestate == GS_LEVEL;
case 1:
return gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_FINALE;
case 2:
return true;
}
}
static void I_CheckNativeMouse ()
{
bool focus = SDL_GetKeyboardFocus() != NULL;
bool fs = screen->IsFullscreen();
bool wantNative = !focus || (!use_mouse || GUICapture || paused || demoplayback || !inGame());
bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame();
bool wantNative = !focus || (!use_mouse || GUICapture || paused || demoplayback || !captureModeInGame);
if (wantNative != NativeMouse)
{

View file

@ -32,9 +32,10 @@
*/
#include <SDL.h>
#include "doomdef.h"
#include "basics.h"
#include "templates.h"
#include "m_joy.h"
#include "keydef.h"
// Very small deadzone so that floating point magic doesn't happen
#define MIN_DEADZONE 0.000001f
@ -155,7 +156,7 @@ public:
FString GetIdentifier()
{
char id[16];
mysnprintf(id, countof(id), "JS:%d", DeviceIndex);
snprintf(id, countof(id), "JS:%d", DeviceIndex);
return id;
}

View file

@ -37,6 +37,7 @@
#include <sys/types.h>
#include "i_system.h"
#include "cmdlib.h"
#include "printf.h"
#include "engineerrors.h"
#include "version.h" // for GAMENAME
@ -152,33 +153,6 @@ FString M_GetAutoexecPath()
return GetUserFile("autoexec.cfg");
}
//===========================================================================
//
// M_GetCajunPath Unix
//
// Returns the location of the Cajun Bot definitions.
//
//===========================================================================
FString M_GetCajunPath(const char *botfilename)
{
FString path;
// Check first in $HOME/.config/zdoom/botfilename.
path = GetUserFile(botfilename);
if (!FileExists(path))
{
// Then check in SHARE_DIR/botfilename.
path = SHARE_DIR;
path << botfilename;
if (!FileExists(path))
{
path = "";
}
}
return path;
}
//===========================================================================
//
// M_GetConfigPath Unix
@ -217,7 +191,7 @@ FString M_GetScreenshotsPath()
FString M_GetSavegamesPath()
{
return NicePath("$HOME/" GAME_DIR);
return NicePath("$HOME/" GAME_DIR "/");
}
//===========================================================================
@ -230,5 +204,37 @@ FString M_GetSavegamesPath()
FString M_GetDocumentsPath()
{
return NicePath("$HOME/" GAME_DIR);
return NicePath("$HOME/" GAME_DIR "/");
}
//===========================================================================
//
// M_GetDemoPath Unix
//
// Returns the path to the default demo directory.
//
//===========================================================================
FString M_GetDemoPath()
{
return M_GetDocumentsPath() + "demo/";
}
//===========================================================================
//
// M_NormalizedPath
//
// Normalizes the given path and returns the result.
//
//===========================================================================
FString M_GetNormalizedPath(const char* path)
{
char *actualpath;
actualpath = realpath(path, NULL);
if (!actualpath) // error ?
return nullptr;
FString fullpath = actualpath;
return fullpath;
}

View file

@ -156,7 +156,8 @@ void InitPalette ()
ReadPalette(fileSystem.GetNumForName("PLAYPAL"), pal);
GPalette.SetPalette (pal);
GPalette.Init(NUM_TRANSLATION_TABLES);
GPalette.SetPalette (pal, 0);
MakeGoodRemap ((uint32_t*)GPalette.BaseColors, GPalette.Remap);
ColorMatcher.SetPalette ((uint32_t *)GPalette.BaseColors);

View file

@ -39,9 +39,10 @@
#include "hardware.h"
#include "c_dispatch.h"
#include "v_text.h"
#include "doomstat.h"
#include "basics.h"
#include "m_argv.h"
#include "version.h"
#include "printf.h"
#include "win32glvideo.h"
#include "win32polyvideo.h"
#ifdef HAVE_VULKAN
@ -49,7 +50,6 @@
#endif
#include "engineerrors.h"
#include "i_system.h"
#include "swrenderer/r_swrenderer.h"
EXTERN_CVAR(Int, vid_preferbackend)

View file

@ -68,14 +68,10 @@
#include "c_dispatch.h"
#include "doomdef.h"
#include "doomstat.h"
#include "m_argv.h"
#include "i_input.h"
#include "v_video.h"
#include "i_sound.h"
#include "g_game.h"
#include "d_main.h"
#include "d_gui.h"
#include "c_console.h"
#include "s_sound.h"
@ -84,11 +80,12 @@
#include "d_event.h"
#include "v_text.h"
#include "version.h"
#include "events.h"
#include "engineerrors.h"
#include "i_system.h"
#include "g_levellocals.h"
#include "i_interface.h"
#include "printf.h"
#include "c_buttons.h"
#include "cmdlib.h"
int32_t refreshfreq = -1;
@ -116,6 +113,7 @@ static HMODULE DInputDLL;
bool GUICapture;
extern FMouse *Mouse;
extern FKeyboard *Keyboard;
extern bool ToggleFullscreen;
bool VidResizing;
@ -136,8 +134,8 @@ static bool noidle = false;
LPDIRECTINPUT8 g_pdi;
LPDIRECTINPUT g_pdi3;
extern bool AppActive;
int SessionState = 0;
int BlockMouseMove;
@ -151,20 +149,7 @@ extern int chatmodeon;
static void I_CheckGUICapture ()
{
bool wantCapt;
if (menuactive == MENU_Off)
{
wantCapt = ConsoleState == c_down || ConsoleState == c_falling || chatmodeon;
}
else
{
wantCapt = (menuactive == MENU_On || menuactive == MENU_OnNoPause);
}
// [ZZ] check active event handlers that want the UI processing
if (!wantCapt && primaryLevel->localEventManager->CheckUiProcessors())
wantCapt = true;
bool wantCapt = sysCallbacks && sysCallbacks->WantGuiCapture && sysCallbacks->WantGuiCapture();
if (wantCapt != GUICapture)
{
@ -427,7 +412,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return result;
}
if ((gamestate == GS_DEMOSCREEN || gamestate == GS_TITLELEVEL) && message == WM_LBUTTONDOWN)
if (message == WM_LBUTTONDOWN && sysCallbacks && sysCallbacks->WantLeftButton() && sysCallbacks->WantLeftButton())
{
if (GUIWndProcHook(hWnd, message, wParam, lParam, &result))
{
@ -462,6 +447,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_SETFOCUS:
GetRefreshRate(hWnd);
I_CheckNativeMouse (false, EventHandlerResultForNativeMouse); // This cannot call the event handler. Doing it from here is unsafe.
break;
@ -539,7 +525,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS);
}
else if (!noidle && !netgame)
else if (!noidle && !(sysCallbacks && sysCallbacks->NetGame && sysCallbacks->NetGame()))
{
SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS);
}
@ -784,7 +770,7 @@ void I_StartTic ()
BlockMouseMove--;
buttonMap.ResetButtonTriggers ();
I_CheckGUICapture ();
EventHandlerResultForNativeMouse = primaryLevel->localEventManager->CheckRequireMouse();
EventHandlerResultForNativeMouse = sysCallbacks && sysCallbacks->WantNativeMouse && sysCallbacks->WantNativeMouse();
I_CheckNativeMouse (false, EventHandlerResultForNativeMouse);
I_GetEvent ();
}

View file

@ -34,8 +34,7 @@
#ifndef __I_INPUT_H__
#define __I_INPUT_H__
#include "doomtype.h"
#include "doomdef.h"
#include "basics.h"
bool I_InitInput (void *hwnd);
void I_ShutdownInput ();

View file

@ -41,10 +41,9 @@
#include "i_input.h"
#include "d_event.h"
#include "d_gui.h"
#include "g_game.h"
#include "hardware.h"
#include "menu/menu.h"
#include "events.h"
#include "i_interface.h"
// MACROS ------------------------------------------------------------------
@ -181,19 +180,6 @@ CUSTOM_CVAR (Int, in_mouse, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)
}
}
CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
{
if (self < 0)
{
self = 0;
}
else if (self > 2)
{
self = 2;
}
}
// CODE --------------------------------------------------------------------
//==========================================================================
@ -251,28 +237,6 @@ static void CenterMouse(int curx, int cury, LONG *centxp, LONG *centyp)
}
}
//==========================================================================
//
// CaptureMode_InGame
//
//==========================================================================
static bool CaptureMode_InGame()
{
if (mouse_capturemode == 2)
{
return true;
}
else if (mouse_capturemode == 1)
{
return gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_FINALE;
}
else
{
return gamestate == GS_LEVEL;
}
}
//==========================================================================
//
// I_CheckNativeMouse
@ -304,8 +268,9 @@ void I_CheckNativeMouse(bool preferNative, bool eventhandlerresult)
}
else
{
bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame();
want_native = ((!m_use_mouse || menuactive != MENU_WaitKey) &&
(!CaptureMode_InGame() || GUICapture || paused || demoplayback));
(!captureModeInGame || GUICapture ||paused || demoplayback));
}
}

View file

@ -42,6 +42,7 @@
#include "gameconfigfile.h"
#include "m_argv.h"
#include "cmdlib.h"
#include "keydef.h"
// MACROS ------------------------------------------------------------------

View file

@ -36,10 +36,11 @@
#include <windows.h>
#include <lmcons.h>
#include <shlobj.h>
#include <Shlwapi.h>
#include "printf.h"
#include "cmdlib.h"
#include "doomtype.h"
#include "m_misc.h"
#include "findfile.h"
#include "version.h" // for GAMENAME
// Vanilla MinGW does not have folder ids
@ -65,7 +66,7 @@ bool UseKnownFolders()
// Cache this value so the semantics don't change during a single run
// of the program. (e.g. Somebody could add write access while the
// program is running.)
static INTBOOL iswritable = -1;
static int iswritable = -1;
HANDLE file;
if (iswritable >= 0)
@ -125,8 +126,6 @@ FString M_GetAppDataPath(bool create)
{ // Failed (e.g. On Win9x): use program directory
path = progdir;
}
// Don't use GAME_DIR and such so that ZDoom and its child ports can
// share the node cache.
path += "/" GAMENAMELOWERCASE;
path.Substitute("//", "/"); // needed because progdir ends with a slash.
if (create)
@ -176,33 +175,13 @@ FString M_GetAutoexecPath()
return "$PROGDIR/autoexec.cfg";
}
//===========================================================================
//
// M_GetCajunPath Windows
//
// Returns the location of the Cajun Bot definitions.
//
//===========================================================================
FString M_GetCajunPath(const char *botfilename)
{
FString path;
path << progdir << "zcajun/" << botfilename;
if (!FileExists(path))
{
path = "";
}
return path;
}
//===========================================================================
//
// M_GetConfigPath Windows
//
// Returns the path to the config file. On Windows, this can vary for reading
// vs writing. i.e. If $PROGDIR/zdoom-<user>.ini does not exist, it will try
// to read from $PROGDIR/zdoom.ini, but it will never write to zdoom.ini.
// vs writing. i.e. If the user specific ini does not exist, it will try
// to read from a neutral version, but never write to it.
//
//===========================================================================
@ -211,7 +190,7 @@ FString M_GetConfigPath(bool for_reading)
FString path;
HRESULT hr;
path.Format("%s" GAMENAME "_portable.ini", progdir.GetChars());
path.Format("%s" GAMENAMELOWERCASE "_portable.ini", progdir.GetChars());
if (FileExists(path))
{
return path;
@ -226,12 +205,12 @@ FString M_GetConfigPath(bool for_reading)
path += "/" GAMENAMELOWERCASE ".ini";
}
else
{ // construct "$PROGDIR/zdoom-$USER.ini"
TCHAR uname[UNLEN+1];
DWORD unamelen = countof(uname);
{ // construct "$PROGDIR/-$USER.ini"
WCHAR uname[UNLEN+1];
DWORD unamelen = UNLEN;
path = progdir;
hr = GetUserName(uname, &unamelen);
hr = GetUserNameW(uname, &unamelen);
if (SUCCEEDED(hr) && uname[0] != 0)
{
// Is it valid for a user name to have slashes?
@ -246,13 +225,13 @@ FString M_GetConfigPath(bool for_reading)
path << GAMENAMELOWERCASE "-" << FString(uname) << ".ini";
}
else
{ // Couldn't get user name, so just use zdoom.ini
{ // Couldn't get user name, so just use base version.
path += GAMENAMELOWERCASE ".ini";
}
}
// If we are reading the config file, check if it exists. If not, fallback
// to $PROGDIR/zdoom.ini
// to base version.
if (for_reading)
{
if (!FileExists(path))
@ -283,19 +262,19 @@ FString M_GetScreenshotsPath()
if (!UseKnownFolders())
{
return progdir;
path << progdir << "/Screenshots/";
}
else if (GetKnownFolder(-1, MyFOLDERID_Screenshots, true, path))
{
path << "/" GAMENAME;
path << "/" GAMENAME "/";
}
else if (GetKnownFolder(CSIDL_MYPICTURES, FOLDERID_Pictures, true, path))
{
path << "/Screenshots/" GAMENAME;
path << "/Screenshots/" GAMENAME "/";
}
else
{
return progdir;
path << progdir << "/Screenshots/";
}
CreatePath(path);
return path;
@ -315,25 +294,25 @@ FString M_GetSavegamesPath()
if (!UseKnownFolders())
{
return progdir;
path << progdir << "Save/";
}
// Try standard Saved Games folder
else if (GetKnownFolder(-1, FOLDERID_SavedGames, true, path))
{
path << "/" GAMENAME;
path << "/" GAMENAME "/";
}
// Try defacto My Documents/My Games folder
else if (GetKnownFolder(CSIDL_PERSONAL, FOLDERID_Documents, true, path))
{
// I assume since this isn't a standard folder, it doesn't have
// a localized name either.
path << "/My Games/" GAMENAME;
CreatePath(path);
path << "/My Games/" GAMENAME "/";
}
else
{
path = progdir;
path << progdir << "Save/";
}
return path;
}
@ -365,7 +344,7 @@ FString M_GetDocumentsPath()
{
// I assume since this isn't a standard folder, it doesn't have
// a localized name either.
path << "/My Games/" GAMENAME;
path << "/My Games/" GAMENAME "/";
CreatePath(path);
}
else
@ -374,3 +353,55 @@ FString M_GetDocumentsPath()
}
return path;
}
//===========================================================================
//
// M_GetDemoPath Windows
//
// Returns the path to the default demp directory.
//
//===========================================================================
FString M_GetDemoPath()
{
FString path;
// A portable INI means that this storage location should also be portable.
FStringf inipath("%s" GAMENAME "_portable.ini", progdir.GetChars());
if (FileExists(inipath) || !UseKnownFolders())
{
path << progdir << "Demos/";
}
else
// Try defacto My Documents/My Games folder
if (GetKnownFolder(CSIDL_PERSONAL, FOLDERID_Documents, true, path))
{
// I assume since this isn't a standard folder, it doesn't have
// a localized name either.
path << "/My Games/" GAMENAME "/";
}
else
{
path << progdir << "Demos/";
}
return path;
}
//===========================================================================
//
// M_NormalizedPath
//
// Normalizes the given path and returns the result.
//
//===========================================================================
FString M_GetNormalizedPath(const char* path)
{
std::wstring wpath = WideString(path);
wchar_t buffer[MAX_PATH];
GetFullPathNameW(wpath.c_str(), MAX_PATH, buffer, nullptr);
FString result(buffer);
FixPathSeperator(result);
return result;
}

View file

@ -141,43 +141,12 @@ int sys_ostype = 0;
// PRIVATE DATA DEFINITIONS ------------------------------------------------
static ticcmd_t emptycmd;
static WadStuff *WadList;
static int NumWads;
static int DefaultWad;
static HCURSOR CustomCursor;
//==========================================================================
//
// I_Tactile
//
// Doom calls it when you take damage, so presumably it could be converted
// to something compatible with force feedback.
//
//==========================================================================
void I_Tactile(int on, int off, int total)
{
// UNUSED.
on = off = total = 0;
}
//==========================================================================
//
// I_BaseTiccmd
//
// Returns an empty ticcmd. I have no idea why this should be system-
// specific.
//
//==========================================================================
ticcmd_t *I_BaseTiccmd()
{
return &emptycmd;
}
//==========================================================================
//
// I_DetectOS

View file

@ -78,8 +78,6 @@ ticcmd_t *I_BaseTiccmd (void);
void I_Quit (void);
void I_Tactile (int on, int off, int total);
// Set the mouse cursor. The texture must be 32x32.
class FTexture;
bool I_SetCursor(FTexture *cursor);

View file

@ -44,6 +44,7 @@
#include "gameconfigfile.h"
#include "m_argv.h"
#include "cmdlib.h"
#include "keydef.h"
// MACROS ------------------------------------------------------------------

View file

@ -45,10 +45,10 @@
#include "v_video.h"
#include "i_input.h"
#include "i_system.h"
#include "doomstat.h"
#include "v_text.h"
#include "m_argv.h"
#include "engineerrors.h"
#include "printf.h"
#include "win32basevideo.h"
#include "cmdlib.h"

View file

@ -34,6 +34,7 @@
#include <windows.h>
#include <GL/gl.h>
#include <vector>
#include "wglext.h"
#include "gl_sysfb.h"
@ -45,9 +46,9 @@
#include "v_video.h"
#include "i_input.h"
#include "i_system.h"
#include "doomstat.h"
#include "v_text.h"
#include "m_argv.h"
#include "printf.h"
#include "engineerrors.h"
#include "win32glvideo.h"
@ -415,8 +416,8 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample)
if (myWglCreateContextAttribsARB != NULL)
{
// let's try to get the best version possible. Some drivers only give us the version we request
// which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.0 is a requirement.
static int versions[] = { 46, 45, 44, 43, 42, 41, 40, 33, 32, 31, 30, -1 };
// which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.3 is a requirement.
static int versions[] = { 46, 45, 44, 43, 42, 41, 40, 33, -1 };
for (int i = 0; versions[i] > 0; i++)
{