Skip to content

Commit 2805bcf

Browse files
committed
Added boolean to Framework toggleable from within UnityEditor to determine whether to read/write from disk for EngineOptions configuration and application stages.
Opened Binding and BindingLibrary as public Added direct Binding accessors into BindingLibrary (.Strings, .Ints, .Floats, .Types, .Objects)
1 parent a2ff273 commit 2805bcf

File tree

12 files changed

+169
-93
lines changed

12 files changed

+169
-93
lines changed

Assembly-CSharp-vs.csproj

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,81 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>10.0.20506</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{BF0BFB5E-A3AD-3F42-3148-FFCDE6E872E2}</ProjectGuid>
9-
<OutputType>Library</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace></RootNamespace>
12-
<AssemblyName>Assembly-CSharp</AssemblyName>
13-
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
14-
<FileAlignment>512</FileAlignment>
15-
<BaseDirectory>Assets</BaseDirectory>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>10.0.20506</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{BF0BFB5E-A3AD-3F42-3148-FFCDE6E872E2}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>
12+
</RootNamespace>
13+
<AssemblyName>Assembly-CSharp</AssemblyName>
14+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
15+
<FileAlignment>512</FileAlignment>
16+
<BaseDirectory>Assets</BaseDirectory>
1617
</PropertyGroup>
1718
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18-
<DebugSymbols>true</DebugSymbols>
19-
<DebugType>full</DebugType>
20-
<Optimize>false</Optimize>
21-
<OutputPath>Temp\bin\Debug\</OutputPath>
22-
<DefineConstants>DEBUG;TRACE;UNITY_STANDALONE_WIN;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_GENERICS;ENABLE_SUBSTANCE;INCLUDE_WP8SUPPORT;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_2D_PHYSICS;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_3_4;UNITY_4_3;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE</DefineConstants>
23-
<ErrorReport>prompt</ErrorReport>
24-
<WarningLevel>4</WarningLevel>
25-
<NoWarn>0169</NoWarn>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>Temp\bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE;UNITY_STANDALONE_WIN;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_GENERICS;ENABLE_SUBSTANCE;INCLUDE_WP8SUPPORT;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_2D_PHYSICS;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;UNITY_4_3_4;UNITY_4_3;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
<NoWarn>0169</NoWarn>
2627
</PropertyGroup>
2728
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28-
<DebugType>pdbonly</DebugType>
29-
<Optimize>true</Optimize>
30-
<OutputPath>Temp\bin\Release\</OutputPath>
31-
<DefineConstants>TRACE</DefineConstants>
32-
<ErrorReport>prompt</ErrorReport>
33-
<WarningLevel>4</WarningLevel>
34-
<NoWarn>0169</NoWarn>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>Temp\bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
<NoWarn>0169</NoWarn>
3536
</PropertyGroup>
3637
<ItemGroup>
37-
<Reference Include="System" />
38+
<Reference Include="System" />
3839
<Reference Include="System.XML" />
39-
<Reference Include="System.Core" />
40-
<Reference Include="System.Xml.Linq" />
41-
<Reference Include="UnityEngine">
42-
<HintPath>E:/Program Files (x86)/Unity/Editor/Data/Managed/UnityEngine.dll</HintPath>
43-
</Reference>
44-
<Reference Include="UnityEditor">
45-
<HintPath>E:/Program Files (x86)/Unity/Editor/Data/Managed/UnityEditor.dll</HintPath>
46-
</Reference>
40+
<Reference Include="System.Core" />
41+
<Reference Include="System.Xml.Linq" />
42+
<Reference Include="UnityEngine">
43+
<HintPath>E:/Program Files (x86)/Unity/Editor/Data/Managed/UnityEngine.dll</HintPath>
44+
</Reference>
45+
<Reference Include="UnityEditor">
46+
<HintPath>E:/Program Files (x86)/Unity/Editor/Data/Managed/UnityEditor.dll</HintPath>
47+
</Reference>
4748
</ItemGroup>
4849
<ItemGroup>
49-
<Compile Include="Assets\CleaveFramework\Binding\Binding.cs" />
50-
<Compile Include="Assets\CleaveFramework\Binding\BindingLibrary.cs" />
51-
<Compile Include="Assets\CleaveFramework\Command\CmdBinder.cs" />
52-
<Compile Include="Assets\CleaveFramework\Command\Command.cs" />
53-
<Compile Include="Assets\CleaveFramework\Command\cmds\ApplyOptionsCmd.cs" />
54-
<Compile Include="Assets\CleaveFramework\Command\cmds\ChangeSceneCmd.cs" />
55-
<Compile Include="Assets\CleaveFramework\Command\cmds\SceneLoadedCmd.cs" />
56-
<Compile Include="Assets\CleaveFramework\Core\App.cs" />
57-
<Compile Include="Assets\CleaveFramework\Core\CommandQueue.cs" />
58-
<Compile Include="Assets\CleaveFramework\Core\EngineOptions.cs" />
59-
<Compile Include="Assets\CleaveFramework\Core\Framework.cs" />
60-
<Compile Include="Assets\CleaveFramework\Core\View.cs" />
61-
<Compile Include="Assets\CleaveFramework\Dependency Inject\Attributes\AInject.cs" />
62-
<Compile Include="Assets\CleaveFramework\Dependency Inject\Injector.cs" />
63-
<Compile Include="Assets\CleaveFramework\Factory\Factory.cs" />
64-
<Compile Include="Assets\CleaveFramework\Interfaces\IConfigureable.cs" />
65-
<Compile Include="Assets\CleaveFramework\Interfaces\IDestroyable.cs" />
66-
<Compile Include="Assets\CleaveFramework\Interfaces\IInitializeable.cs" />
67-
<Compile Include="Assets\CleaveFramework\Interfaces\IUpdateable.cs" />
68-
<Compile Include="Assets\CleaveFramework\Scene\SceneManager.cs" />
69-
<Compile Include="Assets\CleaveFramework\Scene\SceneObjectData.cs" />
70-
<Compile Include="Assets\CleaveFramework\Scene\SceneView.cs" />
71-
<Compile Include="Assets\CleaveFramework\SceneViews\LoadingSceneView.cs" />
72-
<Compile Include="Assets\CleaveFramework\Tools\CDebug.cs" />
73-
<Compile Include="Assets\CleaveFramework\plugins\SimpleJSON.cs" />
74-
<Reference Include="ICSharpCode.SharpZipLib">
75-
<HintPath>Assets\CleaveFramework\plugins\ICSharpCode.SharpZipLib.dll</HintPath>
76-
</Reference>
50+
<Compile Include="Assets\CleaveFramework\Binding\Binding.cs" />
51+
<Compile Include="Assets\CleaveFramework\Binding\BindingLibrary.cs" />
52+
<Compile Include="Assets\CleaveFramework\Command\CmdBinder.cs" />
53+
<Compile Include="Assets\CleaveFramework\Command\Command.cs" />
54+
<Compile Include="Assets\CleaveFramework\Command\cmds\ApplyOptionsCmd.cs" />
55+
<Compile Include="Assets\CleaveFramework\Command\cmds\ChangeSceneCmd.cs" />
56+
<Compile Include="Assets\CleaveFramework\Command\cmds\LoadNextSceneCmd.cs" />
57+
<Compile Include="Assets\CleaveFramework\Command\cmds\SceneLoadedCmd.cs" />
58+
<Compile Include="Assets\CleaveFramework\Core\App.cs" />
59+
<Compile Include="Assets\CleaveFramework\Core\CommandQueue.cs" />
60+
<Compile Include="Assets\CleaveFramework\Core\EngineOptions.cs" />
61+
<Compile Include="Assets\CleaveFramework\Core\Framework.cs" />
62+
<Compile Include="Assets\CleaveFramework\Core\View.cs" />
63+
<Compile Include="Assets\CleaveFramework\Dependency Inject\Attributes\AInject.cs" />
64+
<Compile Include="Assets\CleaveFramework\Dependency Inject\Injector.cs" />
65+
<Compile Include="Assets\CleaveFramework\Factory\Factory.cs" />
66+
<Compile Include="Assets\CleaveFramework\Interfaces\IConfigureable.cs" />
67+
<Compile Include="Assets\CleaveFramework\Interfaces\IDestroyable.cs" />
68+
<Compile Include="Assets\CleaveFramework\Interfaces\IInitializeable.cs" />
69+
<Compile Include="Assets\CleaveFramework\Interfaces\IUpdateable.cs" />
70+
<Compile Include="Assets\CleaveFramework\Scene\SceneManager.cs" />
71+
<Compile Include="Assets\CleaveFramework\Scene\SceneObjectData.cs" />
72+
<Compile Include="Assets\CleaveFramework\Scene\SceneView.cs" />
73+
<Compile Include="Assets\CleaveFramework\SceneViews\LoadingSceneView.cs" />
74+
<Compile Include="Assets\CleaveFramework\Tools\CDebug.cs" />
75+
<Compile Include="Assets\CleaveFramework\plugins\SimpleJSON.cs" />
76+
<Reference Include="ICSharpCode.SharpZipLib">
77+
<HintPath>Assets\CleaveFramework\plugins\ICSharpCode.SharpZipLib.dll</HintPath>
78+
</Reference>
7779
</ItemGroup>
7880
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
7981
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -83,5 +85,4 @@
8385
<Target Name="AfterBuild">
8486
</Target>
8587
-->
86-
87-
</Project>
88+
</Project>

Assembly-CSharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<Compile Include="Assets\CleaveFramework\Command\Command.cs" />
5353
<Compile Include="Assets\CleaveFramework\Command\cmds\ApplyOptionsCmd.cs" />
5454
<Compile Include="Assets\CleaveFramework\Command\cmds\ChangeSceneCmd.cs" />
55+
<Compile Include="Assets\CleaveFramework\Command\cmds\LoadNextSceneCmd.cs" />
5556
<Compile Include="Assets\CleaveFramework\Command\cmds\SceneLoadedCmd.cs" />
5657
<Compile Include="Assets\CleaveFramework\Core\App.cs" />
5758
<Compile Include="Assets\CleaveFramework\Core\CommandQueue.cs" />

Assets/CleaveFramework/Binding/Binding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace CleaveFramework.Binding
4040
/// </summary>
4141
/// <typeparam name="T">Key</typeparam>
4242
/// <typeparam name="V">Value</typeparam>
43-
class Binding<T, V>
43+
public class Binding<T, V>
4444
{
4545
public Dictionary<T, V> Bindings = new Dictionary<T, V>();
4646

Assets/CleaveFramework/Binding/BindingLibrary.cs

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,24 @@ namespace CleaveFramework.Binding
1717
{
1818
/// <summary>
1919
/// A generic BindingLibrary that can filter bindings into an appropriate library
20+
/// Since everything gets stored as an object you need to be sure to cast your expected
21+
/// return value appropriately
2022
///
2123
/// for ex:
2224
/// var myLibrary = new BindingLibrary();
2325
/// myLibrary.Bind(11, "Eleven");
24-
/// var value = myLibrary.Resolve(11); // value = "Eleven";
26+
/// var value = (string) myLibrary.Resolve(11); // value = "Eleven";
2527
///
2628
/// myLibrary.Bind("sky", "is up");
27-
/// var value = myLibrary.Resolve("sky"); // value = "is up";
29+
/// var value = (string) myLibrary.Resolve("sky"); // value = "is up";
2830
///
29-
/// myLibrary.Bind(ESomeEnum.EnumEntry, typeof(MyClass));
30-
/// var value = myLibrary.Resolve(ESomeEnum.EnumEntry); // value = typeof(MyClass);
31+
/// myLibrary.Bind(ESomeEnum.EnumEntry.ToString(), typeof(MyClass));
32+
/// var value = (Type) myLibrary.Resolve(ESomeEnum.EnumEntry.ToString()); // value = typeof(MyClass);
3133
///
3234
/// myLibrary.Bind(typeof(MyClass), new MyClass());
33-
/// var value = myLibrary.Resolve(typeof(MyClass)); // value = MyClass instance previously bound
35+
/// var value = (MyClass) myLibrary.Resolve(typeof(MyClass)); // value = MyClass instance previously bound
3436
/// </summary>
35-
class BindingLibrary
37+
public class BindingLibrary
3638
{
3739
private Binding<object, object> _library = new Binding<object, object>();
3840
private Binding<object, object> _instances = new Binding<object, object>();
@@ -46,7 +48,48 @@ public BindingLibrary()
4648
}
4749

4850
/// <summary>
49-
/// Throw a binding into the library of LHS = RHS
51+
/// Explicitly get the Strings library
52+
/// </summary>
53+
public Binding<string, object> Strings
54+
{
55+
get { return (Binding<string, object>)_library[typeof (string)]; }
56+
}
57+
58+
/// <summary>
59+
/// Explicitly get the Ints library
60+
/// </summary>
61+
public Binding<int, object> Ints
62+
{
63+
get { return (Binding<int, object>)_library[typeof(int)]; }
64+
}
65+
66+
/// <summary>
67+
/// Explicitly get the Floats library
68+
/// </summary>
69+
public Binding<float, object> Floats
70+
{
71+
get { return (Binding<float, object>)_library[typeof(float)]; }
72+
}
73+
74+
/// <summary>
75+
/// Explicitly get the Types library
76+
/// </summary>
77+
public Binding<Type, object> Types
78+
{
79+
get { return (Binding<Type, object>)_library[typeof(Type)]; }
80+
}
81+
82+
/// <summary>
83+
/// Explicitly get the Objects library
84+
/// </summary>
85+
public Binding<object, object> Objects
86+
{
87+
get { return _instances; }
88+
}
89+
90+
91+
/// <summary>
92+
/// Add a binding implicitly by its type into the appropriately library
5093
/// </summary>
5194
/// <typeparam name="T"></typeparam>
5295
/// <param name="key"></param>
@@ -65,11 +108,11 @@ public void Bind<T>(T key, object value)
65108
}
66109

67110
/// <summary>
68-
/// Resolve a binding from the library of LHS
111+
/// Implicitly resolve a binding from the library
69112
/// </summary>
70113
/// <typeparam name="T"></typeparam>
71114
/// <param name="key"></param>
72-
/// <returns></returns>
115+
/// <returns>will return null if no key of that type exists</returns>
73116
public object Resolve<T>(T key)
74117
{
75118
var bindings = GetBinder<T>();

Assets/CleaveFramework/Core/App.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ public sealed class App
1010
{
1111
public EngineOptions Options { get; private set; }
1212

13-
public App()
13+
/// <summary>
14+
///
15+
/// </summary>
16+
/// <param name="diskAccess">If diskAccess is false EngineOptions will initialize to it's default values
17+
/// and never write or read itself from the disk (for web platform)</param>
18+
public App(bool diskAccess)
1419
{
1520
// initialize UnityEngine from Options
16-
Options = new EngineOptions();
21+
Options = new EngineOptions(diskAccess);
1722
CmdBinder.AddBinding<ApplyOptionsCmd>(OnApplyOptions);
1823
}
1924

Assets/CleaveFramework/Core/EngineOptions.cs

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,27 @@
44

55
namespace CleaveFramework.Core
66
{
7+
8+
9+
10+
711
/// <summary>
812
/// wrapper for Unity engine configuration options
913
/// </summary>
1014
public class EngineOptions
1115
{
1216
private const string ConfigFile = "engine.ini";
1317

18+
// Rendering options
19+
public enum Quality
20+
{
21+
Ultra,
22+
High,
23+
Medium,
24+
Low,
25+
Disabled
26+
}
27+
1428
// Window options
1529
public bool FullScreen { get; set; }
1630
public int Width { get; set; }
@@ -22,23 +36,24 @@ public class EngineOptions
2236
public bool PlaySfx { get; set; }
2337
public float SfxVolume { get; set; }
2438

25-
// Rendering options
26-
public enum Quality
27-
{
28-
Ultra,
29-
High,
30-
Medium,
31-
Low,
32-
Disabled
33-
}
39+
3440
public Quality Antialias { get; set; }
3541
public Quality SSAO { get; set; }
3642
public Quality MotionBlur { get; set; }
3743
public Quality Shadow { get; set; }
3844
public Quality Vignette { get; set; }
3945

40-
public EngineOptions()
46+
private bool _useDiskAccess;
47+
48+
/// <summary>
49+
///
50+
/// </summary>
51+
/// <param name="diskAccess">If diskAccess is false EngineOptions will initialize to it's default values
52+
/// and never write or read itself from the disk (for web platform)</param>
53+
public EngineOptions(bool diskAccess)
4154
{
55+
_useDiskAccess = diskAccess;
56+
4257
// check for configuration file
4358
if (!LoadFromConfig())
4459
{
@@ -54,6 +69,8 @@ public EngineOptions()
5469
/// </summary>
5570
private bool LoadFromConfig()
5671
{
72+
if (!_useDiskAccess) return false;
73+
5774
if (!File.Exists(ConfigFile)) return false;
5875
var options = JSONNode.LoadFromFile(ConfigFile);
5976
if (options == null) return false;
@@ -79,6 +96,8 @@ private void CreateDefaultOptions()
7996

8097
private void WriteConfig()
8198
{
99+
if (!_useDiskAccess) return;
100+
82101
var options = Save();
83102
options.SaveToFile(ConfigFile);
84103
}

Assets/CleaveFramework/Core/Framework.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public static string TransitionScene
2424
set { Instance._transitionScene = value; }
2525
}
2626

27+
/// <summary>
28+
/// If true -- application will use engine.ini to load and save it's settings configuration
29+
/// If false -- application will use default configuration and never save
30+
/// </summary>
31+
[SerializeField] private bool _readWriteSettingsConfiguration = true;
32+
2733
/// <summary>
2834
/// singleton instance
2935
/// </summary>
@@ -64,7 +70,8 @@ void Awake()
6470
// give App a getter. Get options via:
6571
// Framework.App.Options.<Option>
6672
// Remember to apply options when necessary
67-
App = _frameworkObjects.PushObjectAsSingleton(new App()) as App;
73+
// true/false parameter tells App if it can use JSON to write and read default configurations from a HD.
74+
App = _frameworkObjects.PushObjectAsSingleton(new App(_readWriteSettingsConfiguration)) as App;
6875

6976
Globals = new SceneObjectData();
7077
Globals.InitializeSceneObjects();

Assets/CleaveFramework/Dependency Inject/Injector.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ private enum InjectTypes
5252
{
5353
Singleton,
5454
Transient,
55-
MonoBehaviour,
5655
}
5756

5857
private static Binding<Type, InjectTypes> _injectionTypes = new Binding<Type, InjectTypes>();

0 commit comments

Comments
 (0)