Skip to content

Commit

Permalink
General cleanup, implementation of being able to filter between game/
Browse files Browse the repository at this point in the history
animation for random mode, random selection information display

- Better naming of table entries in DBTable_Game
- Ability to select include "playable" titles only in queryEntryAddApps
- Ability to filter by library for user and in queryAllGameIDs
- Removed queryAllMainAddAppIDs due to approach change
- Added several error codes required for improved random functionality
- Renamed ErrorVerbosity to MessageVerbosity since the setting now
affects no error related messages
- Random selection process now checks all main entries first and then
additional apps within them if present, choosing randomly between those
and the main entry, instead of considering all playable IDs at once. The
pool is identical to the previous approach but this implementation is
faster, especially when filtering
- Metadata for randomly selected games is now displayed before they are
started unless message verbosity is not at Full
  • Loading branch information
oblivioncth committed Dec 9, 2020
1 parent 866a506 commit 5875dd6
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 80 deletions.
37 changes: 11 additions & 26 deletions src/flashpointinstall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ QSqlError Install::initialGameQuery(QList<DBQueryBuffer>& resultBuffer, QSet<QSt
QString placeholder = ":platform";
QString baseQueryCommand = "SELECT %1 FROM " + DBTable_Game::NAME + " WHERE " +
DBTable_Game::COL_PLATFORM + " = " + placeholder + " AND " +
DBTable_Game::COL_LIBRARY + " = '" + DBTable_Game::GAME_LIBRARY + "'";
DBTable_Game::COL_LIBRARY + " = '" + DBTable_Game::ENTRY_GAME_LIBRARY + "'";

QString mainQueryCommand = baseQueryCommand.arg("`" + DBTable_Game::COLUMN_LIST.join("`,`") + "`");
QString sizeQueryCommand = baseQueryCommand.arg(GENERAL_QUERY_SIZE_COMMAND);
Expand Down Expand Up @@ -753,7 +753,7 @@ QSqlError Install::initialPlaylistQuery(DBQueryBuffer& resultBuffer, QSet<QStrin
placeHolders.chop(1); // Remove trailing ?
QString baseQueryCommand = "SELECT %1 FROM " + DBTable_Playlist::NAME + " WHERE " +
DBTable_Playlist::COL_TITLE + " IN (" + placeHolders + ") AND " +
DBTable_Playlist::COL_LIBRARY + " = '" + DBTable_Playlist::GAME_LIBRARY + "'";
DBTable_Playlist::COL_LIBRARY + " = '" + DBTable_Playlist::ENTRY_GAME_LIBRARY + "'";
QString mainQueryCommand = baseQueryCommand.arg("`" + DBTable_Playlist::COLUMN_LIST.join("`,`") + "`");
QString sizeQueryCommand = baseQueryCommand.arg(GENERAL_QUERY_SIZE_COMMAND);

Expand Down Expand Up @@ -861,7 +861,7 @@ QSqlError Install::queryEntryByID(DBQueryBuffer& resultBuffer, QUuid appID) cons
return makeNonBindQuery(resultBuffer, &fpDB, mainQueryCommand, sizeQueryCommand);
}

QSqlError Install::queryEntryAddApps(DBQueryBuffer& resultBuffer, QUuid appID) const
QSqlError Install::queryEntryAddApps(DBQueryBuffer& resultBuffer, QUuid appID, bool playableOnly) const
{
// Ensure return buffer is effectively null
resultBuffer = DBQueryBuffer();
Expand All @@ -872,14 +872,18 @@ QSqlError Install::queryEntryAddApps(DBQueryBuffer& resultBuffer, QUuid appID) c
// Make query
QString baseQueryCommand = "SELECT %1 FROM " + DBTable_Add_App::NAME + " WHERE " +
DBTable_Add_App::COL_PARENT_ID + " == '" + appID.toString(QUuid::WithoutBraces) + "'";
if(playableOnly)
baseQueryCommand += " AND " + DBTable_Add_App::COL_APP_PATH + " NOT IN ('" + DBTable_Add_App::ENTRY_EXTRAS +
"','" + DBTable_Add_App::ENTRY_MESSAGE + "') AND " + DBTable_Add_App::COL_AUTORUN +
" != 1";
QString mainQueryCommand = baseQueryCommand.arg("`" + DBTable_Add_App::COLUMN_LIST.join("`,`") + "`");
QString sizeQueryCommand = baseQueryCommand.arg(GENERAL_QUERY_SIZE_COMMAND);

resultBuffer.source = DBTable_Add_App::NAME;
return makeNonBindQuery(resultBuffer, &fpDB, mainQueryCommand, sizeQueryCommand);
}

QSqlError Install::queryAllGameIDs(DBQueryBuffer& resultBuffer)
QSqlError Install::queryAllGameIDs(DBQueryBuffer& resultBuffer, LibraryFilter filter) const
{
// Ensure return buffer is effectively null
resultBuffer = DBQueryBuffer();
Expand All @@ -888,35 +892,16 @@ QSqlError Install::queryAllGameIDs(DBQueryBuffer& resultBuffer)
QSqlDatabase fpDB = getThreadedDatabaseConnection();

// Make query
QString baseQueryCommand = "SELECT %1 FROM " + DBTable_Game::NAME + " WHERE " +
DBTable_Game::COL_STATUS + " != '" + DBTable_Game::ENTRY_NOT_WORK + "'";
QString baseQueryCommand = "SELECT %2 FROM " + DBTable_Game::NAME + " WHERE " +
DBTable_Game::COL_STATUS + " != '" + DBTable_Game::ENTRY_NOT_WORK + "'%1";
baseQueryCommand = baseQueryCommand.arg(filter == LibraryFilter::Game ? " AND " + GAME_ONLY_FILTER : (filter == LibraryFilter::Anim ? " AND " + ANIM_ONLY_FILTER : ""));
QString mainQueryCommand = baseQueryCommand.arg("`" + DBTable_Game::COL_ID + "`");
QString sizeQueryCommand = baseQueryCommand.arg(GENERAL_QUERY_SIZE_COMMAND);

resultBuffer.source = DBTable_Game::NAME;
return makeNonBindQuery(resultBuffer, &fpDB, mainQueryCommand, sizeQueryCommand);
}

QSqlError Install::queryAllMainAddAppIDs(DBQueryBuffer& resultBuffer)
{
// Ensure return buffer is effectively null
resultBuffer = DBQueryBuffer();

// Get database
QSqlDatabase fpDB = getThreadedDatabaseConnection();

// Make query
QString baseQueryCommand = "SELECT %1 FROM " + DBTable_Add_App::NAME + " WHERE " +
DBTable_Add_App::COL_APP_PATH + " NOT IN ('" + DBTable_Add_App::ENTRY_EXTRAS +
"','" + DBTable_Add_App::ENTRY_MESSAGE + "') AND " + DBTable_Add_App::COL_AUTORUN +
" != 1";
QString mainQueryCommand = baseQueryCommand.arg("`" + DBTable_Add_App::COL_ID + "`");
QString sizeQueryCommand = baseQueryCommand.arg(GENERAL_QUERY_SIZE_COMMAND);

resultBuffer.source = DBTable_Game::NAME;
return makeNonBindQuery(resultBuffer, &fpDB, mainQueryCommand, sizeQueryCommand);
}

QString Install::getPath() const { return mRootDirectory.absolutePath(); }
QStringList Install::getPlatformList() const { return mPlatformList; }
QStringList Install::getPlaylistList() const { return mPlaylistList; }
Expand Down
15 changes: 10 additions & 5 deletions src/flashpointinstall.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Install
//-Class Enums---------------------------------------------------------------------------------------------------
public:
enum class CompatLevel{ Execution, Full };
enum class LibraryFilter{ Game, Anim, Either };

//-Class Structs-------------------------------------------------------------------------------------------------
public:
Expand Down Expand Up @@ -105,7 +106,8 @@ class Install
COL_BROKEN, COL_EXTREME, COL_PLAY_MODE, COL_STATUS, COL_NOTES, COL_SOURCE, COL_APP_PATH, COL_LAUNCH_COMMAND, COL_RELEASE_DATE,
COL_VERSION, COL_ORIGINAL_DESC, COL_LANGUAGE, COL_LIBRARY, COL_ORDER_TITLE};

static inline const QString GAME_LIBRARY = "arcade";
static inline const QString ENTRY_GAME_LIBRARY = "arcade";
static inline const QString ENTRY_ANIM_LIBRARY = "theatre";
static inline const QString ENTRY_NOT_WORK = "Not Working";
};

Expand Down Expand Up @@ -138,7 +140,7 @@ class Install
static inline const QString COL_AUTHOR = "author";
static inline const QString COL_LIBRARY = "library";

static inline const QString GAME_LIBRARY = "arcade";
static inline const QString ENTRY_GAME_LIBRARY = "arcade";

static inline const QStringList COLUMN_LIST = {COL_ID, COL_TITLE, COL_DESCRIPTION, COL_AUTHOR, COL_LIBRARY};
};
Expand Down Expand Up @@ -300,6 +302,9 @@ class Install
{DBTable_Playlist_Game::NAME, DBTable_Playlist_Game::COLUMN_LIST}};
static inline const QString GENERAL_QUERY_SIZE_COMMAND = "COUNT(1)";

static inline const QString GAME_ONLY_FILTER = DBTable_Game::COL_LIBRARY + " == '" + DBTable_Game::ENTRY_GAME_LIBRARY + "'";
static inline const QString ANIM_ONLY_FILTER = DBTable_Game::COL_LIBRARY + " == '" + DBTable_Game::ENTRY_ANIM_LIBRARY + "'";

//-Instance Variables-----------------------------------------------------------------------------------------------
private:
// Files and directories
Expand Down Expand Up @@ -366,9 +371,9 @@ class Install

// Queries - CLIFp
QSqlError queryEntryByID(DBQueryBuffer& resultBuffer, QUuid appID) const;
QSqlError queryEntryAddApps(DBQueryBuffer& resultBuffer, QUuid appID) const;
QSqlError queryAllGameIDs(DBQueryBuffer& resultBuffer);
QSqlError queryAllMainAddAppIDs(DBQueryBuffer& resultBuffer);
QSqlError queryEntryAddApps(DBQueryBuffer& resultBuffer, QUuid appID, bool playableOnly = false) const;
QSqlError queryAllGameIDs(DBQueryBuffer& resultBuffer, LibraryFilter filter) const;
// QSqlError queryAllMainAddAppIDs(DBQueryBuffer& resultBuffer, LibraryFilter filter) const;

// Data access
QString getPath() const;
Expand Down
Loading

0 comments on commit 5875dd6

Please sign in to comment.