Skip to content

Commit

Permalink
Add in-game InputClass error handling
Browse files Browse the repository at this point in the history
(should hopefully ease some install issues)
  • Loading branch information
alexstrout committed Jun 24, 2021
1 parent 92b2f0c commit d7b4104
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
39 changes: 39 additions & 0 deletions Classes/foxPlayerInput.uc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class foxPlayerInput extends PlayerInput within PlayerController
transient;

var bool bDoInit;
var bool bDoErrorInit;

var float CachedResScaleX;
var float CachedDefaultFOV;
Expand All @@ -21,6 +22,7 @@ struct WeaponInfo
};
var WeaponInfo CachedWeaponInfo;

var globalconfig bool bInputClassErrorCheck;
var globalconfig float Desired43FOV;
var globalconfig bool bCorrectZoomFOV;
var globalconfig bool bCorrectMouseSensitivity;
Expand All @@ -46,6 +48,23 @@ exec function SetFOV(float F)
CachedResScaleX = default.CachedResScaleX;
}

//fox: Check various PlayerController classes for correct InputClass (and possibly just add it if missing)
function CheckControllerInputClass(class<PlayerController> ControllerClass, string FriendlyName)
{
if (ControllerClass.default.InputClass != class'foxPlayerInput') {
ClientMessage("foxWSFix: " $ FriendlyName $ " InputClass is: " $ ControllerClass.default.InputClass);

//Just add InputClass if missing
if (ControllerClass.default.InputClass == None) {
ClientMessage("foxWSFix: Attempting to add missing InputClass line...");
ControllerClass.default.InputClass = class'foxPlayerInput';
ControllerClass.static.StaticSaveConfig();
ClientMessage("foxWSFix: " $ FriendlyName $ " InputClass is now: " $ ControllerClass.default.InputClass);
}
ClientMessage("foxWSFix: Please verify User.ini settings!");
}
}

//fox: Hijack this to force FOV per current aspect ratio - done every frame as a lazy catch-all since we're only hooking clientside PlayerInput
event PlayerInput(float DeltaTime)
{
Expand All @@ -55,6 +74,24 @@ event PlayerInput(float DeltaTime)
if (bDoInit) {
bDoInit = false;

//Check for errors if requested
if (bInputClassErrorCheck
&& (class'PlayerController'.default.InputClass != class'foxPlayerInput' || class'xPlayer'.default.InputClass != class'foxPlayerInput')) {
if (bDoErrorInit && Level.TimeSeconds > 3f) {
bDoErrorInit = false;
ClientMessage("foxWSFix Warning: One or more errors occurred. To skip this error check, set bInputClassErrorCheck=false in User.ini");
CheckControllerInputClass(class'PlayerController', "[Engine.PlayerController]");
CheckControllerInputClass(class'xPlayer', "[XGame.xPlayer]");

//Write settings to ini once if stuck on errors
SaveConfig();
}

//Just bail here, resetting bDoInit so we don't do our normal hooks
bDoInit = true;
return;
}

//Write settings to ini if first run
SaveConfig();

Expand Down Expand Up @@ -260,6 +297,8 @@ function InvertMouse(optional string Invert)
defaultproperties
{
bDoInit=true
bDoErrorInit=true
bInputClassErrorCheck=true
Desired43FOV=90f
bCorrectZoomFOV=true
bCorrectMouseSensitivity=true
Expand Down
15 changes: 11 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
foxWSFix v2.1.0
foxWSFix v2.1.1
===============
Improved widescreen support for Unreal Tournament 2004

Expand All @@ -7,7 +7,7 @@ Features
* Aspect-correct "Hor+" FOV adjustment, including vehicle and weapon zoom values
* Aspect-correct rendering for first-person weapons
* Aspect-correct HUD support (mostly), based on Azarael's HUD Scaling Fix mutator
* Aspect-correct mouse sensitivity (auto-adjusts on resolution change)
* Aspect-correct mouse sensitivity (scale off wider FOV instead of hard-coded 90)
* Entirely client-side - no mutators required

Install / Uninstall
Expand All @@ -23,7 +23,8 @@ Replace every instance of it with the following:
;InputClass=Class'Engine.PlayerInput'
InputClass=Class'foxWSFix.foxPlayerInput'

(Note: This line may appear multiple times - be sure to change each one if so!)
**Note:** This line should appear *at least twice* - once under `[Engine.PlayerController]`, and
once under `[XGame.xPlayer]`. Be sure to change each one! (or add it if missing)

You're done! To uninstall, simply reverse your changes.

Expand Down Expand Up @@ -60,9 +61,10 @@ However, widescreen HUDs are provided for vanilla HUDs only.
foxWSFix stores its settings in System\User.ini as such:

[foxWSFix.foxPlayerInput]
bInputClassErrorCheck=True ;Check User.ini InputClass settings for possible errors?
Desired43FOV=90.000000 ;Desired 4:3 FOV per SetFOV command / menu setting
bCorrectZoomFOV=True ;Correct FOV values for weapon zoom?
bCorrectMouseSensitivity=True ;Correct MouseSensitivity for aspect ratio changes?
bCorrectMouseSensitivity=True ;Correct MouseSensitivity for aspect ratio changes? (due to wider FOV)
Desired43MouseSensitivity=2.200000 ;Desired 4:3 MouseSensitivity per SetSensitivity command / menu setting
WideHUDMap=(HudClass=Class'UT2k4Assault.HUD_Assault',WideHUD="foxWSFix.foxWideHUD_Assault")
WideHUDMap=(HudClass=Class'XInterface.HudCBombingRun',WideHUD="foxWSFix.foxWideHudCBombingRun")
Expand Down Expand Up @@ -118,6 +120,11 @@ And of course, thanks for trying the mod!

Changes
-------
v2.1.1 (2020-06-24):
* Added in-game InputClass error handling to hopefully ease some install issues
* Updated installation instructions to reflect the above
* Clarified bCorrectMouseSensitivity (Unreal normally scales sensitivity against a hard-coded 90 FOV for zoom)

v2.1.0 (2020-02-27):
* Resolved AntiTCC issue with GUIController hook (see "v2.0 Upgrade Note" above)
* (Note: All functionality is still in place, just handled in foxPlayerInput now)
Expand Down

0 comments on commit d7b4104

Please sign in to comment.