Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Narr the Reg | 9358408798 | |
german77 | d01d998a17 | |
german77 | e6d09620e4 |
|
@ -543,6 +543,7 @@ struct System::Impl {
|
|||
|
||||
ExecuteProgramCallback execute_program_callback;
|
||||
ExitCallback exit_callback;
|
||||
GameLogCallback game_log_callback;
|
||||
|
||||
std::array<u64, Core::Hardware::NUM_CPU_CORES> dynarmic_ticks{};
|
||||
std::array<MicroProfileToken, Core::Hardware::NUM_CPU_CORES> microprofile_cpu{};
|
||||
|
@ -1011,6 +1012,18 @@ void System::RegisterExitCallback(ExitCallback&& callback) {
|
|||
impl->exit_callback = std::move(callback);
|
||||
}
|
||||
|
||||
void System::RegisterGameLogCallback(GameLogCallback&& callback) {
|
||||
impl->game_log_callback = std::move(callback);
|
||||
}
|
||||
|
||||
void System::AppendGameMessage(std::string& text) {
|
||||
if (impl->game_log_callback) {
|
||||
impl->game_log_callback(text);
|
||||
} else {
|
||||
LOG_CRITICAL(Core, "game_log_callback must be initialized by the frontend");
|
||||
}
|
||||
}
|
||||
|
||||
void System::Exit() {
|
||||
if (impl->exit_callback) {
|
||||
impl->exit_callback();
|
||||
|
|
|
@ -462,6 +462,18 @@ public:
|
|||
*/
|
||||
void RegisterExitCallback(ExitCallback&& callback);
|
||||
|
||||
/// Type used for the frontend to designate a callback for System to display log output.
|
||||
using GameLogCallback = std::function<void(std::string)>;
|
||||
|
||||
/**
|
||||
* Registers a callback from the frontend for System to display log output.
|
||||
* @param callback Callback from the frontend to display log output.
|
||||
*/
|
||||
void RegisterGameLogCallback(GameLogCallback&& callback);
|
||||
|
||||
/// Inserts a new entry on the game log ouput window
|
||||
void AppendGameMessage(std::string& text);
|
||||
|
||||
/// Instructs the frontend to exit the application.
|
||||
void Exit();
|
||||
|
||||
|
|
|
@ -276,6 +276,7 @@ private:
|
|||
|
||||
if (text_log) {
|
||||
output_log += fmt::format("Log Text: {}\n", *text_log);
|
||||
system.AppendGameMessage(*text_log);
|
||||
}
|
||||
LOG_DEBUG(Service_LM, "LogManager {} ({}):\n{}", NameOf(entry.severity),
|
||||
DestinationToString(destination), output_log);
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
#include <wincon.h>
|
||||
#endif
|
||||
|
||||
#include <QAction>
|
||||
#include <QLayout>
|
||||
#include <QString>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "common/logging/backend.h"
|
||||
#include "yuzu/debugger/console.h"
|
||||
#include "yuzu/uisettings.h"
|
||||
|
@ -46,4 +51,66 @@ void ToggleConsole() {
|
|||
SetColorConsoleBackendEnabled(UISettings::values.show_console.GetValue());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
GameLogOuput::GameLogOuput(QWidget* parent)
|
||||
: QWidget(parent, Qt::Dialog) {
|
||||
setObjectName(QStringLiteral("Game Log Output"));
|
||||
setWindowTitle(tr("Game Log Output"));
|
||||
resize(500, 350);
|
||||
setMinimumSize(500, 350);
|
||||
// Remove the "?" button from the titlebar and enable the maximize button
|
||||
setWindowFlags((windowFlags() & ~Qt::WindowContextHelpButtonHint) |
|
||||
Qt::WindowMaximizeButtonHint);
|
||||
|
||||
log_output = new QPlainTextEdit(this);
|
||||
log_output->setReadOnly(true);
|
||||
QLayout* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(log_output);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void GameLogOuput::AppendMessage(const QString& text) {
|
||||
log_queue.Push(text);
|
||||
// Scrolls to the bottom
|
||||
//log_output->verticalScrollBar()->setValue(
|
||||
// log_output->verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
|
||||
void GameLogOuput::paintEvent(QPaintEvent* event) {
|
||||
QWidget::paintEvent(event);
|
||||
while (!log_queue.Empty()) {
|
||||
QString text{};
|
||||
log_queue.Pop(text);
|
||||
log_output->appendPlainText(text);
|
||||
}
|
||||
}
|
||||
|
||||
QAction* GameLogOuput::toggleViewAction() {
|
||||
if (toggle_view_action == nullptr) {
|
||||
toggle_view_action = new QAction(tr("&Game Log Ouput"), this);
|
||||
toggle_view_action->setCheckable(true);
|
||||
toggle_view_action->setChecked(isVisible());
|
||||
connect(toggle_view_action, &QAction::toggled, this, &GameLogOuput::setVisible);
|
||||
}
|
||||
|
||||
return toggle_view_action;
|
||||
}
|
||||
|
||||
void GameLogOuput::showEvent(QShowEvent* ev) {
|
||||
if (toggle_view_action) {
|
||||
toggle_view_action->setChecked(isVisible());
|
||||
}
|
||||
QWidget::showEvent(ev);
|
||||
}
|
||||
|
||||
void GameLogOuput::hideEvent(QHideEvent* ev) {
|
||||
if (toggle_view_action) {
|
||||
toggle_view_action->setChecked(isVisible());
|
||||
}
|
||||
QWidget::hideEvent(ev);
|
||||
}
|
||||
|
||||
} // namespace Debugger
|
||||
|
|
|
@ -3,6 +3,16 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <QWidget>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
#include "common/threadsafe_queue.h"
|
||||
|
||||
namespace Core::HID {
|
||||
class HIDCore;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Debugger {
|
||||
|
||||
/**
|
||||
|
@ -10,4 +20,27 @@ namespace Debugger {
|
|||
* get a real qt logging window which would work for all platforms.
|
||||
*/
|
||||
void ToggleConsole();
|
||||
|
||||
class GameLogOuput : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameLogOuput(QWidget* parent = nullptr);
|
||||
|
||||
void AppendMessage(const QString& text);
|
||||
|
||||
/// Returns a QAction that can be used to toggle visibility of this dialog.
|
||||
QAction* toggleViewAction();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* ev) override;
|
||||
void hideEvent(QHideEvent* ev) override;
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
private:
|
||||
QAction* toggle_view_action = nullptr;
|
||||
QPlainTextEdit* log_output = nullptr;
|
||||
/// Queue of vibration request to controllers
|
||||
Common::SPSCQueue<QString> log_queue;
|
||||
};
|
||||
} // namespace Debugger
|
|
@ -1248,6 +1248,10 @@ void GMainWindow::InitializeDebugWidgets() {
|
|||
controller_dialog->hide();
|
||||
debug_menu->addAction(controller_dialog->toggleViewAction());
|
||||
|
||||
game_log_ouput_widget = new Debugger::GameLogOuput(this);
|
||||
game_log_ouput_widget->hide();
|
||||
debug_menu->addAction(game_log_ouput_widget->toggleViewAction());
|
||||
|
||||
connect(this, &GMainWindow::EmulationStarting, waitTreeWidget,
|
||||
&WaitTreeWidget::OnEmulationStarting);
|
||||
connect(this, &GMainWindow::EmulationStopping, waitTreeWidget,
|
||||
|
@ -1876,6 +1880,11 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
|
|||
render_window->Exit();
|
||||
});
|
||||
|
||||
// Register an Exit callback such that Core can exit the currently running application.
|
||||
system->RegisterGameLogCallback([this](std::string text) {
|
||||
game_log_ouput_widget->AppendMessage(QString::fromStdString(text));
|
||||
});
|
||||
|
||||
connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
|
||||
connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity);
|
||||
// BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views
|
||||
|
|
|
@ -72,6 +72,10 @@ struct KeyboardInitializeParameters;
|
|||
struct ProfileSelectParameters;
|
||||
} // namespace Core::Frontend
|
||||
|
||||
namespace Debugger {
|
||||
class GameLogOuput;
|
||||
}
|
||||
|
||||
namespace DiscordRPC {
|
||||
class DiscordInterface;
|
||||
}
|
||||
|
@ -468,6 +472,7 @@ private:
|
|||
MicroProfileDialog* microProfileDialog;
|
||||
WaitTreeWidget* waitTreeWidget;
|
||||
ControllerDialog* controller_dialog;
|
||||
Debugger::GameLogOuput* game_log_ouput_widget;
|
||||
|
||||
QAction* actions_recent_files[max_recent_files_item];
|
||||
|
||||
|
|
Loading…
Reference in New Issue