@ -0,0 +1,17 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace IllusionPlugin | |||||
{ | |||||
public interface IEnhancedPlugin : IPlugin | |||||
{ | |||||
/// <summary> | |||||
/// Gets a list of executables this plugin should be excuted on (without the file ending) | |||||
/// </summary> | |||||
/// <example>{ "PlayClub", "PlayClubStudio" }</example> | |||||
string[] Filter { get; } | |||||
void OnLateUpdate(); | |||||
} | |||||
} |
@ -0,0 +1,57 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace IllusionPlugin | |||||
{ | |||||
/// <summary> | |||||
/// Interface for generic Illusion unity plugins. Every class that implements this will be loaded if the DLL is placed at | |||||
/// data/Managed/Plugins. | |||||
/// </summary> | |||||
public interface IPlugin | |||||
{ | |||||
/// <summary> | |||||
/// Gets the name of the plugin. | |||||
/// </summary> | |||||
string Name { get; } | |||||
/// <summary> | |||||
/// Gets the version of the plugin. | |||||
/// </summary> | |||||
string Version { get; } | |||||
/// <summary> | |||||
/// Gets invoked when the application is started. | |||||
/// </summary> | |||||
void OnApplicationStart(); | |||||
/// <summary> | |||||
/// Gets invoked when the application is closed. | |||||
/// </summary> | |||||
void OnApplicationQuit(); | |||||
/// <summary> | |||||
/// Gets invoked whenever a level is loaded. | |||||
/// </summary> | |||||
/// <param name="level"></param> | |||||
void OnLevelWasLoaded(int level); | |||||
/// <summary> | |||||
/// Gets invoked after the first update cycle after a level was loaded. | |||||
/// </summary> | |||||
/// <param name="level"></param> | |||||
void OnLevelWasInitialized(int level); | |||||
/// <summary> | |||||
/// Gets invoked on every graphic update. | |||||
/// </summary> | |||||
void OnUpdate(); | |||||
/// <summary> | |||||
/// Gets invoked on ever physics update. | |||||
/// </summary> | |||||
void OnFixedUpdate(); | |||||
} | |||||
} |
@ -0,0 +1,178 @@ | |||||
<?xml version="1.0"?> | |||||
<doc> | |||||
<assembly> | |||||
<name>IllusionPlugin</name> | |||||
</assembly> | |||||
<members> | |||||
<member name="P:IllusionPlugin.IEnhancedPlugin.Filter"> | |||||
<summary> | |||||
Gets a list of executables this plugin should be excuted on (without the file ending) | |||||
</summary> | |||||
<example>{ "PlayClub", "PlayClubStudio" }</example> | |||||
</member> | |||||
<member name="T:IllusionPlugin.IniFile"> | |||||
<summary> | |||||
Create a New INI file to store or load data | |||||
</summary> | |||||
</member> | |||||
<member name="M:IllusionPlugin.IniFile.#ctor(System.String)"> | |||||
<summary> | |||||
INIFile Constructor. | |||||
</summary> | |||||
<PARAM name="INIPath"></PARAM> | |||||
</member> | |||||
<member name="M:IllusionPlugin.IniFile.IniWriteValue(System.String,System.String,System.String)"> | |||||
<summary> | |||||
Write Data to the INI File | |||||
</summary> | |||||
<PARAM name="Section"></PARAM> | |||||
Section name | |||||
<PARAM name="Key"></PARAM> | |||||
Key Name | |||||
<PARAM name="Value"></PARAM> | |||||
Value Name | |||||
</member> | |||||
<member name="M:IllusionPlugin.IniFile.IniReadValue(System.String,System.String)"> | |||||
<summary> | |||||
Read Data Value From the Ini File | |||||
</summary> | |||||
<PARAM name="Section"></PARAM> | |||||
<PARAM name="Key"></PARAM> | |||||
<PARAM name="Path"></PARAM> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="T:IllusionPlugin.IPlugin"> | |||||
<summary> | |||||
Interface for generic Illusion unity plugins. Every class that implements this will be loaded if the DLL is placed at | |||||
data/Managed/Plugins. | |||||
</summary> | |||||
</member> | |||||
<member name="P:IllusionPlugin.IPlugin.Name"> | |||||
<summary> | |||||
Gets the name of the plugin. | |||||
</summary> | |||||
</member> | |||||
<member name="P:IllusionPlugin.IPlugin.Version"> | |||||
<summary> | |||||
Gets the version of the plugin. | |||||
</summary> | |||||
</member> | |||||
<member name="M:IllusionPlugin.IPlugin.OnApplicationStart"> | |||||
<summary> | |||||
Gets invoked when the application is started. | |||||
</summary> | |||||
</member> | |||||
<member name="M:IllusionPlugin.IPlugin.OnApplicationQuit"> | |||||
<summary> | |||||
Gets invoked when the application is closed. | |||||
</summary> | |||||
</member> | |||||
<member name="M:IllusionPlugin.IPlugin.OnLevelWasLoaded(System.Int32)"> | |||||
<summary> | |||||
Gets invoked whenever a level is loaded. | |||||
</summary> | |||||
<param name="level"></param> | |||||
</member> | |||||
<member name="M:IllusionPlugin.IPlugin.OnLevelWasInitialized(System.Int32)"> | |||||
<summary> | |||||
Gets invoked after the first update cycle after a level was loaded. | |||||
</summary> | |||||
<param name="level"></param> | |||||
</member> | |||||
<member name="M:IllusionPlugin.IPlugin.OnUpdate"> | |||||
<summary> | |||||
Gets invoked on every graphic update. | |||||
</summary> | |||||
</member> | |||||
<member name="M:IllusionPlugin.IPlugin.OnFixedUpdate"> | |||||
<summary> | |||||
Gets invoked on ever physics update. | |||||
</summary> | |||||
</member> | |||||
<member name="T:IllusionPlugin.ModPrefs"> | |||||
<summary> | |||||
Allows to get and set preferences for your mod. | |||||
</summary> | |||||
</member> | |||||
<member name="M:IllusionPlugin.ModPrefs.GetString(System.String,System.String,System.String,System.Boolean)"> | |||||
<summary> | |||||
Gets a string from the ini. | |||||
</summary> | |||||
<param name="section">Section of the key.</param> | |||||
<param name="name">Name of the key.</param> | |||||
<param name="defaultValue">Value that should be used when no value is found.</param> | |||||
<param name="autoSave">Whether or not the default value should be written if no value is found.</param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:IllusionPlugin.ModPrefs.GetInt(System.String,System.String,System.Int32,System.Boolean)"> | |||||
<summary> | |||||
Gets an int from the ini. | |||||
</summary> | |||||
<param name="section">Section of the key.</param> | |||||
<param name="name">Name of the key.</param> | |||||
<param name="defaultValue">Value that should be used when no value is found.</param> | |||||
<param name="autoSave">Whether or not the default value should be written if no value is found.</param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:IllusionPlugin.ModPrefs.GetFloat(System.String,System.String,System.Single,System.Boolean)"> | |||||
<summary> | |||||
Gets a float from the ini. | |||||
</summary> | |||||
<param name="section">Section of the key.</param> | |||||
<param name="name">Name of the key.</param> | |||||
<param name="defaultValue">Value that should be used when no value is found.</param> | |||||
<param name="autoSave">Whether or not the default value should be written if no value is found.</param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:IllusionPlugin.ModPrefs.GetBool(System.String,System.String,System.Boolean,System.Boolean)"> | |||||
<summary> | |||||
Gets a bool from the ini. | |||||
</summary> | |||||
<param name="section">Section of the key.</param> | |||||
<param name="name">Name of the key.</param> | |||||
<param name="defaultValue">Value that should be used when no value is found.</param> | |||||
<param name="autoSave">Whether or not the default value should be written if no value is found.</param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:IllusionPlugin.ModPrefs.HasKey(System.String,System.String)"> | |||||
<summary> | |||||
Checks whether or not a key exists in the ini. | |||||
</summary> | |||||
<param name="section">Section of the key.</param> | |||||
<param name="name">Name of the key.</param> | |||||
<returns></returns> | |||||
</member> | |||||
<member name="M:IllusionPlugin.ModPrefs.SetFloat(System.String,System.String,System.Single)"> | |||||
<summary> | |||||
Sets a float in the ini. | |||||
</summary> | |||||
<param name="section">Section of the key.</param> | |||||
<param name="name">Name of the key.</param> | |||||
<param name="value">Value that should be written.</param> | |||||
</member> | |||||
<member name="M:IllusionPlugin.ModPrefs.SetInt(System.String,System.String,System.Int32)"> | |||||
<summary> | |||||
Sets an int in the ini. | |||||
</summary> | |||||
<param name="section">Section of the key.</param> | |||||
<param name="name">Name of the key.</param> | |||||
<param name="value">Value that should be written.</param> | |||||
</member> | |||||
<member name="M:IllusionPlugin.ModPrefs.SetString(System.String,System.String,System.String)"> | |||||
<summary> | |||||
Sets a string in the ini. | |||||
</summary> | |||||
<param name="section">Section of the key.</param> | |||||
<param name="name">Name of the key.</param> | |||||
<param name="value">Value that should be written.</param> | |||||
</member> | |||||
<member name="M:IllusionPlugin.ModPrefs.SetBool(System.String,System.String,System.Boolean)"> | |||||
<summary> | |||||
Sets a bool in the ini. | |||||
</summary> | |||||
<param name="section">Section of the key.</param> | |||||
<param name="name">Name of the key.</param> | |||||
<param name="value">Value that should be written.</param> | |||||
</member> | |||||
</members> | |||||
</doc> |
@ -0,0 +1,55 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<Project ToolsVersion="4.0" DefaultTargets="Build" 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>{E2848BFB-5432-42F4-8AE0-D2EC0CDF2F71}</ProjectGuid> | |||||
<OutputType>Library</OutputType> | |||||
<AppDesignerFolder>Properties</AppDesignerFolder> | |||||
<RootNamespace>IllusionPlugin</RootNamespace> | |||||
<AssemblyName>IllusionPlugin</AssemblyName> | |||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | |||||
<FileAlignment>512</FileAlignment> | |||||
<TargetFrameworkProfile> | |||||
</TargetFrameworkProfile> | |||||
</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>none</DebugType> | |||||
<Optimize>true</Optimize> | |||||
<OutputPath>bin\Release\</OutputPath> | |||||
<DefineConstants>TRACE</DefineConstants> | |||||
<ErrorReport>prompt</ErrorReport> | |||||
<WarningLevel>4</WarningLevel> | |||||
<DocumentationFile>bin\Release\IllusionPlugin.XML</DocumentationFile> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<Reference Include="System" /> | |||||
<Reference Include="System.Data" /> | |||||
<Reference Include="System.Xml" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<Compile Include="IEnhancedPlugin.cs" /> | |||||
<Compile Include="IniFile.cs" /> | |||||
<Compile Include="IPlugin.cs" /> | |||||
<Compile Include="ModPrefs.cs" /> | |||||
<Compile Include="Properties\AssemblyInfo.cs" /> | |||||
</ItemGroup> | |||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |||||
Other similar extension points exist, see Microsoft.Common.targets. | |||||
<Target Name="BeforeBuild"> | |||||
</Target> | |||||
<Target Name="AfterBuild"> | |||||
</Target> | |||||
--> | |||||
</Project> |
@ -0,0 +1,89 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.IO; | |||||
using System.Runtime.InteropServices; | |||||
using System.Text; | |||||
namespace IllusionPlugin | |||||
{ | |||||
/// <summary> | |||||
/// Create a New INI file to store or load data | |||||
/// </summary> | |||||
internal class IniFile | |||||
{ | |||||
[DllImport("KERNEL32.DLL", EntryPoint = "GetPrivateProfileStringW", | |||||
SetLastError = true, | |||||
CharSet = CharSet.Unicode, ExactSpelling = true, | |||||
CallingConvention = CallingConvention.StdCall)] | |||||
private static extern int GetPrivateProfileString( | |||||
string lpSection, | |||||
string lpKey, | |||||
string lpDefault, | |||||
StringBuilder lpReturnString, | |||||
int nSize, | |||||
string lpFileName); | |||||
[DllImport("KERNEL32.DLL", EntryPoint = "WritePrivateProfileStringW", | |||||
SetLastError = true, | |||||
CharSet = CharSet.Unicode, ExactSpelling = true, | |||||
CallingConvention = CallingConvention.StdCall)] | |||||
private static extern int WritePrivateProfileString( | |||||
string lpSection, | |||||
string lpKey, | |||||
string lpValue, | |||||
string lpFileName); | |||||
private string _path = ""; | |||||
public string Path | |||||
{ | |||||
get | |||||
{ | |||||
return _path; | |||||
} | |||||
set | |||||
{ | |||||
if (!File.Exists(value)) | |||||
File.WriteAllText(value, "", Encoding.Unicode); | |||||
_path = value; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// INIFile Constructor. | |||||
/// </summary> | |||||
/// <PARAM name="INIPath"></PARAM> | |||||
public IniFile(string INIPath) | |||||
{ | |||||
this.Path = INIPath; | |||||
} | |||||
/// <summary> | |||||
/// Write Data to the INI File | |||||
/// </summary> | |||||
/// <PARAM name="Section"></PARAM> | |||||
/// Section name | |||||
/// <PARAM name="Key"></PARAM> | |||||
/// Key Name | |||||
/// <PARAM name="Value"></PARAM> | |||||
/// Value Name | |||||
public void IniWriteValue(string Section, string Key, string Value) | |||||
{ | |||||
WritePrivateProfileString(Section, Key, Value, this.Path); | |||||
} | |||||
/// <summary> | |||||
/// Read Data Value From the Ini File | |||||
/// </summary> | |||||
/// <PARAM name="Section"></PARAM> | |||||
/// <PARAM name="Key"></PARAM> | |||||
/// <PARAM name="Path"></PARAM> | |||||
/// <returns></returns> | |||||
public string IniReadValue(string Section, string Key) | |||||
{ | |||||
const int MAX_CHARS = 1023; | |||||
StringBuilder result = new StringBuilder(MAX_CHARS); | |||||
GetPrivateProfileString(Section, Key, "", result, MAX_CHARS, this.Path); | |||||
return result.ToString(); | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,166 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.IO; | |||||
using System.Text; | |||||
namespace IllusionPlugin | |||||
{ | |||||
/// <summary> | |||||
/// Allows to get and set preferences for your mod. | |||||
/// </summary> | |||||
public static class ModPrefs | |||||
{ | |||||
private static IniFile _instance; | |||||
private static IniFile Instance | |||||
{ | |||||
get | |||||
{ | |||||
if (_instance == null) | |||||
{ | |||||
_instance = new IniFile(Path.Combine(Environment.CurrentDirectory, "UserData/modprefs.ini")); | |||||
} | |||||
return _instance; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// Gets a string from the ini. | |||||
/// </summary> | |||||
/// <param name="section">Section of the key.</param> | |||||
/// <param name="name">Name of the key.</param> | |||||
/// <param name="defaultValue">Value that should be used when no value is found.</param> | |||||
/// <param name="autoSave">Whether or not the default value should be written if no value is found.</param> | |||||
/// <returns></returns> | |||||
public static string GetString(string section, string name, string defaultValue = "", bool autoSave = false) | |||||
{ | |||||
string value = Instance.IniReadValue(section, name); | |||||
if (value != "") | |||||
return value; | |||||
else if (autoSave) | |||||
SetString(section, name, defaultValue); | |||||
return defaultValue; | |||||
} | |||||
/// <summary> | |||||
/// Gets an int from the ini. | |||||
/// </summary> | |||||
/// <param name="section">Section of the key.</param> | |||||
/// <param name="name">Name of the key.</param> | |||||
/// <param name="defaultValue">Value that should be used when no value is found.</param> | |||||
/// <param name="autoSave">Whether or not the default value should be written if no value is found.</param> | |||||
/// <returns></returns> | |||||
public static int GetInt(string section, string name, int defaultValue = 0, bool autoSave = false) | |||||
{ | |||||
int value; | |||||
if (int.TryParse(Instance.IniReadValue(section, name), out value)) | |||||
return value; | |||||
else if (autoSave) | |||||
SetInt(section, name, defaultValue); | |||||
return defaultValue; | |||||
} | |||||
/// <summary> | |||||
/// Gets a float from the ini. | |||||
/// </summary> | |||||
/// <param name="section">Section of the key.</param> | |||||
/// <param name="name">Name of the key.</param> | |||||
/// <param name="defaultValue">Value that should be used when no value is found.</param> | |||||
/// <param name="autoSave">Whether or not the default value should be written if no value is found.</param> | |||||
/// <returns></returns> | |||||
public static float GetFloat(string section, string name, float defaultValue = 0f, bool autoSave = false) | |||||
{ | |||||
float value; | |||||
if (float.TryParse(Instance.IniReadValue(section, name), out value)) | |||||
return value; | |||||
else if (autoSave) | |||||
SetFloat(section, name, defaultValue); | |||||
return defaultValue; | |||||
} | |||||
/// <summary> | |||||
/// Gets a bool from the ini. | |||||
/// </summary> | |||||
/// <param name="section">Section of the key.</param> | |||||
/// <param name="name">Name of the key.</param> | |||||
/// <param name="defaultValue">Value that should be used when no value is found.</param> | |||||
/// <param name="autoSave">Whether or not the default value should be written if no value is found.</param> | |||||
/// <returns></returns> | |||||
public static bool GetBool(string section, string name, bool defaultValue = false, bool autoSave = false) | |||||
{ | |||||
string sVal = GetString(section, name, null); | |||||
if (sVal == "1" || sVal == "0") | |||||
{ | |||||
return sVal == "1"; | |||||
} else if (autoSave) | |||||
{ | |||||
SetBool(section, name, defaultValue); | |||||
} | |||||
return defaultValue; | |||||
} | |||||
/// <summary> | |||||
/// Checks whether or not a key exists in the ini. | |||||
/// </summary> | |||||
/// <param name="section">Section of the key.</param> | |||||
/// <param name="name">Name of the key.</param> | |||||
/// <returns></returns> | |||||
public static bool HasKey(string section, string name) | |||||
{ | |||||
return Instance.IniReadValue(section, name) != null; | |||||
} | |||||
/// <summary> | |||||
/// Sets a float in the ini. | |||||
/// </summary> | |||||
/// <param name="section">Section of the key.</param> | |||||
/// <param name="name">Name of the key.</param> | |||||
/// <param name="value">Value that should be written.</param> | |||||
public static void SetFloat(string section, string name, float value) | |||||
{ | |||||
Instance.IniWriteValue(section, name, value.ToString()); | |||||
} | |||||
/// <summary> | |||||
/// Sets an int in the ini. | |||||
/// </summary> | |||||
/// <param name="section">Section of the key.</param> | |||||
/// <param name="name">Name of the key.</param> | |||||
/// <param name="value">Value that should be written.</param> | |||||
public static void SetInt(string section, string name, int value) | |||||
{ | |||||
Instance.IniWriteValue(section, name, value.ToString()); | |||||
} | |||||
/// <summary> | |||||
/// Sets a string in the ini. | |||||
/// </summary> | |||||
/// <param name="section">Section of the key.</param> | |||||
/// <param name="name">Name of the key.</param> | |||||
/// <param name="value">Value that should be written.</param> | |||||
public static void SetString(string section, string name, string value) | |||||
{ | |||||
Instance.IniWriteValue(section, name, value); | |||||
} | |||||
/// <summary> | |||||
/// Sets a bool in the ini. | |||||
/// </summary> | |||||
/// <param name="section">Section of the key.</param> | |||||
/// <param name="name">Name of the key.</param> | |||||
/// <param name="value">Value that should be written.</param> | |||||
public static void SetBool(string section, string name, bool value) | |||||
{ | |||||
Instance.IniWriteValue(section, name, value ? "1" : "0"); | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,36 @@ | |||||
using System.Reflection; | |||||
using System.Runtime.CompilerServices; | |||||
using System.Runtime.InteropServices; | |||||
// General Information about an assembly is controlled through the following | |||||
// set of attributes. Change these attribute values to modify the information | |||||
// associated with an assembly. | |||||
[assembly: AssemblyTitle("IllusionPlugin")] | |||||
[assembly: AssemblyDescription("")] | |||||
[assembly: AssemblyConfiguration("")] | |||||
[assembly: AssemblyCompany("")] | |||||
[assembly: AssemblyProduct("IllusionPlugin")] | |||||
[assembly: AssemblyCopyright("Copyright © 2015")] | |||||
[assembly: AssemblyTrademark("")] | |||||
[assembly: AssemblyCulture("")] | |||||
// Setting ComVisible to false makes the types in this assembly not visible | |||||
// to COM components. If you need to access a type in this assembly from | |||||
// COM, set the ComVisible attribute to true on that type. | |||||
[assembly: ComVisible(false)] | |||||
// The following GUID is for the ID of the typelib if this project is exposed to COM | |||||
[assembly: Guid("e8cea89d-6c2f-4729-94b3-f355f7db19e5")] | |||||
// Version information for an assembly consists of the following four values: | |||||
// | |||||
// Major Version | |||||
// Minor Version | |||||
// Build Number | |||||
// Revision | |||||
// | |||||
// You can specify all the values or you can default the Build and Revision Numbers | |||||
// by using the '*' as shown below: | |||||
// [assembly: AssemblyVersion("1.0.*")] | |||||
[assembly: AssemblyVersion("1.0.0.0")] | |||||
[assembly: AssemblyFileVersion("1.0.0.0")] |
@ -0,0 +1 @@ | |||||
dd098bdf8443f9e98a9261f325ce0c78fe53aba4 |