aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--launcher/resources/multimc/128x128/instances/forge.pngbin0 -> 3229 bytes
-rw-r--r--launcher/resources/multimc/multimc.qrc2
-rw-r--r--launcher/resources/multimc/scalable/instances/forge.svg43
-rw-r--r--launcher/ui/dialogs/InstallLoaderDialog.cpp78
-rw-r--r--launcher/ui/dialogs/InstallLoaderDialog.h7
-rw-r--r--launcher/ui/widgets/PageContainer.cpp2
-rw-r--r--launcher/ui/widgets/PageContainer.h2
7 files changed, 53 insertions, 81 deletions
diff --git a/launcher/resources/multimc/128x128/instances/forge.png b/launcher/resources/multimc/128x128/instances/forge.png
new file mode 100644
index 00000000..d8ff79a5
--- /dev/null
+++ b/launcher/resources/multimc/128x128/instances/forge.png
Binary files differ
diff --git a/launcher/resources/multimc/multimc.qrc b/launcher/resources/multimc/multimc.qrc
index 907fbb5d..4a407d95 100644
--- a/launcher/resources/multimc/multimc.qrc
+++ b/launcher/resources/multimc/multimc.qrc
@@ -348,9 +348,9 @@
<file>scalable/launch.svg</file>
<file>scalable/server.svg</file>
- <file>scalable/instances/forge.svg</file>
<file>scalable/instances/quiltmc.svg</file>
<file>22x22/fabricmc-small.png</file>
+ <file>128x128/instances/forge.png</file>
<file>128x128/instances/fabricmc.png</file>
<file>128x128/instances/liteloader.png</file>
</qresource>
diff --git a/launcher/resources/multimc/scalable/instances/forge.svg b/launcher/resources/multimc/scalable/instances/forge.svg
deleted file mode 100644
index ea402c5b..00000000
--- a/launcher/resources/multimc/scalable/instances/forge.svg
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xml:space="preserve"
- width="24"
- height="24"
- viewBox="164.072 372.466 24 24"
- version="1.1"
- id="svg132"
- sodipodi:docname="forge.svg"
- inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:svg="http://www.w3.org/2000/svg"><defs
- id="defs136" /><sodipodi:namedview
- id="namedview134"
- pagecolor="#ffffff"
- bordercolor="#000000"
- borderopacity="0.25"
- inkscape:showpageshadow="2"
- inkscape:pageopacity="0.0"
- inkscape:pagecheckerboard="0"
- inkscape:deskcolor="#d1d1d1"
- showgrid="false"
- inkscape:zoom="16"
- inkscape:cx="24.28125"
- inkscape:cy="4.9375"
- inkscape:window-width="1920"
- inkscape:window-height="1011"
- inkscape:window-x="0"
- inkscape:window-y="32"
- inkscape:window-maximized="1"
- inkscape:current-layer="svg132" /><rect
- style="fill:#1d2d41;fill-opacity:1;stroke-width:1.02136"
- id="rect7386"
- width="24"
- height="24"
- x="164.07201"
- y="372.466" /><path
- fill="#1e2d41"
- d="m 183.16438,381.24198 -8.60519,-0.42066 10.51249,-0.008 V 379.966 h -11.85315 v 3.18329 c 0,0.0266 -0.34666,-2.07997 -0.42599,-2.66864 h -0.93198 v 2.96329 c 0,0.028 -0.39866,-2.47596 -0.44066,-2.78929 h -6.3479 c 0.43266,0.37466 2.81996,2.40997 4.51726,3.24729 0.85065,0.41999 1.89464,0.42332 2.8233,0.44933 0.47199,0.0134 0.96665,0.0493 1.31997,0.39866 0.51266,0.50865 0.62665,1.29731 0.18466,1.89396 -0.43732,0.59 -1.66797,0.718 -1.66797,0.718 l -1.02531,1.25798 v 1.46063 h 2.3313 l 0.072,-1.44329 2.01597,-1.42932 c -0.21534,0.17199 -0.69533,0.63332 -1.41664,1.7433 a 3.9826047,3.9826047 0 0 0 -0.38934,0.79333 c 0.50933,-0.43134 1.55531,-0.72667 2.76396,-0.72667 1.20665,0 2.25196,0.29467 2.76195,0.72533 a 3.9752715,3.9752715 0 0 0 -0.38866,-0.79199 c -0.72132,-1.11064 -1.20131,-1.57131 -1.41664,-1.7433 l 2.01597,1.42932 0.0727,1.44329 h 2.17462 v -1.45997 l -1.02464,-1.25864 c 0,0 -1.51798,-0.0967 -1.9153,-0.71733 -1.14466,-1.7893 0.48066,-4.5666 4.28327,-5.40258 z"
- style="fill:#ffffff;stroke-width:0.227407"
- id="path130" /></svg>
diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp
index acef60c6..31d6f9ab 100644
--- a/launcher/ui/dialogs/InstallLoaderDialog.cpp
+++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp
@@ -38,7 +38,7 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage {
// "lightweight" loaders are independent to any game version
const bool lightweight,
const std::shared_ptr<PackProfile> profile)
- : VersionSelectWidget(nullptr), m_id(id), m_icon(icon), m_name(name)
+ : VersionSelectWidget(nullptr), uid(id), iconName(icon), name(name)
{
const QString minecraftVersion = profile->getComponentVersion("net.minecraft");
setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion));
@@ -49,21 +49,21 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage {
setCurrentVersion(currentVersion);
}
- QString id() const override { return m_id; }
- QString displayName() const override { return m_name; }
- QIcon icon() const override { return APPLICATION->getThemedIcon(m_icon); }
+ QString id() const override { return uid; }
+ QString displayName() const override { return name; }
+ QIcon icon() const override { return APPLICATION->getThemedIcon(iconName); }
void openedImpl() override
{
- if (m_loaded)
+ if (loaded)
return;
- const auto versions = APPLICATION->metadataIndex()->get(m_id);
+ const auto versions = APPLICATION->metadataIndex()->get(uid);
if (!versions)
return;
initialize(versions.get());
- m_loaded = true;
+ loaded = true;
}
void setParentContainer(BasePageContainer* container) override
@@ -73,13 +73,13 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage {
}
private:
- const QString m_id;
- const QString m_icon;
- const QString m_name;
- bool m_loaded = false;
+ const QString uid;
+ const QString iconName;
+ const QString name;
+ bool loaded = false;
};
-InstallLoaderPage* pageCast(BasePage* page)
+static InstallLoaderPage* pageCast(BasePage* page)
{
auto result = dynamic_cast<InstallLoaderPage*>(page);
Q_ASSERT(result != nullptr);
@@ -87,46 +87,55 @@ InstallLoaderPage* pageCast(BasePage* page)
}
InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr<PackProfile> profile, const QString& uid, QWidget* parent)
- : QDialog(parent), m_profile(profile), m_container(new PageContainer(this, QString(), this)), m_buttons(new QDialogButtonBox(this))
+ : QDialog(parent), profile(std::move(profile)), container(new PageContainer(this, QString(), this)), buttons(new QDialogButtonBox(this))
{
auto layout = new QVBoxLayout(this);
- m_container->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
- layout->addWidget(m_container);
+ container->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
+ layout->addWidget(container);
auto buttonLayout = new QHBoxLayout(this);
auto refreshButton = new QPushButton(tr("&Refresh"), this);
- connect(refreshButton, &QPushButton::pressed, this, [this] { pageCast(m_container->selectedPage())->loadList(); });
+ connect(refreshButton, &QPushButton::pressed, this, [this] { pageCast(container->selectedPage())->loadList(); });
buttonLayout->addWidget(refreshButton);
- m_buttons->setOrientation(Qt::Horizontal);
- m_buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
- connect(m_buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
- connect(m_buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
- buttonLayout->addWidget(m_buttons);
+ buttons->setOrientation(Qt::Horizontal);
+ buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
+ connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
+ connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
+ buttonLayout->addWidget(buttons);
layout->addLayout(buttonLayout);
setWindowTitle(dialogTitle());
- resize(650, 400);
+ setWindowModality(Qt::WindowModal);
+ resize(520, 347);
- pageCast(m_container->selectedPage())->selectSearch();
- for (BasePage* page : m_container->getPages())
+ for (BasePage* page : container->getPages()) {
if (page->id() == uid)
- m_container->selectPage(page->id());
+ container->selectPage(page->id());
+
+ connect(pageCast(page), &VersionSelectWidget::selectedVersionChanged, this, [this, page] {
+ if (page->id() == container->selectedPage()->id())
+ validate(container->selectedPage());
+ });
+ }
+ connect(container, &PageContainer::selectedPageChanged, this, [this](BasePage* previous, BasePage* current) { validate(current); });
+ pageCast(container->selectedPage())->selectSearch();
+ validate(container->selectedPage());
}
QList<BasePage*> InstallLoaderDialog::getPages()
{
return { // Forge
- new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), false, m_profile),
+ new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), false, profile),
// Fabric
- new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, m_profile),
+ new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, profile),
// Quilt
- new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, m_profile),
+ new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, profile),
// LiteLoader
- new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile)
+ new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, profile)
};
}
@@ -135,13 +144,18 @@ QString InstallLoaderDialog::dialogTitle()
return tr("Install Loader");
}
+void InstallLoaderDialog::validate(BasePage* page)
+{
+ buttons->button(QDialogButtonBox::Ok)->setEnabled(pageCast(page)->selectedVersion() != nullptr);
+}
+
void InstallLoaderDialog::done(int result)
{
if (result == Accepted) {
- auto* page = pageCast(m_container->selectedPage());
+ auto* page = pageCast(container->selectedPage());
if (page->selectedVersion()) {
- m_profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor());
- m_profile->resolve(Net::Mode::Online);
+ profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor());
+ profile->resolve(Net::Mode::Online);
}
}
diff --git a/launcher/ui/dialogs/InstallLoaderDialog.h b/launcher/ui/dialogs/InstallLoaderDialog.h
index 09d84777..cdcba2b9 100644
--- a/launcher/ui/dialogs/InstallLoaderDialog.h
+++ b/launcher/ui/dialogs/InstallLoaderDialog.h
@@ -35,10 +35,11 @@ class InstallLoaderDialog final : public QDialog, public BasePageProvider {
QList<BasePage*> getPages() override;
QString dialogTitle() override;
+ void validate(BasePage* page);
void done(int result) override;
private:
- std::shared_ptr<PackProfile> m_profile;
- PageContainer* m_container;
- QDialogButtonBox* m_buttons;
+ std::shared_ptr<PackProfile> profile;
+ PageContainer* container;
+ QDialogButtonBox* buttons;
};
diff --git a/launcher/ui/widgets/PageContainer.cpp b/launcher/ui/widgets/PageContainer.cpp
index 0a8a0544..dbbed36a 100644
--- a/launcher/ui/widgets/PageContainer.cpp
+++ b/launcher/ui/widgets/PageContainer.cpp
@@ -147,7 +147,7 @@ BasePage* PageContainer::selectedPage() const
return m_currentPage;
}
-const QList<BasePage*> PageContainer::getPages() const
+const QList<BasePage*>& PageContainer::getPages() const
{
return m_model->pages();
}
diff --git a/launcher/ui/widgets/PageContainer.h b/launcher/ui/widgets/PageContainer.h
index bb365c82..eac59723 100644
--- a/launcher/ui/widgets/PageContainer.h
+++ b/launcher/ui/widgets/PageContainer.h
@@ -82,7 +82,7 @@ public:
bool selectPage(QString pageId) override;
BasePage* selectedPage() const override;
BasePage* getPage(QString pageId) override;
- const QList<BasePage*> getPages() const;
+ const QList<BasePage*>& getPages() const;
void refreshContainer() override;
virtual void setParentContainer(BasePageContainer * container)