summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt5
-rw-r--r--buildconfig/BuildConfig.cpp.in13
-rw-r--r--buildconfig/BuildConfig.h5
-rw-r--r--launcher/Application.cpp10
-rw-r--r--launcher/MMCStrings.cpp28
-rw-r--r--launcher/MMCStrings.h4
-rw-r--r--launcher/UpdateController.cpp52
-rw-r--r--launcher/resources/documents/credits.html12
-rw-r--r--launcher/resources/documents/documents.qrc1
-rw-r--r--launcher/ui/dialogs/AboutDialog.cpp80
-rw-r--r--launcher/ui/dialogs/AboutDialog.ui68
-rwxr-xr-xscripts/checkpatch.pl2
-rw-r--r--vcpkg.json5
13 files changed, 167 insertions, 118 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1091c9c1ae..ed0a0c86c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -227,9 +227,14 @@ set(MeshMC_SUBREDDIT_URL "" CACHE STRING "URL for the subreddit.")
#### Check the current Git commit and branch
include(GetGitRevisionDescription)
get_git_head_revision(MeshMC_GIT_REFSPEC MeshMC_GIT_COMMIT)
+git_get_exact_tag(MeshMC_GIT_TAG)
message(STATUS "Git commit: ${MeshMC_GIT_COMMIT}")
message(STATUS "Git refspec: ${MeshMC_GIT_REFSPEC}")
+message(STATUS "Git tag: ${MeshMC_GIT_TAG}")
+
+string(TIMESTAMP TODAY "%Y-%m-%d")
+set(MeshMC_BUILD_TIMESTAMP "${TODAY}")
#### Custom target to just print the version.
add_custom_target(version echo "Version: ${MeshMC_RELEASE_VERSION_NAME}")
diff --git a/buildconfig/BuildConfig.cpp.in b/buildconfig/BuildConfig.cpp.in
index c9b0b7b217..e368dc2ffa 100644
--- a/buildconfig/BuildConfig.cpp.in
+++ b/buildconfig/BuildConfig.cpp.in
@@ -45,6 +45,7 @@ Config::Config()
BUILD_PLATFORM = "@MeshMC_BUILD_PLATFORM@";
BUILD_ARTIFACT = "@MeshMC_BUILD_ARTIFACT@";
+ BUILD_DATE = "@MeshMC_BUILD_TIMESTAMP@";
COMPILER_NAME = "@MeshMC_COMPILER_NAME@";
COMPILER_VERSION = "@MeshMC_COMPILER_VERSION@";
COMPILER_TARGET_SYSTEM = "@MeshMC_COMPILER_TARGET_SYSTEM@";
@@ -57,6 +58,7 @@ Config::Config()
GIT_COMMIT = "@MeshMC_GIT_COMMIT@";
GIT_REFSPEC = "@MeshMC_GIT_REFSPEC@";
+ GIT_TAG = "@MeshMC_GIT_TAG@";
if(GIT_REFSPEC.startsWith("refs/heads/") && !UPDATER_BASE.isEmpty() && !BUILD_PLATFORM.isEmpty() && VERSION_BUILD >= 0)
{
VERSION_CHANNEL = GIT_REFSPEC;
@@ -85,17 +87,16 @@ QString Config::printableVersionString() const
{
QString vstr = QString("%1.%2.%3").arg(QString::number(VERSION_MAJOR), QString::number(VERSION_MINOR), QString::number(VERSION_HOTFIX));
- // If the build is not a main release, append the channel
- if(VERSION_CHANNEL != "stable")
+ if(!GIT_TAG.isEmpty() && !GIT_TAG.endsWith("-NOTFOUND"))
{
- vstr += "-" + VERSION_CHANNEL;
+ return vstr;
}
- // if a build number is set, also add it to the end
- if(VERSION_BUILD >= 0)
+ if(!GIT_COMMIT.isEmpty() && !GIT_COMMIT.endsWith("-NOTFOUND"))
{
- vstr += "-" + QString::number(VERSION_BUILD);
+ vstr += "-r" + GIT_COMMIT.left(6);
}
+
return vstr;
}
diff --git a/buildconfig/BuildConfig.h b/buildconfig/BuildConfig.h
index 2d18186a5c..d96ccaab36 100644
--- a/buildconfig/BuildConfig.h
+++ b/buildconfig/BuildConfig.h
@@ -59,6 +59,8 @@ public:
/// URL for the updater's channel
QString UPDATER_BASE;
+ /// A string containing the build timestamp
+ QString BUILD_DATE;
/// User-Agent to use.
QString USER_AGENT;
@@ -99,6 +101,9 @@ public:
/// The git refspec of this build
QString GIT_REFSPEC;
+ /// The exact git tag of this build, if any
+ QString GIT_TAG;
+
/// This is printed on start to standard output
QString VERSION_STR;
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index e62c54391c..9159fa8e37 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -96,6 +96,7 @@
#include <ganalytics.h>
#include <sys.h>
+#include "MMCStrings.h"
#if defined Q_OS_WIN32
@@ -134,7 +135,14 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QSt
APPLICATION->logFile->write(out.toUtf8());
APPLICATION->logFile->flush();
- QTextStream(stderr) << out.toLocal8Bit();
+ QString coloredOut = QString("%1 %2%3%4%5 %6\n")
+ .arg(buf)
+ .arg(Strings::logColor(type))
+ .arg(levels[type])
+ .arg(":")
+ .arg(Strings::logColorReset())
+ .arg(msg);
+ QTextStream(stderr) << coloredOut.toLocal8Bit();
fflush(stderr);
}
diff --git a/launcher/MMCStrings.cpp b/launcher/MMCStrings.cpp
index c39eb697e7..a037d7f1b2 100644
--- a/launcher/MMCStrings.cpp
+++ b/launcher/MMCStrings.cpp
@@ -95,3 +95,31 @@ int Strings::naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensit
// The two strings are the same (02 == 2) so fall back to the normal sort
return QString::compare(s1, s2, cs);
}
+
+QString Strings::htmlListPatch(const QString &html)
+{
+ // QTextBrowser renders <ul>/<ol> lists with too much padding.
+ // This function corrects this by adding reasonable CSS margin/padding to the list elements.
+ QString patched(html);
+ patched.replace(QLatin1String("<ul"), QLatin1String("<ul style=\"margin-left: 0; padding-left: 20px;\""));
+ patched.replace(QLatin1String("<ol"), QLatin1String("<ol style=\"margin-left: 0; padding-left: 20px;\""));
+ patched.replace(QLatin1String("<li"), QLatin1String("<li style=\"margin-bottom: 4px;\""));
+ return patched;
+}
+
+const char *Strings::logColor(QtMsgType type)
+{
+ switch (type) {
+ case QtInfoMsg: return "\033[36m"; // cyan
+ case QtDebugMsg: return "\033[32m"; // green
+ case QtWarningMsg: return "\033[33m"; // yellow
+ case QtCriticalMsg: return "\033[31m"; // red
+ case QtFatalMsg: return "\033[1;31m"; // red again
+ default: return "";
+ }
+}
+
+const char *Strings::logColorReset()
+{
+ return "\033[0m";
+}
diff --git a/launcher/MMCStrings.h b/launcher/MMCStrings.h
index eb9d40fcac..43c1c6cb61 100644
--- a/launcher/MMCStrings.h
+++ b/launcher/MMCStrings.h
@@ -22,8 +22,12 @@
#pragma once
#include <QString>
+#include <QtGlobal>
namespace Strings
{
int naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs);
+ QString htmlListPatch(const QString &html);
+ const char *logColor(QtMsgType type);
+ const char *logColorReset();
}
diff --git a/launcher/UpdateController.cpp b/launcher/UpdateController.cpp
index 4225055a61..bb2bd36176 100644
--- a/launcher/UpdateController.cpp
+++ b/launcher/UpdateController.cpp
@@ -137,11 +137,6 @@ void UpdateController::installUpdates()
return;
}
- bool useXPHack = false;
- QString exePath;
- QString exeOrigin;
- QString exeBackup;
-
// perform the update operations
for(auto op: m_operations)
{
@@ -159,20 +154,6 @@ void UpdateController::installUpdates()
}
#endif
QFileInfo destination (FS::PathCombine(m_root, op.destination));
-#ifdef Q_OS_WIN32
- if(QSysInfo::windowsVersion() < QSysInfo::WV_VISTA)
- {
- if(destination.fileName() == windowsExeName)
- {
- QDir rootDir(m_root);
- exeOrigin = rootDir.relativeFilePath(op.source);
- exePath = rootDir.relativeFilePath(op.destination);
- exeBackup = rootDir.relativeFilePath(FS::PathCombine(backupPath, destination.fileName()));
- useXPHack = true;
- continue;
- }
- }
-#endif
if(destination.exists())
{
QString backupName = op.destination;
@@ -245,39 +226,6 @@ void UpdateController::installUpdates()
args = qApp->arguments();
args.removeFirst();
- // on old Windows, do insane things... no error checking here, this is just to have something.
- if(useXPHack)
- {
- QString script;
- auto nativePath = QDir::toNativeSeparators(exePath);
- auto nativeOriginPath = QDir::toNativeSeparators(exeOrigin);
- auto nativeBackupPath = QDir::toNativeSeparators(exeBackup);
-
- // so we write this vbscript thing...
- QTextStream out(&script);
- out << "WScript.Sleep 1000\n";
- out << "Set fso=CreateObject(\"Scripting.FileSystemObject\")\n";
- out << "Set shell=CreateObject(\"WScript.Shell\")\n";
- out << "fso.MoveFile \"" << nativePath << "\", \"" << nativeBackupPath << "\"\n";
- out << "fso.MoveFile \"" << nativeOriginPath << "\", \"" << nativePath << "\"\n";
- out << "shell.Run \"" << nativePath << "\"\n";
-
- QString scriptPath = FS::PathCombine(m_root, "update", "update.vbs");
-
- // we save it
- QFile scriptFile(scriptPath);
- if (!scriptFile.open(QIODevice::WriteOnly))
- return;
- scriptFile.write(script.toLocal8Bit().replace("\n", "\r\n"));
- scriptFile.close();
-
- // we run it
- started = QProcess::startDetached("wscript", {scriptPath}, m_root);
-
- // and we quit. conscious thought.
- qApp->quit();
- return;
- }
bool doLiveCheck = true;
bool startFailed = false;
diff --git a/launcher/resources/documents/credits.html b/launcher/resources/documents/credits.html
new file mode 100644
index 0000000000..8fb61c1cf9
--- /dev/null
+++ b/launcher/resources/documents/credits.html
@@ -0,0 +1,12 @@
+<center>
+<h3>%1</h3> <!-- MeshMC Developers -->
+<p>Mehmet Samet Duman &lt;<a href="mailto:yongdohyun@projecttick.org">yongdohyun@projecttick.org</a>&gt;</p>
+<br />
+<h3>%2</h3> <!-- MultiMC Developers-->
+<p>Andrew Okin &lt;<a href="mailto:forkk@forkk.net">forkk@forkk.net</a>&gt;</p>
+<p>Petr Mrázek &lt;<a href="mailto:peterix@gmail.com">peterix@gmail.com</a>&gt;</p>
+<p>Sky Welch &lt;<a href="mailto:multimc@bunnies.io">multimc@bunnies.io</a>&gt;</p>
+<p>Jan (02JanDal) &lt;<a href="mailto:02jandal@gmail.com">02jandal@gmail.com</a>&gt;</p>
+<p>RoboSky &lt;<a href="https://twitter.com/RoboSky_">@RoboSky_</a>&gt;</p>
+<br />
+</center>
diff --git a/launcher/resources/documents/documents.qrc b/launcher/resources/documents/documents.qrc
index 007efcde32..19c7021b53 100644
--- a/launcher/resources/documents/documents.qrc
+++ b/launcher/resources/documents/documents.qrc
@@ -2,6 +2,7 @@
<RCC version="1.0">
<qresource prefix="/documents">
<file>../../../COPYING.md</file>
+ <file>credits.html</file>
</qresource>
</RCC>
diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp
index 3150764157..7773a9a5e8 100644
--- a/launcher/ui/dialogs/AboutDialog.cpp
+++ b/launcher/ui/dialogs/AboutDialog.cpp
@@ -45,77 +45,77 @@
#include <net/NetJob.h>
#include "HoeDown.h"
+#include "MMCStrings.h"
namespace {
// Credits
-// This is a hack, but I can't think of a better way to do this easily without screwing with QTextDocument...
-QString getCreditsHtml(QStringList patrons)
+QString getCreditsHtml()
{
- QString patronsHeading = QObject::tr("Patrons", "About Credits");
- QString output;
- QTextStream stream(&output);
- stream << "<center>\n";
- // TODO: possibly retrieve from git history at build time?
- stream << "<h2> MeshMC Developers </h2>\n";
- stream << "<h3>" << QObject::tr("Developers", "About Credits") << "</h3>\n";
- stream << "<p>Mehmet Samet Duman &lt;<a href='mailto:yongdohyun@projecttick.org'>yongdohyun@projecttick.org</a>&gt;</p>\n";
-
- stream << "<h2> MultiMC Developers </h2>\n";
- stream << "<h3>" << QObject::tr("Developers", "About Credits") << "</h3>\n";
- stream << "<p>Andrew Okin &lt;<a href='mailto:forkk@forkk.net'>forkk@forkk.net</a>&gt;</p>\n";
- stream << "<p>Petr Mrázek &lt;<a href='mailto:peterix@gmail.com'>peterix@gmail.com</a>&gt;</p>\n";
- stream << "<p>Sky Welch &lt;<a href='mailto:multimc@bunnies.io'>multimc@bunnies.io</a>&gt;</p>\n";
- stream << "<p>Jan (02JanDal) &lt;<a href='mailto:02jandal@gmail.com'>02jandal@gmail.com</a>&gt;</p>\n";
- stream << "<p>RoboSky &lt;<a href='https://twitter.com/RoboSky_'>@RoboSky_</a>&gt;</p>\n";
- stream << "<br />\n";
-
- stream << "</center>\n";
- return output;
+ QFile dataFile(":/documents/credits.html");
+ if (!dataFile.open(QIODevice::ReadOnly)) {
+ qWarning() << "Failed to open file" << dataFile.fileName() << "for reading:" << dataFile.errorString();
+ return {};
+ }
+ QString fileContent = QString::fromUtf8(dataFile.readAll());
+ dataFile.close();
+
+ return fileContent.arg(QObject::tr("%1 Developers").arg(BuildConfig.MESHMC_DISPLAYNAME), QObject::tr("MultiMC Developers"));
}
QString getLicenseHtml()
{
- HoeDown hoedown;
QFile dataFile(":/documents/COPYING.md");
- if (!dataFile.open(QIODevice::ReadOnly))
- {
+ if (dataFile.open(QIODevice::ReadOnly)) {
+ HoeDown hoedown;
+ QString output = hoedown.process(dataFile.readAll());
+ dataFile.close();
+ return output;
+ } else {
+ qWarning() << "Failed to open file" << dataFile.fileName() << "for reading:" << dataFile.errorString();
return QString();
}
- QString output = hoedown.process(dataFile.readAll());
- return output;
}
-}
+} // namespace
-AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog)
+AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog)
{
ui->setupUi(this);
- QString launcherName = BuildConfig.MESHMC_NAME;
+ QString launcherName = BuildConfig.MESHMC_DISPLAYNAME;
setWindowTitle(tr("About %1").arg(launcherName));
- QString chtml = getCreditsHtml(QStringList());
- ui->creditsText->setHtml(chtml);
+ QString chtml = getCreditsHtml();
+ ui->creditsText->setHtml(Strings::htmlListPatch(chtml));
QString lhtml = getLicenseHtml();
- ui->licenseText->setHtml(lhtml);
+ ui->licenseText->setHtml(Strings::htmlListPatch(lhtml));
ui->urlLabel->setOpenExternalLinks(true);
ui->icon->setPixmap(APPLICATION->getThemedIcon("logo").pixmap(64));
ui->title->setText(launcherName);
- ui->versionLabel->setText(tr("Version") +": " + BuildConfig.printableVersionString());
- ui->platformLabel->setText(tr("Platform") +": " + BuildConfig.BUILD_PLATFORM);
+ ui->versionLabel->setText(BuildConfig.printableVersionString());
+
+ if (!BuildConfig.BUILD_PLATFORM.isEmpty())
+ ui->platformLabel->setText(tr("Platform") + ": " + BuildConfig.BUILD_PLATFORM);
+ else
+ ui->platformLabel->setVisible(false);
+
+ if (!BuildConfig.GIT_COMMIT.isEmpty())
+ ui->commitLabel->setText(tr("Commit: %1").arg(BuildConfig.GIT_COMMIT));
+ else
+ ui->commitLabel->setVisible(false);
- if (BuildConfig.VERSION_BUILD >= 0)
- ui->buildNumLabel->setText(tr("Build Number") +": " + QString::number(BuildConfig.VERSION_BUILD));
+ if (!BuildConfig.BUILD_DATE.isEmpty())
+ ui->buildDateLabel->setText(tr("Build date: %1").arg(BuildConfig.BUILD_DATE));
else
- ui->buildNumLabel->setVisible(false);
+ ui->buildDateLabel->setVisible(false);
if (!BuildConfig.VERSION_CHANNEL.isEmpty())
- ui->channelLabel->setText(tr("Channel") +": " + BuildConfig.VERSION_CHANNEL);
+ ui->channelLabel->setText(tr("Channel") + ": " + BuildConfig.VERSION_CHANNEL);
else
ui->channelLabel->setVisible(false);
@@ -125,7 +125,7 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDia
QString copyText("© 2026 %1");
ui->copyLabel->setText(copyText.arg(BuildConfig.MESHMC_COPYRIGHT));
- connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
+ connect(ui->closeButton, &QPushButton::clicked, this, &AboutDialog::close);
connect(ui->aboutQt, &QPushButton::clicked, &QApplication::aboutQt);
}
diff --git a/launcher/ui/dialogs/AboutDialog.ui b/launcher/ui/dialogs/AboutDialog.ui
index 341137f6d3..b4eb31e982 100644
--- a/launcher/ui/dialogs/AboutDialog.ui
+++ b/launcher/ui/dialogs/AboutDialog.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>783</width>
- <height>843</height>
+ <width>573</width>
+ <height>600</height>
</rect>
</property>
<property name="minimumSize">
@@ -87,6 +87,16 @@
</property>
</widget>
</item>
+ <item alignment="Qt::AlignHCenter">
+ <widget class="QLabel" name="versionLabel">
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
@@ -126,6 +136,9 @@
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
+ <property name="textInteractionFlags">
+ <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set>
+ </property>
</widget>
</item>
<item>
@@ -151,44 +164,68 @@
</property>
</widget>
</item>
- <item>
- <widget class="QLabel" name="versionLabel">
+ <item alignment="Qt::AlignHCenter">
+ <widget class="QLabel" name="platformLabel">
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
<property name="text">
- <string>Version:</string>
+ <string>Platform:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
- <item>
- <widget class="QLabel" name="platformLabel">
+ <item alignment="Qt::AlignHCenter">
+ <widget class="QLabel" name="buildDateLabel">
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
<property name="text">
- <string>Platform:</string>
+ <string>Build Date:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
- <item>
- <widget class="QLabel" name="buildNumLabel">
+ <item alignment="Qt::AlignHCenter">
+ <widget class="QLabel" name="commitLabel">
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
<property name="text">
- <string>Build Number:</string>
+ <string>Commit:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
- <item>
+ <item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="channelLabel">
+ <property name="cursor">
+ <cursorShape>IBeamCursor</cursorShape>
+ </property>
<property name="text">
<string>Channel:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item>
@@ -212,13 +249,10 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QTextEdit" name="creditsText">
- <property name="readOnly">
+ <widget class="QTextBrowser" name="creditsText">
+ <property name="openExternalLinks">
<bool>true</bool>
</property>
- <property name="textInteractionFlags">
- <set>Qt::TextBrowserInteraction</set>
- </property>
</widget>
</item>
</layout>
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 703363a787..3555120a43 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -78,7 +78,7 @@ use constant {
my $MAX_LINE_LENGTH = 120;
my $INDENT_WIDTH = 4;
my $CMAKE_INDENT_WIDTH = 3;
-my $MAX_FUNCTION_LENGTH = 200;
+my $MAX_FUNCTION_LENGTH = 500;
my $MAX_FILE_LENGTH = 3000;
my $MAX_NESTING_DEPTH = 6;
my $MAX_PARAMS_PER_FUNCTION = 8;
diff --git a/vcpkg.json b/vcpkg.json
index 9ea22257a9..cb5b5e3d3d 100644
--- a/vcpkg.json
+++ b/vcpkg.json
@@ -14,7 +14,10 @@
},
"cmark",
- "qtnetworkauth",
+ {
+ "name": "qtnetworkauth",
+ "platform": "!osx"
+ },
{
"name": "libarchive",
"default-features": false,