Skip to content

Commit

Permalink
Also support client stock mods.
Browse files Browse the repository at this point in the history
  • Loading branch information
DeathByDenim committed Mar 11, 2015
1 parent 94793bc commit 947626f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
43 changes: 36 additions & 7 deletions moddatabaseframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ ModDatabaseFrame::ModDatabaseFrame(QWidget* parent)
main_widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
QVBoxLayout *main_layout = new QVBoxLayout(main_widget);

QWidget *client_mods_widget = loadMods("client_mods", client_mod, main_widget);
if(client_mods_widget == NULL)
client_mods_widget = loadMods("mods", client_mod, main_widget);

QWidget *client_mods_widget = loadMods(client_mod, main_widget);
if(client_mods_widget)
main_layout->addWidget(client_mods_widget);

QWidget *server_mods_widget = loadMods("server_mods", server_mod, main_widget);
QWidget *server_mods_widget = loadMods(server_mod, main_widget);
if(server_mods_widget)
main_layout->addWidget(server_mods_widget);

Expand Down Expand Up @@ -73,7 +70,7 @@ void ModDatabaseFrame::getMoreClicked(bool)
QDesktopServices::openUrl(QUrl("https://forums.uberent.com/threads/rel-pa-mod-manager-cross-platform.59992/"));
}

QWidget * ModDatabaseFrame::loadMods(QString mod_dir, ModDatabaseFrame::mod_type type, QWidget* parent)
QWidget * ModDatabaseFrame::loadMods(ModDatabaseFrame::mod_type type, QWidget* parent)
{
#if defined(linux)
const QString local_pa_dir(QDir::homePath() + "/.local/Uber Entertainment/Planetary Annihilation");
Expand All @@ -87,8 +84,27 @@ QWidget * ModDatabaseFrame::loadMods(QString mod_dir, ModDatabaseFrame::mod_type

QList<mod_t *> mod_list;
QJsonArray enabled_mods;
QString mod_dir;
QString mods_json_file_name;

switch(type)
{
case server_mod:
mod_dir = "server_mods";
mods_json_file_name = local_pa_dir + "/" + mod_dir + "/mods.json";
break;
case client_mod:
mod_dir = "client_mods";
mods_json_file_name = local_pa_dir + "/" + mod_dir + "/mods.json";
if(!QFileInfo(mods_json_file_name).exists())
{
mod_dir = "mods";
mods_json_file_name = local_pa_dir + "/" + mod_dir + "/mods.json";
}
break;
}

QFile mods_json_file(local_pa_dir + "/" + mod_dir + "/mods.json");
QFile mods_json_file(mods_json_file_name);
if(mods_json_file.open(QFile::ReadOnly))
{
enabled_mods = QJsonDocument::fromJson(mods_json_file.readAll()).object()["mount_order"].toArray();
Expand Down Expand Up @@ -288,6 +304,19 @@ QWidget * ModDatabaseFrame::loadMods(QString mod_dir, ModDatabaseFrame::mod_type
stockmod->check_box = NULL;
mod_list.push_back(stockmod);
}
else if(type == client_mod)
{
mod_t *stockmod = new mod_t;
stockmod->identifier = "com.uberent.pa.mods.stockmods.client.cheat.server_browser_show_cheat_servers";
stockmod->name = "Server Browser - Show Cheat Servers";
stockmod->mods_json_file_name = local_pa_dir + "/" + mod_dir + "/mods.json";
stockmod->type = server_mod;
stockmod->enabled = false;
stockmod->priority = 100;
stockmod->processed = false;
stockmod->check_box = NULL;
mod_list.push_back(stockmod);
}

if(mod_list.count() == 0)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion moddatabaseframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ModDatabaseFrame : public QFrame
QList<mod_t *> mModList;
bool mIgnoreStateChange;

QWidget* loadMods(QString mod_dir, mod_type type, QWidget* parent);
QWidget* loadMods(ModDatabaseFrame::mod_type type, QWidget* parent);
void updateModFiles(QString mod_json_file_name, ModDatabaseFrame::mod_type type);
static bool priorityCompare(mod_t *m1, mod_t *m2) { return (m1->priority > m2->priority); }
void enableMod(ModDatabaseFrame::mod_t* mod);
Expand Down
6 changes: 5 additions & 1 deletion paalternativelauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ PAAlternativeLauncher::PAAlternativeLauncher()
, mDefaultInstallPath(QDir::homePath() + "/Games/PA")
#elif defined(_WIN32)
, mPlatform("Windows")
, mDefaultInstallPath("C:\\Games\\PA")
, mDefaultInstallPath("C:\\Games\\Uber Entertainment\\Planetary Annihilation Launcher\\Planetary Annihilation")
#elif defined(__APPLE__)
, mPlatform("OSX")
, mDefaultInstallPath("/Applications/Planetary Annihilation")
Expand Down Expand Up @@ -477,8 +477,12 @@ void PAAlternativeLauncher::launchOfflinePushButtonClicked(bool)

if(install_path.isEmpty())
{
#ifdef _WIN32
install_path = mDefaultInstallPath + "\\stable";
#else
info.critical(tr("Launch offline"), tr("Install path is empty. It looks like this launcher never downloaded PA.\nPlease log in and download PA."));
return;
#endif
}


Expand Down

0 comments on commit 947626f

Please sign in to comment.