2 Commits

Author SHA1 Message Date
c2e94afc1c Update Cryville.Common.Logging. 2023-11-20 20:21:21 +08:00
e2c58c708f Remove console. 2023-11-20 20:15:52 +08:00
27 changed files with 271 additions and 1381 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 8a36c371ab6077d43ac28fe09b0fe675
timeCreated: 1620725915
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,4 +1,3 @@
using Cryville.Common.Logging;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -15,7 +14,7 @@ namespace Cryville.Common.Font {
map1.Add(f.FullName, f); map1.Add(f.FullName, f);
} }
else { else {
Logger.Log("main", 3, "UI", "Discarding a font with a duplicate full name {0}", f.FullName); Shared.Logger.Log(3, "UI", "Discarding a font with a duplicate full name {0}", f.FullName);
continue; continue;
} }
List<Typeface> set2; List<Typeface> set2;

View File

@@ -1,4 +1,3 @@
using Cryville.Common.Logging;
using Cryville.Culture; using Cryville.Culture;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -311,7 +310,7 @@ namespace Cryville.Common.Font {
bool flag = false; bool flag = false;
while (_matcher.Match(lang, supported, out var match, out var distance)) { while (_matcher.Match(lang, supported, out var match, out var distance)) {
if (distance > 40) break; if (distance > 40) break;
Logger.Log("main", 0, "UI", "Matching fonts for language {0}, distance = {1}", match, distance); Shared.Logger.Log(0, "UI", "Matching fonts for language {0}, distance = {1}", match, distance);
if (match.Script.Equals(UltimateFallbackScript, StringComparison.OrdinalIgnoreCase)) { if (match.Script.Equals(UltimateFallbackScript, StringComparison.OrdinalIgnoreCase)) {
flag = true; flag = true;
} }
@@ -322,7 +321,7 @@ namespace Cryville.Common.Font {
supported.Remove(match); supported.Remove(match);
} }
if (flag) yield break; if (flag) yield break;
Logger.Log("main", 0, "UI", "Matching fallback fonts"); Shared.Logger.Log(0, "UI", "Matching fallback fonts");
foreach (var typeface in EnumerateTypefaces(MapScriptToTypefaces[UltimateFallbackScript], distinctFamily)) { foreach (var typeface in EnumerateTypefaces(MapScriptToTypefaces[UltimateFallbackScript], distinctFamily)) {
yield return typeface; yield return typeface;
} }

View File

@@ -1,4 +1,3 @@
using Cryville.Common.Logging;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -35,7 +34,7 @@ namespace Cryville.Common.Network.Http11 {
origPort = _baseUri.Port; origPort = _baseUri.Port;
Headers = new Dictionary<string, string>(); Headers = new Dictionary<string, string>();
_proxied = GetProxy(ref _directHost, ref _directPort); _proxied = GetProxy(ref _directHost, ref _directPort);
Logger.Log("main", 0, "Network", "Connecting to {0}:{1}", DirectHost, DirectPort); Shared.Logger.Log(0, "Network", "Connecting to {0}:{1}", DirectHost, DirectPort);
TcpClient = new TcpClient(DirectHost, DirectPort); TcpClient = new TcpClient(DirectHost, DirectPort);
} }
@@ -96,7 +95,7 @@ namespace Cryville.Common.Network.Http11 {
writer.Flush(); writer.Flush();
} }
var response = new Http11Response(stream); var response = new Http11Response(stream);
Logger.Log("main", 0, "Network", "{0}", response); Shared.Logger.Log(0, "Network", "{0}", response);
return response; return response;
} }

View File

@@ -1,5 +1,4 @@
using Cryville.Common.Collections; using Cryville.Common.Collections;
using Cryville.Common.Logging;
using Cryville.Common.Reflection; using Cryville.Common.Reflection;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -203,7 +202,7 @@ namespace Cryville.Common.Pdt {
switch (GetIdentifier()) { switch (GetIdentifier()) {
case "ver": case "ver":
ws(); ws();
Logger.Log("main", 3, "PDT", "Legacy PDT directive #ver={0} found. Ignoring.", GetNumber()); Shared.Logger.Log(3, "PDT", "Legacy PDT directive #ver={0} found. Ignoring.", GetNumber());
break; break;
case "format": case "format":
ws(); ws();

View File

@@ -0,0 +1,7 @@
using Cryville.Common.Logging;
namespace Cryville.Common {
public static class Shared {
public static readonly Logger Logger = new Logger();
}
}

View File

@@ -1,8 +1,7 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 069c1a41e65819549b4dfcda4e619b76 guid: ef30832cb8f75dd4bb24744d068553f2
timeCreated: 1620726427
licenseType: Free
MonoImporter: MonoImporter:
externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0

View File

@@ -8,7 +8,6 @@ using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.TextCore.LowLevel; using UnityEngine.TextCore.LowLevel;
using UnityEngine.TextCore.Text; using UnityEngine.TextCore.Text;
using Logger = Cryville.Common.Logging.Logger;
namespace Cryville.Common.Unity.UI { namespace Cryville.Common.Unity.UI {
[RequireComponent(typeof(TextMeshProUGUI))] [RequireComponent(typeof(TextMeshProUGUI))]
@@ -32,14 +31,14 @@ namespace Cryville.Common.Unity.UI {
else if (DefaultShader) ifont.material.shader = DefaultShader; else if (DefaultShader) ifont.material.shader = DefaultShader;
if (_font == null) { if (_font == null) {
_font = ifont; _font = ifont;
Logger.Log("main", 1, "UI", "Using main font: {0}", typeface.FullName); Shared.Logger.Log(1, "UI", "Using main font: {0}", typeface.FullName);
if (MaxFallbackCount <= 0) break; if (MaxFallbackCount <= 0) break;
} }
else { else {
if (_font.fallbackFontAssetTable == null) if (_font.fallbackFontAssetTable == null)
_font.fallbackFontAssetTable = new List<FontAsset>(); _font.fallbackFontAssetTable = new List<FontAsset>();
_font.fallbackFontAssetTable.Add(ifont); _font.fallbackFontAssetTable.Add(ifont);
Logger.Log("main", 1, "UI", "Using fallback font #{0}: {1}", _font.fallbackFontAssetTable.Count, typeface.FullName); Shared.Logger.Log(1, "UI", "Using fallback font #{0}: {1}", _font.fallbackFontAssetTable.Count, typeface.FullName);
if (_font.fallbackFontAssetTable.Count >= MaxFallbackCount) break; if (_font.fallbackFontAssetTable.Count >= MaxFallbackCount) break;
} }
} }

View File

@@ -1,4 +1,3 @@
using Cryville.Common.Logging;
using Cryville.Crtr.Extension; using Cryville.Crtr.Extension;
using Mono.Cecil; using Mono.Cecil;
using System; using System;
@@ -36,7 +35,7 @@ namespace Cryville.Crtr.Browsing {
modules.Enqueue(new ModuleItem(extension.OpenRead())); modules.Enqueue(new ModuleItem(extension.OpenRead()));
} }
catch (Exception ex) { catch (Exception ex) {
Logger.Log("main", 4, "Extension", "Failed to load DLL {0}: {1}", extension, ex); Game.MainLogger.Log(4, "Extension", "Failed to load DLL {0}: {1}", extension, ex);
} }
} }
} }
@@ -68,10 +67,10 @@ namespace Cryville.Crtr.Browsing {
LoadExtension(type); LoadExtension(type);
} }
} }
Logger.Log("main", 1, "Extension", "Loaded module {0}", module.Definition.Name); Game.MainLogger.Log(1, "Extension", "Loaded module {0}", module.Definition.Name);
} }
catch (Exception ex) { catch (Exception ex) {
Logger.Log("main", 4, "Extension", "An error occurred while trying to load module {0}: {1}", module.Definition.Name, ex); Game.MainLogger.Log(4, "Extension", "An error occurred while trying to load module {0}: {1}", module.Definition.Name, ex);
} }
finally { finally {
module.Definition.Dispose(); module.Definition.Dispose();
@@ -89,7 +88,7 @@ namespace Cryville.Crtr.Browsing {
missingList.Add(reference.Name); missingList.Add(reference.Name);
} }
} }
Logger.Log("main", 4, "Extension", "Could not load the module {0} because the following dependencies were missing: {1}", module.Definition.Name, missingList.Aggregate((current, next) => current + ", " + next)); Game.MainLogger.Log(4, "Extension", "Could not load the module {0} because the following dependencies were missing: {1}", module.Definition.Name, missingList.Aggregate((current, next) => current + ", " + next));
module.Definition.Dispose(); module.Definition.Dispose();
module.Stream.Dispose(); module.Stream.Dispose();
} }
@@ -128,10 +127,10 @@ namespace Cryville.Crtr.Browsing {
if (name != null && path != null) _localRes.Add(name, path); if (name != null && path != null) _localRes.Add(name, path);
} }
} }
Logger.Log("main", 1, "Extension", "Loaded extension {0}", type); Game.MainLogger.Log(1, "Extension", "Loaded extension {0}", type);
} }
catch (Exception ex) { catch (Exception ex) {
Logger.Log("main", 4, "Extension", "Failed to load extension {0}: {1}", type, ex); Game.MainLogger.Log(4, "Extension", "Failed to load extension {0}: {1}", type, ex);
} }
} }
} }

View File

@@ -11,7 +11,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using Logger = Cryville.Common.Logging.Logger;
namespace Cryville.Crtr.Browsing { namespace Cryville.Crtr.Browsing {
internal class LegacyResourceManager : IPathedResourceManager<ChartDetail> { internal class LegacyResourceManager : IPathedResourceManager<ChartDetail> {
@@ -41,7 +40,7 @@ namespace Cryville.Crtr.Browsing {
} }
void OnFileWatcherError(object sender, ErrorEventArgs e) { void OnFileWatcherError(object sender, ErrorEventArgs e) {
Logger.Log("main", 4, "Data", "An error occurred while watching file changes: {0}", e.GetException()); Game.MainLogger.Log(4, "Data", "An error occurred while watching file changes: {0}", e.GetException());
} }
void OnFileChanged(object sender, FileSystemEventArgs e) { void OnFileChanged(object sender, FileSystemEventArgs e) {
@@ -235,13 +234,13 @@ namespace Cryville.Crtr.Browsing {
void LogAndPopup(int level, string format, params object[] args) { void LogAndPopup(int level, string format, params object[] args) {
var msg = string.Format(format, args); var msg = string.Format(format, args);
Logger.Log("main", level, "Resource", msg); Game.MainLogger.Log(level, "Resource", msg);
Popup.Create(msg); Popup.Create(msg);
} }
void LogAndPopupExtra(int level, object extraLog, string format, params object[] args) { void LogAndPopupExtra(int level, object extraLog, string format, params object[] args) {
var msg = string.Format(format, args); var msg = string.Format(format, args);
Logger.Log("main", level, "Resource", "{0}\n{1}", msg, extraLog); Game.MainLogger.Log(level, "Resource", "{0}\n{1}", msg, extraLog);
Popup.Create(msg); Popup.Create(msg);
} }

View File

@@ -1,5 +1,6 @@
using Cryville.Common; using Cryville.Common;
using Cryville.Common.Buffers; using Cryville.Common.Buffers;
using Cryville.Common.Logging;
using Cryville.Crtr.Config; using Cryville.Crtr.Config;
using Cryville.Crtr.Event; using Cryville.Crtr.Event;
using Cryville.Crtr.Ruleset; using Cryville.Crtr.Ruleset;
@@ -18,7 +19,6 @@ using UnityEngine.Networking;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.Scripting; using UnityEngine.Scripting;
using Coroutine = Cryville.Common.Coroutine; using Coroutine = Cryville.Common.Coroutine;
using Logger = Cryville.Common.Logging.Logger;
using Stopwatch = System.Diagnostics.Stopwatch; using Stopwatch = System.Diagnostics.Stopwatch;
namespace Cryville.Crtr { namespace Cryville.Crtr {
@@ -44,6 +44,7 @@ namespace Cryville.Crtr {
static bool initialized; static bool initialized;
TextMeshProUGUI logs; TextMeshProUGUI logs;
TextMeshProUGUI status; TextMeshProUGUI status;
BufferedLoggerListener loggerListener;
static Vector2 screenSize; static Vector2 screenSize;
public static Rect hitRect; public static Rect hitRect;
@@ -67,7 +68,7 @@ namespace Cryville.Crtr {
#region MonoBehaviour #region MonoBehaviour
void Start() { void Start() {
d_addLogEntry = new Action<int, string, string>(AddLogEntry); d_addLogEntry = AddLogEntry;
var logobj = GameObject.Find("Logs"); var logobj = GameObject.Find("Logs");
if (logobj != null) if (logobj != null)
@@ -80,6 +81,8 @@ namespace Cryville.Crtr {
OnSettingsUpdate(); OnSettingsUpdate();
status = GameObject.Find("Status").GetComponent<TextMeshProUGUI>(); status = GameObject.Find("Status").GetComponent<TextMeshProUGUI>();
loggerListener = new BufferedLoggerListener();
Game.MainLogger.AddListener(loggerListener);
try { try {
Play(); Play();
@@ -101,6 +104,8 @@ namespace Cryville.Crtr {
if (loadThread != null) loadThread.Abort(); if (loadThread != null) loadThread.Abort();
if (inputProxy != null) inputProxy.Dispose(); if (inputProxy != null) inputProxy.Dispose();
if (texs != null) foreach (var t in texs) Texture.Destroy(t.Value); if (texs != null) foreach (var t in texs) Texture.Destroy(t.Value);
Game.MainLogger.RemoveListener(loggerListener);
loggerListener.Dispose();
GC.Collect(); GC.Collect();
} }
@@ -127,7 +132,7 @@ namespace Cryville.Crtr {
} }
else if (loadThread != null) LoadUpdate(); else if (loadThread != null) LoadUpdate();
if (logEnabled) LogUpdate(); if (logEnabled) LogUpdate();
else Game.MainLogger.Enumerate((level, module, msg) => { }); else loggerListener.Enumerate((level, module, msg) => { });
} }
void GameUpdate() { void GameUpdate() {
try { try {
@@ -180,7 +185,7 @@ namespace Cryville.Crtr {
if (!texloaddone) texLoader.Tick(1.0 / Application.targetFrameRate); if (!texloaddone) texLoader.Tick(1.0 / Application.targetFrameRate);
if (!loadThread.IsAlive) { if (!loadThread.IsAlive) {
if (threadException != null) { if (threadException != null) {
Logger.Log("main", 4, "Load/MainThread", "Load failed"); Game.MainLogger.Log(4, "Load/MainThread", "Load failed");
loadThread = null; loadThread = null;
Popup.CreateException(threadException); Popup.CreateException(threadException);
ReturnToMenu(); ReturnToMenu();
@@ -201,7 +206,7 @@ namespace Cryville.Crtr {
readonly StringBuffer logsbuf = new StringBuffer(); readonly StringBuffer logsbuf = new StringBuffer();
readonly List<string> logEntries = new List<string>(); readonly List<string> logEntries = new List<string>();
int logsLength = 0; int logsLength = 0;
Action<int, string, string> d_addLogEntry; LogHandler d_addLogEntry;
void AddLogEntry(int level, string module, string msg) { void AddLogEntry(int level, string module, string msg) {
string color; string color;
switch (level) { switch (level) {
@@ -222,7 +227,7 @@ namespace Cryville.Crtr {
} }
void LogUpdate() { void LogUpdate() {
logsbuf.Clear(); logsbuf.Clear();
Game.MainLogger.Enumerate(d_addLogEntry); loggerListener.Enumerate(d_addLogEntry);
while (logsLength >= 4096) { while (logsLength >= 4096) {
logsLength -= logEntries[0].Length; logsLength -= logEntries[0].Length;
logEntries.RemoveAt(0); logEntries.RemoveAt(0);
@@ -335,7 +340,7 @@ namespace Cryville.Crtr {
texloaddone = true; texloaddone = true;
texLoader = null; texLoader = null;
if (loadThread.IsAlive) { if (loadThread.IsAlive) {
Logger.Log("main", 2, "Game", "Stop requested while the chart is loading. Waiting for the loading thread to exit..."); Game.MainLogger.Log(2, "Game", "Stop requested while the chart is loading. Waiting for the loading thread to exit...");
} }
} }
else { else {
@@ -433,7 +438,7 @@ namespace Cryville.Crtr {
skinFile = skinFile, skinFile = skinFile,
}); });
Logger.Log("main", 0, "Load/MainThread", "Loading textures..."); Game.MainLogger.Log(0, "Load/MainThread", "Loading textures...");
frames = new Dictionary<string, SpriteFrame>(); frames = new Dictionary<string, SpriteFrame>();
texs = new Dictionary<string, Texture2D>(); texs = new Dictionary<string, Texture2D>();
var skinDir = skinFile.Directory.FullName; var skinDir = skinFile.Directory.FullName;
@@ -469,7 +474,7 @@ namespace Cryville.Crtr {
var tex = texHandler.texture; var tex = texHandler.texture;
tex.wrapMode = TextureWrapMode.Clamp; tex.wrapMode = TextureWrapMode.Clamp;
if (frames.ContainsKey(name)) { if (frames.ContainsKey(name)) {
Logger.Log("main", 3, "Load/Prehandle", "Duplicated texture name: {0}", name); Game.MainLogger.Log(3, "Load/Prehandle", "Duplicated texture name: {0}", name);
} }
else { else {
frames.Add(name, new SpriteFrame(tex)); frames.Add(name, new SpriteFrame(tex));
@@ -477,7 +482,7 @@ namespace Cryville.Crtr {
texs.Add(name, tex); texs.Add(name, tex);
} }
else { else {
Logger.Log("main", 4, "Load/Prehandle", "Unable to load texture: {0}", name); Game.MainLogger.Log(4, "Load/Prehandle", "Unable to load texture: {0}", name);
} }
texLoader.Dispose(); texLoader.Dispose();
texHandler.Dispose(); texHandler.Dispose();
@@ -493,39 +498,39 @@ namespace Cryville.Crtr {
} }
texloaddone = true; texloaddone = true;
stopwatch.Stop(); stopwatch.Stop();
Logger.Log("main", 1, "Load/MainThread", "Main thread done ({0}ms)", stopwatch.Elapsed.TotalMilliseconds); Game.MainLogger.Log(1, "Load/MainThread", "Main thread done ({0}ms)", stopwatch.Elapsed.TotalMilliseconds);
yield return 1; yield return 1;
} }
IEnumerator<float> Prehandle() { IEnumerator<float> Prehandle() {
Stopwatch timer = new Stopwatch(); Stopwatch timer = new Stopwatch();
timer.Reset(); timer.Start(); timer.Reset(); timer.Start();
Logger.Log("main", 0, "Load/Prehandle", "Prehandling (iteration 2)"); yield return 0; Game.MainLogger.Log(0, "Load/Prehandle", "Prehandling (iteration 2)"); yield return 0;
cbus.BroadcastPreInit(); cbus.BroadcastPreInit();
Logger.Log("main", 0, "Load/Prehandle", "Prehandling (iteration 3)"); yield return 0; Game.MainLogger.Log(0, "Load/Prehandle", "Prehandling (iteration 3)"); yield return 0;
using (var pbus = cbus.Clone(17)) { using (var pbus = cbus.Clone(17)) {
while (pbus.Time != double.PositiveInfinity) { while (pbus.Time != double.PositiveInfinity) {
pbus.ForwardOnce(); pbus.ForwardOnce();
yield return (float)pbus.EventId / pbus.EventCount; yield return (float)pbus.EventId / pbus.EventCount;
} }
} }
Logger.Log("main", 0, "Load/Prehandle", "Prehandling (iteration 4)"); yield return 1; Game.MainLogger.Log(0, "Load/Prehandle", "Prehandling (iteration 4)"); yield return 1;
cbus.BroadcastPostInit(); cbus.BroadcastPostInit();
Logger.Log("main", 0, "Load/Prehandle", "Seeking to start offset"); yield return 1; Game.MainLogger.Log(0, "Load/Prehandle", "Seeking to start offset"); yield return 1;
cbus.ForwardByTime(startOffset); cbus.ForwardByTime(startOffset);
bbus.ForwardByTime(startOffset); bbus.ForwardByTime(startOffset);
Game.AudioSequencer.SeekTime(startOffset, SeekOrigin.Current); Game.AudioSequencer.SeekTime(startOffset, SeekOrigin.Current);
Logger.Log("main", 0, "Load/Prehandle", "Cleaning up"); yield return 1; Game.MainLogger.Log(0, "Load/Prehandle", "Cleaning up"); yield return 1;
if (logEnabled && Settings.Default.HideLogOnPlay) ToggleLogs(); if (logEnabled && Settings.Default.HideLogOnPlay) ToggleLogs();
Camera.main.cullingMask |= 1; Camera.main.cullingMask |= 1;
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); yield return 1; Game.MainLogger.Log(1, "Load/Prehandle", "Prehandling done ({0}ms)", timer.Elapsed.TotalMilliseconds); yield return 1;
if (Settings.Default.ClearLogOnPlay) { if (Settings.Default.ClearLogOnPlay) {
logEntries.Clear(); logEntries.Clear();
logsLength = 0; logsLength = 0;
Game.MainLogger.Enumerate((level, module, msg) => { }); loggerListener.Enumerate((level, module, msg) => { });
logs.text = ""; logs.text = "";
} }
Game.AudioSequencer.Playing = true; Game.AudioSequencer.Playing = true;
@@ -536,7 +541,7 @@ namespace Cryville.Crtr {
public void Stop() { public void Stop() {
try { try {
Logger.Log("main", 1, "Game", "Stopping"); Game.MainLogger.Log(1, "Game", "Stopping");
Game.AudioClient.Start(); Game.AudioClient.Start();
Game.AudioSession = Game.AudioSequencer.NewSession(); Game.AudioSession = Game.AudioSequencer.NewSession();
Camera.main.cullingMask &= ~1; Camera.main.cullingMask &= ~1;
@@ -555,7 +560,7 @@ namespace Cryville.Crtr {
} }
PdtEvaluator.Instance.Reset(); PdtEvaluator.Instance.Reset();
motionRegistry = null; motionRegistry = null;
Logger.Log("main", 1, "Game", "Stopped"); Game.MainLogger.Log(1, "Game", "Stopped");
} }
catch (Exception ex) { catch (Exception ex) {
if (!logEnabled) ToggleLogs(); if (!logEnabled) ToggleLogs();
@@ -597,7 +602,7 @@ namespace Cryville.Crtr {
workerTimer.Start(); workerTimer.Start();
LoadChart(info); LoadChart(info);
workerTimer.Stop(); workerTimer.Stop();
Logger.Log("main", 1, "Load/WorkerThread", "Worker thread done ({0}ms)", workerTimer.Elapsed.TotalMilliseconds); Game.MainLogger.Log(1, "Load/WorkerThread", "Worker thread done ({0}ms)", workerTimer.Elapsed.TotalMilliseconds);
} }
catch (Exception ex) { catch (Exception ex) {
Game.LogException("Load/WorkerThread", "An error occurred while loading the data", ex); Game.LogException("Load/WorkerThread", "An error occurred while loading the data", ex);
@@ -606,7 +611,7 @@ namespace Cryville.Crtr {
} }
void LoadChart(LoadInfo info) { void LoadChart(LoadInfo info) {
Logger.Log("main", 0, "Load/WorkerThread", "Loading chart: {0}", info.chartFile); Game.MainLogger.Log(0, "Load/WorkerThread", "Loading chart: {0}", info.chartFile);
motionRegistry = new Dictionary<Identifier, MotionRegistry> { motionRegistry = new Dictionary<Identifier, MotionRegistry> {
{ new Identifier("pt") , new MotionRegistry(typeof(Vec2)) }, { new Identifier("pt") , new MotionRegistry(typeof(Vec2)) },
@@ -627,28 +632,28 @@ namespace Cryville.Crtr {
MissingMemberHandling = MissingMemberHandling.Error MissingMemberHandling = MissingMemberHandling.Error
}); });
Logger.Log("main", 0, "Load/WorkerThread", "Applying ruleset (iteration 1)"); loadPregress = .10f; Game.MainLogger.Log(0, "Load/WorkerThread", "Applying ruleset (iteration 1)"); loadPregress = .10f;
pruleset.PrePatch(chart); pruleset.PrePatch(chart);
Logger.Log("main", 0, "Load/WorkerThread", "Batching events"); loadPregress = .20f; Game.MainLogger.Log(0, "Load/WorkerThread", "Batching events"); loadPregress = .20f;
var batcher = new EventBatcher(chart); var batcher = new EventBatcher(chart);
batcher.Forward(); batcher.Forward();
cbus = batcher.Batch(); loadPregress = .30f; cbus = batcher.Batch(); loadPregress = .30f;
LoadSkin(info.skinFile); LoadSkin(info.skinFile);
Logger.Log("main", 0, "Load/WorkerThread", "Initializing judge and input"); loadPregress = .35f; Game.MainLogger.Log(0, "Load/WorkerThread", "Initializing judge and input"); loadPregress = .35f;
judge = new Judge(this, pruleset); judge = new Judge(this, pruleset);
PdtEvaluator.Instance.ContextJudge = judge; PdtEvaluator.Instance.ContextJudge = judge;
inputProxy = new InputProxy(pruleset, judge, screenSize); inputProxy = new InputProxy(pruleset, judge, screenSize);
inputProxy.LoadFrom(_rscfg.inputs); inputProxy.LoadFrom(_rscfg.inputs);
if (!inputProxy.IsCompleted()) { if (!inputProxy.IsCompleted()) {
Logger.Log("main", 2, "Game", "Input config not completed. Input disabled"); Game.MainLogger.Log(2, "Game", "Input config not completed. Input disabled");
inputProxy.Clear(); inputProxy.Clear();
} }
Logger.Log("main", 0, "Load/WorkerThread", "Attaching handlers"); loadPregress = .40f; Game.MainLogger.Log(0, "Load/WorkerThread", "Attaching handlers"); loadPregress = .40f;
var ch = new ChartHandler(chart); var ch = new ChartHandler(chart);
cbus.RootState.AttachHandler(ch); cbus.RootState.AttachHandler(ch);
foreach (var gs in cbus.RootState.Children) { foreach (var gs in cbus.RootState.Children) {
@@ -666,16 +671,16 @@ namespace Cryville.Crtr {
} }
} }
cbus.AttachSystems(pskin, judge); cbus.AttachSystems(pskin, judge);
Logger.Log("main", 0, "Load/WorkerThread", "Prehandling (iteration 1)"); loadPregress = .60f; Game.MainLogger.Log(0, "Load/WorkerThread", "Prehandling (iteration 1)"); loadPregress = .60f;
using (var pbus = cbus.Clone(16)) { using (var pbus = cbus.Clone(16)) {
pbus.Forward(); pbus.Forward();
} }
Logger.Log("main", 0, "Load/WorkerThread", "Cloning states (type 1)"); loadPregress = .70f; Game.MainLogger.Log(0, "Load/WorkerThread", "Cloning states (type 1)"); loadPregress = .70f;
bbus = cbus.Clone(1, -clippingDist); bbus = cbus.Clone(1, -clippingDist);
Logger.Log("main", 0, "Load/WorkerThread", "Cloning states (type 2)"); loadPregress = .80f; Game.MainLogger.Log(0, "Load/WorkerThread", "Cloning states (type 2)"); loadPregress = .80f;
tbus = bbus.Clone(2); tbus = bbus.Clone(2);
Logger.Log("main", 0, "Load/WorkerThread", "Cloning states (type 3)"); loadPregress = .90f; Game.MainLogger.Log(0, "Load/WorkerThread", "Cloning states (type 3)"); loadPregress = .90f;
nbus = bbus.Clone(3); nbus = bbus.Clone(3);
loadPregress = 1; loadPregress = 1;
} }
@@ -683,7 +688,7 @@ namespace Cryville.Crtr {
void LoadRuleset(FileInfo file) { void LoadRuleset(FileInfo file) {
DirectoryInfo dir = file.Directory; DirectoryInfo dir = file.Directory;
Logger.Log("main", 0, "Load/WorkerThread", "Loading ruleset: {0}", file); Game.MainLogger.Log(0, "Load/WorkerThread", "Loading ruleset: {0}", file);
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) { using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
ruleset = JsonConvert.DeserializeObject<RulesetDefinition>(reader.ReadToEnd(), new JsonSerializerSettings() { ruleset = JsonConvert.DeserializeObject<RulesetDefinition>(reader.ReadToEnd(), new JsonSerializerSettings() {
MissingMemberHandling = MissingMemberHandling.Error MissingMemberHandling = MissingMemberHandling.Error
@@ -701,7 +706,7 @@ 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); Game.MainLogger.Log(0, "Load/WorkerThread", "Loading skin: {0}", file);
skin.LoadPdt(dir); skin.LoadPdt(dir);
pskin = skin.Root; pskin = skin.Root;
pskin.Optimize(PdtEvaluator.Instance); pskin.Optimize(PdtEvaluator.Instance);

View File

@@ -5,7 +5,6 @@ using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using Logger = Cryville.Common.Logging.Logger;
namespace Cryville.Crtr.Config.UI { namespace Cryville.Crtr.Config.UI {
public class ConfigPanelMaster : MonoBehaviour { public class ConfigPanelMaster : MonoBehaviour {
@@ -74,7 +73,7 @@ namespace Cryville.Crtr.Config.UI {
} }
catch (Exception ex) { catch (Exception ex) {
Popup.CreateException(ex); Popup.CreateException(ex);
Logger.Log("main", 4, "Config", "An error occurred while loading the config: {0}", ex); Game.MainLogger.Log(4, "Config", "An error occurred while loading the config: {0}", ex);
m_menu.Back(); m_menu.Back();
} }
} }

View File

@@ -1,157 +0,0 @@
using Cryville.Common.Network.Http11;
using System;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Logger = Cryville.Common.Logging.Logger;
using unity = UnityEngine;
namespace Cryville.Crtr {
public class Console : MonoBehaviour {
public Text Logs;
public InputField InputBox;
CommandWorker worker;
readonly Queue<string> _fallbackQueue = new Queue<string>();
~Console() {
worker.Deactivate();
}
void Start() {
Game.Init();
InputBox.Select();
worker = new CommandWorker(MainThreadFallback);
worker.Activate();
}
void OnApplicationQuit() {
Game.Shutdown();
}
public void Submit() {
worker.Issue(InputBox.text);
}
void Update() {
if (
unity::Input.GetKeyDown(KeyCode.Return)
|| unity::Input.GetKeyDown(KeyCode.KeypadEnter)
) {
Submit();
InputBox.text = "";
InputBox.Select();
InputBox.ActivateInputField();
}
if (_fallbackQueue.Count > 0) {
switch (_fallbackQueue.Dequeue()) {
case "play":
SceneManager.LoadScene("Play");
break;
case "quit":
Application.Quit();
break;
default:
Logger.Log("main", 4, "Console", "Unknown command. Type \"help\" for help");
break;
}
}
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\x02<color={1}ff>[{0}] <{2}> {3}</color>",
DateTime.UtcNow.ToString("s"), color, module, msg
);
});
Logs.text = _logs.Substring(Mathf.Max(0, _logs.IndexOf('\x02', Mathf.Max(0, _logs.Length - 8192))));
}
void MainThreadFallback(string cmd) {
_fallbackQueue.Enqueue(cmd);
}
class CommandWorker {
readonly Action<string> _fallback;
Thread _thread;
readonly Queue<string> _queue = new Queue<string>();
public CommandWorker(Action<string> fallback) {
_fallback = fallback;
}
public void Activate() {
_thread = new Thread(ThreadLoop);
_thread.Start();
}
public void Deactivate() {
_thread.Abort();
}
public void Issue(string cmd) {
lock (_queue) {
_queue.Enqueue(cmd);
}
}
void ThreadLoop() {
while (true) {
string cmd = null;
lock (_queue) {
if (_queue.Count > 0) cmd = _queue.Dequeue();
}
if (cmd != null) ProcessCommand(cmd);
else Thread.Sleep(20);
}
}
void ProcessCommand(string cmd) {
Logger.Log("main", 2, "Console", "Command processing: {0}", cmd);
var p = cmd.Split(' ');
try {
switch (p[0]) {
case "!http":
var httpcl = new Http11Client(new Uri(p[1]));
httpcl.Connect();
httpcl.Request("GET", new Uri(p[1])).MessageBody.ReadToEnd();
httpcl.Close();
break;
case "!https":
var httpscl = new Https11Client(new Uri(p[1]));
httpscl.Connect();
httpscl.Request("GET", new Uri(p[1])).MessageBody.ReadToEnd();
httpscl.Close();
break;
case "help": case "?":
Logger.Log(
"main", 1, "Console",
"\n\thelp" +
"\n\tplay" +
"\n\tquit"
);
break;
default:
_fallback.Invoke(cmd);
break;
}
}
catch (Exception ex) {
Logger.Log("main", 4, "Console", "{0}", ex);
}
Logger.Log("main", 2, "Console", "Command done: {0}", cmd);
}
}
}
}

View File

@@ -5,7 +5,6 @@
#if COMPILE #if COMPILE
using Discord; using Discord;
using System; using System;
using Logger = Cryville.Common.Logging.Logger;
#endif #endif
using UnityEngine; using UnityEngine;
@@ -25,7 +24,7 @@ namespace Cryville.Crtr {
launchTime = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds; launchTime = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
try { try {
dc = new Discord.Discord(CLIENT_ID, (UInt64)CreateFlags.NoRequireDiscord); dc = new Discord.Discord(CLIENT_ID, (UInt64)CreateFlags.NoRequireDiscord);
Logger.Log("main", 1, "Discord", "Connected to Discord"); Game.MainLogger.Log(1, "Discord", "Connected to Discord");
am = dc.GetActivityManager(); am = dc.GetActivityManager();
SetIdle(); SetIdle();
} }
@@ -34,7 +33,7 @@ namespace Cryville.Crtr {
dc.Dispose(); dc.Dispose();
dc = null; dc = null;
} }
Logger.Log("main", 3, "Discord", "Cannot connect to Discord"); Game.MainLogger.Log(3, "Discord", "Cannot connect to Discord");
} }
} }
@@ -46,7 +45,7 @@ namespace Cryville.Crtr {
catch (ResultException ex) { catch (ResultException ex) {
dc.Dispose(); dc.Dispose();
dc = null; dc = null;
Logger.Log("main", 4, "Discord", "An error occurred while running callbacks: {0}", ex); Game.MainLogger.Log(4, "Discord", "An error occurred while running callbacks: {0}", ex);
} }
} }

View File

@@ -43,7 +43,9 @@ namespace Cryville.Crtr {
DefaultValueHandling = DefaultValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore,
}; };
public static BufferedLogger MainLogger { get; private set; } public static Logger MainLogger { get; private set; }
static FileStream _logFileStream;
static StreamLoggerListener _logWriter;
static bool _init; static bool _init;
public static void Init() { public static void Init() {
@@ -53,25 +55,41 @@ namespace Cryville.Crtr {
bool _bcflag = new Version(Settings.Default.LastRunVersion) < new Version("0.4"); bool _bcflag = new Version(Settings.Default.LastRunVersion) < new Version("0.4");
if (_bcflag) Settings.Default.Reset(); if (_bcflag) Settings.Default.Reset();
Logger.SetLogPath(Settings.Default.GameDataPath + "/logs");
MainLogger = new BufferedLogger();
Application.logMessageReceivedThreaded += OnLog;
Logger.Create("main", MainLogger);
Logger.Log("main", 1, "Game", "Game Version: {0}", Application.version);
Logger.Log("main", 1, "Game", "Unity Version: {0}", Application.unityVersion);
Logger.Log("main", 1, "Game", "Operating System: {0}, Unity = {1}, Family = {2}", Environment.OSVersion, SystemInfo.operatingSystem, SystemInfo.operatingSystemFamily);
Logger.Log("main", 1, "Game", "Platform: Build = {0}, Unity = {1}", PlatformConfig.Name, Application.platform);
Logger.Log("main", 1, "Game", "Culture: {0}, UI = {1}, System = {2}, Unity = {3}", CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture, CultureInfo.InstalledUICulture, Application.systemLanguage);
Logger.Log("main", 1, "Game", "Device: Model = {0}, Name = {1}, Type = {2}", SystemInfo.deviceModel, SystemInfo.deviceName, SystemInfo.deviceType);
Logger.Log("main", 1, "Game", "Graphics: Name = {0}, Type = {1}, Vendor = {2}, Version = {3}", SystemInfo.graphicsDeviceName, SystemInfo.graphicsDeviceType, SystemInfo.graphicsDeviceVendor, SystemInfo.graphicsDeviceVersion);
Logger.Log("main", 1, "Game", "Processor: Count = {0}, Frequency = {1}MHz, Type = {2}", SystemInfo.processorCount, SystemInfo.processorFrequency, SystemInfo.processorType);
if (_bcflag) Logger.Log("main", 2, "Game", "Reset all settings");
GameDataPath = Settings.Default.GameDataPath; GameDataPath = Settings.Default.GameDataPath;
UnityDataPath = Application.dataPath; UnityDataPath = Application.dataPath;
var logPath = Directory.CreateDirectory(Path.Combine(GameDataPath, "logs"));
_logFileStream = new FileStream(
Path.Combine(
logPath.FullName,
string.Format(
CultureInfo.InvariantCulture,
"{0}.log",
(int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds
)
),
FileMode.Create, FileAccess.Write, FileShare.Read
);
_logWriter = new StreamLoggerListener(_logFileStream) { AutoFlush = true };
MainLogger = new Logger();
var listener = new InstantLoggerListener();
listener.Log += MainLogger.Log;
Common.Shared.Logger.AddListener(listener);
Input.Shared.Logger.AddListener(listener);
MainLogger.AddListener(_logWriter);
Application.logMessageReceivedThreaded += OnInternalLog;
MainLogger.Log(1, "Game", "Game Version: {0}", Application.version);
MainLogger.Log(1, "Game", "Unity Version: {0}", Application.unityVersion);
MainLogger.Log(1, "Game", "Operating System: {0}, Unity = {1}, Family = {2}", Environment.OSVersion, SystemInfo.operatingSystem, SystemInfo.operatingSystemFamily);
MainLogger.Log(1, "Game", "Platform: Build = {0}, Unity = {1}", PlatformConfig.Name, Application.platform);
MainLogger.Log(1, "Game", "Culture: {0}, UI = {1}, System = {2}, Unity = {3}", CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture, CultureInfo.InstalledUICulture, Application.systemLanguage);
MainLogger.Log(1, "Game", "Device: Model = {0}, Name = {1}, Type = {2}", SystemInfo.deviceModel, SystemInfo.deviceName, SystemInfo.deviceType);
MainLogger.Log(1, "Game", "Graphics: Name = {0}, Type = {1}, Vendor = {2}, Version = {3}", SystemInfo.graphicsDeviceName, SystemInfo.graphicsDeviceType, SystemInfo.graphicsDeviceVendor, SystemInfo.graphicsDeviceVersion);
MainLogger.Log(1, "Game", "Processor: Count = {0}, Frequency = {1}MHz, Type = {2}", SystemInfo.processorCount, SystemInfo.processorFrequency, SystemInfo.processorType);
if (_bcflag) MainLogger.Log(2, "Game", "Reset all settings");
#if UNITY_ANDROID && !UNITY_EDITOR #if UNITY_ANDROID && !UNITY_EDITOR
JavaVMManager.Register(JniInvoke.Instance); JavaVMManager.Register(JniInvoke.Instance);
#endif #endif
@@ -120,14 +138,14 @@ namespace Cryville.Crtr {
AudioManager = EngineBuilder.Create(); AudioManager = EngineBuilder.Create();
if (AudioManager == null) { if (AudioManager == null) {
Dialog.Show(null, "Fatal error: Cannot initialize audio engine"); Dialog.Show(null, "Fatal error: Cannot initialize audio engine");
Logger.Log("main", 5, "Audio", "Cannot initialize audio engine"); MainLogger.Log(5, "Audio", "Cannot initialize audio engine");
} }
else { else {
Logger.Log("main", 1, "Audio", "Using audio API: {0}", AudioManager.GetType().Namespace); MainLogger.Log(1, "Audio", "Using audio API: {0}", AudioManager.GetType().Namespace);
AudioDevice = AudioManager.GetDefaultDevice(DataFlow.Out); AudioDevice = AudioManager.GetDefaultDevice(DataFlow.Out);
AudioClient = AudioDevice.Connect(AudioDevice.DefaultFormat, AudioDevice.MinimumBufferSize + AudioDevice.BurstSize); AudioClient = AudioDevice.Connect(AudioDevice.DefaultFormat, AudioDevice.MinimumBufferSize + AudioDevice.BurstSize);
Logger.Log( MainLogger.Log(
"main", 1, "Audio", 1, "Audio",
"Audio Output = {{ Name = \"{0}\", BurstSize = {1}, Format = {2}, BufferSize = {3} }}", "Audio Output = {{ Name = \"{0}\", BurstSize = {1}, Format = {2}, BufferSize = {3} }}",
AudioDevice.Name, AudioDevice.BurstSize, AudioClient.Format, AudioClient.BufferSize AudioDevice.Name, AudioDevice.BurstSize, AudioClient.Format, AudioClient.BufferSize
); );
@@ -140,8 +158,8 @@ namespace Cryville.Crtr {
} }
catch (Exception ex) { catch (Exception ex) {
Dialog.Show(null, "An error occurred while trying to initialize the recommended audio engine\nTrying to use fallback audio engines"); Dialog.Show(null, "An error occurred while trying to initialize the recommended audio engine\nTrying to use fallback audio engines");
Logger.Log("main", 4, "Audio", "An error occurred when initializing the audio engine: {0}", ex); MainLogger.Log(4, "Audio", "An error occurred when initializing the audio engine: {0}", ex);
Logger.Log("main", 2, "Audio", "Trying to use fallback audio engines"); MainLogger.Log(2, "Audio", "Trying to use fallback audio engines");
EngineBuilder.Engines.Remove(AudioManager.GetType()); EngineBuilder.Engines.Remove(AudioManager.GetType());
} }
} }
@@ -159,7 +177,7 @@ namespace Cryville.Crtr {
Settings.Default.LastRunVersion = Application.version; Settings.Default.LastRunVersion = Application.version;
Settings.Default.Save(); Settings.Default.Save();
Logger.Log("main", 1, "UI", "Initializing font manager"); MainLogger.Log(1, "UI", "Initializing font manager");
foreach (var res in Resources.LoadAll<TextAsset>("cldr/common/validity")) { foreach (var res in Resources.LoadAll<TextAsset>("cldr/common/validity")) {
IdValidity.Load(LoadXmlDocument(res)); IdValidity.Load(LoadXmlDocument(res));
} }
@@ -171,7 +189,7 @@ namespace Cryville.Crtr {
}; };
TMPAutoFont.DefaultShader = Resources.Load<Shader>(PlatformConfig.TextShader); TMPAutoFont.DefaultShader = Resources.Load<Shader>(PlatformConfig.TextShader);
Logger.Log("main", 1, "Game", "Initialized"); MainLogger.Log(1, "Game", "Initialized");
} }
static readonly Encoding _encoding = new UTF8Encoding(false, true); static readonly Encoding _encoding = new UTF8Encoding(false, true);
@@ -194,7 +212,7 @@ namespace Cryville.Crtr {
if (_shutdown) return; if (_shutdown) return;
_shutdown = true; _shutdown = true;
Logger.Log("main", 1, "Game", "Shutting down"); MainLogger.Log(1, "Game", "Shutting down");
try { try {
AudioClient.Dispose(); AudioClient.Dispose();
AudioSequencer.Dispose(); AudioSequencer.Dispose();
@@ -205,15 +223,16 @@ namespace Cryville.Crtr {
LogException("Game", "An error occurred while shutting down", ex); LogException("Game", "An error occurred while shutting down", ex);
} }
finally { finally {
Logger.Close(); _logWriter.Dispose();
_logFileStream.Dispose();
} }
} }
public static void LogException(string module, string prefix, Exception ex) { public static void LogException(string module, string prefix, Exception ex) {
Logger.Log("main", 4, module, "{0}: {1}", prefix, ex); MainLogger.Log(4, module, "{0}: {1}", prefix, ex);
} }
static void OnLog(string condition, string stackTrace, LogType type) { static void OnInternalLog(string condition, string stackTrace, LogType type) {
int l; int l;
switch (type) { switch (type) {
case LogType.Log: l = 1; break; case LogType.Log: l = 1; break;
@@ -223,7 +242,7 @@ namespace Cryville.Crtr {
case LogType.Exception: l = 4; break; case LogType.Exception: l = 4; break;
default: l = 1; break; default: l = 1; break;
} }
Logger.Log("main", l, "Internal", "{0}\n{1}", condition, stackTrace); MainLogger.Log(l, "Internal", "{0}\n{1}", condition, stackTrace);
} }
public static void SuspendBackgroundTasks() { public static void SuspendBackgroundTasks() {

View File

@@ -13,7 +13,6 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using UnityEngine; using UnityEngine;
using Logger = Cryville.Common.Logging.Logger;
using ThreadPriority = System.Threading.ThreadPriority; using ThreadPriority = System.Threading.ThreadPriority;
namespace Cryville.Crtr.Network { namespace Cryville.Crtr.Network {
@@ -39,10 +38,10 @@ namespace Cryville.Crtr.Network {
void ThreadLogic() { void ThreadLogic() {
try { try {
CheckVersion(); CheckVersion();
Logger.Log("main", 0, "Network", "Update checker exited normally"); Game.MainLogger.Log(0, "Network", "Update checker exited normally");
} }
catch (Exception ex) { catch (Exception ex) {
Logger.Log("main", 4, "Network", "An error occurred while checking for update: {0}", ex); Game.MainLogger.Log(4, "Network", "An error occurred while checking for update: {0}", ex);
Dialog.Show(null, "Failed to check for update."); Dialog.Show(null, "Failed to check for update.");
} }
} }

View File

@@ -8,7 +8,6 @@ using System.Runtime.Serialization;
using System.Threading; using System.Threading;
using UnityEngine; using UnityEngine;
using UnityEngine.Profiling; using UnityEngine.Profiling;
using Logger = Cryville.Common.Logging.Logger;
using RVector4 = UnityEngine.Vector4; using RVector4 = UnityEngine.Vector4;
namespace Cryville.Crtr.Ruleset { namespace Cryville.Crtr.Ruleset {
@@ -48,7 +47,7 @@ namespace Cryville.Crtr.Ruleset {
foreach (var cfg in config) { foreach (var cfg in config) {
var handler = Game.InputManager.GetHandlerByTypeName(cfg.Value.handler); var handler = Game.InputManager.GetHandlerByTypeName(cfg.Value.handler);
if (handler == null) { if (handler == null) {
Logger.Log("main", 3, "Input", "Uninitialized or unknown handler in ruleset config: {0}", cfg.Value.handler); Game.MainLogger.Log(3, "Input", "Uninitialized or unknown handler in ruleset config: {0}", cfg.Value.handler);
continue; continue;
} }
Set(new InputProxyEntry { Set(new InputProxyEntry {

View File

@@ -1,7 +1,6 @@
using Cryville.Common; using Cryville.Common;
using System; using System;
using UnityEngine; using UnityEngine;
using Logger = Cryville.Common.Logging.Logger;
namespace Cryville.Crtr.Skin.Components { namespace Cryville.Crtr.Skin.Components {
public class SkinAnimation : SkinComponent { public class SkinAnimation : SkinComponent {
@@ -30,7 +29,7 @@ namespace Cryville.Crtr.Skin.Components {
var id = new Identifier(value); var id = new Identifier(value);
AnimationSpan anim; AnimationSpan anim;
if (!ChartPlayer.pskin.animations.TryGetValue(id, out anim)) { if (!ChartPlayer.pskin.animations.TryGetValue(id, out anim)) {
Logger.Log("main", 4, "Skin", "Animation {0} not found", id.Name); Game.MainLogger.Log(4, "Skin", "Animation {0} not found", id.Name);
_anim = null; _anim = null;
return; return;
} }

View File

@@ -1,6 +1,5 @@
using System; using System;
using UnityEngine; using UnityEngine;
using Logger = Cryville.Common.Logging.Logger;
namespace Cryville.Crtr.Skin.Components { namespace Cryville.Crtr.Skin.Components {
public class SpriteInfo { public class SpriteInfo {
@@ -40,7 +39,7 @@ namespace Cryville.Crtr.Skin.Components {
Frame = ChartPlayer.frames[FrameName]; Frame = ChartPlayer.frames[FrameName];
} }
else { else {
Logger.Log("main", 4, "Skin", "Texture {0} not found", FrameName); Game.MainLogger.Log(4, "Skin", "Texture {0} not found", FrameName);
Frame = null; Frame = null;
} }
} }

View File

@@ -3,7 +3,6 @@ using Cryville.Common.Pdt;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Logger = Cryville.Common.Logging.Logger;
namespace Cryville.Crtr.Skin.Components { namespace Cryville.Crtr.Skin.Components {
public class SpriteText : SpriteBase { public class SpriteText : SpriteBase {
@@ -120,7 +119,7 @@ namespace Cryville.Crtr.Skin.Components {
foreach (var c in m_value) { foreach (var c in m_value) {
SpriteInfo f; SpriteInfo f;
if (!m_frames.TryGetValue(c, out f)) { if (!m_frames.TryGetValue(c, out f)) {
Logger.Log("main", 3, "Skin", "Could not render the character '{0}' in the string \"{1}\" on the text component because no image is assigned to that character.", c, m_value); Game.MainLogger.Log(3, "Skin", "Could not render the character '{0}' in the string \"{1}\" on the text component because no image is assigned to that character.", c, m_value);
continue; continue;
} }
var t = f.Frame.Texture; var t = f.Frame.Texture;

View File

@@ -45,7 +45,7 @@ namespace Cryville.Input.Unity.Android {
Batch(timeSecs); Batch(timeSecs);
} }
catch (Exception ex) { catch (Exception ex) {
Logger.Log("main", 4, "Input", "An error occurred while handling an Android sensor event: {0}", ex); Shared.Logger.Log(4, "Input", "An error occurred while handling an Android sensor event: {0}", ex);
} }
} }
} }

View File

@@ -52,7 +52,7 @@ namespace Cryville.Input.Unity.Android {
} }
} }
catch (Exception ex) { catch (Exception ex) {
Logger.Log("main", 4, "Input", "An error occurred while handling an Android touch event: {0}", ex); Shared.Logger.Log(4, "Input", "An error occurred while handling an Android touch event: {0}", ex);
} }
} }
} }

View File

@@ -9,75 +9,177 @@
A logger. A logger.
</summary> </summary>
</member> </member>
<member name="M:Cryville.Common.Logging.Logger.SetLogPath(System.String)"> <member name="M:Cryville.Common.Logging.Logger.AddListener(Cryville.Common.Logging.LoggerListener)">
<summary> <summary>
Sets the path where the log files shall be stored. Attaches a listener to the logger.
</summary> </summary>
<param name="path">The path.</param> <param name="listener">The logger listener.</param>
</member> </member>
<member name="M:Cryville.Common.Logging.Logger.Log(System.String,System.Int32,System.String,System.String,System.Object[])"> <member name="M:Cryville.Common.Logging.Logger.RemoveListener(Cryville.Common.Logging.LoggerListener)">
<summary> <summary>
Logs to the specified logger. Detaches a listener from the logger.
</summary>
<param name="listener">The logger listener.</param>
</member>
<member name="M:Cryville.Common.Logging.Logger.Log(System.Int32,System.String,System.String,System.Object[])">
<summary>
Logs to the logger.
</summary> </summary>
<param name="key">The key of the logger.</param>
<param name="level">The severity level.</param> <param name="level">The severity level.</param>
<param name="module">The module that is logging.</param> <param name="category">The category.</param>
<param name="format">The format string.</param> <param name="format">The format string.</param>
<param name="args">The arguments for formatting.</param> <param name="args">The arguments for formatting.</param>
</member> </member>
<member name="M:Cryville.Common.Logging.Logger.Create(System.String,Cryville.Common.Logging.Logger)"> <member name="M:Cryville.Common.Logging.Logger.Log(System.Int32,System.String,System.IFormatProvider,System.String,System.Object[])">
<summary> <summary>
Adds a created logger to the shared logger manager. Logs to the logger.
</summary>
<param name="key">The key of the logger.</param>
<param name="logger">The logger.</param>
</member>
<member name="M:Cryville.Common.Logging.Logger.Close">
<summary>
Closes all loggers and related file streams.
</summary> </summary>
<param name="level">The severity level.</param>
<param name="category">The category.</param>
<param name="provider">The format provider.</param>
<param name="format">The format string.</param>
<param name="args">The arguments for formatting.</param>
</member> </member>
<member name="M:Cryville.Common.Logging.Logger.Log(System.Int32,System.String,System.String)"> <member name="M:Cryville.Common.Logging.Logger.Log(System.Int32,System.String,System.String)">
<summary> <summary>
Logs to the logger. Logs to the logger.
</summary> </summary>
<param name="level">The severity level.</param> <param name="level">The severity level.</param>
<param name="module">The module that is logging.</param> <param name="category">The category.</param>
<param name="msg">The message.</param> <param name="message">The message.</param>
</member> </member>
<member name="T:Cryville.Common.Logging.InstantLogger"> <member name="M:Cryville.Common.Logging.Logger.Log(System.Int32,System.String,System.Char[])">
<summary> <summary>
A <see cref="T:Cryville.Common.Logging.Logger" /> that calls a callback function on log. Logs to the logger.
</summary>
<param name="level">The severity level.</param>
<param name="category">The category.</param>
<param name="message">An array of <see cref="T:System.Char" /> containing the message.</param>
</member>
<member name="M:Cryville.Common.Logging.Logger.Log(System.Int32,System.String,System.Char[],System.Int32,System.Int32)">
<summary>
Logs to the logger.
</summary>
<param name="level">The severity level.</param>
<param name="category">The category.</param>
<param name="message">An array of <see cref="T:System.Char" /> containing the message.</param>
<param name="index">A zero-based index of the first character of the message within <paramref name="message" />.</param>
<param name="length">The length of the message.</param>
</member>
<member name="M:Cryville.Common.Logging.Logger.Log(System.Int32,System.String,System.Char*,System.Int32)">
<summary>
Logs to the logger.
</summary>
<param name="level">The severity level.</param>
<param name="category">The category.</param>
<param name="message">A pointer to the first character of the message.</param>
<param name="length">The length of the message.</param>
</member>
<member name="T:Cryville.Common.Logging.LoggerListener">
<summary>
A logger listener.
</summary> </summary>
</member> </member>
<member name="M:Cryville.Common.Logging.InstantLogger.#ctor(System.Action{System.Int32,System.String,System.String})"> <member name="M:Cryville.Common.Logging.LoggerListener.Dispose(System.Boolean)">
<summary> <summary>
Creates an instance of the <see cref="T:Cryville.Common.Logging.InstantLogger" /> class. Closes the logger listener and cleans up all the resources.
</summary> </summary>
<param name="callback">The callback function.</param> <param name="disposing">Whether to clean up managed resources.</param>
<exception cref="T:System.ArgumentNullException"><paramref name="callback" /> is <see langword="null" />.</exception>
</member> </member>
<member name="M:Cryville.Common.Logging.InstantLogger.Log(System.Int32,System.String,System.String)"> <member name="M:Cryville.Common.Logging.LoggerListener.Dispose">
<summary>
Closes the logger listener.
</summary>
</member>
<member name="M:Cryville.Common.Logging.LoggerListener.OnLog(System.Int32,System.String,System.String)">
<summary>
Handles an incoming log.
</summary>
<param name="level">The severity level.</param>
<param name="category">The category.</param>
<param name="message">The message.</param>
</member>
<member name="M:Cryville.Common.Logging.LoggerListener.OnLog(System.Int32,System.String,System.Char[],System.Int32,System.Int32)">
<summary>
Handles an incoming log.
</summary>
<param name="level">The severity level.</param>
<param name="category">The category.</param>
<param name="message">An array of <see cref="T:System.Char" /> containing the message.</param>
<param name="index">A zero-based index of the first character of the message within <paramref name="message" />.</param>
<param name="length">The length of the message.</param>
</member>
<member name="M:Cryville.Common.Logging.LoggerListener.OnLog(System.Int32,System.String,System.Char*,System.Int32)">
<summary>
Handles an incoming log.
</summary>
<param name="level">The severity level.</param>
<param name="category">The category.</param>
<param name="message">A pointer to the first character of the message.</param>
<param name="length">The length of the message.</param>
</member>
<member name="T:Cryville.Common.Logging.InstantLoggerListener">
<summary>
A <see cref="T:Cryville.Common.Logging.LoggerListener" /> that calls a callback function on log.
</summary>
</member>
<member name="E:Cryville.Common.Logging.InstantLoggerListener.Log">
<summary>
Occurs when a log is logged to the logger.
</summary>
</member>
<member name="M:Cryville.Common.Logging.InstantLoggerListener.OnLog(System.Int32,System.String,System.String)">
<inheritdoc /> <inheritdoc />
</member> </member>
<member name="T:Cryville.Common.Logging.BufferedLogger"> <member name="T:Cryville.Common.Logging.BufferedLoggerListener">
<summary> <summary>
A <see cref="T:Cryville.Common.Logging.Logger" /> that buffers the logs for enumeration. A <see cref="T:Cryville.Common.Logging.LoggerListener" /> that buffers the logs for enumeration.
</summary> </summary>
</member> </member>
<member name="M:Cryville.Common.Logging.BufferedLogger.#ctor"> <member name="M:Cryville.Common.Logging.BufferedLoggerListener.OnLog(System.Int32,System.String,System.String)">
<summary>
Creates an instance of the <see cref="T:Cryville.Common.Logging.BufferedLogger" /> class.
</summary>
</member>
<member name="M:Cryville.Common.Logging.BufferedLogger.Log(System.Int32,System.String,System.String)">
<inheritdoc /> <inheritdoc />
</member> </member>
<member name="M:Cryville.Common.Logging.BufferedLogger.Enumerate(System.Action{System.Int32,System.String,System.String})"> <member name="M:Cryville.Common.Logging.BufferedLoggerListener.Enumerate(Cryville.Common.Logging.LogHandler)">
<summary> <summary>
Enumerates the buffered logs. Enumerates the buffered logs.
</summary> </summary>
<param name="callback">The callback function to receive the logs.</param> <param name="callback">The callback function to receive the logs.</param>
</member> </member>
<member name="T:Cryville.Common.Logging.StreamLoggerListener">
<summary>
A <see cref="T:Cryville.Common.Logging.LoggerListener" /> that writes logs into a stream.
</summary>
<param name="stream">The stream.</param>
<param name="encoding">The encoding.</param>
</member>
<member name="M:Cryville.Common.Logging.StreamLoggerListener.#ctor(System.IO.Stream,System.Text.Encoding)">
<summary>
A <see cref="T:Cryville.Common.Logging.LoggerListener" /> that writes logs into a stream.
</summary>
<param name="stream">The stream.</param>
<param name="encoding">The encoding.</param>
</member>
<member name="M:Cryville.Common.Logging.StreamLoggerListener.#ctor(System.IO.Stream)">
<summary>
Creates an instance of the <see cref="T:Cryville.Common.Logging.StreamLoggerListener" /> class.
</summary>
<param name="stream">The stream.</param>
</member>
<member name="P:Cryville.Common.Logging.StreamLoggerListener.AutoFlush">
<summary>
Whether to flush the stream every time a log is written.
</summary>
</member>
<member name="M:Cryville.Common.Logging.StreamLoggerListener.OnLog(System.Int32,System.String,System.String)">
<inheritdoc />
</member>
<member name="T:Cryville.Common.Logging.LogHandler">
<summary>
Represents the method that will handle a log.
</summary>
<param name="level">The severity level.</param>
<param name="category">The category.</param>
<param name="message">The message.</param>
</member>
</members> </members>
</doc> </doc>

Binary file not shown.

View File

@@ -537,6 +537,16 @@
反转 W 轴。 反转 W 轴。
</summary> </summary>
</member> </member>
<member name="T:Cryville.Input.Shared">
<summary>
库的共享对象。
</summary>
</member>
<member name="F:Cryville.Input.Shared.Logger">
<summary>
主日志记录器。
</summary>
</member>
<member name="T:Cryville.Input.SimpleInputConsumer"> <member name="T:Cryville.Input.SimpleInputConsumer">
<summary> <summary>
一个接收输入帧的简易输入接收器。 一个接收输入帧的简易输入接收器。