Compare commits
40 Commits
Author | SHA1 | Date | |
---|---|---|---|
a4fdb97424 | |||
735a85b914 | |||
be0c71702b | |||
535959a6ed | |||
ae37b27dc0 | |||
80cc5fdbda | |||
87e406e903 | |||
f04d0ec299 | |||
a19057f869 | |||
d0d981b790 | |||
c95ae92ba8 | |||
31e9f1352b | |||
9974b25377 | |||
852c93c6d0 | |||
15e66d29c4 | |||
3d5ea4f056 | |||
1772c90c2f | |||
53ada70dda | |||
a8ab73ac65 | |||
35ac57bfba | |||
945f9ca7d1 | |||
d2b2834a60 | |||
f82e0ce9ef | |||
5444ea7186 | |||
3a54d2023f | |||
cb3e3e5f28 | |||
174f616e5c | |||
0f8bb5f1f6 | |||
2d35e3177b | |||
7b1f639412 | |||
fcc9935325 | |||
8b29cd2893 | |||
f44d9546e1 | |||
1d1d2646c4 | |||
6444de41a2 | |||
ea856f3339 | |||
74b1a5485b | |||
975b48e61e | |||
9e0bf024d7 | |||
d2ff168e25 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -61,6 +61,7 @@ crashlytics-build.properties
|
||||
#
|
||||
/Docs
|
||||
/Issues
|
||||
/Local
|
||||
/Obsolete
|
||||
/Snapshots
|
||||
/UI
|
||||
|
Binary file not shown.
@@ -17,7 +17,7 @@ namespace Cryville.Common {
|
||||
public static void SetLogPath(string path) {
|
||||
logPath = path;
|
||||
var dir = new DirectoryInfo(path);
|
||||
if (!dir.Exists) Directory.CreateDirectory(dir.FullName);
|
||||
if (!dir.Exists) dir.Create();
|
||||
}
|
||||
/// <summary>
|
||||
/// Logs to the specified logger.
|
||||
|
@@ -168,5 +168,19 @@ namespace Cryville.Common {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the namespace qualified name of a type.
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <returns>The namespace qualified name of the class.</returns>
|
||||
public static string GetNamespaceQualifiedName(Type type) {
|
||||
string result = type.Namespace + "." + type.Name;
|
||||
var typeargs = type.GetGenericArguments();
|
||||
if (typeargs.Length > 0) {
|
||||
result = string.Format("{0}[{1}]", result, string.Join(",", from a in typeargs select GetNamespaceQualifiedName(a)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,14 +9,6 @@ namespace Cryville.Common.Unity {
|
||||
return (num2 & num) == num;
|
||||
}
|
||||
|
||||
public static void ShowException(Exception ex) {
|
||||
ShowMessageBox(ex.ToString());
|
||||
}
|
||||
|
||||
public static void ShowMessageBox(string message) {
|
||||
GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/Popup")).GetComponent<Popup>().Message = message;
|
||||
}
|
||||
|
||||
public static void Purge(Transform obj) {
|
||||
foreach (Transform i in obj)
|
||||
GameObject.Destroy(i.gameObject);
|
||||
|
@@ -13,6 +13,7 @@ namespace Cryville.Common.Unity.Input {
|
||||
};
|
||||
// TODO set private
|
||||
public readonly List<InputHandler> _handlers = new List<InputHandler>();
|
||||
readonly Dictionary<Type, InputHandler> _typemap = new Dictionary<Type, InputHandler>();
|
||||
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
|
||||
readonly object _lock = new object();
|
||||
readonly Dictionary<InputIdentifier, InputVector> _vectors = new Dictionary<InputIdentifier, InputVector>();
|
||||
@@ -22,6 +23,7 @@ namespace Cryville.Common.Unity.Input {
|
||||
try {
|
||||
if (!typeof(InputHandler).IsAssignableFrom(t)) continue;
|
||||
var h = (InputHandler)ReflectionHelper.InvokeEmptyConstructor(t);
|
||||
_typemap.Add(t, h);
|
||||
h.OnInput += OnInput;
|
||||
_handlers.Add(h);
|
||||
_timeOrigins.Add(h, 0);
|
||||
@@ -32,6 +34,9 @@ namespace Cryville.Common.Unity.Input {
|
||||
}
|
||||
}
|
||||
}
|
||||
public InputHandler GetHandler(string name) {
|
||||
return _typemap[Type.GetType(name)];
|
||||
}
|
||||
public void Activate() {
|
||||
lock (_lock) {
|
||||
_events.Clear();
|
||||
|
@@ -1,29 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Common.Unity {
|
||||
public class Popup : MonoBehaviour {
|
||||
|
||||
public string Message = "";
|
||||
|
||||
LayoutElement layout;
|
||||
|
||||
float timer = 0;
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
void Start() {
|
||||
layout = GetComponent<LayoutElement>();
|
||||
GetComponentInChildren<Text>().text = Message;
|
||||
transform.SetParent(GameObject.Find("PopupList").transform);
|
||||
layout.minHeight = 0;
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (timer <= 0.8f) layout.minHeight = timer * 50;
|
||||
else if (timer >= 5f) GameObject.Destroy(gameObject);
|
||||
else if (timer >= 4.2f) layout.minHeight = (300 - timer) * 50;
|
||||
timer += Time.deltaTime;
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
}
|
||||
}
|
@@ -133,10 +133,10 @@ namespace Cryville.Common.Unity {
|
||||
prop.SetValue(Target, v, new object[]{ });
|
||||
}
|
||||
catch (TargetInvocationException ex) {
|
||||
CallHelper.ShowMessageBox(ex.InnerException.Message);
|
||||
// CallHelper.ShowMessageBox(ex.InnerException.Message);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
CallHelper.ShowMessageBox(ex.Message);
|
||||
// CallHelper.ShowMessageBox(ex.Message);
|
||||
}
|
||||
}
|
||||
UpdateValue();
|
||||
|
@@ -200,8 +200,7 @@ namespace Cryville.Common.Unity.UI {
|
||||
|
||||
void GenerateLine(int index, int line) {
|
||||
for (int j = 0; j < LineItemCount; j++) {
|
||||
var child = GameObject.Instantiate(m_itemTemplate);
|
||||
child.transform.SetParent(transform, false);
|
||||
var child = GameObject.Instantiate(m_itemTemplate, transform, false);
|
||||
lines[index][j] = child;
|
||||
}
|
||||
LoadLine(index, line);
|
||||
|
@@ -60,10 +60,10 @@ namespace Cryville.Crtr.Browsing {
|
||||
}
|
||||
}
|
||||
public void OnPlay() {
|
||||
Master.Open(_id);
|
||||
Master.Open(_id, _data);
|
||||
}
|
||||
public void OnConfig() {
|
||||
Master.OpenConfig(_id);
|
||||
Master.OpenConfig(_id, _data);
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logger;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
internal class LegacyResourceManager : IResourceManager<ChartDetail> {
|
||||
@@ -58,24 +59,27 @@ namespace Cryville.Crtr.Browsing {
|
||||
|
||||
public ResourceItemMeta GetItemMeta(int id) {
|
||||
var item = items[id];
|
||||
AsyncDelivery<Texture2D> cover = null;
|
||||
var coverFile = item.GetFiles("cover.*");
|
||||
if (coverFile.Length > 0) {
|
||||
cover = new AsyncDelivery<Texture2D>();
|
||||
var task = new LoadTextureTask(Game.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
||||
cover.CancelSource = task.Cancel;
|
||||
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
||||
}
|
||||
var meta = new ChartMeta();
|
||||
string name = item.Name;
|
||||
string desc = "(Unknown)";
|
||||
var metaFile = new FileInfo(item.FullName + "/meta.json");
|
||||
if (metaFile.Exists) {
|
||||
using (var reader = new StreamReader(metaFile.FullName)) {
|
||||
var meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
||||
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
||||
name = meta.song.name;
|
||||
desc = meta.chart.name;
|
||||
}
|
||||
}
|
||||
AsyncDelivery<Texture2D> cover = null;
|
||||
if (meta.cover != null && meta.cover != "") {
|
||||
var coverFile = item.GetFiles(meta.cover);
|
||||
if (coverFile.Length > 0) {
|
||||
cover = new AsyncDelivery<Texture2D>();
|
||||
var task = new LoadTextureTask(Game.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
||||
cover.CancelSource = task.Cancel;
|
||||
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
||||
}
|
||||
}
|
||||
return new ResourceItemMeta {
|
||||
IsDirectory = false,
|
||||
Icon = cover,
|
||||
@@ -86,21 +90,23 @@ namespace Cryville.Crtr.Browsing {
|
||||
|
||||
public ChartDetail GetItemDetail(int id) {
|
||||
var item = items[id];
|
||||
AsyncDelivery<Texture2D> cover = null;
|
||||
var coverFile = item.GetFiles("cover.*");
|
||||
if (coverFile.Length > 0) {
|
||||
cover = new AsyncDelivery<Texture2D>();
|
||||
var task = new LoadTextureTask(Game.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
||||
cover.CancelSource = task.Cancel;
|
||||
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
||||
}
|
||||
ChartMeta meta = new ChartMeta();
|
||||
var meta = new ChartMeta();
|
||||
var metaFile = new FileInfo(item.FullName + "/meta.json");
|
||||
if (metaFile.Exists) {
|
||||
using (var reader = new StreamReader(metaFile.FullName)) {
|
||||
meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
|
||||
}
|
||||
}
|
||||
AsyncDelivery<Texture2D> cover = null;
|
||||
if (meta.cover != null && meta.cover != "") {
|
||||
var coverFile = item.GetFiles(meta.cover);
|
||||
if (coverFile.Length > 0) {
|
||||
cover = new AsyncDelivery<Texture2D>();
|
||||
var task = new LoadTextureTask(Game.FileProtocolPrefix + coverFile[0].FullName, cover.Deliver);
|
||||
cover.CancelSource = task.Cancel;
|
||||
Game.NetworkTaskWorker.SubmitNetworkTask(task);
|
||||
}
|
||||
}
|
||||
return new ChartDetail {
|
||||
Cover = cover,
|
||||
Meta = meta,
|
||||
@@ -115,9 +121,19 @@ namespace Cryville.Crtr.Browsing {
|
||||
var file = new FileInfo(path);
|
||||
if (!converters.ContainsKey(file.Extension)) return false;
|
||||
foreach (var converter in converters[file.Extension]) {
|
||||
var resources = converter.ConvertFrom(file);
|
||||
IEnumerable<Resource> resources = null;
|
||||
try {
|
||||
resources = converter.ConvertFrom(file);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Popup.Create(ex.Message);
|
||||
return false;
|
||||
}
|
||||
foreach (var res in resources) {
|
||||
if (res is ChartResource) {
|
||||
if (!res.Valid) {
|
||||
Logger.Log("main", 3, "Resource", "Attempt to import invalid resource {0}", res);
|
||||
}
|
||||
else if (res is ChartResource) {
|
||||
var tres = (ChartResource)res;
|
||||
var dir = new DirectoryInfo(_rootPath + "/charts/" + res.Name);
|
||||
if (!dir.Exists) dir.Create();
|
||||
@@ -132,8 +148,9 @@ namespace Cryville.Crtr.Browsing {
|
||||
var tres = (CoverResource)res;
|
||||
var dir = new DirectoryInfo(_rootPath + "/charts/" + res.Name);
|
||||
if (!dir.Exists) dir.Create();
|
||||
var dest = new FileInfo(_rootPath + "/charts/" + res.Name + "/cover" + tres.Source.Extension);
|
||||
var dest = new FileInfo(_rootPath + "/charts/" + res.Name + "/" + tres.Source.Name);
|
||||
if (!dest.Exists) tres.Source.CopyTo(dest.FullName);
|
||||
|
||||
}
|
||||
else if (res is SongResource) {
|
||||
var tres = (SongResource)res;
|
||||
|
@@ -24,10 +24,6 @@ namespace Cryville.Crtr.Browsing {
|
||||
const float SPEED = 8;
|
||||
float _ratio;
|
||||
#pragma warning disable IDE0051
|
||||
void Start() {
|
||||
m_handleArea.sizeDelta = new Vector2(m_handle.rect.height - m_handle.rect.width, 0);
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (_value && _ratio != 1) {
|
||||
_ratio += SPEED * Time.deltaTime;
|
||||
@@ -40,6 +36,10 @@ namespace Cryville.Crtr.Browsing {
|
||||
UpdateGraphics();
|
||||
}
|
||||
}
|
||||
|
||||
void OnRectTransformDimensionsChange() {
|
||||
m_handleArea.sizeDelta = new Vector2(m_handle.rect.height - m_handle.rect.width, 0);
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
void UpdateGraphics() {
|
||||
|
@@ -60,7 +60,6 @@ namespace Cryville.Crtr.Browsing {
|
||||
ev.callback.AddListener(e => OnPointerClick((PointerEventData)e));
|
||||
m_ctn.triggers.Add(ev);
|
||||
|
||||
m_handleArea.sizeDelta = new Vector2(m_handle.rect.height - m_handle.rect.width, 0);
|
||||
if (MaxStep != 0) SetRatio(0.5f);
|
||||
}
|
||||
|
||||
@@ -70,6 +69,10 @@ namespace Cryville.Crtr.Browsing {
|
||||
SetValueFromPos(pp);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRectTransformDimensionsChange() {
|
||||
m_handleArea.sizeDelta = new Vector2(m_handle.rect.height - m_handle.rect.width, 0);
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
Vector2 pp;
|
||||
|
28
Assets/Cryville/Crtr/Browsing/PVPString.cs
Normal file
28
Assets/Cryville/Crtr/Browsing/PVPString.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
public class PVPString : PropertyValuePanel {
|
||||
string m_value;
|
||||
public override object Value {
|
||||
get {
|
||||
return m_value;
|
||||
}
|
||||
set {
|
||||
m_value = (string)value;
|
||||
_inputField.text = m_value;
|
||||
}
|
||||
}
|
||||
|
||||
InputField _inputField;
|
||||
|
||||
void Awake() {
|
||||
_inputField = GetComponent<InputField>();
|
||||
_inputField.onValueChanged.AddListener(OnValueChanged);
|
||||
}
|
||||
|
||||
void OnValueChanged(string value) {
|
||||
m_value = value;
|
||||
Callback(Value);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Browsing/PVPString.cs.meta
Normal file
11
Assets/Cryville/Crtr/Browsing/PVPString.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aadf11739189bc94e9cb4f702eb7ccd3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -32,8 +32,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
public void Load(string name, IEnumerable<PropertyInfo> props, object target) {
|
||||
Name = name.ToUpper();
|
||||
foreach (var prop in props) {
|
||||
var obj = GameObject.Instantiate<GameObject>(m_propertyPrefab);
|
||||
obj.transform.SetParent(transform, false);
|
||||
var obj = GameObject.Instantiate<GameObject>(m_propertyPrefab, transform, false);
|
||||
obj.GetComponent<PropertyPanel>().Load(prop, target);
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,8 @@ namespace Cryville.Crtr.Browsing {
|
||||
GameObject m_bool;
|
||||
[SerializeField]
|
||||
GameObject m_number;
|
||||
[SerializeField]
|
||||
GameObject m_string;
|
||||
|
||||
PropertyInfo _property;
|
||||
object _target;
|
||||
@@ -32,8 +34,9 @@ namespace Cryville.Crtr.Browsing {
|
||||
GameObject vp;
|
||||
if (prop.PropertyType == typeof(bool)) vp = m_bool;
|
||||
else if (prop.PropertyType == typeof(float) || prop.PropertyType == typeof(int)) vp = m_number;
|
||||
else if (prop.PropertyType == typeof(string)) vp = m_string;
|
||||
else return;
|
||||
_value = GameObject.Instantiate(vp, _valueContainer).GetComponent<PropertyValuePanel>();
|
||||
_value = GameObject.Instantiate(vp, _valueContainer, false).GetComponent<PropertyValuePanel>();
|
||||
if (_value is PVPNumber) {
|
||||
var t = (PVPNumber)_value;
|
||||
t.IntegerMode = prop.PropertyType == typeof(int);
|
||||
|
@@ -59,11 +59,11 @@ namespace Cryville.Crtr.Browsing {
|
||||
private void OnAddDialogClosed() {
|
||||
if (_dialog.FileName == null) return;
|
||||
if (ResourceManager.ImportItemFrom(_dialog.FileName)) {
|
||||
Debug.Log("Import succeeded"); // TODO
|
||||
Popup.Create("Import succeeded");
|
||||
OnPathClicked(ResourceManager.CurrentDirectory.Length - 1);
|
||||
}
|
||||
else {
|
||||
Debug.Log("Import failed"); // TODO
|
||||
Popup.Create("Import failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -64,8 +64,8 @@ namespace Cryville.Crtr.Browsing {
|
||||
_units[_slideDest + 1].SlideToRight();
|
||||
}
|
||||
|
||||
public void Open(int id) {
|
||||
SetDataSettings(id);
|
||||
public void Open(int id, ChartDetail detail) {
|
||||
SetDataSettings(id, detail);
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene("Play", LoadSceneMode.Additive);
|
||||
#else
|
||||
@@ -74,8 +74,8 @@ namespace Cryville.Crtr.Browsing {
|
||||
GameObject.Find("/Master").GetComponent<Master>().HideMenu();
|
||||
}
|
||||
|
||||
public void OpenConfig(int id) {
|
||||
SetDataSettings(id);
|
||||
public void OpenConfig(int id, ChartDetail detail) {
|
||||
SetDataSettings(id, detail);
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
SceneManager.LoadScene("Config", LoadSceneMode.Additive);
|
||||
#else
|
||||
@@ -84,9 +84,9 @@ namespace Cryville.Crtr.Browsing {
|
||||
GameObject.Find("/Master").GetComponent<Master>().HideMenu();
|
||||
}
|
||||
|
||||
void SetDataSettings(int id) {
|
||||
Settings.Default.LoadRuleset = "key/.umgr";
|
||||
Settings.Default.LoadSkin = "key/0/.umgs";
|
||||
void SetDataSettings(int id, ChartDetail detail) {
|
||||
Settings.Default.LoadRuleset = detail.Meta.ruleset + "/.umgr";
|
||||
Settings.Default.LoadRulesetConfig = detail.Meta.ruleset + ".json";
|
||||
Settings.Default.LoadChart = MainBrowser.ResourceManager.GetItemPath(id);
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
}
|
||||
public string ruleset { get; set; }
|
||||
public int note_count { get; set; }
|
||||
public string cover { get; set; }
|
||||
}
|
||||
#pragma warning restore IDE1006
|
||||
}
|
||||
|
@@ -12,6 +12,10 @@ namespace Cryville.Crtr.Browsing {
|
||||
Name = StringUtils.EscapeFileName(name);
|
||||
}
|
||||
public string Name { get; private set; }
|
||||
public abstract bool Valid { get; }
|
||||
public override string ToString() {
|
||||
return string.Format("{0} ({1})", Name, ReflectionHelper.GetSimpleName(GetType()));
|
||||
}
|
||||
}
|
||||
public class ChartResource : Resource {
|
||||
public ChartResource(string name, Chart main, ChartMeta meta) : base(name) {
|
||||
@@ -19,17 +23,20 @@ namespace Cryville.Crtr.Browsing {
|
||||
}
|
||||
public Chart Main { get; private set; }
|
||||
public ChartMeta Meta { get; private set; }
|
||||
public override bool Valid { get { return true; } }
|
||||
}
|
||||
public class CoverResource : Resource {
|
||||
public CoverResource(string name, FileInfo src) : base(name) {
|
||||
Source = src;
|
||||
}
|
||||
public FileInfo Source { get; private set; }
|
||||
public override bool Valid { get { return Source.Exists; } }
|
||||
}
|
||||
public class SongResource : Resource {
|
||||
public SongResource(string name, FileInfo src) : base(name) {
|
||||
Source = src;
|
||||
}
|
||||
public FileInfo Source { get; private set; }
|
||||
public override bool Valid { get { return Source.Exists; } }
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
//#define NO_THREAD
|
||||
#define BUILD
|
||||
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Plist;
|
||||
using Cryville.Common.Unity.Input;
|
||||
using Cryville.Crtr.Config;
|
||||
using Cryville.Crtr.Event;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
@@ -53,6 +52,7 @@ namespace Cryville.Crtr {
|
||||
public static Rect hitRect;
|
||||
public static Plane[] frustumPlanes;
|
||||
|
||||
RulesetConfig _rscfg;
|
||||
static bool disableGC = true;
|
||||
static float clippingDist = 1f;
|
||||
static float renderDist = 6f;
|
||||
@@ -69,17 +69,6 @@ namespace Cryville.Crtr {
|
||||
|
||||
InputProxy inputProxy;
|
||||
|
||||
~ChartPlayer() {
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
#if !NO_THREAD
|
||||
if (loadThread != null) loadThread.Abort();
|
||||
#endif
|
||||
if (texLoader != null) texLoader.Dispose();
|
||||
}
|
||||
|
||||
#region MonoBehaviour
|
||||
void Start() {
|
||||
var logobj = GameObject.Find("Logs");
|
||||
@@ -96,134 +85,153 @@ namespace Cryville.Crtr {
|
||||
|
||||
texHandler = new DownloadHandlerTexture();
|
||||
#if BUILD
|
||||
Play();
|
||||
try {
|
||||
Play();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Game.LogException("Load/WorkerThread", "An error occured while loading the data", ex);
|
||||
Popup.CreateException(ex);
|
||||
ReturnToMenu();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Camera.main.RenderToCubemap();
|
||||
}
|
||||
|
||||
void OnDestroy() {
|
||||
if (cbus != null) cbus.Dispose();
|
||||
if (bbus != null) bbus.Dispose();
|
||||
if (tbus != null) tbus.Dispose();
|
||||
if (nbus != null) nbus.Dispose();
|
||||
if (loadThread != null) loadThread.Abort();
|
||||
if (texLoader != null) texLoader.Dispose();
|
||||
if (inputProxy != null) inputProxy.Dispose();
|
||||
if (texs != null) foreach (var t in texs) Texture.Destroy(t.Value);
|
||||
Camera.onPostRender -= OnCameraPostRender;
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
bool texloaddone;
|
||||
diag::Stopwatch texloadtimer = new diag::Stopwatch();
|
||||
bool firstFrame;
|
||||
double atime0;
|
||||
void Update() {
|
||||
// if (Input.GetKeyDown(KeyCode.Return)) TogglePlay();
|
||||
if (started) {
|
||||
try {
|
||||
if (Screen.width != screenSize.x || Screen.height != screenSize.y)
|
||||
throw new InvalidOperationException("Window resized while playing");
|
||||
float dt = firstFrame
|
||||
if (started) GameUpdate();
|
||||
else if (loadThread != null) LoadUpdate();
|
||||
if (logEnabled) LogUpdate();
|
||||
else Game.MainLogger.Enumerate((level, module, msg) => { });
|
||||
}
|
||||
void GameUpdate() {
|
||||
try {
|
||||
if (Screen.width != screenSize.x || Screen.height != screenSize.y)
|
||||
throw new InvalidOperationException("Window resized while playing");
|
||||
float dt = firstFrame
|
||||
? 1f / Application.targetFrameRate
|
||||
: Time.deltaTime;
|
||||
firstFrame = false;
|
||||
inputProxy.ForceTick();
|
||||
cbus.ForwardByTime(dt);
|
||||
bbus.ForwardByTime(dt);
|
||||
UnityEngine.Profiling.Profiler.BeginSample("ChartPlayer.Forward");
|
||||
UnityEngine.Profiling.Profiler.BeginSample("EventBus.Copy");
|
||||
bbus.CopyTo(2, tbus);
|
||||
bbus.CopyTo(3, nbus);
|
||||
UnityEngine.Profiling.Profiler.EndSample();
|
||||
float step = autoRenderStep ? ( firstFrame
|
||||
firstFrame = false;
|
||||
inputProxy.ForceTick();
|
||||
cbus.ForwardByTime(dt);
|
||||
bbus.ForwardByTime(dt);
|
||||
UnityEngine.Profiling.Profiler.BeginSample("ChartPlayer.Forward");
|
||||
UnityEngine.Profiling.Profiler.BeginSample("EventBus.Copy");
|
||||
bbus.CopyTo(2, tbus);
|
||||
bbus.CopyTo(3, nbus);
|
||||
UnityEngine.Profiling.Profiler.EndSample();
|
||||
float step = autoRenderStep ? ( firstFrame
|
||||
? 1f / Application.targetFrameRate
|
||||
: Time.smoothDeltaTime
|
||||
) : renderStep;
|
||||
actualRenderStep = step;
|
||||
actualRenderStep = step;
|
||||
|
||||
nbus.ForwardStepByTime(clippingDist, step);
|
||||
nbus.BroadcastEndUpdate();
|
||||
nbus.Anchor();
|
||||
nbus.ForwardStepByTime(clippingDist, step);
|
||||
nbus.BroadcastEndUpdate();
|
||||
nbus.Anchor();
|
||||
|
||||
tbus.ForwardStepByTime(clippingDist, step);
|
||||
tbus.ForwardStepByTime(renderDist, step);
|
||||
tbus.BroadcastEndUpdate();
|
||||
UnityEngine.Profiling.Profiler.EndSample();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Game.LogException("Game", "An error occured while playing", ex);
|
||||
Stop();
|
||||
}
|
||||
tbus.ForwardStepByTime(clippingDist, step);
|
||||
tbus.ForwardStepByTime(renderDist, step);
|
||||
tbus.BroadcastEndUpdate();
|
||||
UnityEngine.Profiling.Profiler.EndSample();
|
||||
}
|
||||
#if !NO_THREAD
|
||||
else if (loadThread != null) {
|
||||
if (texLoader != null) {
|
||||
string url = texLoader.url;
|
||||
string name = StringUtils.TrimExt(url.Substring(url.LastIndexOfAny(new char[] {'/', '\\'}) + 1));
|
||||
catch (Exception ex) {
|
||||
Game.LogException("Game", "An error occured while playing", ex);
|
||||
Popup.CreateException(ex);
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
void LoadUpdate() {
|
||||
if (texLoader != null) {
|
||||
string url = texLoader.url;
|
||||
string name = StringUtils.TrimExt(url.Substring(url.LastIndexOfAny(new char[] {'/', '\\'}) + 1));
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
if (texHandler.isDone) {
|
||||
var tex = texHandler.texture;
|
||||
texs.Add(name, tex);
|
||||
Logger.Log("main", 0, "Load/MainThread", "Loaded texture {0} ({1} bytes)", name, texLoader.downloadedBytes);
|
||||
texLoader.Dispose();
|
||||
texHandler.Dispose();
|
||||
texLoader = null;
|
||||
}
|
||||
else if (texLoader.downloadProgress != 0) {
|
||||
Logger.Log("main", 0, "Load/MainThread", "Loading texture {0} {1:P0}", name, texLoader.downloadProgress);
|
||||
}
|
||||
#else
|
||||
if (texLoader.isDone) {
|
||||
var tex = texLoader.texture;
|
||||
texs.Add(name, tex);
|
||||
Logger.Log("main", 0, "Load/MainThread", "Loaded texture {0} ({1} bytes)", name, texLoader.bytesDownloaded);
|
||||
texLoader.Dispose();
|
||||
texLoader = null;
|
||||
}
|
||||
else if (texLoader.progress != 0) {
|
||||
Logger.Log("main", 0, "Load/MainThread", "Loading texture {0} {1:P0}", name, texLoader.progress);
|
||||
}
|
||||
#endif
|
||||
if (texHandler.isDone) {
|
||||
var tex = texHandler.texture;
|
||||
tex.wrapMode = TextureWrapMode.Clamp;
|
||||
texs.Add(name, tex);
|
||||
texLoader.Dispose();
|
||||
texHandler.Dispose();
|
||||
texLoader = null;
|
||||
}
|
||||
if (texLoader == null)
|
||||
if (texLoadQueue.Count > 0) {
|
||||
#else
|
||||
if (texLoader.isDone) {
|
||||
var tex = texLoader.texture;
|
||||
tex.wrapMode = TextureWrapMode.Clamp;
|
||||
texs.Add(name, tex);
|
||||
texLoader.Dispose();
|
||||
texLoader = null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (texLoader == null)
|
||||
if (texLoadQueue.Count > 0) {
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
texHandler = new DownloadHandlerTexture();
|
||||
texLoader = new UnityWebRequest(Game.FileProtocolPrefix + texLoadQueue.Dequeue(), "GET", texHandler, null);
|
||||
texLoader.SendWebRequest();
|
||||
texHandler = new DownloadHandlerTexture();
|
||||
texLoader = new UnityWebRequest(Game.FileProtocolPrefix + texLoadQueue.Dequeue(), "GET", texHandler, null);
|
||||
texLoader.SendWebRequest();
|
||||
#else
|
||||
texLoader = new WWW(Game.FileProtocolPrefix + texLoadQueue.Dequeue());
|
||||
#endif
|
||||
}
|
||||
else if (!texloaddone) {
|
||||
texloaddone = true;
|
||||
texloadtimer.Stop();
|
||||
Logger.Log("main", 1, "Load/MainThread", "Main thread done ({0}ms)", texloadtimer.Elapsed.TotalMilliseconds);
|
||||
}
|
||||
if (!loadThread.IsAlive) {
|
||||
if (cbus == null) {
|
||||
Logger.Log("main", 4, "Load/MainThread", "Load failed");
|
||||
loadThread = null;
|
||||
}
|
||||
else if (!texloaddone) {
|
||||
texloaddone = true;
|
||||
texloadtimer.Stop();
|
||||
Logger.Log("main", 1, "Load/MainThread", "Main thread done ({0}ms)", texloadtimer.Elapsed.TotalMilliseconds);
|
||||
}
|
||||
if (!loadThread.IsAlive) {
|
||||
if (threadException != null) {
|
||||
Logger.Log("main", 4, "Load/MainThread", "Load failed");
|
||||
loadThread = null;
|
||||
Popup.CreateException(threadException);
|
||||
#if BUILD
|
||||
ReturnToMenu();
|
||||
ReturnToMenu();
|
||||
#endif
|
||||
}
|
||||
else if (texLoader == null) {
|
||||
Prehandle();
|
||||
loadThread = null;
|
||||
}
|
||||
}
|
||||
else if (texLoader == null) {
|
||||
Prehandle();
|
||||
loadThread = null;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (logEnabled) {
|
||||
string _logs = logs.text;
|
||||
Game.MainLogger.Enumerate((level, module, msg) => {
|
||||
string color;
|
||||
switch (level) {
|
||||
case 0: color = "#888888"; break;
|
||||
case 1: color = "#bbbbbb"; break;
|
||||
case 2: color = "#0088ff"; break;
|
||||
case 3: color = "#ffff00"; break;
|
||||
case 4: color = "#ff0000"; break;
|
||||
case 5: color = "#bb0000"; break;
|
||||
default: color = "#ff00ff"; break;
|
||||
}
|
||||
_logs += string.Format(
|
||||
"\r\n<color={1}bb><{2}> {3}</color>",
|
||||
DateTime.UtcNow.ToString("s"), color, module, msg
|
||||
);
|
||||
});
|
||||
logs.text = _logs.Substring(Mathf.Max(0, _logs.IndexOf('\n', Mathf.Max(0, _logs.Length - 4096))));
|
||||
var sttext = string.Format(
|
||||
}
|
||||
string timetext = string.Empty;
|
||||
void LogUpdate() {
|
||||
string _logs = logs.text;
|
||||
Game.MainLogger.Enumerate((level, module, msg) => {
|
||||
string color;
|
||||
switch (level) {
|
||||
case 0: color = "#888888"; break;
|
||||
case 1: color = "#bbbbbb"; break;
|
||||
case 2: color = "#0088ff"; break;
|
||||
case 3: color = "#ffff00"; break;
|
||||
case 4: color = "#ff0000"; break;
|
||||
case 5: color = "#bb0000"; break;
|
||||
default: color = "#ff00ff"; break;
|
||||
}
|
||||
_logs += string.Format(
|
||||
"\r\n<color={1}bb><{2}> {3}</color>",
|
||||
DateTime.UtcNow.ToString("s"), color, module, msg
|
||||
);
|
||||
});
|
||||
logs.text = _logs.Substring(Mathf.Max(0, _logs.IndexOf('\n', Mathf.Max(0, _logs.Length - 4096))));
|
||||
var sttext = string.Format(
|
||||
"FPS: i{0:0} / s{1:0}\nSMem: {2:N0} / {3:N0}\nIMem: {4:N0} / {5:N0}",
|
||||
1 / Time.deltaTime,
|
||||
1 / Time.smoothDeltaTime,
|
||||
@@ -239,18 +247,18 @@ namespace Cryville.Crtr {
|
||||
UnityEngine.Profiling.Profiler.GetTotalReservedMemory()
|
||||
#endif
|
||||
);
|
||||
if (started) sttext += string.Format(
|
||||
"\nSTime: {0:R}\nATime: {1:R}\nITime: {2:R}",
|
||||
cbus.Time,
|
||||
Game.AudioClient.Position - atime0,
|
||||
inputProxy.GetTimestampAverage()
|
||||
);
|
||||
if (judge != null) sttext += "\n== Scores ==\n" + judge.GetFullFormattedScoreString();
|
||||
status.text = sttext;
|
||||
}
|
||||
else {
|
||||
Game.MainLogger.Enumerate((level, module, msg) => { });
|
||||
}
|
||||
sttext += timetext;
|
||||
if (judge != null) sttext += "\n== Scores ==\n" + judge.GetFullFormattedScoreString();
|
||||
status.text = sttext;
|
||||
}
|
||||
void OnCameraPostRender(Camera cam) {
|
||||
if (started) timetext = string.Format(
|
||||
"\nSTime: {0:R}\nATime: {1:R}\nITime: {2:R}",
|
||||
cbus.Time,
|
||||
Game.AudioClient.Position - atime0,
|
||||
inputProxy.GetTimestampAverage()
|
||||
);
|
||||
else timetext = string.Empty;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -301,14 +309,13 @@ namespace Cryville.Crtr {
|
||||
autoRenderStep = renderStep == 0;
|
||||
soundOffset = Settings.Default.SoundOffset;
|
||||
startOffset = Settings.Default.StartOffset;
|
||||
sv = Settings.Default.ScrollVelocity;
|
||||
firstFrame = true;
|
||||
#if !NO_THREAD
|
||||
texloaddone = false;
|
||||
#endif
|
||||
Game.NetworkTaskWorker.SuspendBackgroundTasks();
|
||||
Game.AudioSession = Game.AudioSequencer.NewSession();
|
||||
|
||||
Camera.onPostRender += OnCameraPostRender;
|
||||
|
||||
var hitPlane = new Plane(Vector3.forward, Vector3.zero);
|
||||
var r0 = Camera.main.ViewportPointToRay(new Vector3(0, 0, 1));
|
||||
float dist;
|
||||
@@ -325,29 +332,33 @@ namespace Cryville.Crtr {
|
||||
FileInfo chartFile = new FileInfo(
|
||||
Game.GameDataPath + "/charts/" + Settings.Default.LoadChart
|
||||
);
|
||||
|
||||
FileInfo rulesetFile = new FileInfo(
|
||||
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
||||
);
|
||||
FileInfo skinFile = new FileInfo(
|
||||
Game.GameDataPath + "/skins/" + Settings.Default.LoadSkin
|
||||
if (!rulesetFile.Exists) throw new FileNotFoundException("Ruleset for the chart not found\nMake sure you have imported the ruleset");
|
||||
|
||||
FileInfo rulesetConfigFile = new FileInfo(
|
||||
Game.GameDataPath + "/config/rulesets/" + Settings.Default.LoadRulesetConfig
|
||||
);
|
||||
#if NO_THREAD
|
||||
texloadtimer.Stop();
|
||||
Logger.LogFormat("main", 0, "Load/MainThread", "Textures loaded successfully ({0}ms)", texloadtimer.Elapsed.TotalMilliseconds);
|
||||
Load(new LoadInfo(){
|
||||
chartFile = chartFile,
|
||||
rulesetFile = rulesetFile,
|
||||
skinFile = skinFile,
|
||||
});
|
||||
Prehandle();
|
||||
#else
|
||||
if (!rulesetConfigFile.Exists) throw new FileNotFoundException("Ruleset config not found\nPlease open the config to generate");
|
||||
using (StreamReader cfgreader = new StreamReader(rulesetConfigFile.FullName, Encoding.UTF8)) {
|
||||
_rscfg = JsonConvert.DeserializeObject<RulesetConfig>(cfgreader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
}
|
||||
sv = _rscfg.generic.ScrollVelocity;
|
||||
|
||||
FileInfo skinFile = new FileInfo(
|
||||
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");
|
||||
loadThread = new Thread(new ParameterizedThreadStart(Load));
|
||||
loadThread.Start(new LoadInfo() {
|
||||
chartFile = chartFile,
|
||||
rulesetFile = rulesetFile,
|
||||
skinFile = skinFile,
|
||||
});
|
||||
#endif
|
||||
|
||||
Logger.Log("main", 0, "Load/MainThread", "Loading textures...");
|
||||
texloadtimer = new diag::Stopwatch();
|
||||
@@ -355,15 +366,7 @@ namespace Cryville.Crtr {
|
||||
texs = new Dictionary<string, Texture2D>();
|
||||
var flist = skinFile.Directory.GetFiles("*.png");
|
||||
foreach (FileInfo f in flist) {
|
||||
#if NO_THREAD
|
||||
using (WWW w = new WWW("file:///" + f.FullName)) {
|
||||
string name = StringUtils.TrimExt(f.Name);
|
||||
while (!w.isDone);
|
||||
texs.Add(name, w.texture);
|
||||
}
|
||||
#else
|
||||
texLoadQueue.Enqueue(f.FullName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,23 +387,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
Logger.Log("main", 0, "Load/Prehandle", "Initializing states");
|
||||
cbus.BroadcastInit();
|
||||
|
||||
inputProxy = new InputProxy(pruleset, judge);
|
||||
foreach (var i in Game.InputManager._handlers) {
|
||||
/*if (i is UnityKeyHandler<UnityKeyboardReceiver>) {
|
||||
inputProxy.Set(new InputProxyEntry { Source = new InputSource { Handler = i, Type = (int)KeyCode.Z }, Target = "track0" });
|
||||
inputProxy.Set(new InputProxyEntry { Source = new InputSource { Handler = i, Type = (int)KeyCode.X }, Target = "track1" });
|
||||
inputProxy.Set(new InputProxyEntry { Source = new InputSource { Handler = i, Type = (int)KeyCode.Comma }, Target = "track2" });
|
||||
inputProxy.Set(new InputProxyEntry { Source = new InputSource { Handler = i, Type = (int)KeyCode.Period }, Target = "track3" });
|
||||
break;
|
||||
}*/
|
||||
if (i is UnityMouseHandler) {
|
||||
inputProxy.Set(new InputProxyEntry { Source = new InputSource { Handler = i, Type = 0 }, Target = "screen_x" });
|
||||
break;
|
||||
}
|
||||
}
|
||||
inputProxy.Activate();
|
||||
|
||||
if (logEnabled) ToggleLogs();
|
||||
Logger.Log("main", 0, "Load/Prehandle", "Cleaning up");
|
||||
GC.Collect();
|
||||
@@ -415,6 +402,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Game.LogException("Load/Prehandle", "An error occured while prehandling the data", ex);
|
||||
Popup.CreateException(ex);
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
@@ -422,19 +410,18 @@ namespace Cryville.Crtr {
|
||||
public void Stop() {
|
||||
try {
|
||||
Logger.Log("main", 1, "Game", "Stopping");
|
||||
chart = null;
|
||||
Game.AudioSession = Game.AudioSequencer.NewSession();
|
||||
if (cbus != null) cbus.Dispose();
|
||||
if (bbus != null) bbus.Dispose();
|
||||
if (tbus != null) tbus.Dispose();
|
||||
if (nbus != null) nbus.Dispose();
|
||||
inputProxy.Deactivate();
|
||||
foreach (var t in texs) Texture.Destroy(t.Value);
|
||||
if (cbus != null) { cbus.Dispose(); cbus = null; }
|
||||
if (bbus != null) { bbus.Dispose(); bbus = null; }
|
||||
if (tbus != null) { tbus.Dispose(); tbus = null; }
|
||||
if (nbus != null) { nbus.Dispose(); nbus = null; }
|
||||
Logger.Log("main", 1, "Game", "Stopped");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (!logEnabled) ToggleLogs();
|
||||
Game.LogException("Game", "An error occured while stopping", ex);
|
||||
Popup.CreateException(ex);
|
||||
}
|
||||
finally {
|
||||
if (started) {
|
||||
@@ -462,6 +449,7 @@ namespace Cryville.Crtr {
|
||||
public FileInfo skinFile;
|
||||
}
|
||||
|
||||
Exception threadException;
|
||||
#if !NO_THREAD
|
||||
Thread loadThread = null;
|
||||
diag::Stopwatch workerTimer;
|
||||
@@ -478,6 +466,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Game.LogException("Load/WorkerThread", "An error occured while loading the data", ex);
|
||||
threadException = ex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,6 +498,12 @@ namespace Cryville.Crtr {
|
||||
judge = new Judge(pruleset);
|
||||
etor.ContextJudge = judge;
|
||||
|
||||
inputProxy = new InputProxy(pruleset, judge);
|
||||
inputProxy.LoadFrom(_rscfg.inputs);
|
||||
if (!inputProxy.IsCompleted) {
|
||||
throw new ArgumentException("Input config not completed\nPlease complete the input settings");
|
||||
}
|
||||
|
||||
cbus.AttachSystems(pskin, judge);
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Attaching handlers");
|
||||
var ch = new ChartHandler(chart, dir);
|
||||
@@ -528,11 +523,15 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Prehandling (iteration 1)");
|
||||
cbus.Clone(16).Forward();
|
||||
using (var pbus = cbus.Clone(16)) {
|
||||
pbus.Forward();
|
||||
}
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Patching events");
|
||||
cbus.DoPatch();
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Prehandling (iteration 2)");
|
||||
cbus.Clone(17).Forward();
|
||||
using (var pbus = cbus.Clone(17)) {
|
||||
pbus.Forward();
|
||||
}
|
||||
|
||||
Logger.Log("main", 0, "Load/WorkerThread", "Cloning states (type 1)");
|
||||
bbus = cbus.Clone(1, -clippingDist);
|
||||
|
@@ -1,9 +1,77 @@
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class ConfigScene : MonoBehaviour {
|
||||
[SerializeField]
|
||||
Transform m_content;
|
||||
|
||||
[SerializeField]
|
||||
SettingsPanel m_genericConfigPanel;
|
||||
|
||||
[SerializeField]
|
||||
InputConfigPanel m_inputConfigPanel;
|
||||
|
||||
public Ruleset ruleset;
|
||||
RulesetConfig _rscfg;
|
||||
|
||||
void Awake() {
|
||||
ChartPlayer.etor = new PdtEvaluator();
|
||||
FileInfo file = new FileInfo(
|
||||
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
||||
);
|
||||
DirectoryInfo dir = file.Directory;
|
||||
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||
ruleset = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
if (ruleset.format != 1) throw new FormatException("Invalid ruleset file version");
|
||||
ruleset.LoadPdt(dir);
|
||||
}
|
||||
FileInfo cfgfile = new FileInfo(
|
||||
Game.GameDataPath + "/config/rulesets/" + Settings.Default.LoadRulesetConfig
|
||||
);
|
||||
if (!cfgfile.Exists) {
|
||||
if (!cfgfile.Directory.Exists) cfgfile.Directory.Create();
|
||||
_rscfg = new RulesetConfig();
|
||||
}
|
||||
else {
|
||||
using (StreamReader cfgreader = new StreamReader(cfgfile.FullName, Encoding.UTF8)) {
|
||||
_rscfg = JsonConvert.DeserializeObject<RulesetConfig>(cfgreader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
m_genericConfigPanel.Target = _rscfg.generic;
|
||||
|
||||
var proxy = new InputProxy(ruleset.Root, null);
|
||||
proxy.LoadFrom(_rscfg.inputs);
|
||||
m_inputConfigPanel.proxy = proxy;
|
||||
Game.InputManager.Activate();
|
||||
}
|
||||
|
||||
public void SwitchCategory(GameObject cat) {
|
||||
foreach (Transform c in m_content) {
|
||||
c.gameObject.SetActive(false);
|
||||
}
|
||||
cat.SetActive(true);
|
||||
}
|
||||
|
||||
public void ReturnToMenu() {
|
||||
Game.InputManager.Deactivate();
|
||||
m_inputConfigPanel.proxy.SaveTo(_rscfg.inputs);
|
||||
m_inputConfigPanel.proxy.Dispose();
|
||||
FileInfo cfgfile = new FileInfo(
|
||||
Game.GameDataPath + "/config/rulesets/" + Settings.Default.LoadRulesetConfig
|
||||
);
|
||||
using (StreamWriter cfgwriter = new StreamWriter(cfgfile.FullName, false, Encoding.UTF8)) {
|
||||
cfgwriter.Write(JsonConvert.SerializeObject(_rscfg, Game.GlobalJsonSerializerSettings));
|
||||
}
|
||||
GameObject.Find("Master").GetComponent<Master>().ShowMenu();
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
SceneManager.UnloadSceneAsync("Config");
|
||||
|
@@ -1,15 +1,14 @@
|
||||
using Cryville.Common.Unity;
|
||||
using Cryville.Common.Unity.Input;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class InputConfig : MonoBehaviour {
|
||||
public class InputConfigPanel : MonoBehaviour {
|
||||
[SerializeField]
|
||||
ConfigScene m_configScene;
|
||||
|
||||
[SerializeField]
|
||||
GameObject m_inputDialog;
|
||||
|
||||
@@ -25,14 +24,13 @@ namespace Cryville.Crtr.Config {
|
||||
[SerializeField]
|
||||
GameObject m_prefabInputConfigEntry;
|
||||
|
||||
InputProxy _proxy;
|
||||
Dictionary<string, InputConfigEntry> _entries = new Dictionary<string, InputConfigEntry>();
|
||||
public InputProxy proxy;
|
||||
Dictionary<string, InputConfigPanelEntry> _entries = new Dictionary<string, InputConfigPanelEntry>();
|
||||
|
||||
string _sel;
|
||||
public void OpenDialog(string entry) {
|
||||
_sel = entry;
|
||||
m_inputDialog.SetActive(true);
|
||||
Game.InputManager.Activate();
|
||||
CallHelper.Purge(m_deviceList);
|
||||
_recvsrcs.Clear();
|
||||
AddSourceItem(null);
|
||||
@@ -40,39 +38,24 @@ namespace Cryville.Crtr.Config {
|
||||
|
||||
public void CloseDialog() {
|
||||
m_inputDialog.SetActive(false);
|
||||
Game.InputManager.Deactivate();
|
||||
}
|
||||
|
||||
public void CloseDialog(InputSource? src) {
|
||||
_proxy.Set(new InputProxyEntry {
|
||||
proxy.Set(new InputProxyEntry {
|
||||
Target = _sel,
|
||||
Source = src,
|
||||
});
|
||||
m_inputDialog.SetActive(false);
|
||||
Game.InputManager.Deactivate();
|
||||
}
|
||||
|
||||
void Start() {
|
||||
ChartPlayer.etor = new PdtEvaluator();
|
||||
FileInfo file = new FileInfo(
|
||||
Game.GameDataPath + "/rulesets/" + Settings.Default.LoadRuleset
|
||||
);
|
||||
DirectoryInfo dir = file.Directory;
|
||||
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||
var ruleset = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
if (ruleset.format != 1) throw new FormatException("Invalid ruleset file version");
|
||||
ruleset.LoadPdt(dir);
|
||||
_proxy = new InputProxy(ruleset.Root, null);
|
||||
foreach (var i in ruleset.Root.inputs) {
|
||||
var e = GameObject.Instantiate(m_prefabInputConfigEntry).GetComponent<InputConfigEntry>();
|
||||
e.transform.SetParent(m_entryList.transform);
|
||||
_entries.Add(i.Key, e);
|
||||
e.SetKey(this, i.Key);
|
||||
}
|
||||
_proxy.ProxyChanged += OnProxyChanged;
|
||||
foreach (var i in m_configScene.ruleset.Root.inputs) {
|
||||
var e = GameObject.Instantiate(m_prefabInputConfigEntry, m_entryList.transform).GetComponent<InputConfigPanelEntry>();
|
||||
_entries.Add(i.Key, e);
|
||||
e.SetKey(this, i.Key);
|
||||
OnProxyChanged(this, proxy[i.Key]);
|
||||
}
|
||||
proxy.ProxyChanged += OnProxyChanged;
|
||||
}
|
||||
|
||||
void OnProxyChanged(object sender, ProxyChangedEventArgs e) {
|
||||
@@ -92,11 +75,10 @@ namespace Cryville.Crtr.Config {
|
||||
void AddSourceItem(InputSource? src) {
|
||||
if (_recvsrcs.Contains(src)) return;
|
||||
_recvsrcs.Add(src);
|
||||
var obj = Instantiate(m_prefabListItem);
|
||||
obj.transform.SetParent(m_deviceList);
|
||||
var obj = Instantiate(m_prefabListItem, m_deviceList);
|
||||
obj.transform.Find("Text").GetComponent<Text>().text = src == null ? "None" : src.Value.Handler.GetTypeName(src.Value.Type);
|
||||
var btn = obj.GetComponent<Button>();
|
||||
if (src != null) btn.interactable = !_proxy.IsUsed(src.Value);
|
||||
if (src != null) btn.interactable = !proxy.IsUsed(src.Value);
|
||||
btn.onClick.AddListener(() => {
|
||||
CloseDialog(src);
|
||||
});
|
@@ -2,7 +2,7 @@
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class InputConfigEntry : MonoBehaviour {
|
||||
public class InputConfigPanelEntry : MonoBehaviour {
|
||||
[SerializeField]
|
||||
Text m_key;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Cryville.Crtr.Config {
|
||||
[SerializeField]
|
||||
Button m_button;
|
||||
|
||||
public void SetKey(InputConfig master, string name) {
|
||||
public void SetKey(InputConfigPanel master, string name) {
|
||||
m_key.text = name;
|
||||
m_value.text = "None";
|
||||
m_button.onClick.AddListener(() => {
|
32
Assets/Cryville/Crtr/Config/RulesetConfig.cs
Normal file
32
Assets/Cryville/Crtr/Config/RulesetConfig.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Cryville.Common.ComponentModel;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Cryville.Crtr.Config {
|
||||
public class RulesetConfig {
|
||||
public Generic generic = new Generic();
|
||||
public class Generic {
|
||||
[Category("basic")]
|
||||
[JsonProperty("skin")]
|
||||
public string Skin { get; set; }
|
||||
|
||||
[Category("deprecated")][Obsolete]
|
||||
[JsonProperty("scroll_velocity")][DefaultValue(1)]
|
||||
[LogarithmicScale][Step(0.5f)][Precision(1e-1)]
|
||||
public float ScrollVelocity { get; set; }
|
||||
|
||||
public Generic() {
|
||||
Skin = "";
|
||||
ScrollVelocity = 1;
|
||||
}
|
||||
}
|
||||
public Dictionary<string, InputEntry> inputs
|
||||
= new Dictionary<string, InputEntry>();
|
||||
public class InputEntry {
|
||||
public string handler;
|
||||
public int type;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Config/RulesetConfig.cs.meta
Normal file
11
Assets/Cryville/Crtr/Config/RulesetConfig.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa140184f4b7acb4b994a0826e1f107d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -196,7 +196,7 @@ namespace Cryville.Crtr.Event {
|
||||
public void Dispose() {
|
||||
if (Disposed) return;
|
||||
Disposed = true;
|
||||
if (Handler != null) Handler.Dispose();
|
||||
if (CloneType < 16 && Handler != null) Handler.Dispose();
|
||||
foreach (var s in Children)
|
||||
s.Value.Dispose();
|
||||
RMVPool.ReturnAll();
|
||||
|
@@ -2,6 +2,7 @@ using Cryville.Crtr.Browsing;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -17,23 +18,30 @@ namespace Cryville.Crtr.Extensions.Malody {
|
||||
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||
List<Resource> result = new List<Resource>();
|
||||
MalodyChart src;
|
||||
if (file.Extension != ".mc") throw new NotImplementedException("mcz file is not supported");
|
||||
using (var reader = new StreamReader(file.FullName)) {
|
||||
src = JsonConvert.DeserializeObject<MalodyChart>(reader.ReadToEnd());
|
||||
}
|
||||
if (src.meta.mode != 0) throw new NotImplementedException("The chart mode is not supported");
|
||||
if (src.meta.mode_ext.column != 4) throw new NotImplementedException("The key count is not supported");
|
||||
|
||||
var ruleset = "malody!" + MODES[src.meta.mode];
|
||||
if (src.meta.mode == 0) {
|
||||
ruleset += "." + src.meta.mode_ext.column.ToString(CultureInfo.InvariantCulture) + "k";
|
||||
}
|
||||
|
||||
ChartMeta meta = new ChartMeta() {
|
||||
song = new ChartMeta.MetaInfo() {
|
||||
name = src.meta.song.titleorg != null ? src.meta.song.titleorg : src.meta.song.title,
|
||||
author = src.meta.song.artistorg != null ? src.meta.song.artistorg : src.meta.song.artist,
|
||||
},
|
||||
ruleset = "malody!" + MODES[src.meta.mode],
|
||||
ruleset = ruleset,
|
||||
};
|
||||
|
||||
Chart chart = new Chart {
|
||||
format = 2,
|
||||
time = new BeatTime(-4, 0, 1),
|
||||
ruleset = "malody!" + MODES[src.meta.mode],
|
||||
ruleset = ruleset,
|
||||
sigs = new List<Chart.Signature>(),
|
||||
sounds = new List<Chart.Sound>(),
|
||||
motions = new List<Chart.Motion>(),
|
||||
@@ -68,7 +76,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
||||
float pbeat = 0f, ctime = 0f;
|
||||
int[] endbeat = new int[] { 0, 0, 1 };
|
||||
foreach (var ev in events) {
|
||||
float cbeat = bp(ev.beat);
|
||||
float cbeat = ConvertBeat(ev.beat);
|
||||
ctime += baseBpm == null ? 0 : (cbeat - pbeat) / baseBpm.Value * 60f;
|
||||
pbeat = cbeat;
|
||||
if (ev is MalodyChart.Time) {
|
||||
@@ -105,7 +113,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
||||
else throw new NotImplementedException();
|
||||
}
|
||||
else {
|
||||
if (bp(tev.beat) > bp(endbeat)) endbeat = tev.beat;
|
||||
if (ConvertBeat(tev.beat) > ConvertBeat(endbeat)) endbeat = tev.beat;
|
||||
var rn = new Chart.Note() {
|
||||
time = new BeatTime(tev.beat[0], tev.beat[1], tev.beat[2]),
|
||||
motions = new List<Chart.Motion> {
|
||||
@@ -113,7 +121,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
||||
},
|
||||
};
|
||||
if (tev.endbeat != null) {
|
||||
if (bp(tev.endbeat) > bp(endbeat)) endbeat = tev.endbeat;
|
||||
if (ConvertBeat(tev.endbeat) > ConvertBeat(endbeat)) endbeat = tev.endbeat;
|
||||
rn.endtime = new BeatTime(tev.endbeat[0], tev.endbeat[1], tev.endbeat[2]);
|
||||
longEvents.Add(ev, new StartEventState {
|
||||
Destination = rn,
|
||||
@@ -141,9 +149,11 @@ namespace Cryville.Crtr.Extensions.Malody {
|
||||
};
|
||||
meta.note_count = group.notes.Count;
|
||||
string chartName = string.Format("{0} - {1}", meta.song.name, meta.chart.name);
|
||||
result.Add(new ChartResource(chartName, chart, meta));
|
||||
if (src.meta.background != null)
|
||||
if (src.meta.background != null) {
|
||||
result.Add(new CoverResource(chartName, new FileInfo(file.DirectoryName + "/" + src.meta.background)));
|
||||
meta.cover = src.meta.background;
|
||||
}
|
||||
result.Add(new ChartResource(chartName, chart, meta));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -152,7 +162,7 @@ namespace Cryville.Crtr.Extensions.Malody {
|
||||
public ChartEvent Destination { get; set; }
|
||||
}
|
||||
|
||||
float bp(int[] beat) {
|
||||
float ConvertBeat(int[] beat) {
|
||||
return beat[0] + (float)beat[1] / beat[2];
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +1,13 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Common.Unity.Input;
|
||||
using Cryville.Crtr.Config;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logger;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class InputProxy {
|
||||
public class InputProxy : IDisposable {
|
||||
readonly PdtEvaluator _etor;
|
||||
readonly PdtRuleset _ruleset;
|
||||
readonly Judge _judge;
|
||||
@@ -37,31 +37,61 @@ namespace Cryville.Crtr {
|
||||
readonly Dictionary<string, int> _use = new Dictionary<string, int>();
|
||||
readonly Dictionary<string, List<string>> _rev = new Dictionary<string, List<string>>();
|
||||
public event EventHandler<ProxyChangedEventArgs> ProxyChanged;
|
||||
public void LoadFrom(Dictionary<string, RulesetConfig.InputEntry> config) {
|
||||
foreach (var cfg in config) {
|
||||
Set(new InputProxyEntry {
|
||||
Target = cfg.Key,
|
||||
Source = new InputSource {
|
||||
Handler = Game.InputManager.GetHandler(cfg.Value.handler),
|
||||
Type = cfg.Value.type
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
public void SaveTo(Dictionary<string, RulesetConfig.InputEntry> config) {
|
||||
config.Clear();
|
||||
foreach (var p in _tproxies) {
|
||||
config.Add(p.Key, new RulesetConfig.InputEntry {
|
||||
handler = ReflectionHelper.GetNamespaceQualifiedName(p.Value.Source.Value.Handler.GetType()),
|
||||
type = p.Value.Source.Value.Type
|
||||
});
|
||||
}
|
||||
}
|
||||
public void Set(InputProxyEntry proxy) {
|
||||
var name = proxy.Target;
|
||||
if (_tproxies.ContainsKey(name)) Remove(proxy);
|
||||
if (_use[proxy.Target] > 0)
|
||||
var target = proxy.Target;
|
||||
if (!_ruleset.inputs.ContainsKey(target)) throw new ArgumentException("Invalid input name");
|
||||
if (_tproxies.ContainsKey(target)) Remove(proxy);
|
||||
if (_use[target] > 0)
|
||||
throw new InvalidOperationException("Input already assigned");
|
||||
if (proxy.Source != null) {
|
||||
proxy.Source.Value.Handler.OnInput -= OnInput; // Prevent duplicated hooks, no exception will be thrown
|
||||
proxy.Source.Value.Handler.OnInput += OnInput;
|
||||
_tproxies.Add(proxy.Target, proxy);
|
||||
if (_judge != null) {
|
||||
proxy.Source.Value.Handler.OnInput -= OnInput; // Prevent duplicated hooks, no exception will be thrown
|
||||
proxy.Source.Value.Handler.OnInput += OnInput;
|
||||
}
|
||||
_tproxies.Add(target, proxy);
|
||||
_sproxies.Add(proxy.Source.Value, proxy);
|
||||
IncrementUseRecursive(name);
|
||||
IncrementReversedUseRecursive(name);
|
||||
IncrementUseRecursive(target);
|
||||
IncrementReversedUseRecursive(target);
|
||||
}
|
||||
}
|
||||
void Remove(InputProxyEntry proxy) {
|
||||
var name = proxy.Target;
|
||||
proxy.Source.Value.Handler.OnInput -= OnInput;
|
||||
_sproxies.Remove(_tproxies[name].Source.Value);
|
||||
_tproxies.Remove(name);
|
||||
DecrementUseRecursive(name);
|
||||
DecrementReversedUseRecursive(name);
|
||||
var target = proxy.Target;
|
||||
if (_judge != null) _tproxies[target].Source.Value.Handler.OnInput -= OnInput;
|
||||
_sproxies.Remove(_tproxies[target].Source.Value);
|
||||
_tproxies.Remove(target);
|
||||
DecrementUseRecursive(target);
|
||||
DecrementReversedUseRecursive(target);
|
||||
}
|
||||
public bool IsUsed(InputSource src) {
|
||||
return _sproxies.ContainsKey(src);
|
||||
}
|
||||
public bool IsCompleted {
|
||||
get {
|
||||
foreach (var i in _use)
|
||||
if (i.Value == 0 && !_tproxies.ContainsKey(i.Key)) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
void IncrementUseRecursive(string name) {
|
||||
BroadcastProxyChanged(name);
|
||||
var passes = _ruleset.inputs[name].pass;
|
||||
@@ -98,7 +128,12 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
void BroadcastProxyChanged(string name) {
|
||||
var del = ProxyChanged;
|
||||
if (del != null) del(this, new ProxyChangedEventArgs(name, _tproxies.ContainsKey(name) ? _tproxies[name].Source : null, _use[name] > 0));
|
||||
if (del != null) del(this, this[name]);
|
||||
}
|
||||
public ProxyChangedEventArgs this[string name] {
|
||||
get {
|
||||
return new ProxyChangedEventArgs(name, _tproxies.ContainsKey(name) ? _tproxies[name].Source : null, _use[name] > 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -113,6 +148,22 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public void Deactivate() { foreach (var src in _sproxies.Keys) src.Handler.Deactivate(); }
|
||||
|
||||
~InputProxy() {
|
||||
Dispose(false);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
}
|
||||
protected void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
Deactivate();
|
||||
foreach (var proxy in _tproxies.Values) {
|
||||
proxy.Source.Value.Handler.OnInput -= OnInput;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly object _lock = new object();
|
||||
static readonly int _var_value = IdentifierManager.SharedInstance.Request("value");
|
||||
static readonly PropOp.Arbitrary _arbop = new PropOp.Arbitrary();
|
||||
@@ -131,14 +182,15 @@ namespace Cryville.Crtr {
|
||||
if (!_vect.TryGetValue(id, out ft)) ft = tt;
|
||||
if (vec.IsNull) {
|
||||
_etor.ContextCascadeUpdate(_var_value, new PropSrc.Arbitrary(PdtInternalType.Null, _nullvalue));
|
||||
OnInput(id, proxy.Target, ft, tt, true);
|
||||
}
|
||||
else {
|
||||
fixed (byte* ptr = _vecbuf) {
|
||||
*(Vector3*)ptr = vec.Vector;
|
||||
}
|
||||
_etor.ContextCascadeUpdate(_var_value, new PropSrc.Arbitrary(PdtInternalType.Vector, _vecbuf));
|
||||
OnInput(id, proxy.Target, ft, tt, false);
|
||||
}
|
||||
OnInput(id, proxy.Target, ft, tt);
|
||||
_vect[id] = tt;
|
||||
_etor.ContextCascadeDiscard();
|
||||
}
|
||||
@@ -146,14 +198,14 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
static readonly int _var_fv = IdentifierManager.SharedInstance.Request("fv");
|
||||
static readonly int _var_tv = IdentifierManager.SharedInstance.Request("tv");
|
||||
unsafe void OnInput(InputIdentifier id, Identifier target, float ft, float tt) {
|
||||
unsafe void OnInput(InputIdentifier id, Identifier target, float ft, float tt, bool nullflag) {
|
||||
var def = _ruleset.inputs[target];
|
||||
if (def.pass != null) {
|
||||
foreach (var p in def.pass) {
|
||||
_etor.ContextCascadeInsert();
|
||||
_arbop.Name = _var_value;
|
||||
_etor.Evaluate(_arbop, p.Value);
|
||||
OnInput(id, p.Key, ft, tt);
|
||||
if (!nullflag) _etor.Evaluate(_arbop, p.Value);
|
||||
OnInput(id, p.Key, ft, tt, nullflag);
|
||||
_etor.ContextCascadeDiscard();
|
||||
}
|
||||
}
|
||||
|
@@ -85,6 +85,19 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
return ~num;
|
||||
}
|
||||
int BinarySearchFirst(List<JudgeEvent> list, float time, int stack) {
|
||||
if (list[0].Definition.stack == stack && list[0].StartClip == time) return 0;
|
||||
int num = 0;
|
||||
int num2 = list.Count - 1;
|
||||
while (num <= num2) {
|
||||
int num3 = num + (num2 - num >> 1);
|
||||
int num4 = -list[num3].Definition.stack.CompareTo(stack);
|
||||
if (num4 == 0) num4 = list[num3].StartClip.CompareTo(time);
|
||||
if (num4 >= 0) num2 = num3 - 1;
|
||||
else num = num3 + 1;
|
||||
}
|
||||
return num + 1;
|
||||
}
|
||||
public void Feed(Identifier target, float ft, float tt) {
|
||||
Forward(target, tt);
|
||||
var actlist = activeEvs[target];
|
||||
@@ -103,8 +116,11 @@ namespace Cryville.Crtr {
|
||||
if (def.scores != null) UpdateScore(def.scores);
|
||||
if (def.pass != null) Pass(def.pass);
|
||||
actlist.RemoveAt(index);
|
||||
index = BinarySearch(actlist, ev.StartClip, def.prop);
|
||||
if (index < 0) index = ~index;
|
||||
if (def.prop != 0 && actlist.Count > 0) {
|
||||
index = BinarySearchFirst(actlist, ev.StartClip, def.stack - def.prop);
|
||||
if (index < 0) index = ~index;
|
||||
}
|
||||
else index++;
|
||||
}
|
||||
else index++;
|
||||
}
|
||||
@@ -150,10 +166,12 @@ namespace Cryville.Crtr {
|
||||
var key = scoreop.Key;
|
||||
_etor.ContextSelfValue = scoreSrcs[key.name.Key];
|
||||
_etor.Evaluate(scoreOps[key.name.Key], scoreop.Value);
|
||||
scoreSrcs[key.name.Key].Invalidate();
|
||||
foreach (var s in _rs.scores) {
|
||||
if (s.Value.value != null) {
|
||||
_etor.ContextSelfValue = scoreSrcs[s.Key.Key];
|
||||
_etor.Evaluate(scoreOps[s.Key.Key], s.Value.value);
|
||||
scoreSrcs[s.Key.Key].Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,7 +216,7 @@ namespace Cryville.Crtr {
|
||||
public Identifier[] miss;
|
||||
public Dictionary<ScoreOperation, PdtExpression> scores;
|
||||
public int stack;
|
||||
public int prop = -1;
|
||||
public int prop = 1;
|
||||
}
|
||||
public class ScoreOperation {
|
||||
public Identifier name;
|
||||
|
@@ -6,11 +6,13 @@ namespace Cryville.Crtr {
|
||||
public class Menu : MonoBehaviour {
|
||||
#pragma warning disable IDE0044
|
||||
[SerializeField]
|
||||
private ResourceBrowserMaster m_browserMaster;
|
||||
ResourceBrowserMaster m_browserMaster;
|
||||
[SerializeField]
|
||||
private Animator m_targetAnimator;
|
||||
Animator m_targetAnimator;
|
||||
[SerializeField]
|
||||
private ProgressBar m_progressBar;
|
||||
ProgressBar m_progressBar;
|
||||
[SerializeField]
|
||||
SettingsPanel m_settingsPanel;
|
||||
#pragma warning restore IDE0044
|
||||
|
||||
bool initialized = false;
|
||||
@@ -19,6 +21,7 @@ namespace Cryville.Crtr {
|
||||
void Awake() {
|
||||
Game.Init();
|
||||
transform.parent.Find("Canvas/Contents").gameObject.SetActive(true);
|
||||
m_settingsPanel.Target = Settings.Default;
|
||||
}
|
||||
void Update() {
|
||||
if (!initialized) {
|
||||
|
@@ -146,6 +146,8 @@ namespace Cryville.Crtr {
|
||||
_ctxops.Add(IdentifierManager.SharedInstance.Request("attack_timing"), new func_attack_timing(cccb));
|
||||
_ctxops.Add(IdentifierManager.SharedInstance.Request("enter_timing"), new func_enter_timing(cccb));
|
||||
_ctxops.Add(IdentifierManager.SharedInstance.Request("release_timing"), new func_release_timing(cccb));
|
||||
_ctxops.Add(IdentifierManager.SharedInstance.Request("leave_timing"), new func_leave_timing(cccb));
|
||||
_ctxops.Add(IdentifierManager.SharedInstance.Request("contact_timing"), new func_contact_timing(cccb));
|
||||
}
|
||||
static PdtEvaluator() {
|
||||
_shortops.Add(new PdtOperatorSignature("@", 2), new op_at_2());
|
||||
@@ -507,6 +509,22 @@ namespace Cryville.Crtr {
|
||||
return ft > t0 && ft <= t1;
|
||||
}
|
||||
}
|
||||
class func_leave_timing : JudgeFunction {
|
||||
public func_leave_timing(Func<int, PropSrc> ctxcb) : base(1, ctxcb) { }
|
||||
protected override bool ExecuteImpl(float fn, float tn, float ft, float tt, Vector3? fv, Vector3? tv) {
|
||||
if (fv == null || tv == null) return false;
|
||||
var t1 = GetOperand(0).AsNumber() + tn;
|
||||
return ft < t1 && tt >= t1;
|
||||
}
|
||||
}
|
||||
class func_contact_timing : JudgeFunction {
|
||||
public func_contact_timing(Func<int, PropSrc> ctxcb) : base(2, ctxcb) { }
|
||||
protected override bool ExecuteImpl(float fn, float tn, float ft, float tt, Vector3? fv, Vector3? tv) {
|
||||
var t0 = GetOperand(0).AsNumber() + fn;
|
||||
var t1 = GetOperand(1).AsNumber() + tn;
|
||||
return (fv == null || ft < t1) && (tv == null || tt >= t0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
unsafe static class oputil {
|
||||
public static float AsNumber(PropSrc src) {
|
||||
|
37
Assets/Cryville/Crtr/Popup.cs
Normal file
37
Assets/Cryville/Crtr/Popup.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class Popup : MonoBehaviour {
|
||||
public string Message = "";
|
||||
CanvasGroup group;
|
||||
float timer = 0;
|
||||
|
||||
const float DURATION = 5.0f;
|
||||
const float DURIN = 0.4f;
|
||||
const float DUROUT = 0.4f;
|
||||
|
||||
void Start() {
|
||||
group = GetComponent<CanvasGroup>();
|
||||
group.alpha = 0;
|
||||
GetComponentInChildren<Text>().text = Message;
|
||||
transform.SetParent(GameObject.Find("PopupList").transform);
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (timer <= DURIN) group.alpha = timer / DURIN;
|
||||
else if (timer >= DURATION) GameObject.Destroy(gameObject);
|
||||
else if (timer >= DURATION - DUROUT) group.alpha = (DURATION - timer) / DUROUT;
|
||||
timer += Time.deltaTime;
|
||||
}
|
||||
|
||||
public static void CreateException(Exception ex) {
|
||||
Create(ex.Message);
|
||||
}
|
||||
|
||||
public static void Create(string msg) {
|
||||
Instantiate(Resources.Load<GameObject>("Common/Popup")).GetComponent<Popup>().Message = msg;
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,6 +6,7 @@ namespace Cryville.Crtr {
|
||||
public abstract class PropSrc {
|
||||
int _type;
|
||||
byte[] _buf = null;
|
||||
public void Invalidate() { _buf = null; }
|
||||
public void Get(out int type, out byte[] value) {
|
||||
if (_buf == null) InternalGet(out _type, out _buf);
|
||||
type = _type;
|
||||
|
@@ -84,6 +84,18 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[Category("data")]
|
||||
[Description("The ruleset config file to load.")]
|
||||
public string LoadRulesetConfig {
|
||||
get {
|
||||
return PlayerPrefs.GetString("LoadRulesetConfig", "");
|
||||
}
|
||||
set {
|
||||
PlayerPrefs.SetString("LoadRulesetConfig", value);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[Category("data")]
|
||||
[Description("The skin file to load.")]
|
||||
@@ -100,7 +112,7 @@ namespace Cryville.Crtr {
|
||||
[LogarithmicScale][Step(0.5f)][Precision(1e-1)]
|
||||
public float RenderDistance {
|
||||
get {
|
||||
return PlayerPrefs.GetFloat("RenderDistance", 6);
|
||||
return PlayerPrefs.GetFloat("RenderDistance", 4);
|
||||
}
|
||||
set {
|
||||
PlayerPrefs.SetFloat("RenderDistance", value);
|
||||
@@ -119,17 +131,6 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
[Category("gameplay")]
|
||||
[LogarithmicScale][Step(0.5f)][Precision(1e-1)]
|
||||
public float ScrollVelocity {
|
||||
get {
|
||||
return PlayerPrefs.GetFloat("ScrollVelocity", 1);
|
||||
}
|
||||
set {
|
||||
PlayerPrefs.SetFloat("ScrollVelocity", value);
|
||||
}
|
||||
}
|
||||
|
||||
[Category("gameplay")]
|
||||
[Step(0.04f)][Precision(1e-3)]
|
||||
public float SoundOffset {
|
||||
|
@@ -7,30 +7,41 @@ using UnityEngine;
|
||||
namespace Cryville.Crtr {
|
||||
public class SettingsPanel : MonoBehaviour {
|
||||
[SerializeField]
|
||||
private GameObject m_categoryPrefab;
|
||||
GameObject m_categoryPrefab;
|
||||
|
||||
private Transform _container;
|
||||
[SerializeField]
|
||||
Transform m_container;
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
void Awake() {
|
||||
_container = transform.Find("Content/__content__");
|
||||
}
|
||||
public void Start() {
|
||||
LoadProperties();
|
||||
foreach (Transform c in _container) GameObject.Destroy(c.gameObject);
|
||||
foreach (var c in _categories) {
|
||||
var obj = GameObject.Instantiate<GameObject>(m_categoryPrefab);
|
||||
obj.transform.SetParent(_container, false);
|
||||
obj.GetComponent<PropertyCategoryPanel>().Load(c.Key, c.Value, Settings.Default);
|
||||
bool _invalidated = true;
|
||||
object m_target;
|
||||
public object Target {
|
||||
get {
|
||||
return m_target;
|
||||
}
|
||||
set {
|
||||
if (m_target != value) {
|
||||
m_target = value;
|
||||
_invalidated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
Dictionary<string, List<PropertyInfo>> _categories = null;
|
||||
public void Update() {
|
||||
if (!_invalidated) return;
|
||||
LoadProperties();
|
||||
foreach (Transform c in m_container) GameObject.Destroy(c.gameObject);
|
||||
foreach (var c in _categories) {
|
||||
var obj = GameObject.Instantiate<GameObject>(m_categoryPrefab, m_container, false);
|
||||
obj.GetComponent<PropertyCategoryPanel>().Load(c.Key, c.Value, Target);
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<string, List<PropertyInfo>> _categories = new Dictionary<string, List<PropertyInfo>>();
|
||||
public void LoadProperties() {
|
||||
if (_categories != null) return;
|
||||
_categories = new Dictionary<string, List<PropertyInfo>>();
|
||||
foreach (var p in typeof(Settings).GetProperties()) {
|
||||
_categories.Clear();
|
||||
_invalidated = false;
|
||||
if (Target == null) return;
|
||||
foreach (var p in Target.GetType().GetProperties()) {
|
||||
bool browsable = true;
|
||||
string category = "miscellaneous";
|
||||
foreach (var attr in p.GetCustomAttributes(true)) {
|
||||
|
Binary file not shown.
24
Assets/MsvcStdextWorkaround.cs
Normal file
24
Assets/MsvcStdextWorkaround.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
|
||||
public class MsvcStdextWorkaround : IPreprocessBuildWithReport {
|
||||
const string kWorkaroundFlag = "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS";
|
||||
|
||||
public int callbackOrder => 0;
|
||||
|
||||
public void OnPreprocessBuild(BuildReport report) {
|
||||
var clEnv = Environment.GetEnvironmentVariable("_CL_");
|
||||
|
||||
if (string.IsNullOrEmpty(clEnv)) {
|
||||
Environment.SetEnvironmentVariable("_CL_", kWorkaroundFlag);
|
||||
}
|
||||
else if (!clEnv.Contains(kWorkaroundFlag)) {
|
||||
clEnv += " " + kWorkaroundFlag;
|
||||
Environment.SetEnvironmentVariable("_CL_", clEnv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // UNITY_EDITOR
|
11
Assets/MsvcStdextWorkaround.cs.meta
Normal file
11
Assets/MsvcStdextWorkaround.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ed0687e714ce1042921c0057f42039f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
BIN
Assets/Prefabs/PVString.prefab
Normal file
BIN
Assets/Prefabs/PVString.prefab
Normal file
Binary file not shown.
7
Assets/Prefabs/PVString.prefab.meta
Normal file
7
Assets/Prefabs/PVString.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3142009b74dda042a75e9b808dde66d
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
Assets/Resources/default.txt
Symbolic link
1
Assets/Resources/default.txt
Symbolic link
@@ -0,0 +1 @@
|
||||
../../Local/default_resources.zip
|
Reference in New Issue
Block a user