@@ -151,9 +151,27 @@ TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
151151}
152152
153153void TombRaiderLinuxLauncher::generateList (const QList<int >& availableGames) {
154+ setInstalled ();
154155 levelListModel->setLevels (availableGames);
155156}
156157
158+ void TombRaiderLinuxLauncher::setInstalled () {
159+ QStringList keys = m_settings.allKeys ();
160+ QHash<int , bool > installedLevel;
161+ QHash<int , bool > installedGame;
162+ for (const QString &key : keys) {
163+ if (key.startsWith (" installed/game" )) {
164+ qint64 id = key.mid (QString (" installed/game" ).length ()).toInt ();
165+ installedGame.insert (id, m_settings.value (key).toBool ());
166+ } else if (key.startsWith (" installed/level" )) {
167+ qint64 id = key.mid (QString (" installed/level" ).length ()).toInt ();
168+ installedLevel.insert (id, m_settings.value (key).toBool ());
169+ }
170+ }
171+ levelListModel->setInstalledListOriginal (installedGame);
172+ levelListModel->setInstalledList (installedLevel);
173+ }
174+
157175void TombRaiderLinuxLauncher::sortByTitle () {
158176 levelListModel->sortItems (levelListModel->compareTitles );
159177}
@@ -222,7 +240,7 @@ void TombRaiderLinuxLauncher::setup() {
222240 const QString homeDir =
223241 QStandardPaths::writableLocation (QStandardPaths::HomeLocation);
224242 qDebug () << " Home Directory:" << homeDir;
225- const QString s = " /.steam/root /steamapps/common/" ;
243+ const QString s = " /.steam/steam /steamapps/common/" ;
226244 const QString l = " /.local/share/TombRaiderLinuxLauncher" ;
227245 ui->gamePathEdit ->setText (homeDir + s);
228246 ui->levelPathEdit ->setText (homeDir + l);
@@ -231,8 +249,7 @@ void TombRaiderLinuxLauncher::setup() {
231249void TombRaiderLinuxLauncher::originalSelected (qint64 id) {
232250 if (id != 0 ) {
233251 // the game directory was a symbolic link and it has a level directory
234- if ((controller.checkGameDirectory (id) == 2 )
235- && (controller.getItemState (id) == 1 )) {
252+ if (levelListModel->getInstalled (id)) {
236253 ui->pushButtonLink ->setEnabled (true );
237254 ui->pushButtonDownload ->setEnabled (false );
238255 } else {
@@ -247,7 +264,7 @@ void TombRaiderLinuxLauncher::levelDirSelected(qint64 id) {
247264 if (id != 0 ) {
248265 int state = controller.getItemState (id);
249266 // Activate or deactivate pushbuttons based on the selected item
250- qDebug () << id << Qt::endl;
267+ qDebug () << " Selected: " << id << Qt::endl;
251268 // if state == 1 then only activate link button
252269 // if state == 2 then only activate link and info button
253270 // if state == 0 then only activate download button
@@ -329,6 +346,9 @@ void TombRaiderLinuxLauncher::linkClicked() {
329346 if (m_settings.value (QString (" level%1/RunnerType" ).arg (id)) == 2 ) {
330347 Model::getInstance ().runWine (id);
331348 } else {
349+ if (levelListModel->getListType ()) {
350+ id = (-1 )*id;
351+ }
332352 if (!controller.link (id)) {
333353 qDebug () << " link error" ;
334354 }
@@ -343,7 +363,6 @@ void TombRaiderLinuxLauncher::downloadClicked() {
343363 if (current.isValid ()) {
344364 qint64 id = levelListModel->getLid (current);
345365 if (levelListModel->getListType ()) {
346- qDebug () << " controller.setupGame(" << id << " )" ;
347366 ui->listViewLevels ->setEnabled (false );
348367 ui->progressBar ->setValue (0 );
349368 ui->stackedWidgetBar ->setCurrentWidget (
@@ -445,11 +464,18 @@ void TombRaiderLinuxLauncher::workTick() {
445464 QModelIndex current = ui->listViewLevels ->currentIndex ();
446465 if (current.isValid ()) {
447466 qint64 id = levelListModel->getLid (current);
448- if (id < 0 ) { // its the original game
467+ levelListModel->setInstalled (current);
468+ if (levelListModel->getListType ()) { // its the original game
469+ m_settings.setValue (
470+ QString (" installed/game%1" ).arg (id),
471+ " true" );
449472 ui->pushButtonLink ->setEnabled (true );
450473 ui->pushButtonInfo ->setEnabled (false );
451474 ui->pushButtonDownload ->setEnabled (false );
452- } else if (id > 0 ) {
475+ } else {
476+ m_settings.setValue (
477+ QString (" installed/level%1" ).arg (id),
478+ " true" );
453479 ui->pushButtonLink ->setEnabled (true );
454480 ui->pushButtonInfo ->setEnabled (true );
455481 ui->pushButtonDownload ->setEnabled (false );
@@ -497,6 +523,7 @@ void TombRaiderLinuxLauncher::GlobalSaveClicked() {
497523 controller.setup (newLevelPath, newGamePath);
498524 }
499525}
526+
500527void TombRaiderLinuxLauncher::GlobalResetClicked () {
501528 ui->tableWidgetSetup ->item (0 , 0 )->setText (
502529 m_settings.value (" gamePath" ).toString ());
0 commit comments