Code structure cleanup.

This commit is contained in:
2023-08-24 15:47:34 +08:00
parent e40c98ae1b
commit 1f58390298
137 changed files with 439 additions and 362 deletions

View File

@@ -1,4 +1,5 @@
using Cryville.Common.Collections.Specialized;
using Cryville.Crtr.Skin;
using UnityEngine;
namespace Cryville.Crtr {

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: cfa7de3f6f944914d9999fcfda245f97
timeCreated: 1637552994
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: b38d66b3e6e5d94438c72f855c4efff9
timeCreated: 1637554149
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
using Cryville.Common;
using Cryville.Crtr.Extension;
using UnityEngine;
namespace Cryville.Crtr.Browsing {
public struct ChartDetail {
public AsyncDelivery<Texture2D> Cover { get; set; }
public ChartMeta Meta { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5f9870328bccefa4d8d4f6d5e3cef591
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 477e04b1ed5b60e48886fb76081245c5
timeCreated: 1637722157
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -3,6 +3,7 @@ using Cryville.Common.Unity;
using Cryville.Crtr.Extension;
using Cryville.Crtr.Extensions;
using Cryville.Crtr.Extensions.Umg;
using Cryville.Crtr.UI;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 5d443a346e9a19d4eabbb0fa9ec7016f
timeCreated: 1637566071
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: c6b4df13dea0e4a469d7e54e7e8fb428
timeCreated: 1637234060
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 256d7d3efda1f9b4c882eb42e608cc8e
timeCreated: 1638414803
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: a69c80e5f3e7bd04485bc3afc5826584
timeCreated: 1638415083
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -2,15 +2,6 @@ using Cryville.Common;
using UnityEngine;
namespace Cryville.Crtr.Browsing {
internal abstract class BrowserItem : MonoBehaviour {
public int? Id { get; private set; }
protected ResourceItemMeta meta;
internal virtual void Load(int id, ResourceItemMeta item) {
Id = id;
meta = item;
}
}
public struct ResourceItemMeta {
public bool IsDirectory { get; set; }
public AsyncDelivery<Texture2D> Icon { get; set; }

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f535064222dd08c4f8e52d6e9144079a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,10 +1,10 @@
using Cryville.Crtr.Components;
using Cryville.Crtr.Skin.Components;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Cryville.Crtr {
public static class GenericResources {
public static class BuiltinResources {
public static Dictionary<string, Type> Components
= new Dictionary<string, Type>();
public static Dictionary<string, Shader> Shaders

View File

@@ -1,6 +1,7 @@
using Cryville.Common;
using Cryville.Common.Collections.Specialized;
using Cryville.Common.Pdt;
using Cryville.Crtr.Ruleset;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;

View File

@@ -2,6 +2,9 @@ using Cryville.Common;
using Cryville.Common.Buffers;
using Cryville.Crtr.Config;
using Cryville.Crtr.Event;
using Cryville.Crtr.Ruleset;
using Cryville.Crtr.Skin;
using Cryville.Crtr.UI;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -22,9 +25,9 @@ namespace Cryville.Crtr {
public class ChartPlayer : MonoBehaviour {
#region Fields
Chart chart;
Skin skin;
SkinDefinition skin;
public static PdtSkin pskin;
Ruleset ruleset;
RulesetDefinition ruleset;
PdtRuleset pruleset;
Dictionary<string, Texture2D> texs;
public static Dictionary<string, SpriteFrame> frames;
@@ -71,7 +74,7 @@ namespace Cryville.Crtr {
logs = logobj.GetComponent<TextMeshProUGUI>();
if (!initialized) {
Game.Init();
GenericResources.LoadDefault();
BuiltinResources.LoadDefault();
initialized = true;
}
OnSettingsUpdate();
@@ -417,10 +420,10 @@ namespace Cryville.Crtr {
);
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() {
skin = JsonConvert.DeserializeObject<SkinDefinition>(reader.ReadToEnd(), new JsonSerializerSettings() {
MissingMemberHandling = MissingMemberHandling.Error
});
if (skin.format != Skin.CURRENT_FORMAT) throw new FormatException("Invalid skin file version");
if (skin.format != SkinDefinition.CURRENT_FORMAT) throw new FormatException("Invalid skin file version");
}
loadThread = new Thread(new ParameterizedThreadStart(Load));
@@ -682,10 +685,10 @@ namespace Cryville.Crtr {
DirectoryInfo dir = file.Directory;
Logger.Log("main", 0, "Load/WorkerThread", "Loading ruleset: {0}", file);
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
ruleset = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd(), new JsonSerializerSettings() {
ruleset = JsonConvert.DeserializeObject<RulesetDefinition>(reader.ReadToEnd(), new JsonSerializerSettings() {
MissingMemberHandling = MissingMemberHandling.Error
});
if (ruleset.format != Ruleset.CURRENT_FORMAT) throw new FormatException("Invalid ruleset file version");
if (ruleset.format != RulesetDefinition.CURRENT_FORMAT) throw new FormatException("Invalid ruleset file version");
ruleset.LoadPdt(dir);
pruleset = ruleset.Root;
pruleset.Optimize(PdtEvaluator.Instance);

View File

@@ -1,3 +1,5 @@
using Cryville.Crtr.Ruleset;
using Cryville.Crtr.UI;
using Newtonsoft.Json;
using System;
using System.IO;
@@ -22,7 +24,7 @@ namespace Cryville.Crtr.Config {
[SerializeField]
InputConfigPanel m_inputConfigPanel;
public Ruleset ruleset;
public RulesetDefinition ruleset;
RulesetConfig _rscfg;
bool _loaded;
@@ -38,10 +40,10 @@ namespace Cryville.Crtr.Config {
}
DirectoryInfo dir = file.Directory;
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
ruleset = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd(), new JsonSerializerSettings() {
ruleset = JsonConvert.DeserializeObject<RulesetDefinition>(reader.ReadToEnd(), new JsonSerializerSettings() {
MissingMemberHandling = MissingMemberHandling.Error
});
if (ruleset.format != Ruleset.CURRENT_FORMAT) throw new FormatException("Invalid ruleset file version");
if (ruleset.format != RulesetDefinition.CURRENT_FORMAT) throw new FormatException("Invalid ruleset file version");
ruleset.LoadPdt(dir);
}
FileInfo cfgfile = new FileInfo(

View File

@@ -1,5 +1,6 @@
using Cryville.Common;
using Cryville.Common.Unity;
using Cryville.Crtr.Ruleset;
using Cryville.Input;
using System;
using System.Collections.Generic;

View File

@@ -1,4 +1,5 @@
using Cryville.Common;
using Cryville.Crtr.Ruleset;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

View File

@@ -1,5 +1,6 @@
using Cryville.Common;
using Cryville.Common.Pdt;
using Cryville.Crtr.Ruleset;
using System;
using System.Collections.Generic;

View File

@@ -1,5 +1,6 @@
using Cryville.Common;
using Cryville.Common.Collections.Specialized;
using Cryville.Crtr.Ruleset;
using System;
using System.Collections.Generic;

View File

@@ -1,9 +1,8 @@
using Cryville.Audio.Source;
using Cryville.Crtr.Event;
using System.Collections.Generic;
using System.IO;
namespace Cryville.Crtr {
namespace Cryville.Crtr.Event {
public class ChartHandler : TransformHandler {
protected override TransformHandler Parent { get { return null; } }

View File

@@ -1,8 +1,7 @@
fileFormatVersion: 2
guid: d8339b62359a4eb428e5d7939a0e8fe4
timeCreated: 1593870951
licenseType: Pro
guid: 59e25dacd9b4d1f45b1da3a381187560
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

View File

@@ -1,7 +1,9 @@
using Cryville.Common;
using Cryville.Common.Buffers;
using Cryville.Common.Collections.Specialized;
using Cryville.Crtr.Components;
using Cryville.Crtr.Ruleset;
using Cryville.Crtr.Skin;
using Cryville.Crtr.Skin.Components;
using System;
using System.Collections.Generic;
using System.Globalization;

View File

@@ -2,6 +2,8 @@ using Cryville.Common;
using Cryville.Common.Buffers;
using Cryville.Common.Collections.Specialized;
using Cryville.Common.Pdt;
using Cryville.Crtr.Ruleset;
using Cryville.Crtr.Skin;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

View File

@@ -1,3 +1,5 @@
using Cryville.Crtr.Ruleset;
using Cryville.Crtr.Skin;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

View File

@@ -1,9 +1,8 @@
using Cryville.Common.Math;
using Cryville.Crtr.Event;
using System;
using UnityEngine;
namespace Cryville.Crtr {
namespace Cryville.Crtr.Event {
public class GroupHandler : TransformHandler {
protected override TransformHandler Parent { get { return _ch; } }
public ChartHandler _ch;

View File

@@ -1,8 +1,7 @@
fileFormatVersion: 2
guid: 1d6ad7170a6c76248a8ec305e98a75b2
timeCreated: 1599459182
licenseType: Pro
guid: a254d6c958ea6c5409991bde44e67635
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

View File

@@ -1,16 +1,16 @@
using Cryville.Common;
using Cryville.Crtr.Components;
using Cryville.Crtr.Event;
using Cryville.Crtr.Ruleset;
using Cryville.Crtr.Skin.Components;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Cryville.Crtr {
namespace Cryville.Crtr.Event {
public class NoteHandler : ContainerHandler {
readonly GroupHandler gh;
public readonly Chart.Note Event;
readonly Chart.Note _note;
public NoteHandler(Chart.Note ev, GroupHandler gh) : base() {
Event = ev;
_note = ev;
this.gh = gh;
}
@@ -43,7 +43,7 @@ namespace Cryville.Crtr {
public override void PreInit() {
base.PreInit();
foreach (var j in Event.judges) {
foreach (var j in _note.judges) {
judges.Add(j, new JudgeState(this, j.Id.Key));
}
}
@@ -63,7 +63,7 @@ namespace Cryville.Crtr {
base.StartGraphicalUpdate(s);
TransformAwake(s);
if (RootTransform) {
if (Event.IsLong) {
if (_note.IsLong) {
foreach (var i in sgos) {
i.Reset();
i.AppendPoint(Position, Rotation);
@@ -88,7 +88,7 @@ namespace Cryville.Crtr {
if (s.CloneType <= 2) {
Position = GetFramePoint(s.Parent, s.Track);
Rotation = GetFrameRotation(s.Parent, s.Track);
if (s.CloneType == 2 && RootTransform && Event.IsLong) {
if (s.CloneType == 2 && RootTransform && _note.IsLong) {
foreach (var i in sgos)
i.AppendPoint(Position, Rotation);
}
@@ -131,7 +131,7 @@ namespace Cryville.Crtr {
}
Quaternion GetFrameRotation(ContainerState state, float track) {
var r = GetFrame(state, track, th => Quaternion.Euler(th.Direction) * Vector3.forward);
var r = GetFrame(state, track, th => th.Handler.Rotation * Vector3.forward);
return Quaternion.LookRotation(r, state.Normal);
}

Some files were not shown because too many files have changed in this diff Show More