aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/ryujinx_dialog.cpp
blob: 563714f6beae4f30aa3b5e6cad07c43027abb328 (plain) (blame)
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
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

#include "qt_common/abstract/frontend.h"
#include "ryujinx_dialog.h"
#include "qt_common/util/fs.h"
#include "ui_ryujinx_dialog.h"
#include <filesystem>

RyujinxDialog::RyujinxDialog(std::filesystem::path eden_path,
                             std::filesystem::path ryu_path,
                             QWidget *parent)
    : QDialog(parent)
      , ui(new Ui::RyujinxDialog)
      , m_eden(eden_path.make_preferred())
      , m_ryu(ryu_path.make_preferred())
{
    ui->setupUi(this);

    connect(ui->eden, &QPushButton::clicked, this, &RyujinxDialog::fromEden);
    connect(ui->ryujinx, &QPushButton::clicked, this, &RyujinxDialog::fromRyujinx);
    connect(ui->cancel, &QPushButton::clicked, this, &RyujinxDialog::reject);
}

RyujinxDialog::~RyujinxDialog()
{
    delete ui;
}

void RyujinxDialog::fromEden()
{
    accept();

    // Workaround: Ryujinx deletes and re-creates its directory structure???
    // So we just copy Eden's data to Ryujinx and then link the other way
    namespace fs = std::filesystem;
    try {
        fs::remove_all(m_ryu);
        fs::create_directories(m_ryu);
        fs::copy(m_eden, m_ryu, fs::copy_options::recursive);
    } catch (std::exception &e) {
        QtCommon::Frontend::Critical(tr("Failed to link save data"),
                                     tr("OS returned error: %1").arg(QString::fromStdString(e.what())));
    }

    // ?ploo
    QtCommon::FS::LinkRyujinx(m_ryu, m_eden);
}

void RyujinxDialog::fromRyujinx()
{
    accept();
    QtCommon::FS::LinkRyujinx(m_ryu, m_eden);
}