Compare commits
102 Commits
0.5.0-rc1
...
ff5928b556
@@ -1,8 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
|
|
||||||
[assembly: AssemblyCompany("Cryville")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Cryville 2020-2022")]
|
|
||||||
[assembly: AssemblyDefaultAlias("Cosmo Resona")]
|
|
||||||
[assembly: AssemblyProduct("Cosmo Resona")]
|
|
||||||
[assembly: AssemblyTitle("Cosmo Resona")]
|
|
||||||
[assembly: AssemblyVersion("0.5.0")]
|
|
||||||
Binary file not shown.
120
Assets/Cryville/Common/Buffers/TargetString.cs
Normal file
120
Assets/Cryville/Common/Buffers/TargetString.cs
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Buffers {
|
||||||
|
/// <summary>
|
||||||
|
/// An auto-resized <see cref="char" /> array as a variable-length string used as a target that is modified frequently.
|
||||||
|
/// </summary>
|
||||||
|
public class TargetString : IEnumerable<char> {
|
||||||
|
public event Action OnUpdate;
|
||||||
|
char[] _arr;
|
||||||
|
bool _invalidated;
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an instance of the <see cref="TargetString" /> class with a capacity of 16.
|
||||||
|
/// </summary>
|
||||||
|
public TargetString() : this(16) { }
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an instance of the <see cref="TargetString" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="capacity">The initial capacity of the string.</param>
|
||||||
|
public TargetString(int capacity) {
|
||||||
|
_arr = new char[capacity];
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets one of the characters in the string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">The zero-based index of the character.</param>
|
||||||
|
/// <returns>The character at the given index.</returns>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="index" /> is less than 0 or not less than <see cref="Length" />.</exception>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>Set <see cref="Length" /> to a desired value before updating the characters.</para>
|
||||||
|
/// <para>Call <see cref=" Validate" /> after all the characters are updated.</para>
|
||||||
|
/// </remarks>
|
||||||
|
public char this[int index] {
|
||||||
|
get {
|
||||||
|
if (index < 0 || index >= m_length)
|
||||||
|
throw new ArgumentOutOfRangeException("index");
|
||||||
|
return _arr[index];
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
if (index < 0 || index >= m_length)
|
||||||
|
throw new ArgumentOutOfRangeException("index");
|
||||||
|
if (_arr[index] == value) return;
|
||||||
|
_arr[index] = value;
|
||||||
|
_invalidated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int m_length;
|
||||||
|
/// <summary>
|
||||||
|
/// The length of the string.
|
||||||
|
/// </summary>
|
||||||
|
public int Length {
|
||||||
|
get {
|
||||||
|
return m_length;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
if (m_length == value) return;
|
||||||
|
if (_arr.Length < value) {
|
||||||
|
var len = m_length;
|
||||||
|
while (len < value) len *= 2;
|
||||||
|
var arr2 = new char[len];
|
||||||
|
Array.Copy(_arr, arr2, m_length);
|
||||||
|
_arr = arr2;
|
||||||
|
}
|
||||||
|
m_length = value;
|
||||||
|
_invalidated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Validates the string.
|
||||||
|
/// </summary>
|
||||||
|
public void Validate() {
|
||||||
|
if (!_invalidated) return;
|
||||||
|
_invalidated = false;
|
||||||
|
var ev = OnUpdate;
|
||||||
|
if (ev != null) ev.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator() {
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
public IEnumerator<char> GetEnumerator() {
|
||||||
|
return new Enumerator(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Enumerator : IEnumerator<char> {
|
||||||
|
readonly TargetString _self;
|
||||||
|
int _index = -1;
|
||||||
|
public Enumerator(TargetString self) { _self = self; }
|
||||||
|
|
||||||
|
public char Current {
|
||||||
|
get {
|
||||||
|
if (_index < 0)
|
||||||
|
throw new InvalidOperationException(_index == -1 ? "Enum not started" : "Enum ended");
|
||||||
|
return _self[_index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object IEnumerator.Current { get { return Current; } }
|
||||||
|
|
||||||
|
public void Dispose() {
|
||||||
|
_index = -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool MoveNext() {
|
||||||
|
if (_index == -2) return false;
|
||||||
|
_index++;
|
||||||
|
if (_index >= _self.Length) {
|
||||||
|
_index = -2;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset() {
|
||||||
|
_index = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 9ed0687e714ce1042921c0057f42039f
|
guid: f0fc34ac257793d4883a9cfcdb6941b9
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -10,10 +10,10 @@ namespace Cryville.Common {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static IdentifierManager SharedInstance = new IdentifierManager();
|
public static IdentifierManager SharedInstance = new IdentifierManager();
|
||||||
|
|
||||||
Dictionary<object, int> _idents = new Dictionary<object, int>();
|
readonly Dictionary<object, int> _idents = new Dictionary<object, int>();
|
||||||
List<object> _ids = new List<object>();
|
readonly List<object> _ids = new List<object>();
|
||||||
|
|
||||||
object _syncRoot = new object();
|
readonly object _syncRoot = new object();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates an instance of the <see cref="IdentifierManager" /> class.
|
/// Creates an instance of the <see cref="IdentifierManager" /> class.
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace Cryville.Common {
|
namespace Cryville.Common {
|
||||||
@@ -40,7 +41,7 @@ namespace Cryville.Common {
|
|||||||
public static void Create(string key, Logger logger) {
|
public static void Create(string key, Logger logger) {
|
||||||
Instances[key] = logger;
|
Instances[key] = logger;
|
||||||
if (logPath != null) {
|
if (logPath != null) {
|
||||||
Files[key] = new StreamWriter(logPath + "/" + ((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds).ToString() + "-" + key + ".log") {
|
Files[key] = new StreamWriter(logPath + "/" + ((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds).ToString(CultureInfo.InvariantCulture) + "-" + key + ".log") {
|
||||||
AutoFlush = true
|
AutoFlush = true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
78
Assets/Cryville/Common/Math/FractionUtils.cs
Normal file
78
Assets/Cryville/Common/Math/FractionUtils.cs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Math {
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a set of <see langword="static" /> methods related to fractions.
|
||||||
|
/// </summary>
|
||||||
|
public static class FractionUtils {
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a <see cref="double" /> decimal to a fraction.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The decimal.</param>
|
||||||
|
/// <param name="error">The error.</param>
|
||||||
|
/// <param name="n">The numerator.</param>
|
||||||
|
/// <param name="d">The denominator.</param>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="value" /> is less than 0 or <paramref name="error" /> is not greater than 0 or not less than 1.</exception>
|
||||||
|
public static void ToFraction(double value, double error, out int n, out int d) {
|
||||||
|
if (value < 0.0)
|
||||||
|
throw new ArgumentOutOfRangeException("value", "Must be >= 0.");
|
||||||
|
if (error <= 0.0 || error >= 1.0)
|
||||||
|
throw new ArgumentOutOfRangeException("accuracy", "Must be > 0 and < 1.");
|
||||||
|
|
||||||
|
int num = (int)System.Math.Floor(value);
|
||||||
|
value -= num;
|
||||||
|
|
||||||
|
if (value < error) { n = num; d = 1; return; }
|
||||||
|
if (1 - error < value) { n = num + 1; d = 1; return; }
|
||||||
|
|
||||||
|
int lower_n = 0;
|
||||||
|
int lower_d = 1;
|
||||||
|
int upper_n = 1;
|
||||||
|
int upper_d = 1;
|
||||||
|
while (true) {
|
||||||
|
int middle_n = lower_n + upper_n;
|
||||||
|
int middle_d = lower_d + upper_d;
|
||||||
|
|
||||||
|
if (middle_d * (value + error) < middle_n) {
|
||||||
|
upper_n = middle_n;
|
||||||
|
upper_d = middle_d;
|
||||||
|
}
|
||||||
|
else if (middle_n < (value - error) * middle_d) {
|
||||||
|
lower_n = middle_n;
|
||||||
|
lower_d = middle_d;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
n = num * middle_d + middle_n;
|
||||||
|
d = middle_d;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the greatest common divisor (GCD) of two integers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="n">The first integer.</param>
|
||||||
|
/// <param name="d">The second integer.</param>
|
||||||
|
/// <returns>The greatest common divisor (GCD) of the two integers.</returns>
|
||||||
|
public static int GreatestCommonDivisor(int n, int d) {
|
||||||
|
while (d != 0) {
|
||||||
|
int t = d;
|
||||||
|
d = n % d;
|
||||||
|
n = t;
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Simplifies a fraction.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="n">The numerator.</param>
|
||||||
|
/// <param name="d">The denominator.</param>
|
||||||
|
public static void Simplify(ref int n, ref int d) {
|
||||||
|
var gcd = GreatestCommonDivisor(n, d);
|
||||||
|
n /= gcd;
|
||||||
|
d /= gcd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a69a6c726b01961419c4835bba37a218
|
guid: 6829ada596979a545a935785eeea2972
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
namespace Cryville.Common.Math {
|
using System;
|
||||||
|
|
||||||
|
namespace Cryville.Common.Math {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a square matrix.
|
/// Represents a square matrix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SquareMatrix {
|
public class SquareMatrix {
|
||||||
readonly float[,] content;
|
readonly float[,] content;
|
||||||
|
readonly float[,] buffer;
|
||||||
|
readonly int[] refl;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The size of the matrix.
|
/// The size of the matrix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -17,6 +21,8 @@
|
|||||||
/// <param name="size">The size of the matrix.</param>
|
/// <param name="size">The size of the matrix.</param>
|
||||||
public SquareMatrix(int size) {
|
public SquareMatrix(int size) {
|
||||||
content = new float[size, size];
|
content = new float[size, size];
|
||||||
|
buffer = new float[size, size];
|
||||||
|
refl = new int[size];
|
||||||
Size = size;
|
Size = size;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -38,38 +44,36 @@
|
|||||||
/// <returns>The column vector eliminated.</returns>
|
/// <returns>The column vector eliminated.</returns>
|
||||||
public ColumnVector<T> Eliminate<T>(ColumnVector<T> v, IVectorOperator<T> o) {
|
public ColumnVector<T> Eliminate<T>(ColumnVector<T> v, IVectorOperator<T> o) {
|
||||||
int s = Size;
|
int s = Size;
|
||||||
float[,] d = (float[,])content.Clone();
|
Array.Copy(content, buffer, Size * Size);
|
||||||
int[] refl = new int[s];
|
for (int i = 0; i < s; i++) refl[i] = i;
|
||||||
for (int i = 0; i < s; i++)
|
|
||||||
refl[i] = i;
|
|
||||||
for (int r = 0; r < s; r++) {
|
for (int r = 0; r < s; r++) {
|
||||||
for (int r0 = r; r0 < s; r0++)
|
for (int r0 = r; r0 < s; r0++)
|
||||||
if (d[refl[r0], r] != 0) {
|
if (buffer[refl[r0], r] != 0) {
|
||||||
refl[r] = r0;
|
refl[r] = r0;
|
||||||
refl[r0] = r;
|
refl[r0] = r;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int or = refl[r];
|
int or = refl[r];
|
||||||
float sf0 = d[or, r];
|
float sf0 = buffer[or, r];
|
||||||
for (int c0 = r; c0 < s; c0++)
|
for (int c0 = r; c0 < s; c0++)
|
||||||
d[or, c0] /= sf0;
|
buffer[or, c0] /= sf0;
|
||||||
v[or] = o.ScalarMultiply(1 / sf0, v[or]);
|
v[or] = o.ScalarMultiply(1 / sf0, v[or]);
|
||||||
for (int r1 = r + 1; r1 < s; r1++) {
|
for (int r1 = r + 1; r1 < s; r1++) {
|
||||||
int or1 = refl[r1];
|
int or1 = refl[r1];
|
||||||
float sf1 = d[or1, r];
|
float sf1 = buffer[or1, r];
|
||||||
for (int c1 = r; c1 < s; c1++)
|
for (int c1 = r; c1 < s; c1++)
|
||||||
d[or1, c1] -= d[or, c1] * sf1;
|
buffer[or1, c1] -= buffer[or, c1] * sf1;
|
||||||
v[or1] = o.Add(v[or1], o.ScalarMultiply(-sf1, v[or]));
|
v[or1] = o.Add(v[or1], o.ScalarMultiply(-sf1, v[or]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
T[] res = new T[s];
|
ColumnVector<T> res = new ColumnVector<T>(s);
|
||||||
for (int r2 = s - 1; r2 >= 0; r2--) {
|
for (int r2 = s - 1; r2 >= 0; r2--) {
|
||||||
var v2 = v[refl[r2]];
|
var v2 = v[refl[r2]];
|
||||||
for (int c2 = r2 + 1; c2 < s; c2++)
|
for (int c2 = r2 + 1; c2 < s; c2++)
|
||||||
v2 = o.Add(v2, o.ScalarMultiply(-d[refl[r2], c2], res[refl[c2]]));
|
v2 = o.Add(v2, o.ScalarMultiply(-buffer[refl[r2], c2], res[refl[c2]]));
|
||||||
res[refl[r2]] = v2;
|
res[refl[r2]] = v2;
|
||||||
}
|
}
|
||||||
return new ColumnVector<T>(res);
|
return res;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a square matrix and fills it with polynomial coefficients.
|
/// Creates a square matrix and fills it with polynomial coefficients.
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace Cryville.Common.Network {
|
|||||||
encoding = Encoding.UTF8;
|
encoding = Encoding.UTF8;
|
||||||
payload = encoding.GetBytes(body);
|
payload = encoding.GetBytes(body);
|
||||||
headers.Add("Content-Encoding", encoding.EncodingName);
|
headers.Add("Content-Encoding", encoding.EncodingName);
|
||||||
headers.Add("Content-Length", payload.Length.ToString());
|
headers.Add("Content-Length", payload.Length.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
string request_line = string.Format(
|
string request_line = string.Format(
|
||||||
"{0} {1} {2}\r\n", method, uri, Version
|
"{0} {1} {2}\r\n", method, uri, Version
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ namespace Cryville.Common.Network {
|
|||||||
set { throw new NotSupportedException(); }
|
set { throw new NotSupportedException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Flush() {
|
public override void Flush() { }
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract byte[] ReadToEnd();
|
public abstract byte[] ReadToEnd();
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Cryville.Common.Network {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class InternalTlsClient : DefaultTlsClient {
|
private class InternalTlsClient : DefaultTlsClient {
|
||||||
string _host;
|
readonly string _host;
|
||||||
|
|
||||||
public InternalTlsClient(string host, TlsCrypto crypto) : base(crypto) {
|
public InternalTlsClient(string host, TlsCrypto crypto) : base(crypto) {
|
||||||
_host = host;
|
_host = host;
|
||||||
@@ -92,9 +92,7 @@ namespace Cryville.Common.Network {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NotifyServerCertificate(TlsServerCertificate serverCertificate) {
|
public void NotifyServerCertificate(TlsServerCertificate serverCertificate) { }
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace Cryville.Common.Plist {
|
|
||||||
public class PlistConvert {
|
|
||||||
public static T Deserialize<T>(string file) {
|
|
||||||
return (T)Deserialize(typeof(T), PlistCS.Plist.readPlist(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static object Deserialize(Type type, object obj, Binder binder = null) {
|
|
||||||
if (binder == null)
|
|
||||||
binder = BinderAttribute.CreateBinderOfType(type);
|
|
||||||
if (obj is IList) {
|
|
||||||
var lobj = (List<object>)obj;
|
|
||||||
foreach (var i in lobj) {
|
|
||||||
throw new NotImplementedException(); // TODO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (obj is IDictionary) {
|
|
||||||
var dobj = (Dictionary<string, object>)obj;
|
|
||||||
if (typeof(IDictionary).IsAssignableFrom(type)) {
|
|
||||||
var result = (IDictionary)ReflectionHelper.InvokeEmptyConstructor(type);
|
|
||||||
var it = type.GetGenericArguments()[1];
|
|
||||||
foreach (var i in dobj) {
|
|
||||||
var value = Deserialize(it, i.Value, binder);
|
|
||||||
result.Add(i.Key, value);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var result = ReflectionHelper.InvokeEmptyConstructor(type);
|
|
||||||
foreach (var i in dobj) {
|
|
||||||
var imis = type.GetMember(i.Key);
|
|
||||||
if (imis.Length == 0) continue;
|
|
||||||
var imi = imis[0];
|
|
||||||
var it = ReflectionHelper.GetMemberType(imi);
|
|
||||||
var value = Deserialize(it, i.Value, binder);
|
|
||||||
ReflectionHelper.SetValue(imi, result, value, binder);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else return obj;
|
|
||||||
throw new Exception(); // TODO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -40,7 +40,25 @@ namespace Cryville.Common {
|
|||||||
/// <param name="name">The file name excluding the extension.</param>
|
/// <param name="name">The file name excluding the extension.</param>
|
||||||
/// <returns>The escaped file name.</returns>
|
/// <returns>The escaped file name.</returns>
|
||||||
public static string EscapeFileName(string name) {
|
public static string EscapeFileName(string name) {
|
||||||
return Regex.Replace(name, @"[\/\\\<\>\:\x22\|\?\*\p{Cc}\.\s]", "_");
|
var result = Regex.Replace(name, @"[\/\\\<\>\:\x22\|\?\*\p{Cc}]", "_").TrimEnd(' ', '.');
|
||||||
|
if (result.Length == 0) return "_";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the process path from a command.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="command">The command.</param>
|
||||||
|
/// <returns>The process path.</returns>
|
||||||
|
public static string GetProcessPathFromCommand(string command) {
|
||||||
|
command = command.Trim();
|
||||||
|
if (command[0] == '"') {
|
||||||
|
return command.Substring(1, command.IndexOf('"', 1) - 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int e = command.IndexOf(' ');
|
||||||
|
if (e == -1) return command;
|
||||||
|
else return command.Substring(0, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@@ -11,13 +12,13 @@ namespace Cryville.Common.Unity {
|
|||||||
Transform dirs;
|
Transform dirs;
|
||||||
Transform files;
|
Transform files;
|
||||||
|
|
||||||
public Action Callback { private get; set; }
|
public event Action OnClose;
|
||||||
|
|
||||||
#if UNITY_ANDROID && !UNITY_EDITOR_WIN
|
#if UNITY_ANDROID && !UNITY_EDITOR_WIN
|
||||||
string androidStorage = "";
|
string androidStorage = "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string fileName = "";
|
string fileName = null;
|
||||||
public string FileName {
|
public string FileName {
|
||||||
get { return fileName; }
|
get { return fileName; }
|
||||||
}
|
}
|
||||||
@@ -27,8 +28,16 @@ namespace Cryville.Common.Unity {
|
|||||||
set { m_filter = value; }
|
set { m_filter = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE0051
|
public Dictionary<string, string> m_presetPaths = new Dictionary<string, string>();
|
||||||
|
public Dictionary<string, string> PresetPaths {
|
||||||
|
get { return m_presetPaths; }
|
||||||
|
set { m_presetPaths = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObject prefabButton;
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
|
prefabButton = Resources.Load<GameObject>("Common/Button");
|
||||||
panel = gameObject.transform.Find("Panel");
|
panel = gameObject.transform.Find("Panel");
|
||||||
title = panel.Find("Title/Text");
|
title = panel.Find("Title/Text");
|
||||||
drives = panel.Find("Drives/DrivesInner");
|
drives = panel.Find("Drives/DrivesInner");
|
||||||
@@ -38,8 +47,8 @@ namespace Cryville.Common.Unity {
|
|||||||
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
|
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
|
||||||
CurrentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
CurrentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
#elif UNITY_ANDROID
|
#elif UNITY_ANDROID
|
||||||
using (AndroidJavaClass ajc=new AndroidJavaClass("android.os.Environment"))
|
using (AndroidJavaClass ajc = new AndroidJavaClass("android.os.Environment"))
|
||||||
using (AndroidJavaObject file=ajc.CallStatic<AndroidJavaObject>("getExternalStorageDirectory")) {
|
using (AndroidJavaObject file = ajc.CallStatic<AndroidJavaObject>("getExternalStorageDirectory")) {
|
||||||
androidStorage = file.Call<string>("getAbsolutePath");
|
androidStorage = file.Call<string>("getAbsolutePath");
|
||||||
CurrentDirectory = new DirectoryInfo(androidStorage);
|
CurrentDirectory = new DirectoryInfo(androidStorage);
|
||||||
}
|
}
|
||||||
@@ -47,9 +56,8 @@ namespace Cryville.Common.Unity {
|
|||||||
#error No default directory
|
#error No default directory
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
UpdateGUI();
|
UpdateGUI(0);
|
||||||
}
|
}
|
||||||
#pragma warning restore IDE0051
|
|
||||||
|
|
||||||
public void Show() {
|
public void Show() {
|
||||||
fileName = null;
|
fileName = null;
|
||||||
@@ -57,85 +65,82 @@ namespace Cryville.Common.Unity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Close() {
|
public void Close() {
|
||||||
if (Callback != null) Callback.Invoke();
|
var ev = OnClose;
|
||||||
|
if (ev != null) ev.Invoke();
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DirectoryInfo CurrentDirectory;
|
public DirectoryInfo CurrentDirectory;
|
||||||
|
|
||||||
void OnDriveChanged(string s) {
|
void ChangeDirectory(DirectoryInfo s) {
|
||||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
CurrentDirectory = s;
|
||||||
CurrentDirectory = new DirectoryInfo(s);
|
UpdateGUI(1);
|
||||||
#elif UNITY_ANDROID
|
|
||||||
switch (s) {
|
|
||||||
case "?storage":
|
|
||||||
CurrentDirectory = new DirectoryInfo(androidStorage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#error No change drive logic
|
|
||||||
#endif
|
|
||||||
UpdateGUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDirectoryChanged(string s) {
|
void SelectFile(string s) {
|
||||||
CurrentDirectory = new DirectoryInfo(CurrentDirectory.FullName + "/" + s);
|
|
||||||
UpdateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnFileChanged(string s) {
|
|
||||||
fileName = s;
|
fileName = s;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateGUI() {
|
void UpdateGUI(int depth) {
|
||||||
title.GetComponent<Text>().text = CurrentDirectory.FullName;
|
title.GetComponent<Text>().text = CurrentDirectory.FullName;
|
||||||
|
|
||||||
CallHelper.Purge(drives);
|
if (depth <= 0) {
|
||||||
|
CallHelper.Purge(drives);
|
||||||
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
||||||
var dl = Directory.GetLogicalDrives();
|
var dl = Directory.GetLogicalDrives();
|
||||||
foreach (string d in dl) {
|
foreach (string d in dl) {
|
||||||
GameObject btn = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/Button"));
|
GameObject btn = Instantiate(prefabButton);
|
||||||
btn.GetComponentInChildren<Text>().text = d;
|
btn.GetComponentInChildren<Text>().text = d;
|
||||||
var ts = d;
|
btn.GetComponentInChildren<Button>().onClick.AddListener(() => ChangeDirectory(new DirectoryInfo(d)));
|
||||||
btn.GetComponentInChildren<Button>().onClick.AddListener(() => OnDriveChanged(ts));
|
btn.transform.SetParent(drives, false);
|
||||||
btn.transform.SetParent(drives, false);
|
}
|
||||||
}
|
|
||||||
#elif UNITY_ANDROID
|
#elif UNITY_ANDROID
|
||||||
GameObject sbtn = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/Button"));
|
GameObject sbtn = GameObject.Instantiate<GameObject>(prefabButton);
|
||||||
sbtn.GetComponentInChildren<Text>().text = "Storage";
|
sbtn.GetComponentInChildren<Text>().text = "Storage";
|
||||||
sbtn.GetComponentInChildren<Button>().onClick.AddListener(() => OnDriveChanged("?storage"));
|
sbtn.GetComponentInChildren<Button>().onClick.AddListener(() => OnDriveChanged(new DirectoryInfo(androidStorage)));
|
||||||
sbtn.transform.SetParent(drives, false);
|
sbtn.transform.SetParent(drives, false);
|
||||||
#else
|
#else
|
||||||
#error No update GUI logic
|
#error No update GUI logic
|
||||||
#endif
|
#endif
|
||||||
|
foreach (var p in m_presetPaths) {
|
||||||
|
var d = new DirectoryInfo(p.Value);
|
||||||
|
if (d.Exists) {
|
||||||
|
GameObject btn = Instantiate(prefabButton);
|
||||||
|
btn.GetComponentInChildren<Text>().text = p.Key;
|
||||||
|
btn.GetComponentInChildren<Button>().onClick.AddListener(() => ChangeDirectory(d));
|
||||||
|
btn.transform.SetParent(drives, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CallHelper.Purge(dirs);
|
CallHelper.Purge(dirs);
|
||||||
DirectoryInfo[] subdirs = CurrentDirectory.GetDirectories();
|
DirectoryInfo[] subdirs = CurrentDirectory.GetDirectories();
|
||||||
GameObject pbtn = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/Button"));
|
GameObject pbtn = Instantiate(prefabButton);
|
||||||
pbtn.GetComponentInChildren<Text>().text = "..";
|
pbtn.GetComponentInChildren<Text>().text = "..";
|
||||||
pbtn.GetComponentInChildren<Button>().onClick.AddListener(() => OnDirectoryChanged(".."));
|
pbtn.GetComponentInChildren<Button>().onClick.AddListener(() => ChangeDirectory(new DirectoryInfo(Path.Combine(CurrentDirectory.FullName, ".."))));
|
||||||
pbtn.transform.SetParent(dirs, false);
|
pbtn.transform.SetParent(dirs, false);
|
||||||
foreach (DirectoryInfo d in subdirs) {
|
foreach (DirectoryInfo d in subdirs) {
|
||||||
GameObject btn = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/Button"));
|
GameObject btn = Instantiate(prefabButton);
|
||||||
btn.GetComponentInChildren<Text>().text = d.Name;
|
btn.GetComponentInChildren<Text>().text = d.Name;
|
||||||
var ts = d.Name;
|
var ts = d;
|
||||||
btn.GetComponentInChildren<Button>().onClick.AddListener(() => OnDirectoryChanged(ts));
|
btn.GetComponentInChildren<Button>().onClick.AddListener(() => ChangeDirectory(ts));
|
||||||
btn.transform.SetParent(dirs, false);
|
btn.transform.SetParent(dirs, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallHelper.Purge(files);
|
CallHelper.Purge(files);
|
||||||
FileInfo[] fl = CurrentDirectory.GetFiles();
|
FileInfo[] fl = CurrentDirectory.GetFiles();
|
||||||
foreach (FileInfo d in fl) {
|
foreach (FileInfo d in fl) {
|
||||||
foreach (string ext in m_filter)
|
foreach (string ext in m_filter) {
|
||||||
if (d.Extension == ext) goto ext_matched;
|
if (d.Extension == ext) {
|
||||||
continue;
|
GameObject btn = Instantiate(prefabButton);
|
||||||
ext_matched:
|
btn.GetComponentInChildren<Text>().text = d.Name + " / " + (d.Length / 1024.0).ToString("0.0 KiB");
|
||||||
GameObject btn = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/Button"));
|
var ts = d.FullName;
|
||||||
btn.GetComponentInChildren<Text>().text = d.Name + " / " + (d.Length / 1024.0).ToString("0.0 KiB");
|
btn.GetComponentInChildren<Button>().onClick.AddListener(() => SelectFile(ts));
|
||||||
var ts = d.FullName;
|
btn.transform.SetParent(files, false);
|
||||||
btn.GetComponentInChildren<Button>().onClick.AddListener(() => OnFileChanged(ts));
|
break;
|
||||||
btn.transform.SetParent(files, false);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
typeof(UnityMouseHandler),
|
typeof(UnityMouseHandler),
|
||||||
typeof(UnityTouchHandler),
|
typeof(UnityTouchHandler),
|
||||||
};
|
};
|
||||||
// TODO set private
|
readonly List<InputHandler> _handlers = new List<InputHandler>();
|
||||||
public readonly List<InputHandler> _handlers = new List<InputHandler>();
|
|
||||||
readonly Dictionary<Type, InputHandler> _typemap = new Dictionary<Type, InputHandler>();
|
readonly Dictionary<Type, InputHandler> _typemap = new Dictionary<Type, InputHandler>();
|
||||||
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
|
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
|
||||||
readonly object _lock = new object();
|
readonly object _lock = new object();
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ namespace Cryville.Common.Unity.Input {
|
|||||||
Callback = h;
|
Callback = h;
|
||||||
}
|
}
|
||||||
public abstract string GetKeyName(int type);
|
public abstract string GetKeyName(int type);
|
||||||
|
void Awake() {
|
||||||
|
useGUILayout = false;
|
||||||
|
}
|
||||||
void Update() {
|
void Update() {
|
||||||
double time = Time.realtimeSinceStartupAsDouble;
|
double time = Time.realtimeSinceStartupAsDouble;
|
||||||
foreach (var k in Keys) {
|
foreach (var k in Keys) {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ namespace Cryville.Common.Unity {
|
|||||||
fdialog = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/FileDialog")).GetComponent<FileDialog>();
|
fdialog = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/FileDialog")).GetComponent<FileDialog>();
|
||||||
fdialog.Filter = filter;
|
fdialog.Filter = filter;
|
||||||
fdialog.CurrentDirectory = ContextPath;
|
fdialog.CurrentDirectory = ContextPath;
|
||||||
fdialog.Callback = () => OnFileDialogClosed();
|
fdialog.OnClose += OnFileDialogClosed;
|
||||||
}
|
}
|
||||||
editor.SetDescription(PropertyName, desc);
|
editor.SetDescription(PropertyName, desc);
|
||||||
UpdateValue();
|
UpdateValue();
|
||||||
|
|||||||
@@ -126,8 +126,8 @@ namespace Cryville.Common.Unity.UI {
|
|||||||
void Update() {
|
void Update() {
|
||||||
Vector2 cprectsize = ((RectTransform)transform.parent).rect.size;
|
Vector2 cprectsize = ((RectTransform)transform.parent).rect.size;
|
||||||
if (cprectsize != pprectsize) {
|
if (cprectsize != pprectsize) {
|
||||||
OnFrameUpdate();
|
|
||||||
pprectsize = cprectsize;
|
pprectsize = cprectsize;
|
||||||
|
OnFrameUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma warning restore IDE0051
|
#pragma warning restore IDE0051
|
||||||
|
|||||||
22
Assets/Cryville/Crtr/Browsing/ChartResourceImporter.cs
Normal file
22
Assets/Cryville/Crtr/Browsing/ChartResourceImporter.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Cryville.Crtr.Browsing {
|
||||||
|
public class ChartResourceImporter : ResourceConverter {
|
||||||
|
static readonly string[] SUPPORTED_FORMATS = { ".umgc" };
|
||||||
|
public override string[] GetSupportedFormats() {
|
||||||
|
return SUPPORTED_FORMATS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||||
|
var meta = Path.Combine(file.Directory.FullName, "meta.json");
|
||||||
|
if (!File.Exists(meta)) throw new FileNotFoundException("Meta file for the chart not found");
|
||||||
|
using (StreamReader reader = new StreamReader(meta, Encoding.UTF8)) {
|
||||||
|
var data = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
||||||
|
return new Resource[] { new ChartResource(data.name, file) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: d6a3a023271b82a4985d1bbcc86e6fa8
|
guid: 168366bb891392b42a1d0a6bfa068ff3
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -47,11 +47,11 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
_cover.sprite = m_coverPlaceholder;
|
_cover.sprite = m_coverPlaceholder;
|
||||||
if (data.Cover != null) data.Cover.Destination = DisplayCover;
|
if (data.Cover != null) data.Cover.Destination = DisplayCover;
|
||||||
var meta = data.Meta;
|
var meta = data.Meta;
|
||||||
_title.text = string.Format("{0}\n{1}", meta.song.name, meta.chart.name);
|
_title.text = string.Format("{0}\n{1}", meta.song.name, meta.name);
|
||||||
_desc.text = string.Format(
|
_desc.text = string.Format(
|
||||||
"Music artist: {0}\nCharter: {1}\nLength: {2}\nNote Count: {3}",
|
"Music artist: {0}\nCharter: {1}\nLength: {2}\nNote Count: {3}",
|
||||||
meta.song.author, meta.chart.author,
|
meta.song.author, meta.author,
|
||||||
TimeSpan.FromSeconds(meta.chart.length).ToString(3), meta.note_count
|
TimeSpan.FromSeconds(meta.length).ToString(3), meta.note_count
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
private void DisplayCover(bool succeeded, Texture2D tex) {
|
private void DisplayCover(bool succeeded, Texture2D tex) {
|
||||||
|
|||||||
9
Assets/Cryville/Crtr/Browsing/ExtensionInterface.cs
Normal file
9
Assets/Cryville/Crtr/Browsing/ExtensionInterface.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Cryville.Crtr.Browsing {
|
||||||
|
public abstract class ExtensionInterface {
|
||||||
|
public abstract IEnumerable<ResourceConverter> GetResourceConverters();
|
||||||
|
public abstract IEnumerable<LocalResourceFinder> GetResourceFinders();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 62489f8e495a805478e5b45c0f53ca4e
|
guid: 4ffe72fef6ebb9e4da3571b4117f0d6d
|
||||||
timeCreated: 1623583546
|
|
||||||
licenseType: Pro
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Cryville.Crtr.Browsing {
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Cryville.Crtr.Browsing {
|
||||||
public interface IResourceManager<T> {
|
public interface IResourceManager<T> {
|
||||||
string[] CurrentDirectory { get; }
|
string[] CurrentDirectory { get; }
|
||||||
int ChangeDirectory(string[] dir);
|
int ChangeDirectory(string[] dir);
|
||||||
@@ -10,5 +12,6 @@
|
|||||||
|
|
||||||
bool ImportItemFrom(string path);
|
bool ImportItemFrom(string path);
|
||||||
string[] GetSupportedFormats();
|
string[] GetSupportedFormats();
|
||||||
|
Dictionary<string, string> GetPresetPaths();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,8 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
|
|
||||||
static readonly Dictionary<string, List<ResourceConverter>> converters
|
static readonly Dictionary<string, List<ResourceConverter>> converters
|
||||||
= new Dictionary<string, List<ResourceConverter>>();
|
= new Dictionary<string, List<ResourceConverter>>();
|
||||||
|
static readonly Dictionary<string, string> localRes
|
||||||
|
= new Dictionary<string, string>();
|
||||||
|
|
||||||
public LegacyResourceManager(string rootPath) {
|
public LegacyResourceManager(string rootPath) {
|
||||||
_rootPath = rootPath;
|
_rootPath = rootPath;
|
||||||
@@ -25,13 +27,35 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
static LegacyResourceManager() {
|
static LegacyResourceManager() {
|
||||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) {
|
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) {
|
||||||
foreach (var type in asm.GetTypes()) {
|
foreach (var type in asm.GetTypes()) {
|
||||||
if (type.IsSubclassOf(typeof(ResourceConverter))) {
|
if (!type.IsSubclassOf(typeof(ExtensionInterface))) continue;
|
||||||
var converter = (ResourceConverter)Activator.CreateInstance(type);
|
var ext = (ExtensionInterface)Activator.CreateInstance(type);
|
||||||
foreach (var f in converter.GetSupportedFormats()) {
|
try {
|
||||||
if (!converters.ContainsKey(f))
|
var cs = ext.GetResourceConverters();
|
||||||
converters.Add(f, new List<ResourceConverter> { converter });
|
if (cs != null) {
|
||||||
else converters[f].Add(converter);
|
foreach (var c in cs) {
|
||||||
|
var fs = c.GetSupportedFormats();
|
||||||
|
if (fs == null) continue;
|
||||||
|
foreach (var f in fs) {
|
||||||
|
if (f == null) continue;
|
||||||
|
if (!converters.ContainsKey(f))
|
||||||
|
converters.Add(f, new List<ResourceConverter> { c });
|
||||||
|
else converters[f].Add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
var fs2 = ext.GetResourceFinders();
|
||||||
|
if (fs2 != null) {
|
||||||
|
foreach (var f in fs2) {
|
||||||
|
var name = f.Name;
|
||||||
|
var path = f.GetRootPath();
|
||||||
|
if (name != null && path != null)
|
||||||
|
localRes.Add(name, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Logger.Log("main", 1, "Resource", "Loaded extension {0}", ReflectionHelper.GetNamespaceQualifiedName(type));
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Log("main", 4, "Resource", "Failed to initialize extension {0}: {1}", ReflectionHelper.GetNamespaceQualifiedName(type), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,12 +86,12 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
var meta = new ChartMeta();
|
var meta = new ChartMeta();
|
||||||
string name = item.Name;
|
string name = item.Name;
|
||||||
string desc = "(Unknown)";
|
string desc = "(Unknown)";
|
||||||
var metaFile = new FileInfo(item.FullName + "/meta.json");
|
var metaFile = new FileInfo(item.FullName + "/.umgc");
|
||||||
if (metaFile.Exists) {
|
if (metaFile.Exists) {
|
||||||
using (var reader = new StreamReader(metaFile.FullName)) {
|
using (var reader = new StreamReader(metaFile.FullName)) {
|
||||||
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
||||||
name = meta.song.name;
|
name = meta.song.name;
|
||||||
desc = meta.chart.name;
|
desc = meta.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AsyncDelivery<Texture2D> cover = null;
|
AsyncDelivery<Texture2D> cover = null;
|
||||||
@@ -91,7 +115,7 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
public ChartDetail GetItemDetail(int id) {
|
public ChartDetail GetItemDetail(int id) {
|
||||||
var item = items[id];
|
var item = items[id];
|
||||||
var meta = new ChartMeta();
|
var meta = new ChartMeta();
|
||||||
var metaFile = new FileInfo(item.FullName + "/meta.json");
|
var metaFile = new FileInfo(item.FullName + "/.umgc");
|
||||||
if (metaFile.Exists) {
|
if (metaFile.Exists) {
|
||||||
using (var reader = new StreamReader(metaFile.FullName)) {
|
using (var reader = new StreamReader(metaFile.FullName)) {
|
||||||
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
||||||
@@ -114,7 +138,13 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string GetItemPath(int id) {
|
public string GetItemPath(int id) {
|
||||||
return items[id].Name + "/.umgc";
|
var item = items[id];
|
||||||
|
var meta = new ChartMeta();
|
||||||
|
var metaFile = new FileInfo(item.FullName + "/.umgc");
|
||||||
|
using (var reader = new StreamReader(metaFile.FullName)) {
|
||||||
|
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
||||||
|
}
|
||||||
|
return string.Format("{0}/{1}.json", items[id].Name, meta.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ImportItemFrom(string path) {
|
public bool ImportItemFrom(string path) {
|
||||||
@@ -126,38 +156,56 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
resources = converter.ConvertFrom(file);
|
resources = converter.ConvertFrom(file);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
Popup.Create(ex.Message);
|
LogAndPopup(4, ex.Message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
foreach (var res in resources) {
|
foreach (var res in resources) {
|
||||||
if (!res.Valid) {
|
if (!res.Valid) {
|
||||||
Logger.Log("main", 3, "Resource", "Attempt to import invalid resource {0}", res);
|
LogAndPopup(3, "Attempt to import invalid resource: {0}", res);
|
||||||
}
|
}
|
||||||
else if (res is ChartResource) {
|
else if (res is RawChartResource) {
|
||||||
var tres = (ChartResource)res;
|
var tres = (RawChartResource)res;
|
||||||
var dir = new DirectoryInfo(_rootPath + "/charts/" + res.Name);
|
var dir = new DirectoryInfo(_rootPath + "/charts/" + res.Name);
|
||||||
if (!dir.Exists) dir.Create();
|
if (!dir.Exists) dir.Create();
|
||||||
using (var writer = new StreamWriter(dir.FullName + "/.umgc")) {
|
using (var writer = new StreamWriter(dir.FullName + "/.json")) {
|
||||||
writer.Write(JsonConvert.SerializeObject(tres.Main, Game.GlobalJsonSerializerSettings));
|
writer.Write(JsonConvert.SerializeObject(tres.Main, Game.GlobalJsonSerializerSettings));
|
||||||
}
|
}
|
||||||
using (var writer = new StreamWriter(dir.FullName + "/meta.json")) {
|
using (var writer = new StreamWriter(dir.FullName + "/.umgc")) {
|
||||||
|
tres.Meta.data = "";
|
||||||
writer.Write(JsonConvert.SerializeObject(tres.Meta, Game.GlobalJsonSerializerSettings));
|
writer.Write(JsonConvert.SerializeObject(tres.Meta, Game.GlobalJsonSerializerSettings));
|
||||||
}
|
}
|
||||||
|
if (tres.Meta.cover != null) {
|
||||||
|
var coverFile = new FileInfo(Path.Combine(file.Directory.FullName, tres.Meta.cover));
|
||||||
|
if (coverFile.Exists)
|
||||||
|
coverFile.CopyTo(Path.Combine(dir.FullName, tres.Meta.cover), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (res is CoverResource) {
|
else if (res is FileResource) {
|
||||||
var tres = (CoverResource)res;
|
var tres = (FileResource)res;
|
||||||
var dir = new DirectoryInfo(_rootPath + "/charts/" + res.Name);
|
DirectoryInfo dest;
|
||||||
if (!dir.Exists) dir.Create();
|
if (res is ChartResource)
|
||||||
var dest = new FileInfo(_rootPath + "/charts/" + res.Name + "/" + tres.Source.Name);
|
dest = new DirectoryInfo(_rootPath + "/charts/" + res.Name);
|
||||||
if (!dest.Exists) tres.Source.CopyTo(dest.FullName);
|
else if (res is RulesetResource)
|
||||||
|
dest = new DirectoryInfo(_rootPath + "/rulesets/" + res.Name);
|
||||||
|
else if (res is SkinResource)
|
||||||
|
dest = new DirectoryInfo(_rootPath + "/skins/" + (res as SkinResource).RulesetName + "/" + res.Name);
|
||||||
|
else if (res is SongResource)
|
||||||
|
dest = new DirectoryInfo(_rootPath + "/songs/" + res.Name);
|
||||||
|
else {
|
||||||
|
LogAndPopup(3, "Attempt to import unsupported file resource: {0}", res);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!dest.Exists) {
|
||||||
|
dest.Create();
|
||||||
|
tres.Master.CopyTo(Path.Combine(dest.FullName, tres.Master.Extension));
|
||||||
|
foreach (var attachment in tres.Attachments) {
|
||||||
|
attachment.CopyTo(Path.Combine(dest.FullName, attachment.Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else LogAndPopup(1, "Resource already exists: {0}", res);
|
||||||
}
|
}
|
||||||
else if (res is SongResource) {
|
else {
|
||||||
var tres = (SongResource)res;
|
LogAndPopup(3, "Attempt to import unsupported resource: {0}", res);
|
||||||
var dir = new DirectoryInfo(_rootPath + "/songs/" + res.Name);
|
|
||||||
if (!dir.Exists) dir.Create();
|
|
||||||
var dest = new FileInfo(_rootPath + "/songs/" + res.Name + "/.ogg");
|
|
||||||
if (!dest.Exists) tres.Source.CopyTo(dest.FullName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -165,8 +213,18 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogAndPopup(int level, string format, params object[] args) {
|
||||||
|
var msg = string.Format(format, args);
|
||||||
|
Logger.Log("main", level, "Resource", msg);
|
||||||
|
Popup.Create(msg);
|
||||||
|
}
|
||||||
|
|
||||||
public string[] GetSupportedFormats() {
|
public string[] GetSupportedFormats() {
|
||||||
return converters.Keys.ToArray();
|
return converters.Keys.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, string> GetPresetPaths() {
|
||||||
|
return localRes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
6
Assets/Cryville/Crtr/Browsing/LocalResourceFinder.cs
Normal file
6
Assets/Cryville/Crtr/Browsing/LocalResourceFinder.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Cryville.Crtr.Browsing {
|
||||||
|
public abstract class LocalResourceFinder {
|
||||||
|
public abstract string Name { get; }
|
||||||
|
public abstract string GetRootPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Crtr/Browsing/LocalResourceFinder.cs.meta
Normal file
11
Assets/Cryville/Crtr/Browsing/LocalResourceFinder.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f5b3f3294f679f14f8ec1195b0def630
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Cryville.Common.Unity;
|
using Cryville.Common.Unity;
|
||||||
using Cryville.Common.Unity.UI;
|
using Cryville.Common.Unity.UI;
|
||||||
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@@ -19,6 +20,9 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
|
|
||||||
_dialog = GameObject.Instantiate(Resources.Load<GameObject>("Common/FileDialog")).GetComponent<FileDialog>();
|
_dialog = GameObject.Instantiate(Resources.Load<GameObject>("Common/FileDialog")).GetComponent<FileDialog>();
|
||||||
_dialog.gameObject.SetActive(false);
|
_dialog.gameObject.SetActive(false);
|
||||||
|
_dialog.Filter = ResourceManager.GetSupportedFormats();
|
||||||
|
_dialog.PresetPaths = ResourceManager.GetPresetPaths();
|
||||||
|
_dialog.OnClose += OnAddDialogClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool LoadPathPart(int id, GameObject obj) {
|
private bool LoadPathPart(int id, GameObject obj) {
|
||||||
@@ -29,8 +33,13 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
|
|
||||||
private bool LoadItem(int id, GameObject obj) {
|
private bool LoadItem(int id, GameObject obj) {
|
||||||
var bi = obj.GetComponent<BrowserItem>();
|
var bi = obj.GetComponent<BrowserItem>();
|
||||||
var item = ResourceManager.GetItemMeta(id);
|
try {
|
||||||
bi.Load(id, item);
|
var item = ResourceManager.GetItemMeta(id);
|
||||||
|
bi.Load(id, item);
|
||||||
|
}
|
||||||
|
catch (Exception) {
|
||||||
|
bi.Load(id, new ResourceItemMeta { Name = "<color=#ff0000>Invalid resource</color>" });
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,8 +60,6 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void OnAddButtonClicked() {
|
public void OnAddButtonClicked() {
|
||||||
_dialog.Callback = OnAddDialogClosed;
|
|
||||||
_dialog.Filter = ResourceManager.GetSupportedFormats();
|
|
||||||
_dialog.Show();
|
_dialog.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Cryville.Common;
|
using Cryville.Common;
|
||||||
using Cryville.Common.Unity.UI;
|
using Cryville.Common.Unity.UI;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
@@ -97,14 +98,19 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE1006
|
#pragma warning disable IDE1006
|
||||||
public struct ChartMeta {
|
public class MetaInfo {
|
||||||
public MetaInfo song { get; set; }
|
public string name { get; set; }
|
||||||
public MetaInfo chart { get; set; }
|
public string author { get; set; }
|
||||||
public struct MetaInfo {
|
[JsonRequired]
|
||||||
public string name { get; set; }
|
public string data { get; set; }
|
||||||
public string author { get; set; }
|
}
|
||||||
public float length { get; set; }
|
public class SongMetaInfo {
|
||||||
}
|
public string name { get; set; }
|
||||||
|
public string author { get; set; }
|
||||||
|
}
|
||||||
|
public class ChartMeta : MetaInfo {
|
||||||
|
public SongMetaInfo song { get; set; }
|
||||||
|
public float length { get; set; }
|
||||||
public string ruleset { get; set; }
|
public string ruleset { get; set; }
|
||||||
public int note_count { get; set; }
|
public int note_count { get; set; }
|
||||||
public string cover { get; set; }
|
public string cover { get; set; }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Cryville.Common;
|
using Cryville.Common;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
@@ -17,26 +18,62 @@ namespace Cryville.Crtr.Browsing {
|
|||||||
return string.Format("{0} ({1})", Name, ReflectionHelper.GetSimpleName(GetType()));
|
return string.Format("{0} ({1})", Name, ReflectionHelper.GetSimpleName(GetType()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class ChartResource : Resource {
|
public class RawChartResource : Resource {
|
||||||
public ChartResource(string name, Chart main, ChartMeta meta) : base(name) {
|
public RawChartResource(string name, Chart main, ChartMeta meta) : base(name) {
|
||||||
Main = main; Meta = meta;
|
Main = main; Meta = meta;
|
||||||
}
|
}
|
||||||
public Chart Main { get; private set; }
|
public Chart Main { get; private set; }
|
||||||
public ChartMeta Meta { get; private set; }
|
public ChartMeta Meta { get; private set; }
|
||||||
public override bool Valid { get { return true; } }
|
public override bool Valid { get { return true; } }
|
||||||
}
|
}
|
||||||
public class CoverResource : Resource {
|
public abstract class FileResource : Resource {
|
||||||
public CoverResource(string name, FileInfo src) : base(name) {
|
public FileResource(string name, FileInfo master) : base(name) {
|
||||||
Source = src;
|
Master = master;
|
||||||
|
Attachments = new List<FileInfo>();
|
||||||
|
}
|
||||||
|
public FileInfo Master { get; private set; }
|
||||||
|
public List<FileInfo> Attachments { get; private set; }
|
||||||
|
public override bool Valid {
|
||||||
|
get {
|
||||||
|
if (!Master.Exists) return false;
|
||||||
|
foreach (var file in Attachments) {
|
||||||
|
if (!file.Exists) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public FileInfo Source { get; private set; }
|
|
||||||
public override bool Valid { get { return Source.Exists; } }
|
|
||||||
}
|
}
|
||||||
public class SongResource : Resource {
|
public class ChartResource : FileResource {
|
||||||
public SongResource(string name, FileInfo src) : base(name) {
|
public ChartResource(string name, FileInfo master) : base(name, master) {
|
||||||
Source = src;
|
using (var reader = new StreamReader(master.FullName)) {
|
||||||
|
var meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
||||||
|
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".json")));
|
||||||
|
if (meta.cover != null) Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.cover)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class SongResource : FileResource {
|
||||||
|
public SongResource(string name, FileInfo master) : base(name, master) { }
|
||||||
|
}
|
||||||
|
public class RulesetResource : FileResource {
|
||||||
|
public RulesetResource(string name, FileInfo master) : base(name, master) {
|
||||||
|
using (var reader = new StreamReader(master.FullName)) {
|
||||||
|
var meta = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd());
|
||||||
|
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".pdt")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class SkinResource : FileResource {
|
||||||
|
public string RulesetName { get; private set; }
|
||||||
|
public SkinResource(string name, FileInfo master) : base(name, master) {
|
||||||
|
using (var reader = new StreamReader(master.FullName)) {
|
||||||
|
var meta = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd());
|
||||||
|
RulesetName = meta.ruleset;
|
||||||
|
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".pdt")));
|
||||||
|
foreach (var frame in meta.frames) {
|
||||||
|
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, frame)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public FileInfo Source { get; private set; }
|
|
||||||
public override bool Valid { get { return Source.Exists; } }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
20
Assets/Cryville/Crtr/Browsing/RulesetResourceImporter.cs
Normal file
20
Assets/Cryville/Crtr/Browsing/RulesetResourceImporter.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Cryville.Crtr.Browsing {
|
||||||
|
public class RulesetResourceImporter : ResourceConverter {
|
||||||
|
static readonly string[] SUPPORTED_FORMATS = { ".umgr" };
|
||||||
|
public override string[] GetSupportedFormats() {
|
||||||
|
return SUPPORTED_FORMATS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||||
|
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||||
|
var data = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd());
|
||||||
|
return new Resource[] { new RulesetResource(data.name, file) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f2c1531e76f19a647865f7ec335561cd
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
20
Assets/Cryville/Crtr/Browsing/SkinResourceImporter.cs
Normal file
20
Assets/Cryville/Crtr/Browsing/SkinResourceImporter.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Cryville.Crtr.Browsing {
|
||||||
|
public class SkinResourceImporter : ResourceConverter {
|
||||||
|
static readonly string[] SUPPORTED_FORMATS = { ".umgs" };
|
||||||
|
public override string[] GetSupportedFormats() {
|
||||||
|
return SUPPORTED_FORMATS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||||
|
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||||
|
var data = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd());
|
||||||
|
return new Resource[] { new SkinResource(data.name, file) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Crtr/Browsing/SkinResourceImporter.cs.meta
Normal file
11
Assets/Cryville/Crtr/Browsing/SkinResourceImporter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9904b4c21758c5046afc341fe2fa8845
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -3,19 +3,25 @@ using Newtonsoft.Json;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
[JsonConverter(typeof(BeatTimeConverter))]
|
[JsonConverter(typeof(BeatTimeConverter))]
|
||||||
public struct BeatTime {
|
public struct BeatTime : IComparable<BeatTime>, IEquatable<BeatTime> {
|
||||||
[JsonConstructor()]
|
[JsonConstructor()]
|
||||||
public BeatTime(int _b, int _n, int _d) {
|
public BeatTime(int _b, int _n, int _d) {
|
||||||
b = _b;
|
b = _b;
|
||||||
n = _n;
|
n = _n;
|
||||||
d = _d;
|
d = _d;
|
||||||
}
|
}
|
||||||
|
public BeatTime(int _n, int _d) {
|
||||||
|
b = _n / _d;
|
||||||
|
n = _n % _d;
|
||||||
|
d = _d;
|
||||||
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int b;
|
public int b;
|
||||||
|
|
||||||
@@ -24,6 +30,36 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int d;
|
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 class BeatTimeConverter : JsonConverter {
|
||||||
@@ -55,7 +91,7 @@ namespace Cryville.Crtr {
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public float BeatPosition {
|
public float BeatPosition {
|
||||||
get {
|
get {
|
||||||
return time.Value.b + time.Value.n / (float)time.Value.d + BeatOffset;
|
return (float)time.Value.Decimal + BeatOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +101,7 @@ namespace Cryville.Crtr {
|
|||||||
public float EndBeatPosition {
|
public float EndBeatPosition {
|
||||||
get {
|
get {
|
||||||
if (endtime == null) return BeatPosition;
|
if (endtime == null) return BeatPosition;
|
||||||
return endtime.Value.b + endtime.Value.n / (float)endtime.Value.d + BeatOffset;
|
return (float)endtime.Value.Decimal + BeatOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +311,7 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
private void LoadFromString(string s) {
|
private void LoadFromString(string s) {
|
||||||
Match m = Regex.Match(s, @"^(.+?)(#(\d+))?(@(.+?))?(\^(.+?))?(\*(.+?))?(:(.+))?$");
|
Match m = Regex.Match(s, @"^(.+?)(#(\d+))?(@(.+?))?(\^(.+?))?(\*(.+?))?(:(.+))?$");
|
||||||
if (!m.Success) throw new ArgumentException(); // TODO
|
if (!m.Success) throw new ArgumentException("Invalid motion string format");
|
||||||
name = new Identifier(m.Groups[1].Value);
|
name = new Identifier(m.Groups[1].Value);
|
||||||
var registry = ChartPlayer.motionRegistry[name];
|
var registry = ChartPlayer.motionRegistry[name];
|
||||||
if (m.Groups[3].Success) {
|
if (m.Groups[3].Success) {
|
||||||
@@ -303,7 +339,7 @@ namespace Cryville.Crtr {
|
|||||||
var node = RelativeNode;
|
var node = RelativeNode;
|
||||||
result += "#" + node.Id;
|
result += "#" + node.Id;
|
||||||
if (node.Time != null) result += "@" + node.Time.ToString();
|
if (node.Time != null) result += "@" + node.Time.ToString();
|
||||||
if (node.Transition != null) result = "^" + node.Transition.ToString();
|
if (node.Transition != null) result = "^" + ((byte)node.Transition).ToString(CultureInfo.InvariantCulture);
|
||||||
if (node.Rate != null) result += "*" + node.Rate.ToString();
|
if (node.Rate != null) result += "*" + node.Rate.ToString();
|
||||||
if (node.Value != null) result += ":" + node.Value.ToString();
|
if (node.Value != null) result += ":" + node.Value.ToString();
|
||||||
}
|
}
|
||||||
@@ -377,14 +413,6 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Note() {
|
|
||||||
SubmitPropSrc("track", new PropSrc.Float(() => {
|
|
||||||
var i = motions.FirstOrDefault(m => m.RelativeNode == null && m.Name == "track");
|
|
||||||
if (i == null) return ((Vec1)ChartPlayer.motionRegistry["track"].InitValue).Value;
|
|
||||||
else return ((Vec1)i.AbsoluteValue).Value;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override EventList GetEventsOfType(string type) {
|
public override EventList GetEventsOfType(string type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "judges": return new EventList<Judge>(judges);
|
case "judges": return new EventList<Judge>(judges);
|
||||||
@@ -399,10 +427,12 @@ namespace Cryville.Crtr {
|
|||||||
public class Judge : ChartEvent {
|
public class Judge : ChartEvent {
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Identifier Id;
|
public Identifier Id;
|
||||||
|
#pragma warning disable IDE1006
|
||||||
public string name {
|
public string name {
|
||||||
get { return Id.ToString(); }
|
get { return Id.ToString(); }
|
||||||
set { Id = new Identifier(value); }
|
set { Id = new Identifier(value); }
|
||||||
}
|
}
|
||||||
|
#pragma warning restore IDE1006
|
||||||
|
|
||||||
public override int Priority {
|
public override int Priority {
|
||||||
get { return 0; }
|
get { return 0; }
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ namespace Cryville.Crtr {
|
|||||||
else if (ev.Unstamped == null) { }
|
else if (ev.Unstamped == null) { }
|
||||||
else if (ev.Unstamped is Chart.Sound) {
|
else if (ev.Unstamped is Chart.Sound) {
|
||||||
Chart.Sound tev = (Chart.Sound)ev.Unstamped;
|
Chart.Sound tev = (Chart.Sound)ev.Unstamped;
|
||||||
var source = new LibavFileAudioSource(
|
var dir = new DirectoryInfo(Game.GameDataPath + "/songs/" + tev.id);
|
||||||
Game.GameDataPath + "/songs/" + tev.id + "/.ogg"
|
var files = dir.GetFiles();
|
||||||
);
|
var source = new LibavFileAudioSource(files[0].FullName);
|
||||||
source.SelectStream();
|
source.SelectStream();
|
||||||
sounds.Add(source);
|
sounds.Add(source);
|
||||||
Game.AudioSession.Sequence(
|
Game.AudioSession.Sequence(
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#define BUILD
|
#define BUILD
|
||||||
|
|
||||||
using Cryville.Common;
|
using Cryville.Common;
|
||||||
using Cryville.Common.Plist;
|
|
||||||
using Cryville.Crtr.Config;
|
using Cryville.Crtr.Config;
|
||||||
using Cryville.Crtr.Event;
|
using Cryville.Crtr.Event;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -26,8 +25,7 @@ namespace Cryville.Crtr {
|
|||||||
Ruleset ruleset;
|
Ruleset ruleset;
|
||||||
PdtRuleset pruleset;
|
PdtRuleset pruleset;
|
||||||
Dictionary<string, Texture2D> texs;
|
Dictionary<string, Texture2D> texs;
|
||||||
public static Dictionary<string, Cocos2dFrames.Frame> frames;
|
public static Dictionary<string, SpriteFrame> frames;
|
||||||
List<Cocos2dFrames> plists;
|
|
||||||
|
|
||||||
readonly Queue<string> texLoadQueue = new Queue<string>();
|
readonly Queue<string> texLoadQueue = new Queue<string>();
|
||||||
#if UNITY_5_4_OR_NEWER
|
#if UNITY_5_4_OR_NEWER
|
||||||
@@ -252,6 +250,7 @@ namespace Cryville.Crtr {
|
|||||||
status.text = sttext;
|
status.text = sttext;
|
||||||
}
|
}
|
||||||
void OnCameraPostRender(Camera cam) {
|
void OnCameraPostRender(Camera cam) {
|
||||||
|
if (!logEnabled) return;
|
||||||
if (started) timetext = string.Format(
|
if (started) timetext = string.Format(
|
||||||
"\nSTime: {0:R}\nATime: {1:R}\nITime: {2:R}",
|
"\nSTime: {0:R}\nATime: {1:R}\nITime: {2:R}",
|
||||||
cbus.Time,
|
cbus.Time,
|
||||||
@@ -353,6 +352,13 @@ namespace Cryville.Crtr {
|
|||||||
string.Format("{0}/skins/{1}/{2}/.umgs", Game.GameDataPath, rulesetFile.Directory.Name, _rscfg.generic.Skin)
|
string.Format("{0}/skins/{1}/{2}/.umgs", Game.GameDataPath, rulesetFile.Directory.Name, _rscfg.generic.Skin)
|
||||||
);
|
);
|
||||||
if (!skinFile.Exists) throw new FileNotFoundException("Skin not found\nPlease specify an available skin in the config");
|
if (!skinFile.Exists) throw new FileNotFoundException("Skin not found\nPlease specify an available skin in the config");
|
||||||
|
using (StreamReader reader = new StreamReader(skinFile.FullName, Encoding.UTF8)) {
|
||||||
|
skin = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||||
|
MissingMemberHandling = MissingMemberHandling.Error
|
||||||
|
});
|
||||||
|
if (skin.format != Skin.CURRENT_FORMAT) throw new FormatException("Invalid skin file version");
|
||||||
|
}
|
||||||
|
|
||||||
loadThread = new Thread(new ParameterizedThreadStart(Load));
|
loadThread = new Thread(new ParameterizedThreadStart(Load));
|
||||||
loadThread.Start(new LoadInfo() {
|
loadThread.Start(new LoadInfo() {
|
||||||
chartFile = chartFile,
|
chartFile = chartFile,
|
||||||
@@ -363,10 +369,11 @@ namespace Cryville.Crtr {
|
|||||||
Logger.Log("main", 0, "Load/MainThread", "Loading textures...");
|
Logger.Log("main", 0, "Load/MainThread", "Loading textures...");
|
||||||
texloadtimer = new diag::Stopwatch();
|
texloadtimer = new diag::Stopwatch();
|
||||||
texloadtimer.Start();
|
texloadtimer.Start();
|
||||||
|
frames = new Dictionary<string, SpriteFrame>();
|
||||||
texs = new Dictionary<string, Texture2D>();
|
texs = new Dictionary<string, Texture2D>();
|
||||||
var flist = skinFile.Directory.GetFiles("*.png");
|
var skinDir = skinFile.Directory.FullName;
|
||||||
foreach (FileInfo f in flist) {
|
foreach (var f in skin.frames) {
|
||||||
texLoadQueue.Enqueue(f.FullName);
|
texLoadQueue.Enqueue(Path.Combine(skinDir, f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,26 +381,35 @@ namespace Cryville.Crtr {
|
|||||||
try {
|
try {
|
||||||
diag::Stopwatch timer = new diag::Stopwatch();
|
diag::Stopwatch timer = new diag::Stopwatch();
|
||||||
timer.Reset(); timer.Start();
|
timer.Reset(); timer.Start();
|
||||||
Logger.Log("main", 0, "Load/Prehandle", "Prehandling (iteration 3)");
|
Logger.Log("main", 0, "Load/Prehandle", "Initializing textures");
|
||||||
foreach (var i in plists) i.Init(texs);
|
|
||||||
foreach (var t in texs) {
|
foreach (var t in texs) {
|
||||||
if (frames.ContainsKey(t.Key)) {
|
if (frames.ContainsKey(t.Key)) {
|
||||||
Logger.Log("main", 3, "Load/Prehandle", "Duplicated texture name: {0}", t.Key);
|
Logger.Log("main", 3, "Load/Prehandle", "Duplicated texture name: {0}", t.Key);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var f = new Cocos2dFrames.Frame(t.Value);
|
var f = new SpriteFrame(t.Value);
|
||||||
f.Init();
|
f.Init();
|
||||||
frames.Add(t.Key, f);
|
frames.Add(t.Key, f);
|
||||||
}
|
}
|
||||||
Logger.Log("main", 0, "Load/Prehandle", "Initializing states");
|
Logger.Log("main", 0, "Load/Prehandle", "Prehandling (iteration 2)");
|
||||||
cbus.BroadcastInit();
|
cbus.BroadcastPreInit();
|
||||||
|
Logger.Log("main", 0, "Load/Prehandle", "Prehandling (iteration 3)");
|
||||||
|
using (var pbus = cbus.Clone(17)) {
|
||||||
|
pbus.Forward();
|
||||||
|
}
|
||||||
|
Logger.Log("main", 0, "Load/Prehandle", "Prehandling (iteration 4)");
|
||||||
|
cbus.BroadcastPostInit();
|
||||||
inputProxy.Activate();
|
inputProxy.Activate();
|
||||||
if (logEnabled) ToggleLogs();
|
if (logEnabled && Settings.Default.HideLogOnPlay) ToggleLogs();
|
||||||
Logger.Log("main", 0, "Load/Prehandle", "Cleaning up");
|
Logger.Log("main", 0, "Load/Prehandle", "Cleaning up");
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
if (disableGC) GarbageCollector.GCMode = GarbageCollector.Mode.Disabled;
|
if (disableGC) GarbageCollector.GCMode = GarbageCollector.Mode.Disabled;
|
||||||
timer.Stop();
|
timer.Stop();
|
||||||
Logger.Log("main", 1, "Load/Prehandle", "Prehandling done ({0}ms)", timer.Elapsed.TotalMilliseconds);
|
Logger.Log("main", 1, "Load/Prehandle", "Prehandling done ({0}ms)", timer.Elapsed.TotalMilliseconds);
|
||||||
|
if (Settings.Default.ClearLogOnPlay) {
|
||||||
|
logs.text = "";
|
||||||
|
Game.MainLogger.Enumerate((level, module, msg) => { });
|
||||||
|
}
|
||||||
Game.AudioSequencer.Playing = true;
|
Game.AudioSequencer.Playing = true;
|
||||||
atime0 = Game.AudioClient.BufferPosition;
|
atime0 = Game.AudioClient.BufferPosition;
|
||||||
Thread.Sleep((int)((atime0 - Game.AudioClient.Position) * 1000));
|
Thread.Sleep((int)((atime0 - Game.AudioClient.Position) * 1000));
|
||||||
@@ -504,7 +520,6 @@ namespace Cryville.Crtr {
|
|||||||
throw new ArgumentException("Input config not completed\nPlease complete the input settings");
|
throw new ArgumentException("Input config not completed\nPlease complete the input settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
cbus.AttachSystems(pskin, judge);
|
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Attaching handlers");
|
Logger.Log("main", 0, "Load/WorkerThread", "Attaching handlers");
|
||||||
var ch = new ChartHandler(chart, dir);
|
var ch = new ChartHandler(chart, dir);
|
||||||
cbus.RootState.AttachHandler(ch);
|
cbus.RootState.AttachHandler(ch);
|
||||||
@@ -514,7 +529,7 @@ namespace Cryville.Crtr {
|
|||||||
foreach (var ts in gs.Value.Children) {
|
foreach (var ts in gs.Value.Children) {
|
||||||
ContainerHandler th;
|
ContainerHandler th;
|
||||||
if (ts.Key is Chart.Note) {
|
if (ts.Key is Chart.Note) {
|
||||||
th = new NoteHandler(gh, (Chart.Note)ts.Key, pruleset, judge);
|
th = new NoteHandler(gh, (Chart.Note)ts.Key, pruleset);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
th = new TrackHandler(gh, (Chart.Track)ts.Key);
|
th = new TrackHandler(gh, (Chart.Track)ts.Key);
|
||||||
@@ -522,16 +537,13 @@ namespace Cryville.Crtr {
|
|||||||
ts.Value.AttachHandler(th);
|
ts.Value.AttachHandler(th);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cbus.AttachSystems(pskin, judge);
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Prehandling (iteration 1)");
|
Logger.Log("main", 0, "Load/WorkerThread", "Prehandling (iteration 1)");
|
||||||
using (var pbus = cbus.Clone(16)) {
|
using (var pbus = cbus.Clone(16)) {
|
||||||
pbus.Forward();
|
pbus.Forward();
|
||||||
}
|
}
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Patching events");
|
Logger.Log("main", 0, "Load/WorkerThread", "Patching events");
|
||||||
cbus.DoPatch();
|
cbus.DoPatch();
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Prehandling (iteration 2)");
|
|
||||||
using (var pbus = cbus.Clone(17)) {
|
|
||||||
pbus.Forward();
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Cloning states (type 1)");
|
Logger.Log("main", 0, "Load/WorkerThread", "Cloning states (type 1)");
|
||||||
bbus = cbus.Clone(1, -clippingDist);
|
bbus = cbus.Clone(1, -clippingDist);
|
||||||
@@ -549,7 +561,7 @@ namespace Cryville.Crtr {
|
|||||||
ruleset = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
ruleset = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||||
MissingMemberHandling = MissingMemberHandling.Error
|
MissingMemberHandling = MissingMemberHandling.Error
|
||||||
});
|
});
|
||||||
if (ruleset.format != 1) throw new FormatException("Invalid ruleset file version");
|
if (ruleset.format != Ruleset.CURRENT_FORMAT) throw new FormatException("Invalid ruleset file version");
|
||||||
ruleset.LoadPdt(dir);
|
ruleset.LoadPdt(dir);
|
||||||
pruleset = ruleset.Root;
|
pruleset = ruleset.Root;
|
||||||
pruleset.Optimize(etor);
|
pruleset.Optimize(etor);
|
||||||
@@ -559,23 +571,9 @@ namespace Cryville.Crtr {
|
|||||||
void LoadSkin(FileInfo file) {
|
void LoadSkin(FileInfo file) {
|
||||||
DirectoryInfo dir = file.Directory;
|
DirectoryInfo dir = file.Directory;
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Loading skin: {0}", file);
|
Logger.Log("main", 0, "Load/WorkerThread", "Loading skin: {0}", file);
|
||||||
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
skin.LoadPdt(dir);
|
||||||
skin = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
pskin = skin.Root;
|
||||||
MissingMemberHandling = MissingMemberHandling.Error
|
pskin.Optimize(etor);
|
||||||
});
|
|
||||||
if (skin.format != 1) throw new FormatException("Invalid skin file version");
|
|
||||||
skin.LoadPdt(dir);
|
|
||||||
pskin = skin.Root;
|
|
||||||
pskin.Optimize(etor);
|
|
||||||
}
|
|
||||||
plists = new List<Cocos2dFrames>();
|
|
||||||
frames = new Dictionary<string, Cocos2dFrames.Frame>();
|
|
||||||
foreach (FileInfo f in file.Directory.GetFiles("*.plist")) {
|
|
||||||
var pobj = PlistConvert.Deserialize<Cocos2dFrames>(f.FullName);
|
|
||||||
plists.Add(pobj);
|
|
||||||
foreach (var i in pobj.frames)
|
|
||||||
frames.Add(StringUtils.TrimExt(i.Key), i.Value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,176 +0,0 @@
|
|||||||
using Cryville.Common;
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Cryville.Crtr {
|
|
||||||
[BinderAttribute(typeof(Cocos2dFramesBinder))]
|
|
||||||
public class Cocos2dFrames {
|
|
||||||
public Metadata metadata;
|
|
||||||
public class Metadata {
|
|
||||||
public int format;
|
|
||||||
public Vector2 size;
|
|
||||||
public string textureFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, Frame> frames;
|
|
||||||
public class Frame {
|
|
||||||
#pragma warning disable IDE1006
|
|
||||||
Rect _frame;
|
|
||||||
public Rect frame {
|
|
||||||
get { return _frame; }
|
|
||||||
set { _frame = value; }
|
|
||||||
}
|
|
||||||
public Rect textureRect {
|
|
||||||
get { return _frame; }
|
|
||||||
set { _frame = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _rotated = false;
|
|
||||||
public bool rotated {
|
|
||||||
get { return _rotated; }
|
|
||||||
set { _rotated = value; }
|
|
||||||
}
|
|
||||||
public bool textureRotated {
|
|
||||||
get { return _rotated; }
|
|
||||||
set { _rotated = value; }
|
|
||||||
}
|
|
||||||
#pragma warning restore IDE1006
|
|
||||||
|
|
||||||
public Vector2 offset;
|
|
||||||
|
|
||||||
public Rect sourceColorRect;
|
|
||||||
public Vector2 sourceSize;
|
|
||||||
private Rect _uv;
|
|
||||||
private Vector2[] cuv;
|
|
||||||
public Rect UV {
|
|
||||||
get {
|
|
||||||
return _uv;
|
|
||||||
}
|
|
||||||
private set {
|
|
||||||
_uv = value;
|
|
||||||
float x0 = Mathf.Min(_uv.xMin, _uv.xMax);
|
|
||||||
float x1 = Mathf.Max(_uv.xMin, _uv.xMax);
|
|
||||||
float y0 = Mathf.Min(_uv.yMin, _uv.yMax);
|
|
||||||
float y1 = Mathf.Max(_uv.yMin, _uv.yMax);
|
|
||||||
if (_rotated) cuv = new Vector2[]{
|
|
||||||
new Vector2(x0, y1),
|
|
||||||
new Vector2(x1, y0),
|
|
||||||
new Vector2(x0, y0),
|
|
||||||
new Vector2(x1, y1),
|
|
||||||
};
|
|
||||||
else cuv = new Vector2[]{
|
|
||||||
new Vector2(x0, y0),
|
|
||||||
new Vector2(x1, y1),
|
|
||||||
new Vector2(x1, y0),
|
|
||||||
new Vector2(x0, y1),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public Vector2 GetUV(Vector2 uv) {
|
|
||||||
return GetUV(uv.x, uv.y);
|
|
||||||
}
|
|
||||||
public Vector2 GetUV(float u, float v) {
|
|
||||||
Vector2 uv00 = cuv[0], uv11 = cuv[1],
|
|
||||||
uv10 = cuv[2], uv01 = cuv[3];
|
|
||||||
return (1 - u - v) * uv00
|
|
||||||
+ u * uv10
|
|
||||||
+ v * uv01
|
|
||||||
+ u * v * (uv00 + uv11 - uv10 - uv01);
|
|
||||||
}
|
|
||||||
public Texture2D Texture {
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
}
|
|
||||||
public Vector2 Size {
|
|
||||||
get {
|
|
||||||
return new Vector2(Texture.width, Texture.height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Init() {
|
|
||||||
if (Texture == null)
|
|
||||||
throw new InvalidOperationException(); // TODO
|
|
||||||
_frame = new Rect(Vector2.zero, Size);
|
|
||||||
var w = _frame.width;
|
|
||||||
var h = _frame.height;
|
|
||||||
float x = _frame.x / w;
|
|
||||||
float y = 1 - _frame.y / h;
|
|
||||||
float tw = (_rotated ? _frame.height : _frame.width) / w;
|
|
||||||
float th = (_rotated ? _frame.width : _frame.height) / h;
|
|
||||||
if (_rotated) UV = new Rect(x, y, tw, -th);
|
|
||||||
else UV = new Rect(x, y, tw, -th);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Init(int w, int h, Texture2D _base) {
|
|
||||||
if (Texture != null)
|
|
||||||
throw new InvalidOperationException(); // TODO
|
|
||||||
Texture = _base;
|
|
||||||
float x = _frame.x / w;
|
|
||||||
float y = 1 - _frame.y / h;
|
|
||||||
float tw = (_rotated ? _frame.height : _frame.width) / w;
|
|
||||||
float th = (_rotated ? _frame.width : _frame.height) / h;
|
|
||||||
if (_rotated) UV = new Rect(x, y, tw, -th);
|
|
||||||
else UV = new Rect(x, y, tw, -th);
|
|
||||||
}
|
|
||||||
public Frame() { }
|
|
||||||
public Frame(Texture2D tex) {
|
|
||||||
Texture = tex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Texture2D _base;
|
|
||||||
|
|
||||||
public void Init(Dictionary<string, Texture2D> texs) {
|
|
||||||
_base = texs[StringUtils.TrimExt(metadata.textureFileName)];
|
|
||||||
var w = (int)metadata.size.x;
|
|
||||||
var h = (int)metadata.size.y;
|
|
||||||
if (w == 0 || h == 0) {
|
|
||||||
w = _base.width;
|
|
||||||
h = _base.height;
|
|
||||||
}
|
|
||||||
foreach (var f in frames) {
|
|
||||||
f.Value.Init(w, h, _base);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Cocos2dFramesBinder : EmptyBinder {
|
|
||||||
public override object ChangeType(object value, Type type, CultureInfo culture) {
|
|
||||||
if (value is string) {
|
|
||||||
var str = (string)value;
|
|
||||||
if (type == typeof(Rect)) {
|
|
||||||
var m = Regex.Match(str, @"^{({.*?}),({.*?})}$");
|
|
||||||
var p = (Vector2)ChangeType(m.Groups[1].Value, typeof(Vector2), culture);
|
|
||||||
var s = (Vector2)ChangeType(m.Groups[2].Value, typeof(Vector2), culture);
|
|
||||||
return new Rect(p, s);
|
|
||||||
}
|
|
||||||
else if (type == typeof(Vector2)) {
|
|
||||||
var m = Regex.Match(str, @"^{(.*?),(.*?)}$");
|
|
||||||
var w = float.Parse(m.Groups[1].Value);
|
|
||||||
var h = float.Parse(m.Groups[2].Value);
|
|
||||||
return new Vector2(w, h);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (typeof(IDictionary).IsAssignableFrom(value.GetType())) {
|
|
||||||
var dict = (IDictionary)value;
|
|
||||||
if (type == typeof(Rect)) {
|
|
||||||
var x = float.Parse((string)dict["x"]);
|
|
||||||
var y = float.Parse((string)dict["y"]);
|
|
||||||
var w = float.Parse((string)dict["w"]);
|
|
||||||
var h = float.Parse((string)dict["h"]);
|
|
||||||
return new Rect(x, y, w, h);
|
|
||||||
}
|
|
||||||
else if (type == typeof(Vector2)) {
|
|
||||||
var w = float.Parse((string)dict["w"]);
|
|
||||||
var h = float.Parse((string)dict["h"]);
|
|
||||||
return new Vector2(w, h);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return base.ChangeType(value, type, culture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
30
Assets/Cryville/Crtr/Components/MeshBase.cs
Normal file
30
Assets/Cryville/Crtr/Components/MeshBase.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Cryville.Crtr.Components {
|
||||||
|
public abstract class MeshBase : SkinComponent {
|
||||||
|
public MeshBase() {
|
||||||
|
SubmitProperty("zindex", new PropOp.Integer(v => ZIndex = (short)v));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MeshWrapper mesh = new MeshWrapper();
|
||||||
|
|
||||||
|
short _zindex;
|
||||||
|
public short ZIndex {
|
||||||
|
get {
|
||||||
|
return _zindex;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
if (value < 0 || value > 5000)
|
||||||
|
throw new ArgumentOutOfRangeException("value", "Z-index must be in [0..5000]");
|
||||||
|
_zindex = value;
|
||||||
|
UpdateZIndex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected void UpdateZIndex() {
|
||||||
|
if (!mesh.Initialized) return;
|
||||||
|
foreach (var mat in mesh.Renderer.materials) {
|
||||||
|
mat.renderQueue = _zindex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Cryville/Crtr/Components/MeshBase.cs.meta
Normal file
11
Assets/Cryville/Crtr/Components/MeshBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 75daba44e5811b943a08e6f137cc2b0c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -5,11 +5,15 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Cryville.Crtr.Components {
|
namespace Cryville.Crtr.Components {
|
||||||
public abstract class SectionalGameObject : SkinComponent {
|
public abstract class SectionalGameObject : MeshBase {
|
||||||
protected Vector3? prevpt;
|
protected Vector3? prevpt;
|
||||||
protected Quaternion? prevrot;
|
protected Quaternion? prevrot;
|
||||||
protected int vertCount = 0;
|
protected int vertCount = 0;
|
||||||
protected MeshWrapper mesh = new MeshWrapper();
|
bool suppressed;
|
||||||
|
|
||||||
|
public SectionalGameObject() {
|
||||||
|
SubmitProperty("suppressed", new PropOp.Boolean(v => suppressed = v), 2);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnDestroy() {
|
protected override void OnDestroy() {
|
||||||
mesh.Destroy();
|
mesh.Destroy();
|
||||||
@@ -24,7 +28,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void AppendPoint(Vector3 p, Quaternion r) {
|
public void AppendPoint(Vector3 p, Quaternion r) {
|
||||||
if (prevpt == p && prevrot == r) return;
|
if (prevpt == p && prevrot == r || suppressed) return;
|
||||||
AppendPointInternal(p, r);
|
AppendPointInternal(p, r);
|
||||||
// if (!headGenerated) Logger.Log("main", 0, "Skin/Polysec", "{0}", r);
|
// if (!headGenerated) Logger.Log("main", 0, "Skin/Polysec", "{0}", r);
|
||||||
prevpt = p;
|
prevpt = p;
|
||||||
@@ -56,8 +60,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
SubmitProperty("head", new PropOp.String(v => head.FrameName = v));
|
SubmitProperty("head", new PropOp.String(v => head.FrameName = v));
|
||||||
SubmitProperty("body", new PropOp.String(v => body.FrameName = v));
|
SubmitProperty("body", new PropOp.String(v => body.FrameName = v));
|
||||||
SubmitProperty("tail", new PropOp.String(v => tail.FrameName = v));
|
SubmitProperty("tail", new PropOp.String(v => tail.FrameName = v));
|
||||||
SubmitProperty("transparent", new PropOp.Boolean(v => transparent = v));
|
SubmitProperty("shape", new op_set_shape(this), 2);
|
||||||
SubmitProperty("shape", new op_set_shape(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE1006
|
#pragma warning disable IDE1006
|
||||||
@@ -94,31 +97,20 @@ namespace Cryville.Crtr.Components {
|
|||||||
public SpriteInfo body = new SpriteInfo();
|
public SpriteInfo body = new SpriteInfo();
|
||||||
public SpriteInfo tail = new SpriteInfo();
|
public SpriteInfo tail = new SpriteInfo();
|
||||||
|
|
||||||
public bool transparent;
|
|
||||||
List<Vector3> vertices;
|
List<Vector3> vertices;
|
||||||
List<float> lengths;
|
List<float> lengths;
|
||||||
float sumLength = 0;
|
float sumLength = 0;
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
base.Init();
|
base.Init();
|
||||||
|
mesh.Init(transform);
|
||||||
|
|
||||||
head.Load();
|
var mats = mesh.Renderer.materials = new Material[] { mesh.NewMaterial, mesh.NewMaterial, mesh.NewMaterial };
|
||||||
body.Load();
|
head.Bind(mats[0]);
|
||||||
tail.Load();
|
body.Bind(mats[1]);
|
||||||
|
tail.Bind(mats[2]);
|
||||||
|
|
||||||
mesh.Init(transform, transparent);
|
UpdateZIndex();
|
||||||
|
|
||||||
List<Material> materials = new List<Material>();
|
|
||||||
if (head.FrameName != null) AddMat(materials, head.FrameName);
|
|
||||||
if (body.FrameName != null) AddMat(materials, body.FrameName);
|
|
||||||
if (tail.FrameName != null) AddMat(materials, tail.FrameName);
|
|
||||||
mesh.Renderer.materials = materials.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddMat(List<Material> list, string frame) {
|
|
||||||
var mat = mesh.NewMaterial;
|
|
||||||
mat.mainTexture = ChartPlayer.frames[frame].Texture;
|
|
||||||
list.Add(mat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDestroy() {
|
protected override void OnDestroy() {
|
||||||
@@ -132,7 +124,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vector3 prevp = Vector3.zero;
|
|
||||||
protected override void AppendPointInternal(Vector3 p, Quaternion r) {
|
protected override void AppendPointInternal(Vector3 p, Quaternion r) {
|
||||||
if (vertices == null) {
|
if (vertices == null) {
|
||||||
vertices = _ptPool.Rent();
|
vertices = _ptPool.Rent();
|
||||||
@@ -160,9 +151,9 @@ namespace Cryville.Crtr.Components {
|
|||||||
int vcpsec = _shapeLength; // Vertex Count Per Section
|
int vcpsec = _shapeLength; // Vertex Count Per Section
|
||||||
float width = GetWidth();
|
float width = GetWidth();
|
||||||
float headLength = 0;
|
float headLength = 0;
|
||||||
if (head.FrameName != null) headLength = width / head.Ratio;
|
if (head.Frame != null) headLength = width / head.Ratio;
|
||||||
float tailLength = 0;
|
float tailLength = 0;
|
||||||
if (tail.FrameName != null) tailLength = width / tail.Ratio;
|
if (tail.Frame != null) tailLength = width / tail.Ratio;
|
||||||
float endLength = headLength + tailLength;
|
float endLength = headLength + tailLength;
|
||||||
if (sumLength <= endLength) {
|
if (sumLength <= endLength) {
|
||||||
// The total length of the two ends is longer than the whole mesh, squeeze the two ends
|
// The total length of the two ends is longer than the whole mesh, squeeze the two ends
|
||||||
@@ -190,17 +181,17 @@ namespace Cryville.Crtr.Components {
|
|||||||
verts = _vertPool.Rent(vc * vcpsec);
|
verts = _vertPool.Rent(vc * vcpsec);
|
||||||
uvs = _uvPool.Rent(vc * vcpsec);
|
uvs = _uvPool.Rent(vc * vcpsec);
|
||||||
int i = 0; int t = 0; float l = 0; int m = 0;
|
int i = 0; int t = 0; float l = 0; int m = 0;
|
||||||
if (head.FrameName != null) { m++; GenerateMeshTo(verts, uvs, out trih, head, ref i, ref t, ref l, 0, headLength, vcpsec, hvc); }
|
if (head.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trih, head, ref i, ref t, ref l, 0, headLength, vcpsec, hvc); }
|
||||||
if (body.FrameName != null) { m++; GenerateMeshTo(verts, uvs, out trib, body, ref i, ref t, ref l, headLength, sumLength - tailLength, vcpsec, hvc + bvc); }
|
if (body.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trib, body, ref i, ref t, ref l, headLength, sumLength - tailLength, vcpsec, hvc + bvc); }
|
||||||
if (tail.FrameName != null) { m++; GenerateMeshTo(verts, uvs, out trit, tail, ref i, ref t, ref l, sumLength - tailLength, sumLength, vcpsec, vc); }
|
if (tail.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trit, tail, ref i, ref t, ref l, sumLength - tailLength, sumLength, vcpsec, vc); }
|
||||||
|
|
||||||
mesh.Mesh.subMeshCount = m;
|
mesh.Mesh.subMeshCount = m;
|
||||||
m = 0;
|
m = 0;
|
||||||
mesh.Mesh.SetVertices(verts);
|
mesh.Mesh.SetVertices(verts);
|
||||||
mesh.Mesh.SetUVs(0, uvs);
|
mesh.Mesh.SetUVs(0, uvs);
|
||||||
if (head.FrameName != null) mesh.Mesh.SetTriangles(trih, m++);
|
if (head.Frame != null) mesh.Mesh.SetTriangles(trih, m++);
|
||||||
if (body.FrameName != null) mesh.Mesh.SetTriangles(trib, m++);
|
if (body.Frame != null) mesh.Mesh.SetTriangles(trib, m++);
|
||||||
if (tail.FrameName != null) mesh.Mesh.SetTriangles(trit, m++);
|
if (tail.Frame != null) mesh.Mesh.SetTriangles(trit, m++);
|
||||||
mesh.Mesh.RecalculateNormals();
|
mesh.Mesh.RecalculateNormals();
|
||||||
|
|
||||||
_vertPool.Return(verts); verts = null;
|
_vertPool.Return(verts); verts = null;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Cryville.Common.Pdt;
|
using Cryville.Common;
|
||||||
|
using Cryville.Common.Pdt;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -7,25 +8,32 @@ namespace Cryville.Crtr.Components {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The property operators of the component.
|
/// The property operators of the component.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, PdtOperator> PropOps { get; private set; }
|
public Dictionary<int, SkinProperty> Properties { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Submits a property.
|
/// Submits a property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of the property.</param>
|
/// <param name="name">The name of the property.</param>
|
||||||
/// <param name="property">The property operator.</param>
|
/// <param name="property">The property.</param>
|
||||||
protected void SubmitProperty(string name, PdtOperator property) {
|
protected void SubmitProperty(string name, PdtOperator property, int uct = 1) {
|
||||||
PropOps.Add(name, property);
|
Properties.Add(IdentifierManager.SharedInstance.Request(name), new SkinProperty(property, uct));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a skin component
|
/// Creates a skin component.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected SkinComponent() {
|
protected SkinComponent() {
|
||||||
// Properties = new Dictionary<string, Property>();
|
Properties = new Dictionary<int, SkinProperty>();
|
||||||
PropOps = new Dictionary<string, PdtOperator>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Init() { }
|
public virtual void Init() { }
|
||||||
protected abstract void OnDestroy();
|
protected abstract void OnDestroy();
|
||||||
}
|
}
|
||||||
|
public struct SkinProperty {
|
||||||
|
public PdtOperator Operator { get; set; }
|
||||||
|
public int UpdateCloneType { get; set; }
|
||||||
|
public SkinProperty(PdtOperator op, int uct = 1) {
|
||||||
|
Operator = op;
|
||||||
|
UpdateCloneType = uct;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,12 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Cryville.Crtr.Components {
|
namespace Cryville.Crtr.Components {
|
||||||
public abstract class SpriteBase : SkinComponent {
|
public abstract class SpriteBase : MeshBase {
|
||||||
public SpriteBase() {
|
public SpriteBase() {
|
||||||
SubmitProperty("bound", new op_set_bound(this));
|
SubmitProperty("bound", new op_set_bound(this));
|
||||||
SubmitProperty("transparent", new PropOp.Boolean(v => transparent = v));
|
|
||||||
SubmitProperty("pivot", new PropOp.Vector2(v => Pivot = v));
|
SubmitProperty("pivot", new PropOp.Vector2(v => Pivot = v));
|
||||||
SubmitProperty("scale", new PropOp.Vector2(v => Scale = v));
|
SubmitProperty("scale", new PropOp.Vector2(v => Scale = v));
|
||||||
SubmitProperty("ui", new PropOp.Boolean(v => UI = v));
|
SubmitProperty("ui", new PropOp.Boolean(v => UI = v));
|
||||||
SubmitProperty("zindex", new PropOp.Integer(v => ZIndex = (short)v));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable IDE1006
|
#pragma warning disable IDE1006
|
||||||
@@ -27,8 +25,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
}
|
}
|
||||||
#pragma warning restore IDE1006
|
#pragma warning restore IDE1006
|
||||||
|
|
||||||
protected MeshWrapper mesh = new MeshWrapper();
|
|
||||||
|
|
||||||
protected override void OnDestroy() {
|
protected override void OnDestroy() {
|
||||||
mesh.Destroy();
|
mesh.Destroy();
|
||||||
}
|
}
|
||||||
@@ -82,21 +78,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
if (da.x != 0) _scale.x = dp.x / da.x;
|
if (da.x != 0) _scale.x = dp.x / da.x;
|
||||||
if (da.y != 0) _scale.y = dp.z / da.y;
|
if (da.y != 0) _scale.y = dp.z / da.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
short _zindex;
|
|
||||||
public short ZIndex {
|
|
||||||
get {
|
|
||||||
return _zindex;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
_zindex = value;
|
|
||||||
UpdateZIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected void UpdateZIndex() {
|
|
||||||
if (!mesh.Initialized) return;
|
|
||||||
mesh.Renderer.sortingOrder = _zindex;
|
|
||||||
}
|
|
||||||
|
|
||||||
static readonly Quaternion uirot
|
static readonly Quaternion uirot
|
||||||
= Quaternion.Euler(new Vector3(-90, 0, 0));
|
= Quaternion.Euler(new Vector3(-90, 0, 0));
|
||||||
@@ -109,10 +90,8 @@ namespace Cryville.Crtr.Components {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool transparent = false;
|
|
||||||
|
|
||||||
protected void InternalInit(string meshName = "quad") {
|
protected void InternalInit(string meshName = "quad") {
|
||||||
mesh.Init(transform, transparent);
|
mesh.Init(transform);
|
||||||
mesh.Mesh = GenericResources.Meshes[meshName];
|
mesh.Mesh = GenericResources.Meshes[meshName];
|
||||||
UpdateScale();
|
UpdateScale();
|
||||||
UpdateZIndex();
|
UpdateZIndex();
|
||||||
|
|||||||
@@ -4,8 +4,17 @@ using Logger = Cryville.Common.Logger;
|
|||||||
|
|
||||||
namespace Cryville.Crtr.Components {
|
namespace Cryville.Crtr.Components {
|
||||||
public class SpriteInfo {
|
public class SpriteInfo {
|
||||||
public string FrameName;
|
string m_frameName;
|
||||||
public Cocos2dFrames.Frame Frame {
|
public string FrameName {
|
||||||
|
get {
|
||||||
|
return m_frameName;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
m_frameName = value;
|
||||||
|
Reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public SpriteFrame Frame {
|
||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
@@ -20,15 +29,32 @@ namespace Cryville.Crtr.Components {
|
|||||||
return Rect.width / Rect.height;
|
return Rect.width / Rect.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool _loaded;
|
||||||
|
Material _mat;
|
||||||
|
public void Bind(Material mat) {
|
||||||
|
_loaded = true;
|
||||||
|
_mat = mat;
|
||||||
|
Reload();
|
||||||
|
}
|
||||||
public void Load() {
|
public void Load() {
|
||||||
if (FrameName != null) {
|
_loaded = true;
|
||||||
|
Reload();
|
||||||
|
}
|
||||||
|
public void Reload() {
|
||||||
|
if (!_loaded) return;
|
||||||
|
if (!string.IsNullOrEmpty(FrameName)) {
|
||||||
if (ChartPlayer.frames.ContainsKey(FrameName)) {
|
if (ChartPlayer.frames.ContainsKey(FrameName)) {
|
||||||
Frame = ChartPlayer.frames[FrameName];
|
Frame = ChartPlayer.frames[FrameName];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logger.Log("main", 4, "Skin", "Texture {0} not found", FrameName);
|
Logger.Log("main", 4, "Skin", "Texture {0} not found", FrameName);
|
||||||
|
Frame = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else Frame = null;
|
||||||
|
if (_mat != null) {
|
||||||
|
_mat.mainTexture = Frame == null ? null : Frame.Texture;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,16 +94,11 @@ namespace Cryville.Crtr.Components {
|
|||||||
}
|
}
|
||||||
protected void OnFrameUpdate() {
|
protected void OnFrameUpdate() {
|
||||||
if (!mesh.Initialized) return;
|
if (!mesh.Initialized) return;
|
||||||
if (frameInfo.FrameName == null) {
|
if (frameInfo.Frame == null) {
|
||||||
mesh.Renderer.enabled = false;
|
mesh.Renderer.enabled = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mesh.Renderer.enabled = true;
|
mesh.Renderer.enabled = true;
|
||||||
frameInfo.Load();
|
|
||||||
if (frameInfo.Frame != null)
|
|
||||||
mesh.Renderer.material.mainTexture = frameInfo.Frame.Texture;
|
|
||||||
else
|
|
||||||
Logger.Log("main", 4, "Skin", "Unable to load texture {0}", frameInfo.FrameName);
|
|
||||||
UpdateUV();
|
UpdateUV();
|
||||||
UpdateScale();
|
UpdateScale();
|
||||||
UpdateZIndex();
|
UpdateZIndex();
|
||||||
@@ -140,8 +161,8 @@ namespace Cryville.Crtr.Components {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
frameInfo.Load();
|
|
||||||
InternalInit();
|
InternalInit();
|
||||||
|
frameInfo.Bind(mesh.Renderer.material);
|
||||||
OnFrameUpdate();
|
OnFrameUpdate();
|
||||||
UpdateOpacity();
|
UpdateOpacity();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ namespace Cryville.Crtr.Components {
|
|||||||
public class SpriteRect : SpriteBase {
|
public class SpriteRect : SpriteBase {
|
||||||
public SpriteRect() {
|
public SpriteRect() {
|
||||||
SubmitProperty("color", new PropOp.Color(v => Color = v));
|
SubmitProperty("color", new PropOp.Color(v => Color = v));
|
||||||
|
|
||||||
transparent = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _color;
|
Color _color;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Cryville.Common.Pdt;
|
using Cryville.Common.Buffers;
|
||||||
|
using Cryville.Common.Pdt;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -7,7 +8,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
public class SpriteText : SpriteBase {
|
public class SpriteText : SpriteBase {
|
||||||
public SpriteText() {
|
public SpriteText() {
|
||||||
SubmitProperty("frames", new op_set_frames(this));
|
SubmitProperty("frames", new op_set_frames(this));
|
||||||
SubmitProperty("value", new PropOp.String(v => Value = v));
|
SubmitProperty("value", new PropOp.TargetString(() => Value));
|
||||||
SubmitProperty("size", new PropOp.Float(v => Size = v));
|
SubmitProperty("size", new PropOp.Float(v => Size = v));
|
||||||
SubmitProperty("spacing", new PropOp.Float(v => Spacing = v));
|
SubmitProperty("spacing", new PropOp.Float(v => Spacing = v));
|
||||||
SubmitProperty("opacity", new PropOp.Float(v => Opacity = v));
|
SubmitProperty("opacity", new PropOp.Float(v => Opacity = v));
|
||||||
@@ -41,21 +42,14 @@ namespace Cryville.Crtr.Components {
|
|||||||
foreach (var m in meshes) m.Value.Destroy();
|
foreach (var m in meshes) m.Value.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly Dictionary<Texture2D, MeshWrapper> meshes = new Dictionary<Texture2D, MeshWrapper>();
|
|
||||||
Dictionary<char, SpriteInfo> m_frames;
|
Dictionary<char, SpriteInfo> m_frames;
|
||||||
public Dictionary<char, SpriteInfo> Frames {
|
public Dictionary<char, SpriteInfo> Frames {
|
||||||
get { return m_frames; }
|
get { return m_frames; }
|
||||||
set { m_frames = value; UpdateFrames(); UpdateScale(); }
|
set { m_frames = value; UpdateFrames(); UpdateScale(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string m_value;
|
readonly TargetString m_value = new TargetString();
|
||||||
public string Value {
|
public TargetString Value { get { return m_value; } }
|
||||||
get { return m_value; }
|
|
||||||
set {
|
|
||||||
if (m_value == value) return;
|
|
||||||
m_value = value; UpdateScale();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float m_size;
|
public float m_size;
|
||||||
public float Size {
|
public float Size {
|
||||||
@@ -80,31 +74,38 @@ namespace Cryville.Crtr.Components {
|
|||||||
float frameHeight = 0;
|
float frameHeight = 0;
|
||||||
foreach (var m in meshes) m.Value.Destroy();
|
foreach (var m in meshes) m.Value.Destroy();
|
||||||
meshes.Clear();
|
meshes.Clear();
|
||||||
|
verts.Clear();
|
||||||
|
uvs.Clear();
|
||||||
foreach (var f in m_frames) {
|
foreach (var f in m_frames) {
|
||||||
f.Value.Load();
|
f.Value.Load();
|
||||||
if (frameHeight == 0) frameHeight = f.Value.Rect.height;
|
if (frameHeight == 0) frameHeight = f.Value.Rect.height;
|
||||||
else if (frameHeight != f.Value.Rect.height) throw new Exception("Inconsistent frame height");
|
else if (frameHeight != f.Value.Rect.height) throw new Exception("Inconsistent frame height");
|
||||||
if (!meshes.ContainsKey(f.Value.Frame.Texture)) {
|
var tex = f.Value.Frame.Texture;
|
||||||
|
if (!meshes.ContainsKey(tex)) {
|
||||||
var m = new MeshWrapper();
|
var m = new MeshWrapper();
|
||||||
m.Init(mesh.MeshTransform, transparent);
|
m.Init(mesh.MeshTransform);
|
||||||
m.Mesh = new Mesh();
|
m.Mesh = new Mesh();
|
||||||
m.Renderer.material.mainTexture = f.Value.Frame.Texture;
|
m.Renderer.material.mainTexture = tex;
|
||||||
meshes.Add(f.Value.Frame.Texture, m);
|
meshes.Add(tex, m);
|
||||||
|
verts.Add(tex, new List<Vector3>());
|
||||||
|
uvs.Add(tex, new List<Vector2>());
|
||||||
|
tris.Add(tex, new List<int>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float sum_x;
|
float sum_x;
|
||||||
|
readonly Dictionary<Texture2D, MeshWrapper> meshes = new Dictionary<Texture2D, MeshWrapper>();
|
||||||
|
readonly Dictionary<Texture2D, List<Vector3>> verts = new Dictionary<Texture2D, List<Vector3>>();
|
||||||
|
readonly Dictionary<Texture2D, List<Vector2>> uvs = new Dictionary<Texture2D, List<Vector2>>();
|
||||||
|
readonly Dictionary<Texture2D, List<int>> tris = new Dictionary<Texture2D, List<int>>();
|
||||||
void UpdateMeshes() {
|
void UpdateMeshes() {
|
||||||
// TODO optimize GC
|
|
||||||
if (meshes.Count == 0) return;
|
if (meshes.Count == 0) return;
|
||||||
sum_x = 0;
|
sum_x = 0;
|
||||||
int vc = m_value.Length * 4;
|
|
||||||
Dictionary<Texture2D, List<Vector3>> verts = new Dictionary<Texture2D, List<Vector3>>();
|
|
||||||
Dictionary<Texture2D, List<Vector2>> uvs = new Dictionary<Texture2D, List<Vector2>>();
|
|
||||||
foreach (var t in meshes.Keys) {
|
foreach (var t in meshes.Keys) {
|
||||||
verts.Add(t, new List<Vector3>(vc));
|
verts[t].Clear();
|
||||||
uvs.Add(t, new List<Vector2>(vc));
|
uvs[t].Clear();
|
||||||
|
tris[t].Clear();
|
||||||
}
|
}
|
||||||
foreach (var c in m_value) {
|
foreach (var c in m_value) {
|
||||||
var f = m_frames[c];
|
var f = m_frames[c];
|
||||||
@@ -124,18 +125,18 @@ namespace Cryville.Crtr.Components {
|
|||||||
var m = meshes[t].Mesh;
|
var m = meshes[t].Mesh;
|
||||||
m.Clear();
|
m.Clear();
|
||||||
int cc = verts[t].Count / 4;
|
int cc = verts[t].Count / 4;
|
||||||
int[] tris = new int[cc * 6];
|
var _tris = tris[t];
|
||||||
for (int i = 0; i < cc; i++) {
|
for (int i = 0; i < cc; i++) {
|
||||||
tris[i * 6 ] = i * 4 ;
|
_tris.Add(i * 4);
|
||||||
tris[i * 6 + 1] = i * 4 + 3;
|
_tris.Add(i * 4 + 3);
|
||||||
tris[i * 6 + 2] = i * 4 + 1;
|
_tris.Add(i * 4 + 1);
|
||||||
tris[i * 6 + 3] = i * 4 + 1;
|
_tris.Add(i * 4 + 1);
|
||||||
tris[i * 6 + 4] = i * 4 + 3;
|
_tris.Add(i * 4 + 3);
|
||||||
tris[i * 6 + 5] = i * 4 + 2;
|
_tris.Add(i * 4 + 2);
|
||||||
}
|
}
|
||||||
m.vertices = verts[t].ToArray();
|
m.SetVertices(verts[t]);
|
||||||
m.uv = uvs[t].ToArray();
|
m.SetUVs(0, uvs[t]);
|
||||||
m.triangles = tris;
|
m.SetTriangles(tris[t], 0);
|
||||||
m.RecalculateNormals();
|
m.RecalculateNormals();
|
||||||
}
|
}
|
||||||
sum_x -= m_spacing;
|
sum_x -= m_spacing;
|
||||||
@@ -175,6 +176,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
UpdateFrames();
|
UpdateFrames();
|
||||||
mesh.Mesh.Clear();
|
mesh.Mesh.Clear();
|
||||||
UpdateScale();
|
UpdateScale();
|
||||||
|
Value.OnUpdate += UpdateScale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,17 @@ namespace Cryville.Crtr.Config {
|
|||||||
FileInfo file = new FileInfo(
|
FileInfo file = new FileInfo(
|
||||||
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
||||||
);
|
);
|
||||||
|
if (!file.Exists) {
|
||||||
|
Popup.Create("Ruleset for the chart not found\nMake sure you have imported the ruleset");
|
||||||
|
ReturnToMenu();
|
||||||
|
return;
|
||||||
|
}
|
||||||
DirectoryInfo dir = file.Directory;
|
DirectoryInfo dir = file.Directory;
|
||||||
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||||
ruleset = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
ruleset = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||||
MissingMemberHandling = MissingMemberHandling.Error
|
MissingMemberHandling = MissingMemberHandling.Error
|
||||||
});
|
});
|
||||||
if (ruleset.format != 1) throw new FormatException("Invalid ruleset file version");
|
if (ruleset.format != Ruleset.CURRENT_FORMAT) throw new FormatException("Invalid ruleset file version");
|
||||||
ruleset.LoadPdt(dir);
|
ruleset.LoadPdt(dir);
|
||||||
}
|
}
|
||||||
FileInfo cfgfile = new FileInfo(
|
FileInfo cfgfile = new FileInfo(
|
||||||
@@ -62,7 +67,7 @@ namespace Cryville.Crtr.Config {
|
|||||||
cat.SetActive(true);
|
cat.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReturnToMenu() {
|
public void SaveAndReturnToMenu() {
|
||||||
Game.InputManager.Deactivate();
|
Game.InputManager.Deactivate();
|
||||||
m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
|
m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
|
||||||
m_inputConfigPanel.proxy.Dispose();
|
m_inputConfigPanel.proxy.Dispose();
|
||||||
@@ -72,6 +77,9 @@ namespace Cryville.Crtr.Config {
|
|||||||
using (StreamWriter cfgwriter = new StreamWriter(cfgfile.FullName, false, Encoding.UTF8)) {
|
using (StreamWriter cfgwriter = new StreamWriter(cfgfile.FullName, false, Encoding.UTF8)) {
|
||||||
cfgwriter.Write(JsonConvert.SerializeObject(_rscfg, Game.GlobalJsonSerializerSettings));
|
cfgwriter.Write(JsonConvert.SerializeObject(_rscfg, Game.GlobalJsonSerializerSettings));
|
||||||
}
|
}
|
||||||
|
ReturnToMenu();
|
||||||
|
}
|
||||||
|
public void ReturnToMenu() {
|
||||||
GameObject.Find("Master").GetComponent<Master>().ShowMenu();
|
GameObject.Find("Master").GetComponent<Master>().ShowMenu();
|
||||||
#if UNITY_5_5_OR_NEWER
|
#if UNITY_5_5_OR_NEWER
|
||||||
SceneManager.UnloadSceneAsync("Config");
|
SceneManager.UnloadSceneAsync("Config");
|
||||||
|
|||||||
@@ -25,13 +25,14 @@ namespace Cryville.Crtr.Config {
|
|||||||
GameObject m_prefabInputConfigEntry;
|
GameObject m_prefabInputConfigEntry;
|
||||||
|
|
||||||
public InputProxy proxy;
|
public InputProxy proxy;
|
||||||
Dictionary<string, InputConfigPanelEntry> _entries = new Dictionary<string, InputConfigPanelEntry>();
|
readonly Dictionary<string, InputConfigPanelEntry> _entries = new Dictionary<string, InputConfigPanelEntry>();
|
||||||
|
|
||||||
string _sel;
|
string _sel;
|
||||||
public void OpenDialog(string entry) {
|
public void OpenDialog(string entry) {
|
||||||
_sel = entry;
|
_sel = entry;
|
||||||
m_inputDialog.SetActive(true);
|
m_inputDialog.SetActive(true);
|
||||||
CallHelper.Purge(m_deviceList);
|
CallHelper.Purge(m_deviceList);
|
||||||
|
Game.InputManager.EnumerateEvents(ev => { });
|
||||||
_recvsrcs.Clear();
|
_recvsrcs.Clear();
|
||||||
AddSourceItem(null);
|
AddSourceItem(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
using Cryville.Common;
|
||||||
using Cryville.Crtr.Components;
|
using Cryville.Crtr.Components;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Cryville.Crtr.Event {
|
namespace Cryville.Crtr.Event {
|
||||||
@@ -35,9 +37,10 @@ namespace Cryville.Crtr.Event {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Transform gogroup;
|
public Transform gogroup;
|
||||||
|
|
||||||
public readonly Dictionary<string, Anchor> Anchors = new Dictionary<string, Anchor>();
|
public readonly Dictionary<int, Anchor> Anchors = new Dictionary<int, Anchor>();
|
||||||
public Transform a_head;
|
protected Transform a_cur;
|
||||||
public Transform a_tail;
|
protected Transform a_head;
|
||||||
|
protected Transform a_tail;
|
||||||
public Vector3 Position {
|
public Vector3 Position {
|
||||||
get;
|
get;
|
||||||
protected set;
|
protected set;
|
||||||
@@ -62,27 +65,41 @@ namespace Cryville.Crtr.Event {
|
|||||||
public EventContainer Container {
|
public EventContainer Container {
|
||||||
get { return cs.Container; }
|
get { return cs.Container; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkinContainer skinContainer;
|
||||||
|
protected Judge judge;
|
||||||
|
public void AttachSystems(PdtSkin skin, Judge judge) {
|
||||||
|
skinContainer = new SkinContainer(skin);
|
||||||
|
this.judge = judge;
|
||||||
|
}
|
||||||
|
|
||||||
public ContainerHandler() { }
|
public ContainerHandler() { }
|
||||||
public abstract string TypeName {
|
public abstract string TypeName {
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
protected readonly static int _a_cur = IdentifierManager.SharedInstance.Request("cur");
|
||||||
|
protected readonly static int _a_head = IdentifierManager.SharedInstance.Request("head");
|
||||||
|
protected readonly static int _a_tail = IdentifierManager.SharedInstance.Request("tail");
|
||||||
public virtual void PreInit() {
|
public virtual void PreInit() {
|
||||||
gogroup = new GameObject(TypeName + ":" + Container.GetHashCode().ToString()).transform;
|
gogroup = new GameObject(TypeName + ":" + Container.GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
|
||||||
if (cs.Parent != null)
|
if (cs.Parent != null)
|
||||||
gogroup.SetParent(cs.Parent.Handler.gogroup, false);
|
gogroup.SetParent(cs.Parent.Handler.gogroup, false);
|
||||||
a_head = new GameObject("::head").transform;
|
a_cur = RegisterAnchor(_a_cur);
|
||||||
a_head.SetParent(gogroup, false);
|
a_head = RegisterAnchor(_a_head);
|
||||||
Anchors.Add("head", new Anchor() { Transform = a_head });
|
a_tail = RegisterAnchor(_a_tail);
|
||||||
a_tail = new GameObject("::tail").transform;
|
|
||||||
a_tail.SetParent(gogroup, false);
|
|
||||||
Anchors.Add("tail", new Anchor() { Transform = a_tail });
|
|
||||||
}
|
}
|
||||||
|
protected Transform RegisterAnchor(int name) {
|
||||||
|
var go = new GameObject("." + IdentifierManager.SharedInstance.Retrieve(name)).transform;
|
||||||
|
go.SetParent(gogroup, false);
|
||||||
|
Anchors.Add(name, new Anchor() { Transform = go });
|
||||||
|
return go;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called upon initialization of <see cref="cs" />.
|
/// Called upon StartUpdate of ps 17.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Init() {
|
public virtual void Init() {
|
||||||
cs.skinContainer.MatchStatic(cs);
|
skinContainer.MatchStatic(ps);
|
||||||
foreach (var i in gogroup.GetComponentsInChildren<SkinComponent>())
|
foreach (var i in gogroup.GetComponentsInChildren<SkinComponent>())
|
||||||
i.Init();
|
i.Init();
|
||||||
}
|
}
|
||||||
@@ -100,10 +117,10 @@ namespace Cryville.Crtr.Event {
|
|||||||
protected virtual void PreAwake(ContainerState s) {
|
protected virtual void PreAwake(ContainerState s) {
|
||||||
if (gogroup) gogroup.gameObject.SetActive(true);
|
if (gogroup) gogroup.gameObject.SetActive(true);
|
||||||
Awoken = true; Alive = true;
|
Awoken = true; Alive = true;
|
||||||
OpenAnchor("head");
|
OpenAnchor(_a_head);
|
||||||
}
|
}
|
||||||
protected virtual void Awake(ContainerState s) {
|
protected virtual void Awake(ContainerState s) {
|
||||||
CloseAnchor("head");
|
CloseAnchor(_a_head);
|
||||||
}
|
}
|
||||||
protected virtual void GetPosition(ContainerState s) { }
|
protected virtual void GetPosition(ContainerState s) { }
|
||||||
public virtual void StartUpdate(ContainerState s) {
|
public virtual void StartUpdate(ContainerState s) {
|
||||||
@@ -111,11 +128,14 @@ namespace Cryville.Crtr.Event {
|
|||||||
PreAwake(s);
|
PreAwake(s);
|
||||||
Awake(s);
|
Awake(s);
|
||||||
}
|
}
|
||||||
|
else if (s.CloneType == 17) {
|
||||||
|
Init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public virtual void Update(ContainerState s, StampedEvent ev) {
|
public virtual void Update(ContainerState s, StampedEvent ev) {
|
||||||
bool flag = !Awoken && s.CloneType >= 2 && s.CloneType < 16;
|
bool flag = !Awoken && s.CloneType >= 2 && s.CloneType < 16;
|
||||||
if (flag) PreAwake(s);
|
if (flag) PreAwake(s);
|
||||||
if (Awoken && s.CloneType <= 2) if (gogroup) cs.skinContainer.MatchDynamic(s);
|
if (s.CloneType <= 2) if (gogroup) skinContainer.MatchDynamic(s);
|
||||||
if (flag) Awake(s);
|
if (flag) Awake(s);
|
||||||
}
|
}
|
||||||
public virtual void ExUpdate(ContainerState s, StampedEvent ev) { }
|
public virtual void ExUpdate(ContainerState s, StampedEvent ev) { }
|
||||||
@@ -123,14 +143,14 @@ namespace Cryville.Crtr.Event {
|
|||||||
public virtual void EndUpdate(ContainerState s) {
|
public virtual void EndUpdate(ContainerState s) {
|
||||||
if (s.CloneType < 16) {
|
if (s.CloneType < 16) {
|
||||||
Awoken = false;
|
Awoken = false;
|
||||||
if (gogroup && s.CloneType <= 2) cs.skinContainer.MatchDynamic(s);
|
if (gogroup && s.CloneType <= 2) skinContainer.MatchDynamic(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual void Anchor() { }
|
public virtual void Anchor() { }
|
||||||
protected void OpenAnchor(string name) {
|
protected void OpenAnchor(int name) {
|
||||||
if (Anchors.ContainsKey(name)) Anchors[name].Open();
|
if (Anchors.ContainsKey(name)) Anchors[name].Open();
|
||||||
}
|
}
|
||||||
protected void CloseAnchor(string name) {
|
protected void CloseAnchor(int name) {
|
||||||
if (Anchors.ContainsKey(name)) Anchors[name].Close();
|
if (Anchors.ContainsKey(name)) Anchors[name].Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user