diff options
| author | 2026-04-05 15:52:10 -0400 | |
|---|---|---|
| committer | 2026-04-05 15:52:10 -0400 | |
| commit | e094e66536e31f52e0b91521e6e561b593ed480a (patch) | |
| tree | 96e4ff54b2c80f9084358482aab3864c68425a9a | |
| parent | da80badc0e0acaa11459aefeb486f7e58c473eb3 (diff) | |
| download | NewCamera-e094e66536e31f52e0b91521e6e561b593ed480a.tar.gz NewCamera-e094e66536e31f52e0b91521e6e561b593ed480a.tar.bz2 NewCamera-e094e66536e31f52e0b91521e6e561b593ed480a.zip | |
Simplify and fix preset select and disable fading
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rwxr-xr-x | Config.cs | 17 | ||||
| -rwxr-xr-x | Plugin.cs | 592 |
2 files changed, 317 insertions, 292 deletions
@@ -10,6 +10,9 @@ namespace NewCamera public String Name => "NewCamera";
public String Version => "4.0";
+ public const float DEFAULT_FOV = 60.0f;
+ public const float DEFAULT_NEAR_CLIP = 16.0f;
+
public struct Settings
{
public const float DEFAULT_SPEED = 5.35f;
@@ -70,23 +73,33 @@ namespace NewCamera public struct Preset
{
public float FieldOfView { get; set; }
+ public float Roll { get; set; }
public float Forward { get; set; }
public float Right { get; set; }
public float Up { get; set; }
- public float Roll { get; set; }
public bool DisableFading { get; set; }
}
+ public static Preset DefaultPreset = new Preset()
+ {
+ FieldOfView = DEFAULT_FOV,
+ Roll = 0.0f,
+ Forward = 0.0f,
+ Right = 0.0f,
+ Up = 0.0f,
+ DisableFading = false
+ };
+
public struct Position
{
public float FieldOfView { get; set; }
+ public float Roll { get; set; }
public float PosX { get; set; }
public float PosY { get; set; }
public float PosZ { get; set; }
public float TargetX { get; set; }
public float TargetY { get; set; }
public float TargetZ { get; set; }
- public float Roll { get; set; }
}
private static Dictionary<string, Button> buttonMap = new Dictionary<string, Button>
@@ -47,9 +47,12 @@ using SharpPluginLoader.Core.Configuration; // @TODO:
// - pCamera refactor.
+// - Structured tuning tool interop.
// - Facial contact shadows incorrectly move based on camera position.
// - Attempt to document all test cases I can think of.
+// - Wasd for ignore camera direction.
// - Make audio like waterfall follow camera position instead of player position.
+// - Audio high/lowpass?
// - Better hook for renderer params.
// - Centralize all bindings to get a better idea of how to structure custom binds.
// - Use GetRef<>.
@@ -140,7 +143,7 @@ using SharpPluginLoader.Core.Configuration; // - A night time in Astera, there will eventually be 3 hunters eating at the table next to the handler.
// If this is broken, two of them will be invisible.
//
-// 2x Shadow Resolution:
+// 3x Shadow Resolution:
// - The shadow of the "Waterfall Bridge" lift in Astera.
// - Walk up the stairs towards the canteen and the shadow of the lift will fade-out. Move the camera
// back and forth and make sure the lower resolution shadow aligns with the higher res one.
@@ -152,8 +155,8 @@ namespace NewCamera public string Name => "New Camera";
public string Author => "Akon City Software";
- private const float DEFAULT_FOV = 60.0f;
- private const float DEFAULT_NEAR_CLIP = 16.0f;
+ private const float DEFAULT_FOV = Config.DEFAULT_FOV;
+ private const float DEFAULT_NEAR_CLIP = Config.DEFAULT_NEAR_CLIP;
private static byte ByteFlag(bool f) { return f ? (byte)0x1 : (byte)0x0; }
@@ -313,10 +316,11 @@ namespace NewCamera private bool uiToggled = false;
private Patch jmpOverUi;
+ private static readonly MtObject sMhScene = SingletonManager.GetSingleton("sMhScene")!;
private bool disableCharacterFade = false;
private Patch noopCharacterFade;
- private int disableDofOverride = 0;
+ private int disableNearDofOverride = 0;
private bool enableUnderwaterCamera = false;
private Patch underwaterCamera1;
@@ -324,6 +328,8 @@ namespace NewCamera private Patch underwaterCamera3;
private Patch underwaterCamera4;
private Patch underwaterCamera5;
+ private bool disableDofCoc = false;
+ private Patch nullifyDofCoc;
private bool cameraIsUnderwater = false;
private delegate void UnderwaterCheck(nint unknownPtr);
private Hook<UnderwaterCheck>? underwaterCheck;
@@ -556,7 +562,6 @@ namespace NewCamera stickDeadzone = camera.StickDeadzone;
alternateNearClip = camera.AlternateNearClip;
- // @TODO: offsetPerspective doesn't affect disableCharacterFade when it is supposed to.
enableOffsetPerspective = config.PerspectiveCameraEnabled;
ConfigManager.SaveConfig<Config>(this);
@@ -717,6 +722,7 @@ namespace NewCamera underwaterCamera3 = new Patch(new IntPtr(0x141FA5A7E), [0x90, 0x90]); // Nop check.
underwaterCamera4 = new Patch(new IntPtr(0x141FA5BA0), [0x40, 0x84, 0xF6, 0x90, 0x74]); // jae -> je.
underwaterCamera5 = new Patch(new IntPtr(0x141FA5A74), [0x0F, 0x57, 0xF6, 0x31, 0xD2, 0x48, 0x8D, 0x4D, 0x80, 0xE8, 0x9E, 0x41, 0x38, 0xFE, 0xC1, 0xE8, 0x14, 0x66, 0x25, 0xD8, 0x03, 0xFF, 0xC8, 0x66, 0x3D, 0x48, 0x00, 0x77]);
+ nullifyDofCoc = new Patch(new IntPtr(0x1424236DD), [0x0F, 0x57, 0xF6, 0x90, 0x90, 0x90, 0x90]);
underwaterCheck = Hook.Create<UnderwaterCheck>(0x1412AD500, UnderwaterCheckHook); // nint
// Player + ECCC = How far underwater is the player.
@@ -778,21 +784,29 @@ namespace NewCamera return data;
}
- private bool getDisableFadingObjects(int viewportIndex)
+ // This doesn't include decals or monsters.
+ private bool getViewportFadeObjects(int viewportIndex)
{
Viewport vp = CameraSystem.GetViewport(viewportIndex);
- return MemoryUtil.Read<byte>(vp.Instance + 0x21) == 0;
+ return MemoryUtil.Read<byte>(vp.Instance + 0x21) == 0x1;
}
- private void setDisableFadingObjects(int viewportIndex, bool disable)
+ private void setViewportFadeObjects(int viewportIndex, bool enable)
{
Viewport vp = CameraSystem.GetViewport(viewportIndex);
- MemoryUtil.WriteBytes(vp.Instance + 0x21, disable ? [0x0] : [0x1]);
+ MemoryUtil.GetRef<byte>(vp.Instance + 0x21) = ByteFlag(enable);
+ }
+
+ private bool getPassthroughEnabled()
+ {
+ return MemoryUtil.Read<byte>(sMhScene.Instance + 0xE9A0) == 0x1;
+ }
+
+ private void setPassthroughEnabled(bool enable)
+ {
+ MemoryUtil.GetRef<byte>(sMhScene.Instance + 0xE9A0) = ByteFlag(enable);
}
- // @TODO:
- // - Doesn't apply right when switching presets.
- // - Don't touch while in freecam and switching preset.
private void setDisableCharacterFade(bool disable)
{
if (disable && !disableCharacterFade)
@@ -807,43 +821,71 @@ namespace NewCamera }
}
+ private void setDisableFading(bool disable)
+ {
+ setPassthroughEnabled(!disable);
+ setDisableCharacterFade(disable);
+ }
+
private void setPerspectivePreset(Config.Preset preset)
{
- cameraFov = preset.FieldOfView;
if (restoreFov != null)
{
- restoreFov = cameraFov;
+ restoreFov = preset.FieldOfView;
+ }
+ else
+ {
+ cameraFov = preset.FieldOfView;
+ }
+ if (restoreRoll != null)
+ {
+ restoreRoll = preset.Roll;
+ }
+ else
+ {
+ cameraRoll = preset.Roll;
}
orbitDistance += cameraForward - preset.Forward;
cameraForward = preset.Forward;
cameraRight = preset.Right;
cameraUp = preset.Up;
- cameraRoll = preset.Roll;
- if (restoreRoll != null)
- {
- restoreRoll = cameraRoll;
- }
disableFading = preset.DisableFading;
- if (pCameraViewportIndex >= 0)
+ if (!freeCamera)
{
- setDisableFadingObjects(pCameraViewportIndex, disableFading);
+ setDisableFading(disableFading);
}
- setDisableCharacterFade(disableFading);
}
public void OnLoad()
{
Config config = loadConfig();
- if (config.Selected != "")
+ if (enableOffsetPerspective && config.Selected != "")
{
setPerspectivePreset(config.Presets[config.Selected]);
}
tuningTool = IPlugin.GetInstance("World Tuning Tool");
}
+ private void toggleUi()
+ {
+ uiToggled = !uiToggled;
+ if (uiToggled)
+ {
+ jmpOverUi.Enable();
+ }
+ else
+ {
+ jmpOverUi.Disable();
+ }
+ if (unlockInputForMenu)
+ {
+ unlockInputHideMenu = uiToggled;
+ }
+ }
+
private Player? getPlayerFromSaveSlot(int index)
{
- nint offset = (Player.SingletonInstance.Instance + 0x40) + (0x740 * index);
+ nint offset = (sPlayer.Instance + 0x40) + (0x740 * index);
nint playerAddr = MemoryUtil.Read<nint>(offset);
if (playerAddr != 0x1433FE588)
{
@@ -858,6 +900,80 @@ namespace NewCamera return new Player(playerAddr);
}
+ private Player? checkPlayerChange()
+ {
+ Player? player = Player.MainPlayer;
+ if (player != lastPlayer)
+ {
+ pCamera = null;
+ pCameraViewportIndex = -1;
+ lastPlayer = player;
+ }
+ return player;
+ }
+
+ private int getVisibleCamera()
+ {
+ for (int i = 0; i < 8; i++)
+ {
+ Viewport vp = CameraSystem.GetViewport(i);
+ // A viewport can be visible with a null camera.
+ if (vp.Visible && vp.Camera != null)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private void checkCurrentVisibleCamera(Player? player)
+ {
+ int prevIndex = vCameraViewportIndex;
+ vCameraViewportIndex = getVisibleCamera();
+ if (vCameraViewportIndex >= 0)
+ {
+ Camera camera = CameraSystem.GetViewport(vCameraViewportIndex).Camera!;
+ // Evaluate potential free camera target change.
+ if (freeCamera)
+ {
+ if (vCamera != camera)
+ {
+ if (player != null)
+ {
+ // Try to position the camera behind the player.
+ cameraPosition = player.Position;
+ cameraPosition.X -= player.Forward.X * 250.0f;
+ cameraPosition.Y += 200.0f;
+ cameraPosition.Z -= player.Forward.Z * 250.0f;
+ cameraTarget = player.Position;
+ cameraTarget.Y += 150.0f;
+ }
+ else
+ {
+ cameraPosition = camera.Position;
+ cameraTarget = camera.Target;
+ }
+ Quaternion forward = Quaternion.Normalize(getForward(cameraPosition, cameraTarget));
+ cameraYaw = Single.RadiansToDegrees(MathF.Atan2(forward.Z, forward.X));
+ cameraPitch = Single.RadiansToDegrees(MathF.Asin(forward.Y));
+ }
+ }
+ vCamera = camera;
+ // Assume that after a player is set the visible camera is the player camera.
+ if (pCamera == null && player != null)
+ {
+ pCamera = vCamera;
+ pCameraViewportIndex = vCameraViewportIndex;
+ }
+ }
+ else
+ {
+ vCamera = null;
+ pCamera = null;
+ pCameraViewportIndex = -1;
+ }
+ }
+
private void resetStatePerFrame()
{
primaryPad = 0x0;
@@ -895,15 +1011,7 @@ namespace NewCamera }
if (Input.IsPressed(Key.NumPadPeriod))
{
- uiToggled = !uiToggled;
- if (uiToggled)
- {
- jmpOverUi.Enable();
- }
- else
- {
- jmpOverUi.Disable();
- }
+ toggleUi();
}
if (Input.IsPressed(Key.NumPadSlash))
{
@@ -1092,8 +1200,7 @@ namespace NewCamera // actually shown, which avoids a jump when toggling free camera. This is also
// why we don't enable free camera until after applying a offset on this update.
cameraFov = camera.FieldOfView;
- setDisableFadingObjects(viewportIndex, true);
- setDisableCharacterFade(true);
+ setDisableFading(true);
forceMinimapFollowsCamera.Enable();
/*
//MemoryUtil.WriteBytes(psuedoViewModeObject + 0x10, BitConverter.GetBytes(vCamera.Instance));
@@ -1130,8 +1237,14 @@ namespace NewCamera }
cameraWrapState = 0;
setTentBasePos(new Vector3(0.0f, -19850.0f, 270.0f), new Vector3(0.0f, -19830.0f, 0.0f));
- setDisableFadingObjects(vCameraViewportIndex, (vCameraViewportIndex == pCameraViewportIndex) ? disableFading : false);
- setDisableCharacterFade(disableFading);
+ if (enableOffsetPerspective)
+ {
+ setDisableFading(disableFading);
+ }
+ else
+ {
+ setDisableFading(false);
+ }
forceMinimapFollowsCamera.Disable();
//stopViewMode.Invoke(psuedoViewModeObject);
}
@@ -1449,89 +1562,6 @@ namespace NewCamera camera.FieldOfView = cameraFov;
}
- private Player? checkPlayerChange()
- {
- Player? player = Player.MainPlayer;
- if (player != lastPlayer)
- {
- pCamera = null;
- pCameraViewportIndex = -1;
- lastPlayer = player;
- }
- return player;
- }
-
- private int getVisibleCamera()
- {
- for (int i = 0; i < 8; i++)
- {
- Viewport vp = CameraSystem.GetViewport(i);
- // A viewport can be visible with a null camera.
- if (vp.Visible && vp.Camera != null)
- {
- return i;
- }
- }
- return -1;
- }
-
- private void checkCurrentVisibleCamera(Player? player)
- {
- int prevIndex = vCameraViewportIndex;
- vCameraViewportIndex = getVisibleCamera();
- if (vCameraViewportIndex >= 0)
- {
- Camera camera = CameraSystem.GetViewport(vCameraViewportIndex).Camera!;
- // Evaluate potential free camera target change.
- if (freeCamera)
- {
- if (prevIndex != vCameraViewportIndex)
- {
- if (prevIndex >= 0)
- {
- setDisableFadingObjects(prevIndex, (prevIndex == pCameraViewportIndex) ? disableFading : false);
- }
- setDisableFadingObjects(vCameraViewportIndex, true);
- }
- if (vCamera != camera)
- {
- if (player != null)
- {
- // Try to position the camera behind the player.
- cameraPosition = player.Position;
- cameraPosition.X -= player.Forward.X * 250.0f;
- cameraPosition.Y += 200.0f;
- cameraPosition.Z -= player.Forward.Z * 250.0f;
- cameraTarget = player.Position;
- cameraTarget.Y += 150.0f;
- }
- else
- {
- cameraPosition = camera.Position;
- cameraTarget = camera.Target;
- }
- Quaternion forward = Quaternion.Normalize(getForward(cameraPosition, cameraTarget));
- cameraYaw = Single.RadiansToDegrees(MathF.Atan2(forward.Z, forward.X));
- cameraPitch = Single.RadiansToDegrees(MathF.Asin(forward.Y));
- }
- }
- vCamera = camera;
- // Assume that after a player is set the visible camera is the player camera.
- if (pCamera == null && player != null)
- {
- pCamera = vCamera;
- pCameraViewportIndex = vCameraViewportIndex;
- setDisableFadingObjects(pCameraViewportIndex, disableFading);
- }
- }
- else
- {
- vCamera = null;
- pCamera = null;
- pCameraViewportIndex = -1;
- }
- }
-
private void checkCameraAnimState()
{
if (pCamera != null)
@@ -1938,19 +1968,7 @@ namespace NewCamera }
if (buttonWasPressed(Button.Share))
{
- uiToggled = !uiToggled;
- if (uiToggled)
- {
- jmpOverUi.Enable();
- }
- else
- {
- jmpOverUi.Disable();
- }
- if (unlockInputForMenu)
- {
- unlockInputHideMenu = uiToggled;
- }
+ toggleUi();
}
if (buttonWasPressed(Button.L1))
{
@@ -2139,14 +2157,14 @@ namespace NewCamera }
if (buttonWasPressed(Button.Circle))
{
- if (disableDofOverride != 0)
+ if (disableNearDofOverride != 0)
{
- tuningTool.RemoveOverride(disableDofOverride);
- disableDofOverride = 0;
+ tuningTool.RemoveOverride(disableNearDofOverride);
+ disableNearDofOverride = 0;
}
else
{
- disableDofOverride = tuningTool.AddOverride("Near Enable", new Vector4(), 0);
+ disableNearDofOverride = tuningTool.AddOverride("Near Enable", new Vector4(), 0);
}
}
}
@@ -2381,6 +2399,17 @@ namespace NewCamera }
}
+ if (cameraIsUnderwater && !disableDofCoc)
+ {
+ nullifyDofCoc.Enable();
+ disableDofCoc = true;
+ }
+ else if (!cameraIsUnderwater && disableDofCoc)
+ {
+ nullifyDofCoc.Disable();
+ disableDofCoc = false;
+ }
+
if (cameraIsUnderwater)
{
underwaterValues = MemoryUtil.ReadArray<byte>(targetAddr + 0x8, 120);
@@ -2390,7 +2419,7 @@ namespace NewCamera cameraEffectHook!.Original(unknownPtr, unknownPtr2, unknownPtr3);
- if (cameraIsUnderwater && underwaterValues != null)
+ if (underwaterValues != null)
{
MemoryUtil.WriteBytes(targetAddr + 0x8, underwaterValues);
}
@@ -2409,12 +2438,17 @@ namespace NewCamera {
ImGui.Text($"Resolution: {vp.Region.Width}x{vp.Region.Height}");
}
- if (vp.Visible)
+ if (debug && vp.Visible)
{
- bool disableFadingObjects = getDisableFadingObjects(i);
- if (ImGui.Checkbox("Disable Fading Objects When Close to Camera", ref disableFadingObjects))
+ bool fadeObjects = getViewportFadeObjects(i);
+ if (ImGui.Checkbox("Fade Objects When Close to Camera", ref fadeObjects))
+ {
+ setViewportFadeObjects(i, fadeObjects);
+ }
+ if (ImGui.BeginItemTooltip())
{
- setDisableFadingObjects(i, disableFadingObjects);
+ ImGui.Text("This is a viewport flag which is not used by the \"Disable Fading\" option. It doesn't apply to decals or monsters.");
+ ImGui.EndTooltip();
}
}
if (vp.Camera != null)
@@ -2498,13 +2532,13 @@ namespace NewCamera {
Config.Position pos = new Config.Position();
pos.FieldOfView = camera.FieldOfView;
+ pos.Roll = cameraRoll;
pos.PosX = camera.Position.X;
pos.PosY = camera.Position.Y;
pos.PosZ = camera.Position.Z;
pos.TargetX = camera.Target.X;
pos.TargetY = camera.Target.Y;
pos.TargetZ = camera.Target.Z;
- pos.Roll = cameraRoll;
if (config.Positions.ContainsKey(name))
{
config.Positions[name] = pos;
@@ -2536,6 +2570,7 @@ namespace NewCamera Config.Position pos = config.Positions[positionKey];
selectedPositionName = positionKey;
camera.FieldOfView = pos.FieldOfView;
+ cameraRoll = pos.Roll;
cameraPosition = new Vector3(pos.PosX, pos.PosY, pos.PosZ);
cameraTarget = new Vector3(pos.TargetX, pos.TargetY, pos.TargetZ);
Quaternion forward = Quaternion.Normalize(getForward(cameraPosition, cameraTarget));
@@ -2543,7 +2578,6 @@ namespace NewCamera cameraPitch = Single.RadiansToDegrees(MathF.Asin(forward.Y));
camera.Position = cameraPosition;
camera.Target = cameraTarget;
- cameraRoll = pos.Roll;
}
}
ImGui.EndCombo();
@@ -2670,9 +2704,9 @@ namespace NewCamera }
else
{
+ ImGui.SetNextItemWidth(width * 0.8f);
ImGui.SliderFloat("Frame", ref animationLayer.CurrentFrame, 0.0f, animationLayer.MaxFrame, "%.3f");
}
- ImGui.PushItemWidth(width * 0.35f);
bool animationPaused = animationLayer.Paused;
if (ImGui.Checkbox("Paused", ref animationPaused))
{
@@ -2694,9 +2728,10 @@ namespace NewCamera }
}
ImGui.SameLine();
+ ImGui.PushItemWidth(width * 0.35f);
if (animationLocked)
{
- float requestSpeed = (float)lockedSpeed;
+ float requestSpeed = (float)lockedSpeed!;
if (ImGui.DragFloat($"Speed", ref requestSpeed, 0.01f, 0.0f, 0.0f, "%.3f"))
{
animationLayer.LockSpeed(requestSpeed);
@@ -2737,6 +2772,11 @@ namespace NewCamera private void tryToDisableMod(Player? player)
{
disableAllCollisionHooks();
+ if (player != null)
+ {
+ player.Rotation.X = 0.0f;
+ player.Rotation.Z = 0.0f;
+ }
if (freeCamera)
{
disableFreeCamera();
@@ -2748,12 +2788,11 @@ namespace NewCamera {
vp.Camera.Move = true;
}
- setDisableFadingObjects(i, false);
+ setViewportFadeObjects(i, true);
}
- if (player != null)
+ if (enableOffsetPerspective && disableFading)
{
- player.Rotation.X = 0.0f;
- player.Rotation.Z = 0.0f;
+ setPassthroughEnabled(true);
}
if (disableCharacterFade)
{
@@ -2775,9 +2814,9 @@ namespace NewCamera private void tryToEnableMod()
{
- if (pCameraViewportIndex >= 0)
+ if (enableOffsetPerspective && disableFading)
{
- setDisableFadingObjects(pCameraViewportIndex, disableFading);
+ setPassthroughEnabled(false);
}
if (disableCharacterFade)
{
@@ -3085,8 +3124,8 @@ namespace NewCamera }
if (ImGui.Button("Sit in Hot Springs"))
{
- // Run sit in hot springs action (top of function):
- // MonsterHunterWorld.exe+17601F0 - mov [rsp+08],rbx
+ // Run sit in hot springs action (top of function).
+ // MonsterHunterWorld.exe+17601F0 - mov [rsp+08],rbx
MemoryUtil.WriteBytes(player.ActionController.Instance + 0xC0, [0x65, 0x00, 0x00, 0x00]);
MemoryUtil.WriteBytes(player.ActionController.Instance + 0xBC, [0x01, 0x00, 0x00, 0x00]);
}
@@ -3135,13 +3174,12 @@ namespace NewCamera ImGui.EndTooltip();
}
- ImGui.PushItemWidth(width * 0.35f);
ref float playerOpacity = ref MemoryUtil.GetRef<float>(player.Instance + 0x78E0);
+ ImGui.SetNextItemWidth(width * 0.325f);
if (ImGui.DragFloat("Opacity", ref playerOpacity, 0.01f, 0.0f, Single.MaxValue))
{
playerOpacityOverride = playerOpacity;
}
- ImGui.PopItemWidth();
if (ImGui.CollapsingHeader("Wetness"))
{
@@ -3192,6 +3230,7 @@ namespace NewCamera }
}
+ ImGui.PushItemWidth(width * 0.8f);
ImGui.DragFloat3("Position", ref player.Position, 0.5f);
Vector3 forward;
forward.X = player.Forward.X;
@@ -3210,6 +3249,7 @@ namespace NewCamera player.Rotation.Z = rotation.Z;
player.Rotation.W = rotation.W;
}
+ ImGui.PopItemWidth();
if (ImGui.Button("Reset"))
{
player.Rotation.X = 0.0f;
@@ -3376,137 +3416,120 @@ namespace NewCamera ImGui.Separator();
- ImGui.Checkbox("Enable Free Camera", ref enableFreeCamera);
- if (enableFreeCamera)
- {
- ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true);
- ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
- }
if (ImGui.Checkbox("Enable Perspective Camera", ref enableOffsetPerspective))
{
config.PerspectiveCameraEnabled = enableOffsetPerspective;
+ if (enableOffsetPerspective)
+ {
+ if (config.Selected != "")
+ {
+ setPerspectivePreset(config.Presets[config.Selected]);
+ }
+ }
+ else if (!freeCamera && disableFading)
+ {
+ setDisableFading(false);
+ }
ConfigManager.SaveConfig<Config>(this);
}
- if (enableFreeCamera)
+ if (enableOffsetPerspective)
{
- ImGui.PopItemFlag();
- ImGui.PopStyleVar();
- }
-
- ImGui.PushID("Perspective");
- ImGui.PushItemWidth(width * 0.575f);
- ImGui.DragFloat("Field of View", ref cameraFov, 0.4f, 1.0f, 179.0f);
- ImGui.DragFloat("Forward", ref cameraForward, 0.25f);
- ImGui.DragFloat("Right", ref cameraRight, 0.25f);
- ImGui.DragFloat("Up", ref cameraUp, 0.025f);
- if (ImGui.DragFloat("Roll", ref cameraRoll, 0.25f))
- {
- if (restoreRoll != null)
+ ImGui.PushID("Perspective");
+ ImGui.PushItemWidth(width * 0.575f);
+ ImGui.DragFloat("Field of View", ref cameraFov, 0.4f, 1.0f, 179.0f);
+ ImGui.DragFloat("Roll", ref cameraRoll, 0.25f);
+ if (freeCamera)
{
- restoreRoll = cameraRoll;
+ ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
}
- }
- if (freeCamera)
- {
- ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
- }
- ImGui.PopItemWidth();
- if (ImGui.Checkbox("Disable Fading", ref disableFading))
- {
- if (pCameraViewportIndex >= 0)
+ ImGui.DragFloat("Forward", ref cameraForward, 0.25f);
+ ImGui.DragFloat("Right", ref cameraRight, 0.25f);
+ ImGui.DragFloat("Up", ref cameraUp, 0.025f);
+ ImGui.PopItemWidth();
+ if (ImGui.Checkbox("Disable Fading", ref disableFading))
{
- setDisableFadingObjects(pCameraViewportIndex, disableFading);
+ setDisableFading(disableFading);
}
- setDisableCharacterFade(disableFading);
- }
- if (ImGui.BeginItemTooltip())
- {
- ImGui.Text("Disable transparency fading when the camera gets close to something.\nApplies to Objects, Players, Palicos and NPCs.\nEnabled by default while in free camera.");
- ImGui.EndTooltip();
- }
- if (freeCamera)
- {
- ImGui.PopStyleVar();
- }
- if (ImGui.Button("Default"))
- {
- cameraFov = DEFAULT_FOV;
- cameraForward = 0.0f;
- cameraRight = 0.0f;
- cameraUp = 0.0f;
- cameraRoll = 0.0f;
- if (restoreRoll != null)
+ if (ImGui.BeginItemTooltip())
{
- restoreRoll = cameraRoll;
+ ImGui.Text("Disable transparency fading when the camera is close to something.\nApplies to objects, monsters, players, palicos and NPCs.\nEnabled by default when entering free camera.");
+ ImGui.EndTooltip();
}
- disableFading = false;
- if (pCameraViewportIndex >= 0)
+ if (freeCamera)
{
- setDisableFadingObjects(pCameraViewportIndex, false);
+ ImGui.PopStyleVar();
}
- setDisableCharacterFade(false);
- config.Selected = "";
- ConfigManager.SaveConfig<Config>(this);
- }
- ImGui.SameLine();
- ImGui.PushItemWidth(width * 0.2f);
- ImGui.InputText("##Preset Name", ref typedPresetName, 99);
- ImGui.SameLine();
- if (ImGui.Button("Save"))
- {
- string name = typedPresetName;
- if (name != "")
+ if (ImGui.Button("Default"))
{
- Config.Preset preset = new Config.Preset();
- preset.FieldOfView = cameraFov;
- preset.Forward = cameraForward;
- preset.Right = cameraRight;
- preset.Up = cameraUp;
- preset.Roll = cameraRoll;
- preset.DisableFading = (pCameraViewportIndex >= 0) ? getDisableFadingObjects(pCameraViewportIndex) : false;
- if (config.Presets.ContainsKey(name))
+ setPerspectivePreset(Config.DefaultPreset);
+ config.Selected = "";
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ ImGui.SameLine();
+ ImGui.PushItemWidth(width * 0.2f);
+ ImGui.InputText("##Preset Name", ref typedPresetName, 99);
+ ImGui.SameLine();
+ if (ImGui.Button("Save"))
+ {
+ string name = typedPresetName;
+ if (name != "")
{
- config.Presets[name] = preset;
+ Config.Preset preset = new Config.Preset()
+ {
+ FieldOfView = cameraFov,
+ Roll = cameraRoll,
+ Forward = cameraForward,
+ Right = cameraRight,
+ Up = cameraUp,
+ DisableFading = disableFading
+ };
+ if (config.Presets.ContainsKey(name))
+ {
+ config.Presets[name] = preset;
+ }
+ else
+ {
+ config.Presets.Add(name, preset);
+ }
+ config.Selected = name;
+ ConfigManager.SaveConfig<Config>(this);
}
- else
+ }
+ ImGui.SameLine();
+ if (ImGui.BeginCombo("##Preset", config.Selected))
+ {
+ Dictionary<string, Config.Preset>.KeyCollection presetKeys = config.Presets.Keys;
+ for (int i = 0; i < presetKeys.Count; i++)
{
- config.Presets.Add(name, preset);
+ string presetKey = presetKeys.ElementAt(i);
+ bool isSelected = presetKey == config.Selected;
+ if (ImGui.Selectable(presetKey, isSelected))
+ {
+ config.Selected = presetKey;
+ setPerspectivePreset(config.Presets[config.Selected]);
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ if (isSelected) ImGui.SetItemDefaultFocus();
}
- config.Selected = name;
- ConfigManager.SaveConfig<Config>(this);
+ ImGui.EndCombo();
}
- }
- ImGui.SameLine();
- if (ImGui.BeginCombo("##Preset", config.Selected))
- {
- Dictionary<string, Config.Preset>.KeyCollection presetKeys = config.Presets.Keys;
- for (int i = 0; i < presetKeys.Count; i++)
+ ImGui.PopItemWidth();
+ ImGui.SameLine();
+ if (ImGui.Button("Delete"))
{
- string presetKey = presetKeys.ElementAt(i);
- bool isSelected = presetKey == config.Selected;
- if (ImGui.Selectable(presetKey, isSelected))
+ if (config.Selected != "")
{
- config.Selected = presetKey;
- setPerspectivePreset(config.Presets[config.Selected]);
+ config.Presets.Remove(config.Selected);
+ config.Selected = "";
ConfigManager.SaveConfig<Config>(this);
}
- if (isSelected) ImGui.SetItemDefaultFocus();
- }
- ImGui.EndCombo();
- }
- ImGui.PopItemWidth();
- ImGui.SameLine();
- if (ImGui.Button("Delete"))
- {
- if (config.Selected != "")
- {
- config.Presets.Remove(config.Selected);
- config.Selected = "";
- ConfigManager.SaveConfig<Config>(this);
}
+ ImGui.PopID();
}
- ImGui.PopID();
+ ImGui.Separator();
+
+ ImGui.Checkbox("Enable Free Camera", ref enableFreeCamera);
ImGui.PushID("Settings");
ImGui.PushItemWidth(width * 0.575f);
ImGui.DragFloat("Camera Speed", ref cameraSpeed, 0.01f, 0.0f, 0.0f, "%.4f");
@@ -3586,16 +3609,10 @@ namespace NewCamera ImGui.PushID("Toggles");
ImGui.Text("Toggles");
- if (ImGui.Checkbox("Disable UI", ref uiToggled))
+ bool uiWasToggled = uiToggled;
+ if (ImGui.Checkbox("Disable UI", ref uiWasToggled))
{
- if (uiToggled)
- {
- jmpOverUi.Enable();
- }
- else
- {
- jmpOverUi.Disable();
- }
+ toggleUi();
}
if (ImGui.BeginItemTooltip())
{
@@ -3637,7 +3654,7 @@ namespace NewCamera }
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Changing the near clip will subtly break rendering of various effects.\nTemporarily lowering the near clip can allow you to get the camera closer to things without clipping.");
+ ImGui.Text("Changing the near clip will break the rendering of shadows and various effects.\nTemporarily reducing the near clip can allow you to move the camera closer to things without clipping.");
ImGui.EndTooltip();
}
ImGui.SameLine();
@@ -3667,16 +3684,12 @@ namespace NewCamera ImGui.Text("Set Disable Fading in the camera preset above for these to persist.");
ImGui.EndTooltip();
}
- if (vCameraViewportIndex >= 0)
+ bool disableFadingObjects = !getPassthroughEnabled();
+ if (ImGui.Checkbox("Disable Fading of Objects/Monsters", ref disableFadingObjects))
{
- bool disableFadingObjects = getDisableFadingObjects(vCameraViewportIndex);
- if (ImGui.Checkbox("Disable Fading Objects", ref disableFadingObjects))
- {
- setDisableFadingObjects(vCameraViewportIndex, disableFadingObjects);
- }
+ setPassthroughEnabled(!disableFadingObjects);
}
-
- if (ImGui.Checkbox("Disable Fading Player/Palico/NPCs", ref disableCharacterFade))
+ if (ImGui.Checkbox("Disable Fading of Player/Palico/NPCs", ref disableCharacterFade))
{
if (disableCharacterFade)
{
@@ -4172,12 +4185,11 @@ namespace NewCamera ImGui.Separator();
- ImGui.Text($"sMhPlayer: {Player.SingletonInstance}");
-
+ ImGui.PushID("Player");
+ ImGui.Text("Player:");
+ ImGui.Text($"sMhPlayer: {sPlayer.Instance:X}");
if (player != null)
{
- ImGui.PushID("Player");
- ImGui.Text("Player:");
ImGui.Text($"Address: {player.Instance:X}");
drawAnimationInfo(player, width, true);
@@ -4193,17 +4205,17 @@ namespace NewCamera {
player.Fix = fix;
}
- ImGui.PopID();
ImGui.Separator();
+ }
+ ImGui.PopID();
- ImGui.PushID("Palico");
- ImGui.Text("Palico/Otomo");
- ImGui.Text($"Address: {sOtomo.Instance:X}");
- ImGui.PopID();
+ ImGui.PushID("Palico");
+ ImGui.Text("Palico/Otomo:");
+ ImGui.Text($"sOtomo: {sOtomo.Instance:X}");
+ ImGui.PopID();
- ImGui.Separator();
- }
+ ImGui.Separator();
Monster[] monsters = Monster.GetAllMonsters();
if (monsters.Length != 0 && ImGui.CollapsingHeader("Monsters"))
@@ -4314,7 +4326,7 @@ namespace NewCamera if (ImGui.CollapsingHeader("Credits"))
{
ImGui.TextWrapped("Fexty/SharpPluginLoader Authors: Framework for this mod and reference for various memory locations.");
- ImGui.TextWrapped("Otis_Inf: Initial LOD and object fading adjustment locations. Time of day and game speed.");
+ ImGui.TextWrapped("Otis_Inf: Initial LOD and object fading adjustment locations, time of day and game speed.");
ImGui.TextWrapped("Andoryuuta: MHW-ClassPropDump/MHW-DTI-Dumps.");
ImGui.TextWrapped("MonsterHunterWorldModding/wiki Authors.");
}
|