core: De-globalize movie (#6659)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "citra_qt/compatdb.h"
|
||||
#include "common/telemetry.h"
|
||||
#include "core/core.h"
|
||||
#include "core/telemetry_session.h"
|
||||
#include "ui_compatdb.h"
|
||||
|
||||
CompatDB::CompatDB(Core::TelemetrySession& telemetry_session_, QWidget* parent)
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QUrl>
|
||||
#include "citra_qt/configuration/configure_storage.h"
|
||||
#include "common/file_util.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
#include "ui_configure_storage.h"
|
||||
|
@@ -5,11 +5,10 @@
|
||||
#include <array>
|
||||
#include "citra_qt/debugger/wait_tree.h"
|
||||
#include "citra_qt/uisettings.h"
|
||||
#include "citra_qt/util/util.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/kernel/mutex.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "core/hle/kernel/semaphore.h"
|
||||
#include "core/hle/kernel/thread.h"
|
||||
#include "core/hle/kernel/timer.h"
|
||||
|
@@ -9,10 +9,11 @@
|
||||
#include "citra_qt/uisettings.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/core.h"
|
||||
#include "core/loader/loader.h"
|
||||
|
||||
namespace DiscordRPC {
|
||||
|
||||
DiscordImpl::DiscordImpl() {
|
||||
DiscordImpl::DiscordImpl(const Core::System& system_) : system{system_} {
|
||||
DiscordEventHandlers handlers{};
|
||||
|
||||
// The number is the client ID for Citra, it's used for images and the
|
||||
@@ -34,12 +35,15 @@ void DiscordImpl::Update() {
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count();
|
||||
std::string title;
|
||||
if (Core::System::GetInstance().IsPoweredOn())
|
||||
Core::System::GetInstance().GetAppLoader().ReadTitle(title);
|
||||
const bool is_powered_on = system.IsPoweredOn();
|
||||
if (is_powered_on) {
|
||||
system.GetAppLoader().ReadTitle(title);
|
||||
}
|
||||
|
||||
DiscordRichPresence presence{};
|
||||
presence.largeImageKey = "citra";
|
||||
presence.largeImageText = "Citra is an emulator for the Nintendo 3DS";
|
||||
if (Core::System::GetInstance().IsPoweredOn()) {
|
||||
if (is_powered_on) {
|
||||
presence.state = title.c_str();
|
||||
presence.details = "Currently in game";
|
||||
} else {
|
||||
|
@@ -6,15 +6,22 @@
|
||||
|
||||
#include "citra_qt/discord.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DiscordRPC {
|
||||
|
||||
class DiscordImpl : public DiscordInterface {
|
||||
public:
|
||||
DiscordImpl();
|
||||
DiscordImpl(const Core::System& system);
|
||||
~DiscordImpl() override;
|
||||
|
||||
void Pause() override;
|
||||
void Update() override;
|
||||
|
||||
private:
|
||||
const Core::System& system;
|
||||
};
|
||||
|
||||
} // namespace DiscordRPC
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include <QtGui>
|
||||
#include <QtWidgets>
|
||||
#include <fmt/format.h>
|
||||
#include "core/telemetry_session.h"
|
||||
#ifdef __APPLE__
|
||||
#include <unistd.h> // for chdir
|
||||
#endif
|
||||
@@ -73,7 +74,6 @@
|
||||
#include "common/microprofile.h"
|
||||
#include "common/scm_rev.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "common/string_util.h"
|
||||
#if CITRA_ARCH(x86_64)
|
||||
#include "common/x64/cpu_detect.h"
|
||||
#endif
|
||||
@@ -173,7 +173,7 @@ static QString PrettyProductName() {
|
||||
}
|
||||
|
||||
GMainWindow::GMainWindow(Core::System& system_)
|
||||
: ui{std::make_unique<Ui::MainWindow>()}, system{system_}, movie{Core::Movie::GetInstance()},
|
||||
: ui{std::make_unique<Ui::MainWindow>()}, system{system_}, movie{system.Movie()},
|
||||
config{std::make_unique<Config>()}, emu_thread{nullptr} {
|
||||
Common::Log::Initialize();
|
||||
Common::Log::Start();
|
||||
@@ -1413,7 +1413,7 @@ void GMainWindow::UpdateSaveStates() {
|
||||
if (system.GetAppLoader().ReadProgramId(title_id) != Loader::ResultStatus::Success) {
|
||||
return;
|
||||
}
|
||||
auto savestates = Core::ListSaveStates(title_id);
|
||||
auto savestates = Core::ListSaveStates(title_id, movie.GetCurrentMovieID());
|
||||
for (u32 i = 0; i < Core::SaveStateSlotCount; ++i) {
|
||||
actions_load_state[i]->setEnabled(false);
|
||||
actions_load_state[i]->setText(tr("Slot %1").arg(i + 1));
|
||||
@@ -2125,7 +2125,7 @@ void GMainWindow::OnCreateGraphicsSurfaceViewer() {
|
||||
}
|
||||
|
||||
void GMainWindow::OnRecordMovie() {
|
||||
MovieRecordDialog dialog(this);
|
||||
MovieRecordDialog dialog(this, system);
|
||||
if (dialog.exec() != QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
@@ -2142,7 +2142,7 @@ void GMainWindow::OnRecordMovie() {
|
||||
}
|
||||
|
||||
void GMainWindow::OnPlayMovie() {
|
||||
MoviePlayDialog dialog(this, game_list);
|
||||
MoviePlayDialog dialog(this, game_list, system);
|
||||
if (dialog.exec() != QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
@@ -2847,7 +2847,7 @@ void GMainWindow::RetranslateStatusBar() {
|
||||
void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) {
|
||||
#ifdef USE_DISCORD_PRESENCE
|
||||
if (state) {
|
||||
discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>();
|
||||
discord_rpc = std::make_unique<DiscordRPC::DiscordImpl>(system);
|
||||
} else {
|
||||
discord_rpc = std::make_unique<DiscordRPC::NullImpl>();
|
||||
}
|
||||
|
@@ -15,8 +15,9 @@
|
||||
#include "core/movie.h"
|
||||
#include "ui_movie_play_dialog.h"
|
||||
|
||||
MoviePlayDialog::MoviePlayDialog(QWidget* parent, GameList* game_list_)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::MoviePlayDialog>()), game_list(game_list_) {
|
||||
MoviePlayDialog::MoviePlayDialog(QWidget* parent, GameList* game_list_, const Core::System& system_)
|
||||
: QDialog(parent),
|
||||
ui(std::make_unique<Ui::MoviePlayDialog>()), game_list{game_list_}, system{system_} {
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
@@ -26,10 +27,10 @@ MoviePlayDialog::MoviePlayDialog(QWidget* parent, GameList* game_list_)
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &MoviePlayDialog::accept);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &MoviePlayDialog::reject);
|
||||
|
||||
if (Core::System::GetInstance().IsPoweredOn()) {
|
||||
if (system.IsPoweredOn()) {
|
||||
QString note_text;
|
||||
note_text = tr("Current running game will be stopped.");
|
||||
if (Core::Movie::GetInstance().GetPlayMode() == Core::Movie::PlayMode::Recording) {
|
||||
if (system.Movie().GetPlayMode() == Core::Movie::PlayMode::Recording) {
|
||||
note_text.append(tr("<br>Current recording will be discarded."));
|
||||
}
|
||||
ui->note2Label->setText(note_text);
|
||||
@@ -43,7 +44,7 @@ QString MoviePlayDialog::GetMoviePath() const {
|
||||
}
|
||||
|
||||
QString MoviePlayDialog::GetGamePath() const {
|
||||
const auto metadata = Core::Movie::GetInstance().GetMovieMetadata(GetMoviePath().toStdString());
|
||||
const auto metadata = system.Movie().GetMovieMetadata(GetMoviePath().toStdString());
|
||||
return game_list->FindGameByProgramID(metadata.program_id, GameListItemPath::FullPathRole);
|
||||
}
|
||||
|
||||
@@ -67,9 +68,10 @@ void MoviePlayDialog::UpdateUIDisplay() {
|
||||
ui->lengthLineEdit->clear();
|
||||
ui->note1Label->setVisible(true);
|
||||
|
||||
const auto& movie = system.Movie();
|
||||
const auto path = GetMoviePath().toStdString();
|
||||
|
||||
const auto validation_result = Core::Movie::GetInstance().ValidateMovie(path);
|
||||
const auto validation_result = movie.ValidateMovie(path);
|
||||
if (validation_result == Core::Movie::ValidationResult::Invalid) {
|
||||
ui->note1Label->setText(tr("Invalid movie file."));
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
@@ -94,7 +96,7 @@ void MoviePlayDialog::UpdateUIDisplay() {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
const auto metadata = Core::Movie::GetInstance().GetMovieMetadata(path);
|
||||
const auto metadata = movie.GetMovieMetadata(path);
|
||||
|
||||
// Format game title
|
||||
const auto title =
|
||||
|
@@ -11,11 +11,15 @@ namespace Ui {
|
||||
class MoviePlayDialog;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
class MoviePlayDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MoviePlayDialog(QWidget* parent, GameList* game_list);
|
||||
explicit MoviePlayDialog(QWidget* parent, GameList* game_list, const Core::System& system);
|
||||
~MoviePlayDialog() override;
|
||||
|
||||
QString GetMoviePath() const;
|
||||
@@ -27,4 +31,5 @@ private:
|
||||
|
||||
std::unique_ptr<Ui::MoviePlayDialog> ui;
|
||||
GameList* game_list;
|
||||
const Core::System& system;
|
||||
};
|
||||
|
@@ -10,8 +10,8 @@
|
||||
#include "core/movie.h"
|
||||
#include "ui_movie_record_dialog.h"
|
||||
|
||||
MovieRecordDialog::MovieRecordDialog(QWidget* parent)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::MovieRecordDialog>()) {
|
||||
MovieRecordDialog::MovieRecordDialog(QWidget* parent, const Core::System& system_)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::MovieRecordDialog>()), system{system_} {
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
@@ -23,9 +23,9 @@ MovieRecordDialog::MovieRecordDialog(QWidget* parent)
|
||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &MovieRecordDialog::reject);
|
||||
|
||||
QString note_text;
|
||||
if (Core::System::GetInstance().IsPoweredOn()) {
|
||||
if (system.IsPoweredOn()) {
|
||||
note_text = tr("Current running game will be restarted.");
|
||||
if (Core::Movie::GetInstance().GetPlayMode() == Core::Movie::PlayMode::Recording) {
|
||||
if (system.Movie().GetPlayMode() == Core::Movie::PlayMode::Recording) {
|
||||
note_text.append(tr("<br>Current recording will be discarded."));
|
||||
}
|
||||
} else {
|
||||
|
@@ -9,11 +9,15 @@ namespace Ui {
|
||||
class MovieRecordDialog;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
class MovieRecordDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MovieRecordDialog(QWidget* parent);
|
||||
explicit MovieRecordDialog(QWidget* parent, const Core::System& system);
|
||||
~MovieRecordDialog() override;
|
||||
|
||||
QString GetPath() const;
|
||||
@@ -24,4 +28,5 @@ private:
|
||||
void UpdateUIDisplay();
|
||||
|
||||
std::unique_ptr<Ui::MovieRecordDialog> ui;
|
||||
const Core::System& system;
|
||||
};
|
||||
|
Reference in New Issue
Block a user