Code cleanup.
This commit is contained in:
@@ -24,8 +24,8 @@ namespace Cryville.Crtr {
|
|||||||
Skin skin;
|
Skin skin;
|
||||||
PdtSkin pskin;
|
PdtSkin pskin;
|
||||||
Ruleset ruleset;
|
Ruleset ruleset;
|
||||||
public static PdtRuleset pruleset;
|
PdtRuleset pruleset;
|
||||||
public static Dictionary<string, Texture2D> texs;
|
Dictionary<string, Texture2D> texs;
|
||||||
public static Dictionary<string, Cocos2dFrames.Frame> frames;
|
public static Dictionary<string, Cocos2dFrames.Frame> frames;
|
||||||
List<Cocos2dFrames> plists;
|
List<Cocos2dFrames> plists;
|
||||||
|
|
||||||
@@ -48,19 +48,18 @@ namespace Cryville.Crtr {
|
|||||||
static Text logs;
|
static Text logs;
|
||||||
Text status;
|
Text status;
|
||||||
|
|
||||||
|
static Vector2 screenSize;
|
||||||
public static Rect hitRect;
|
public static Rect hitRect;
|
||||||
public static Vector2 screenSize;
|
|
||||||
public static Plane[] frustumPlanes;
|
public static Plane[] frustumPlanes;
|
||||||
|
|
||||||
public static bool disableGC = true;
|
static bool disableGC = true;
|
||||||
public static float clippingDist = 1f;
|
static float clippingDist = 1f;
|
||||||
public static float judgeTolerance = 0.1f;
|
static float renderDist = 6f;
|
||||||
public static float renderDist = 6f;
|
static float renderStep = 0.05f;
|
||||||
public static float renderStep = 0.05f;
|
|
||||||
public static float actualRenderStep = 0f;
|
public static float actualRenderStep = 0f;
|
||||||
public static bool autoRenderStep = false;
|
static bool autoRenderStep = false;
|
||||||
public static float soundOffset = 0;
|
public static float soundOffset = 0;
|
||||||
public static float startOffset = 0;
|
static float startOffset = 0;
|
||||||
public static float sv = 16f;
|
public static float sv = 16f;
|
||||||
|
|
||||||
public static Dictionary<string, MotionRegistry> motionRegistry = new Dictionary<string, MotionRegistry>();
|
public static Dictionary<string, MotionRegistry> motionRegistry = new Dictionary<string, MotionRegistry>();
|
||||||
@@ -78,6 +77,7 @@ namespace Cryville.Crtr {
|
|||||||
if (texLoader != null) texLoader.Dispose();
|
if (texLoader != null) texLoader.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region MonoBehaviour
|
||||||
void Start() {
|
void Start() {
|
||||||
var logobj = GameObject.Find("Logs");
|
var logobj = GameObject.Find("Logs");
|
||||||
if (logobj != null)
|
if (logobj != null)
|
||||||
@@ -102,8 +102,11 @@ namespace Cryville.Crtr {
|
|||||||
// Camera.main.RenderToCubemap();
|
// Camera.main.RenderToCubemap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool texloaddone;
|
||||||
|
diag::Stopwatch texloadtimer = new diag::Stopwatch();
|
||||||
|
bool firstFrame;
|
||||||
void Update() {
|
void Update() {
|
||||||
if (Input.GetKeyDown(KeyCode.Return)) TogglePlay();
|
// if (Input.GetKeyDown(KeyCode.Return)) TogglePlay();
|
||||||
if (started) {
|
if (started) {
|
||||||
try {
|
try {
|
||||||
if (Screen.width != screenSize.x || Screen.height != screenSize.y)
|
if (Screen.width != screenSize.x || Screen.height != screenSize.y)
|
||||||
@@ -249,7 +252,9 @@ namespace Cryville.Crtr {
|
|||||||
Game.MainLogger.Enumerate((level, module, msg) => { });
|
Game.MainLogger.Enumerate((level, module, msg) => { });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Triggers
|
||||||
private void ReturnToMenu() {
|
private void ReturnToMenu() {
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
Invoke(nameof(_returnToMenu), 4);
|
Invoke(nameof(_returnToMenu), 4);
|
||||||
@@ -284,7 +289,9 @@ namespace Cryville.Crtr {
|
|||||||
else Logger.Log("main", 2, "Load/MainThread", "The chart is currently loading");
|
else Logger.Log("main", 2, "Load/MainThread", "The chart is currently loading");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Load
|
||||||
void Play() {
|
void Play() {
|
||||||
disableGC = Settings.Default.DisableGC;
|
disableGC = Settings.Default.DisableGC;
|
||||||
clippingDist = Settings.Default.BackwardClippingDistance;
|
clippingDist = Settings.Default.BackwardClippingDistance;
|
||||||
@@ -395,18 +402,52 @@ 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();
|
||||||
|
// Game.InputManager.Deactivate();
|
||||||
|
foreach (var t in texs) Texture.Destroy(t.Value);
|
||||||
|
Logger.Log("main", 1, "Game", "Stopped");
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
if (!logEnabled) ToggleLogs();
|
||||||
|
Game.LogException("Game", "An error occured while stopping", ex);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (started) {
|
||||||
|
if (disableGC) GarbageCollector.GCMode = GarbageCollector.Mode.Enabled;
|
||||||
|
GC.Collect();
|
||||||
|
started = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Game.NetworkTaskWorker.ResumeBackgroundTasks();
|
||||||
|
#if BUILD
|
||||||
|
ReturnToMenu();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnSettingsUpdate() {
|
||||||
|
Application.targetFrameRate = Settings.Default.TargetFrameRate;
|
||||||
|
QualitySettings.vSyncCount = Settings.Default.VSync ? 1 : 0;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Threaded
|
||||||
struct LoadInfo {
|
struct LoadInfo {
|
||||||
public FileInfo chartFile;
|
public FileInfo chartFile;
|
||||||
public FileInfo rulesetFile;
|
public FileInfo rulesetFile;
|
||||||
public FileInfo skinFile;
|
public FileInfo skinFile;
|
||||||
}
|
}
|
||||||
diag::Stopwatch texloadtimer = new diag::Stopwatch();
|
|
||||||
bool firstFrame;
|
|
||||||
|
|
||||||
#if !NO_THREAD
|
#if !NO_THREAD
|
||||||
Thread loadThread = null;
|
Thread loadThread = null;
|
||||||
diag::Stopwatch workerTimer;
|
diag::Stopwatch workerTimer;
|
||||||
bool texloaddone;
|
|
||||||
#endif
|
#endif
|
||||||
void Load(object _info) {
|
void Load(object _info) {
|
||||||
var info = (LoadInfo)_info;
|
var info = (LoadInfo)_info;
|
||||||
@@ -446,7 +487,7 @@ namespace Cryville.Crtr {
|
|||||||
cbus = batcher.Batch();
|
cbus = batcher.Batch();
|
||||||
Logger.Log("main", 0, "Load/WorkerThread", "Batched {0} event batches", cbus.events.Count);
|
Logger.Log("main", 0, "Load/WorkerThread", "Batched {0} event batches", cbus.events.Count);
|
||||||
|
|
||||||
judge = new Judge();
|
judge = new Judge(pruleset);
|
||||||
etor.ContextJudge = judge;
|
etor.ContextJudge = judge;
|
||||||
|
|
||||||
LoadSkin(info.skinFile);
|
LoadSkin(info.skinFile);
|
||||||
@@ -520,40 +561,6 @@ namespace Cryville.Crtr {
|
|||||||
frames.Add(StringUtils.TrimExt(i.Key), i.Value);
|
frames.Add(StringUtils.TrimExt(i.Key), i.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
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();
|
|
||||||
Game.InputManager.Deactivate();
|
|
||||||
foreach (var t in texs) Texture.Destroy(t.Value);
|
|
||||||
Logger.Log("main", 1, "Game", "Stopped");
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
if (!logEnabled) ToggleLogs();
|
|
||||||
Game.LogException("Game", "An error occured while stopping", ex);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
if (started) {
|
|
||||||
if (disableGC) GarbageCollector.GCMode = GarbageCollector.Mode.Enabled;
|
|
||||||
GC.Collect();
|
|
||||||
started = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Game.NetworkTaskWorker.ResumeBackgroundTasks();
|
|
||||||
#if BUILD
|
|
||||||
ReturnToMenu();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnSettingsUpdate() {
|
|
||||||
Application.targetFrameRate = Settings.Default.TargetFrameRate;
|
|
||||||
QualitySettings.vSyncCount = Settings.Default.VSync ? 1 : 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,9 +4,9 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace Cryville.Crtr {
|
namespace Cryville.Crtr {
|
||||||
public class Judge {
|
public class Judge {
|
||||||
readonly PdtRuleset rs;
|
readonly PdtRuleset _rs;
|
||||||
public Judge() {
|
public Judge(PdtRuleset rs) {
|
||||||
rs = ChartPlayer.pruleset;
|
_rs = rs;
|
||||||
foreach (var s in rs.scores)
|
foreach (var s in rs.scores)
|
||||||
scores.Add(s.Key, s.Value.init);
|
scores.Add(s.Key, s.Value.init);
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ namespace Cryville.Crtr {
|
|||||||
public Dictionary<string, string> GetFormattedScoreStrings() {
|
public Dictionary<string, string> GetFormattedScoreStrings() {
|
||||||
if (ScoreCache.Count == 0) {
|
if (ScoreCache.Count == 0) {
|
||||||
foreach (var s in scores)
|
foreach (var s in scores)
|
||||||
ScoreCache.Add(s.Key, s.Value.ToString(rs.scores[s.Key].format));
|
ScoreCache.Add(s.Key, s.Value.ToString(_rs.scores[s.Key].format));
|
||||||
}
|
}
|
||||||
return ScoreCache;
|
return ScoreCache;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user