From afb91ab9e9fd67da0030d5bff3a66774ff43aeb6 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Mon, 30 Oct 2023 19:00:17 +0100 Subject: [PATCH] port: add radial menu sensitivity slider --- port/src/main.c | 2 ++ port/src/optionsmenu.c | 29 +++++++++++++++++++++++++++++ src/game/activemenutick.c | 4 ++-- src/game/player.c | 1 + src/include/data.h | 1 + 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/port/src/main.c b/port/src/main.c index 056a489a8..8db10b5fe 100644 --- a/port/src/main.c +++ b/port/src/main.c @@ -64,6 +64,7 @@ static void gameLoadConfig(void) g_PlayerMouseAimMode = configGetIntClamped("Game.MouseAimMode", g_PlayerMouseAimMode, 0, 1); g_PlayerMouseAimSpeedX = configGetFloatClamped("Game.MouseAimSpeedX", g_PlayerMouseAimSpeedX, 0.f, 10.f); g_PlayerMouseAimSpeedY = configGetFloatClamped("Game.MouseAimSpeedY", g_PlayerMouseAimSpeedY, 0.f, 10.f); + g_PlayerRadialMenuSpeed = configGetFloatClamped("Game.RadialMenuSpeed", g_PlayerRadialMenuSpeed, 0.f, 10.f); g_PlayerFovAffectsZoom = configGetIntClamped("Game.FovAffectsZoom", g_PlayerFovAffectsZoom, 0, 1); g_PlayerFovZoomMultiplier = g_PlayerFovAffectsZoom ? g_PlayerDefaultFovY / 60.0f : 1.0f; g_PlayerClassicCrouch = configGetIntClamped("Game.ClassicCrouch", 0, 0, 1); @@ -83,6 +84,7 @@ static void gameSaveConfig(void) configSetInt("Game.MouseAimMode", g_PlayerMouseAimMode); configSetFloat("Game.MouseAimSpeedX", g_PlayerMouseAimSpeedX); configSetFloat("Game.MouseAimSpeedY", g_PlayerMouseAimSpeedY); + configSetFloat("Game.RadialMenuSpeed", g_PlayerRadialMenuSpeed); configSetFloat("Game.CrosshairSway", g_PlayerCrosshairSway); configSetFloat("Game.ScreenShakeIntensity", g_ViShakeIntensityMult); } diff --git a/port/src/optionsmenu.c b/port/src/optionsmenu.c index 3fde8001f..efb81b0b4 100644 --- a/port/src/optionsmenu.c +++ b/port/src/optionsmenu.c @@ -130,6 +130,27 @@ static MenuItemHandlerResult menuhandlerMouseAimSpeedY(s32 operation, struct men return 0; } +static MenuItemHandlerResult menuhandlerRadialMenuSpeed(s32 operation, struct menuitem *item, union handlerdata *data) +{ + switch (operation) { + case MENUOP_GETSLIDER: + if (g_PlayerRadialMenuSpeed < 0.f) { + data->slider.value = 0; + } else if (g_PlayerRadialMenuSpeed> 10.f) { + data->slider.value = 100; + } else { + data->slider.value = g_PlayerRadialMenuSpeed * 10.f + 0.5f; + } + break; + case MENUOP_SET: + g_PlayerRadialMenuSpeed = (f32)data->slider.value / 10.f; + break; + } + + return 0; +} + + struct menuitem g_ExtendedMouseMenuItems[] = { { MENUITEMTYPE_CHECKBOX, @@ -187,6 +208,14 @@ struct menuitem g_ExtendedMouseMenuItems[] = { 100, menuhandlerMouseAimSpeedY, }, + { + MENUITEMTYPE_SLIDER, + 0, + MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE, + (uintptr_t)"Radial Menu Speed", + 100, + menuhandlerRadialMenuSpeed, + }, { MENUITEMTYPE_SEPARATOR, 0, diff --git a/src/game/activemenutick.c b/src/game/activemenutick.c index 23554f857..4424926cc 100644 --- a/src/game/activemenutick.c +++ b/src/game/activemenutick.c @@ -80,8 +80,8 @@ void amTick(void) struct activemenu *am = &g_AmMenus[g_AmIndex]; inputMouseGetAbsScaledDelta(&mdx, &mdy); if (mdx || mdy) { - am->mousex += mdx * 4.f; - am->mousey += mdy * 4.f; + am->mousex += mdx * g_PlayerRadialMenuSpeed; + am->mousey += mdy * g_PlayerRadialMenuSpeed; am->mousex = (am->mousex > 127.f) ? 127.f : (am->mousex < -128.f) ? -128.f : am->mousex; am->mousey = (am->mousey > 127.f) ? 127.f : (am->mousey < -128.f) ? -128.f : am->mousey; } diff --git a/src/game/player.c b/src/game/player.c index 2ecffb6a2..4b0645428 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -208,6 +208,7 @@ f32 g_PlayerCrosshairSway = 1.f; s32 g_PlayerMouseAimMode = MOUSEAIM_CLASSIC; f32 g_PlayerMouseAimSpeedX = 0.7f; f32 g_PlayerMouseAimSpeedY = 0.7f; +f32 g_PlayerRadialMenuSpeed = 4.0f; s32 g_PlayerFovAffectsZoom = 1; f32 g_PlayerFovZoomMultiplier = 1.0f; s32 g_PlayerClassicCrouch = true; diff --git a/src/include/data.h b/src/include/data.h index dba6ff5d0..f36ffbeef 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -540,6 +540,7 @@ extern f32 g_PlayerDefaultFovY; extern s32 g_PlayerMouseAimMode; extern f32 g_PlayerMouseAimSpeedX; extern f32 g_PlayerMouseAimSpeedY; +extern f32 g_PlayerRadialMenuSpeed; extern s32 g_PlayerFovAffectsZoom; extern f32 g_PlayerFovZoomMultiplier; extern s32 g_PlayerClassicCrouch;