aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--launcher/minecraft/World.cpp23
-rw-r--r--launcher/minecraft/World.h5
-rw-r--r--launcher/minecraft/WorldList.cpp18
-rw-r--r--launcher/minecraft/WorldList.h4
-rw-r--r--program_info/LICENSE57
6 files changed, 73 insertions, 36 deletions
diff --git a/README.md b/README.md
index a114869c..eb4d1889 100644
--- a/README.md
+++ b/README.md
@@ -77,4 +77,4 @@ All launcher code is available under the GPL-3 license.
[Source for the website](https://github.com/PolyMC/polymc.github.io) is hosted under the AGPL-3 License.
-The logo and related assets are under the CC BY-NC-SA 4.0 license.
+The logo and related assets are under the CC BY-SA 4.0 license.
diff --git a/launcher/minecraft/World.cpp b/launcher/minecraft/World.cpp
index 2937c116..dc756e06 100644
--- a/launcher/minecraft/World.cpp
+++ b/launcher/minecraft/World.cpp
@@ -17,6 +17,7 @@
#include <QString>
#include <QDebug>
#include <QSaveFile>
+#include <QDirIterator>
#include "World.h"
#include "GZip.h"
@@ -187,6 +188,26 @@ bool putLevelDatDataToFS(const QFileInfo &file, QByteArray & data)
return f.commit();
}
+int64_t calculateWorldSize(const QFileInfo &file)
+{
+ if (file.isFile() && file.suffix() == "zip")
+ {
+ return file.size();
+ }
+ else if(file.isDir())
+ {
+ QDirIterator it(file.absoluteFilePath(), QDir::Files, QDirIterator::Subdirectories);
+ int64_t total = 0;
+ while (it.hasNext())
+ {
+ total += it.fileInfo().size();
+ it.next();
+ }
+ return total;
+ }
+ return -1;
+}
+
World::World(const QFileInfo &file)
{
repath(file);
@@ -196,6 +217,7 @@ void World::repath(const QFileInfo &file)
{
m_containerFile = file;
m_folderName = file.fileName();
+ m_size = calculateWorldSize(file);
if(file.isFile() && file.suffix() == "zip")
{
m_iconFile = QString();
@@ -482,6 +504,7 @@ void World::loadFromLevelDat(QByteArray data)
if(randomSeed) {
qDebug() << "Seed:" << *randomSeed;
}
+ qDebug() << "Size:" << m_size;
qDebug() << "GameType:" << m_gameType.toLogString();
}
diff --git a/launcher/minecraft/World.h b/launcher/minecraft/World.h
index 35e32788..0f587620 100644
--- a/launcher/minecraft/World.h
+++ b/launcher/minecraft/World.h
@@ -52,6 +52,10 @@ public:
{
return m_iconFile;
}
+ int64_t bytes() const
+ {
+ return m_size;
+ }
QDateTime lastPlayed() const
{
return m_lastPlayed;
@@ -105,6 +109,7 @@ protected:
QString m_iconFile;
QDateTime levelDatTime;
QDateTime m_lastPlayed;
+ int64_t m_size;
int64_t m_randomSeed = 0;
GameType m_gameType;
bool is_valid = false;
diff --git a/launcher/minecraft/WorldList.cpp b/launcher/minecraft/WorldList.cpp
index dcdbc321..344bea63 100644
--- a/launcher/minecraft/WorldList.cpp
+++ b/launcher/minecraft/WorldList.cpp
@@ -14,6 +14,8 @@
*/
#include "WorldList.h"
+
+#include "Application.h"
#include <FileSystem.h>
#include <QMimeData>
#include <QUrl>
@@ -150,7 +152,7 @@ bool WorldList::resetIcon(int row)
int WorldList::columnCount(const QModelIndex &parent) const
{
- return 3;
+ return 4;
}
QVariant WorldList::data(const QModelIndex &index, int role) const
@@ -164,6 +166,8 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
if (row < 0 || row >= worlds.size())
return QVariant();
+ QLocale locale;
+
auto & world = worlds[row];
switch (role)
{
@@ -179,6 +183,9 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
case LastPlayedColumn:
return world.lastPlayed();
+ case SizeColumn:
+ return locale.formattedDataSize(world.bytes());
+
default:
return QVariant();
}
@@ -207,6 +214,10 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
{
return world.lastPlayed();
}
+ case SizeRole:
+ {
+ return locale.formattedDataSize(world.bytes());
+ }
case IconFileRole:
{
return world.iconFile();
@@ -229,6 +240,9 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol
return tr("Game Mode");
case LastPlayedColumn:
return tr("Last Played");
+ case SizeColumn:
+ //: World size on disk
+ return tr("Size");
default:
return QVariant();
}
@@ -242,6 +256,8 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol
return tr("Game mode of the world.");
case LastPlayedColumn:
return tr("Date and time the world was last played.");
+ case SizeColumn:
+ return tr("Size of the world on disk.");
default:
return QVariant();
}
diff --git a/launcher/minecraft/WorldList.h b/launcher/minecraft/WorldList.h
index 8e238ee3..5138e583 100644
--- a/launcher/minecraft/WorldList.h
+++ b/launcher/minecraft/WorldList.h
@@ -32,7 +32,8 @@ public:
{
NameColumn,
GameModeColumn,
- LastPlayedColumn
+ LastPlayedColumn,
+ SizeColumn
};
enum Roles
@@ -43,6 +44,7 @@ public:
NameRole,
GameModeRole,
LastPlayedRole,
+ SizeRole,
IconFileRole
};
diff --git a/program_info/LICENSE b/program_info/LICENSE
index 40cc6059..c68207dc 100644
--- a/program_info/LICENSE
+++ b/program_info/LICENSE
@@ -1,4 +1,4 @@
-Attribution-NonCommercial-ShareAlike 4.0 International
+Attribution-ShareAlike 4.0 International
This license only applies to the logos and branding in this folder.
@@ -56,18 +56,18 @@ exhaustive, and do not form part of our licenses.
=======================================================================
-Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
-Public License
+Creative Commons Attribution-ShareAlike 4.0 International Public
+License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
-Attribution-NonCommercial-ShareAlike 4.0 International Public License
-("Public License"). To the extent this Public License may be
-interpreted as a contract, You are granted the Licensed Rights in
-consideration of Your acceptance of these terms and conditions, and the
-Licensor grants You such rights in consideration of benefits the
-Licensor receives from making the Licensed Material available under
-these terms and conditions.
+Attribution-ShareAlike 4.0 International Public License ("Public
+License"). To the extent this Public License may be interpreted as a
+contract, You are granted the Licensed Rights in consideration of Your
+acceptance of these terms and conditions, and the Licensor grants You
+such rights in consideration of benefits the Licensor receives from
+making the Licensed Material available under these terms and
+conditions.
Section 1 -- Definitions.
@@ -86,7 +86,7 @@ Section 1 -- Definitions.
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
- c. BY-NC-SA Compatible License means a license listed at
+ c. BY-SA Compatible License means a license listed at
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.
@@ -110,7 +110,7 @@ Section 1 -- Definitions.
g. License Elements means the license attributes listed in the name
of a Creative Commons Public License. The License Elements of this
- Public License are Attribution, NonCommercial, and ShareAlike.
+ Public License are Attribution and ShareAlike.
h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
@@ -124,15 +124,7 @@ Section 1 -- Definitions.
j. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
- k. NonCommercial means not primarily intended for or directed towards
- commercial advantage or monetary compensation. For purposes of
- this Public License, the exchange of the Licensed Material for
- other material subject to Copyright and Similar Rights by digital
- file-sharing or similar means is NonCommercial provided there is
- no payment of monetary compensation in connection with the
- exchange.
-
- l. Share means to provide material to the public by any means or
+ k. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
@@ -140,13 +132,13 @@ Section 1 -- Definitions.
public may access the material from a place and at a time
individually chosen by them.
- m. Sui Generis Database Rights means rights other than copyright
+ l. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
- n. You means the individual or entity exercising the Licensed Rights
+ m. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
@@ -160,10 +152,9 @@ Section 2 -- Scope.
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
- in part, for NonCommercial purposes only; and
+ in part; and
- b. produce, reproduce, and Share Adapted Material for
- NonCommercial purposes only.
+ b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
@@ -231,9 +222,7 @@ Section 2 -- Scope.
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
- reserves any right to collect such royalties, including when
- the Licensed Material is used other than for NonCommercial
- purposes.
+ reserves any right to collect such royalties.
Section 3 -- License Conditions.
@@ -278,6 +267,7 @@ following conditions.
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
+
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
@@ -289,7 +279,7 @@ following conditions.
1. The Adapter's License You apply must be a Creative Commons
license with the same License Elements, this version or
- later, or a BY-NC-SA Compatible License.
+ later, or a BY-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the
Adapter's License You apply. You may satisfy this condition
@@ -309,15 +299,14 @@ apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
- portion of the contents of the database for NonCommercial purposes
- only;
+ portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material,
- including for purposes of Section 3(b); and
+ including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
@@ -417,6 +406,7 @@ Section 8 -- Interpretation.
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
+
=======================================================================
Creative Commons is not a party to its public
@@ -437,3 +427,4 @@ the avoidance of doubt, this paragraph does not form part of the
public licenses.
Creative Commons may be contacted at creativecommons.org.
+