diff --git a/src/game/client/swarm/asw_in_mouse.cpp b/src/game/client/swarm/asw_in_mouse.cpp index 046e28034..783bb403f 100644 --- a/src/game/client/swarm/asw_in_mouse.cpp +++ b/src/game/client/swarm/asw_in_mouse.cpp @@ -15,6 +15,9 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +bool g_ultra_wide_screen = false; +Rect_t g_clamp_area = {}; + ConVar glow_outline_color_active( "glow_outline_color_active", "153 153 204", FCVAR_NONE ); ConVar glow_outline_color_inactive( "glow_outline_color_inactive", "77 77 77", FCVAR_NONE ); @@ -85,6 +88,36 @@ void CASWInput::ApplyMouse( int nSlot, QAngle& viewangles, CUserCmd *cmd, float int current_posx, current_posy; GetMousePos(current_posx, current_posy); + // restrict cursor to 16:9 area to prevent ultra-wide fov cheat + g_ultra_wide_screen = false; + C_ASW_Player* asw_player = C_ASW_Player::GetLocalASWPlayer(); + + if (asw_player && !asw_player->GetSpectatingNPC()) { + int screen_w = ScreenWidth(); + int screen_h = ScreenHeight(); + float aspect = static_cast(screen_w) / screen_h; + + constexpr float ratio169 = 16.0f / 9.0f; + + if (aspect > ratio169) { + g_ultra_wide_screen = true; + + int target_h = screen_h; + int target_w = static_cast(screen_h * ratio169); + + int left = (screen_w - target_w) / 2; + int top = 0; + + g_clamp_area.x = left; + g_clamp_area.y = top; + g_clamp_area.width = left + target_w; + g_clamp_area.height = top + target_h; + + current_posx = clamp(current_posx, g_clamp_area.x, g_clamp_area.width); + current_posy = clamp(current_posy, g_clamp_area.y, g_clamp_area.height); + } + } + if ( ASWInput()->ControllerModeActiveMouse() ) return; diff --git a/src/game/client/swarm/vgui/asw_hud_master.cpp b/src/game/client/swarm/vgui/asw_hud_master.cpp index 9b50772c7..e574a2747 100644 --- a/src/game/client/swarm/vgui/asw_hud_master.cpp +++ b/src/game/client/swarm/vgui/asw_hud_master.cpp @@ -36,12 +36,18 @@ extern ConVar asw_hud_alpha; extern ConVar rd_respawn_time; extern ConVar rd_hud_hide_clips; +extern bool g_ultra_wide_screen; +extern Rect_t g_clamp_area; + ConVar rd_draw_avatars_with_frags( "rd_draw_avatars_with_frags", "1", FCVAR_ARCHIVE, "If 1 In PvP modes a panel with avatars and frags will be shown at top of the screen"); ConVar rd_draw_portraits( "rd_draw_portraits", "1", FCVAR_NONE ); ConVar rd_draw_timer( "rd_draw_timer", "0", FCVAR_ARCHIVE, "Display the current mission time at the top of the screen" ); ConVar rd_draw_timer_color( "rd_draw_timer_color", "255 255 255 255", FCVAR_ARCHIVE, "The color of the current mission time" ); ConVar rd_draw_marine_health_counter( "rd_draw_marine_health_counter", "0", FCVAR_ARCHIVE, "Display a numeric counter for marine health on the HUD" ); +ConVar rd_draw_restricted_borders( "rd_draw_restricted_borders", "1", FCVAR_ARCHIVE, "Display the restricted cursor area when using ultra-wide resolution" ); +ConVar rd_draw_restricted_borders_color("rd_draw_restricted_borders_color", "128 128 128 128", 0, "Color of the restricted cursor area borders"); + using namespace vgui; DECLARE_HUDELEMENT( CASW_Hud_Master ); @@ -480,6 +486,17 @@ void CASW_Hud_Master::Paint( void ) if ( m_pLocalMarineResource ) { + // draw restricted borders for ultra-wide screen + if (rd_draw_restricted_borders.GetBool() && g_ultra_wide_screen && !pPlayer->GetSpectatingNPC()) { + // (x,y)-----------(w,y) + // | | + // | | + // (x,h)-----------(w,h) + surface()->DrawSetColor(rd_draw_restricted_borders_color.GetColor()); + surface()->DrawLine(g_clamp_area.x, g_clamp_area.y, g_clamp_area.x, g_clamp_area.height); + surface()->DrawLine(g_clamp_area.width, g_clamp_area.y, g_clamp_area.width, g_clamp_area.height); + } + C_ASW_Marine_Resource *pMR = m_pLocalMarineResource; float flTimeToFade = 2.0f;