Added menu option to locate current mirror repository

This commit is contained in:
spectranator 2024-05-08 14:16:40 +02:00
parent cdcbfdc837
commit 08f47542e8
4 changed files with 46 additions and 2 deletions

View file

@ -382,7 +382,7 @@ elseif(WIN32)
endif() endif()
target_link_libraries(yuzu PRIVATE common core input_common frontend_common network video_core) target_link_libraries(yuzu PRIVATE common core input_common frontend_common network video_core)
target_link_libraries(yuzu PRIVATE Boost::headers glad Qt${QT_MAJOR_VERSION}::Widgets) target_link_libraries(yuzu PRIVATE Boost::headers glad Qt${QT_MAJOR_VERSION}::Widgets httplib::httplib)
target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
target_link_libraries(yuzu PRIVATE Vulkan::Headers) target_link_libraries(yuzu PRIVATE Vulkan::Headers)

View file

@ -21,6 +21,7 @@
#include "common/linux/gamemode.h" #include "common/linux/gamemode.h"
#endif #endif
#include <httplib.h>
#include <boost/container/flat_set.hpp> #include <boost/container/flat_set.hpp>
// VFS includes must be before glad as they will conflict with Windows file api, which uses defines. // VFS includes must be before glad as they will conflict with Windows file api, which uses defines.
@ -1524,6 +1525,7 @@ void GMainWindow::ConnectMenuEvents() {
connect_menu(ui->action_Open_Mods_Page, &GMainWindow::OnOpenModsPage); connect_menu(ui->action_Open_Mods_Page, &GMainWindow::OnOpenModsPage);
connect_menu(ui->action_Open_Quickstart_Guide, &GMainWindow::OnOpenQuickstartGuide); connect_menu(ui->action_Open_Quickstart_Guide, &GMainWindow::OnOpenQuickstartGuide);
connect_menu(ui->action_Open_FAQ, &GMainWindow::OnOpenFAQ); connect_menu(ui->action_Open_FAQ, &GMainWindow::OnOpenFAQ);
connect_menu(ui->action_Open_Mirror_Repo, &GMainWindow::OnOpenMirrorRepo);
connect_menu(ui->action_Restart, &GMainWindow::OnRestartGame); connect_menu(ui->action_Restart, &GMainWindow::OnRestartGame);
connect_menu(ui->action_Configure, &GMainWindow::OnConfigure); connect_menu(ui->action_Configure, &GMainWindow::OnConfigure);
connect_menu(ui->action_Configure_Current_Game, &GMainWindow::OnConfigurePerGame); connect_menu(ui->action_Configure_Current_Game, &GMainWindow::OnConfigurePerGame);
@ -3566,6 +3568,41 @@ void GMainWindow::OnOpenFAQ() {
OpenURL(QUrl(QStringLiteral("https://yuzu-emu.org/wiki/faq/"))); OpenURL(QUrl(QStringLiteral("https://yuzu-emu.org/wiki/faq/")));
} }
void GMainWindow::OnOpenMirrorRepo() {
struct Mirror {
const char *host, *path;
};
const std::initializer_list<Mirror> mirrors = {
{"https://github.com", "/litucks/torzu"},
{"https://gitlab.com", "/litucks/torzu"},
{"https://bitbucket.org", "/litucks/torzu"},
{"https://codeberg.org", "/litucks/torzu"},
{"https://notabug.org", "/litucks/torzu"},
{"https://gitea.com", "/litucks/torzu"},
{"https://try.gitea.io", "/litucks/torzu"},
{"https://git.math.hamburg", "/litucks/torzu"},
{"https://gitea.sprint-pay.com", "/litucks/torzu"},
{"https://gitea.djoe.ovh", "/litucks/torzu"},
{"https://git.sheetjs.com", "/litucks/torzu"},
{"https://gitea.cisetech.com", "/litucks/torzu"}
};
for (const auto& mirror : mirrors) {
httplib::Client cli(mirror.host);
if (cli.Get(mirror.path)) {
OpenURL(QUrl(QString::fromStdString(fmt::format("{}{}", mirror.host, mirror.path))));
return;
}
}
QMessageBox::warning(this, tr("Error locating mirror"), tr("There has been an error finding the current mirror repository.\n"
"Your version may be so old the list has already been depleted\n"
"or your network connectivity may be limited.\n"
"Please either try again later, through a VPN or access the main\n"
"repository via the Tor Browser:\n"
"http://y2nlvhmmk5jnsvechppxnbyzmmv3vbl7dvzn6ltwcdbpgxixp3clkgqd.onion/torzu-emu/torzu"));
}
void GMainWindow::ToggleFullscreen() { void GMainWindow::ToggleFullscreen() {
if (!emulation_running) { if (!emulation_running) {
return; return;

View file

@ -337,6 +337,7 @@ private slots:
void OnOpenModsPage(); void OnOpenModsPage();
void OnOpenQuickstartGuide(); void OnOpenQuickstartGuide();
void OnOpenFAQ(); void OnOpenFAQ();
void OnOpenMirrorRepo();
/// Called whenever a user selects a game in the game list widget. /// Called whenever a user selects a game in the game list widget.
void OnGameListLoadFile(QString game_path, u64 program_id); void OnGameListLoadFile(QString game_path, u64 program_id);
void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target, void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target,

View file

@ -45,7 +45,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1280</width> <width>1280</width>
<height>21</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menu_File"> <widget class="QMenu" name="menu_File">
@ -185,6 +185,7 @@
<addaction name="action_Report_Compatibility"/> <addaction name="action_Report_Compatibility"/>
<addaction name="action_Open_Mods_Page"/> <addaction name="action_Open_Mods_Page"/>
<addaction name="action_Open_Quickstart_Guide"/> <addaction name="action_Open_Quickstart_Guide"/>
<addaction name="action_Open_Mirror_Repo"/>
<addaction name="action_Open_FAQ"/> <addaction name="action_Open_FAQ"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="action_About"/> <addaction name="action_About"/>
@ -481,6 +482,11 @@
<string>Open Home Menu</string> <string>Open Home Menu</string>
</property> </property>
</action> </action>
<action name="action_Open_Mirror_Repo">
<property name="text">
<string>Open current Mirror &amp;Repo</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="yuzu.qrc"/> <include location="yuzu.qrc"/>