1212 */
1313
1414#include " ../src/Model.hpp"
15+ #include " ../src/Data.hpp"
16+ #include " ../src/Path.hpp"
1517
1618Model::Model () {}
1719Model::~Model () {}
1820
1921bool Model::setupDirectories (const QString& level, const QString& game) {
2022 bool status = false ;
23+
2124 if (fileManager.setUpCamp (level, game) &&
2225 downloader.setUpCamp (level) &&
2326 data.initializeDatabase (level) &&
2427 m_pyRunner.setUpCamp (level)) {
28+ Path::setProgramFilesPath ();
29+ Path::setResourcePath ();
2530 status = true ;
2631 }
2732 return status;
@@ -34,8 +39,10 @@ void Model::setup(const QString& level, const QString& game) {
3439 // Iterate backward to avoid index shifting
3540 for (int i = 4 ; i >= 0 ; i--) {
3641 int dirStatus = commonFiles[i];
37- if (fileManager.checkDir (
38- QString (" /Original.TR%1" ).arg (i + 1 ), false ) == true ) {
42+
43+ Path p (Path::resource);
44+ p << QString (" Original.TR%1" ).arg (i + 1 );
45+ if (p.isDir ()) {
3946 commonFiles[i] = i + 1 ;
4047 } else if (dirStatus == 2 ) {
4148 commonFiles[i] = -(i + 1 );
@@ -111,16 +118,19 @@ void Model::getCoverList(QVector<ListItemData*>* items) {
111118
112119int Model::getItemState (int id) {
113120 int status = 0 ;
121+
122+ Path path (Path::resource);
114123 if (id < 0 ) {
115- QString dir = QString (" Original.TR%1" ).arg (id);
116- if (fileManager. checkDir (dir, false )) {
124+ path << QString (" Original.TR%1" ).arg (id);
125+ if (path. isDir ( )) {
117126 status = 2 ;
118127 } else {
119128 status = 1 ;
120129 }
121130 } else if (id > 0 ) {
122- QString dir = QString (" %1.TRLE" ).arg (id);
123- if (fileManager.checkDir (dir, false )) {
131+ path << QString (" %1.TRLE" ).arg (id);
132+ qDebug () << " getItemState: path is " << path.get ();
133+ if (path.isDir ()) {
124134 status = 2 ;
125135 } else {
126136 status = 0 ;
@@ -175,8 +185,8 @@ bool Model::runUmu(const int id) {
175185}
176186
177187
178- void Model::setUmuEnv (const QVector<QPair<QString, QString>>& env ) {
179- for (const QPair<QString, QString>& e : env ) {
188+ void Model::setUmuEnv (const QVector<QPair<QString, QString>>& environment ) {
189+ for (const QPair<QString, QString>& e : environment ) {
180190 m_umuRunner.insertProcessEnvironment (e);
181191 }
182192}
@@ -224,8 +234,8 @@ bool Model::runWine(const qint64 id) {
224234 return status;
225235}
226236
227- void Model::setWineEnv (const QVector<QPair<QString, QString>>& env ) {
228- for (const QPair<QString, QString>& e : env ) {
237+ void Model::setWineEnv (const QVector<QPair<QString, QString>>& environment ) {
238+ for (const QPair<QString, QString>& e : environment ) {
229239 m_wineRunner.insertProcessEnvironment (e);
230240 }
231241}
@@ -236,19 +246,22 @@ void Model::setWineSetup() {
236246
237247bool Model::setLink (int id) {
238248 bool status = false ;
249+ Path path (Path::resource);
239250 if (id < 0 ) { // we use original game id as negative number
240251 int orgId = (-1 )*id;
241- const QString s = QString (" /Original.TR%1" ).arg (orgId);
242- if (fileManager.checkDir (s, false )) {
252+ path << QString (" Original.TR%1" ).arg (orgId);
253+ const QString s = path.get ();
254+ if (path.isDir ()) {
243255 status = fileManager.linkGameDir (s, getGameDirectory (orgId));
244256 } else {
245257 qDebug () << " Dirr: " << s << " seems to bee missing" ;
246258 }
247259 } else {
248- const QString s = QString (" /%1.TRLE" ).arg (id);
260+ path << QString (" %1.TRLE" ).arg (id);
261+ const QString s = path.get ();
249262 const int t = data.getType (id);
250263
251- if (fileManager. checkDir (s, false )) {
264+ if (path. isDir ( )) {
252265 status = fileManager.linkGameDir (s, getGameDirectory (t));
253266 } else {
254267 qDebug () << " Dirr: " << s << " seems to bee missing" ;
@@ -258,7 +271,7 @@ bool Model::setLink(int id) {
258271}
259272
260273void Model::setupGame (int id) {
261- QVector<File > list = data.getFileList (id);
274+ QVector<FileListItem > list = data.getFileList (id);
262275 const size_t s = list.size ();
263276 assert (s != (unsigned int )0 );
264277
@@ -363,7 +376,11 @@ void Model::getLevel(int id) {
363376 downloader.setUrl (zipData.m_URL );
364377 downloader.setSaveFile (zipData.m_fileName );
365378 // this if just slips up execution but has nothing to do with the error
366- if (fileManager.checkFile (zipData.m_fileName , false )) {
379+
380+ Path path (Path::resource);
381+ path << zipData.m_fileName ;
382+
383+ if (path.isFile ()) {
367384 qWarning () << " File exists:" << zipData.m_fileName ;
368385 status = getLevelHaveFile (id, zipData.m_MD5sum , zipData.m_fileName );
369386 } else {
0 commit comments