From 5ff6fbf4648d286ff0f07a4dbf37c0b72651f66b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 28 Aug 2013 04:38:29 +0200 Subject: Basic 1.6 mod management (no jar mods) --- CMakeLists.txt | 8 +- gui/LegacyModEditDialog.cpp | 32 ++---- gui/LegacyModEditDialog.ui | 4 +- gui/ModEditDialogCommon.cpp | 17 ++++ gui/ModEditDialogCommon.h | 4 + gui/OneSixModEditDialog.cpp | 165 ++++++++++++++++++++++++++++++ gui/OneSixModEditDialog.h | 52 ++++++++++ gui/OneSixModEditDialog.ui | 187 ++++++++++++++++++++++++++++++++++ gui/modeditdialog.cpp | 35 ------- gui/modeditdialog.h | 52 ---------- gui/modeditdialog.ui | 167 ------------------------------ gui/modeditwindow.cpp | 37 ------- gui/modeditwindow.h | 0 gui/modeditwindow.ui | 241 -------------------------------------------- logic/LegacyInstance.cpp | 15 ++- logic/LegacyInstance.h | 2 +- logic/OneSixInstance.cpp | 42 +++++++- logic/OneSixInstance.h | 18 +++- logic/OneSixInstance_p.h | 5 +- logic/OneSixUpdate.cpp | 2 +- logic/OneSixVersion.cpp | 4 +- logic/OneSixVersion.h | 4 +- logic/VersionFactory.cpp | 12 +-- logic/VersionFactory.h | 6 +- 24 files changed, 518 insertions(+), 593 deletions(-) create mode 100644 gui/ModEditDialogCommon.cpp create mode 100644 gui/ModEditDialogCommon.h create mode 100644 gui/OneSixModEditDialog.cpp create mode 100644 gui/OneSixModEditDialog.h create mode 100644 gui/OneSixModEditDialog.ui delete mode 100644 gui/modeditdialog.cpp delete mode 100644 gui/modeditdialog.h delete mode 100644 gui/modeditdialog.ui delete mode 100644 gui/modeditwindow.cpp delete mode 100644 gui/modeditwindow.h delete mode 100644 gui/modeditwindow.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 5938b07b..ba139ff6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,7 +152,6 @@ AppVersion.h AppSettings.h gui/mainwindow.h -gui/modeditdialog.h gui/settingsdialog.h gui/newinstancedialog.h gui/logindialog.h @@ -165,6 +164,8 @@ gui/lwjglselectdialog.h gui/instancesettings.h gui/IconPickerDialog.h gui/LegacyModEditDialog.h +gui/OneSixModEditDialog.h +gui/ModEditDialogCommon.h gui/ModListView.h gui/LabeledToolButton.h gui/EditNotesDialog.h @@ -222,7 +223,6 @@ AppVersion.cpp AppSettings.cpp gui/mainwindow.cpp -gui/modeditdialog.cpp gui/settingsdialog.cpp gui/newinstancedialog.cpp gui/logindialog.cpp @@ -235,6 +235,8 @@ gui/lwjglselectdialog.cpp gui/instancesettings.cpp gui/IconPickerDialog.cpp gui/LegacyModEditDialog.cpp +gui/OneSixModEditDialog.cpp +gui/ModEditDialogCommon.cpp gui/ModListView.cpp gui/LabeledToolButton.cpp gui/EditNotesDialog.cpp @@ -282,7 +284,6 @@ logic/tasks/LoginTask.cpp ######## UIs ######## SET(MULTIMC_UIS gui/mainwindow.ui -gui/modeditdialog.ui gui/settingsdialog.ui gui/newinstancedialog.ui gui/logindialog.ui @@ -294,6 +295,7 @@ gui/lwjglselectdialog.ui gui/instancesettings.ui gui/IconPickerDialog.ui gui/LegacyModEditDialog.ui +gui/OneSixModEditDialog.ui gui/EditNotesDialog.ui ) diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index 27856bb5..3181e7ee 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -14,6 +14,7 @@ */ #include "LegacyModEditDialog.h" +#include "ModEditDialogCommon.h" #include "ui_LegacyModEditDialog.h" #include #include @@ -57,12 +58,13 @@ LegacyModEditDialog::LegacyModEditDialog( LegacyInstance* inst, QWidget* parent { ensureFolderPathExists(m_inst->loaderModsDir()); m_mods = m_inst->loaderModList(); - ui->mlModTreeView->setModel(m_mods.data()); - ui->mlModTreeView->installEventFilter( this ); + ui->loaderModTreeView->setModel(m_mods.data()); + ui->loaderModTreeView->installEventFilter( this ); m_mods->startWatching(); } // texture packs { + ensureFolderPathExists(m_inst->texturePacksDir()); m_texturepacks = m_inst->texturePackList(); ui->texPackTreeView->setModel(m_texturepacks.data()); ui->texPackTreeView->installEventFilter( this ); @@ -142,7 +144,7 @@ bool LegacyModEditDialog::loaderListFilter ( QKeyEvent* keyEvent ) default: break; } - return QDialog::eventFilter( ui->mlModTreeView, keyEvent ); + return QDialog::eventFilter( ui->loaderModTreeView, keyEvent ); } bool LegacyModEditDialog::texturePackListFilter ( QKeyEvent* keyEvent ) @@ -173,10 +175,10 @@ bool LegacyModEditDialog::eventFilter ( QObject* obj, QEvent* ev ) return jarListFilter(keyEvent); if(obj == ui->coreModsTreeView) return coreListFilter(keyEvent); - if(obj == ui->mlModTreeView) + if(obj == ui->loaderModTreeView) return loaderListFilter(keyEvent); if(obj == ui->texPackTreeView) - return loaderListFilter(keyEvent); + return texturePackListFilter(keyEvent); return QDialog::eventFilter( obj, ev ); } @@ -226,22 +228,6 @@ void LegacyModEditDialog::on_addTexPackBtn_clicked() } } -bool lastfirst (QModelIndexList & list, int & first, int & last) -{ - if(!list.size()) - return false; - first = last = list[0].row(); - for(auto item: list) - { - int row = item.row(); - if(row < first) - first = row; - if(row > last) - last = row; - } - return true; -} - void LegacyModEditDialog::on_moveJarDownBtn_clicked() { int first, last; @@ -286,7 +272,7 @@ void LegacyModEditDialog::on_rmJarBtn_clicked() void LegacyModEditDialog::on_rmModBtn_clicked() { int first, last; - auto list = ui->mlModTreeView->selectionModel()->selectedRows(); + auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); if(!lastfirst(list, first, last)) return; @@ -315,7 +301,7 @@ void LegacyModEditDialog::on_viewModBtn_clicked() } void LegacyModEditDialog::on_viewTexPackBtn_clicked() { - openDirInDefaultProgram(m_inst->texturePackDir(), true); + openDirInDefaultProgram(m_inst->texturePacksDir(), true); } diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui index 49ddbb19..bd147c85 100644 --- a/gui/LegacyModEditDialog.ui +++ b/gui/LegacyModEditDialog.ui @@ -145,11 +145,11 @@ - Mods + Loader Mods - + true diff --git a/gui/ModEditDialogCommon.cpp b/gui/ModEditDialogCommon.cpp new file mode 100644 index 00000000..5da0a039 --- /dev/null +++ b/gui/ModEditDialogCommon.cpp @@ -0,0 +1,17 @@ +#include "ModEditDialogCommon.h" + +bool lastfirst (QModelIndexList & list, int & first, int & last) +{ + if(!list.size()) + return false; + first = last = list[0].row(); + for(auto item: list) + { + int row = item.row(); + if(row < first) + first = row; + if(row > last) + last = row; + } + return true; +} \ No newline at end of file diff --git a/gui/ModEditDialogCommon.h b/gui/ModEditDialogCommon.h new file mode 100644 index 00000000..a27a8a82 --- /dev/null +++ b/gui/ModEditDialogCommon.h @@ -0,0 +1,4 @@ +#pragma once +#include + +bool lastfirst (QModelIndexList & list, int & first, int & last); \ No newline at end of file diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp new file mode 100644 index 00000000..8e738fa1 --- /dev/null +++ b/gui/OneSixModEditDialog.cpp @@ -0,0 +1,165 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "OneSixModEditDialog.h" +#include "ModEditDialogCommon.h" +#include "ui_OneSixModEditDialog.h" +#include +#include +#include +#include +#include +#include + +OneSixModEditDialog::OneSixModEditDialog(OneSixInstance * inst, QWidget *parent): + m_inst(inst), + QDialog(parent), + ui(new Ui::OneSixModEditDialog) +{ + ui->setupUi(this); + //TODO: libraries! + { + // yeah... here be the real dragons. + } + // Loader mods + { + ensureFolderPathExists(m_inst->loaderModsDir()); + m_mods = m_inst->loaderModList(); + ui->loaderModTreeView->setModel(m_mods.data()); + ui->loaderModTreeView->installEventFilter( this ); + m_mods->startWatching(); + } + // resource packs + { + ensureFolderPathExists(m_inst->resourcePacksDir()); + m_resourcepacks = m_inst->resourcePackList(); + ui->resPackTreeView->setModel(m_resourcepacks.data()); + ui->resPackTreeView->installEventFilter( this ); + m_resourcepacks->startWatching(); + } +} + +OneSixModEditDialog::~OneSixModEditDialog() +{ + m_mods->stopWatching(); + m_resourcepacks->stopWatching(); + delete ui; +} + +bool OneSixModEditDialog::loaderListFilter ( QKeyEvent* keyEvent ) +{ + switch(keyEvent->key()) + { + case Qt::Key_Delete: + on_rmModBtn_clicked(); + return true; + case Qt::Key_Plus: + on_addModBtn_clicked(); + return true; + default: + break; + } + return QDialog::eventFilter( ui->loaderModTreeView, keyEvent ); +} + +bool OneSixModEditDialog::resourcePackListFilter ( QKeyEvent* keyEvent ) +{ + switch(keyEvent->key()) + { + case Qt::Key_Delete: + on_rmResPackBtn_clicked(); + return true; + case Qt::Key_Plus: + on_addResPackBtn_clicked(); + return true; + default: + break; + } + return QDialog::eventFilter( ui->resPackTreeView, keyEvent ); +} + + +bool OneSixModEditDialog::eventFilter ( QObject* obj, QEvent* ev ) +{ + if (ev->type() != QEvent::KeyPress) + { + return QDialog::eventFilter( obj, ev ); + } + QKeyEvent *keyEvent = static_cast(ev); + if(obj == ui->loaderModTreeView) + return loaderListFilter(keyEvent); + if(obj == ui->resPackTreeView) + return resourcePackListFilter(keyEvent); + return QDialog::eventFilter( obj, ev ); +} + +void OneSixModEditDialog::on_buttonBox_rejected() +{ + close(); +} + +void OneSixModEditDialog::on_addModBtn_clicked() +{ + QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Loader Mods"); + for(auto filename:fileNames) + { + m_mods->stopWatching(); + m_mods->installMod(QFileInfo(filename)); + m_mods->startWatching(); + } +} +void OneSixModEditDialog::on_rmModBtn_clicked() +{ + int first, last; + auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); + + if(!lastfirst(list, first, last)) + return; + m_mods->stopWatching(); + m_mods->deleteMods(first, last); + m_mods->startWatching(); +} +void OneSixModEditDialog::on_viewModBtn_clicked() +{ + openDirInDefaultProgram(m_inst->loaderModsDir(), true); +} + + +void OneSixModEditDialog::on_addResPackBtn_clicked() +{ + QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Resource Packs"); + for(auto filename:fileNames) + { + m_resourcepacks->stopWatching(); + m_resourcepacks->installMod(QFileInfo(filename)); + m_resourcepacks->startWatching(); + } +} +void OneSixModEditDialog::on_rmResPackBtn_clicked() +{ + int first, last; + auto list = ui->resPackTreeView->selectionModel()->selectedRows(); + + if(!lastfirst(list, first, last)) + return; + m_resourcepacks->stopWatching(); + m_resourcepacks->deleteMods(first, last); + m_resourcepacks->startWatching(); +} +void OneSixModEditDialog::on_viewResPackBtn_clicked() +{ + openDirInDefaultProgram(m_inst->resourcePacksDir(), true); +} + diff --git a/gui/OneSixModEditDialog.h b/gui/OneSixModEditDialog.h new file mode 100644 index 00000000..3430bd26 --- /dev/null +++ b/gui/OneSixModEditDialog.h @@ -0,0 +1,52 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once +#include + +#include + +namespace Ui { + class OneSixModEditDialog; +} + +class OneSixModEditDialog : public QDialog +{ + Q_OBJECT + +public: + explicit OneSixModEditDialog(OneSixInstance* inst, QWidget *parent = 0); + virtual ~OneSixModEditDialog(); + +private slots: + void on_addModBtn_clicked(); + void on_rmModBtn_clicked(); + void on_viewModBtn_clicked(); + + void on_addResPackBtn_clicked(); + void on_rmResPackBtn_clicked(); + void on_viewResPackBtn_clicked(); + // Questionable: SettingsDialog doesn't need this for some reason? + void on_buttonBox_rejected(); +protected: + bool eventFilter(QObject *obj, QEvent *ev); + bool loaderListFilter( QKeyEvent* ev ); + bool resourcePackListFilter( QKeyEvent* ev ); +private: + Ui::OneSixModEditDialog *ui; + QSharedPointer m_mods; + QSharedPointer m_resourcepacks; + OneSixInstance * m_inst; +}; diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui new file mode 100644 index 00000000..3feca726 --- /dev/null +++ b/gui/OneSixModEditDialog.ui @@ -0,0 +1,187 @@ + + + OneSixModEditDialog + + + + 0 + 0 + 543 + 423 + + + + Dialog + + + + + + true + + + + 0 + 0 + + + + 0 + + + Qt::ElideNone + + + false + + + + Library + + + + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOff + + + + + + + + Loader Mods + + + + + + true + + + QAbstractItemView::DropOnly + + + + + + + + + &Add + + + + + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + &View Folder + + + + + + + + + + Resource Packs + + + + + + true + + + QAbstractItemView::DropOnly + + + + + + + + + &Add + + + + + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + &View Folder + + + + + + + + + + + + + false + + + QDialogButtonBox::Close + + + + + + + + ModListView + QTreeView +
gui/ModListView.h
+
+
+ + +
diff --git a/gui/modeditdialog.cpp b/gui/modeditdialog.cpp deleted file mode 100644 index 011de53d..00000000 --- a/gui/modeditdialog.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "modeditdialog.h" -#include "ui_modeditdialog.h" -#include "logic/BaseInstance.h" - -ModEditDialog::ModEditDialog(QWidget *parent, BaseInstance* m_inst) : -QDialog(parent), -ui(new Ui::ModEditDialog) -{ - ui->setupUi(this); -} - -ModEditDialog::~ModEditDialog() -{ - delete ui; -} - -void ModEditDialog::on_buttonBox_rejected() -{ - close(); -} \ No newline at end of file diff --git a/gui/modeditdialog.h b/gui/modeditdialog.h deleted file mode 100644 index 94272a32..00000000 --- a/gui/modeditdialog.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MODEDITDIALOG_H -#define MODEDITDIALOG_H - -#include - -#include "logic/BaseInstance.h" - -namespace Ui { - class ModEditDialog; -} - -class ModEditDialog : public QDialog -{ - Q_OBJECT - -public: - explicit ModEditDialog(QWidget *parent = 0, BaseInstance* m_inst = 0); - ~ModEditDialog(); - -private slots: - /* Mapped for implementation - void on_addModBtn_clicked(); - void on_rmModBtn_clicked(); - void on_viewModBtn_clicked(); - - void on_addResPackBtn_clicked(); - void on_rmResPackBtn_clicked(); - void on_viewResPackBtn_clicked(); - */ - // Questionable: SettingsDialog doesn't need this for some reason? - void on_buttonBox_rejected(); - -private: - Ui::ModEditDialog *ui; -}; - -#endif // MODEDITDIALOG_H \ No newline at end of file diff --git a/gui/modeditdialog.ui b/gui/modeditdialog.ui deleted file mode 100644 index dfc59d21..00000000 --- a/gui/modeditdialog.ui +++ /dev/null @@ -1,167 +0,0 @@ - - - ModEditDialog - - - - 0 - 0 - 543 - 423 - - - - Dialog - - - - - - true - - - - 0 - 0 - - - - 0 - - - Qt::ElideNone - - - false - - - - Library - - - - - - - - - - Mods - - - - - - true - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - - - - - - - - - Resource Pack - - - - - - true - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - - - - - - - - - - - - false - - - QDialogButtonBox::Close - - - - - - - - diff --git a/gui/modeditwindow.cpp b/gui/modeditwindow.cpp deleted file mode 100644 index a7d4fbbb..00000000 --- a/gui/modeditwindow.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "modeditwindow.h" -#include "ui_modeditwindow.h" -#include "BaseInstance.h" - -#include - -ModEditWindow::ModEditWindow(QWidget *parent, BaseInstance* m_inst) : - QDialog(parent), - ui(new Ui::ModEditWindow) -{ - ui->setupUi(this); -} - -ModEditWindow::~ModEditWindow() -{ - delete ui; -} - -void ModEditWindow::on_buttonBox_rejected() -{ - close(); -} \ No newline at end of file diff --git a/gui/modeditwindow.h b/gui/modeditwindow.h deleted file mode 100644 index e69de29b..00000000 diff --git a/gui/modeditwindow.ui b/gui/modeditwindow.ui deleted file mode 100644 index 9305d553..00000000 --- a/gui/modeditwindow.ui +++ /dev/null @@ -1,241 +0,0 @@ - - - ModEditWindow - - - - 0 - 0 - 540 - 420 - - - - Dialog - - - - - - 3 - - - - Jar Mods - - - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - MCForge - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Move &Up - - - - - - - Move &Down - - - - - - - - - - Core Mods - - - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - - - - - - - - - Mods - - - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - - - - - - - - - Texture Packs - - - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - - - - - - - - - - - - QDialogButtonBox::Close - - - - - - - - diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp index 73a02cbd..6b2341d7 100644 --- a/logic/LegacyInstance.cpp +++ b/logic/LegacyInstance.cpp @@ -87,6 +87,11 @@ MinecraftProcess* LegacyInstance::prepareForLaunch(QString user, QString session return proc; } +void LegacyInstance::cleanupAfterRun() +{ + //FIXME: delete the launcher and icons and whatnot. +} + QSharedPointer< ModList > LegacyInstance::coreModList() { I_D(LegacyInstance); @@ -136,7 +141,7 @@ QSharedPointer< ModList > LegacyInstance::texturePackList() I_D(LegacyInstance); if(!d->texture_pack_list) { - d->texture_pack_list.reset(new ModList(texturePackDir())); + d->texture_pack_list.reset(new ModList(texturePacksDir())); } else d->texture_pack_list->update(); @@ -150,12 +155,6 @@ QDialog * LegacyInstance::createModEditDialog ( QWidget* parent ) } -void LegacyInstance::cleanupAfterRun() -{ - //FIXME: delete the launcher and icons and whatnot. -} - - QString LegacyInstance::jarModsDir() const { return PathCombine(instanceRoot(), "instMods"); @@ -185,7 +184,7 @@ QString LegacyInstance::resourceDir() const { return PathCombine(minecraftRoot(), "resources"); } -QString LegacyInstance::texturePackDir() const +QString LegacyInstance::texturePacksDir() const { return PathCombine(minecraftRoot(), "texturepacks"); } diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h index 4df884d2..b36026fc 100644 --- a/logic/LegacyInstance.h +++ b/logic/LegacyInstance.h @@ -26,7 +26,7 @@ public: ////// Directories ////// QString savesDir() const; - QString texturePackDir() const; + QString texturePacksDir() const; QString jarModsDir() const; QString binDir() const; QString loaderModsDir() const; diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index 44af6707..8609e4a1 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -8,6 +8,7 @@ #include #include #include +#include OneSixInstance::OneSixInstance ( const QString& rootDir, SettingsObject* setting_obj, QObject* parent ) : BaseInstance ( new OneSixInstancePrivate(), rootDir, setting_obj, parent ) @@ -155,12 +156,35 @@ void OneSixInstance::cleanupAfterRun() dir.removeRecursively(); } -QDialog * OneSixInstance::createModEditDialog ( QWidget* parent ) +QSharedPointer< ModList > OneSixInstance::loaderModList() +{ + I_D(OneSixInstance); + if(!d->loader_mod_list) + { + d->loader_mod_list.reset(new ModList(loaderModsDir())); + } + else + d->loader_mod_list->update(); + return d->loader_mod_list; +} + +QSharedPointer< ModList > OneSixInstance::resourcePackList() { - return nullptr; + I_D(OneSixInstance); + if(!d->resource_pack_list) + { + d->resource_pack_list.reset(new ModList(resourcePacksDir())); + } + else + d->resource_pack_list->update(); + return d->resource_pack_list; } +QDialog * OneSixInstance::createModEditDialog ( QWidget* parent ) +{ + return new OneSixModEditDialog(this, parent); +} bool OneSixInstance::setIntendedVersionId ( QString version ) { @@ -215,7 +239,7 @@ bool OneSixInstance::reloadFullVersion() return false; } -QSharedPointer< FullVersion > OneSixInstance::getFullVersion() +QSharedPointer< OneSixVersion > OneSixInstance::getFullVersion() { I_D(OneSixInstance); return d->version; @@ -235,8 +259,6 @@ bool OneSixInstance::menuActionEnabled ( QString action_name ) const { if(action_name == "actionChangeInstLWJGLVersion") return false; - if(action_name == "actionEditInstMods") - return false; return true; } @@ -245,6 +267,16 @@ QString OneSixInstance::getStatusbarDescription() return "One Six : " + intendedVersionId(); } +QString OneSixInstance::loaderModsDir() const +{ + return PathCombine(minecraftRoot(), "mods"); +} + +QString OneSixInstance::resourcePacksDir() const +{ + return PathCombine(minecraftRoot(), "resourcepacks"); +} + QString OneSixInstance::instanceConfigFolder() const { return PathCombine(minecraftRoot(), "config"); diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h index 7c28b4cc..a4c67ed1 100644 --- a/logic/OneSixInstance.h +++ b/logic/OneSixInstance.h @@ -2,14 +2,26 @@ #include "BaseInstance.h" #include -class FullVersion; +class OneSixVersion; class BaseUpdate; +class ModList; class OneSixInstance : public BaseInstance { Q_OBJECT public: explicit OneSixInstance(const QString &rootDir, SettingsObject * settings, QObject *parent = 0); + + + ////// Mod Lists ////// + QSharedPointer loaderModList(); + QSharedPointer resourcePackList(); + + ////// Directories ////// + QString resourcePacksDir() const; + QString loaderModsDir() const; + virtual QString instanceConfigFolder() const; + virtual BaseUpdate* doUpdate(); virtual MinecraftProcess* prepareForLaunch ( QString user, QString session ); virtual void cleanupAfterRun(); @@ -28,15 +40,13 @@ public: /// reload the full version json file. return true on success! bool reloadFullVersion(); /// get the current full version info - QSharedPointer getFullVersion(); + QSharedPointer getFullVersion(); virtual QString defaultBaseJar() const; virtual QString defaultCustomBaseJar() const; virtual bool menuActionEnabled ( QString action_name ) const; virtual QString getStatusbarDescription(); - virtual QString instanceConfigFolder() const; - private: QStringList processMinecraftArgs( QString user, QString session ); }; \ No newline at end of file diff --git a/logic/OneSixInstance_p.h b/logic/OneSixInstance_p.h index 1037e03c..c098c9e2 100644 --- a/logic/OneSixInstance_p.h +++ b/logic/OneSixInstance_p.h @@ -2,8 +2,11 @@ #include "BaseInstance_p.h" #include "OneSixVersion.h" +#include "ModList.h" struct OneSixInstancePrivate: public BaseInstancePrivate { - QSharedPointer version; + QSharedPointer version; + QSharedPointer loader_mod_list; + QSharedPointer resource_pack_list; }; \ No newline at end of file diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp index 09d3cb14..a47beda0 100644 --- a/logic/OneSixUpdate.cpp +++ b/logic/OneSixUpdate.cpp @@ -129,7 +129,7 @@ void OneSixUpdate::jarlibStart() return; } - QSharedPointer version = inst->getFullVersion(); + QSharedPointer version = inst->getFullVersion(); // download the right jar, save it in versions/$version/$version.jar QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/"); diff --git a/logic/OneSixVersion.cpp b/logic/OneSixVersion.cpp index 2b2f79f5..56e272e2 100644 --- a/logic/OneSixVersion.cpp +++ b/logic/OneSixVersion.cpp @@ -103,7 +103,7 @@ QString Library::storagePath() } -QList > FullVersion::getActiveNormalLibs() +QList > OneSixVersion::getActiveNormalLibs() { QList > output; for ( auto lib: libraries ) @@ -116,7 +116,7 @@ QList > FullVersion::getActiveNormalLibs() return output; } -QList > FullVersion::getActiveNativeLibs() +QList > OneSixVersion::getActiveNativeLibs() { QList > output; for ( auto lib: libraries ) diff --git a/logic/OneSixVersion.h b/logic/OneSixVersion.h index 46055304..89b7c911 100644 --- a/logic/OneSixVersion.h +++ b/logic/OneSixVersion.h @@ -147,7 +147,7 @@ public: }; -class FullVersion +class OneSixVersion { public: /// the ID - determines which jar to use! ACTUALLY IMPORTANT! @@ -203,7 +203,7 @@ public: // QList rules; public: - FullVersion() + OneSixVersion() { minimumLauncherVersion = 0xDEADBEEF; } diff --git a/logic/VersionFactory.cpp b/logic/VersionFactory.cpp index 9eccce26..71c4d747 100644 --- a/logic/VersionFactory.cpp +++ b/logic/VersionFactory.cpp @@ -45,7 +45,7 @@ QList > FullVersionFactory::parse4rules(QJsonObject & baseO } -QSharedPointer FullVersionFactory::parse4(QJsonObject root, QSharedPointer fullVersion) +QSharedPointer FullVersionFactory::parse4(QJsonObject root, QSharedPointer fullVersion) { fullVersion->id = root.value("id").toString(); @@ -154,9 +154,9 @@ QSharedPointer FullVersionFactory::parse4(QJsonObject root, QShared return fullVersion; } -QSharedPointer FullVersionFactory::parse(QByteArray data) +QSharedPointer FullVersionFactory::parse(QByteArray data) { - QSharedPointer readVersion(new FullVersion()); + QSharedPointer readVersion(new OneSixVersion()); QJsonParseError jsonError; QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError); @@ -165,14 +165,14 @@ QSharedPointer FullVersionFactory::parse(QByteArray data) { error_string = QString( "Error reading version file :") + " " + jsonError.errorString(); m_error = FullVersionFactory::ParseError; - return QSharedPointer(); + return QSharedPointer(); } if(!jsonDoc.isObject()) { error_string = "Error reading version file."; m_error = FullVersionFactory::ParseError; - return QSharedPointer(); + return QSharedPointer(); } QJsonObject root = jsonDoc.object(); @@ -184,7 +184,7 @@ QSharedPointer FullVersionFactory::parse(QByteArray data) { error_string = "Version file was for an unrecognized launcher version. RIP"; m_error = FullVersionFactory::UnsupportedVersion; - return QSharedPointer(); + return QSharedPointer(); } } diff --git a/logic/VersionFactory.h b/logic/VersionFactory.h index 82c5278a..0c0ee2d4 100644 --- a/logic/VersionFactory.h +++ b/logic/VersionFactory.h @@ -1,7 +1,7 @@ #pragma once #include -struct FullVersion; +struct OneSixVersion; class Rule; class FullVersionFactory @@ -17,8 +17,8 @@ public: public: FullVersionFactory(); - QSharedPointer parse(QByteArray data); + QSharedPointer parse(QByteArray data); private: - QSharedPointer parse4(QJsonObject root, QSharedPointer product); + QSharedPointer parse4(QJsonObject root, QSharedPointer product); QList > parse4rules(QJsonObject & baseObj); }; \ No newline at end of file -- cgit v1.2.3