Update Cryville.Common.Logging.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using Cryville.Common.Logging;
|
||||
using Cryville.Crtr.Extension;
|
||||
using Mono.Cecil;
|
||||
using System;
|
||||
@@ -36,7 +35,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
modules.Enqueue(new ModuleItem(extension.OpenRead()));
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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) {
|
||||
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 {
|
||||
module.Definition.Dispose();
|
||||
@@ -89,7 +88,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
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.Stream.Dispose();
|
||||
}
|
||||
@@ -128,10 +127,10 @@ namespace Cryville.Crtr.Browsing {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
|
||||
namespace Cryville.Crtr.Browsing {
|
||||
internal class LegacyResourceManager : IPathedResourceManager<ChartDetail> {
|
||||
@@ -41,7 +40,7 @@ namespace Cryville.Crtr.Browsing {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -235,13 +234,13 @@ namespace Cryville.Crtr.Browsing {
|
||||
|
||||
void LogAndPopup(int level, string format, params object[] args) {
|
||||
var msg = string.Format(format, args);
|
||||
Logger.Log("main", level, "Resource", msg);
|
||||
Game.MainLogger.Log(level, "Resource", msg);
|
||||
Popup.Create(msg);
|
||||
}
|
||||
|
||||
void LogAndPopupExtra(int level, object extraLog, string format, params object[] 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);
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Buffers;
|
||||
using Cryville.Common.Logging;
|
||||
using Cryville.Crtr.Config;
|
||||
using Cryville.Crtr.Event;
|
||||
using Cryville.Crtr.Ruleset;
|
||||
@@ -18,7 +19,6 @@ using UnityEngine.Networking;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.Scripting;
|
||||
using Coroutine = Cryville.Common.Coroutine;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
using Stopwatch = System.Diagnostics.Stopwatch;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
@@ -44,6 +44,7 @@ namespace Cryville.Crtr {
|
||||
static bool initialized;
|
||||
TextMeshProUGUI logs;
|
||||
TextMeshProUGUI status;
|
||||
BufferedLoggerListener loggerListener;
|
||||
|
||||
static Vector2 screenSize;
|
||||
public static Rect hitRect;
|
||||
@@ -67,7 +68,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
#region MonoBehaviour
|
||||
void Start() {
|
||||
d_addLogEntry = new Action<int, string, string>(AddLogEntry);
|
||||
d_addLogEntry = AddLogEntry;
|
||||
|
||||
var logobj = GameObject.Find("Logs");
|
||||
if (logobj != null)
|
||||
@@ -80,6 +81,8 @@ namespace Cryville.Crtr {
|
||||
OnSettingsUpdate();
|
||||
|
||||
status = GameObject.Find("Status").GetComponent<TextMeshProUGUI>();
|
||||
loggerListener = new BufferedLoggerListener();
|
||||
Game.MainLogger.AddListener(loggerListener);
|
||||
|
||||
try {
|
||||
Play();
|
||||
@@ -101,6 +104,8 @@ namespace Cryville.Crtr {
|
||||
if (loadThread != null) loadThread.Abort();
|
||||
if (inputProxy != null) inputProxy.Dispose();
|
||||
if (texs != null) foreach (var t in texs) Texture.Destroy(t.Value);
|
||||
Game.MainLogger.RemoveListener(loggerListener);
|
||||
loggerListener.Dispose();
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
@@ -127,7 +132,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
else if (loadThread != null) LoadUpdate();
|
||||
if (logEnabled) LogUpdate();
|
||||
else Game.MainLogger.Enumerate((level, module, msg) => { });
|
||||
else loggerListener.Enumerate((level, module, msg) => { });
|
||||
}
|
||||
void GameUpdate() {
|
||||
try {
|
||||
@@ -180,7 +185,7 @@ namespace Cryville.Crtr {
|
||||
if (!texloaddone) texLoader.Tick(1.0 / Application.targetFrameRate);
|
||||
if (!loadThread.IsAlive) {
|
||||
if (threadException != null) {
|
||||
Logger.Log("main", 4, "Load/MainThread", "Load failed");
|
||||
Game.MainLogger.Log(4, "Load/MainThread", "Load failed");
|
||||
loadThread = null;
|
||||
Popup.CreateException(threadException);
|
||||
ReturnToMenu();
|
||||
@@ -201,7 +206,7 @@ namespace Cryville.Crtr {
|
||||
readonly StringBuffer logsbuf = new StringBuffer();
|
||||
readonly List<string> logEntries = new List<string>();
|
||||
int logsLength = 0;
|
||||
Action<int, string, string> d_addLogEntry;
|
||||
LogHandler d_addLogEntry;
|
||||
void AddLogEntry(int level, string module, string msg) {
|
||||
string color;
|
||||
switch (level) {
|
||||
@@ -222,7 +227,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
void LogUpdate() {
|
||||
logsbuf.Clear();
|
||||
Game.MainLogger.Enumerate(d_addLogEntry);
|
||||
loggerListener.Enumerate(d_addLogEntry);
|
||||
while (logsLength >= 4096) {
|
||||
logsLength -= logEntries[0].Length;
|
||||
logEntries.RemoveAt(0);
|
||||
@@ -335,7 +340,7 @@ namespace Cryville.Crtr {
|
||||
texloaddone = true;
|
||||
texLoader = null;
|
||||
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 {
|
||||
@@ -433,7 +438,7 @@ namespace Cryville.Crtr {
|
||||
skinFile = skinFile,
|
||||
});
|
||||
|
||||
Logger.Log("main", 0, "Load/MainThread", "Loading textures...");
|
||||
Game.MainLogger.Log(0, "Load/MainThread", "Loading textures...");
|
||||
frames = new Dictionary<string, SpriteFrame>();
|
||||
texs = new Dictionary<string, Texture2D>();
|
||||
var skinDir = skinFile.Directory.FullName;
|
||||
@@ -469,7 +474,7 @@ namespace Cryville.Crtr {
|
||||
var tex = texHandler.texture;
|
||||
tex.wrapMode = TextureWrapMode.Clamp;
|
||||
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 {
|
||||
frames.Add(name, new SpriteFrame(tex));
|
||||
@@ -477,7 +482,7 @@ namespace Cryville.Crtr {
|
||||
texs.Add(name, tex);
|
||||
}
|
||||
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();
|
||||
texHandler.Dispose();
|
||||
@@ -493,39 +498,39 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
texloaddone = true;
|
||||
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;
|
||||
}
|
||||
|
||||
IEnumerator<float> Prehandle() {
|
||||
Stopwatch timer = new Stopwatch();
|
||||
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();
|
||||
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)) {
|
||||
while (pbus.Time != double.PositiveInfinity) {
|
||||
pbus.ForwardOnce();
|
||||
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();
|
||||
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);
|
||||
bbus.ForwardByTime(startOffset);
|
||||
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();
|
||||
Camera.main.cullingMask |= 1;
|
||||
GC.Collect();
|
||||
if (disableGC) GarbageCollector.GCMode = GarbageCollector.Mode.Disabled;
|
||||
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) {
|
||||
logEntries.Clear();
|
||||
logsLength = 0;
|
||||
Game.MainLogger.Enumerate((level, module, msg) => { });
|
||||
loggerListener.Enumerate((level, module, msg) => { });
|
||||
logs.text = "";
|
||||
}
|
||||
Game.AudioSequencer.Playing = true;
|
||||
@@ -536,7 +541,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
public void Stop() {
|
||||
try {
|
||||
Logger.Log("main", 1, "Game", "Stopping");
|
||||
Game.MainLogger.Log(1, "Game", "Stopping");
|
||||
Game.AudioClient.Start();
|
||||
Game.AudioSession = Game.AudioSequencer.NewSession();
|
||||
Camera.main.cullingMask &= ~1;
|
||||
@@ -555,7 +560,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
PdtEvaluator.Instance.Reset();
|
||||
motionRegistry = null;
|
||||
Logger.Log("main", 1, "Game", "Stopped");
|
||||
Game.MainLogger.Log(1, "Game", "Stopped");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (!logEnabled) ToggleLogs();
|
||||
@@ -597,7 +602,7 @@ namespace Cryville.Crtr {
|
||||
workerTimer.Start();
|
||||
LoadChart(info);
|
||||
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) {
|
||||
Game.LogException("Load/WorkerThread", "An error occurred while loading the data", ex);
|
||||
@@ -606,7 +611,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
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> {
|
||||
{ new Identifier("pt") , new MotionRegistry(typeof(Vec2)) },
|
||||
@@ -627,28 +632,28 @@ namespace Cryville.Crtr {
|
||||
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);
|
||||
|
||||
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);
|
||||
batcher.Forward();
|
||||
cbus = batcher.Batch(); loadPregress = .30f;
|
||||
|
||||
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);
|
||||
PdtEvaluator.Instance.ContextJudge = judge;
|
||||
|
||||
inputProxy = new InputProxy(pruleset, judge, screenSize);
|
||||
inputProxy.LoadFrom(_rscfg.inputs);
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
cbus.RootState.AttachHandler(ch);
|
||||
foreach (var gs in cbus.RootState.Children) {
|
||||
@@ -666,16 +671,16 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
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)) {
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
loadPregress = 1;
|
||||
}
|
||||
@@ -683,7 +688,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
void LoadRuleset(FileInfo file) {
|
||||
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)) {
|
||||
ruleset = JsonConvert.DeserializeObject<RulesetDefinition>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
@@ -701,7 +706,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
void LoadSkin(FileInfo file) {
|
||||
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);
|
||||
pskin = skin.Root;
|
||||
pskin.Optimize(PdtEvaluator.Instance);
|
||||
|
@@ -5,7 +5,6 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
|
||||
namespace Cryville.Crtr.Config.UI {
|
||||
public class ConfigPanelMaster : MonoBehaviour {
|
||||
@@ -74,7 +73,7 @@ namespace Cryville.Crtr.Config.UI {
|
||||
}
|
||||
catch (Exception 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();
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@
|
||||
#if COMPILE
|
||||
using Discord;
|
||||
using System;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
@@ -25,7 +24,7 @@ namespace Cryville.Crtr {
|
||||
launchTime = (long)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
|
||||
try {
|
||||
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();
|
||||
SetIdle();
|
||||
}
|
||||
@@ -34,7 +33,7 @@ namespace Cryville.Crtr {
|
||||
dc.Dispose();
|
||||
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) {
|
||||
dc.Dispose();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,9 @@ namespace Cryville.Crtr {
|
||||
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;
|
||||
public static void Init() {
|
||||
@@ -53,25 +55,41 @@ namespace Cryville.Crtr {
|
||||
bool _bcflag = new Version(Settings.Default.LastRunVersion) < new Version("0.4");
|
||||
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;
|
||||
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
|
||||
JavaVMManager.Register(JniInvoke.Instance);
|
||||
#endif
|
||||
@@ -120,14 +138,14 @@ namespace Cryville.Crtr {
|
||||
AudioManager = EngineBuilder.Create();
|
||||
if (AudioManager == null) {
|
||||
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 {
|
||||
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);
|
||||
AudioClient = AudioDevice.Connect(AudioDevice.DefaultFormat, AudioDevice.MinimumBufferSize + AudioDevice.BurstSize);
|
||||
Logger.Log(
|
||||
"main", 1, "Audio",
|
||||
MainLogger.Log(
|
||||
1, "Audio",
|
||||
"Audio Output = {{ Name = \"{0}\", BurstSize = {1}, Format = {2}, BufferSize = {3} }}",
|
||||
AudioDevice.Name, AudioDevice.BurstSize, AudioClient.Format, AudioClient.BufferSize
|
||||
);
|
||||
@@ -140,8 +158,8 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
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);
|
||||
Logger.Log("main", 2, "Audio", "Trying to use fallback audio engines");
|
||||
MainLogger.Log(4, "Audio", "An error occurred when initializing the audio engine: {0}", ex);
|
||||
MainLogger.Log(2, "Audio", "Trying to use fallback audio engines");
|
||||
EngineBuilder.Engines.Remove(AudioManager.GetType());
|
||||
}
|
||||
}
|
||||
@@ -159,7 +177,7 @@ namespace Cryville.Crtr {
|
||||
Settings.Default.LastRunVersion = Application.version;
|
||||
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")) {
|
||||
IdValidity.Load(LoadXmlDocument(res));
|
||||
}
|
||||
@@ -171,7 +189,7 @@ namespace Cryville.Crtr {
|
||||
};
|
||||
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);
|
||||
@@ -194,7 +212,7 @@ namespace Cryville.Crtr {
|
||||
if (_shutdown) return;
|
||||
_shutdown = true;
|
||||
|
||||
Logger.Log("main", 1, "Game", "Shutting down");
|
||||
MainLogger.Log(1, "Game", "Shutting down");
|
||||
try {
|
||||
AudioClient.Dispose();
|
||||
AudioSequencer.Dispose();
|
||||
@@ -205,15 +223,16 @@ namespace Cryville.Crtr {
|
||||
LogException("Game", "An error occurred while shutting down", ex);
|
||||
}
|
||||
finally {
|
||||
Logger.Close();
|
||||
_logWriter.Dispose();
|
||||
_logFileStream.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
switch (type) {
|
||||
case LogType.Log: l = 1; break;
|
||||
@@ -223,7 +242,7 @@ namespace Cryville.Crtr {
|
||||
case LogType.Exception: l = 4; 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() {
|
||||
|
@@ -13,7 +13,6 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
using ThreadPriority = System.Threading.ThreadPriority;
|
||||
|
||||
namespace Cryville.Crtr.Network {
|
||||
@@ -39,10 +38,10 @@ namespace Cryville.Crtr.Network {
|
||||
void ThreadLogic() {
|
||||
try {
|
||||
CheckVersion();
|
||||
Logger.Log("main", 0, "Network", "Update checker exited normally");
|
||||
Game.MainLogger.Log(0, "Network", "Update checker exited normally");
|
||||
}
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@ using System.Runtime.Serialization;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
using RVector4 = UnityEngine.Vector4;
|
||||
|
||||
namespace Cryville.Crtr.Ruleset {
|
||||
@@ -48,7 +47,7 @@ namespace Cryville.Crtr.Ruleset {
|
||||
foreach (var cfg in config) {
|
||||
var handler = Game.InputManager.GetHandlerByTypeName(cfg.Value.handler);
|
||||
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;
|
||||
}
|
||||
Set(new InputProxyEntry {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using Cryville.Common;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
|
||||
namespace Cryville.Crtr.Skin.Components {
|
||||
public class SkinAnimation : SkinComponent {
|
||||
@@ -30,7 +29,7 @@ namespace Cryville.Crtr.Skin.Components {
|
||||
var id = new Identifier(value);
|
||||
AnimationSpan 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;
|
||||
return;
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
|
||||
namespace Cryville.Crtr.Skin.Components {
|
||||
public class SpriteInfo {
|
||||
@@ -40,7 +39,7 @@ namespace Cryville.Crtr.Skin.Components {
|
||||
Frame = ChartPlayer.frames[FrameName];
|
||||
}
|
||||
else {
|
||||
Logger.Log("main", 4, "Skin", "Texture {0} not found", FrameName);
|
||||
Game.MainLogger.Log(4, "Skin", "Texture {0} not found", FrameName);
|
||||
Frame = null;
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ using Cryville.Common.Pdt;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
|
||||
namespace Cryville.Crtr.Skin.Components {
|
||||
public class SpriteText : SpriteBase {
|
||||
@@ -120,7 +119,7 @@ namespace Cryville.Crtr.Skin.Components {
|
||||
foreach (var c in m_value) {
|
||||
SpriteInfo 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;
|
||||
}
|
||||
var t = f.Frame.Texture;
|
||||
|
Reference in New Issue
Block a user