mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 17:19:44 -06:00
Automatic disc change for 2-disc games
This commit is contained in:
@ -737,6 +737,17 @@ bool GameList::HasMultipleSelected() const
|
||||
m_grid->selectionModel()->selectedIndexes().size() > 1;
|
||||
}
|
||||
|
||||
std::shared_ptr<const UICommon::GameFile> GameList::FindGame(const std::string& path) const
|
||||
{
|
||||
return m_model->FindGame(path);
|
||||
}
|
||||
|
||||
std::shared_ptr<const UICommon::GameFile>
|
||||
GameList::FindSecondDisc(const UICommon::GameFile& game) const
|
||||
{
|
||||
return m_model->FindSecondDisc(game);
|
||||
}
|
||||
|
||||
void GameList::SetViewColumn(int col, bool view)
|
||||
{
|
||||
m_list->setColumnHidden(col, !view);
|
||||
|
@ -30,6 +30,8 @@ public:
|
||||
std::shared_ptr<const UICommon::GameFile> GetSelectedGame() const;
|
||||
QList<std::shared_ptr<const UICommon::GameFile>> GetSelectedGames() const;
|
||||
bool HasMultipleSelected() const;
|
||||
std::shared_ptr<const UICommon::GameFile> FindGame(const std::string& path) const;
|
||||
std::shared_ptr<const UICommon::GameFile> FindSecondDisc(const UICommon::GameFile& game) const;
|
||||
|
||||
void SetListView() { SetPreferredView(true); }
|
||||
void SetGridView() { SetPreferredView(false); }
|
||||
|
@ -278,7 +278,7 @@ void GameListModel::AddGame(const std::shared_ptr<const UICommon::GameFile>& gam
|
||||
|
||||
void GameListModel::UpdateGame(const std::shared_ptr<const UICommon::GameFile>& game)
|
||||
{
|
||||
int index = FindGame(game->GetFilePath());
|
||||
int index = FindGameIndex(game->GetFilePath());
|
||||
if (index < 0)
|
||||
{
|
||||
AddGame(game);
|
||||
@ -292,7 +292,7 @@ void GameListModel::UpdateGame(const std::shared_ptr<const UICommon::GameFile>&
|
||||
|
||||
void GameListModel::RemoveGame(const std::string& path)
|
||||
{
|
||||
int entry = FindGame(path);
|
||||
int entry = FindGameIndex(path);
|
||||
if (entry < 0)
|
||||
return;
|
||||
|
||||
@ -301,7 +301,13 @@ void GameListModel::RemoveGame(const std::string& path)
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
int GameListModel::FindGame(const std::string& path) const
|
||||
std::shared_ptr<const UICommon::GameFile> GameListModel::FindGame(const std::string& path) const
|
||||
{
|
||||
const int index = FindGameIndex(path);
|
||||
return index < 0 ? nullptr : m_games[index];
|
||||
}
|
||||
|
||||
int GameListModel::FindGameIndex(const std::string& path) const
|
||||
{
|
||||
for (int i = 0; i < m_games.size(); i++)
|
||||
{
|
||||
@ -311,6 +317,29 @@ int GameListModel::FindGame(const std::string& path) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::shared_ptr<const UICommon::GameFile>
|
||||
GameListModel::FindSecondDisc(const UICommon::GameFile& game) const
|
||||
{
|
||||
std::shared_ptr<const UICommon::GameFile> match_without_revision = nullptr;
|
||||
|
||||
if (DiscIO::IsDisc(game.GetPlatform()))
|
||||
{
|
||||
for (auto& other_game : m_games)
|
||||
{
|
||||
if (game.GetGameID() == other_game->GetGameID() &&
|
||||
game.GetDiscNumber() != other_game->GetDiscNumber())
|
||||
{
|
||||
if (game.GetRevision() == other_game->GetRevision())
|
||||
return other_game;
|
||||
else
|
||||
match_without_revision = other_game;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return match_without_revision;
|
||||
}
|
||||
|
||||
void GameListModel::SetSearchTerm(const QString& term)
|
||||
{
|
||||
m_term = term;
|
||||
|
@ -63,6 +63,9 @@ public:
|
||||
void UpdateGame(const std::shared_ptr<const UICommon::GameFile>& game);
|
||||
void RemoveGame(const std::string& path);
|
||||
|
||||
std::shared_ptr<const UICommon::GameFile> FindGame(const std::string& path) const;
|
||||
std::shared_ptr<const UICommon::GameFile> FindSecondDisc(const UICommon::GameFile& game) const;
|
||||
|
||||
void SetScale(float scale);
|
||||
float GetScale() const;
|
||||
|
||||
@ -79,7 +82,7 @@ public:
|
||||
|
||||
private:
|
||||
// Index in m_games, or -1 if it isn't found
|
||||
int FindGame(const std::string& path) const;
|
||||
int FindGameIndex(const std::string& path) const;
|
||||
|
||||
QStringList m_tag_list;
|
||||
QMap<QString, QVariant> m_game_tags;
|
||||
|
Reference in New Issue
Block a user