-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.6.0.37 - text console logging enhancement (#779)
- [Fix] Saves.db3 failures no longer cause crashes - [Fix] Prevent crashes if FX Script.lua has Lua errors - [Fix] Gameplay debug info now shows at the right place - [Feat] LogNotification messages now show on screen top (FX and BG Lua script error, preimage-not-found warning, complex number format warning, modal-window-not-closed error, TJA parsing error) - [Feat] BG Lua script errors are now logged - [Feat] TJA parsing errors are now logged and as warnings. - [Feat] TextConsole messages now respect to font height
- Loading branch information
1 parent
912c8d1
commit 1e9fd20
Showing
21 changed files
with
164 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,25 @@ | ||
using System.Diagnostics; | ||
using FDK; | ||
|
||
namespace OpenTaiko; | ||
|
||
internal class LogNotification { | ||
private static Queue<CLogNotification> Notifications = new Queue<CLogNotification>(); | ||
|
||
public enum ENotificationType { | ||
EINFO, | ||
ESUCCESS, | ||
EWARNING, | ||
EERROR, | ||
} | ||
|
||
public class CLogNotification { | ||
public CLogNotification(ENotificationType nt, string msg) { | ||
NotificationType = nt; | ||
Message = msg; | ||
} | ||
|
||
public ENotificationType NotificationType = ENotificationType.EINFO; | ||
public string Message = ""; | ||
public CCounter LifeTime = new CCounter(0, 1000, 1, OpenTaiko.Timer); | ||
} | ||
|
||
|
||
public static void PopError(string message) { | ||
Notifications.Enqueue(new CLogNotification(ENotificationType.EERROR, message)); | ||
OpenTaiko.VisualLogManager?.PushCard(TraceEventType.Error, message); | ||
Trace.TraceError("<Runtime Error>: " + message); | ||
} | ||
|
||
public static void PopWarning(string message) { | ||
Notifications.Enqueue(new CLogNotification(ENotificationType.EWARNING, message)); | ||
OpenTaiko.VisualLogManager?.PushCard(TraceEventType.Warning, message); | ||
Trace.TraceWarning("<Runtime Warning>: " + message); | ||
} | ||
|
||
public static void PopSuccess(string message) { | ||
Notifications.Enqueue(new CLogNotification(ENotificationType.ESUCCESS, message)); | ||
OpenTaiko.VisualLogManager?.PushCard(TraceEventType.Verbose, message); | ||
Trace.TraceInformation("<Runtime Success>: " + message); | ||
} | ||
|
||
public static void PopInfo(string message) { | ||
Notifications.Enqueue(new CLogNotification(ENotificationType.EINFO, message)); | ||
OpenTaiko.VisualLogManager?.PushCard(TraceEventType.Information, message); | ||
Trace.TraceInformation("<Runtime Info>: " + message); | ||
} | ||
|
||
public static void Display() { | ||
while (Notifications.Count > 0 && Notifications.Peek().LifeTime.IsEnded) Notifications.Dequeue(); | ||
// Add an optimized method to display the notifications here | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,55 @@ | ||
using FDK; | ||
using System.Diagnostics; | ||
using FDK; | ||
|
||
namespace OpenTaiko; | ||
|
||
class CVisualLogManager { | ||
public enum ELogCardType { | ||
LogInfo, | ||
LogWarning, | ||
LogError | ||
} | ||
|
||
class LogCard { | ||
public LogCard(ELogCardType type, string message) { | ||
public LogCard(TraceEventType type, string message) { | ||
lct = type; | ||
msg = message; | ||
timeSinceCreation = new CCounter(0, 10000, 1, OpenTaiko.Timer); | ||
InitTimeSinceCreation(); | ||
} | ||
|
||
public void Display(int screenPosition) { | ||
private void InitTimeSinceCreation() | ||
=> timeSinceCreation = new CCounter(0, 10000, 1, OpenTaiko.Timer); | ||
|
||
public int Display(int y) { | ||
if (timeSinceCreation.IsStoped) { | ||
// OpenTaiko.Timer was null. Reinitialize. | ||
InitTimeSinceCreation(); | ||
} | ||
timeSinceCreation.Tick(); | ||
|
||
// Display stuff here | ||
|
||
int x = 0; | ||
int y = 0 + (40 * screenPosition); | ||
|
||
OpenTaiko.actTextConsole.Print(x, y, CTextConsole.EFontType.Cyan, msg); | ||
if (OpenTaiko.actTextConsole != null) { | ||
y = OpenTaiko.actTextConsole.Print(0, y, CTextConsole.EFontType.Cyan, msg).y; | ||
y += OpenTaiko.actTextConsole.fontHeight + 24; | ||
} | ||
return y; | ||
} | ||
|
||
public bool IsExpired() { | ||
return timeSinceCreation.IsEnded; | ||
} | ||
|
||
private CCounter timeSinceCreation; | ||
private ELogCardType lct; | ||
private TraceEventType lct; | ||
private string msg; | ||
} | ||
|
||
public void PushCard(ELogCardType lct, string msg) { | ||
cards.Add(new LogCard(lct, msg)); | ||
public void PushCard(TraceEventType lct, string msg) { | ||
cards.Enqueue(new LogCard(lct, msg)); | ||
} | ||
|
||
public void Display() { | ||
for (int i = 0; i < cards.Count; i++) | ||
cards[i].Display(i); | ||
cards.RemoveAll(card => card.IsExpired()); | ||
while (this.cards.TryPeek(out var card) && card.IsExpired()) { | ||
this.cards.Dequeue(); | ||
} | ||
int y = 0; | ||
foreach (var card in this.cards) | ||
y = card.Display(y); | ||
} | ||
|
||
private List<LogCard> cards = new List<LogCard>(); | ||
private readonly Queue<LogCard> cards = new Queue<LogCard>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.