-
Notifications
You must be signed in to change notification settings - Fork 879
Expand file tree
/
Copy pathLoggingWindow.cpp
More file actions
87 lines (65 loc) · 2.91 KB
/
Copy pathLoggingWindow.cpp
File metadata and controls
87 lines (65 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "wxgui/LoggingWindow.h"
#include "Cemu/Logging/CemuLogging.h"
#include "wxgui/helpers/wxLogEvent.h"
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/wupdlock.h>
wxDEFINE_EVENT(EVT_LOG, wxLogEvent);
LoggingWindow::LoggingWindow(wxFrame* parent)
: wxFrame(parent, wxID_ANY, _("Logging window"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL)
{
SetSize(FromDIP(wxSize(800, 600)));
auto* sizer = new wxBoxSizer( wxVERTICAL );
{
auto filter_row = new wxBoxSizer( wxHORIZONTAL );
filter_row->Add(new wxStaticText( this, wxID_ANY, _("Filter")), 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxString choices[] = {"Unsupported APIs calls", "Coreinit Logging", "Coreinit File-Access", "Coreinit Thread-Synchronization", "Coreinit Memory", "Coreinit MP", "Coreinit Thread", "nn::nfp", "GX2", "Audio", "Input", "Socket", "Save", "H264", "Graphic pack patches", "Texture cache", "Texture readback", "OpenGL debug output", "Vulkan validation layer", "Metal debug output"};
m_filter = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, std::size(choices), choices);
m_filter->Bind(wxEVT_COMBOBOX, &LoggingWindow::OnFilterChange, this);
m_filter->Bind(wxEVT_TEXT, &LoggingWindow::OnFilterChange, this);
filter_row->Add(m_filter, 1, wxALL, 5 );
m_filter_message = new wxCheckBox(this, wxID_ANY, _("Filter messages"));
m_filter_message->Bind(wxEVT_CHECKBOX, &LoggingWindow::OnFilterMessageChange, this);
filter_row->Add(m_filter_message, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
sizer->Add( filter_row, 0, wxEXPAND, 5 );
}
m_log_list = new wxLogCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxScrolledWindowStyle, true);
sizer->Add( m_log_list, 1, wxALL | wxEXPAND, 5 );
this->SetSizer( sizer );
this->Layout();
this->Bind(EVT_LOG, &LoggingWindow::OnLogMessage, this);
cemuLog_setCallbacks(this);
}
LoggingWindow::~LoggingWindow()
{
this->Unbind(EVT_LOG, &LoggingWindow::OnLogMessage, this);
cemuLog_clearCallbacks();
}
void LoggingWindow::Log(std::string_view filter, std::string_view message)
{
wxLogEvent event(std::string {filter}, std::string{ message });
OnLogMessage(event);
//const auto log_event = new wxLogEvent(filter, message);
//wxQueueEvent(s_instance, log_event);
}
void LoggingWindow::Log(std::string_view filter, std::wstring_view message)
{
wxLogEvent event(std::string {filter}, std::wstring{ message });
OnLogMessage(event);
//const auto log_event = new wxLogEvent(filter, message);
//wxQueueEvent(s_instance, log_event);
}
void LoggingWindow::OnLogMessage(wxLogEvent& event)
{
m_log_list->PushEntry(event.GetFilter(), event.GetMessage());
}
void LoggingWindow::OnFilterChange(wxCommandEvent& event)
{
m_log_list->SetActiveFilter(m_filter->GetValue().utf8_string());
event.Skip();
}
void LoggingWindow::OnFilterMessageChange(wxCommandEvent& event)
{
m_log_list->SetFilterMessage(m_filter_message->GetValue());
event.Skip();
}