Compare commits
82 Commits
dev-extens
...
0.7.0-rc0
Author | SHA1 | Date | |
---|---|---|---|
2784544884 | |||
c39a02a1c2 | |||
4c397ab2f7 | |||
6b3a9c9f0a | |||
1c1560f17f | |||
0699bc5614 | |||
d86da00258 | |||
d1ad68debe | |||
b937285a74 | |||
69fe03475b | |||
e5956f2b34 | |||
fdb4ab55a3 | |||
e30df8bdbc | |||
251b7bc352 | |||
61b72107ae | |||
d6208f19fb | |||
93d9fdd4b8 | |||
8670482c04 | |||
d2b71e41c9 | |||
29a8ac2136 | |||
a9fc5130bb | |||
b51c7d2352 | |||
56fd0936bb | |||
2b3898655f | |||
1b30d3e62c | |||
bdbb1fcb07 | |||
659f2165ff | |||
a5439430fb | |||
0f683e403c | |||
cf6a7a795b | |||
f664708165 | |||
a7be55f2b0 | |||
398cec1fc5 | |||
a8b9ba0af4 | |||
f54564c567 | |||
a2c5850fcd | |||
f4411629e4 | |||
17d620ff0c | |||
5887b1267a | |||
400723d83b | |||
07babcb0ff | |||
f7bfe07660 | |||
3690adf5dd | |||
48349b598d | |||
d6e3d3ad00 | |||
c57c82bdd1 | |||
4bc921d47e | |||
8907dd19b0 | |||
2221658e7a | |||
916c55b4b2 | |||
3d8a4a64a9 | |||
6cb36a7064 | |||
1fc5ea8ac6 | |||
6fd8e44d10 | |||
ff19b45a9f | |||
f467832115 | |||
0a25b5260d | |||
c877437ab6 | |||
676d19f452 | |||
fd7c1e6635 | |||
c98536e8ab | |||
a013d59379 | |||
2e69035618 | |||
072703efe7 | |||
0c796c4d7a | |||
ee4b0c5483 | |||
ba7a458e7c | |||
06d9df304e | |||
578e10bbd7 | |||
c685e634d5 | |||
824f401b77 | |||
aafc326f95 | |||
88a6410439 | |||
d6e1b19d32 | |||
6fa459e5d3 | |||
bde6216295 | |||
e03dbef5ff | |||
e2c683567e | |||
89f391f040 | |||
92a3d5018f | |||
d510fec57b | |||
c5214dd477 |
@@ -1,6 +1,9 @@
|
||||
# Remove the line below if you want to inherit .editorconfig settings from higher directories
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
|
||||
# C# files
|
||||
[*.cs]
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common {
|
||||
/// <summary>
|
||||
|
@@ -13,7 +13,7 @@ namespace Cryville.Common {
|
||||
public static Binder CreateBinderOfType(Type type) {
|
||||
var l = type.GetCustomAttributes(typeof(BinderAttribute), true);
|
||||
if (l.Length > 0) {
|
||||
return (Binder)ReflectionHelper.InvokeEmptyConstructor(
|
||||
return (Binder)Activator.CreateInstance(
|
||||
((BinderAttribute)l[0]).BinderType
|
||||
);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Cryville.Common.Buffers {
|
||||
namespace Cryville.Common.Buffers {
|
||||
/// <summary>
|
||||
/// A resource pool that allows reusing instances of arrays of type <typeparamref name="T" />.
|
||||
/// </summary>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Common.Buffers {
|
||||
/// <summary>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Common.Buffers {
|
||||
/// <summary>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Cryville.Common.Buffers {
|
||||
namespace Cryville.Common.Buffers {
|
||||
/// <summary>
|
||||
/// A resource pool that allows reusing instances of type <typeparamref name="T" />.
|
||||
/// </summary>
|
||||
@@ -28,7 +28,6 @@
|
||||
_objs[_index++] = null;
|
||||
}
|
||||
if (obj == null) obj = Construct();
|
||||
else Reset(obj);
|
||||
return obj;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -36,7 +35,10 @@
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to return.</param>
|
||||
public void Return(T obj) {
|
||||
if (_index > 0) _objs[--_index] = obj;
|
||||
if (_index > 0) {
|
||||
Reset(obj);
|
||||
_objs[--_index] = obj;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs a new instance of type <typeparamref name="T" />.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Cryville.Common.Buffers {
|
||||
namespace Cryville.Common.Buffers {
|
||||
/// <summary>
|
||||
/// A resource pool that allows reusing instances of type <typeparamref name="T" />, which has a parameterless constructor.
|
||||
/// </summary>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Common.Collections.Generic {
|
||||
public interface IPairList<TKey, TValue> : IList<KeyValuePair<TKey, TValue>> {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
@@ -28,6 +28,10 @@ namespace Cryville.Common.Collections.Generic {
|
||||
if (_pairList != null) _pairList.CopyTo(array, index);
|
||||
else _dictionary.CopyTo(array, index);
|
||||
}
|
||||
|
||||
public static bool IsPairCollection(Type type) {
|
||||
return typeof(IPairList<TKey, TValue>).IsAssignableFrom(type) || typeof(IDictionary<TKey, TValue>).IsAssignableFrom(type);
|
||||
}
|
||||
}
|
||||
internal class PairCollectionDebugView<TKey, TValue> {
|
||||
readonly PairCollection<TKey, TValue> _self;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
|
106
Assets/Cryville/Common/Collections/HashHelpers.cs
Normal file
106
Assets/Cryville/Common/Collections/HashHelpers.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading;
|
||||
|
||||
namespace Cryville.Common.Collections {
|
||||
internal static class HashHelpers {
|
||||
#if FEATURE_RANDOMIZED_STRING_HASHING
|
||||
public const int HashCollisionThreshold = 100;
|
||||
public static bool s_UseRandomizedStringHashing = String.UseRandomizedHashing();
|
||||
#endif
|
||||
|
||||
// Table of prime numbers to use as hash table sizes.
|
||||
// A typical resize algorithm would pick the smallest prime number in this array
|
||||
// that is larger than twice the previous capacity.
|
||||
// Suppose our Hashtable currently has capacity x and enough elements are added
|
||||
// such that a resize needs to occur. Resizing first computes 2x then finds the
|
||||
// first prime in the table greater than 2x, i.e. if primes are ordered
|
||||
// p_1, p_2, ..., p_i, ..., it finds p_n such that p_n-1 < 2x < p_n.
|
||||
// Doubling is important for preserving the asymptotic complexity of the
|
||||
// hashtable operations such as add. Having a prime guarantees that double
|
||||
// hashing does not lead to infinite loops. IE, your hash function will be
|
||||
// h1(key) + i*h2(key), 0 <= i < size. h2 and the size must be relatively prime.
|
||||
public static readonly int[] primes = {
|
||||
3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919,
|
||||
1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591,
|
||||
17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523, 108631, 130363, 156437,
|
||||
187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263,
|
||||
1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369};
|
||||
|
||||
// Used by Hashtable and Dictionary's SeralizationInfo .ctor's to store the SeralizationInfo
|
||||
// object until OnDeserialization is called.
|
||||
private static ConditionalWeakTable<object, SerializationInfo> s_SerializationInfoTable;
|
||||
|
||||
internal static ConditionalWeakTable<object, SerializationInfo> SerializationInfoTable {
|
||||
get {
|
||||
if (s_SerializationInfoTable == null) {
|
||||
ConditionalWeakTable<object, SerializationInfo> newTable = new ConditionalWeakTable<object, SerializationInfo>();
|
||||
Interlocked.CompareExchange(ref s_SerializationInfoTable, newTable, null);
|
||||
}
|
||||
|
||||
return s_SerializationInfoTable;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
|
||||
public static bool IsPrime(int candidate) {
|
||||
if ((candidate & 1) != 0) {
|
||||
int limit = (int)System.Math.Sqrt (candidate);
|
||||
for (int divisor = 3; divisor <= limit; divisor += 2) {
|
||||
if ((candidate % divisor) == 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return (candidate == 2);
|
||||
}
|
||||
|
||||
internal const Int32 HashPrime = 101;
|
||||
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
|
||||
public static int GetPrime(int min) {
|
||||
if (min < 0)
|
||||
throw new ArgumentException("Hashtable's capacity overflowed and went negative. Check load factor, capacity and the current size of the table.");
|
||||
Contract.EndContractBlock();
|
||||
|
||||
for (int i = 0; i < primes.Length; i++) {
|
||||
int prime = primes[i];
|
||||
if (prime >= min) return prime;
|
||||
}
|
||||
|
||||
//outside of our predefined table.
|
||||
//compute the hard way.
|
||||
for (int i = (min | 1); i < Int32.MaxValue; i += 2) {
|
||||
if (IsPrime(i) && ((i - 1) % HashPrime != 0))
|
||||
return i;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
public static int GetMinPrime() {
|
||||
return primes[0];
|
||||
}
|
||||
|
||||
// Returns size of hashtable to grow to.
|
||||
public static int ExpandPrime(int oldSize) {
|
||||
int newSize = 2 * oldSize;
|
||||
|
||||
// Allow the hashtables to grow to maximum possible size (~2G elements) before encoutering capacity overflow.
|
||||
// Note that this check works even when _items.Length overflowed thanks to the (uint) cast
|
||||
if ((uint)newSize > MaxPrimeArrayLength && MaxPrimeArrayLength > oldSize) {
|
||||
Contract.Assert(MaxPrimeArrayLength == GetPrime(MaxPrimeArrayLength), "Invalid MaxPrimeArrayLength");
|
||||
return MaxPrimeArrayLength;
|
||||
}
|
||||
|
||||
return GetPrime(newSize);
|
||||
}
|
||||
|
||||
|
||||
// This is the maximum prime smaller than Array.MaxArrayLength
|
||||
public const int MaxPrimeArrayLength = 0x7FEFFFFD;
|
||||
}
|
||||
}
|
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 499dc47d3f108de4eb80b2d73e5851c5
|
||||
timeCreated: 1608801352
|
||||
licenseType: Free
|
||||
guid: e7fe2c6f3299681448c1a546cce4dc65
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
|
||||
namespace Cryville.Common.Collections {
|
||||
public interface IPairList : IList {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -29,6 +29,10 @@ namespace Cryville.Common.Collections {
|
||||
if (_pairList != null) _pairList.CopyTo(array, index);
|
||||
else _dictionary.CopyTo(array, index);
|
||||
}
|
||||
|
||||
public static bool IsPairCollection(Type type) {
|
||||
return typeof(IPairList).IsAssignableFrom(type) || typeof(IDictionary).IsAssignableFrom(type);
|
||||
}
|
||||
}
|
||||
internal class PairCollectionDebugView {
|
||||
readonly PairCollection _self;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Cryville.Common.Collections {
|
||||
|
8
Assets/Cryville/Common/Collections/Specialized.meta
Normal file
8
Assets/Cryville/Common/Collections/Specialized.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f68b44d5226a73441b94e7dd5873529f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1037
Assets/Cryville/Common/Collections/Specialized/IntKeyedDictionary.cs
Normal file
1037
Assets/Cryville/Common/Collections/Specialized/IntKeyedDictionary.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de5a0d32ac5669347ac4570c014967d1
|
||||
timeCreated: 1608801356
|
||||
licenseType: Free
|
||||
guid: 634536d804abc784394d4ac028a77879
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common.ComponentModel {
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common.ComponentModel {
|
||||
[AttributeUsage(AttributeTargets.Property, Inherited = false)]
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common.ComponentModel {
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common.ComponentModel {
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
|
||||
|
26
Assets/Cryville/Common/Coroutine.cs
Normal file
26
Assets/Cryville/Common/Coroutine.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Cryville.Common {
|
||||
public class Coroutine {
|
||||
readonly IEnumerator<float> _enumerator;
|
||||
readonly Stopwatch _stopwatch = new Stopwatch();
|
||||
public float Progress { get; private set; }
|
||||
public Coroutine(IEnumerator<float> enumerator) {
|
||||
_enumerator = enumerator;
|
||||
}
|
||||
public bool TickOnce() {
|
||||
if (!_enumerator.MoveNext()) return false;
|
||||
Progress = _enumerator.Current;
|
||||
return true;
|
||||
}
|
||||
public bool Tick(double minTime) {
|
||||
_stopwatch.Restart();
|
||||
while (_stopwatch.Elapsed.TotalSeconds < minTime) {
|
||||
if (!_enumerator.MoveNext()) return false;
|
||||
Progress = _enumerator.Current;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Common/Coroutine.cs.meta
Normal file
11
Assets/Cryville/Common/Coroutine.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 387adc7d494be0147b7cb930bc2e726b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common {
|
||||
public class FileStringAttribute : Attribute {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using Cryville.Common.IO;
|
||||
using Cryville.Common.IO;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using Cryville.Common.Culture;
|
||||
using Cryville.Common.Culture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Cryville.Common.Font {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common {
|
||||
public struct Identifier : IEquatable<Identifier> {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Common {
|
||||
/// <summary>
|
||||
|
@@ -1,44 +1,27 @@
|
||||
using SMath = System.Math;
|
||||
using SMath = System.Math;
|
||||
|
||||
namespace Cryville.Common.Math {
|
||||
// Ported from https://github.com/arian/cubic-bezier/blob/master/index.js
|
||||
public static class CubicBezier {
|
||||
public static float Evaluate(float t, float x1, float y1, float x2, float y2, float epsilon) {
|
||||
float x = t, t0, t1, t2, tx, d2, i;
|
||||
for (t2 = x, i = 0; i < 8; i++) {
|
||||
tx = CurveX(t2, x1, x2) - x;
|
||||
if (SMath.Abs(tx) < epsilon) return CurveY(t2, y1, y2);
|
||||
d2 = DerivativeCurveX(t2, x1, x2);
|
||||
if (SMath.Abs(d2) < 1e-6) break;
|
||||
t2 -= tx / d2;
|
||||
}
|
||||
float x = t, t0 = 0, t1 = 1, t2 = x;
|
||||
|
||||
t0 = 0; t1 = 1; t2 = x;
|
||||
|
||||
if (t2 < t0) return CurveY(t0, y1, y2);
|
||||
if (t2 > t1) return CurveY(t1, y1, y2);
|
||||
if (t2 < t0) return Curve(t0, y1, y2);
|
||||
if (t2 > t1) return Curve(t1, y1, y2);
|
||||
|
||||
while (t0 < t1) {
|
||||
tx = CurveX(t2, x1, x2);
|
||||
if (SMath.Abs(tx - x) < epsilon) return CurveY(t2, y1, y2);
|
||||
float tx = Curve(t2, x1, x2);
|
||||
if (SMath.Abs(tx - x) < epsilon) return Curve(t2, y1, y2);
|
||||
if (x > tx) t0 = t2;
|
||||
else t1 = t2;
|
||||
t2 = (t1 - t0) * .5f + t0;
|
||||
}
|
||||
|
||||
return CurveY(t2, y1, y2);
|
||||
return Curve(t2, y1, y2);
|
||||
}
|
||||
static float CurveX(float t, float x1, float x2) {
|
||||
static float Curve(float t, float p1, float p2) {
|
||||
float v = 1 - t;
|
||||
return 3 * v * v * t * x1 + 3 * v * t * t * x2 + t * t * t;
|
||||
}
|
||||
static float CurveY(float t, float y1, float y2) {
|
||||
float v = 1 - t;
|
||||
return 3 * v * v * t * y1 + 3 * v * t * t * y2 + t * t * t;
|
||||
}
|
||||
static float DerivativeCurveX(float t, float x1, float x2) {
|
||||
float v = 1 - t;
|
||||
return 3 * (2 * (t - 1) * t + v * v) * x1 + 3 * (-t * t * t + 2 * v * t) * x2;
|
||||
return 3 * v * v * t * p1 + 3 * v * t * t * p2 + t * t * t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common.Math {
|
||||
/// <summary>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnsafeIL;
|
||||
using UnsafeIL;
|
||||
|
||||
namespace Cryville.Common.Math {
|
||||
/// <summary>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
@@ -130,4 +130,4 @@ namespace Cryville.Common.Network {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common.Pdt {
|
||||
/// <summary>
|
||||
/// Indicates that the attributed member is an element list.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>An element list is a <see cref="System.Collections.IDictionary" /> or <see cref="Cryville.Common.Collections.Generic.IPairList" /> that represents a collection of PDT elements. There must be at most one element list in a class.</para>
|
||||
/// <para>An element list is a <see cref="System.Collections.IDictionary" /> or <see cref="Cryville.Common.Collections.IPairList" /> that represents a collection of PDT elements. There must be at most one element list in a class.</para>
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class ElementListAttribute : Attribute { }
|
||||
@@ -14,7 +14,7 @@ namespace Cryville.Common.Pdt {
|
||||
/// Indicates that the attributed member is a property list.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>A property list is a <see cref="System.Collections.IDictionary" /> or <see cref="Cryville.Common.Collections.Generic.IPairList" /> that represents a collection of PDT properties. There must be at most one property list in a class.</para>
|
||||
/// <para>A property list is a <see cref="System.Collections.IDictionary" /> or <see cref="Cryville.Common.Collections.IPairList" /> that represents a collection of PDT properties. There must be at most one property list in a class.</para>
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class PropertyListAttribute : Attribute { }
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
@@ -17,22 +17,23 @@ namespace Cryville.Common.Pdt {
|
||||
readonly StackFrame[] _stack = new StackFrame[256];
|
||||
readonly byte[] _mem = new byte[0x100000];
|
||||
bool _revokepttconst;
|
||||
LinkedListNode<PdtInstruction> _rip;
|
||||
LinkedListNode<PdtInstruction> _ip;
|
||||
/// <summary>
|
||||
/// Evaluates an expression and passes the result to a target operator.
|
||||
/// </summary>
|
||||
/// <param name="target">The target operator.</param>
|
||||
/// <param name="exp">The expression to evaluate.</param>
|
||||
public void Evaluate(PdtOperator target, PdtExpression exp) {
|
||||
/// <returns>Whether the evaluaton succeeded.</returns>
|
||||
public bool Evaluate(PdtOperator target, PdtExpression exp) {
|
||||
_framecount = 0;
|
||||
_goffset = 0;
|
||||
_revokepttconst = false;
|
||||
for (_rip = exp.Instructions.First; _rip != null; _rip = _rip.Next)
|
||||
_rip.Value.Execute(this);
|
||||
Operate(target, _framecount, true);
|
||||
for (_ip = exp.Instructions.First; _ip != null; _ip = _ip.Next)
|
||||
_ip.Value.Execute(this);
|
||||
if (exp.IsPotentialConstant) {
|
||||
exp.IsConstant = exp.IsPotentialConstant = !_revokepttconst;
|
||||
}
|
||||
return Operate(target, _framecount, true);
|
||||
}
|
||||
/// <summary>
|
||||
/// Patches an expression with a lefthand variable and a compound operator.
|
||||
@@ -54,8 +55,10 @@ namespace Cryville.Common.Pdt {
|
||||
List<PdtInstruction.Collapse> ct;
|
||||
var cols = new Dictionary<LinkedListNode<PdtInstruction>, List<PdtInstruction.Collapse>>();
|
||||
var il = exp.Instructions;
|
||||
for (_rip = il.First; _rip != null; _rip = _rip == null ? il.First : _rip.Next) {
|
||||
var i = _rip.Value;
|
||||
_ip = il.First;
|
||||
while (_ip != null) {
|
||||
bool nextFlag = false;
|
||||
var i = _ip.Value;
|
||||
if (i is PdtInstruction.Operate) {
|
||||
int fc0 = _framecount;
|
||||
int fc1 = ((PdtInstruction.Operate)i).Signature.ParamCount;
|
||||
@@ -71,29 +74,36 @@ namespace Cryville.Common.Pdt {
|
||||
}
|
||||
else {
|
||||
var frame = _stack[_framecount - 1];
|
||||
_rip = il.AddAfter(_rip, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length));
|
||||
for (var j = 0; j <= fc1; j++) il.Remove(_rip.Previous);
|
||||
ReplaceIP(il, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length), cols);
|
||||
for (var j = 0; j < fc1; j++) il.Remove(_ip.Previous);
|
||||
}
|
||||
}
|
||||
else if (i is PdtInstruction.Collapse) {
|
||||
var t = (PdtInstruction.Collapse)i;
|
||||
try {
|
||||
var pins = _rip;
|
||||
var pins = _ip;
|
||||
i.Execute(this);
|
||||
if (_rip == pins) {
|
||||
_rip = _rip.Next;
|
||||
il.Remove(_rip.Previous);
|
||||
il.Remove(_rip.Previous);
|
||||
_rip = _rip.Previous;
|
||||
if (_stack[_framecount - 1].Type == PdtInternalType.Error) {
|
||||
throw new EvaluationFailureException();
|
||||
}
|
||||
if (_ip == pins) {
|
||||
_ip = _ip.Next;
|
||||
il.Remove(_ip.Previous);
|
||||
il.Remove(_ip.Previous);
|
||||
_ip = _ip.Previous;
|
||||
if (_ip == null) {
|
||||
_ip = il.First;
|
||||
nextFlag = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_rip = pins.Previous;
|
||||
while (_rip.Next != t.Target) il.Remove(_rip.Next);
|
||||
il.Remove(_rip.Next);
|
||||
_ip = pins.Previous;
|
||||
while (_ip.Next != t.Target) il.Remove(_ip.Next);
|
||||
il.Remove(_ip.Next);
|
||||
if (cols.TryGetValue(t.Target, out ct)) {
|
||||
foreach (var u in ct) u.Target = _rip;
|
||||
foreach (var u in ct) u.Target = _ip;
|
||||
cols.Remove(t.Target);
|
||||
cols.Add(_rip, ct);
|
||||
cols.Add(_ip, ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,12 +116,11 @@ namespace Cryville.Common.Pdt {
|
||||
i.Execute(this);
|
||||
var frame = _stack[_framecount - 1];
|
||||
if (frame.Type != PdtInternalType.Undefined && frame.Type != PdtInternalType.Error) {
|
||||
_rip = il.AddAfter(_rip, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length));
|
||||
il.Remove(_rip.Previous);
|
||||
ReplaceIP(il, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length), cols);
|
||||
}
|
||||
}
|
||||
else i.Execute(this);
|
||||
if (_rip != null && cols.TryGetValue(_rip, out ct)) {
|
||||
if (_ip != null && cols.TryGetValue(_ip, out ct)) {
|
||||
unsafe {
|
||||
fixed (StackFrame* frame = &_stack[_framecount - 1]) {
|
||||
frame->Type = PdtInternalType.Error;
|
||||
@@ -120,6 +129,7 @@ namespace Cryville.Common.Pdt {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!nextFlag) _ip = _ip.Next;
|
||||
}
|
||||
exp.IsConstant = true;
|
||||
exp.IsPotentialConstant = true;
|
||||
@@ -133,6 +143,13 @@ namespace Cryville.Common.Pdt {
|
||||
}
|
||||
}
|
||||
}
|
||||
void ReplaceIP(LinkedList<PdtInstruction> il, PdtInstruction ins, Dictionary<LinkedListNode<PdtInstruction>, List<PdtInstruction.Collapse>> cols) {
|
||||
List<PdtInstruction.Collapse> cins;
|
||||
if (cols.TryGetValue(_ip, out cins)) cols.Remove(_ip);
|
||||
_ip = il.AddAfter(_ip, ins);
|
||||
il.Remove(_ip.Previous);
|
||||
if (cins != null) cols.Add(_ip, cins);
|
||||
}
|
||||
/// <summary>
|
||||
/// Revokes the potential constant mark of the current expression.
|
||||
/// </summary>
|
||||
@@ -184,23 +201,34 @@ namespace Cryville.Common.Pdt {
|
||||
/// <returns>An operator of the specific name.</returns>
|
||||
/// <remarks>The parameter count of the returned operator does not necessarily equal to <paramref name="pc" />.</remarks>
|
||||
protected abstract PdtOperator GetOperator(PdtOperatorSignature sig);
|
||||
unsafe void Operate(PdtOperator op, int pc, bool noset = false) {
|
||||
unsafe bool Operate(PdtOperator op, int pc, bool noset = false) {
|
||||
fixed (byte* pmem = _mem) {
|
||||
op.Begin(this, pc);
|
||||
for (int i = 0; i < pc; i++) {
|
||||
var frame = _stack[--_framecount];
|
||||
if (frame.Type == PdtInternalType.Error) {
|
||||
_framecount -= pc - i;
|
||||
_stack[_framecount++] = new StackFrame { Type = PdtInternalType.Error, Offset = _goffset, Length = 0 };
|
||||
return false;
|
||||
}
|
||||
op.LoadOperand(new PdtVariableMemory(frame.Type, pmem + frame.Offset, frame.Length));
|
||||
_goffset -= frame.Length;
|
||||
}
|
||||
op.Call(pmem + _goffset, noset);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
internal unsafe void Collapse(int name, LinkedListNode<PdtInstruction> target) {
|
||||
fixed (byte* pmem = _mem) {
|
||||
var frame = _stack[--_framecount];
|
||||
if (frame.Type == PdtInternalType.Error) {
|
||||
_stack[_framecount++] = new StackFrame { Type = PdtInternalType.Error, Offset = _goffset, Length = 0 };
|
||||
_ip = target;
|
||||
return;
|
||||
}
|
||||
if (Collapse(name, new PdtVariableMemory(frame.Type, pmem + frame.Offset, frame.Length))) {
|
||||
_framecount++;
|
||||
_rip = target;
|
||||
_ip = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -226,7 +254,7 @@ namespace Cryville.Common.Pdt {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The exception that is thrown when the evalution of a <see cref="PdtExpression" /> fails.
|
||||
/// The exception that is thrown when the evaluation of a <see cref="PdtExpression" /> fails.
|
||||
/// </summary>
|
||||
public class EvaluationFailureException : Exception {
|
||||
/// <inheritdoc />
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace Cryville.Common.Pdt {
|
||||
default: pc++; break;
|
||||
}
|
||||
}
|
||||
else if (OP_TYPE[t2.Value[0]] == 1) {
|
||||
if (OP_TYPE[t2.Value[0]] == 1) {
|
||||
colp = new Dictionary<LinkedListNode<PdtInstruction>, string> { { ins.Last, t2.Value } };
|
||||
}
|
||||
t1 = t2;
|
||||
|
59
Assets/Cryville/Common/Pdt/PdtFragmentInterpreter.cs
Normal file
59
Assets/Cryville/Common/Pdt/PdtFragmentInterpreter.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Cryville.Common.Pdt {
|
||||
/// <summary>
|
||||
/// Interpreter for fragments in Property Definition Tree (PDT) file format.
|
||||
/// </summary>
|
||||
public class PdtFragmentInterpreter : PdtInterpreter {
|
||||
public PdtFragmentInterpreter() : base(null, new EmptyBinder()) { }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the new source string for the fragment interpreter and resets the position.
|
||||
/// </summary>
|
||||
/// <param name="value">The new source string.</param>
|
||||
public void SetSource(string value) {
|
||||
Source = value;
|
||||
Position = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The binder.
|
||||
/// </summary>
|
||||
public Binder Binder {
|
||||
get { return _binder; }
|
||||
set { _binder = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the current character and increments the position.
|
||||
/// </summary>
|
||||
/// <returns>The current character.</returns>
|
||||
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
|
||||
public new char GetChar() { return base.GetChar(); }
|
||||
/// <summary>
|
||||
/// Reads an identifier.
|
||||
/// </summary>
|
||||
/// <returns>An identifier.</returns>
|
||||
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
|
||||
public new string GetIdentifier() { return base.GetIdentifier(); }
|
||||
/// <summary>
|
||||
/// Reads a number.
|
||||
/// </summary>
|
||||
/// <returns>A number.</returns>
|
||||
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
|
||||
public new string GetNumber() { return base.GetNumber(); }
|
||||
/// <summary>
|
||||
/// Reads a string.
|
||||
/// </summary>
|
||||
/// <returns>A string.</returns>
|
||||
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
|
||||
public new string GetString() { return base.GetString(); }
|
||||
/// <summary>
|
||||
/// Reads an expression.
|
||||
/// </summary>
|
||||
/// <returns>An expression.</returns>
|
||||
/// <exception cref="IndexOutOfRangeException">The end of the source string is reached.</exception>
|
||||
public new PdtExpression GetExp() { return base.GetExp(); }
|
||||
}
|
||||
}
|
11
Assets/Cryville/Common/Pdt/PdtFragmentInterpreter.cs.meta
Normal file
11
Assets/Cryville/Common/Pdt/PdtFragmentInterpreter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7088ba23ed4b424eadaf664be48e376
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,4 +1,4 @@
|
||||
namespace Cryville.Common.Pdt {
|
||||
namespace Cryville.Common.Pdt {
|
||||
/// <summary>
|
||||
/// The identifiers of the internal types of PDT.
|
||||
/// </summary>
|
||||
|
@@ -1,10 +1,10 @@
|
||||
using Cryville.Common.Collections;
|
||||
using Cryville.Common.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using CMath = System.Math;
|
||||
|
||||
namespace Cryville.Common.Pdt {
|
||||
/// <summary>
|
||||
@@ -61,12 +61,12 @@ namespace Cryville.Common.Pdt {
|
||||
/// <summary>
|
||||
/// The source string.
|
||||
/// </summary>
|
||||
public string Source { get; private set; }
|
||||
Binder _binder;
|
||||
public string Source { get; protected set; }
|
||||
protected Binder _binder;
|
||||
/// <summary>
|
||||
/// The current position in the string being parsed by the interpreter.
|
||||
/// </summary>
|
||||
public int Position { get; private set; }
|
||||
public int Position { get; protected set; }
|
||||
#pragma warning disable IDE1006
|
||||
/// <summary>
|
||||
/// The character at the current position.
|
||||
@@ -228,8 +228,8 @@ namespace Cryville.Common.Pdt {
|
||||
if (!flag) throw new FormatException("Format directive not found");
|
||||
}
|
||||
object InterpretObject(Type type) {
|
||||
var result = ReflectionHelper.InvokeEmptyConstructor(type);
|
||||
bool dictflag = typeof(IDictionary).IsAssignableFrom(type);
|
||||
var result = Activator.CreateInstance(type);
|
||||
bool pcflag = PairCollection.IsPairCollection(type);
|
||||
while (true) {
|
||||
try { ws(); }
|
||||
catch (IndexOutOfRangeException) { return result; }
|
||||
@@ -241,69 +241,51 @@ namespace Cryville.Common.Pdt {
|
||||
char c = GetChar();
|
||||
switch (c) {
|
||||
case '{':
|
||||
if (dictflag) {
|
||||
var ktype = type.GetGenericArguments()[0];
|
||||
var ptype = type.GetGenericArguments()[1];
|
||||
object key = _binder.ChangeType(pkey, ktype, null);
|
||||
object value = InterpretObject(ptype);
|
||||
((IDictionary)result).Add(key, value);
|
||||
}
|
||||
else {
|
||||
MemberInfo prop = null;
|
||||
bool flag = false;
|
||||
if (pkey is string) prop = ReflectionHelper.GetMember(type, (string)pkey);
|
||||
if (prop == null) flag = ReflectionHelper.TryFindMemberWithAttribute<ElementListAttribute>(type, out prop);
|
||||
if (prop == null) throw new MissingMemberException(string.Format("The property \"{0}\" is not found", pkey));
|
||||
Type ptype = ReflectionHelper.GetMemberType(prop);
|
||||
if (flag) {
|
||||
using (var collection = new PairCollection(ReflectionHelper.GetValue(prop, result))) {
|
||||
var ktype = ptype.GetGenericArguments()[0];
|
||||
var vtype = ptype.GetGenericArguments()[1];
|
||||
object key = _binder.ChangeType(pkey, ktype, null);
|
||||
object value = InterpretObject(vtype);
|
||||
collection.Add(key, value);
|
||||
}
|
||||
}
|
||||
else ReflectionHelper.SetValue(prop, result, InterpretObject(ptype));
|
||||
}
|
||||
InterpretObjectInternal<ElementListAttribute>(pcflag, type, pkey, result, type => InterpretObject(type));
|
||||
break;
|
||||
case ':':
|
||||
case ';':
|
||||
var exp = c == ';' ? _emptyexp : GetExp();
|
||||
if (dictflag) {
|
||||
var ktype = type.GetGenericArguments()[0];
|
||||
var vtype = type.GetGenericArguments()[1];
|
||||
object key = _binder.ChangeType(pkey, ktype, null);
|
||||
object value = _binder.ChangeType(exp, vtype, null);
|
||||
((IDictionary)result).Add(key, value);
|
||||
}
|
||||
else {
|
||||
MemberInfo prop = null;
|
||||
bool flag = false;
|
||||
if (pkey is string) prop = ReflectionHelper.GetMember(type, (string)pkey);
|
||||
if (prop == null) flag = ReflectionHelper.TryFindMemberWithAttribute<PropertyListAttribute>(type, out prop);
|
||||
if (prop == null) throw new MissingMemberException(string.Format("The property \"{0}\" is not found", pkey));
|
||||
var ptype = ReflectionHelper.GetMemberType(prop);
|
||||
if (flag) {
|
||||
using (var collection = new PairCollection(ReflectionHelper.GetValue(prop, result))) {
|
||||
var ktype = ptype.GetGenericArguments()[0];
|
||||
var vtype = ptype.GetGenericArguments()[1];
|
||||
object key = _binder.ChangeType(pkey, ktype, null);
|
||||
object value = _binder.ChangeType(exp, vtype, null);
|
||||
collection.Add(key, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
object value = _binder.ChangeType(exp, ptype, null);
|
||||
ReflectionHelper.SetValue(prop, result, value, _binder);
|
||||
}
|
||||
}
|
||||
InterpretObjectInternal<PropertyListAttribute>(pcflag, type, pkey, result, type => _binder.ChangeType(exp, type, null));
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException("Internal error: Invalid key interpretation");
|
||||
}
|
||||
}
|
||||
}
|
||||
void InterpretObjectInternal<T>(bool pcflag, Type type, object pkey, object result, Func<Type, object> vfunc) where T : Attribute {
|
||||
if (pcflag) {
|
||||
using (var collection = new PairCollection(result)) {
|
||||
var ktype = type.GetGenericArguments()[0];
|
||||
var ptype = type.GetGenericArguments()[1];
|
||||
object key = _binder.ChangeType(pkey, ktype, null);
|
||||
object value = vfunc(ptype);
|
||||
collection.Add(key, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
MemberInfo prop = null;
|
||||
bool flag = false;
|
||||
if (pkey is string) prop = ReflectionHelper.TryGetMember(type, (string)pkey);
|
||||
if (prop == null) flag = ReflectionHelper.TryFindMemberWithAttribute<T>(type, out prop);
|
||||
if (prop == null) throw new MissingMemberException(string.Format("The property \"{0}\" is not found", pkey));
|
||||
Type ptype = ReflectionHelper.GetMemberType(prop);
|
||||
if (flag) {
|
||||
var origCollection = ReflectionHelper.GetValue(prop, result);
|
||||
if (origCollection == null) {
|
||||
ReflectionHelper.SetValue(prop, result, origCollection = Activator.CreateInstance(ptype));
|
||||
}
|
||||
using (var collection = new PairCollection(origCollection)) {
|
||||
var ktype = ptype.GetGenericArguments()[0];
|
||||
var vtype = ptype.GetGenericArguments()[1];
|
||||
object key = _binder.ChangeType(pkey, ktype, null);
|
||||
object value = vfunc(vtype);
|
||||
collection.Add(key, value);
|
||||
}
|
||||
}
|
||||
else ReflectionHelper.SetValue(prop, result, vfunc(ptype), _binder);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Interprets a key from the current position.
|
||||
/// </summary>
|
||||
@@ -324,13 +306,13 @@ namespace Cryville.Common.Pdt {
|
||||
int pos = interpreter.Position;
|
||||
if (pos >= src.Length) return "Failed to interpret the PDT: There are some missing or redundant tokens";
|
||||
int lineStartPos = src.LastIndexOf('\n', pos) + 1;
|
||||
int previewStartPos = src.LastIndexOf('\n', pos, 64);
|
||||
int previewStartPos = src.LastIndexOf('\n', pos, CMath.Min(64, pos));
|
||||
if (previewStartPos == -1) {
|
||||
previewStartPos = pos - 64;
|
||||
if (previewStartPos < 0) previewStartPos = 0;
|
||||
}
|
||||
else previewStartPos++;
|
||||
int previewEndPos = src.IndexOf('\n', pos, 64);
|
||||
int previewEndPos = src.IndexOf('\n', pos, CMath.Min(64, src.Length - pos));
|
||||
if (previewEndPos == -1) {
|
||||
previewEndPos = pos + 64;
|
||||
if (previewEndPos > src.Length) previewEndPos = src.Length;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Common.Pdt {
|
||||
/// <summary>
|
||||
@@ -116,4 +116,4 @@ namespace Cryville.Common.Pdt {
|
||||
return string.Format("{0}({1})", IdentifierManager.SharedInstance.Retrieve(Name), ParamCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using UnsafeIL;
|
||||
|
||||
namespace Cryville.Common.Pdt {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -8,24 +8,7 @@ namespace Cryville.Common {
|
||||
/// Provides a set of <see langword="static" /> methods for refletion.
|
||||
/// </summary>
|
||||
public static class ReflectionHelper {
|
||||
static readonly Type[] emptyTypeArray = {};
|
||||
/// <summary>
|
||||
/// Gets the parameterless constructor of a type.
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <returns>The parameterless constructor of the type.</returns>
|
||||
public static ConstructorInfo GetEmptyConstructor(Type type) {
|
||||
return type.GetConstructor(emptyTypeArray);
|
||||
}
|
||||
static readonly object[] emptyObjectArray = {};
|
||||
/// <summary>
|
||||
/// Invokes the parameterless constructor of a type and returns the result.
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <returns>The created instance.</returns>
|
||||
public static object InvokeEmptyConstructor(Type type) {
|
||||
return GetEmptyConstructor(type).Invoke(emptyObjectArray);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to find a member with the specified attribute type in a type.
|
||||
@@ -90,6 +73,22 @@ namespace Cryville.Common {
|
||||
return mil[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get the member from a type with the specified name.
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <param name="name">The name of the member.</param>
|
||||
/// <returns>The member. <see langword="null" /> when not found.</returns>
|
||||
public static MemberInfo TryGetMember(Type type, string name) {
|
||||
var mil = type.GetMember(
|
||||
name,
|
||||
MemberTypes.Field | MemberTypes.Property,
|
||||
BindingFlags.Public | BindingFlags.Instance
|
||||
);
|
||||
if (mil.Length != 1) return null;
|
||||
return mil[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of a member.
|
||||
/// </summary>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Common.Unity {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Common.Unity.Input {
|
||||
|
@@ -17,7 +17,7 @@ namespace Cryville.Common.Unity.Input {
|
||||
foreach (var t in HandlerRegistries) {
|
||||
try {
|
||||
if (!typeof(InputHandler).IsAssignableFrom(t)) continue;
|
||||
var h = (InputHandler)ReflectionHelper.InvokeEmptyConstructor(t);
|
||||
var h = (InputHandler)Activator.CreateInstance(t);
|
||||
_typemap.Add(t, h);
|
||||
_handlers.Add(h);
|
||||
Logger.Log("main", 1, "Input", "Initialized {0}", ReflectionHelper.GetSimpleName(t));
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Cryville.Common.Unity.Input {
|
||||
namespace Cryville.Common.Unity.Input {
|
||||
public enum WindowMessages : uint {
|
||||
WM_NULL = 0x0000,
|
||||
WM_CREATE = 0x0001,
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Common.Unity.Input {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Common.Unity.Input {
|
||||
public static class UnityCameraUtils {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
@@ -179,7 +179,7 @@ namespace Cryville.Common.Unity {
|
||||
if (!www.isDone) return false;
|
||||
if (handler.isDone && handler.texture != null) {
|
||||
var buffer = handler.texture;
|
||||
/*var result = new Texture2D(buffer.width, buffer.height, buffer.format, true);
|
||||
var result = new Texture2D(buffer.width, buffer.height, buffer.format, true);
|
||||
if (SystemInfo.copyTextureSupport.HasFlag(CopyTextureSupport.Basic)) {
|
||||
Graphics.CopyTexture(buffer, 0, 0, result, 0, 0);
|
||||
}
|
||||
@@ -188,8 +188,8 @@ namespace Cryville.Common.Unity {
|
||||
}
|
||||
result.Apply(true, true);
|
||||
Texture2D.Destroy(buffer);
|
||||
Callback(true, result);*/
|
||||
Callback(true, buffer);
|
||||
Callback(true, result);
|
||||
// Callback(true, buffer);
|
||||
}
|
||||
else {
|
||||
Callback(false, null);
|
||||
|
@@ -1,145 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Common.Unity {
|
||||
public class PropItem : MonoBehaviour {
|
||||
public object Target;
|
||||
public PropertyEditor editor;
|
||||
public DirectoryInfo ContextPath;
|
||||
|
||||
public string PropertyName = "";
|
||||
InputField valueObj;
|
||||
string value;
|
||||
string desc = "";
|
||||
PropertyInfo prop;
|
||||
Type bindToType;
|
||||
TypeConverter converter;
|
||||
|
||||
bool mustExpand = false;
|
||||
bool readOnly = false;
|
||||
string[] filter = null;
|
||||
FileDialog fdialog;
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
void Awake() {
|
||||
transform.Find("Value").GetComponent<InputField>().onEndEdit.AddListener(s => OnValueChanged(s));
|
||||
var entry = new EventTrigger.Entry(){
|
||||
eventID = EventTriggerType.PointerClick,
|
||||
callback = new EventTrigger.TriggerEvent()
|
||||
};
|
||||
entry.callback.AddListener(e => OnClick(e));
|
||||
transform.Find("Value").GetComponent<EventTrigger>().triggers.Add(entry);
|
||||
}
|
||||
|
||||
void Start() {
|
||||
transform.Find("Name").GetComponent<Text>().text = PropertyName;
|
||||
valueObj = transform.Find("Value").GetComponent<InputField>();
|
||||
prop = Target.GetType().GetProperty(PropertyName);
|
||||
bindToType = prop.PropertyType;
|
||||
converter = TypeDescriptor.GetConverter(bindToType);
|
||||
|
||||
var descattr = (DescriptionAttribute[])prop.GetCustomAttributes(typeof(DescriptionAttribute), true);
|
||||
if (descattr.Length > 0) desc = descattr[0].Description;
|
||||
|
||||
var roattr = (ReadOnlyAttribute[])prop.GetCustomAttributes(typeof(ReadOnlyAttribute), true);
|
||||
if (roattr.Length > 0) if (roattr[0].IsReadOnly == true) {
|
||||
readOnly = true;
|
||||
valueObj.enabled = false;
|
||||
valueObj.transform.Find("ValueString").GetComponent<Text>().color = Color.gray;
|
||||
}
|
||||
|
||||
if (converter == null || !converter.CanConvertFrom(typeof(string)) || converter.GetPropertiesSupported()){
|
||||
mustExpand = true;
|
||||
valueObj.enabled = false;
|
||||
}
|
||||
|
||||
var fsattr = (FileStringAttribute[])prop.GetCustomAttributes(typeof(FileStringAttribute), true);
|
||||
if (fsattr.Length > 0) {
|
||||
valueObj.enabled = false;
|
||||
filter = fsattr[0].Filter;
|
||||
}
|
||||
|
||||
UpdateValue();
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
void OnFileDialogClosed() {
|
||||
var file = fdialog.GetComponent<FileDialog>().FileName;
|
||||
if (file != "") {
|
||||
var f = new FileInfo(file);
|
||||
if (f.Directory.FullName != ContextPath.FullName) {
|
||||
string targetFile = ContextPath.FullName + "\\" + f.Name;
|
||||
f.CopyTo(targetFile, true);
|
||||
}
|
||||
OnValueChanged(f.Name);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateValue() {
|
||||
object v;
|
||||
valueObj.placeholder.GetComponent<Text>().text = "";
|
||||
v = prop.GetValue(Target, new object[]{ });
|
||||
if (v == null) {
|
||||
DefaultValueAttribute[] defvattr = (DefaultValueAttribute[])prop.GetCustomAttributes(typeof(DefaultValueAttribute), true);
|
||||
if (defvattr.Length > 0) {
|
||||
v = defvattr[0].Value;
|
||||
if (v == null) {
|
||||
v = "";
|
||||
valueObj.placeholder.GetComponent<Text>().text = "null";
|
||||
}
|
||||
}
|
||||
else {
|
||||
v = "";
|
||||
valueObj.placeholder.GetComponent<Text>().text = "null";
|
||||
}
|
||||
}
|
||||
|
||||
if (mustExpand || readOnly || filter != null) {
|
||||
valueObj.transform.Find("ValueString").GetComponent<Text>().text = v.ToString();
|
||||
}
|
||||
else {
|
||||
valueObj.text = v.ToString();
|
||||
}
|
||||
value = valueObj.text;
|
||||
}
|
||||
|
||||
void OnClick(BaseEventData e) {
|
||||
if (mustExpand && !readOnly) {
|
||||
GameObject subeditor = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/PropertyEditor"));
|
||||
object obj = prop.GetValue(Target, new object[]{ });
|
||||
subeditor.GetComponent<PropertyEditor>().TargetObject = obj;
|
||||
}
|
||||
else if (filter != null && !readOnly) {
|
||||
fdialog = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/FileDialog")).GetComponent<FileDialog>();
|
||||
fdialog.Filter = filter;
|
||||
fdialog.CurrentDirectory = ContextPath;
|
||||
fdialog.OnClose += OnFileDialogClosed;
|
||||
}
|
||||
editor.SetDescription(PropertyName, desc);
|
||||
UpdateValue();
|
||||
}
|
||||
|
||||
void OnValueChanged(string s) {
|
||||
if (s == value) return;
|
||||
object v = null;
|
||||
if (!(mustExpand || readOnly)) {
|
||||
try {
|
||||
v = converter.ConvertFrom(s);
|
||||
prop.SetValue(Target, v, new object[]{ });
|
||||
}
|
||||
catch (TargetInvocationException ex) {
|
||||
// CallHelper.ShowMessageBox(ex.InnerException.Message);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// CallHelper.ShowMessageBox(ex.Message);
|
||||
}
|
||||
}
|
||||
UpdateValue();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,60 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Common.Unity {
|
||||
public class PropertyEditor : MonoBehaviour {
|
||||
|
||||
private object target;
|
||||
public object TargetObject {
|
||||
get { return target; }
|
||||
set {
|
||||
target = value;
|
||||
ReloadProperties();
|
||||
}
|
||||
}
|
||||
|
||||
private Text desc;
|
||||
private Transform list;
|
||||
|
||||
public Action Callback;
|
||||
|
||||
private void ReloadProperties() {
|
||||
foreach (Transform p in list) {
|
||||
GameObject.Destroy(p.gameObject);
|
||||
}
|
||||
PropertyInfo[] props = target.GetType().GetProperties();
|
||||
foreach (PropertyInfo m in props) {
|
||||
var brattr = (BrowsableAttribute[])m.GetCustomAttributes(typeof(BrowsableAttribute), true);
|
||||
if (brattr.Length > 0)
|
||||
if (brattr[0].Browsable == false)
|
||||
continue;
|
||||
GameObject mi = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/PropItem"));
|
||||
mi.transform.SetParent(list, false);
|
||||
mi.GetComponent<PropItem>().PropertyName = m.Name;
|
||||
mi.GetComponent<PropItem>().Target = target;
|
||||
mi.GetComponent<PropItem>().editor = this;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
void Awake() {
|
||||
Transform panel = transform.Find("Panel");
|
||||
desc = panel.Find("Description").GetComponent<Text>();
|
||||
list = panel.Find("PropList").Find("PropListInner");
|
||||
SetDescription("(Property)", "");
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
public void SetDescription(string n, string d) {
|
||||
desc.text = "<b>" + n + "</b>\n" + d;
|
||||
}
|
||||
|
||||
public void Close() {
|
||||
if (Callback != null) Callback.Invoke();
|
||||
GameObject.Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Common.Unity.UI {
|
||||
/// <summary>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Common.Unity.UI {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Common.Unity.UI {
|
||||
/// <summary>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Common.Unity.UI {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Sprites;
|
||||
using UnityEngine.UI;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Common.Unity.UI {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Common.Unity.UI {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Common.Unity.UI {
|
||||
public class SetIntegerParameterBehaviour : SetParameterBehaviour {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Cryville.Common.Collections.Specialized;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
@@ -6,12 +6,12 @@ namespace Cryville.Crtr {
|
||||
public int Name { get; private set; }
|
||||
public Transform Transform { get; private set; }
|
||||
public SkinContext SkinContext { get; private set; }
|
||||
public Dictionary<int, PropSrc> PropSrcs { get; private set; }
|
||||
public IntKeyedDictionary<PropSrc> PropSrcs { get; private set; }
|
||||
public Anchor(int name, Transform transform, int propSrcCount = 0) {
|
||||
Name = name;
|
||||
Transform = transform;
|
||||
if (propSrcCount > 0) PropSrcs = new Dictionary<int, PropSrc>(propSrcCount);
|
||||
if (propSrcCount > 0) PropSrcs = new IntKeyedDictionary<PropSrc>(propSrcCount);
|
||||
SkinContext = new SkinContext(transform, PropSrcs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
79
Assets/Cryville/Crtr/BeatTime.cs
Normal file
79
Assets/Cryville/Crtr/BeatTime.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
[JsonConverter(typeof(BeatTimeConverter))]
|
||||
public struct BeatTime : IComparable<BeatTime>, IEquatable<BeatTime> {
|
||||
public BeatTime(int _b, int _n, int _d) {
|
||||
b = _b;
|
||||
n = _n;
|
||||
d = _d;
|
||||
}
|
||||
public BeatTime(int _n, int _d) {
|
||||
b = _n / _d;
|
||||
n = _n % _d;
|
||||
d = _d;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public int b;
|
||||
|
||||
[JsonIgnore]
|
||||
public int n;
|
||||
|
||||
[JsonIgnore]
|
||||
public int d;
|
||||
|
||||
[JsonIgnore]
|
||||
public double Decimal { get { return b + (double)n / d; } }
|
||||
|
||||
public int CompareTo(BeatTime other) {
|
||||
var c = b.CompareTo(other.b);
|
||||
if (c != 0) return c;
|
||||
return ((double)n / d).CompareTo((double)other.n / other.d);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) {
|
||||
if (!(obj is BeatTime)) return false;
|
||||
return Equals((BeatTime)obj);
|
||||
}
|
||||
|
||||
public bool Equals(BeatTime other) {
|
||||
return b.Equals(other.b) && ((double)n / d).Equals((double)other.n / other.d);
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
return Decimal.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(BeatTime left, BeatTime right) {
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(BeatTime left, BeatTime right) {
|
||||
return !left.Equals(right);
|
||||
}
|
||||
}
|
||||
public class BeatTimeConverter : JsonConverter {
|
||||
public override bool CanConvert(Type objectType) {
|
||||
return objectType == typeof(int[]);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
|
||||
int b = (int)reader.ReadAsInt32();
|
||||
int n = (int)reader.ReadAsInt32();
|
||||
int d = (int)reader.ReadAsInt32();
|
||||
reader.Read();
|
||||
return new BeatTime(b, n, d);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
|
||||
BeatTime obj = (BeatTime)value;
|
||||
writer.WriteStartArray();
|
||||
writer.WriteValue(obj.b);
|
||||
writer.WriteValue(obj.n);
|
||||
writer.WriteValue(obj.d);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/BeatTime.cs.meta
Normal file
11
Assets/Cryville/Crtr/BeatTime.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f29ed034a9faa27409d153dbd9a46f95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,4 +1,4 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
@@ -18,4 +18,4 @@ namespace Cryville.Crtr.Browsing {
|
||||
public string DescriptionMain { get; set; }
|
||||
public string DescriptionSub { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using TMPro;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
}
|
||||
private void DisplayCover(bool succeeded, Texture2D tex) {
|
||||
if (succeeded) {
|
||||
_icon.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
|
||||
_icon.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 160, 0, SpriteMeshType.FullRect);
|
||||
}
|
||||
}
|
||||
public void OnClick() {
|
||||
@@ -50,4 +50,4 @@ namespace Cryville.Crtr.Browsing {
|
||||
else resourceBrowser.OnObjectItemClicked(Id.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Unity.UI;
|
||||
using System;
|
||||
using TMPro;
|
||||
@@ -57,7 +57,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
}
|
||||
private void DisplayCover(bool succeeded, Texture2D tex) {
|
||||
if (succeeded) {
|
||||
_cover.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero);
|
||||
_cover.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 160, 0, SpriteMeshType.FullRect);
|
||||
}
|
||||
}
|
||||
public void OnPlay() {
|
||||
@@ -67,4 +67,4 @@ namespace Cryville.Crtr.Browsing {
|
||||
Master.OpenConfig(_id, _data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common;
|
||||
using Cryville.Crtr.Extension;
|
||||
using Mono.Cecil;
|
||||
using System;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public interface IResourceManager<T> {
|
||||
@@ -14,4 +14,4 @@ namespace Cryville.Crtr.Browsing {
|
||||
string[] GetSupportedFormats();
|
||||
IReadOnlyDictionary<string, string> GetPresetPaths();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
@@ -131,7 +131,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
else result = (1 - ratio) * Range.Value.x + ratio * Range.Value.y;
|
||||
}
|
||||
else {
|
||||
double delta = (ratio - 0.5f) * 2 * MaxStep * Time.deltaTime;
|
||||
double delta = (ratio > 0.5 ? 1 : -1) * Math.Pow((ratio - 0.5f) * 2, 2) * MaxStep * Time.deltaTime;
|
||||
if (LogarithmicMode) result = Math.Pow(Math.E, Math.Log(m_value) + delta);
|
||||
else result = m_value + delta;
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public class PVPString : PropertyValuePanel {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
@@ -24,4 +24,4 @@ namespace Cryville.Crtr.Browsing {
|
||||
GetComponentInParent<ResourceBrowser>().OnPathClicked(_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -48,4 +48,4 @@ namespace Cryville.Crtr.Browsing {
|
||||
_nameLabel.text = (Collapsed ? "+ " : "- ") + Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user