From 2e656c247ba14bd143e10b3d2f6e261b1de5fd10 Mon Sep 17 00:00:00 2001 From: Ice Yeti <101294194+IceYetiWins@users.noreply.github.com> Date: Fri, 12 Jun 2026 12:09:33 -0400 Subject: [PATCH] instance icons and minecraft version --- launcher/minecraft/MultiWorldList.cpp | 30 ++++++++++++++++++--------- launcher/minecraft/MultiWorldList.h | 4 ++-- launcher/ui/MainWindow.cpp | 4 ++++ launcher/ui/MultiWorldListPage.cpp | 8 +++++++ 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/launcher/minecraft/MultiWorldList.cpp b/launcher/minecraft/MultiWorldList.cpp index cb00d7b05..12b8529cb 100644 --- a/launcher/minecraft/MultiWorldList.cpp +++ b/launcher/minecraft/MultiWorldList.cpp @@ -46,7 +46,10 @@ #include #include +#include "Application.h" #include "MinecraftInstance.h" +#include "PackProfile.h" +#include "icons/IconList.h" MultiWorldList::MultiWorldList(const QList& instances) : QAbstractListModel(), allInstances(instances) { @@ -230,6 +233,10 @@ QVariant MultiWorldList::data(const QModelIndex& index, int role) const case InstanceColumn: return instanceWorld.instance->name(); + case VersionColumn: + static_cast(instanceWorld.instance)->getPackProfile()->reload(Net::Mode::Online); + return static_cast(instanceWorld.instance)->getPackProfile()->getComponentVersion("net.minecraft"); + case GameModeColumn: return instanceWorld.world.gameType().toTranslatedString(); @@ -240,10 +247,8 @@ QVariant MultiWorldList::data(const QModelIndex& index, int role) const return locale.formattedDataSize(instanceWorld.world.bytes()); case InfoColumn: - for (QString path : instDirPaths()) { - if (instanceWorld.world.isSymLinkUnder(path)) { - return tr("This world is symbolically linked from elsewhere."); - } + if (instanceWorld.world.isSymLinkUnder(QFileInfo(instanceWorld.instance->instanceRoot()).absoluteFilePath())) { + return tr("This world is symbolically linked from elsewhere."); } if (instanceWorld.world.isMoreThanOneHardLink()) { return tr("\nThis world is hard linked elsewhere."); @@ -260,12 +265,10 @@ QVariant MultiWorldList::data(const QModelIndex& index, int role) const case Qt::ToolTipRole: { if (column == InfoColumn) { - for (QString path : instDirPaths()) { - if (instanceWorld.world.isSymLinkUnder(path)) { - return tr("Warning: This world is symbolically linked from elsewhere. Editing it will also change the original." - "\nCanonical Path: %1") - .arg(instanceWorld.world.canonicalFilePath()); - } + if (instanceWorld.world.isSymLinkUnder(QFileInfo(instanceWorld.instance->instanceRoot()).absoluteFilePath())) { + return tr("Warning: This world is symbolically linked from elsewhere. Editing it will also change the original." + "\nCanonical Path: %1") + .arg(instanceWorld.world.canonicalFilePath()); } if (instanceWorld.world.isMoreThanOneHardLink()) { return tr("Warning: This world is hard linked elsewhere. Editing it will also change the original."); @@ -294,6 +297,9 @@ QVariant MultiWorldList::data(const QModelIndex& index, int role) const case IconFileRole: { return instanceWorld.world.iconFile(); } + case InstanceIconFileRole: { + return APPLICATION->icons()->getIcon(instanceWorld.instance->iconKey()); + } default: return QVariant(); } @@ -308,6 +314,8 @@ QVariant MultiWorldList::headerData(int section, [[maybe_unused]] Qt::Orientatio return tr("Name"); case InstanceColumn: return tr("Instance"); + case VersionColumn: + return tr("Version"); case GameModeColumn: return tr("Game Mode"); case LastPlayedColumn: @@ -328,6 +336,8 @@ QVariant MultiWorldList::headerData(int section, [[maybe_unused]] Qt::Orientatio return tr("The name of the world."); case InstanceColumn: return tr("The instance the world belongs to."); + case VersionColumn: + return tr("The Minecraft version of the world."); case GameModeColumn: return tr("Game mode of the world."); case LastPlayedColumn: diff --git a/launcher/minecraft/MultiWorldList.h b/launcher/minecraft/MultiWorldList.h index ddd936892..be9103ba3 100644 --- a/launcher/minecraft/MultiWorldList.h +++ b/launcher/minecraft/MultiWorldList.h @@ -33,9 +33,9 @@ struct InstanceWorld { class MultiWorldList : public QAbstractListModel { Q_OBJECT public: - enum Columns { NameColumn, InstanceColumn, GameModeColumn, LastPlayedColumn, SizeColumn, InfoColumn }; + enum Columns { NameColumn, InstanceColumn, VersionColumn, GameModeColumn, LastPlayedColumn, SizeColumn, InfoColumn }; - enum Roles { ObjectRole = Qt::UserRole + 1, FolderRole, SeedRole, NameRole, InstanceRole, GameModeRole, LastPlayedRole, SizeRole, IconFileRole }; + enum Roles { ObjectRole = Qt::UserRole + 1, FolderRole, SeedRole, NameRole, InstanceRole, VersionRole, GameModeRole, LastPlayedRole, SizeRole, IconFileRole, InstanceIconFileRole }; MultiWorldList(const QList& instances); diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 7d2709a00..4ce7a61ec 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -889,11 +889,15 @@ void MainWindow::toggleAllWorldsScreen(bool toggled) ui->instanceToolBar->setVisible(false); allWorldsPage->setVisible(true); + allWorlds->startWatching(); + connect(allWorldsPage, &MultiWorldListPage::worldJoined, this, &MainWindow::worldJoined); } else { allWorldsPage->setVisible(false); view->setVisible(true); ui->instanceToolBar->setVisible(m_oldInstanceToolbarSetting); + + allWorlds->stopWatching(); } } diff --git a/launcher/ui/MultiWorldListPage.cpp b/launcher/ui/MultiWorldListPage.cpp index 7c0c41062..324aedf38 100644 --- a/launcher/ui/MultiWorldListPage.cpp +++ b/launcher/ui/MultiWorldListPage.cpp @@ -83,6 +83,12 @@ class MultiWorldListProxyModel : public QSortFilterProxyModel { return QIcon(iconFile); } + if (index.column() == 1 && role == Qt::DecorationRole) { + MultiWorldList* worlds = qobject_cast(sourceModel()); + auto icon = worlds->data(sourceIndex, MultiWorldList::InstanceIconFileRole).value(); + return icon.pixmap(24, 24); + } + return sourceIndex.data(role); } }; @@ -484,6 +490,8 @@ MinecraftInstance* MultiWorldListPage::selectInstance(const QString& message, Ba } } + instanceList->sortItems(Qt::AscendingOrder); + layout->addWidget(instanceList); auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);