summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-02-07 10:43:09 +0100
committerPetr Mrázek <peterix@gmail.com>2015-04-12 20:57:17 +0200
commit4e94de413ba60a1da91715a41c8ba8caa8474728 (patch)
tree9907e1ade674ab98fea5719f7e2da5ca0ec35464
parent141e0a02a0a0c4bbc4cc2e900560db5048366104 (diff)
downloadMultiMC-4e94de413ba60a1da91715a41c8ba8caa8474728.tar
MultiMC-4e94de413ba60a1da91715a41c8ba8caa8474728.tar.gz
MultiMC-4e94de413ba60a1da91715a41c8ba8caa8474728.tar.lz
MultiMC-4e94de413ba60a1da91715a41c8ba8caa8474728.tar.xz
MultiMC-4e94de413ba60a1da91715a41c8ba8caa8474728.zip
SCRATCH no more gui includes in logic
-rw-r--r--CMakeLists.txt3
-rw-r--r--gui/ConsoleWindow.cpp6
-rw-r--r--gui/InstancePageProvider.cpp0
-rw-r--r--gui/InstancePageProvider.h52
-rw-r--r--gui/MainWindow.cpp15
-rw-r--r--logic/minecraft/OneSixInstance.cpp33
-rw-r--r--logic/minecraft/OneSixInstance.h7
7 files changed, 72 insertions, 44 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d35753cb..b4281d5a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -284,6 +284,9 @@ SET(MULTIMC_SOURCES
gui/ConsoleWindow.h
gui/ConsoleWindow.cpp
+ gui/InstancePageProvider.h
+ gui/InstancePageProvider.cpp
+
# GUI - page dialog pages
gui/pages/BasePage.h
gui/pages/VersionPage.cpp
diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp
index 1f7c63cf..a9c1f455 100644
--- a/gui/ConsoleWindow.cpp
+++ b/gui/ConsoleWindow.cpp
@@ -29,6 +29,7 @@
#include <gui/dialogs/ProgressDialog.h>
#include "widgets/PageContainer.h"
#include "pages/LogPage.h"
+#include "InstancePageProvider.h"
#include "logic/icons/IconList.h"
@@ -71,8 +72,9 @@ ConsoleWindow::ConsoleWindow(BaseProcess *process, QWidget *parent)
// Add page container
{
auto mainLayout = new QVBoxLayout;
- auto provider = std::dynamic_pointer_cast<BasePageProvider>(m_proc->instance());
- auto proxy_provider = std::make_shared<LogPageProvider>(provider, new LogPage(m_proc));
+ auto provider = std::make_shared<InstancePageProvider>(m_proc->instance());
+ auto baseprovider = std::dynamic_pointer_cast<BasePageProvider>(provider);
+ auto proxy_provider = std::make_shared<LogPageProvider>(baseprovider, new LogPage(m_proc));
m_container = new PageContainer(proxy_provider, "console", this);
mainLayout->addWidget(m_container);
mainLayout->setSpacing(0);
diff --git a/gui/InstancePageProvider.cpp b/gui/InstancePageProvider.cpp
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/gui/InstancePageProvider.cpp
diff --git a/gui/InstancePageProvider.h b/gui/InstancePageProvider.h
new file mode 100644
index 00000000..d4f7cb91
--- /dev/null
+++ b/gui/InstancePageProvider.h
@@ -0,0 +1,52 @@
+#pragma once
+#include "logic/minecraft/OneSixInstance.h"
+#include "pages/BasePage.h"
+#include "pages/VersionPage.h"
+#include "pages/ModFolderPage.h"
+#include "pages/ResourcePackPage.h"
+#include "pages/TexturePackPage.h"
+#include "pages/NotesPage.h"
+#include "pages/ScreenshotsPage.h"
+#include "pages/InstanceSettingsPage.h"
+#include "pages/OtherLogsPage.h"
+#include "pages/BasePageProvider.h"
+#include <pathutils.h>
+
+class InstancePageProvider : public QObject, public BasePageProvider
+{
+ Q_OBJECT
+public:
+ explicit InstancePageProvider(InstancePtr parent)
+ {
+ inst = parent;
+ }
+
+ virtual ~InstancePageProvider() {};
+ virtual QList<BasePage *> getPages() override
+ {
+ QList<BasePage *> values;
+ std::shared_ptr<OneSixInstance> onesix = std::dynamic_pointer_cast<OneSixInstance>(inst);
+ if(onesix)
+ {
+ values.append(new VersionPage(onesix.get()));
+ values.append(new ModFolderPage(onesix.get(), onesix->loaderModList(), "mods", "loadermods",
+ tr("Loader mods"), "Loader-mods"));
+ values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList(), "coremods", "coremods",
+ tr("Core mods"), "Core-mods"));
+ values.append(new ResourcePackPage(onesix.get()));
+ values.append(new TexturePackPage(onesix.get()));
+ values.append(new NotesPage(onesix.get()));
+ values.append(new ScreenshotsPage(PathCombine(onesix->minecraftRoot(), "screenshots")));
+ values.append(new InstanceSettingsPage(onesix.get()));
+ values.append(new OtherLogsPage(onesix->minecraftRoot()));
+ }
+ return values;
+ }
+
+ virtual QString dialogTitle() override
+ {
+ return tr("Edit Instance (%1)").arg(inst->name());
+ }
+protected:
+ InstancePtr inst;
+};
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index 7ad93f07..f5382ed0 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -381,6 +381,7 @@ namespace Ui {
#include "logic/BaseProcess.h"
#include "logic/java/JavaUtils.h"
#include "gui/NagUtils.h"
+#include "InstancePageProvider.h"
#include "logic/minecraft/SkinUtils.h"
//#include "logic/minecraft/LegacyInstance.h"
@@ -1366,6 +1367,12 @@ void ShowPageDialog(T raw_provider, QWidget * parent, QString open_page = QStrin
dlg.exec();
}
+void ShowInstancePageDialog(InstancePtr instance, QWidget * parent, QString open_page = QString())
+{
+ auto provider = std::make_shared<InstancePageProvider>(instance);
+ ShowPageDialog(provider, parent, open_page);
+}
+
void MainWindow::on_actionSettings_triggered()
{
ShowPageDialog(m_globalSettingsProvider, this, "global-settings");
@@ -1378,22 +1385,22 @@ void MainWindow::on_actionSettings_triggered()
void MainWindow::on_actionInstanceSettings_triggered()
{
- ShowPageDialog(m_selectedInstance, this, "settings");
+ ShowInstancePageDialog(m_selectedInstance, this, "settings");
}
void MainWindow::on_actionEditInstNotes_triggered()
{
- ShowPageDialog(m_selectedInstance, this, "notes");
+ ShowInstancePageDialog(m_selectedInstance, this, "notes");
}
void MainWindow::on_actionEditInstance_triggered()
{
- ShowPageDialog(m_selectedInstance, this);
+ ShowInstancePageDialog(m_selectedInstance, this);
}
void MainWindow::on_actionScreenshots_triggered()
{
- ShowPageDialog(m_selectedInstance, this, "screenshots");
+ ShowInstancePageDialog(m_selectedInstance, this, "screenshots");
}
diff --git a/logic/minecraft/OneSixInstance.cpp b/logic/minecraft/OneSixInstance.cpp
index ebba22d6..f43275ab 100644
--- a/logic/minecraft/OneSixInstance.cpp
+++ b/logic/minecraft/OneSixInstance.cpp
@@ -28,15 +28,7 @@
#include "logic/minecraft/AssetsUtils.h"
#include "logic/icons/IconList.h"
-#include "gui/pagedialog/PageDialog.h"
-#include "gui/pages/VersionPage.h"
-#include "gui/pages/ModFolderPage.h"
-#include "gui/pages/ResourcePackPage.h"
-#include "gui/pages/TexturePackPage.h"
-#include "gui/pages/InstanceSettingsPage.h"
-#include "gui/pages/NotesPage.h"
-#include "gui/pages/ScreenshotsPage.h"
-#include "gui/pages/OtherLogsPage.h"
+
OneSixInstance::OneSixInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
: MinecraftInstance(globalSettings, settings, rootDir)
{
@@ -53,29 +45,6 @@ void OneSixInstance::createProfile()
m_version.reset(new MinecraftProfile(new OneSixProfileStrategy(this)));
}
-
-QList<BasePage *> OneSixInstance::getPages()
-{
- QList<BasePage *> values;
- values.append(new VersionPage(this));
- values.append(new ModFolderPage(this, loaderModList(), "mods", "loadermods",
- tr("Loader mods"), "Loader-mods"));
- values.append(new CoreModFolderPage(this, coreModList(), "coremods", "coremods",
- tr("Core mods"), "Core-mods"));
- values.append(new ResourcePackPage(this));
- values.append(new TexturePackPage(this));
- values.append(new NotesPage(this));
- values.append(new ScreenshotsPage(PathCombine(minecraftRoot(), "screenshots")));
- values.append(new InstanceSettingsPage(this));
- values.append(new OtherLogsPage(minecraftRoot()));
- return values;
-}
-
-QString OneSixInstance::dialogTitle()
-{
- return tr("Edit Instance (%1)").arg(name());
-}
-
QSet<QString> OneSixInstance::traits()
{
auto version = getMinecraftProfile();
diff --git a/logic/minecraft/OneSixInstance.h b/logic/minecraft/OneSixInstance.h
index 3a9e528e..79e67bd2 100644
--- a/logic/minecraft/OneSixInstance.h
+++ b/logic/minecraft/OneSixInstance.h
@@ -19,9 +19,8 @@
#include "logic/minecraft/MinecraftProfile.h"
#include "logic/minecraft/ModList.h"
-#include "gui/pages/BasePageProvider.h"
-class OneSixInstance : public MinecraftInstance, public BasePageProvider
+class OneSixInstance : public MinecraftInstance
{
Q_OBJECT
public:
@@ -30,10 +29,6 @@ public:
virtual void init();
- ////// Edit Instance Dialog stuff //////
- virtual QList<BasePage *> getPages();
- virtual QString dialogTitle();
-
////// Mod Lists //////
std::shared_ptr<ModList> loaderModList() const;
std::shared_ptr<ModList> coreModList() const;