diff --git a/Ryujinx.UI/EmulationController.cs b/Ryujinx.UI/EmulationController.cs
index 23be2d2e65..715c65b64f 100644
--- a/Ryujinx.UI/EmulationController.cs
+++ b/Ryujinx.UI/EmulationController.cs
@@ -12,7 +12,8 @@ namespace Ryujinx.Core
private Thread EmulationThread;
private Switch Ns;
private IGalRenderer Renderer;
- private bool IsPaused = false;
+ private bool IsPaused = false;
+ private bool IsShutDown = false;
public EmutionController(Switch Ns, IGalRenderer Renderer)
{
@@ -33,6 +34,7 @@ namespace Ryujinx.Core
Screen.Closed += (Sender, Args) =>
{
+ if(!IsShutDown)
Stop();
};
@@ -46,6 +48,7 @@ namespace Ryujinx.Core
public void Stop()
{
IsPaused = false;
+ IsShutDown = true;
Ns.Os.ShutDown();
}
diff --git a/Ryujinx.UI/MainWindow.cs b/Ryujinx.UI/MainWindow.cs
index d54e19be05..3298494ff2 100644
--- a/Ryujinx.UI/MainWindow.cs
+++ b/Ryujinx.UI/MainWindow.cs
@@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Gtk;
using GUI = Gtk.Builder.ObjectAttribute;
+using Ryujinx;
using Ryujinx.Audio;
using Ryujinx.Audio.OpenAL;
using Ryujinx.Core;
@@ -17,16 +18,18 @@ namespace Ryujinx.UI
class MainWindow : Window
{
//UI Controls
+ [GUI] Box MainBox;
[GUI] MenuItem LoadFileMenuItem;
[GUI] MenuItem LoadFolderMenuItem;
[GUI] MenuItem ExitMenuItem;
[GUI] MenuItem OptionMenuItem;
- [GUI] MenuItem ShowDebugMenuItem;
[GUI] MenuItem ContinueMenuItem;
[GUI] MenuItem PauseMenuItem;
[GUI] MenuItem StopMenuItem;
[GUI] MenuItem AboutMenuItem;
+ UI.Debugging.LogPage LogPage;
+
bool DebugWindowActive = false;
Core.Switch Ns;
@@ -48,9 +51,7 @@ namespace Ryujinx.UI
using (StreamReader reader = new StreamReader(stream))
{
Icon = new Gdk.Pixbuf(stream);
- }
-
- InitializeSwitch();
+ }
//Register Events
DeleteEvent += Window_DeleteEvent;
@@ -58,7 +59,6 @@ namespace Ryujinx.UI
LoadFolderMenuItem.Activated += LoadFolderMenuItem_Activated;
ExitMenuItem.Activated += ExitMenuItem_Activated;
OptionMenuItem.Activated += OptionMenuItem_Activated;
- ShowDebugMenuItem.Activated += ShowDebugMenuItem_Activated;
ContinueMenuItem.Activated += ContinueMenuItem_Activated;
PauseMenuItem.Activated += PauseMenuItem_Activated;
StopMenuItem.Activated += StopMenuItem_Activated;
@@ -70,6 +70,12 @@ namespace Ryujinx.UI
//Initialize Ryujinx
Console.Title = "Ryujinx Console";
+
+ LogPage = new UI.Debugging.LogPage();
+ MainBox.Add(LogPage.Widget);
+ MainBox.SetChildPacking(LogPage.Widget, false, false, 0, PackType.End);
+
+ InitializeSwitch();
}
private void AboutMenuItem_Activated(object sender, EventArgs e)
@@ -131,6 +137,9 @@ namespace Ryujinx.UI
void InitializeSwitch()
{
+ if(Ns!=null)
+ Ns.Log.Updated -= UI.Debugging.LogPage.LogWriter.WriteLog;
+
Renderer = new OpenGLRenderer();
IAalOutput AudioOut = new OpenALAudioOut();
@@ -138,6 +147,10 @@ namespace Ryujinx.UI
Ns = new Core.Switch(Renderer, AudioOut);
Settings.Read(Ns.Log);
+
+ LogPage.UpdateSettings(Ns.Log);
+
+ Ns.Log.Updated += UI.Debugging.LogPage.LogWriter.WriteLog;
}
private void StopMenuItem_Activated(object sender, EventArgs e)
@@ -165,14 +178,6 @@ namespace Ryujinx.UI
StopMenuItem.Sensitive = true;
}
- private void ShowDebugMenuItem_Activated(object sender, EventArgs e)
- {
- UI.Debugging.Debugger debugger = new UI.Debugging.Debugger();
- debugger.DeleteEvent += Debugger_DeleteEvent;
- DebugWindowActive = true;
- debugger.Show();
- }
-
private void Debugger_DeleteEvent(object o, DeleteEventArgs args)
{
DebugWindowActive = false;
@@ -227,8 +232,11 @@ namespace Ryujinx.UI
void Start()
{
+ EmulationController?.Stop();
+
EmulationController = new EmutionController(Ns, Renderer);
EmulationController.Start();
+
PauseMenuItem.Sensitive = true;
ContinueMenuItem.Sensitive = false;
StopMenuItem.Sensitive = true;
diff --git a/Ryujinx.UI/Settings.cs b/Ryujinx.UI/Settings.cs
index 86d78ea50c..e62f544b21 100644
--- a/Ryujinx.UI/Settings.cs
+++ b/Ryujinx.UI/Settings.cs
@@ -37,7 +37,7 @@ namespace Ryujinx.UI
Configuration.LoggingFilteredClasses = Configuration.LoggingFilteredClasses != null ?
Configuration.LoggingFilteredClasses : string.Empty;
- string[] FilteredLogClasses = Configuration.LoggingFilteredClasses.Split('\n');
+ string[] FilteredLogClasses = Configuration.LoggingFilteredClasses.Trim().Split('\n',StringSplitOptions.RemoveEmptyEntries);
//When the classes are specified on the list, we only
//enable the classes that are on the list.
@@ -68,6 +68,8 @@ namespace Ryujinx.UI
public static void Write(Logger Logger)
{
+ if (Logger == null)
+ Logger = new Logger();
Configuration Configuration = new Configuration
{
EmulatedJoyCon = Config.FakeJoyCon,
diff --git a/Ryujinx.UI/UI/ConfigurationWindow.cs b/Ryujinx.UI/UI/ConfigurationWindow.cs
index a57ede9006..b0b9f2a917 100644
--- a/Ryujinx.UI/UI/ConfigurationWindow.cs
+++ b/Ryujinx.UI/UI/ConfigurationWindow.cs
@@ -35,7 +35,7 @@ namespace Ryujinx.UI.UI
OptionNotebook.AppendPage(GeneralPage.GetWidget(), GeneralLabel);
Label InputLabel = new Label("Input");
InputPage InputPage = new InputPage();
- OptionNotebook.AppendPage(InputPage.GetWidget(), InputLabel);
+ OptionNotebook.AppendPage(InputPage.Widget, InputLabel);
//Register Events
OptionAcceptButton.Clicked += OptionAcceptButton_Clicked;
diff --git a/Ryujinx.UI/UI/Debugging/Debugger.cs b/Ryujinx.UI/UI/Debugging/Debugger.cs
deleted file mode 100644
index 00d24d7002..0000000000
--- a/Ryujinx.UI/UI/Debugging/Debugger.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Gtk;
-using System;
-using System.Reflection;
-using GUI = Gtk.Builder.ObjectAttribute;
-
-
-namespace Ryujinx.UI.UI.Debugging
-{
- public class Debugger : Gtk.Window
- {
- [GUI] Notebook DebuggerNotebook;
-
- public Debugger() : this(new Builder("Debugger.glade")) { }
-
- public Debugger(Builder builder) : base(builder.GetObject("Debugger").Handle)
- {
- builder.Autoconnect(this);
-
- //Add Pages
- Label LogLabel = new Label("Log");
- LogPage LogPage = new LogPage();
- DebuggerNotebook.AppendPage(LogPage.Widget, LogLabel);
- }
- }
-}
diff --git a/Ryujinx.UI/UI/Debugging/Debugger.glade b/Ryujinx.UI/UI/Debugging/Debugger.glade
deleted file mode 100644
index e5283c9f5f..0000000000
--- a/Ryujinx.UI/UI/Debugging/Debugger.glade
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
diff --git a/Ryujinx.UI/UI/Debugging/LogPage.cs b/Ryujinx.UI/UI/Debugging/LogPage.cs
index 4856c0fcdb..e037fcde10 100644
--- a/Ryujinx.UI/UI/Debugging/LogPage.cs
+++ b/Ryujinx.UI/UI/Debugging/LogPage.cs
@@ -3,6 +3,7 @@ using System;
using System.IO;
using System.Reflection;
using System.Text;
+using System.Threading;
using Ryujinx.Core.Logging;
using GUI = Gtk.Builder.ObjectAttribute;
namespace Ryujinx.UI.UI.Debugging
@@ -43,6 +44,7 @@ namespace Ryujinx.UI.UI.Debugging
//Style the log text box
LogTextView.StyleContext.AddProvider(provider,1000);
+ Widget.StyleContext.AddClass("border");
//Register Events
InfoLogEnable.Toggled += InfoLogEnable_Toggled;
@@ -161,6 +163,7 @@ namespace Ryujinx.UI.UI.Debugging
public override Encoding Encoding => Encoding.UTF8;
public TextBuffer LogBuffer { get; private set; }
private TextIter EndIter;
+ private static object LogLock = new object();
public LogWriter()
{
@@ -177,22 +180,42 @@ namespace Ryujinx.UI.UI.Debugging
LogBuffer.TagTable.Add(new TextTag("DarkGray") { Foreground = "darkgray" });
}
- public override void Write(string value)
+ public void WriteLog(object sender, LogEventArgs e)
{
- string consoleColor = Console.ForegroundColor.ToString();
- Gtk.Application.Invoke(delegate
+ lock (LogLock)
{
- LogBuffer.InsertWithTagsByName(ref EndIter, value, consoleColor);
- });
- }
+ string FormattedTime = e.Time.ToString(@"hh\:mm\:ss\.fff");
+
+ string CurrentThread = Thread.CurrentThread.ManagedThreadId.ToString("d4");
+
+ string Message = FormattedTime + " | " + CurrentThread + " " + e.Message;
+
+ string ColorTag = "White";
+
+ switch (e.Level)
+ {
+ case LogLevel.Debug:
+ ColorTag = "Gray";
+ break;
+ case LogLevel.Error:
+ ColorTag = "Red";
+ break;
+ case LogLevel.Info:
+ ColorTag = "White";
+ break;
+ case LogLevel.Stub:
+ ColorTag = "DarkGray";
+ break;
+ case LogLevel.Warning:
+ ColorTag = "Yellow";
+ break;
+ }
+ Gtk.Application.Invoke(delegate
+ {
+ LogBuffer.InsertWithTagsByName(ref EndIter, Message + Environment.NewLine, ColorTag);
+ });
+ }
- public override void WriteLine(string value)
- {
- string consoleColor = Console.ForegroundColor.ToString();
- Gtk.Application.Invoke(delegate
- {
- LogBuffer.InsertWithTagsByName(ref EndIter, value + Environment.NewLine, consoleColor);
- });
}
diff --git a/Ryujinx.UI/UI/Debugging/LogPage.glade b/Ryujinx.UI/UI/Debugging/LogPage.glade
index 395756b467..7475094f32 100644
--- a/Ryujinx.UI/UI/Debugging/LogPage.glade
+++ b/Ryujinx.UI/UI/Debugging/LogPage.glade
@@ -3,6 +3,7 @@
+ 300
True
False
@@ -15,6 +16,9 @@
10
10
in
+ 0
+ 350
+ 350
True
True
@@ -22,6 +26,9 @@
400
True
True
+ 5
+ natural
+ natural
False
word