diff --git a/source/common/console/c_cvars.cpp b/source/common/console/c_cvars.cpp index 111bad99c..6fd6e4271 100644 --- a/source/common/console/c_cvars.cpp +++ b/source/common/console/c_cvars.cpp @@ -150,6 +150,11 @@ const char *FBaseCVar::GetHumanString(int precision) const return GetGenericRep(CVAR_String).String; } +const char *FBaseCVar::GetHumanStringDefault(int precision) const +{ + return GetGenericRepDefault(CVAR_String).String; +} + void FBaseCVar::ForceSet (UCVarValue value, ECVarType type, bool nouserinfosend) { DoSet (value, type); @@ -653,6 +658,16 @@ const char *FFloatCVar::GetHumanString(int precision) const return cstrbuf; } +const char *FFloatCVar::GetHumanStringDefault(int precision) const +{ + if (precision < 0) + { + precision = 6; + } + mysnprintf(cstrbuf, countof(cstrbuf), "%.*g", precision, DefaultValue); + return cstrbuf; +} + UCVarValue FFloatCVar::GetGenericRep (ECVarType type) const { return FromFloat (Value, type); diff --git a/source/common/console/c_cvars.h b/source/common/console/c_cvars.h index 567475c70..abbe31a4b 100644 --- a/source/common/console/c_cvars.h +++ b/source/common/console/c_cvars.h @@ -161,6 +161,7 @@ public: virtual UCVarValue GetGenericRep (ECVarType type) const = 0; virtual UCVarValue GetFavoriteRep (ECVarType *type) const = 0; + virtual const char *GetHumanStringDefault(int precision = -1) const; virtual UCVarValue GetGenericRepDefault (ECVarType type) const = 0; virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const = 0; virtual void SetGenericRepDefault (UCVarValue value, ECVarType type) = 0; @@ -339,6 +340,7 @@ public: virtual UCVarValue GetFavoriteRepDefault (ECVarType *type) const override; virtual void SetGenericRepDefault (UCVarValue value, ECVarType type) override; const char *GetHumanString(int precision) const override; + const char *GetHumanStringDefault(int precision) const override; float operator= (float floatval) { UCVarValue val; val.Float = floatval; SetGenericRep (val, CVAR_Float); return floatval; } diff --git a/source/common/console/c_dispatch.cpp b/source/common/console/c_dispatch.cpp index cc050fea5..bcb52ba7e 100644 --- a/source/common/console/c_dispatch.cpp +++ b/source/common/console/c_dispatch.cpp @@ -302,7 +302,8 @@ void C_DoCommand (const char *cmd, int keynum) else { // Get the variable's value if (var->GetDescription().Len()) Printf("%s\n", GStrings.localize(var->GetDescription())); - Printf ("\"%s\" is \"%s\"\n", var->GetName(), var->GetHumanString()); + Printf ("\"%s\" is \"%s\" ", var->GetName(), var->GetHumanString()); + Printf ("(default: \"%s\")\n", var->GetHumanStringDefault()); } } else diff --git a/source/common/engine/d_event.cpp b/source/common/engine/d_event.cpp index 9c612cf3d..effb5dc3a 100644 --- a/source/common/engine/d_event.cpp +++ b/source/common/engine/d_event.cpp @@ -137,7 +137,7 @@ void D_PostEvent(event_t* ev) { return; } - if (sysCallbacks && sysCallbacks->DispatchEvent && sysCallbacks->DispatchEvent(ev)) + if (sysCallbacks.DispatchEvent && sysCallbacks.DispatchEvent(ev)) return; events[eventhead] = *ev; diff --git a/source/common/engine/i_interface.cpp b/source/common/engine/i_interface.cpp index 90d0df385..613c3d5de 100644 --- a/source/common/engine/i_interface.cpp +++ b/source/common/engine/i_interface.cpp @@ -1,7 +1,7 @@ #include "i_interface.h" // Some global engine variables taken out of the backend code. -SystemCallbacks *sysCallbacks; +SystemCallbacks sysCallbacks; FString endoomName; bool batchrun; float menuBlurAmount; diff --git a/source/common/engine/i_interface.h b/source/common/engine/i_interface.h index 7207df14f..80cc3b1e9 100644 --- a/source/common/engine/i_interface.h +++ b/source/common/engine/i_interface.h @@ -24,7 +24,7 @@ struct SystemCallbacks bool (*DispatchEvent)(event_t* ev); }; -extern SystemCallbacks *sysCallbacks; +extern SystemCallbacks sysCallbacks; struct WadStuff { diff --git a/source/common/engine/i_net.cpp b/source/common/engine/i_net.cpp index d20673dfb..94388656f 100644 --- a/source/common/engine/i_net.cpp +++ b/source/common/engine/i_net.cpp @@ -162,7 +162,7 @@ uint8_t TransmitBuffer[TRANSMIT_SIZE]; FString GetPlayerName(int num) { - if (sysCallbacks && sysCallbacks->GetPlayerName) return sysCallbacks->GetPlayerName(sendplayer[num]); + if (sysCallbacks.GetPlayerName) return sysCallbacks.GetPlayerName(sendplayer[num]); else return FStringf("Player %d", sendplayer[num] + 1); } diff --git a/source/common/engine/namedef.h b/source/common/engine/namedef.h index 53fca85d0..e6bdcee92 100644 --- a/source/common/engine/namedef.h +++ b/source/common/engine/namedef.h @@ -660,7 +660,10 @@ xx(Static) xx(Staticconst) xx(DeathmatchStatusScreen) xx(CoopStatusScreen) +xx(DoomStatusScreen) xx(RavenStatusScreen) +xx(DoomStatusScreenSized) +xx(RavenStatusScreenSized) xx(StatusbarWidget) xx(StatusbarHead) xx(StatusbarCondition) @@ -1076,3 +1079,10 @@ xx(NewPlayerMenu) xx(AltHud) xx(GameScreen) +// summary +xx(cwidth) +xx(cheight) +xx(wrapwidth) +xx(scalefactorx) +xx(scalefactory) +xx(scalemode) diff --git a/source/common/engine/serializer.h b/source/common/engine/serializer.h index b25aeeb0f..6110ca4b4 100644 --- a/source/common/engine/serializer.h +++ b/source/common/engine/serializer.h @@ -265,7 +265,8 @@ inline FSerializer &Serialize(FSerializer &arc, const char *key, DVector2 &p, DV return arc.Array(key, &p[0], def? &(*def)[0] : nullptr, 2, true); } -inline FSerializer &Serialize(FSerializer &arc, const char *key, DAngle &p, DAngle *def) +template +inline FSerializer &Serialize(FSerializer &arc, const char *key, TAngle &p, TAngle *def) { return Serialize(arc, key, p.Degrees, def? &def->Degrees : nullptr); } diff --git a/source/common/platform/posix/cocoa/i_input.mm b/source/common/platform/posix/cocoa/i_input.mm index a9b9443a0..6782eca78 100644 --- a/source/common/platform/posix/cocoa/i_input.mm +++ b/source/common/platform/posix/cocoa/i_input.mm @@ -73,7 +73,7 @@ size_t s_skipMouseMoves; void CheckGUICapture() { - bool wantCapt = sysCallbacks && sysCallbacks->WantGuiCapture && sysCallbacks->WantGuiCapture(); + bool wantCapt = sysCallbacks.WantGuiCapture && sysCallbacks.WantGuiCapture(); if (wantCapt != GUICapture) { @@ -149,7 +149,7 @@ void CheckNativeMouse() } else { - bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame(); + bool captureModeInGame = sysCallbacks.CaptureModeInGame && sysCallbacks.CaptureModeInGame(); wantNative = (!m_use_mouse || MENU_WaitKey != menuactive) && (!captureModeInGame || GUICapture); } @@ -161,7 +161,7 @@ void CheckNativeMouse() && (MENU_On == menuactive || MENU_OnNoPause == menuactive); } - if (!wantNative && sysCallbacks && sysCallbacks->WantNativeMouse && sysCallbacks->WantNativeMouse()) + if (!wantNative && sysCallbacks.WantNativeMouse && sysCallbacks.WantNativeMouse()) wantNative = true; I_SetNativeMouse(wantNative); diff --git a/source/common/platform/posix/osx/iwadpicker_cocoa.mm b/source/common/platform/posix/osx/iwadpicker_cocoa.mm index d751a1edd..bb7cdd0a6 100644 --- a/source/common/platform/posix/osx/iwadpicker_cocoa.mm +++ b/source/common/platform/posix/osx/iwadpicker_cocoa.mm @@ -66,8 +66,8 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" }; - (void)dealloc; - (IWADTableData *)init:(WadStuff *) wads num:(int) numwads; -- (int)numberOfRowsInTableView:(NSTableView *)aTableView; -- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex; +- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView; +- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex; @end @implementation IWADTableData @@ -100,12 +100,12 @@ static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" }; return self; } -- (int)numberOfRowsInTableView:(NSTableView *)aTableView +- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView { return [data count]; } -- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex +- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { NSParameterAssert(rowIndex >= 0 && (unsigned int) rowIndex < [data count]); NSMutableDictionary *record = [data objectAtIndex:rowIndex]; diff --git a/source/common/platform/posix/sdl/i_input.cpp b/source/common/platform/posix/sdl/i_input.cpp index 1ad9fa65d..a102b38a8 100644 --- a/source/common/platform/posix/sdl/i_input.cpp +++ b/source/common/platform/posix/sdl/i_input.cpp @@ -165,7 +165,7 @@ static const TMap KeyScanToDIK(InitKeyScanMap()); static void I_CheckGUICapture () { - bool wantCapt = sysCallbacks && sysCallbacks->WantGuiCapture && sysCallbacks->WantGuiCapture(); + bool wantCapt = sysCallbacks.WantGuiCapture && sysCallbacks.WantGuiCapture(); if (wantCapt != GUICapture) { @@ -206,10 +206,10 @@ static void I_CheckNativeMouse () { bool focus = SDL_GetKeyboardFocus() != NULL; - bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame(); + bool captureModeInGame = sysCallbacks.CaptureModeInGame && sysCallbacks.CaptureModeInGame(); bool wantNative = !focus || (!use_mouse || GUICapture || !captureModeInGame); - if (!wantNative && sysCallbacks && sysCallbacks->WantNativeMouse && sysCallbacks->WantNativeMouse()) + if (!wantNative && sysCallbacks.WantNativeMouse && sysCallbacks.WantNativeMouse()) wantNative = true; if (wantNative != NativeMouse) diff --git a/source/common/platform/posix/sdl/i_main.cpp b/source/common/platform/posix/sdl/i_main.cpp index 7fc179a51..a984721fc 100644 --- a/source/common/platform/posix/sdl/i_main.cpp +++ b/source/common/platform/posix/sdl/i_main.cpp @@ -87,7 +87,7 @@ FArgs *Args; static int GetCrashInfo (char *buffer, char *end) { - if (sysCallbacks && sysCallbacks->CrashInfo) sysCallbacks->CrashInfo(buffer, end - buffer, "\n"); + if (sysCallbacks.CrashInfo) sysCallbacks.CrashInfo(buffer, end - buffer, "\n"); return strlen(buffer); } diff --git a/source/common/platform/win32/i_input.cpp b/source/common/platform/win32/i_input.cpp index c9cc13609..1b49f5680 100644 --- a/source/common/platform/win32/i_input.cpp +++ b/source/common/platform/win32/i_input.cpp @@ -147,7 +147,7 @@ extern int chatmodeon; static void I_CheckGUICapture () { - bool wantCapt = sysCallbacks && sysCallbacks->WantGuiCapture && sysCallbacks->WantGuiCapture(); + bool wantCapt = sysCallbacks.WantGuiCapture && sysCallbacks.WantGuiCapture(); if (wantCapt != GUICapture) { @@ -394,7 +394,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return result; } - if (message == WM_LBUTTONDOWN && sysCallbacks && sysCallbacks->WantLeftButton() && sysCallbacks->WantLeftButton()) + if (message == WM_LBUTTONDOWN && sysCallbacks.WantLeftButton() && sysCallbacks.WantLeftButton()) { if (GUIWndProcHook(hWnd, message, wParam, lParam, &result)) { @@ -504,7 +504,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS); } - else if (!noidle && !(sysCallbacks && sysCallbacks->NetGame && sysCallbacks->NetGame())) + else if (!noidle && !(sysCallbacks.NetGame && sysCallbacks.NetGame())) { SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS); } @@ -749,7 +749,7 @@ void I_StartTic () BlockMouseMove--; buttonMap.ResetButtonTriggers (); I_CheckGUICapture (); - EventHandlerResultForNativeMouse = sysCallbacks && sysCallbacks->WantNativeMouse && sysCallbacks->WantNativeMouse(); + EventHandlerResultForNativeMouse = sysCallbacks.WantNativeMouse && sysCallbacks.WantNativeMouse(); I_CheckNativeMouse (false, EventHandlerResultForNativeMouse); I_GetEvent (); } diff --git a/source/common/platform/win32/i_main.cpp b/source/common/platform/win32/i_main.cpp index f0bacc0b7..6e1b2ea33 100644 --- a/source/common/platform/win32/i_main.cpp +++ b/source/common/platform/win32/i_main.cpp @@ -1108,7 +1108,7 @@ LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info) char *custominfo = (char *)HeapAlloc (GetProcessHeap(), 0, 16384); CrashPointers = *info; - if (sysCallbacks && sysCallbacks->CrashInfo && custominfo) sysCallbacks->CrashInfo(custominfo, 16384, "\r\n"); + if (sysCallbacks.CrashInfo && custominfo) sysCallbacks.CrashInfo(custominfo, 16384, "\r\n"); CreateCrashLog (custominfo, (DWORD)strlen(custominfo), ConWindow); // If the main thread crashed, then make it clean up after itself. diff --git a/source/common/platform/win32/i_mouse.cpp b/source/common/platform/win32/i_mouse.cpp index b4a15a494..a3042236a 100644 --- a/source/common/platform/win32/i_mouse.cpp +++ b/source/common/platform/win32/i_mouse.cpp @@ -269,7 +269,7 @@ void I_CheckNativeMouse(bool preferNative, bool eventhandlerresult) else { bool pauseState = false; - bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame(); + bool captureModeInGame = sysCallbacks.CaptureModeInGame && sysCallbacks.CaptureModeInGame(); want_native = ((!m_use_mouse || menuactive != MENU_WaitKey) && (!captureModeInGame || GUICapture)); } diff --git a/source/common/platform/win32/st_start_util.cpp b/source/common/platform/win32/st_start_util.cpp index 047aa8310..8c6074863 100644 --- a/source/common/platform/win32/st_start_util.cpp +++ b/source/common/platform/win32/st_start_util.cpp @@ -396,8 +396,8 @@ static const int StrifeStartupPicSizes[4 + 2 + 1] = static void ST_Sound(const char* sndname) { - if (sysCallbacks && sysCallbacks->PlayStartupSound) - sysCallbacks->PlayStartupSound(sndname); + if (sysCallbacks.PlayStartupSound) + sysCallbacks.PlayStartupSound(sndname); } //========================================================================== diff --git a/source/common/rendering/gl/gl_samplers.cpp b/source/common/rendering/gl/gl_samplers.cpp index a03c1c40d..0e2ef0546 100644 --- a/source/common/rendering/gl/gl_samplers.cpp +++ b/source/common/rendering/gl/gl_samplers.cpp @@ -119,7 +119,7 @@ void FSamplerManager::SetTextureFilterMode() glBindSampler(i, 0); } - int filter = sysCallbacks && sysCallbacks->DisableTextureFilter && sysCallbacks->DisableTextureFilter() ? 0 : gl_texture_filter; + int filter = sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter() ? 0 : gl_texture_filter; for (int i = 0; i < 4; i++) { diff --git a/source/common/rendering/hwrenderer/data/hw_clock.cpp b/source/common/rendering/hwrenderer/data/hw_clock.cpp index 84576875b..e9affdbe6 100644 --- a/source/common/rendering/hwrenderer/data/hw_clock.cpp +++ b/source/common/rendering/hwrenderer/data/hw_clock.cpp @@ -166,7 +166,7 @@ void CheckBench() FString compose; - if (sysCallbacks && sysCallbacks->GetLocationDescription) compose = sysCallbacks->GetLocationDescription(); + if (sysCallbacks.GetLocationDescription) compose = sysCallbacks.GetLocationDescription(); AppendRenderStats(compose); AppendRenderTimes(compose); diff --git a/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp b/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp index 17bfefaef..bde88b5a7 100644 --- a/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp +++ b/source/common/rendering/hwrenderer/data/hw_vrmodes.cpp @@ -61,7 +61,7 @@ static VRMode vrmi_checker = { 2, isqrt2, isqrt2, 1.f,{ { -.5f, 1.f },{ .5f, 1.f const VRMode *VRMode::GetVRMode(bool toscreen) { #ifdef VR3D_ENABLED - int mode = !toscreen || (sysCallbacks && sysCallbacks->DisableTextureFilter && sysCallbacks->DisableTextureFilter()) ? 0 : vr_mode; + int mode = !toscreen || (sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter()) ? 0 : vr_mode; switch (mode) { diff --git a/source/common/rendering/r_videoscale.cpp b/source/common/rendering/r_videoscale.cpp index dee86723e..1f5a7bb38 100644 --- a/source/common/rendering/r_videoscale.cpp +++ b/source/common/rendering/r_videoscale.cpp @@ -107,7 +107,7 @@ namespace static bool lastspecialUI = false; bool isInActualMenu = false; - bool specialUI = sysCallbacks && (!sysCallbacks->IsSpecialUI || sysCallbacks->IsSpecialUI()); + bool specialUI = (!sysCallbacks.IsSpecialUI || sysCallbacks.IsSpecialUI()); if (specialUI == lastspecialUI) return; diff --git a/source/common/rendering/v_framebuffer.cpp b/source/common/rendering/v_framebuffer.cpp index 4d55989c3..747a37c6e 100644 --- a/source/common/rendering/v_framebuffer.cpp +++ b/source/common/rendering/v_framebuffer.cpp @@ -200,7 +200,7 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds) mScreenViewport.height = screenHeight; // Viewport for the 3D scene - if (sysCallbacks && sysCallbacks->GetSceneRect) mSceneViewport = sysCallbacks->GetSceneRect(); + if (sysCallbacks.GetSceneRect) mSceneViewport = sysCallbacks.GetSceneRect(); else mSceneViewport = mScreenViewport; // Scale viewports to fit letterbox diff --git a/source/common/rendering/v_video.cpp b/source/common/rendering/v_video.cpp index 435768c98..3cf9f7bb1 100644 --- a/source/common/rendering/v_video.cpp +++ b/source/common/rendering/v_video.cpp @@ -116,8 +116,8 @@ CUSTOM_CVAR(Int, uiscale, 0, CVAR_ARCHIVE | CVAR_NOINITCALL) self = 0; return; } - if (sysCallbacks && sysCallbacks->OnScreenSizeChanged) - sysCallbacks->OnScreenSizeChanged(); + if (sysCallbacks.OnScreenSizeChanged) + sysCallbacks.OnScreenSizeChanged(); setsizeneeded = true; } @@ -294,8 +294,8 @@ void V_OutputResized (int width, int height) twod->End(); setsizeneeded = true; C_NewModeAdjust(); - if (sysCallbacks && sysCallbacks->OnScreenSizeChanged) - sysCallbacks->OnScreenSizeChanged(); + if (sysCallbacks.OnScreenSizeChanged) + sysCallbacks.OnScreenSizeChanged(); } bool IVideo::SetResolution () @@ -392,8 +392,8 @@ void V_Init2() CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) { setsizeneeded = true; - if (sysCallbacks && sysCallbacks->OnScreenSizeChanged) - sysCallbacks->OnScreenSizeChanged(); + if (sysCallbacks.OnScreenSizeChanged) + sysCallbacks.OnScreenSizeChanged(); } DEFINE_ACTION_FUNCTION(_Screen, GetAspectRatio) diff --git a/source/common/rendering/vulkan/textures/vk_samplers.cpp b/source/common/rendering/vulkan/textures/vk_samplers.cpp index 2a616e293..adc6dd2b4 100644 --- a/source/common/rendering/vulkan/textures/vk_samplers.cpp +++ b/source/common/rendering/vulkan/textures/vk_samplers.cpp @@ -81,7 +81,7 @@ void VkSamplerManager::SetTextureFilterMode() void VkSamplerManager::Create() { - int filter = sysCallbacks && sysCallbacks->DisableTextureFilter && sysCallbacks->DisableTextureFilter()? 0 : gl_texture_filter; + int filter = sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter()? 0 : gl_texture_filter; for (int i = CLAMP_NONE; i <= CLAMP_XY; i++) { diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index af57a1e29..23cd4b0eb 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -498,7 +498,7 @@ int GameMain() { int r; - static SystemCallbacks syscb = + sysCallbacks = { System_WantGuiCapture, System_WantLeftButton, @@ -516,7 +516,6 @@ int GameMain() nullptr, System_DispatchEvent, }; - sysCallbacks = &syscb; try {