2015-12-20 05:24:48 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <QAction>
|
2016-02-11 11:59:44 +00:00
|
|
|
#include <QDesktopServices>
|
2017-05-04 21:01:12 +00:00
|
|
|
#include <QFileDialog>
|
2017-05-08 17:03:59 +00:00
|
|
|
#include <QMap>
|
2017-05-04 21:01:12 +00:00
|
|
|
#include <QMessageBox>
|
2016-02-11 11:59:44 +00:00
|
|
|
#include <QUrl>
|
2015-12-20 05:24:48 +00:00
|
|
|
|
2017-06-14 09:58:11 +00:00
|
|
|
#include "Core/CommonTitles.h"
|
|
|
|
#include "Core/IOS/ES/ES.h"
|
|
|
|
#include "Core/IOS/IOS.h"
|
2016-02-15 01:56:40 +00:00
|
|
|
#include "Core/State.h"
|
2016-02-11 11:59:44 +00:00
|
|
|
#include "DolphinQt2/AboutDialog.h"
|
2017-05-04 21:01:12 +00:00
|
|
|
#include "DolphinQt2/GameList/GameFile.h"
|
2015-12-20 05:24:48 +00:00
|
|
|
#include "DolphinQt2/MenuBar.h"
|
2016-01-01 10:29:39 +00:00
|
|
|
#include "DolphinQt2/Settings.h"
|
2015-12-20 05:24:48 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent)
|
2015-12-20 05:24:48 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
AddFileMenu();
|
|
|
|
AddEmulationMenu();
|
|
|
|
addMenu(tr("Movie"));
|
2017-06-06 11:49:49 +00:00
|
|
|
AddOptionsMenu();
|
2017-05-04 21:01:12 +00:00
|
|
|
AddToolsMenu();
|
2016-06-24 08:43:46 +00:00
|
|
|
AddViewMenu();
|
|
|
|
AddHelpMenu();
|
|
|
|
|
|
|
|
EmulationStopped();
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::EmulationStarted()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// Emulation
|
|
|
|
m_play_action->setEnabled(false);
|
|
|
|
m_play_action->setVisible(false);
|
|
|
|
m_pause_action->setEnabled(true);
|
|
|
|
m_pause_action->setVisible(true);
|
|
|
|
m_stop_action->setEnabled(true);
|
|
|
|
m_reset_action->setEnabled(true);
|
|
|
|
m_fullscreen_action->setEnabled(true);
|
|
|
|
m_frame_advance_action->setEnabled(true);
|
|
|
|
m_screenshot_action->setEnabled(true);
|
|
|
|
m_state_load_menu->setEnabled(true);
|
|
|
|
m_state_save_menu->setEnabled(true);
|
|
|
|
UpdateStateSlotMenu();
|
2017-06-14 09:58:11 +00:00
|
|
|
UpdateToolsMenu(true);
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
void MenuBar::EmulationPaused()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_play_action->setEnabled(true);
|
|
|
|
m_play_action->setVisible(true);
|
|
|
|
m_pause_action->setEnabled(false);
|
|
|
|
m_pause_action->setVisible(false);
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
void MenuBar::EmulationStopped()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// Emulation
|
|
|
|
m_play_action->setEnabled(true);
|
|
|
|
m_play_action->setVisible(true);
|
|
|
|
m_pause_action->setEnabled(false);
|
|
|
|
m_pause_action->setVisible(false);
|
|
|
|
m_stop_action->setEnabled(false);
|
|
|
|
m_reset_action->setEnabled(false);
|
|
|
|
m_fullscreen_action->setEnabled(false);
|
|
|
|
m_frame_advance_action->setEnabled(false);
|
|
|
|
m_screenshot_action->setEnabled(false);
|
|
|
|
m_state_load_menu->setEnabled(false);
|
|
|
|
m_state_save_menu->setEnabled(false);
|
|
|
|
UpdateStateSlotMenu();
|
2017-06-14 09:58:11 +00:00
|
|
|
UpdateToolsMenu(false);
|
2015-12-20 05:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddFileMenu()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QMenu* file_menu = addMenu(tr("File"));
|
|
|
|
m_open_action = file_menu->addAction(tr("Open"), this, SIGNAL(Open()));
|
|
|
|
m_exit_action = file_menu->addAction(tr("Exit"), this, SIGNAL(Exit()));
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 21:01:12 +00:00
|
|
|
void MenuBar::AddToolsMenu()
|
|
|
|
{
|
|
|
|
QMenu* tools_menu = addMenu(tr("Tools"));
|
|
|
|
m_wad_install_action = tools_menu->addAction(tr("Install WAD..."), this, SLOT(InstallWAD()));
|
2017-06-14 09:58:11 +00:00
|
|
|
|
|
|
|
m_perform_online_update_menu = tools_menu->addMenu(tr("Perform Online System Update"));
|
|
|
|
m_perform_online_update_for_current_region = m_perform_online_update_menu->addAction(
|
|
|
|
tr("Current Region"), [this] { emit PerformOnlineUpdate(""); });
|
|
|
|
m_perform_online_update_menu->addSeparator();
|
|
|
|
m_perform_online_update_menu->addAction(tr("Europe"),
|
|
|
|
[this] { emit PerformOnlineUpdate("EUR"); });
|
|
|
|
m_perform_online_update_menu->addAction(tr("Japan"), [this] { emit PerformOnlineUpdate("JPN"); });
|
|
|
|
m_perform_online_update_menu->addAction(tr("Korea"), [this] { emit PerformOnlineUpdate("KOR"); });
|
|
|
|
m_perform_online_update_menu->addAction(tr("United States"),
|
|
|
|
[this] { emit PerformOnlineUpdate("USA"); });
|
2017-05-04 21:01:12 +00:00
|
|
|
}
|
|
|
|
|
2016-02-15 01:56:40 +00:00
|
|
|
void MenuBar::AddEmulationMenu()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QMenu* emu_menu = addMenu(tr("Emulation"));
|
|
|
|
m_play_action = emu_menu->addAction(tr("Play"), this, SIGNAL(Play()));
|
|
|
|
m_pause_action = emu_menu->addAction(tr("Pause"), this, SIGNAL(Pause()));
|
|
|
|
m_stop_action = emu_menu->addAction(tr("Stop"), this, SIGNAL(Stop()));
|
|
|
|
m_reset_action = emu_menu->addAction(tr("Reset"), this, SIGNAL(Reset()));
|
|
|
|
m_fullscreen_action = emu_menu->addAction(tr("Fullscreen"), this, SIGNAL(Fullscreen()));
|
|
|
|
m_frame_advance_action = emu_menu->addAction(tr("Frame Advance"), this, SIGNAL(FrameAdvance()));
|
|
|
|
m_screenshot_action = emu_menu->addAction(tr("Take Screenshot"), this, SIGNAL(Screenshot()));
|
|
|
|
AddStateLoadMenu(emu_menu);
|
|
|
|
AddStateSaveMenu(emu_menu);
|
|
|
|
AddStateSlotMenu(emu_menu);
|
|
|
|
UpdateStateSlotMenu();
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddStateLoadMenu(QMenu* emu_menu)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_state_load_menu = emu_menu->addMenu(tr("Load State"));
|
|
|
|
m_state_load_menu->addAction(tr("Load State from File"), this, SIGNAL(StateLoad()));
|
|
|
|
m_state_load_menu->addAction(tr("Load State from Selected Slot"), this, SIGNAL(StateLoadSlot()));
|
|
|
|
m_state_load_slots_menu = m_state_load_menu->addMenu(tr("Load State from Slot"));
|
|
|
|
m_state_load_menu->addAction(tr("Undo Load State"), this, SIGNAL(StateLoadUndo()));
|
|
|
|
|
|
|
|
for (int i = 1; i <= 10; i++)
|
|
|
|
{
|
|
|
|
QAction* action = m_state_load_slots_menu->addAction(QStringLiteral(""));
|
|
|
|
|
|
|
|
connect(action, &QAction::triggered, this, [=]() { emit StateLoadSlotAt(i); });
|
|
|
|
}
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddStateSaveMenu(QMenu* emu_menu)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_state_save_menu = emu_menu->addMenu(tr("Save State"));
|
|
|
|
m_state_save_menu->addAction(tr("Save State to File"), this, SIGNAL(StateSave()));
|
|
|
|
m_state_save_menu->addAction(tr("Save State to Selected Slot"), this, SIGNAL(StateSaveSlot()));
|
|
|
|
m_state_save_menu->addAction(tr("Save State to Oldest Slot"), this, SIGNAL(StateSaveOldest()));
|
|
|
|
m_state_save_slots_menu = m_state_save_menu->addMenu(tr("Save State to Slot"));
|
|
|
|
m_state_save_menu->addAction(tr("Undo Save State"), this, SIGNAL(StateSaveUndo()));
|
|
|
|
|
|
|
|
for (int i = 1; i <= 10; i++)
|
|
|
|
{
|
|
|
|
QAction* action = m_state_save_slots_menu->addAction(QStringLiteral(""));
|
|
|
|
|
|
|
|
connect(action, &QAction::triggered, this, [=]() { emit StateSaveSlotAt(i); });
|
|
|
|
}
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddStateSlotMenu(QMenu* emu_menu)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_state_slot_menu = emu_menu->addMenu(tr("Select State Slot"));
|
|
|
|
m_state_slots = new QActionGroup(this);
|
|
|
|
|
|
|
|
for (int i = 1; i <= 10; i++)
|
|
|
|
{
|
|
|
|
QAction* action = m_state_slot_menu->addAction(QStringLiteral(""));
|
|
|
|
action->setCheckable(true);
|
|
|
|
action->setActionGroup(m_state_slots);
|
2017-05-31 07:17:39 +00:00
|
|
|
if (Settings::Instance().GetStateSlot() == i)
|
2016-06-24 08:43:46 +00:00
|
|
|
action->setChecked(true);
|
|
|
|
|
|
|
|
connect(action, &QAction::triggered, this, [=]() { emit SetStateSlot(i); });
|
|
|
|
}
|
2016-02-15 01:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::UpdateStateSlotMenu()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QList<QAction*> actions_slot = m_state_slots->actions();
|
|
|
|
QList<QAction*> actions_load = m_state_load_slots_menu->actions();
|
|
|
|
QList<QAction*> actions_save = m_state_save_slots_menu->actions();
|
|
|
|
for (int i = 0; i < actions_slot.length(); i++)
|
|
|
|
{
|
|
|
|
int slot = i + 1;
|
|
|
|
QString info = QString::fromStdString(State::GetInfoStringOfSlot(slot));
|
|
|
|
QString action_string = tr(" Slot %1 - %2").arg(slot).arg(info);
|
|
|
|
actions_load.at(i)->setText(tr("Load from") + action_string);
|
|
|
|
actions_save.at(i)->setText(tr("Save to") + action_string);
|
|
|
|
actions_slot.at(i)->setText(tr("Select") + action_string);
|
|
|
|
}
|
2015-12-20 05:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddViewMenu()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QMenu* view_menu = addMenu(tr("View"));
|
|
|
|
AddGameListTypeSection(view_menu);
|
|
|
|
view_menu->addSeparator();
|
|
|
|
AddTableColumnsMenu(view_menu);
|
2015-12-20 05:24:48 +00:00
|
|
|
}
|
|
|
|
|
2017-06-06 11:49:49 +00:00
|
|
|
void MenuBar::AddOptionsMenu()
|
|
|
|
{
|
|
|
|
QMenu* options_menu = addMenu(tr("Options"));
|
|
|
|
options_menu->addAction(tr("Hotkey Settings"), this, &MenuBar::ConfigureHotkeys);
|
|
|
|
}
|
|
|
|
|
2016-02-11 11:59:44 +00:00
|
|
|
void MenuBar::AddHelpMenu()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QMenu* help_menu = addMenu(tr("Help"));
|
2017-05-05 08:08:01 +00:00
|
|
|
QAction* website = help_menu->addAction(tr("Website"));
|
|
|
|
connect(website, &QAction::triggered, this,
|
|
|
|
[]() { QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/"))); });
|
2016-06-24 08:43:46 +00:00
|
|
|
QAction* documentation = help_menu->addAction(tr("Online Documentation"));
|
2017-05-05 08:08:01 +00:00
|
|
|
connect(documentation, &QAction::triggered, this, []() {
|
2016-06-24 08:43:46 +00:00
|
|
|
QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/docs/guides")));
|
|
|
|
});
|
2017-05-05 08:08:01 +00:00
|
|
|
QAction* github = help_menu->addAction(tr("GitHub Repository"));
|
|
|
|
connect(github, &QAction::triggered, this, []() {
|
|
|
|
QDesktopServices::openUrl(QUrl(QStringLiteral("https://github.com/dolphin-emu/dolphin")));
|
|
|
|
});
|
|
|
|
|
|
|
|
help_menu->addSeparator();
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
help_menu->addAction(tr("About"), this, SIGNAL(ShowAboutDialog()));
|
2016-02-11 11:59:44 +00:00
|
|
|
}
|
|
|
|
|
2015-12-20 05:24:48 +00:00
|
|
|
void MenuBar::AddGameListTypeSection(QMenu* view_menu)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QAction* table_view = view_menu->addAction(tr("Table"));
|
|
|
|
table_view->setCheckable(true);
|
2015-12-20 05:24:48 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
QAction* list_view = view_menu->addAction(tr("List"));
|
|
|
|
list_view->setCheckable(true);
|
2015-12-20 05:24:48 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
QActionGroup* list_group = new QActionGroup(this);
|
|
|
|
list_group->addAction(table_view);
|
|
|
|
list_group->addAction(list_view);
|
2015-12-20 05:24:48 +00:00
|
|
|
|
2017-05-31 07:17:39 +00:00
|
|
|
bool prefer_table = Settings::Instance().GetPreferredView();
|
2016-06-24 08:43:46 +00:00
|
|
|
table_view->setChecked(prefer_table);
|
|
|
|
list_view->setChecked(!prefer_table);
|
2015-12-20 05:24:48 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
connect(table_view, &QAction::triggered, this, &MenuBar::ShowTable);
|
|
|
|
connect(list_view, &QAction::triggered, this, &MenuBar::ShowList);
|
2015-12-20 05:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuBar::AddTableColumnsMenu(QMenu* view_menu)
|
|
|
|
{
|
2017-05-31 07:17:39 +00:00
|
|
|
auto& settings = Settings::Instance();
|
|
|
|
static const QMap<QString, bool*> columns{{tr("Platform"), &settings.PlatformVisible()},
|
|
|
|
{tr("ID"), &settings.IDVisible()},
|
|
|
|
{tr("Banner"), &settings.BannerVisible()},
|
|
|
|
{tr("Title"), &settings.TitleVisible()},
|
|
|
|
{tr("Description"), &settings.DescriptionVisible()},
|
|
|
|
{tr("Maker"), &settings.MakerVisible()},
|
|
|
|
{tr("Size"), &settings.SizeVisible()},
|
|
|
|
{tr("Country"), &settings.CountryVisible()},
|
|
|
|
{tr("Quality"), &settings.StateVisible()}};
|
2017-05-08 17:03:59 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
QActionGroup* column_group = new QActionGroup(this);
|
|
|
|
QMenu* cols_menu = view_menu->addMenu(tr("Table Columns"));
|
|
|
|
column_group->setExclusive(false);
|
|
|
|
|
2017-05-08 17:03:59 +00:00
|
|
|
for (const auto& key : columns.keys())
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-05-08 17:03:59 +00:00
|
|
|
bool* config = columns[key];
|
|
|
|
QAction* action = column_group->addAction(cols_menu->addAction(key));
|
2016-06-24 08:43:46 +00:00
|
|
|
action->setCheckable(true);
|
2017-05-08 17:03:59 +00:00
|
|
|
action->setChecked(*config);
|
|
|
|
connect(action, &QAction::toggled, [this, config, key](bool value) {
|
|
|
|
*config = value;
|
2017-05-31 07:17:39 +00:00
|
|
|
Settings::Instance().Save();
|
2017-05-08 17:03:59 +00:00
|
|
|
emit ColumnVisibilityToggled(key, value);
|
|
|
|
});
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2015-12-20 05:24:48 +00:00
|
|
|
}
|
2017-05-04 21:01:12 +00:00
|
|
|
|
2017-06-14 09:58:11 +00:00
|
|
|
void MenuBar::UpdateToolsMenu(bool emulation_started)
|
|
|
|
{
|
|
|
|
const bool enable_wii_tools = !emulation_started || !Settings::Instance().IsWiiGameRunning();
|
|
|
|
m_perform_online_update_menu->setEnabled(enable_wii_tools);
|
|
|
|
if (enable_wii_tools)
|
|
|
|
{
|
|
|
|
IOS::HLE::Kernel ios;
|
|
|
|
const auto tmd = ios.GetES()->FindInstalledTMD(Titles::SYSTEM_MENU);
|
|
|
|
for (QAction* action : m_perform_online_update_menu->actions())
|
|
|
|
action->setEnabled(!tmd.IsValid());
|
|
|
|
m_perform_online_update_for_current_region->setEnabled(tmd.IsValid());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-04 21:01:12 +00:00
|
|
|
void MenuBar::InstallWAD()
|
|
|
|
{
|
|
|
|
QString wad_file = QFileDialog::getOpenFileName(this, tr("Select a title to install to NAND"),
|
|
|
|
QString(), tr("WAD files (*.wad)"));
|
|
|
|
|
|
|
|
if (wad_file.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
QMessageBox result_dialog(this);
|
|
|
|
|
|
|
|
if (GameFile(wad_file).Install())
|
|
|
|
{
|
|
|
|
result_dialog.setIcon(QMessageBox::Information);
|
|
|
|
result_dialog.setText(tr("Successfully installed title to the NAND"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result_dialog.setIcon(QMessageBox::Critical);
|
|
|
|
result_dialog.setText(tr("Failed to install title to the NAND!"));
|
|
|
|
}
|
|
|
|
|
|
|
|
result_dialog.exec();
|
|
|
|
}
|