Skip to content

Commit

Permalink
Add option to set a custom factor for the view shake
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-bckl committed May 4, 2021
1 parent 05246ac commit 276164c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
17 changes: 13 additions & 4 deletions Mod/Classes/ModGameOptionsMenu.uc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var() MenuSprite OptionsDescBorder;

var() MenuText OptionDesc;

const NUM_OPTIONS = 12;
const NUM_OPTIONS = 13;

var() MenuText OptionLabels[NUM_OPTIONS];
var() MenuButtonEnum Options[NUM_OPTIONS];
Expand Down Expand Up @@ -185,6 +185,7 @@ simulated function Refresh()

Options[10].Current = i;
Options[11].Current = SWRCFix.HudArmsFOVFactor * 10;
Options[12].Current = SWRCFix.ViewShake * 10;

if ( !bInMultiplayer )
{
Expand Down Expand Up @@ -339,22 +340,25 @@ simulated function ChangeOption( int i, int Delta )
GetPlayerOwner().TacticalModeIntensity = float(Options[i].Current) / 10.0f;
GetPlayerOwner().SaveConfig();
GetPlayerOwner().PassOnTacticalIntensity();

break;

case 9:
SWRCFix.FpsLimit = float(Options[9].Items[Options[9].Current]);

SWRCFix.SaveConfig();
break;

case 10:
SWRCFix.SetFov(GetPlayerOwner(), float(Options[10].Items[Options[10].Current]));

break;

case 11:
SWRCFix.HudArmsFOVFactor = float(Options[11].Items[Options[11].Current]);
SWRCFix.SetFOV(GetPlayerOwner(), SWRCFix.FOV);
break;

case 12:
SWRCFix.ViewShake = float(Options[12].Items[Options[12].Current]);
SWRCFix.SaveConfig();
}

GetPlayerOwner().PropagateSettings();
Expand Down Expand Up @@ -436,6 +440,7 @@ defaultproperties
OptionLabels(9)=(Text="FPS LIMIT")
OptionLabels(10)=(Text="FIELD OF VIEW")
OptionLabels(11)=(Text="WEAPON FOV FACTOR")
OptionLabels(12)=(Text="VIEW SHAKE")
Options(0)=(Items=("1","2","3","4","5","6","7","8","9","10"),Blurred=(PosX=0.77375,PosY=0.12,ScaleX=0.6,ScaleY=0.6),BackgroundBlurred=(PosX=0.77375,PosY=0.12,ScaleX=0.26,ScaleY=0.02666),OnLeft="OnLeft",OnRight="OnRight",Pass=2,Style="ButtonEnumStyle1")
Options(1)=(Items=("YES","NO"),Blurred=(PosY=0.16),BackgroundBlurred=(PosY=0.16))
Options(2)=(Items=("ON","OFF"))
Expand All @@ -448,6 +453,7 @@ defaultproperties
Options(9)=(Items=("NONE","30","60","75","100","120","144","240","360"));
Options(10)=(Items=("85","90","95","100","105","110","115","120","125","130"))
Options(11)=(Items=("0.0","0.1","0.2","0.3","0.4","0.5","0.6","0.7","0.8","0.9","1.0"))
Options(12)=(Items=("0.0","0.1","0.2","0.3","0.4","0.5","0.6","0.7","0.8","0.9","1.0"))
OptionLeftArrows(0)=(Blurred=(WidgetTexture=Texture'GUIContent.Menu.CT_ArrowLeft',DrawColor=(B=255,G=255,R=255,A=255),DrawPivot=DP_MiddleMiddle,PosX=0.62625,PosY=0.12,ScaleX=0.5,ScaleY=0.5),Focused=(DrawColor=(B=255,G=255,R=255,A=255),ScaleX=0.65,ScaleY=0.65),bIgnoreController=1,OnSelect="OnLeft",Pass=2)
OptionLeftArrows(1)=(Blurred=(PosX=0.62625,PosY=0.16))
OptionLeftArrows(2)=(Blurred=(PosX=0.62625))
Expand All @@ -460,6 +466,7 @@ defaultproperties
OptionLeftArrows(9)=(Blurred=(PosX=0.62625))
OptionLeftArrows(10)=(Blurred=(PosX=0.62625))
OptionLeftArrows(11)=(Blurred=(PosX=0.62625))
OptionLeftArrows(12)=(Blurred=(PosX=0.62625))
OptionRightArrows(0)=(Blurred=(WidgetTexture=Texture'GUIContent.Menu.CT_ArrowRight',DrawColor=(B=255,G=255,R=255,A=255),DrawPivot=DP_MiddleMiddle,PosX=0.9225,PosY=0.12,ScaleX=0.5,ScaleY=0.5),Focused=(DrawColor=(B=255,G=255,R=255,A=255),ScaleX=0.65,ScaleY=0.65),bIgnoreController=1,OnSelect="OnRight",Pass=2)
OptionRightArrows(1)=(Blurred=(PosX=0.9225,PosY=0.16))
OptionRightArrows(2)=(Blurred=(PosX=0.9225))
Expand All @@ -472,13 +479,15 @@ defaultproperties
OptionRightArrows(9)=(Blurred=(PosX=0.9225))
OptionRightArrows(10)=(Blurred=(PosX=0.9225))
OptionRightArrows(11)=(Blurred=(PosX=0.9225))
OptionRightArrows(12)=(Blurred=(PosX=0.9225))
OptionDefaults(0)=5
OptionDefaults(1)=1
OptionDefaults(2)=1
OptionDefaults(5)=1
OptionDefaults(7)=2
OptionDefaults(8)=2
OptionDefaults(11)=10
OptionDefaults(12)=10
GameLabel=(MenuFont=Font'OrbitFonts.OrbitBold15',Text="GAME",DrawColor=(A=255),DrawPivot=DP_MiddleLeft,PosX=0.05375,PosY=0.2,ScaleX=1,ScaleY=0.8,Pass=2)
GameLabelBackground=(WidgetTexture=Texture'GUIContent.Menu.CT_ButtonFocus',DrawColor=(B=255,G=255,R=255,A=192),DrawPivot=DP_MiddleLeft,PosX=0.04375,PosY=0.2,ScaleX=0.245,ScaleY=0.04333,ScaleMode=MSCM_FitStretch,Pass=1)
GameLabelConnector=(WidgetTexture=Texture'GUIContent.Menu.CT_ButtonFocus',DrawColor=(B=255,G=255,R=255,A=192),DrawPivot=DP_MiddleLeft,PosX=0.295,PosY=0.2,ScaleX=0.005,ScaleY=0.04333,ScaleMode=MSCM_FitStretch)
Expand Down
25 changes: 24 additions & 1 deletion Mod/Classes/SWRCFix.uc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class SWRCFix extends Object config native transient;

#exec OBJ LOAD FILE="Properties.u"
var() config float ViewShake;
var() config float FpsLimit;
var() config float FOV;
var() config float HudArmsFOVFactor;
Expand All @@ -12,6 +13,8 @@ var() config bool EnableEditorSelectionFix; // Only here for convenience. The
var FunctionOverride CTPlayerEndZoomOverride;
var FunctionOverride CTPlayerResetFOVOverride;
var FunctionOverride PlayerControllerShakeViewOverride;
var FunctionOverride WeaponSetWeapFOVOverride;
var FunctionOverride MenuBaseCallMenuClassOverride;
Expand All @@ -26,6 +29,9 @@ event InitScript(){
CTPlayerEndZoomOverride.Init(class'CTPlayer', 'EndZoom', self, 'CTPlayerEndZoom');
CTPlayerResetFOVOverride = new class'FunctionOverride';
CTPlayerResetFOVOverride.Init(class'CTPlayer', 'ResetFOV', self, 'CTPlayerResetFOV');
// PlayerController
PlayerControllerShakeViewOverride = new class'FunctionOverride';
PlayerControllerShakeViewOverride.Init(class'PlayerController', 'ShakeView', self, 'PlayerControllerShakeView');
// Weapon
WeaponSetWeapFOVOverride = new class'FunctionOverride';
WeaponSetWeapFOVOverride.Init(class'Weapon', 'SetWeapFOV', self, 'WeaponSetWeapFOV');
Expand Down Expand Up @@ -132,13 +138,29 @@ function SetViewFOV(PlayerController Player){
Player.FOVAngle = CurrentFOV;
}
event SetFOV(PlayerController Player, float NewFOV){
function SetFOV(PlayerController Player, float NewFOV){
FOV = NewFOV;
SaveConfig();
SetViewFOV(Player);
}
// View shake
function PlayerControllerShakeView(float InTime, float SustainTime, float OutTime, float XMag, float YMag, float ZMag, float YawMag, float PitchMag, float Frequency){
if(ViewShake > 0){
PlayerController(PlayerControllerShakeViewOverride.CurrentSelf).ShakeView(InTime,
SustainTime,
OutTime,
XMag * ViewShake,
YMag * ViewShake,
ZMag * ViewShake,
YawMag * ViewShake,
PitchMag * ViewShake,
Frequency);
}
}
// Menu stuff
simulated function MenuBaseCallMenuClass(String MenuClassName, optional String Args){
Expand Down Expand Up @@ -183,6 +205,7 @@ cpptext

defaultproperties
{
ViewShake=1.0
FOV=85.0
HUDArmsFOVFactor=1.0
LimitHudArmsFOV=true
Expand Down
13 changes: 2 additions & 11 deletions Mod/Inc/ModClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MOD_API UFunctionOverride : public UObject
class MOD_API USWRCFix : public UObject
{
public:
FLOAT ViewShake;
FLOAT FpsLimit;
FLOAT FOV;
FLOAT HudArmsFOVFactor;
Expand All @@ -50,6 +51,7 @@ class MOD_API USWRCFix : public UObject
BITFIELD EnableEditorSelectionFix:1;
class UFunctionOverride* CTPlayerEndZoomOverride GCC_PACK(4);
class UFunctionOverride* CTPlayerResetFOVOverride;
class UFunctionOverride* PlayerControllerShakeViewOverride;
class UFunctionOverride* WeaponSetWeapFOVOverride;
class UFunctionOverride* MenuBaseCallMenuClassOverride;
class UFunctionOverride* MenuBaseOverlayMenuClassOverride;
Expand All @@ -59,17 +61,6 @@ class MOD_API USWRCFix : public UObject
DECLARE_NAME(InitScript);
ProcessEvent(NInitScript, NULL);
}
void SetFOV(class APlayerController* Player, FLOAT NewFOV)
{
DECLARE_NAME(SetFOV);
struct {
class APlayerController* Player;
FLOAT NewFOV;
} Parms;
Parms.Player=Player;
Parms.NewFOV=NewFOV;
ProcessEvent(NSetFOV, &Parms);
}
DECLARE_CLASS(USWRCFix,UObject,0|CLASS_Transient|CLASS_Config,Mod)
void Init();

Expand Down
24 changes: 0 additions & 24 deletions Mod/Src/ModRenderDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,30 +536,6 @@ UBOOL UModRenderDevice::Exec(const TCHAR* Cmd, FOutputDevice& Ar){

debugf("Selection fix %s", bEnableSelectionFix ? "enabled" : "disabled");

return 1;
}
}else if(USWRCFix::Instance){
if(ParseCommand(&Cmd, "SETFOV")){
TObjectIterator<UViewport> It;

checkSlow(It);

FLOAT FOV = appAtof(Cmd);

Ar.Logf("Setting field of view to %f", FOV);
USWRCFix::Instance->SetFOV(It->Actor, FOV);

return 1;
}else if(ParseCommand(&Cmd, "SETFPSLIMIT")){
if(appStrlen(Cmd) > 0){
USWRCFix::Instance->FpsLimit = Max(0.0f, appAtof(Cmd));
USWRCFix::Instance->SaveConfig();
}

return 1;
}else if(ParseCommand(&Cmd, "GETFPSLIMIT")){
Ar.Logf("%f", USWRCFix::Instance->FpsLimit);

return 1;
}
}
Expand Down

0 comments on commit 276164c

Please sign in to comment.