mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
instance icons and minecraft version
This commit is contained in:
parent
7e7de65fb4
commit
2e656c247b
4 changed files with 34 additions and 12 deletions
|
|
@ -46,7 +46,10 @@
|
|||
#include <QUuid>
|
||||
#include <Qt>
|
||||
|
||||
#include "Application.h"
|
||||
#include "MinecraftInstance.h"
|
||||
#include "PackProfile.h"
|
||||
#include "icons/IconList.h"
|
||||
|
||||
MultiWorldList::MultiWorldList(const QList<BaseInstance*>& 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<MinecraftInstance*>(instanceWorld.instance)->getPackProfile()->reload(Net::Mode::Online);
|
||||
return static_cast<MinecraftInstance*>(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:
|
||||
|
|
|
|||
|
|
@ -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<BaseInstance*>& instances);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,12 @@ class MultiWorldListProxyModel : public QSortFilterProxyModel {
|
|||
return QIcon(iconFile);
|
||||
}
|
||||
|
||||
if (index.column() == 1 && role == Qt::DecorationRole) {
|
||||
MultiWorldList* worlds = qobject_cast<MultiWorldList*>(sourceModel());
|
||||
auto icon = worlds->data(sourceIndex, MultiWorldList::InstanceIconFileRole).value<QIcon>();
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue