diff --git a/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp b/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp index c756774d0..e45a59777 100644 --- a/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp +++ b/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp @@ -122,19 +122,7 @@ ClientModeHL2MPNormal::ClientModeHL2MPNormal() m_pViewport = new CHudViewport(); m_pViewport->Start(gameuifuncs, gameeventmanager); #ifdef NEO - ConVarRef cl_software_cursor( "cl_software_cursor" ); - Assert(cl_software_cursor.IsValid()); - if (cl_software_cursor.IsValid()) - { - if (auto* surface = vgui::surface()) - { - surface->SetSoftwareCursor(cl_software_cursor.GetBool()); - } - else - { - Assert(false); - } - } + SwCursorHack_RestoreValue(); #endif } diff --git a/src/game/client/neo/ui/neo_loading.cpp b/src/game/client/neo/ui/neo_loading.cpp index bb4159598..ab40a4c62 100644 --- a/src/game/client/neo/ui/neo_loading.cpp +++ b/src/game/client/neo/ui/neo_loading.cpp @@ -93,11 +93,9 @@ void CNeoLoading::OnMessage(const KeyValues *params, vgui::VPANEL fromPanel) else if (V_strcmp(pSzMsgName, "deactivate") == 0) { g_pNeoRoot->m_bOnLoadingScreen = false; - static ConVarRef cl_software_cursor( "cl_software_cursor" ); // Revert the software cursor option back to user preference once we exit the loading screen. - Assert(cl_software_cursor.IsValid()); - vgui::surface()->SetSoftwareCursor(cl_software_cursor.GetBool()); + SwCursorHack_RestoreValue(); if (engine->IsConnected() && !engine->IsLevelMainMenuBackground()) { diff --git a/src/game/client/neo/ui/neo_root_settings.cpp b/src/game/client/neo/ui/neo_root_settings.cpp index 8057264bf..c765e2b33 100644 --- a/src/game/client/neo/ui/neo_root_settings.cpp +++ b/src/game/client/neo/ui/neo_root_settings.cpp @@ -12,6 +12,7 @@ #include #include #include "vgui/ISystem.h" +#include "view.h" #include "voice_status.h" #include "neo_ui.h" @@ -662,7 +663,7 @@ void NeoSettingsRestore(NeoSettings *ns, const NeoSettings::Keys::Flags flagsKey pVideo->flGamma = cvr->mat_monitorgamma.GetFloat(); pVideo->iFov = cvr->neo_fov.GetInt(); pVideo->iViewmodelFov = cvr->neo_viewmodel_fov_offset.GetInt(); - pVideo->bSoftwareCursor = cvr->cl_software_cursor.GetBool(); + pVideo->iSoftwareCursor = cvr->cl_software_cursor.GetInt(); } { NeoSettings::Crosshair *pCrosshair = &ns->crosshair; @@ -933,7 +934,7 @@ void NeoSettingsSave(const NeoSettings *ns) cvr->mat_monitorgamma.SetValue(pVideo->flGamma); cvr->neo_fov.SetValue(pVideo->iFov); cvr->neo_viewmodel_fov_offset.SetValue(pVideo->iViewmodelFov); - cvr->cl_software_cursor.SetValue(pVideo->bSoftwareCursor); + cvr->cl_software_cursor.SetValue(pVideo->iSoftwareCursor); } { const NeoSettings::Crosshair *pCrosshair = &ns->crosshair; @@ -1353,7 +1354,9 @@ void NeoSettings_Video(NeoSettings *ns) NeoUI::Slider(L"Gamma", &pVideo->flGamma, 1.6, 2.6, 2, 0.1f); NeoUI::SliderInt(L"FOV", &pVideo->iFov, MIN_FOV, MAX_FOV); NeoUI::SliderInt(L"Viewmodel FOV Offset", &pVideo->iViewmodelFov, -20, 40); - NeoUI::RingBoxBool(L"Software Cursor", &pVideo->bSoftwareCursor); +#ifndef LINUX // disabled on Linux for now, see bug #2114 + NeoUI::RingBoxFlag(L"Software Cursor", ESoftwareCursor::EnabledForPlatform, &pVideo->iSoftwareCursor); +#endif NeoUI::Divider(L"VISUALS"); NeoUI::RingBox(L"Model detail", QUALITY_LABELS, 3, &pVideo->iModelDetail); diff --git a/src/game/client/neo/ui/neo_root_settings.h b/src/game/client/neo/ui/neo_root_settings.h index 6065ce8cc..966c0b0d0 100644 --- a/src/game/client/neo/ui/neo_root_settings.h +++ b/src/game/client/neo/ui/neo_root_settings.h @@ -161,7 +161,7 @@ struct NeoSettings float flGamma; int iFov; int iViewmodelFov; - bool bSoftwareCursor; + int iSoftwareCursor; // Video modes int iVMListSize; diff --git a/src/game/client/view.cpp b/src/game/client/view.cpp index 7e792a1f1..e5ef02894 100644 --- a/src/game/client/view.cpp +++ b/src/game/client/view.cpp @@ -147,15 +147,24 @@ static ConVar r_farz( "r_farz", "-1", FCVAR_CHEAT, "Override the far clipping pl static ConVar cl_demoviewoverride( "cl_demoviewoverride", "0", 0, "Override view during demo playback" ); +#ifdef NEO +static ConVar cl_software_cursor( "cl_software_cursor", "1", FCVAR_ARCHIVE, + "Switches the game to use a larger software cursor instead of the normal OS cursor. " + "Set as bitflags. 1: enabled for Windows, 2: enabled for Linux, 3: enabled for both", + true, ESoftwareCursor::Disabled, true, ESoftwareCursor::Maximum, + [](IConVar*, const char*, float) { SwCursorHack_RestoreValue(); }); +void SwCursorHack_RestoreValue() +{ + bool enabled = (cl_software_cursor.GetInt() & ESoftwareCursor::EnabledForPlatform); + vgui::surface()->SetSoftwareCursor(enabled || UseVR()); +} +#else +static ConVar cl_software_cursor ( "cl_software_cursor", "0", FCVAR_ARCHIVE, "Switches the game to use a larger software cursor instead of the normal OS cursor", SoftwareCursorChangedCB ); void SoftwareCursorChangedCB( IConVar *pVar, const char *pOldValue, float fOldValue ) { ConVar *pConVar = (ConVar *)pVar; vgui::surface()->SetSoftwareCursor( pConVar->GetBool() || UseVR() ); } -#ifdef NEO -static ConVar cl_software_cursor ( "cl_software_cursor", "1", FCVAR_ARCHIVE, "Switches the game to use a larger software cursor instead of the normal OS cursor", SoftwareCursorChangedCB ); -#else -static ConVar cl_software_cursor ( "cl_software_cursor", "0", FCVAR_ARCHIVE, "Switches the game to use a larger software cursor instead of the normal OS cursor", SoftwareCursorChangedCB ); #endif @@ -343,6 +352,8 @@ void CViewRender::Init( void ) #endif #ifdef NEO + SwCursorHack_RestoreValue(); + ITexture *pDepthOld = materials->FindTexture("_rt_FullFrameDepth", TEXTURE_GROUP_RENDER_TARGET); const bool bDepthTexOk = ((pDepthOld != NULL) && (!pDepthOld->IsError())); const int flags = (bDepthTexOk ? pDepthOld->GetFlags() : TEXTUREFLAGS_NOMIP | diff --git a/src/game/client/view.h b/src/game/client/view.h index 754c2ab3a..afaf976b0 100644 --- a/src/game/client/view.h +++ b/src/game/client/view.h @@ -20,6 +20,25 @@ class Vector; class QAngle; class VPlane; +#ifdef NEO +enum ESoftwareCursor // stored in user configs, don't reorder +{ + Disabled = 0, + EnabledForWindows = (1 << 0), + EnabledForLinux = (1 << 1), + +#ifdef _WIN32 + EnabledForPlatform = EnabledForWindows, +#elif defined(LINUX) + EnabledForPlatform = EnabledForLinux, +#else + EnabledForPlatform = 0, +#endif + Maximum = (EnabledForWindows | EnabledForLinux) +}; + +void SwCursorHack_RestoreValue(); +#endif // near and far Z it uses to render the world. #ifdef NEO