-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3dae17
commit 89909be
Showing
10 changed files
with
266 additions
and
64 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{78A794C6-0D3E-4ECA-98DD-4D0F65F46DBA}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>FieldOfView</RootNamespace> | ||
<AssemblyName>FieldOfView</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="0Harmony12"> | ||
<HintPath>..\external\UnityModManager\0Harmony12.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>..\external\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp-firstpass"> | ||
<HintPath>..\external\Assembly-CSharp-firstpass.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>..\external\UnityEngine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.CoreModule"> | ||
<HintPath>..\external\UnityEngine.CoreModule.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.IMGUIModule"> | ||
<HintPath>..\external\UnityEngine.IMGUIModule.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.UI"> | ||
<HintPath>..\external\UnityEngine.UI.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.UIModule"> | ||
<HintPath>..\external\UnityEngine.UIModule.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityModManager"> | ||
<HintPath>..\external\UnityModManager\UnityModManager.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Main.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Settings.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<PostBuildEvent>call $(SolutionDir)copyDll.bat FieldOfView</PostBuildEvent> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
using Harmony12; | ||
using Pathea.CameraSystemNs; | ||
using Pathea.UISystemNs; | ||
using System.Reflection; | ||
using UnityEngine; | ||
using UnityModManagerNet; | ||
|
||
namespace FieldOfView | ||
{ | ||
public class Main | ||
{ | ||
public static Settings settings { get; private set; } | ||
public static bool enabled; | ||
|
||
private static readonly bool isDebug = true; | ||
|
||
public static void Dbgl(string str = "", bool pref = true) | ||
{ | ||
if (isDebug) | ||
Debug.Log((pref ? typeof(Main).Namespace + " " : "") + str); | ||
} | ||
|
||
private static void Load(UnityModManager.ModEntry modEntry) | ||
{ | ||
settings = UnityModManager.ModSettings.Load<Settings>(modEntry); | ||
|
||
modEntry.OnGUI = OnGUI; | ||
modEntry.OnSaveGUI = OnSaveGUI; | ||
modEntry.OnToggle = OnToggle; | ||
modEntry.OnUpdate = OnUpdate; | ||
|
||
var harmony = HarmonyInstance.Create(modEntry.Info.Id); | ||
harmony.PatchAll(Assembly.GetExecutingAssembly()); | ||
} | ||
|
||
// Called when the mod is turned to on/off. | ||
static bool OnToggle(UnityModManager.ModEntry modEntry, bool value /* active or inactive */) | ||
{ | ||
enabled = value; | ||
return true; // Permit or not. | ||
} | ||
private static void OnSaveGUI(UnityModManager.ModEntry modEntry) | ||
{ | ||
settings.Save(modEntry); | ||
} | ||
|
||
private static void OnGUI(UnityModManager.ModEntry modEntry) | ||
{ | ||
GUILayout.Label(string.Format("Current Field of View: <b>{0:F0}</b>", settings.FieldOfView), new GUILayoutOption[0]); | ||
settings.FieldOfView = GUILayout.HorizontalSlider(settings.FieldOfView, 1, 180, new GUILayoutOption[0]); | ||
GUILayout.Space(10f); | ||
|
||
settings.UseScrollWheel = GUILayout.Toggle(settings.UseScrollWheel, "Use scroll wheel to change FOV", new GUILayoutOption[0]); | ||
GUILayout.Space(10f); | ||
|
||
GUILayout.Label(string.Format("Ordinary Increment: <b>{0:F0}</b>", settings.IncrementNormal), new GUILayoutOption[0]); | ||
settings.IncrementNormal = GUILayout.HorizontalSlider(settings.IncrementNormal, 1f, 50f, new GUILayoutOption[0]); | ||
GUILayout.Space(10f); | ||
|
||
GUILayout.Label(string.Format("Fast Increment: <b>{0:F0}</b>", settings.IncrementFast), new GUILayoutOption[0]); | ||
settings.IncrementFast = GUILayout.HorizontalSlider(settings.IncrementFast, 1f, 50f, new GUILayoutOption[0]); | ||
GUILayout.Space(10f); | ||
|
||
GUILayout.Space(10f); | ||
GUILayout.BeginHorizontal(); | ||
GUILayout.Label("Ordinary Increment Modifier Key: ", new GUILayoutOption[0]); | ||
settings.ModKeyNormal = GUILayout.TextField(settings.ModKeyNormal, new GUILayoutOption[] { GUILayout.Width(100) }); | ||
GUILayout.EndHorizontal(); | ||
GUILayout.Space(10f); | ||
|
||
GUILayout.BeginHorizontal(); | ||
GUILayout.Label("Fast Increment Modifier Key: ", new GUILayoutOption[0]); | ||
settings.ModKeyFast = GUILayout.TextField(settings.ModKeyFast, new GUILayoutOption[] { GUILayout.Width(100) }); | ||
GUILayout.EndHorizontal(); | ||
|
||
GUILayout.Space(20f); | ||
|
||
GUILayout.BeginHorizontal(); | ||
GUILayout.Label("Increase FOV Key: ", new GUILayoutOption[0]); | ||
settings.KeyIncrease = GUILayout.TextField(settings.KeyIncrease, new GUILayoutOption[] { GUILayout.Width(100) }); | ||
GUILayout.EndHorizontal(); | ||
GUILayout.Space(10f); | ||
|
||
GUILayout.BeginHorizontal(); | ||
GUILayout.Label("Decrease FOV Key: ", new GUILayoutOption[0]); | ||
settings.KeyDecrease = GUILayout.TextField(settings.KeyDecrease, new GUILayoutOption[] { GUILayout.Width(100) }); | ||
GUILayout.EndHorizontal(); | ||
GUILayout.Space(10f); | ||
} | ||
|
||
private static void OnUpdate(UnityModManager.ModEntry arg1, float arg2) | ||
{ | ||
if ( | ||
(settings.UseScrollWheel && Input.mouseScrollDelta.y != 0 && (CheckKeyHeld(settings.ModKeyNormal) || CheckKeyHeld(settings.ModKeyFast))) || | ||
((CheckKeyDown(settings.KeyIncrease) || CheckKeyDown(settings.KeyDecrease)) && (CheckKeyHeld(settings.ModKeyNormal, false) || CheckKeyHeld(settings.ModKeyFast, false))) | ||
) | ||
{ | ||
float change = CheckKeyHeld(settings.ModKeyFast) ? settings.IncrementFast : settings.IncrementNormal; | ||
|
||
if (Input.mouseScrollDelta.y > 0) | ||
settings.FieldOfView -= change; | ||
else if (Input.mouseScrollDelta.y < 0) | ||
settings.FieldOfView += change; | ||
else if (CheckKeyDown(settings.KeyIncrease)) | ||
settings.FieldOfView += change; | ||
else if (CheckKeyDown(settings.KeyDecrease)) | ||
settings.FieldOfView -= change; | ||
|
||
settings.FieldOfView = Mathf.Clamp(settings.FieldOfView, 1, 180); | ||
//Dbgl($"scrolling {Input.mouseScrollDelta.y}; camera fov {settings.FieldOfView}"); | ||
} | ||
} | ||
|
||
|
||
|
||
[HarmonyPatch(typeof(PlayerItemBarCtr), "AddSlotIndex")] | ||
static class PlayerItemBarCtr_AddSlotIndex_Patch | ||
{ | ||
static bool Prefix() | ||
{ | ||
return !enabled || (!CheckKeyHeld(settings.ModKeyNormal) && !CheckKeyHeld(settings.ModKeyFast)); | ||
} | ||
} | ||
[HarmonyPatch(typeof(StandardThirdPersonCameraController), "OnCameraActiveUpdate")] | ||
static class StandardThirdPersonCameraController_OnCameraActiveUpdate_Patch | ||
{ | ||
static void Postfix(CameraAgent cameraAgent) | ||
{ | ||
if (!enabled) | ||
return; | ||
cameraAgent.FieldOfView = settings.FieldOfView; | ||
} | ||
} | ||
public static bool CheckKeyDown(string value) | ||
{ | ||
try | ||
{ | ||
return Input.GetKeyDown(value.ToLower()); | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
} | ||
public static bool CheckKeyHeld(string value, bool req = true) | ||
{ | ||
try | ||
{ | ||
return Input.GetKey(value.ToLower()); | ||
} | ||
catch | ||
{ | ||
return !req; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using UnityModManagerNet; | ||
|
||
namespace FieldOfView | ||
{ | ||
public class Settings : UnityModManager.ModSettings | ||
{ | ||
public bool UseScrollWheel { get; set; } = true; | ||
public float FieldOfView { get; set; } = 45; | ||
public float IncrementNormal { get; set; } = 1; | ||
public float IncrementFast { get; set; } = 5; | ||
public string KeyDecrease { get; set; } = ""; | ||
public string KeyIncrease { get; set; } = ""; | ||
public string ModKeyNormal { get; set; } = "left ctrl"; | ||
public string ModKeyFast { get; set; } = "left alt"; | ||
|
||
public override void Save(UnityModManager.ModEntry modEntry) | ||
{ | ||
Save(this, modEntry); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters