Skip to content

Commit

Permalink
etc
Browse files Browse the repository at this point in the history
  • Loading branch information
aedenthorn committed Sep 10, 2021
1 parent e3dae17 commit 89909be
Show file tree
Hide file tree
Showing 10 changed files with 266 additions and 64 deletions.
Binary file modified .vs/PortiaMods/v16/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion 1DebugUtils/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using UnityEngine;
using UnityModManagerNet;

namespace DebugUtils
namespace FieldOfView
{
public class Main
{
Expand Down
2 changes: 1 addition & 1 deletion 1DebugUtils/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using UnityModManagerNet;

namespace DebugUtils
namespace FieldOfView
{
public class Settings : UnityModManager.ModSettings
{
Expand Down
2 changes: 2 additions & 0 deletions Cheats/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Pathea.ActorNs;
using Pathea.AppearNs;
using Pathea.BlackBoardNs;
using Pathea.CameraSystemNs;
using Pathea.ConfigNs;
using Pathea.DungeonModuleNs;
using Pathea.FavorSystemNs;
Expand Down Expand Up @@ -132,6 +133,7 @@ private static ItemBox CreateTreasure(Transform point, string prefabPath, int re
component.transform.rotation = point.rotation;
return component;
}
private static float fov = 45;
private static void OnUpdate(UnityModManager.ModEntry arg1, float arg2)
{
if (Input.GetKeyDown(","))
Expand Down
11 changes: 0 additions & 11 deletions ClassLibrary1/Class1.cs

This file was deleted.

50 changes: 0 additions & 50 deletions ClassLibrary1/ClassLibrary1.csproj

This file was deleted.

77 changes: 77 additions & 0 deletions FieldOfView/FieldOfView.csproj
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>
157 changes: 157 additions & 0 deletions FieldOfView/Main.cs
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;
}
}
}
}
21 changes: 21 additions & 0 deletions FieldOfView/Settings.cs
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);
}
}
}
8 changes: 7 additions & 1 deletion PortiaMods.sln
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chests", "Chests\Chests.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnhancedRomanceChance", "EnhancedRomanceChance\EnhancedRomanceChance.csproj", "{3DCE8512-F3D8-4745-9CE1-09302B366369}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryStorageSize", "FactoryStorageSize\FactoryStorageSize.csproj", "{DABF37E7-DE0A-4FD6-8D01-A0AD2459F445}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryStorageSize", "FactoryStorageSize\FactoryStorageSize.csproj", "{DABF37E7-DE0A-4FD6-8D01-A0AD2459F445}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FieldOfView", "FieldOfView\FieldOfView.csproj", "{78A794C6-0D3E-4ECA-98DD-4D0F65F46DBA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -453,6 +455,10 @@ Global
{DABF37E7-DE0A-4FD6-8D01-A0AD2459F445}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DABF37E7-DE0A-4FD6-8D01-A0AD2459F445}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DABF37E7-DE0A-4FD6-8D01-A0AD2459F445}.Release|Any CPU.Build.0 = Release|Any CPU
{78A794C6-0D3E-4ECA-98DD-4D0F65F46DBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78A794C6-0D3E-4ECA-98DD-4D0F65F46DBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78A794C6-0D3E-4ECA-98DD-4D0F65F46DBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78A794C6-0D3E-4ECA-98DD-4D0F65F46DBA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 89909be

Please sign in to comment.