コード例 #1
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::UninstallWAD()
{
  const auto game = GetSelectedGame();
  if (!game)
    return;

  ModalMessageBox warning_dialog(this);

  warning_dialog.setIcon(QMessageBox::Information);
  warning_dialog.setWindowTitle(tr("Confirm"));
  warning_dialog.setText(tr("Uninstalling the WAD will remove the currently installed version of "
                            "this title from the NAND without deleting its save data. Continue?"));
  warning_dialog.setStandardButtons(QMessageBox::No | QMessageBox::Yes);

  if (warning_dialog.exec() == QMessageBox::No)
    return;

  ModalMessageBox result_dialog(this);

  const bool success = WiiUtils::UninstallTitle(game->GetTitleID());

  result_dialog.setIcon(success ? QMessageBox::Information : QMessageBox::Critical);
  result_dialog.setWindowTitle(success ? tr("Success") : tr("Failure"));
  result_dialog.setText(success ? tr("Successfully removed this title from the NAND.") :
                                  tr("Failed to remove this title from the NAND."));
  result_dialog.exec();
}
コード例 #2
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::keyReleaseEvent(QKeyEvent* event)
{
  if (event->key() == Qt::Key_Return && GetSelectedGame() != nullptr)
    emit GameSelected();
  else
    QStackedWidget::keyReleaseEvent(event);
}
コード例 #3
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::ChangeDisc()
{
  const auto game = GetSelectedGame();
  if (!game)
    return;

  Core::RunAsCPUThread([file_path = game->GetFilePath()] { DVDInterface::ChangeDisc(file_path); });
}
コード例 #4
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::OpenWiiSaveFolder()
{
  const auto game = GetSelectedGame();
  if (!game)
    return;

  QUrl url = QUrl::fromLocalFile(QString::fromStdString(game->GetWiiFSPath()));
  QDesktopServices::openUrl(url);
}
コード例 #5
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::SetDefaultISO()
{
  const auto game = GetSelectedGame();
  if (!game)
    return;

  Settings::Instance().SetDefaultGame(
      QDir::toNativeSeparators(QString::fromStdString(game->GetFilePath())));
}
コード例 #6
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::OpenGCSaveFolder()
{
  const auto game = GetSelectedGame();
  if (!game)
    return;

  bool found = false;

  for (int i = 0; i < 2; i++)
  {
    QUrl url;
    switch (SConfig::GetInstance().m_EXIDevice[i])
    {
    case ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER:
    {
      std::string path = StringFromFormat("%s/%s/%s", File::GetUserPath(D_GCUSER_IDX).c_str(),
                                          SConfig::GetDirectoryForRegion(game->GetRegion()),
                                          i == 0 ? "Card A" : "Card B");

      std::string override_path = i == 0 ? Config::Get(Config::MAIN_GCI_FOLDER_A_PATH_OVERRIDE) :
                                           Config::Get(Config::MAIN_GCI_FOLDER_B_PATH_OVERRIDE);

      if (!override_path.empty())
        path = override_path;

      QDir dir(QString::fromStdString(path));

      if (!dir.entryList({QStringLiteral("%1-%2-*.gci")
                              .arg(QString::fromStdString(game->GetMakerID()))
                              .arg(QString::fromStdString(game->GetGameID().substr(0, 4)))})
               .empty())
      {
        url = QUrl::fromLocalFile(dir.absolutePath());
      }
      break;
    }
    case ExpansionInterface::EXIDEVICE_MEMORYCARD:
      std::string memcard_path = i == 0 ? Config::Get(Config::MAIN_MEMCARD_A_PATH) :
                                          Config::Get(Config::MAIN_MEMCARD_B_PATH);

      std::string memcard_dir;

      SplitPath(memcard_path, &memcard_dir, nullptr, nullptr);
      url = QUrl::fromLocalFile(QString::fromStdString(memcard_dir));
      break;
    }

    found |= !url.isEmpty();

    if (!url.isEmpty())
      QDesktopServices::openUrl(url);
  }

  if (!found)
    ModalMessageBox::information(this, tr("Information"), tr("No save data found."));
}
コード例 #7
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::OpenContainingFolder()
{
  const auto game = GetSelectedGame();
  if (!game)
    return;

  QUrl url = QUrl::fromLocalFile(
      QFileInfo(QString::fromStdString(game->GetFilePath())).dir().absolutePath());
  QDesktopServices::openUrl(url);
}
コード例 #8
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::OpenWiki()
{
  const auto game = GetSelectedGame();
  if (!game)
    return;

  QString game_id = QString::fromStdString(game->GetGameID());
  QString url = QStringLiteral("https://wiki.dolphin-emu.org/index.php?title=").append(game_id);
  QDesktopServices::openUrl(QUrl(url));
}
コード例 #9
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::InstallWAD()
{
  QMessageBox result_dialog(this);

  const bool success = GameFile(GetSelectedGame()).Install();

  result_dialog.setIcon(success ? QMessageBox::Information : QMessageBox::Critical);
  result_dialog.setText(success ? tr("Succesfully installed title to the NAND") :
                                  tr("Failed to install title to the NAND"));
  result_dialog.exec();
}
コード例 #10
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::ExportWiiSave()
{
  QMessageBox result_dialog(this);

  const bool success = GameFile(GetSelectedGame()).ExportWiiSave();

  result_dialog.setIcon(success ? QMessageBox::Information : QMessageBox::Critical);
  result_dialog.setText(success ? tr("Successfully exported save files") :
                                  tr("Failed to export save files!"));
  result_dialog.exec();
}
コード例 #11
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::OpenProperties()
{
  const auto game = GetSelectedGame();
  if (!game)
    return;

  PropertiesDialog* properties = new PropertiesDialog(this, *game);

  connect(properties, &PropertiesDialog::OpenGeneralSettings, this, &GameList::OpenGeneralSettings);

  properties->show();
}
コード例 #12
0
ファイル: GameList.cpp プロジェクト: jloehr/dolphin
void GameList::ShowContextMenu(const QPoint&)
{
  QMenu* menu = new QMenu(this);
  DiscIO::Platform platform = GameFile(GetSelectedGame()).GetPlatformID();
  if (platform == DiscIO::Platform::GAMECUBE_DISC || platform == DiscIO::Platform::WII_DISC)
  {
    menu->addAction(tr("Properties"), this, SLOT(OpenProperties()));
    menu->addAction(tr("Open Wiki Page"), this, SLOT(OpenWiki()));
    menu->addAction(tr("Set as Default ISO"), this, SLOT(SetDefaultISO()));
  }
  else
  {
    return;
  }
  menu->exec(QCursor::pos());
}
コード例 #13
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::InstallWAD()
{
  const auto game = GetSelectedGame();
  if (!game)
    return;

  ModalMessageBox result_dialog(this);

  const bool success = WiiUtils::InstallWAD(game->GetFilePath());

  result_dialog.setIcon(success ? QMessageBox::Information : QMessageBox::Critical);
  result_dialog.setWindowTitle(success ? tr("Success") : tr("Failure"));
  result_dialog.setText(success ? tr("Successfully installed this title to the NAND.") :
                                  tr("Failed to install this title to the NAND."));
  result_dialog.exec();
}
コード例 #14
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::MakeGridView()
{
  m_grid = new QListView(this);
  m_grid->setModel(m_grid_proxy);
  m_grid->setSelectionMode(QAbstractItemView::ExtendedSelection);
  m_grid->setViewMode(QListView::IconMode);
  m_grid->setResizeMode(QListView::Adjust);
  m_grid->setUniformItemSizes(true);
  m_grid->setContextMenuPolicy(Qt::CustomContextMenu);
  m_grid->setFrameStyle(QFrame::NoFrame);
  connect(m_grid, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
  connect(m_grid->selectionModel(), &QItemSelectionModel::selectionChanged,
          [this](const QItemSelection&, const QItemSelection&) {
            emit SelectionChanged(GetSelectedGame());
          });
}
コード例 #15
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::ShowContextMenu(const QPoint&)
{
  const auto game = GetSelectedGame();
  if (game.isEmpty())
    return;

  QMenu* menu = new QMenu(this);
  DiscIO::Platform platform = GameFile(game).GetPlatformID();
  menu->addAction(tr("Properties"), this, SLOT(OpenProperties()));
  menu->addAction(tr("Wiki"), this, SLOT(OpenWiki()));
  menu->addSeparator();

  if (platform == DiscIO::Platform::GAMECUBE_DISC || platform == DiscIO::Platform::WII_DISC)
  {
    menu->addAction(tr("Default ISO"), this, SLOT(SetDefaultISO()));
    const auto blob_type = GameFile(game).GetBlobType();

    if (blob_type == DiscIO::BlobType::GCZ)
      menu->addAction(tr("Decompress ISO"), this, SLOT(DecompressISO()));
    else if (blob_type == DiscIO::BlobType::PLAIN)
      menu->addAction(tr("Compress ISO"), this, SLOT(CompressISO()));

    menu->addSeparator();
  }
  if (platform == DiscIO::Platform::WII_WAD)
  {
    menu->addAction(tr("Install to the NAND"), this, SLOT(InstallWAD()));

    if (GameFile(game).IsInstalled())
      menu->addAction(tr("Uninstall from the NAND"), this, SLOT(UninstallWAD()));

    menu->addSeparator();
  }

  if (platform == DiscIO::Platform::WII_WAD || platform == DiscIO::Platform::WII_DISC)
  {
    menu->addAction(tr("Open Wii save folder"), this, SLOT(OpenSaveFolder()));
    menu->addAction(tr("Export Wii save (Experimental)"), this, SLOT(ExportWiiSave()));
    menu->addSeparator();
  }

  menu->addAction(tr("Open Containing Folder"), this, SLOT(OpenContainingFolder()));
  menu->addAction(tr("Remove File"), this, SLOT(DeleteFile()));
  menu->exec(QCursor::pos());
}
コード例 #16
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::UninstallWAD()
{
  QMessageBox warning_dialog(this);

  warning_dialog.setIcon(QMessageBox::Information);
  warning_dialog.setText(tr("Uninstalling the WAD will remove the currently installed version of "
                            "this title from the NAND without deleting its save data. Continue?"));
  warning_dialog.setStandardButtons(QMessageBox::No | QMessageBox::Yes);

  if (warning_dialog.exec() == QMessageBox::No)
    return;

  QMessageBox result_dialog(this);

  const bool success = GameFile(GetSelectedGame()).Uninstall();

  result_dialog.setIcon(success ? QMessageBox::Information : QMessageBox::Critical);
  result_dialog.setText(success ? tr("Succesfully removed title from the NAND") :
                                  tr("Failed to remove title from the NAND"));
  result_dialog.exec();
}
コード例 #17
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::DeleteFile()
{
  const auto game = GetSelectedGame();
  QMessageBox confirm_dialog(this);

  confirm_dialog.setIcon(QMessageBox::Warning);
  confirm_dialog.setText(tr("Are you sure you want to delete this file?"));
  confirm_dialog.setInformativeText(tr("You won't be able to undo this!"));
  confirm_dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);

  if (confirm_dialog.exec() == QMessageBox::Yes)
  {
    bool deletion_successful = false;

    while (!deletion_successful)
    {
      deletion_successful = File::Delete(game.toStdString());

      if (deletion_successful)
      {
        m_model->RemoveGame(game);
      }
      else
      {
        QMessageBox error_dialog(this);

        error_dialog.setIcon(QMessageBox::Critical);
        error_dialog.setText(tr("Failed to delete the selected file."));
        error_dialog.setInformativeText(tr("Check whether you have the permissions required to "
                                           "delete the file or whether it's still in use."));
        error_dialog.setStandardButtons(QMessageBox::Retry | QMessageBox::Abort);

        if (error_dialog.exec() == QMessageBox::Abort)
          break;
      }
    }
  }
}
コード例 #18
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::OpenSaveFolder()
{
  QUrl url = QUrl::fromLocalFile(GameFile(GetSelectedGame()).GetWiiFSPath());
  QDesktopServices::openUrl(url);
}
コード例 #19
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::MakeListView()
{
  m_list = new QTableView(this);
  m_list->setModel(m_list_proxy);

  m_list->setSelectionMode(QAbstractItemView::ExtendedSelection);
  m_list->setSelectionBehavior(QAbstractItemView::SelectRows);
  m_list->setAlternatingRowColors(true);
  m_list->setShowGrid(false);
  m_list->setSortingEnabled(true);
  m_list->setCurrentIndex(QModelIndex());
  m_list->setContextMenuPolicy(Qt::CustomContextMenu);
  m_list->setWordWrap(false);
  // Have 1 pixel of padding above and below the 32 pixel banners.
  m_list->verticalHeader()->setDefaultSectionSize(32 + 2);

  connect(m_list, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
  connect(m_list->selectionModel(), &QItemSelectionModel::selectionChanged,
          [this](const QItemSelection&, const QItemSelection&) {
            emit SelectionChanged(GetSelectedGame());
          });

  QHeaderView* hor_header = m_list->horizontalHeader();

  hor_header->restoreState(
      Settings::GetQSettings().value(QStringLiteral("tableheader/state")).toByteArray());

  hor_header->setContextMenuPolicy(Qt::CustomContextMenu);
  connect(hor_header, &QWidget::customContextMenuRequested, this, &GameList::ShowHeaderContextMenu);

  connect(hor_header, &QHeaderView::sortIndicatorChanged, this, &GameList::OnHeaderViewChanged);
  connect(hor_header, &QHeaderView::sectionCountChanged, this, &GameList::OnHeaderViewChanged);
  connect(hor_header, &QHeaderView::sectionMoved, this, &GameList::OnHeaderViewChanged);
  connect(hor_header, &QHeaderView::sectionResized, this, &GameList::OnSectionResized);

  if (!Settings::GetQSettings().contains(QStringLiteral("tableheader/state")))
    m_list->sortByColumn(GameListModel::COL_TITLE, Qt::AscendingOrder);

  hor_header->setSectionResizeMode(GameListModel::COL_PLATFORM, QHeaderView::Fixed);
  hor_header->setSectionResizeMode(GameListModel::COL_BANNER, QHeaderView::Fixed);
  hor_header->setSectionResizeMode(GameListModel::COL_TITLE, QHeaderView::Interactive);
  hor_header->setSectionResizeMode(GameListModel::COL_DESCRIPTION, QHeaderView::Interactive);
  hor_header->setSectionResizeMode(GameListModel::COL_MAKER, QHeaderView::Interactive);
  hor_header->setSectionResizeMode(GameListModel::COL_ID, QHeaderView::Fixed);
  hor_header->setSectionResizeMode(GameListModel::COL_COUNTRY, QHeaderView::Fixed);
  hor_header->setSectionResizeMode(GameListModel::COL_SIZE, QHeaderView::Fixed);
  hor_header->setSectionResizeMode(GameListModel::COL_FILE_NAME, QHeaderView::Interactive);
  hor_header->setSectionResizeMode(GameListModel::COL_TAGS, QHeaderView::Interactive);

  // There's some odd platform-specific behavior with default minimum section size
  hor_header->setMinimumSectionSize(38);

  // Cells have 3 pixels of padding, so the width of these needs to be image width + 6. Banners are
  // 96 pixels wide, platform and country icons are 32 pixels wide.
  m_list->setColumnWidth(GameListModel::COL_BANNER, 102);
  m_list->setColumnWidth(GameListModel::COL_PLATFORM, 38);
  m_list->setColumnWidth(GameListModel::COL_COUNTRY, 38);
  m_list->setColumnWidth(GameListModel::COL_SIZE, 85);
  m_list->setColumnWidth(GameListModel::COL_ID, 70);

  UpdateColumnVisibility();

  m_list->verticalHeader()->hide();
  m_list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  m_list->setFrameStyle(QFrame::NoFrame);

  hor_header->setSectionsMovable(true);
  hor_header->setHighlightSections(false);
}
コード例 #20
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::SetDefaultISO()
{
  Settings::Instance().SetDefaultGame(GetSelectedGame());
}
コード例 #21
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::OpenContainingFolder()
{
  QUrl url = QUrl::fromLocalFile(QFileInfo(GetSelectedGame()).dir().absolutePath());
  QDesktopServices::openUrl(url);
}
コード例 #22
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::CompressISO(bool decompress)
{
  auto files = GetSelectedGames();
  const auto game = GetSelectedGame();

  if (files.empty() || !game)
    return;

  bool wii_warning_given = false;
  for (QMutableListIterator<std::shared_ptr<const UICommon::GameFile>> it(files); it.hasNext();)
  {
    auto file = it.next();

    if ((file->GetPlatform() != DiscIO::Platform::GameCubeDisc &&
         file->GetPlatform() != DiscIO::Platform::WiiDisc) ||
        (decompress && file->GetBlobType() != DiscIO::BlobType::GCZ) ||
        (!decompress && file->GetBlobType() != DiscIO::BlobType::PLAIN))
    {
      it.remove();
      continue;
    }

    if (!wii_warning_given && !decompress && file->GetPlatform() == DiscIO::Platform::WiiDisc)
    {
      ModalMessageBox wii_warning(this);
      wii_warning.setIcon(QMessageBox::Warning);
      wii_warning.setWindowTitle(tr("Confirm"));
      wii_warning.setText(tr("Are you sure?"));
      wii_warning.setInformativeText(tr(
          "Compressing a Wii disc image will irreversibly change the compressed copy by removing "
          "padding data. Your disc image will still work. Continue?"));
      wii_warning.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

      if (wii_warning.exec() == QMessageBox::No)
        return;

      wii_warning_given = true;
    }
  }

  QString dst_dir;
  QString dst_path;

  if (files.size() > 1)
  {
    dst_dir = QFileDialog::getExistingDirectory(
        this,
        decompress ? tr("Select where you want to save the decompressed images") :
                     tr("Select where you want to save the compressed images"),
        QFileInfo(QString::fromStdString(game->GetFilePath())).dir().absolutePath());

    if (dst_dir.isEmpty())
      return;
  }
  else
  {
    dst_path = QFileDialog::getSaveFileName(
        this,
        decompress ? tr("Select where you want to save the decompressed image") :
                     tr("Select where you want to save the compressed image"),
        QFileInfo(QString::fromStdString(game->GetFilePath()))
            .dir()
            .absoluteFilePath(
                QFileInfo(QString::fromStdString(files[0]->GetFilePath())).completeBaseName())
            .append(decompress ? QStringLiteral(".gcm") : QStringLiteral(".gcz")),
        decompress ? tr("Uncompressed GC/Wii images (*.iso *.gcm)") :
                     tr("Compressed GC/Wii images (*.gcz)"));

    if (dst_path.isEmpty())
      return;
  }

  for (const auto& file : files)
  {
    const auto original_path = file->GetFilePath();
    if (files.size() > 1)
    {
      dst_path =
          QDir(dst_dir)
              .absoluteFilePath(QFileInfo(QString::fromStdString(original_path)).completeBaseName())
              .append(decompress ? QStringLiteral(".gcm") : QStringLiteral(".gcz"));
      QFileInfo dst_info = QFileInfo(dst_path);
      if (dst_info.exists())
      {
        ModalMessageBox confirm_replace(this);
        confirm_replace.setIcon(QMessageBox::Warning);
        confirm_replace.setWindowTitle(tr("Confirm"));
        confirm_replace.setText(tr("The file %1 already exists.\n"
                                   "Do you wish to replace it?")
                                    .arg(dst_info.fileName()));
        confirm_replace.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

        if (confirm_replace.exec() == QMessageBox::No)
          continue;
      }
    }

    QProgressDialog progress_dialog(decompress ? tr("Decompressing...") : tr("Compressing..."),
                                    tr("Abort"), 0, 100, this);
    progress_dialog.setWindowModality(Qt::WindowModal);
    progress_dialog.setWindowFlags(progress_dialog.windowFlags() &
                                   ~Qt::WindowContextHelpButtonHint);
    progress_dialog.setWindowTitle(tr("Progress"));

    bool good;

    if (decompress)
    {
      if (files.size() > 1)
        progress_dialog.setLabelText(tr("Decompressing...") + QStringLiteral("\n") +
                                     QFileInfo(QString::fromStdString(original_path)).fileName());
      good = DiscIO::DecompressBlobToFile(original_path, dst_path.toStdString(), &CompressCB,
                                          &progress_dialog);
    }
    else
    {
      if (files.size() > 1)
        progress_dialog.setLabelText(tr("Compressing...") + QStringLiteral("\n") +
                                     QFileInfo(QString::fromStdString(original_path)).fileName());
      good = DiscIO::CompressFileToBlob(original_path, dst_path.toStdString(),
                                        file->GetPlatform() == DiscIO::Platform::WiiDisc ? 1 : 0,
                                        16384, &CompressCB, &progress_dialog);
    }

    if (!good)
    {
      QErrorMessage(this).showMessage(tr("Dolphin failed to complete the requested action."));
      return;
    }
  }

  ModalMessageBox::information(this, tr("Success"),
                               decompress ?
                                   tr("Successfully decompressed %n image(s).", "", files.size()) :
                                   tr("Successfully compressed %n image(s).", "", files.size()));
}
コード例 #23
0
ファイル: GameList.cpp プロジェクト: booto/dolphin
void GameList::ShowContextMenu(const QPoint&)
{
  if (!GetSelectedGame())
    return;

  QMenu* menu = new QMenu(this);

  if (HasMultipleSelected())
  {
    bool wii_saves = true;
    bool compress = false;
    bool decompress = false;

    for (const auto& game : GetSelectedGames())
    {
      DiscIO::Platform platform = game->GetPlatform();

      if (platform == DiscIO::Platform::GameCubeDisc || platform == DiscIO::Platform::WiiDisc)
      {
        const auto blob_type = game->GetBlobType();
        if (blob_type == DiscIO::BlobType::GCZ)
          decompress = true;
        else if (blob_type == DiscIO::BlobType::PLAIN)
          compress = true;
      }

      if (platform != DiscIO::Platform::WiiWAD && platform != DiscIO::Platform::WiiDisc)
        wii_saves = false;
    }

    if (compress)
      menu->addAction(tr("Compress Selected ISOs..."), this, [this] { CompressISO(false); });
    if (decompress)
      menu->addAction(tr("Decompress Selected ISOs..."), this, [this] { CompressISO(true); });
    if (compress || decompress)
      menu->addSeparator();

    if (wii_saves)
    {
      menu->addAction(tr("Export Wii Saves (Experimental)"), this, &GameList::ExportWiiSave);
      menu->addSeparator();
    }

    menu->addAction(tr("Delete Selected Files..."), this, &GameList::DeleteFile);
  }
  else
  {
    const auto game = GetSelectedGame();
    DiscIO::Platform platform = game->GetPlatform();

    if (platform != DiscIO::Platform::ELFOrDOL)
    {
      menu->addAction(tr("&Properties"), this, &GameList::OpenProperties);
      menu->addAction(tr("&Wiki"), this, &GameList::OpenWiki);

      menu->addSeparator();
    }

    if (platform == DiscIO::Platform::GameCubeDisc || platform == DiscIO::Platform::WiiDisc)
    {
      menu->addAction(tr("Set as &Default ISO"), this, &GameList::SetDefaultISO);
      const auto blob_type = game->GetBlobType();

      if (blob_type == DiscIO::BlobType::GCZ)
        menu->addAction(tr("Decompress ISO..."), this, [this] { CompressISO(true); });
      else if (blob_type == DiscIO::BlobType::PLAIN)
        menu->addAction(tr("Compress ISO..."), this, [this] { CompressISO(false); });

      QAction* change_disc = menu->addAction(tr("Change &Disc"), this, &GameList::ChangeDisc);

      connect(&Settings::Instance(), &Settings::EmulationStateChanged, change_disc,
              [change_disc] { change_disc->setEnabled(Core::IsRunning()); });
      change_disc->setEnabled(Core::IsRunning());

      menu->addSeparator();
    }

    if (platform == DiscIO::Platform::WiiDisc)
    {
      auto* perform_disc_update = menu->addAction(tr("Perform System Update"), this,
                                                  [this, file_path = game->GetFilePath()] {
                                                    WiiUpdate::PerformDiscUpdate(file_path, this);
                                                  });
      perform_disc_update->setEnabled(!Core::IsRunning() || !SConfig::GetInstance().bWii);
    }

    if (platform == DiscIO::Platform::WiiWAD)
    {
      QAction* wad_install_action = new QAction(tr("Install to the NAND"), menu);
      QAction* wad_uninstall_action = new QAction(tr("Uninstall from the NAND"), menu);

      connect(wad_install_action, &QAction::triggered, this, &GameList::InstallWAD);
      connect(wad_uninstall_action, &QAction::triggered, this, &GameList::UninstallWAD);

      for (QAction* a : {wad_install_action, wad_uninstall_action})
      {
        a->setEnabled(!Core::IsRunning());
        menu->addAction(a);
      }
      if (!Core::IsRunning())
        wad_uninstall_action->setEnabled(WiiUtils::IsTitleInstalled(game->GetTitleID()));

      connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu,
              [=](Core::State state) {
                wad_install_action->setEnabled(state == Core::State::Uninitialized);
                wad_uninstall_action->setEnabled(state == Core::State::Uninitialized &&
                                                 WiiUtils::IsTitleInstalled(game->GetTitleID()));
              });

      menu->addSeparator();
    }

    if (platform == DiscIO::Platform::WiiWAD || platform == DiscIO::Platform::WiiDisc)
    {
      menu->addAction(tr("Open Wii &Save Folder"), this, &GameList::OpenWiiSaveFolder);
      menu->addAction(tr("Export Wii Save (Experimental)"), this, &GameList::ExportWiiSave);
      menu->addSeparator();
    }

    if (platform == DiscIO::Platform::GameCubeDisc)
    {
      menu->addAction(tr("Open GameCube &Save Folder"), this, &GameList::OpenGCSaveFolder);
      menu->addSeparator();
    }

    menu->addAction(tr("Open &Containing Folder"), this, &GameList::OpenContainingFolder);
    menu->addAction(tr("Delete File..."), this, &GameList::DeleteFile);

    menu->addSeparator();

    auto* model = Settings::Instance().GetGameListModel();

    auto* tags_menu = menu->addMenu(tr("Tags"));

    auto path = game->GetFilePath();
    auto game_tags = model->GetGameTags(path);

    for (const auto& tag : model->GetAllTags())
    {
      auto* tag_action = tags_menu->addAction(tag);

      tag_action->setCheckable(true);
      tag_action->setChecked(game_tags.contains(tag));

      connect(tag_action, &QAction::toggled, [path, tag, model](bool checked) {
        if (!checked)
          model->RemoveGameTag(path, tag);
        else
          model->AddGameTag(path, tag);
      });
    }

    menu->addAction(tr("New Tag..."), this, &GameList::NewTag);
    menu->addAction(tr("Remove Tag..."), this, &GameList::DeleteTag);

    menu->addSeparator();

    QAction* netplay_host = new QAction(tr("Host with NetPlay"), menu);

    connect(netplay_host, &QAction::triggered, [this, game] {
      emit NetPlayHost(QString::fromStdString(game->GetUniqueIdentifier()));
    });

    connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu, [=](Core::State state) {
      netplay_host->setEnabled(state == Core::State::Uninitialized);
    });
    netplay_host->setEnabled(!Core::IsRunning());

    menu->addAction(netplay_host);
  }

  menu->exec(QCursor::pos());
}
コード例 #24
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::CompressISO()
{
  const auto original_path = GetSelectedGame();
  auto file = GameFile(original_path);

  const bool compressed = (file.GetBlobType() == DiscIO::BlobType::GCZ);

  if (!compressed && file.GetPlatformID() == DiscIO::Platform::WII_DISC)
  {
    QMessageBox wii_warning(this);
    wii_warning.setIcon(QMessageBox::Warning);
    wii_warning.setText(tr("Are you sure?"));
    wii_warning.setInformativeText(
        tr("Compressing a Wii disc image will irreversibly change the compressed copy by removing "
           "padding data. Your disc image will still work."));
    wii_warning.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

    if (wii_warning.exec() == QMessageBox::No)
      return;
  }

  QString dst_path = QFileDialog::getSaveFileName(
      this, compressed ? tr("Select where you want to save the decompressed image") :
                         tr("Select where you want to save the compressed image"),
      QFileInfo(GetSelectedGame())
          .dir()
          .absoluteFilePath(file.GetGameID())
          .append(compressed ? QStringLiteral(".gcm") : QStringLiteral(".gcz")),
      compressed ? tr("Uncompressed GC/Wii images (*.iso *.gcm") :
                   tr("Compressed GC/Wii images (*.gcz)"));

  if (dst_path.isEmpty())
    return;

  QProgressDialog progress_dialog(compressed ? tr("Decompressing...") : tr("Compressing..."),
                                  tr("Abort"), 0, 100, this);
  progress_dialog.setWindowModality(Qt::WindowModal);

  bool good;

  if (compressed)
  {
    good = DiscIO::DecompressBlobToFile(original_path.toStdString(), dst_path.toStdString(),
                                        &CompressCB, &progress_dialog);
  }
  else
  {
    good = DiscIO::CompressFileToBlob(original_path.toStdString(), dst_path.toStdString(),
                                      file.GetPlatformID() == DiscIO::Platform::WII_DISC ? 1 : 0,
                                      16384, &CompressCB, &progress_dialog);
  }

  if (good)
  {
    QMessageBox(QMessageBox::Information, tr("Success!"), tr("Successfully compressed image."),
                QMessageBox::Ok, this)
        .exec();
  }
  else
  {
    QErrorMessage(this).showMessage(tr("Dolphin failed to complete the requested action."));
  }
}
コード例 #25
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::OpenWiki()
{
  QString game_id = GameFile(GetSelectedGame()).GetGameID();
  QString url = QStringLiteral("https://wiki.dolphin-emu.org/index.php?title=").append(game_id);
  QDesktopServices::openUrl(QUrl(url));
}
コード例 #26
0
ファイル: GameList.cpp プロジェクト: ToadKing/dolphin
void GameList::OpenProperties()
{
  PropertiesDialog* properties = new PropertiesDialog(this, GameFile(GetSelectedGame()));
  properties->show();
}