fix log page, added logpage to main window

This commit is contained in:
emmaus 2018-04-25 22:03:11 +00:00
parent c4c0ad5837
commit c24f4b03a1
11 changed files with 132 additions and 119 deletions

View file

@ -12,7 +12,8 @@ namespace Ryujinx.Core
private Thread EmulationThread; private Thread EmulationThread;
private Switch Ns; private Switch Ns;
private IGalRenderer Renderer; private IGalRenderer Renderer;
private bool IsPaused = false; private bool IsPaused = false;
private bool IsShutDown = false;
public EmutionController(Switch Ns, IGalRenderer Renderer) public EmutionController(Switch Ns, IGalRenderer Renderer)
{ {
@ -33,6 +34,7 @@ namespace Ryujinx.Core
Screen.Closed += (Sender, Args) => Screen.Closed += (Sender, Args) =>
{ {
if(!IsShutDown)
Stop(); Stop();
}; };
@ -46,6 +48,7 @@ namespace Ryujinx.Core
public void Stop() public void Stop()
{ {
IsPaused = false; IsPaused = false;
IsShutDown = true;
Ns.Os.ShutDown(); Ns.Os.ShutDown();
} }

View file

@ -2,6 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Gtk; using Gtk;
using GUI = Gtk.Builder.ObjectAttribute; using GUI = Gtk.Builder.ObjectAttribute;
using Ryujinx;
using Ryujinx.Audio; using Ryujinx.Audio;
using Ryujinx.Audio.OpenAL; using Ryujinx.Audio.OpenAL;
using Ryujinx.Core; using Ryujinx.Core;
@ -17,16 +18,18 @@ namespace Ryujinx.UI
class MainWindow : Window class MainWindow : Window
{ {
//UI Controls //UI Controls
[GUI] Box MainBox;
[GUI] MenuItem LoadFileMenuItem; [GUI] MenuItem LoadFileMenuItem;
[GUI] MenuItem LoadFolderMenuItem; [GUI] MenuItem LoadFolderMenuItem;
[GUI] MenuItem ExitMenuItem; [GUI] MenuItem ExitMenuItem;
[GUI] MenuItem OptionMenuItem; [GUI] MenuItem OptionMenuItem;
[GUI] MenuItem ShowDebugMenuItem;
[GUI] MenuItem ContinueMenuItem; [GUI] MenuItem ContinueMenuItem;
[GUI] MenuItem PauseMenuItem; [GUI] MenuItem PauseMenuItem;
[GUI] MenuItem StopMenuItem; [GUI] MenuItem StopMenuItem;
[GUI] MenuItem AboutMenuItem; [GUI] MenuItem AboutMenuItem;
UI.Debugging.LogPage LogPage;
bool DebugWindowActive = false; bool DebugWindowActive = false;
Core.Switch Ns; Core.Switch Ns;
@ -50,15 +53,12 @@ namespace Ryujinx.UI
Icon = new Gdk.Pixbuf(stream); Icon = new Gdk.Pixbuf(stream);
} }
InitializeSwitch();
//Register Events //Register Events
DeleteEvent += Window_DeleteEvent; DeleteEvent += Window_DeleteEvent;
LoadFileMenuItem.Activated += LoadFileMenuItem_Activated; LoadFileMenuItem.Activated += LoadFileMenuItem_Activated;
LoadFolderMenuItem.Activated += LoadFolderMenuItem_Activated; LoadFolderMenuItem.Activated += LoadFolderMenuItem_Activated;
ExitMenuItem.Activated += ExitMenuItem_Activated; ExitMenuItem.Activated += ExitMenuItem_Activated;
OptionMenuItem.Activated += OptionMenuItem_Activated; OptionMenuItem.Activated += OptionMenuItem_Activated;
ShowDebugMenuItem.Activated += ShowDebugMenuItem_Activated;
ContinueMenuItem.Activated += ContinueMenuItem_Activated; ContinueMenuItem.Activated += ContinueMenuItem_Activated;
PauseMenuItem.Activated += PauseMenuItem_Activated; PauseMenuItem.Activated += PauseMenuItem_Activated;
StopMenuItem.Activated += StopMenuItem_Activated; StopMenuItem.Activated += StopMenuItem_Activated;
@ -70,6 +70,12 @@ namespace Ryujinx.UI
//Initialize Ryujinx //Initialize Ryujinx
Console.Title = "Ryujinx Console"; 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) private void AboutMenuItem_Activated(object sender, EventArgs e)
@ -131,6 +137,9 @@ namespace Ryujinx.UI
void InitializeSwitch() void InitializeSwitch()
{ {
if(Ns!=null)
Ns.Log.Updated -= UI.Debugging.LogPage.LogWriter.WriteLog;
Renderer = new OpenGLRenderer(); Renderer = new OpenGLRenderer();
IAalOutput AudioOut = new OpenALAudioOut(); IAalOutput AudioOut = new OpenALAudioOut();
@ -138,6 +147,10 @@ namespace Ryujinx.UI
Ns = new Core.Switch(Renderer, AudioOut); Ns = new Core.Switch(Renderer, AudioOut);
Settings.Read(Ns.Log); Settings.Read(Ns.Log);
LogPage.UpdateSettings(Ns.Log);
Ns.Log.Updated += UI.Debugging.LogPage.LogWriter.WriteLog;
} }
private void StopMenuItem_Activated(object sender, EventArgs e) private void StopMenuItem_Activated(object sender, EventArgs e)
@ -165,14 +178,6 @@ namespace Ryujinx.UI
StopMenuItem.Sensitive = true; 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) private void Debugger_DeleteEvent(object o, DeleteEventArgs args)
{ {
DebugWindowActive = false; DebugWindowActive = false;
@ -227,8 +232,11 @@ namespace Ryujinx.UI
void Start() void Start()
{ {
EmulationController?.Stop();
EmulationController = new EmutionController(Ns, Renderer); EmulationController = new EmutionController(Ns, Renderer);
EmulationController.Start(); EmulationController.Start();
PauseMenuItem.Sensitive = true; PauseMenuItem.Sensitive = true;
ContinueMenuItem.Sensitive = false; ContinueMenuItem.Sensitive = false;
StopMenuItem.Sensitive = true; StopMenuItem.Sensitive = true;

View file

@ -37,7 +37,7 @@ namespace Ryujinx.UI
Configuration.LoggingFilteredClasses = Configuration.LoggingFilteredClasses != null ? Configuration.LoggingFilteredClasses = Configuration.LoggingFilteredClasses != null ?
Configuration.LoggingFilteredClasses : string.Empty; 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 //When the classes are specified on the list, we only
//enable the classes that are on the list. //enable the classes that are on the list.
@ -68,6 +68,8 @@ namespace Ryujinx.UI
public static void Write(Logger Logger) public static void Write(Logger Logger)
{ {
if (Logger == null)
Logger = new Logger();
Configuration Configuration = new Configuration Configuration Configuration = new Configuration
{ {
EmulatedJoyCon = Config.FakeJoyCon, EmulatedJoyCon = Config.FakeJoyCon,

View file

@ -35,7 +35,7 @@ namespace Ryujinx.UI.UI
OptionNotebook.AppendPage(GeneralPage.GetWidget(), GeneralLabel); OptionNotebook.AppendPage(GeneralPage.GetWidget(), GeneralLabel);
Label InputLabel = new Label("Input"); Label InputLabel = new Label("Input");
InputPage InputPage = new InputPage(); InputPage InputPage = new InputPage();
OptionNotebook.AppendPage(InputPage.GetWidget(), InputLabel); OptionNotebook.AppendPage(InputPage.Widget, InputLabel);
//Register Events //Register Events
OptionAcceptButton.Clicked += OptionAcceptButton_Clicked; OptionAcceptButton.Clicked += OptionAcceptButton_Clicked;

View file

@ -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);
}
}
}

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.21.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="Debugger">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Debugger</property>
<child>
<object class="GtkNotebook" id="DebuggerNotebook">
<property name="height_request">500</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
</child>
<child type="titlebar">
<placeholder/>
</child>
</object>
</interface>

View file

@ -3,6 +3,7 @@ using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading;
using Ryujinx.Core.Logging; using Ryujinx.Core.Logging;
using GUI = Gtk.Builder.ObjectAttribute; using GUI = Gtk.Builder.ObjectAttribute;
namespace Ryujinx.UI.UI.Debugging namespace Ryujinx.UI.UI.Debugging
@ -43,6 +44,7 @@ namespace Ryujinx.UI.UI.Debugging
//Style the log text box //Style the log text box
LogTextView.StyleContext.AddProvider(provider,1000); LogTextView.StyleContext.AddProvider(provider,1000);
Widget.StyleContext.AddClass("border");
//Register Events //Register Events
InfoLogEnable.Toggled += InfoLogEnable_Toggled; InfoLogEnable.Toggled += InfoLogEnable_Toggled;
@ -161,6 +163,7 @@ namespace Ryujinx.UI.UI.Debugging
public override Encoding Encoding => Encoding.UTF8; public override Encoding Encoding => Encoding.UTF8;
public TextBuffer LogBuffer { get; private set; } public TextBuffer LogBuffer { get; private set; }
private TextIter EndIter; private TextIter EndIter;
private static object LogLock = new object();
public LogWriter() public LogWriter()
{ {
@ -177,22 +180,42 @@ namespace Ryujinx.UI.UI.Debugging
LogBuffer.TagTable.Add(new TextTag("DarkGray") { Foreground = "darkgray" }); 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(); lock (LogLock)
Gtk.Application.Invoke(delegate
{ {
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);
});
} }

View file

@ -3,6 +3,7 @@
<interface> <interface>
<requires lib="gtk+" version="3.20"/> <requires lib="gtk+" version="3.20"/>
<object class="GtkBox" id="MainBox"> <object class="GtkBox" id="MainBox">
<property name="height_request">300</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child> <child>
@ -15,6 +16,9 @@
<property name="margin_top">10</property> <property name="margin_top">10</property>
<property name="margin_bottom">10</property> <property name="margin_bottom">10</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<property name="min_content_width">0</property>
<property name="min_content_height">350</property>
<property name="max_content_height">350</property>
<property name="propagate_natural_width">True</property> <property name="propagate_natural_width">True</property>
<property name="propagate_natural_height">True</property> <property name="propagate_natural_height">True</property>
<child> <child>
@ -22,6 +26,9 @@
<property name="width_request">400</property> <property name="width_request">400</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="border_width">5</property>
<property name="hscroll_policy">natural</property>
<property name="vscroll_policy">natural</property>
<property name="editable">False</property> <property name="editable">False</property>
<property name="wrap_mode">word</property> <property name="wrap_mode">word</property>
<style> <style>
@ -38,11 +45,12 @@
</child> </child>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="width_request">200</property> <property name="width_request">-1</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_left">5</property> <property name="margin_left">5</property>
<property name="margin_right">5</property> <property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property> <property name="margin_bottom">5</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
@ -107,34 +115,6 @@
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="TraceLogEnable">
<property name="label" translatable="yes">Trace</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="FatalLogEnable">
<property name="label" translatable="yes">Fatal</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child> <child>
<object class="GtkCheckButton" id="StubLogEnable"> <object class="GtkCheckButton" id="StubLogEnable">
<property name="label" translatable="yes">Stub</property> <property name="label" translatable="yes">Stub</property>
@ -181,6 +161,20 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">10</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkFrame"> <object class="GtkFrame">
<property name="visible">True</property> <property name="visible">True</property>
@ -192,6 +186,7 @@
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
<object class="GtkAlignment"> <object class="GtkAlignment">
<property name="width_request">200</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
@ -225,12 +220,12 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="SaveButton"> <object class="GtkButton" id="SaveButton">
<property name="label" translatable="yes">button</property> <property name="label" translatable="yes">Save</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
@ -240,14 +235,14 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">3</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>

View file

@ -9,6 +9,8 @@ namespace Ryujinx.UI.UI
{ {
public class InputPage : Notebook public class InputPage : Notebook
{ {
public Widget Widget => Notebook;
Notebook Notebook; Notebook Notebook;
//Buttons //Buttons
[GUI] Button LeftAnalogUp; [GUI] Button LeftAnalogUp;
@ -487,9 +489,6 @@ namespace Ryujinx.UI.UI
IsPressed = false; IsPressed = false;
} }
public Widget GetWidget()
{
return Notebook;
}
} }
} }

View file

@ -28,6 +28,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="baseline_position">bottom</property>
<child> <child>
<object class="GtkMenuBar" id="MainMenu"> <object class="GtkMenuBar" id="MainMenu">
<property name="visible">True</property> <property name="visible">True</property>
@ -143,14 +144,6 @@
<object class="GtkMenu"> <object class="GtkMenu">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="ShowDebugMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Show Debug Window</property>
<property name="use_underline">True</property>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>
@ -184,6 +177,35 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>

View file

@ -3,3 +3,8 @@
background-color:black; background-color:black;
color:blue; color:blue;
} }
* .border
{
background-color : lightgray;
}