Skip to content

Commit

Permalink
PostProcessing
Browse files Browse the repository at this point in the history
  • Loading branch information
aedenthorn committed May 27, 2020
1 parent 7e2bc1d commit 090b248
Show file tree
Hide file tree
Showing 9 changed files with 405 additions and 3 deletions.
Binary file modified .vs/PortiaMods/v16/.suo
Binary file not shown.
92 changes: 92 additions & 0 deletions CustomQuests/CustomQuests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?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>{06F79FB4-D84F-4C73-B804-D3D4A4813BE3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CustomQuests</RootNamespace>
<AssemblyName>CustomQuests</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>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityModManager\0Harmony12.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\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>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AnimationModule">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.UIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestAudioModule">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestModule">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.UnityWebRequestModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestWWWModule">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll</HintPath>
</Reference>
<Reference Include="UnityModManager">
<HintPath>H:\tmp\ga\MTAP\Portia_Data\Managed\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" />
</Project>
90 changes: 90 additions & 0 deletions CustomQuests/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using Harmony12;
using SimpleJSON;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEngine;
using UnityModManagerNet;

namespace CustomQuests
{
public partial class Main
{
private static bool isDebug = false;

public static void Dbgl(string str = "", bool pref = true)
{
if (isDebug)
Debug.Log((pref ? "CustomQuests " : "") + str);
}
public static bool enabled;
public static Settings settings { get; private set; }

public static Dictionary<int, string> nameDesc = new Dictionary<int, string>();
public static Dictionary<int, int> sourceStrings = new Dictionary<int, int>();

// Send a response to the mod manager about the launch status, success or not.
private static bool Load(UnityModManager.ModEntry modEntry)
{
settings = UnityModManager.ModSettings.Load<Settings>(modEntry);
modEntry.OnToggle = OnToggle;
modEntry.OnGUI = OnGUI;
modEntry.OnSaveGUI = OnSaveGUI;

var harmony = HarmonyInstance.Create(modEntry.Info.Id);
harmony.PatchAll(Assembly.GetExecutingAssembly());

LoadItems();

//LoadItemFile();

return true;
}

private static void LoadItems()
{
// weapons items
string path = $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\\assets\\";
if (Directory.Exists(path))
{
string[] files = Directory.GetFiles(path, "*.json");
foreach (string file in files)
{
try
{
JSONNode jsonRoot = JSONNode.Parse(File.ReadAllText(file));
if (jsonRoot != null)
{
for (int i = 0; i < jsonRoot.Count; i++)
{
JSONNode jsonNode = jsonRoot[i];
storeItems.Add(new StoreItem(jsonNode["ID"].AsInt, productIds++, jsonNode["count"].AsInt, jsonNode["currency"].AsInt, jsonNode["requireMission"], jsonNode["storeId"].AsInt, jsonNode["chance"].AsFloat));
}
}
}
catch (Exception arg)
{
Debug.LogError("exception reading json file:" + arg);
}
}
}
}

private static void OnSaveGUI(UnityModManager.ModEntry modEntry)
{
settings.Save(modEntry);
}

private static void OnGUI(UnityModManager.ModEntry modEntry)
{
}

// 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.
}
}
}
13 changes: 13 additions & 0 deletions CustomQuests/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using UnityModManagerNet;

namespace CustomQuests
{
public class Settings : UnityModManager.ModSettings
{
public override void Save(UnityModManager.ModEntry modEntry)
{
Save(this, modEntry);
}
}
}
6 changes: 6 additions & 0 deletions PortiaMods.sln
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenDungeons", "OpenDungeon
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PostProcessing", "PostProcessing\PostProcessing.csproj", "{5AD3331E-8F85-4E91-96F0-C65972137ADA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomQuests", "CustomQuests\CustomQuests.csproj", "{06F79FB4-D84F-4C73-B804-D3D4A4813BE3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -243,6 +245,10 @@ Global
{5AD3331E-8F85-4E91-96F0-C65972137ADA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AD3331E-8F85-4E91-96F0-C65972137ADA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AD3331E-8F85-4E91-96F0-C65972137ADA}.Release|Any CPU.Build.0 = Release|Any CPU
{06F79FB4-D84F-4C73-B804-D3D4A4813BE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06F79FB4-D84F-4C73-B804-D3D4A4813BE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06F79FB4-D84F-4C73-B804-D3D4A4813BE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06F79FB4-D84F-4C73-B804-D3D4A4813BE3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
116 changes: 116 additions & 0 deletions PostProcessing/Main.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Harmony12;
using Hont.ExMethod.Collection;
using NovaEnv;
using Pathea.WeatherNs;
using System;
Expand Down Expand Up @@ -30,6 +31,21 @@ public static partial class Main
"Very Large"
};

private static string[] fxaaPresets = new string[] {
"Extreme Performance",
"Performance",
"Default",
"Quality",
"Extreme Quality"
};

private static Dictionary<string,int> sampleCounts = new Dictionary<string, int> {
{ "Lowest",3 },
{ "Low",6 },
{ "Medium",10 },
{ "High",16 },
};

public static void Dbgl(string str = "", bool pref = true)
{
if (isDebug)
Expand Down Expand Up @@ -435,6 +451,106 @@ private static void OnGUI(UnityModManager.ModEntry modEntry)

}

GUILayout.Space(10f);


settings.customAO = GUILayout.Toggle(settings.customAO, "<b>Use Custom Ambient Occlusion</b>", new GUILayoutOption[0]);
if (settings.customAO)
{
GUILayout.Space(10f);
GUILayout.BeginHorizontal();
GUILayout.Space(indentSpace);
GUILayout.BeginVertical();

GUILayout.Label(new GUIContent(string.Format("Intensity <b>{0:F2}</b> ", settings.AOIntensity), "Degree of darkness produced by the effect."), new GUILayoutOption[0]);
settings.AOIntensity = GUILayout.HorizontalSlider((float)settings.AOIntensity * 100f, 0f, 400f) / 100f;

GUILayout.Space(10f);


GUILayout.Label(new GUIContent(string.Format("Radius <b>{0:F2}</b> ", settings.AORadius), "Radius of sample points, which affects extent of darkened areas."), new GUILayoutOption[0]);
settings.AORadius = GUILayout.HorizontalSlider((float)settings.AORadius * 10000f, 1f, 10000) / 10000f;

GUILayout.Space(10f);


GUILayout.Label(new GUIContent(string.Format("Sample Count <b>{0:F2}</b> ", sampleCounts.Keys.ToArray()[settings.AOSampleCount]), "Number of sample points, which affects quality and performance."), new GUILayoutOption[0]);
settings.AOSampleCount = (int)GUILayout.HorizontalSlider((float)settings.AOSampleCount, 0f, 3f);

GUILayout.Space(10f);


settings.AODownsampling = GUILayout.Toggle(settings.AODownsampling, new GUIContent("Downsample", "Halves the resolution of the effect to increase performance at the cost of visual quality."), new GUILayoutOption[0]);
GUILayout.Space(10f);

settings.AOForceForwardCompatibility = GUILayout.Toggle(settings.AOForceForwardCompatibility, new GUIContent("Force Forward Compatibility", "Forces compatibility with Forward rendered objects when working with the Deferred rendering path."), new GUILayoutOption[0]);
GUILayout.Space(10f);

settings.AOAmbientOnly = GUILayout.Toggle(settings.AOAmbientOnly, new GUIContent("Ambient Only", "Enables the ambient-only mode in that the effect only affects ambient lighting. This mode is only available with the Deferred rendering path and HDR rendering."), new GUILayoutOption[0]);
GUILayout.Space(10f);

settings.AOHighPrecision = GUILayout.Toggle(settings.AOHighPrecision, new GUIContent("High Precision", "Toggles the use of a higher precision depth texture with the forward rendering path (may impact performances). Has no effect with the deferred rendering path."), new GUILayoutOption[0]);
GUILayout.Space(10f);

GUILayout.EndVertical();
GUILayout.EndHorizontal();

}

GUILayout.Space(10f);


settings.customAA = GUILayout.Toggle(settings.customAA, "<b>Use Custom Anti-Aliasing</b>", new GUILayoutOption[0]);
if (settings.customAA)
{
GUILayout.Space(10f);
GUILayout.BeginHorizontal();
GUILayout.Space(indentSpace);
GUILayout.BeginVertical();

settings.AAMethodTaa = !GUILayout.Toggle(!settings.AAMethodTaa, "<b>Use Fxaa Anti-Aliasing</b>", new GUILayoutOption[0]);
settings.AAMethodTaa = GUILayout.Toggle(settings.AAMethodTaa, "<b>Use Taa Anti-Aliasing</b>", new GUILayoutOption[0]);

if (settings.AAMethodTaa)
{
GUILayout.Label(new GUIContent(string.Format("Jitter Spread <b>{0:F2}</b> ", settings.AAJitterSpread), "The diameter (in texels) inside which jitter samples are spread. Smaller values result in crisper but more aliased output, while larger values result in more stable but blurrier output."), new GUILayoutOption[0]);
settings.AAJitterSpread = GUILayout.HorizontalSlider((float)settings.AAJitterSpread*100f, 10f, 100f)/100f;

GUILayout.Space(10f);


GUILayout.Label(new GUIContent(string.Format("Sharpen <b>{0:F2}</b> ", settings.AASharpen), "Controls the amount of sharpening applied to the color buffer."), new GUILayoutOption[0]);
settings.AASharpen = GUILayout.HorizontalSlider((float)settings.AASharpen * 100f, 0, 300f)/100f;

GUILayout.Space(10f);


GUILayout.Label(new GUIContent(string.Format("Stationary Blending <b>{0:F2}</b> ", settings.AAStationaryBlending), "The blend coefficient for a stationary fragment. Controls the percentage of history sample blended into the final color."), new GUILayoutOption[0]);
settings.AAStationaryBlending = GUILayout.HorizontalSlider((float)settings.AAStationaryBlending * 100f, 0f, 99f)/100f;

GUILayout.Space(10f);


GUILayout.Label(new GUIContent(string.Format("Motion Blending <b>{0:F2}</b> ", settings.AAMotionBlending), "The blend coefficient for a fragment with significant motion. Controls the percentage of history sample blended into the final color."), new GUILayoutOption[0]);
settings.AAMotionBlending = GUILayout.HorizontalSlider((float)settings.AAMotionBlending * 100f, 0f, 99f)/100f;

}
else
{
GUILayout.Label(new GUIContent(string.Format("Fxaa Preset <b>{0}</b> ", fxaaPresets[settings.AAFxaaPreset]), ""), new GUILayoutOption[0]);
settings.AAFxaaPreset = (int)GUILayout.HorizontalSlider((float)settings.AAFxaaPreset, 0f, 4f);


}

GUILayout.Space(10f);


GUILayout.EndVertical();
GUILayout.EndHorizontal();

}

GUILayout.Space(20f);

GUILayout.EndVertical();
Expand Down
Loading

0 comments on commit 090b248

Please sign in to comment.