mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-04-30 06:34:27 +02:00
chore: rename varibales to match code standards
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
564f120c22
commit
6e00f94a57
@ -252,41 +252,41 @@ void World::readFromFS(const QFileInfo& file)
|
|||||||
{
|
{
|
||||||
auto bytes = getLevelDatDataFromFS(file);
|
auto bytes = getLevelDatDataFromFS(file);
|
||||||
if (bytes.isEmpty()) {
|
if (bytes.isEmpty()) {
|
||||||
is_valid = false;
|
m_isValid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
loadFromLevelDat(bytes);
|
loadFromLevelDat(bytes);
|
||||||
levelDatTime = file.lastModified();
|
m_levelDatTime = file.lastModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::readFromZip(const QFileInfo& file)
|
void World::readFromZip(const QFileInfo& file)
|
||||||
{
|
{
|
||||||
QuaZip zip(file.absoluteFilePath());
|
QuaZip zip(file.absoluteFilePath());
|
||||||
is_valid = zip.open(QuaZip::mdUnzip);
|
m_isValid = zip.open(QuaZip::mdUnzip);
|
||||||
if (!is_valid) {
|
if (!m_isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto location = MMCZip::findFolderOfFileInZip(&zip, "level.dat");
|
auto location = MMCZip::findFolderOfFileInZip(&zip, "level.dat");
|
||||||
is_valid = !location.isEmpty();
|
m_isValid = !location.isEmpty();
|
||||||
if (!is_valid) {
|
if (!m_isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_containerOffsetPath = location;
|
m_containerOffsetPath = location;
|
||||||
QuaZipFile zippedFile(&zip);
|
QuaZipFile zippedFile(&zip);
|
||||||
// read the install profile
|
// read the install profile
|
||||||
is_valid = zip.setCurrentFile(location + "level.dat");
|
m_isValid = zip.setCurrentFile(location + "level.dat");
|
||||||
if (!is_valid) {
|
if (!m_isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
is_valid = zippedFile.open(QIODevice::ReadOnly);
|
m_isValid = zippedFile.open(QIODevice::ReadOnly);
|
||||||
QuaZipFileInfo64 levelDatInfo;
|
QuaZipFileInfo64 levelDatInfo;
|
||||||
zippedFile.getFileInfo(&levelDatInfo);
|
zippedFile.getFileInfo(&levelDatInfo);
|
||||||
auto modTime = levelDatInfo.getNTFSmTime();
|
auto modTime = levelDatInfo.getNTFSmTime();
|
||||||
if (!modTime.isValid()) {
|
if (!modTime.isValid()) {
|
||||||
modTime = levelDatInfo.dateTime;
|
modTime = levelDatInfo.dateTime;
|
||||||
}
|
}
|
||||||
levelDatTime = modTime;
|
m_levelDatTime = modTime;
|
||||||
if (!is_valid) {
|
if (!m_isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
loadFromLevelDat(zippedFile.readAll());
|
loadFromLevelDat(zippedFile.readAll());
|
||||||
@ -430,7 +430,7 @@ void World::loadFromLevelDat(QByteArray data)
|
|||||||
{
|
{
|
||||||
auto levelData = parseLevelDat(data);
|
auto levelData = parseLevelDat(data);
|
||||||
if (!levelData) {
|
if (!levelData) {
|
||||||
is_valid = false;
|
m_isValid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,20 +439,20 @@ void World::loadFromLevelDat(QByteArray data)
|
|||||||
valPtr = &levelData->at("Data");
|
valPtr = &levelData->at("Data");
|
||||||
} catch (const std::out_of_range& e) {
|
} catch (const std::out_of_range& e) {
|
||||||
qWarning() << "Unable to read NBT tags from " << m_folderName << ":" << e.what();
|
qWarning() << "Unable to read NBT tags from " << m_folderName << ":" << e.what();
|
||||||
is_valid = false;
|
m_isValid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nbt::value& val = *valPtr;
|
nbt::value& val = *valPtr;
|
||||||
|
|
||||||
is_valid = val.get_type() == nbt::tag_type::Compound;
|
m_isValid = val.get_type() == nbt::tag_type::Compound;
|
||||||
if (!is_valid)
|
if (!m_isValid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto name = read_string(val, "LevelName");
|
auto name = read_string(val, "LevelName");
|
||||||
m_actualName = name ? *name : m_folderName;
|
m_actualName = name ? *name : m_folderName;
|
||||||
|
|
||||||
auto timestamp = read_long(val, "LastPlayed");
|
auto timestamp = read_long(val, "LastPlayed");
|
||||||
m_lastPlayed = timestamp ? QDateTime::fromMSecsSinceEpoch(*timestamp) : levelDatTime;
|
m_lastPlayed = timestamp ? QDateTime::fromMSecsSinceEpoch(*timestamp) : m_levelDatTime;
|
||||||
|
|
||||||
m_gameType = read_gametype(val, "GameType");
|
m_gameType = read_gametype(val, "GameType");
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ bool World::replace(World& with)
|
|||||||
|
|
||||||
bool World::destroy()
|
bool World::destroy()
|
||||||
{
|
{
|
||||||
if (!is_valid)
|
if (!m_isValid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (FS::trash(m_containerFile.filePath()))
|
if (FS::trash(m_containerFile.filePath()))
|
||||||
@ -508,7 +508,7 @@ bool World::destroy()
|
|||||||
|
|
||||||
bool World::operator==(const World& other) const
|
bool World::operator==(const World& other) const
|
||||||
{
|
{
|
||||||
return is_valid == other.is_valid && folderName() == other.folderName();
|
return m_isValid == other.m_isValid && folderName() == other.folderName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool World::isSymLinkUnder(const QString& instPath) const
|
bool World::isSymLinkUnder(const QString& instPath) const
|
||||||
|
@ -39,7 +39,7 @@ class World {
|
|||||||
QDateTime lastPlayed() const { return m_lastPlayed; }
|
QDateTime lastPlayed() const { return m_lastPlayed; }
|
||||||
GameType gameType() const { return m_gameType; }
|
GameType gameType() const { return m_gameType; }
|
||||||
int64_t seed() const { return m_randomSeed; }
|
int64_t seed() const { return m_randomSeed; }
|
||||||
bool isValid() const { return is_valid; }
|
bool isValid() const { return m_isValid; }
|
||||||
bool isOnFS() const { return m_containerFile.isDir(); }
|
bool isOnFS() const { return m_containerFile.isDir(); }
|
||||||
QFileInfo container() const { return m_containerFile; }
|
QFileInfo container() const { return m_containerFile; }
|
||||||
// delete all the files of this world
|
// delete all the files of this world
|
||||||
@ -83,10 +83,10 @@ class World {
|
|||||||
QString m_folderName;
|
QString m_folderName;
|
||||||
QString m_actualName;
|
QString m_actualName;
|
||||||
QString m_iconFile;
|
QString m_iconFile;
|
||||||
QDateTime levelDatTime;
|
QDateTime m_levelDatTime;
|
||||||
QDateTime m_lastPlayed;
|
QDateTime m_lastPlayed;
|
||||||
int64_t m_size;
|
int64_t m_size;
|
||||||
int64_t m_randomSeed = 0;
|
int64_t m_randomSeed = 0;
|
||||||
GameType m_gameType;
|
GameType m_gameType;
|
||||||
bool is_valid = false;
|
bool m_isValid = false;
|
||||||
};
|
};
|
||||||
|
@ -51,18 +51,18 @@ WorldList::WorldList(const QString& dir, BaseInstance* instance) : QAbstractList
|
|||||||
m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
|
m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
|
||||||
m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
|
m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
|
||||||
m_watcher = new QFileSystemWatcher(this);
|
m_watcher = new QFileSystemWatcher(this);
|
||||||
is_watching = false;
|
m_isWatching = false;
|
||||||
connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, &WorldList::directoryChanged);
|
connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, &WorldList::directoryChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldList::startWatching()
|
void WorldList::startWatching()
|
||||||
{
|
{
|
||||||
if (is_watching) {
|
if (m_isWatching) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
is_watching = m_watcher->addPath(m_dir.absolutePath());
|
m_isWatching = m_watcher->addPath(m_dir.absolutePath());
|
||||||
if (is_watching) {
|
if (m_isWatching) {
|
||||||
qDebug() << "Started watching " << m_dir.absolutePath();
|
qDebug() << "Started watching " << m_dir.absolutePath();
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Failed to start watching " << m_dir.absolutePath();
|
qDebug() << "Failed to start watching " << m_dir.absolutePath();
|
||||||
@ -71,11 +71,11 @@ void WorldList::startWatching()
|
|||||||
|
|
||||||
void WorldList::stopWatching()
|
void WorldList::stopWatching()
|
||||||
{
|
{
|
||||||
if (!is_watching) {
|
if (!m_isWatching) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
is_watching = !m_watcher->removePath(m_dir.absolutePath());
|
m_isWatching = !m_watcher->removePath(m_dir.absolutePath());
|
||||||
if (!is_watching) {
|
if (!m_isWatching) {
|
||||||
qDebug() << "Stopped watching " << m_dir.absolutePath();
|
qDebug() << "Stopped watching " << m_dir.absolutePath();
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Failed to stop watching " << m_dir.absolutePath();
|
qDebug() << "Failed to stop watching " << m_dir.absolutePath();
|
||||||
@ -101,12 +101,12 @@ bool WorldList::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
worlds.swap(newWorlds);
|
m_worlds.swap(newWorlds);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldList::directoryChanged(QString path)
|
void WorldList::directoryChanged(QString)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -123,12 +123,12 @@ QString WorldList::instDirPath() const
|
|||||||
|
|
||||||
bool WorldList::deleteWorld(int index)
|
bool WorldList::deleteWorld(int index)
|
||||||
{
|
{
|
||||||
if (index >= worlds.size() || index < 0)
|
if (index >= m_worlds.size() || index < 0)
|
||||||
return false;
|
return false;
|
||||||
World& m = worlds[index];
|
World& m = m_worlds[index];
|
||||||
if (m.destroy()) {
|
if (m.destroy()) {
|
||||||
beginRemoveRows(QModelIndex(), index, index);
|
beginRemoveRows(QModelIndex(), index, index);
|
||||||
worlds.removeAt(index);
|
m_worlds.removeAt(index);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
emit changed();
|
emit changed();
|
||||||
return true;
|
return true;
|
||||||
@ -139,11 +139,11 @@ bool WorldList::deleteWorld(int index)
|
|||||||
bool WorldList::deleteWorlds(int first, int last)
|
bool WorldList::deleteWorlds(int first, int last)
|
||||||
{
|
{
|
||||||
for (int i = first; i <= last; i++) {
|
for (int i = first; i <= last; i++) {
|
||||||
World& m = worlds[i];
|
World& m = m_worlds[i];
|
||||||
m.destroy();
|
m.destroy();
|
||||||
}
|
}
|
||||||
beginRemoveRows(QModelIndex(), first, last);
|
beginRemoveRows(QModelIndex(), first, last);
|
||||||
worlds.erase(worlds.begin() + first, worlds.begin() + last + 1);
|
m_worlds.erase(m_worlds.begin() + first, m_worlds.begin() + last + 1);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
emit changed();
|
emit changed();
|
||||||
return true;
|
return true;
|
||||||
@ -151,9 +151,9 @@ bool WorldList::deleteWorlds(int first, int last)
|
|||||||
|
|
||||||
bool WorldList::resetIcon(int row)
|
bool WorldList::resetIcon(int row)
|
||||||
{
|
{
|
||||||
if (row >= worlds.size() || row < 0)
|
if (row >= m_worlds.size() || row < 0)
|
||||||
return false;
|
return false;
|
||||||
World& m = worlds[row];
|
World& m = m_worlds[row];
|
||||||
if (m.resetIcon()) {
|
if (m.resetIcon()) {
|
||||||
emit dataChanged(index(row), index(row), { WorldList::IconFileRole });
|
emit dataChanged(index(row), index(row), { WorldList::IconFileRole });
|
||||||
return true;
|
return true;
|
||||||
@ -174,12 +174,12 @@ QVariant WorldList::data(const QModelIndex& index, int role) const
|
|||||||
int row = index.row();
|
int row = index.row();
|
||||||
int column = index.column();
|
int column = index.column();
|
||||||
|
|
||||||
if (row < 0 || row >= worlds.size())
|
if (row < 0 || row >= m_worlds.size())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QLocale locale;
|
QLocale locale;
|
||||||
|
|
||||||
auto& world = worlds[row];
|
auto& world = m_worlds[row];
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
switch (column) {
|
switch (column) {
|
||||||
@ -339,9 +339,9 @@ QMimeData* WorldList::mimeData(const QModelIndexList& indexes) const
|
|||||||
if (idx.column() != 0)
|
if (idx.column() != 0)
|
||||||
continue;
|
continue;
|
||||||
int row = idx.row();
|
int row = idx.row();
|
||||||
if (row < 0 || row >= this->worlds.size())
|
if (row < 0 || row >= this->m_worlds.size())
|
||||||
continue;
|
continue;
|
||||||
worlds_.append(this->worlds[row]);
|
worlds_.append(this->m_worlds[row]);
|
||||||
}
|
}
|
||||||
if (!worlds_.size()) {
|
if (!worlds_.size()) {
|
||||||
return new QMimeData();
|
return new QMimeData();
|
||||||
@ -393,7 +393,7 @@ bool WorldList::dropMimeData(const QMimeData* data,
|
|||||||
return false;
|
return false;
|
||||||
// files dropped from outside?
|
// files dropped from outside?
|
||||||
if (data->hasUrls()) {
|
if (data->hasUrls()) {
|
||||||
bool was_watching = is_watching;
|
bool was_watching = m_isWatching;
|
||||||
if (was_watching)
|
if (was_watching)
|
||||||
stopWatching();
|
stopWatching();
|
||||||
auto urls = data->urls();
|
auto urls = data->urls();
|
||||||
|
@ -40,9 +40,9 @@ class WorldList : public QAbstractListModel {
|
|||||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
virtual int columnCount(const QModelIndex& parent) const;
|
virtual int columnCount(const QModelIndex& parent) const;
|
||||||
|
|
||||||
size_t size() const { return worlds.size(); };
|
size_t size() const { return m_worlds.size(); };
|
||||||
bool empty() const { return size() == 0; }
|
bool empty() const { return size() == 0; }
|
||||||
World& operator[](size_t index) { return worlds[index]; }
|
World& operator[](size_t index) { return m_worlds[index]; }
|
||||||
|
|
||||||
/// Reloads the mod list and returns true if the list changed.
|
/// Reloads the mod list and returns true if the list changed.
|
||||||
virtual bool update();
|
virtual bool update();
|
||||||
@ -82,7 +82,7 @@ class WorldList : public QAbstractListModel {
|
|||||||
|
|
||||||
QString instDirPath() const;
|
QString instDirPath() const;
|
||||||
|
|
||||||
const QList<World>& allWorlds() const { return worlds; }
|
const QList<World>& allWorlds() const { return m_worlds; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void directoryChanged(QString path);
|
void directoryChanged(QString path);
|
||||||
@ -93,7 +93,7 @@ class WorldList : public QAbstractListModel {
|
|||||||
protected:
|
protected:
|
||||||
BaseInstance* m_instance;
|
BaseInstance* m_instance;
|
||||||
QFileSystemWatcher* m_watcher;
|
QFileSystemWatcher* m_watcher;
|
||||||
bool is_watching;
|
bool m_isWatching;
|
||||||
QDir m_dir;
|
QDir m_dir;
|
||||||
QList<World> worlds;
|
QList<World> m_worlds;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user