2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 08:27:42 +00:00

New code style refactor

This commit is contained in:
Jack Andersen
2018-12-07 19:19:40 -10:00
parent a1ed397436
commit 39a8b1608d
24 changed files with 2019 additions and 2329 deletions

View File

@@ -16,10 +16,8 @@ const QString CurPlatformString = QStringLiteral("linux");
#error HECL does not know which OS to fetch for
#endif
QString PlatformToString(Platform plat)
{
switch (plat)
{
QString PlatformToString(Platform plat) {
switch (plat) {
case Platform::MacOS:
return QStringLiteral("macos");
case Platform::Win32:
@@ -34,18 +32,15 @@ QString PlatformToString(Platform plat)
Architecture CurArchitecture = Architecture::Invalid;
QString CurArchitectureString;
Platform StringToPlatform(const QString& str)
{
Platform StringToPlatform(const QString& str) {
for (int i = 1; i < int(Platform::MAXPlatform); ++i)
if (!str.compare(PlatformToString(Platform(i)), Qt::CaseInsensitive))
return Platform(i);
return Platform::Invalid;
}
QString ArchitectureToString(Architecture arch)
{
switch (arch)
{
QString ArchitectureToString(Architecture arch) {
switch (arch) {
case Architecture::X86:
return QStringLiteral("x86");
case Architecture::X86_64:
@@ -59,18 +54,15 @@ QString ArchitectureToString(Architecture arch)
}
}
Architecture StringToArchitecture(const QString& str)
{
Architecture StringToArchitecture(const QString& str) {
for (int i = 1; i < int(Architecture::MAXArchitecture); ++i)
if (!str.compare(ArchitectureToString(Architecture(i)), Qt::CaseInsensitive))
return Architecture(i);
return Architecture::Invalid;
}
QString VectorISAToString(VectorISA visa)
{
switch (visa)
{
QString VectorISAToString(VectorISA visa) {
switch (visa) {
case VectorISA::X87:
return QStringLiteral("x87");
case VectorISA::SSE:
@@ -90,20 +82,17 @@ QString VectorISAToString(VectorISA visa)
}
}
VectorISA StringToVectorISA(const QString& str)
{
VectorISA StringToVectorISA(const QString& str) {
for (int i = 1; i < int(VectorISA::MAXVectorISA); ++i)
if (!str.compare(VectorISAToString(VectorISA(i)), Qt::CaseInsensitive))
return VectorISA(i);
return VectorISA::Invalid;
}
URDEVersion::URDEVersion(const QString& filename)
{
URDEVersion::URDEVersion(const QString& filename) {
int idx;
QString useFilename = filename;
if ((idx = filename.indexOf('.')) >= 0)
{
if ((idx = filename.indexOf('.')) >= 0) {
m_extension = QString(filename).remove(0, idx);
useFilename.truncate(idx);
}
@@ -118,20 +107,16 @@ URDEVersion::URDEVersion(const QString& filename)
m_vectorISA = StringToVectorISA(list[4]);
}
QString URDEVersion::fileString(bool withExtension) const
{
QString URDEVersion::fileString(bool withExtension) const {
if (m_version < 0)
return {};
if (withExtension && !m_extension.isEmpty())
return QString("urde-%1-%2-%3-%4%5").arg(QString::number(m_version),
PlatformToString(m_platform),
ArchitectureToString(m_architecture),
VectorISAToString(m_vectorISA),
m_extension);
return QString("urde-%1-%2-%3-%4%5")
.arg(QString::number(m_version), PlatformToString(m_platform), ArchitectureToString(m_architecture),
VectorISAToString(m_vectorISA), m_extension);
else
return QString("urde-%1-%2-%3-%4").arg(QString::number(m_version),
PlatformToString(m_platform),
ArchitectureToString(m_architecture),
return QString("urde-%1-%2-%3-%4")
.arg(QString::number(m_version), PlatformToString(m_platform), ArchitectureToString(m_architecture),
VectorISAToString(m_vectorISA));
}
@@ -139,8 +124,7 @@ QString URDEVersion::fileString(bool withExtension) const
static void HUPHandler(int) {}
#endif
void InitializePlatform()
{
void InitializePlatform() {
#ifndef _WIN32
/* This can happen when terminating hecl - do nothing */
signal(SIGHUP, HUPHandler);
@@ -150,13 +134,11 @@ void InitializePlatform()
const_cast<Architecture&>(CurArchitecture) = Architecture::X86_64;
#elif ZEUS_ARCH_X86
#if !defined(__APPLE__) && !defined(_WIN32)
const_cast<Architecture&>(CurArchitecture) =
(sysconf(_SC_WORD_BIT) == 64 ? Architecture::X86_64 : Architecture::X86);
const_cast<Architecture&>(CurArchitecture) = (sysconf(_SC_WORD_BIT) == 64 ? Architecture::X86_64 : Architecture::X86);
#elif _WIN32
bool isWOW = false;
IsWow64Process(GetCurrentProcess(), &isWOW);
const_cast<Architecture&>(CurArchitecture) =
(isWOW ? Architecture::X86_64 : Architecture::X86);
const_cast<Architecture&>(CurArchitecture) = (isWOW ? Architecture::X86_64 : Architecture::X86);
#endif
#endif
const_cast<QString&>(CurArchitectureString) = ArchitectureToString(CurArchitecture);

View File

@@ -4,14 +4,7 @@
#include <QMetaType>
#include "zeus/Math.hpp"
enum class Platform
{
Invalid,
MacOS,
Win32,
Linux,
MAXPlatform
};
enum class Platform { Invalid, MacOS, Win32, Linux, MAXPlatform };
QString PlatformToString(Platform plat);
Platform StringToPlatform(const QString& str);
@@ -25,43 +18,24 @@ constexpr Platform CurPlatform = Platform::Linux;
extern const QString CurPlatformString;
enum class Architecture
{
Invalid,
X86,
X86_64,
ARM,
AARCH64,
MAXArchitecture
};
enum class Architecture { Invalid, X86, X86_64, ARM, AARCH64, MAXArchitecture };
QString ArchitectureToString(Architecture arch);
Architecture StringToArchitecture(const QString& str);
extern Architecture CurArchitecture;
extern QString CurArchitectureString;
enum class VectorISA
{
Invalid,
X87,
SSE,
SSE2,
SSE3,
SSE41,
AVX,
AVX2,
MAXVectorISA
};
enum class VectorISA { Invalid, X87, SSE, SSE2, SSE3, SSE41, AVX, AVX2, MAXVectorISA };
QString VectorISAToString(VectorISA visa);
VectorISA StringToVectorISA(const QString& str);
class URDEVersion
{
class URDEVersion {
int m_version = -1;
Platform m_platform = CurPlatform;
Architecture m_architecture = CurArchitecture;
VectorISA m_vectorISA = VectorISA::Invalid;
QString m_extension;
public:
URDEVersion() = default;
explicit URDEVersion(const QString& filename);
@@ -75,4 +49,3 @@ public:
Q_DECLARE_METATYPE(URDEVersion);
void InitializePlatform();

View File

@@ -16,8 +16,7 @@ static const char AxioDLPublicKeyPEM[] =
"pwIDAQAB\n"
"-----END PUBLIC KEY-----\n";
static const QSslKey AxioDLPublicKey =
QSslKey({AxioDLPublicKeyPEM}, QSsl::Rsa, QSsl::Pem, QSsl::PublicKey);
static const QSslKey AxioDLPublicKey = QSslKey({AxioDLPublicKeyPEM}, QSsl::Rsa, QSsl::Pem, QSsl::PublicKey);
static const char AxioDLEdgePublicKeyPEM[] =
"-----BEGIN PUBLIC KEY-----\n"
@@ -25,24 +24,20 @@ static const char AxioDLEdgePublicKeyPEM[] =
"K2Uu5VGl7iamdGpUjynQ4uYWMx+WXf2Qkh7UZZgYvA6UeWHEs3M6ME8T6g==\n"
"-----END PUBLIC KEY-----\n";
static const QSslKey AxioDLEdgePublicKey =
QSslKey({AxioDLEdgePublicKeyPEM}, QSsl::Ec, QSsl::Pem, QSsl::PublicKey);
static const QSslKey AxioDLEdgePublicKey = QSslKey({AxioDLEdgePublicKeyPEM}, QSsl::Ec, QSsl::Pem, QSsl::PublicKey);
#endif
void DownloadManager::_validateCert(QNetworkReply* reply)
{
void DownloadManager::_validateCert(QNetworkReply* reply) {
#if KEY_PINNING
QSslCertificate peerCert = reply->sslConfiguration().peerCertificate();
QSslKey peerKey = peerCert.publicKey();
if (peerKey != AxioDLPublicKey && peerKey != AxioDLEdgePublicKey)
{
if (peerKey != AxioDLPublicKey && peerKey != AxioDLEdgePublicKey) {
auto cn = peerCert.subjectInfo(QSslCertificate::CommonName);
if (!cn.empty())
setError(QNetworkReply::SslHandshakeFailedError,
QStringLiteral("Certificate pinning mismatch \"") + cn.first() + "\"");
else
setError(QNetworkReply::SslHandshakeFailedError,
QStringLiteral("Certificate pinning mismatch"));
setError(QNetworkReply::SslHandshakeFailedError, QStringLiteral("Certificate pinning mismatch"));
reply->abort();
}
#endif
@@ -51,8 +46,7 @@ void DownloadManager::_validateCert(QNetworkReply* reply)
static const QString Domain = QStringLiteral("https://releases.axiodl.com/");
static const QString Index = QStringLiteral("index.txt");
void DownloadManager::fetchIndex()
{
void DownloadManager::fetchIndex() {
if (m_indexInProgress)
return;
@@ -60,16 +54,13 @@ void DownloadManager::fetchIndex()
QString url = Domain + CurPlatformString + '/' + Index;
m_indexInProgress = m_netManager.get(QNetworkRequest(url));
connect(m_indexInProgress, SIGNAL(finished()),
this, SLOT(indexFinished()));
connect(m_indexInProgress, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(indexError(QNetworkReply::NetworkError)));
connect(m_indexInProgress, SIGNAL(encrypted()),
this, SLOT(indexValidateCert()));
connect(m_indexInProgress, SIGNAL(finished()), this, SLOT(indexFinished()));
connect(m_indexInProgress, SIGNAL(error(QNetworkReply::NetworkError)), this,
SLOT(indexError(QNetworkReply::NetworkError)));
connect(m_indexInProgress, SIGNAL(encrypted()), this, SLOT(indexValidateCert()));
}
void DownloadManager::fetchBinary(const QString& str, const QString& outPath)
{
void DownloadManager::fetchBinary(const QString& str, const QString& outPath) {
if (m_binaryInProgress)
return;
@@ -78,31 +69,26 @@ void DownloadManager::fetchBinary(const QString& str, const QString& outPath)
QString url = Domain + CurPlatformString + '/' + str;
m_binaryInProgress = m_netManager.get(QNetworkRequest(url));
connect(m_binaryInProgress, SIGNAL(finished()),
this, SLOT(binaryFinished()));
connect(m_binaryInProgress, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(binaryError(QNetworkReply::NetworkError)));
connect(m_binaryInProgress, SIGNAL(encrypted()),
this, SLOT(binaryValidateCert()));
connect(m_binaryInProgress, SIGNAL(downloadProgress(qint64, qint64)),
this, SLOT(binaryDownloadProgress(qint64, qint64)));
connect(m_binaryInProgress, SIGNAL(finished()), this, SLOT(binaryFinished()));
connect(m_binaryInProgress, SIGNAL(error(QNetworkReply::NetworkError)), this,
SLOT(binaryError(QNetworkReply::NetworkError)));
connect(m_binaryInProgress, SIGNAL(encrypted()), this, SLOT(binaryValidateCert()));
connect(m_binaryInProgress, SIGNAL(downloadProgress(qint64, qint64)), this,
SLOT(binaryDownloadProgress(qint64, qint64)));
if (m_progBar)
{
if (m_progBar) {
m_progBar->setEnabled(true);
m_progBar->setValue(0);
}
}
void DownloadManager::indexFinished()
{
void DownloadManager::indexFinished() {
if (m_hasError)
return;
QStringList files;
while (!m_indexInProgress->atEnd())
{
while (!m_indexInProgress->atEnd()) {
QString line = QString::fromUtf8(m_indexInProgress->readLine()).trimmed();
if (line.isEmpty())
continue;
@@ -116,20 +102,15 @@ void DownloadManager::indexFinished()
m_indexInProgress = nullptr;
}
void DownloadManager::indexError(QNetworkReply::NetworkError error)
{
void DownloadManager::indexError(QNetworkReply::NetworkError error) {
setError(error, m_indexInProgress->errorString());
m_indexInProgress->deleteLater();
m_indexInProgress = nullptr;
}
void DownloadManager::indexValidateCert()
{
_validateCert(m_indexInProgress);
}
void DownloadManager::indexValidateCert() { _validateCert(m_indexInProgress); }
void DownloadManager::binaryFinished()
{
void DownloadManager::binaryFinished() {
if (m_hasError)
return;
@@ -139,8 +120,7 @@ void DownloadManager::binaryFinished()
QByteArray all = m_binaryInProgress->readAll();
QBuffer buff(&all);
QuaZip zip(&buff);
if (!zip.open(QuaZip::mdUnzip))
{
if (!zip.open(QuaZip::mdUnzip)) {
setError(QNetworkReply::UnknownContentError, "Unable to open zip archive.");
m_binaryInProgress->deleteLater();
m_binaryInProgress = nullptr;
@@ -154,8 +134,7 @@ void DownloadManager::binaryFinished()
m_binaryInProgress = nullptr;
}
void DownloadManager::binaryError(QNetworkReply::NetworkError error)
{
void DownloadManager::binaryError(QNetworkReply::NetworkError error) {
setError(error, m_binaryInProgress->errorString());
m_binaryInProgress->deleteLater();
m_binaryInProgress = nullptr;
@@ -167,15 +146,10 @@ void DownloadManager::binaryError(QNetworkReply::NetworkError error)
m_failedHandler();
}
void DownloadManager::binaryValidateCert()
{
_validateCert(m_binaryInProgress);
}
void DownloadManager::binaryValidateCert() { _validateCert(m_binaryInProgress); }
void DownloadManager::binaryDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
if (m_progBar)
{
void DownloadManager::binaryDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
if (m_progBar) {
if (bytesReceived == bytesTotal)
m_progBar->setValue(100);
else

View File

@@ -8,8 +8,7 @@
class QuaZip;
class DownloadManager : public QObject
{
class DownloadManager : public QObject {
Q_OBJECT
QNetworkAccessManager m_netManager;
QNetworkReply* m_indexInProgress = nullptr;
@@ -22,15 +21,13 @@ class DownloadManager : public QObject
std::function<void(QuaZip& file)> m_completionHandler;
std::function<void()> m_failedHandler;
void resetError()
{
void resetError() {
m_hasError = false;
if (m_errorLabel)
m_errorLabel->setText(QString());
}
void setError(QNetworkReply::NetworkError error, const QString& errStr)
{
void setError(QNetworkReply::NetworkError error, const QString& errStr) {
if (m_hasError && error == QNetworkReply::OperationCanceledError)
return;
m_hasError = true;
@@ -41,13 +38,10 @@ class DownloadManager : public QObject
void _validateCert(QNetworkReply* reply);
public:
explicit DownloadManager(QObject* parent = Q_NULLPTR)
: QObject(parent), m_netManager(this) {}
explicit DownloadManager(QObject* parent = Q_NULLPTR) : QObject(parent), m_netManager(this) {}
void connectWidgets(QProgressBar* progBar, QLabel* errorLabel,
std::function<void(const QStringList& index)>&& indexCompletionHandler,
std::function<void(QuaZip& file)>&& completionHandler,
std::function<void()>&& failedHandler)
{
std::function<void(QuaZip& file)>&& completionHandler, std::function<void()>&& failedHandler) {
m_progBar = progBar;
m_errorLabel = errorLabel;
m_indexCompletionHandler = std::move(indexCompletionHandler);
@@ -67,6 +61,4 @@ public slots:
void binaryError(QNetworkReply::NetworkError error);
void binaryValidateCert();
void binaryDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
};

View File

@@ -2,12 +2,10 @@
#include <QLabel>
class ErrorLabel : public QLabel
{
class ErrorLabel : public QLabel {
public:
ErrorLabel(QWidget* parent = Q_NULLPTR) : QLabel(parent) {}
void setText(const QString& str, bool success = false)
{
void setText(const QString& str, bool success = false) {
QPalette pal = QLabel::palette();
if (success)
pal.setColor(QPalette::WindowText, QColor(0, 255, 0));
@@ -17,4 +15,3 @@ public:
QLabel::setText(str);
}
};

View File

@@ -6,8 +6,7 @@
// http://misc.flogisoft.com/bash/tip_colors_and_formatting
// http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharFormat& textCharFormat,
const QTextCharFormat& defaultTextCharFormat)
{
const QTextCharFormat& defaultTextCharFormat) {
switch (attribute) {
case 0: { // Normal/Default (reset all attributes)
textCharFormat = defaultTextCharFormat;
@@ -70,7 +69,8 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
QStringList fontStyles = fontDatabase.styles(fontFamily);
int fontStyleIndex = attribute - 11;
if (fontStyleIndex < fontStyles.length()) {
textCharFormat.setFont(fontDatabase.font(fontFamily, fontStyles.at(fontStyleIndex), textCharFormat.font().pointSize()));
textCharFormat.setFont(
fontDatabase.font(fontFamily, fontStyles.at(fontStyleIndex), textCharFormat.font().pointSize()));
}
break;
}
@@ -124,8 +124,7 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
case 34:
case 35:
case 36:
case 37:
{
case 37: {
int colorIndex = attribute - 30;
QColor color;
if (QFont::Normal < textCharFormat.fontWeight()) {
@@ -162,9 +161,7 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
color = Qt::white;
break;
}
default : {
Q_ASSERT(false);
}
default: { Q_ASSERT(false); }
}
} else {
/* Normally dark colors, but forced to light colors for visibility */
@@ -201,9 +198,7 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
color = Qt::white;
break;
}
default : {
Q_ASSERT(false);
}
default: { Q_ASSERT(false); }
}
}
textCharFormat.setForeground(color);
@@ -235,23 +230,17 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
color.setRgb(red, green, blue);
break;
}
case 5 :
{
case 5: {
if (!i.hasNext()) {
break;
}
int index = i.next().toInt(&ok);
Q_ASSERT(ok);
if (index >= 0 && index <= 0x07)
{ // 0x00-0x07: standard colors (as in ESC [ 30..37 m)
if (index >= 0 && index <= 0x07) { // 0x00-0x07: standard colors (as in ESC [ 30..37 m)
return ParseEscapeSequence(index - 0x00 + 30, i, textCharFormat, defaultTextCharFormat);
}
else if (index >= 0x08 && index <= 0x0F)
{ // 0x08-0x0F: high intensity colors (as in ESC [ 90..97 m)
} else if (index >= 0x08 && index <= 0x0F) { // 0x08-0x0F: high intensity colors (as in ESC [ 90..97 m)
return ParseEscapeSequence(index - 0x08 + 90, i, textCharFormat, defaultTextCharFormat);
}
else if (index >= 0x10 && index <= 0xE7)
{ // 0x10-0xE7: 6*6*6=216 colors: 16 + 36*r + 6*g + b (0≤r,g,b≤5)
} else if (index >= 0x10 && index <= 0xE7) { // 0x10-0xE7: 6*6*6=216 colors: 16 + 36*r + 6*g + b (0≤r,g,b≤5)
index -= 0x10;
int red = index % 6;
index /= 6;
@@ -262,9 +251,7 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
Q_ASSERT(index == 0);
color.setRgb(red, green, blue);
break;
}
else if (index >= 0xE8 && index <= 0xFF)
{ // 0xE8-0xFF: grayscale from black to white in 24 steps
} else if (index >= 0xE8 && index <= 0xFF) { // 0xE8-0xFF: grayscale from black to white in 24 steps
qreal intensity = qreal(index - 0xE8) / (0xFF - 0xE8);
color.setRgbF(intensity, intensity, intensity);
break;
@@ -272,9 +259,7 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
textCharFormat.setForeground(color);
break;
}
default : {
break;
}
default: { break; }
}
}
break;
@@ -326,9 +311,7 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
color = Qt::white;
break;
}
default : {
Q_ASSERT(false);
}
default: { Q_ASSERT(false); }
}
textCharFormat.setBackground(color);
break;
@@ -365,16 +348,11 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
}
int index = i.next().toInt(&ok);
Q_ASSERT(ok);
if (index >= 0x00 && index <= 0x07)
{ // 0x00-0x07: standard colors (as in ESC [ 40..47 m)
if (index >= 0x00 && index <= 0x07) { // 0x00-0x07: standard colors (as in ESC [ 40..47 m)
return ParseEscapeSequence(index - 0x00 + 40, i, textCharFormat, defaultTextCharFormat);
}
else if (index >= 0x08 && index <= 0x0F)
{ // 0x08-0x0F: high intensity colors (as in ESC [ 100..107 m)
} else if (index >= 0x08 && index <= 0x0F) { // 0x08-0x0F: high intensity colors (as in ESC [ 100..107 m)
return ParseEscapeSequence(index - 0x08 + 100, i, textCharFormat, defaultTextCharFormat);
}
else if (index >= 0x10 && index <= 0xE7)
{ // 0x10-0xE7: 6*6*6=216 colors: 16 + 36*r + 6*g + b (0≤r,g,b≤5)
} else if (index >= 0x10 && index <= 0xE7) { // 0x10-0xE7: 6*6*6=216 colors: 16 + 36*r + 6*g + b (0≤r,g,b≤5)
index -= 0x10;
int red = index % 6;
index /= 6;
@@ -385,9 +363,7 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
Q_ASSERT(index == 0);
color.setRgb(red, green, blue);
break;
}
else if (index >= 0xE8 && index <= 0xFF)
{ // 0xE8-0xFF: grayscale from black to white in 24 steps
} else if (index >= 0xE8 && index <= 0xFF) { // 0xE8-0xFF: grayscale from black to white in 24 steps
qreal intensity = qreal(index - 0xE8) / (0xFF - 0xE8);
color.setRgbF(intensity, intensity, intensity);
}
@@ -445,9 +421,7 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
color = Qt::white;
break;
}
default : {
Q_ASSERT(false);
}
default: { Q_ASSERT(false); }
}
// color.setRedF(color.redF() * 0.8);
// color.setGreenF(color.greenF() * 0.8);
@@ -462,8 +436,7 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
case 104:
case 105:
case 106:
case 107:
{
case 107: {
int colorIndex = attribute - 100;
QColor color;
switch (colorIndex) {
@@ -499,9 +472,7 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
color = Qt::white;
break;
}
default : {
Q_ASSERT(false);
}
default: { Q_ASSERT(false); }
}
// color.setRedF(color.redF() * 0.8);
// color.setGreenF(color.greenF() * 0.8);
@@ -509,30 +480,22 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
textCharFormat.setBackground(color);
break;
}
default : {
break;
}
default: { break; }
}
}
void ReturnInsert(QTextCursor& cur, const QString& text)
{
auto DoLine = [&](const QString& line)
{
auto DoReturn = [&](const QString& ret)
{
if (!ret.isEmpty())
{
void ReturnInsert(QTextCursor& cur, const QString& text) {
auto DoLine = [&](const QString& line) {
auto DoReturn = [&](const QString& ret) {
if (!ret.isEmpty()) {
cur.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, ret.size());
cur.insertText(ret);
}
};
QStringList list = line.split('\r');
DoReturn(list.front());
if (list.size() > 1)
{
for (auto it = list.begin() + 1; it != list.end(); ++it)
{
if (list.size() > 1) {
for (auto it = list.begin() + 1; it != list.end(); ++it) {
cur.movePosition(QTextCursor::StartOfBlock);
DoReturn(*it);
}
@@ -545,10 +508,8 @@ void ReturnInsert(QTextCursor& cur, const QString& text)
QStringList lineSplit = text.split('\n');
#endif
DoLine(lineSplit.front());
if (lineSplit.size() > 1)
{
for (auto it = lineSplit.begin() + 1; it != lineSplit.end(); ++it)
{
if (lineSplit.size() > 1) {
for (auto it = lineSplit.begin() + 1; it != lineSplit.end(); ++it) {
cur.movePosition(QTextCursor::EndOfLine);
cur.insertBlock();
DoLine(*it);
@@ -556,24 +517,18 @@ void ReturnInsert(QTextCursor& cur, const QString& text)
}
}
void ReturnInsert(QTextCursor& cur, const QString& text, const QTextCharFormat& format)
{
auto DoLine = [&](const QString& line)
{
auto DoReturn = [&](const QString& ret)
{
if (!ret.isEmpty())
{
void ReturnInsert(QTextCursor& cur, const QString& text, const QTextCharFormat& format) {
auto DoLine = [&](const QString& line) {
auto DoReturn = [&](const QString& ret) {
if (!ret.isEmpty()) {
cur.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, ret.size());
cur.insertText(ret, format);
}
};
QStringList list = line.split('\r');
DoReturn(list.front());
if (list.size() > 1)
{
for (auto it = list.begin() + 1; it != list.end(); ++it)
{
if (list.size() > 1) {
for (auto it = list.begin() + 1; it != list.end(); ++it) {
cur.movePosition(QTextCursor::StartOfBlock);
DoReturn(*it);
}
@@ -586,10 +541,8 @@ void ReturnInsert(QTextCursor& cur, const QString& text, const QTextCharFormat&
QStringList lineSplit = text.split('\n');
#endif
DoLine(lineSplit.front());
if (lineSplit.size() > 1)
{
for (auto it = lineSplit.begin() + 1; it != lineSplit.end(); ++it)
{
if (lineSplit.size() > 1) {
for (auto it = lineSplit.begin() + 1; it != lineSplit.end(); ++it) {
cur.movePosition(QTextCursor::EndOfLine);
cur.insertBlock();
DoLine(*it);

View File

@@ -10,4 +10,3 @@ void ParseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharForm
void ReturnInsert(QTextCursor& cur, const QString& text);
void ReturnInsert(QTextCursor& cur, const QString& text, const QTextCharFormat& format);

View File

@@ -8,8 +8,7 @@
* Only contains directory extraction functionality.
*/
static bool copyData(QIODevice &inFile, QIODevice &outFile)
{
static bool copyData(QIODevice& inFile, QIODevice& outFile) {
while (!inFile.atEnd()) {
char buf[4096];
qint64 readLen = inFile.read(buf, 4096);
@@ -21,8 +20,7 @@ static bool copyData(QIODevice &inFile, QIODevice &outFile)
return true;
}
QStringList ExtractZip::getFileList(QuaZip& zip)
{
QStringList ExtractZip::getFileList(QuaZip& zip) {
// Estraggo i nomi dei file
QStringList lst;
QuaZipFileInfo64 info;
@@ -50,20 +48,21 @@ QStringList ExtractZip::getFileList(QuaZip& zip)
*
* (1): prima di uscire dalla funzione cancella il file estratto.
*/
bool ExtractZip::extractFile(QuaZip& zip, QString fileName, QString fileDest)
{
bool ExtractZip::extractFile(QuaZip& zip, QString fileName, QString fileDest) {
// zip: oggetto dove aggiungere il file
// filename: nome del file reale
// fileincompress: nome del file all'interno del file compresso
// Controllo l'apertura dello zip
if (zip.getMode()!=QuaZip::mdUnzip) return false;
if (zip.getMode() != QuaZip::mdUnzip)
return false;
// Apro il file compresso
if (!fileName.isEmpty())
zip.setCurrentFile(fileName);
QuaZipFile inFile(&zip);
if(!inFile.open(QIODevice::ReadOnly) || inFile.getZipError()!=UNZ_OK) return false;
if (!inFile.open(QIODevice::ReadOnly) || inFile.getZipError() != UNZ_OK)
return false;
// Controllo esistenza cartella file risultato
QDir curDir;
@@ -92,7 +91,8 @@ bool ExtractZip::extractFile(QuaZip& zip, QString fileName, QString fileDest)
// Apro il file risultato
QFile outFile;
outFile.setFileName(fileDest);
if(!outFile.open(QIODevice::WriteOnly)) return false;
if (!outFile.open(QIODevice::WriteOnly))
return false;
// Copio i dati
if (!copyData(inFile, outFile) || inFile.getZipError() != UNZ_OK) {
@@ -124,8 +124,7 @@ bool ExtractZip::extractFile(QuaZip& zip, QString fileName, QString fileDest)
* * la compressione di un file fallisce;
* * non si riesce a chiudere l'oggetto zip;
*/
bool ExtractZip::extractDir(QuaZip& zip, QString dir)
{
bool ExtractZip::extractDir(QuaZip& zip, QString dir) {
QDir directory(dir);
if (!zip.goToFirstFile()) {
return false;

View File

@@ -4,11 +4,9 @@ class QStringList;
class QuaZip;
class QString;
class ExtractZip
{
class ExtractZip {
public:
static QStringList getFileList(QuaZip& zip);
static bool extractFile(QuaZip& zip, QString fileName, QString fileDest);
static bool extractDir(QuaZip& zip, QString dir);
};

View File

@@ -2,10 +2,8 @@
#include <QFileDialog>
class FileDirDialog : public QFileDialog
{
class FileDirDialog : public QFileDialog {
Q_OBJECT
public:
FileDirDialog(QWidget* parent = nullptr) : QFileDialog(parent) { setFileMode(QFileDialog::Directory); }
};

View File

@@ -2,8 +2,7 @@
#include "hecl/SteamFinder.hpp"
#include "hecl/hecl.hpp"
namespace hecl::blender
{
namespace hecl::blender {
#ifdef __APPLE__
#define DEFAULT_BLENDER_BIN "/Applications/Blender.app/Contents/MacOS/blender"
@@ -16,16 +15,14 @@ namespace hecl::blender
static const std::regex regBlenderVersion(R"(Blender ([0-9]+).([0-9]+) )",
std::regex::ECMAScript | std::regex::optimize);
static bool RegFileExists(const hecl::SystemChar* path)
{
static bool RegFileExists(const hecl::SystemChar* path) {
if (!path)
return false;
hecl::Sstat theStat;
return !hecl::Stat(path, &theStat) && S_ISREG(theStat.st_mode);
}
hecl::SystemString FindBlender(int& major, int& minor)
{
hecl::SystemString FindBlender(int& major, int& minor) {
major = 0;
minor = 0;
@@ -42,58 +39,46 @@ hecl::SystemString FindBlender(int& major, int& minor)
/* Child process of blender */
#if _WIN32
if (!blenderBin || !RegFileExists(blenderBin))
{
if (!blenderBin || !RegFileExists(blenderBin)) {
/* Environment not set; try steam */
steamBlender = hecl::FindCommonSteamApp(_SYS_STR("Blender"));
if (steamBlender.size())
{
if (steamBlender.size()) {
steamBlender += _SYS_STR("\\blender.exe");
blenderBin = steamBlender.c_str();
}
if (!RegFileExists(blenderBin))
{
if (!RegFileExists(blenderBin)) {
/* No steam; try default */
wchar_t progFiles[256];
if (GetEnvironmentVariableW(L"ProgramFiles", progFiles, 256))
{
if (GetEnvironmentVariableW(L"ProgramFiles", progFiles, 256)) {
_snwprintf(BLENDER_BIN_BUF, 2048, L"%s\\Blender Foundation\\Blender\\blender.exe", progFiles);
blenderBin = BLENDER_BIN_BUF;
if (!RegFileExists(blenderBin))
blenderBin = nullptr;
}
else
} else
blenderBin = nullptr;
}
}
#else
if (!RegFileExists(blenderBin))
{
if (!RegFileExists(blenderBin)) {
/* Try steam */
steamBlender = hecl::FindCommonSteamApp(_SYS_STR("Blender"));
if (steamBlender.size())
{
if (steamBlender.size()) {
#ifdef __APPLE__
steamBlender += "/blender.app/Contents/MacOS/blender";
#else
steamBlender += "/blender";
#endif
blenderBin = steamBlender.c_str();
if (!RegFileExists(blenderBin))
{
if (!RegFileExists(blenderBin)) {
blenderBin = DEFAULT_BLENDER_BIN;
if (!RegFileExists(blenderBin))
{
if (!RegFileExists(blenderBin)) {
blenderBin = nullptr;
}
}
}
else
{
} else {
blenderBin = DEFAULT_BLENDER_BIN;
if (!RegFileExists(blenderBin))
{
if (!RegFileExists(blenderBin)) {
blenderBin = nullptr;
}
}
@@ -119,8 +104,7 @@ hecl::SystemString FindBlender(int& major, int& minor)
#endif
std::cmatch match;
if (std::regex_search(versionBuf, match, regBlenderVersion))
{
if (std::regex_search(versionBuf, match, regBlenderVersion)) {
major = atoi(match[1].str().c_str());
minor = atoi(match[2].str().c_str());
return blenderBin;
@@ -129,5 +113,4 @@ hecl::SystemString FindBlender(int& major, int& minor)
return blenderBin;
}
}
} // namespace hecl::blender

View File

@@ -2,10 +2,8 @@
#include "hecl/hecl.hpp"
namespace hecl::blender
{
namespace hecl::blender {
hecl::SystemString FindBlender(int& major, int& minor);
}

View File

@@ -4,15 +4,14 @@
extern hecl::CVar* hecl::com_developer;
LaunchMenu::LaunchMenu(hecl::CVarCommons& commons, QWidget* parent)
: QMenu("Launch Menu", parent),
m_commons(commons),
m_apiMenu("Graphics API", this),
m_msaaMenu("Anti-Aliasing", this),
m_anisoMenu("Anisotropic Filtering", this),
m_apiGroup(this),
m_msaaGroup(this),
m_anisoGroup(this)
{
: QMenu("Launch Menu", parent)
, m_commons(commons)
, m_apiMenu("Graphics API", this)
, m_msaaMenu("Anti-Aliasing", this)
, m_anisoMenu("Anisotropic Filtering", this)
, m_apiGroup(this)
, m_msaaGroup(this)
, m_anisoGroup(this) {
#ifdef _WIN32
initApiAction(QStringLiteral("D3D11"));
initApiAction(QStringLiteral("Vulkan"));
@@ -48,8 +47,7 @@ LaunchMenu::LaunchMenu(hecl::CVarCommons& commons, QWidget* parent)
initDeveloperMode();
}
void LaunchMenu::initApiAction(const QString& action)
{
void LaunchMenu::initApiAction(const QString& action) {
QAction* act = m_apiGroup.addAction(action);
connect(act, SIGNAL(triggered()), this, SLOT(apiTriggered()));
act->setCheckable(true);
@@ -57,8 +55,7 @@ void LaunchMenu::initApiAction(const QString& action)
act->setChecked(true);
}
void LaunchMenu::initMsaaAction(const QString& action)
{
void LaunchMenu::initMsaaAction(const QString& action) {
QAction* act = m_msaaGroup.addAction(action);
connect(act, SIGNAL(triggered()), this, SLOT(msaaTriggered()));
act->setCheckable(true);
@@ -66,8 +63,7 @@ void LaunchMenu::initMsaaAction(const QString& action)
act->setChecked(true);
}
void LaunchMenu::initAnisoAction(const QString& action)
{
void LaunchMenu::initAnisoAction(const QString& action) {
QAction* act = m_anisoGroup.addAction(action);
connect(act, SIGNAL(triggered()), this, SLOT(anisoTriggered()));
act->setCheckable(true);
@@ -75,8 +71,7 @@ void LaunchMenu::initAnisoAction(const QString& action)
act->setChecked(true);
}
void LaunchMenu::initDeepColor()
{
void LaunchMenu::initDeepColor() {
QAction* act = addAction("Deep Color");
act->setToolTip(m_commons.m_deepColor->rawHelp().data());
act->setCheckable(true);
@@ -84,8 +79,7 @@ void LaunchMenu::initDeepColor()
connect(act, SIGNAL(triggered()), this, SLOT(deepColorTriggered()));
}
void LaunchMenu::initDeveloperMode()
{
void LaunchMenu::initDeveloperMode() {
QAction* act = addAction("Developer Mode");
act->setToolTip(hecl::com_developer->rawHelp().data());
act->setCheckable(true);
@@ -93,34 +87,29 @@ void LaunchMenu::initDeveloperMode()
connect(act, SIGNAL(triggered()), this, SLOT(developerModeTriggered()));
}
void LaunchMenu::apiTriggered()
{
void LaunchMenu::apiTriggered() {
QString apiStr = qobject_cast<QAction*>(sender())->text();
apiStr = apiStr.remove('&');
m_commons.setGraphicsApi(apiStr.toStdString());
m_commons.serialize();
}
void LaunchMenu::msaaTriggered()
{
void LaunchMenu::msaaTriggered() {
m_commons.setSamples(qobject_cast<QAction*>(sender())->text().toUInt());
m_commons.serialize();
}
void LaunchMenu::anisoTriggered()
{
void LaunchMenu::anisoTriggered() {
m_commons.setAnisotropy(qobject_cast<QAction*>(sender())->text().toUInt());
m_commons.serialize();
}
void LaunchMenu::deepColorTriggered()
{
void LaunchMenu::deepColorTriggered() {
m_commons.setDeepColor(qobject_cast<QAction*>(sender())->isChecked());
m_commons.serialize();
}
void LaunchMenu::developerModeTriggered()
{
void LaunchMenu::developerModeTriggered() {
hecl::CVarManager::instance()->setDeveloperMode(qobject_cast<QAction*>(sender())->isChecked(), true);
m_commons.serialize();
}

View File

@@ -1,10 +1,11 @@
#pragma once
#include <QMenu>
namespace hecl { struct CVarCommons; }
namespace hecl {
struct CVarCommons;
}
class LaunchMenu : public QMenu
{
class LaunchMenu : public QMenu {
Q_OBJECT
hecl::CVarCommons& m_commons;
@@ -32,4 +33,3 @@ public slots:
void deepColorTriggered();
void developerModeTriggered();
};

View File

@@ -1,4 +1,3 @@
#pragma once
void GetMacOSSystemVersion(int& major, int& minor, int& patch);

View File

@@ -11,8 +11,7 @@
#include <shellapi.h>
#include <TlHelp32.h>
static void KillProcessTree(QProcess& proc)
{
static void KillProcessTree(QProcess& proc) {
Q_PID pid = proc.pid();
if (!pid)
return;
@@ -23,20 +22,16 @@ static void KillProcessTree(QProcess& proc)
HANDLE hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (::Process32First(hSnap, &pe))
{
if (::Process32First(hSnap, &pe)) {
BOOL bContinue = TRUE;
// kill child processes
while (bContinue)
{
while (bContinue) {
// only kill child processes
if (pe.th32ParentProcessID == myprocID)
{
if (pe.th32ParentProcessID == myprocID) {
HANDLE hChildProc = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
if (hChildProc)
{
if (hChildProc) {
::TerminateProcess(hChildProc, 1);
::CloseHandle(hChildProc);
}
@@ -50,15 +45,14 @@ static void KillProcessTree(QProcess& proc)
proc.terminate();
}
#else
static void KillProcessTree(QProcess& proc)
{
static void KillProcessTree(QProcess& proc) {
proc.close();
proc.terminate();
}
#endif
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
, m_fileMgr(_SYS_STR("urde"))
, m_cvarManager(m_fileMgr)
, m_cvarCommons(m_cvarManager)
@@ -66,8 +60,7 @@ MainWindow::MainWindow(QWidget *parent) :
, m_heclProc(this)
, m_dlManager(this)
, m_launchMenu(m_cvarCommons, this)
, m_settings("AxioDL", "HECL", this)
{
, m_settings("AxioDL", "HECL", this) {
m_ui->setupUi(this);
m_ui->heclTabs->setCurrentIndex(0);
@@ -101,14 +94,12 @@ MainWindow::MainWindow(QWidget *parent) :
setPath(m_settings.value(QStringLiteral("working_dir")).toString());
}
MainWindow::~MainWindow()
{
MainWindow::~MainWindow() {
KillProcessTree(m_heclProc);
delete m_ui;
}
void MainWindow::onExtract()
{
void MainWindow::onExtract() {
if (m_path.isEmpty())
return;
QString imgPath = QFileDialog::getOpenFileName(this, QStringLiteral("Extract Image"), m_path,
@@ -138,8 +129,7 @@ void MainWindow::onExtract()
connect(m_ui->extractBtn, SIGNAL(clicked()), this, SLOT(doHECLTerminate()));
}
void MainWindow::onExtractFinished(int returnCode)
{
void MainWindow::onExtractFinished(int returnCode) {
m_cursor.movePosition(QTextCursor::End);
m_cursor.insertBlock();
disconnect(m_ui->extractBtn, SIGNAL(clicked()), nullptr, nullptr);
@@ -147,8 +137,7 @@ void MainWindow::onExtractFinished(int returnCode)
checkDownloadedBinary();
}
void MainWindow::onPackage()
{
void MainWindow::onPackage() {
if (m_path.isEmpty())
return;
m_ui->processOutput->clear();
@@ -161,8 +150,7 @@ void MainWindow::onPackage()
m_heclProc.setProcessEnvironment(env);
disconnect(&m_heclProc, SIGNAL(finished(int)), nullptr, nullptr);
connect(&m_heclProc, SIGNAL(finished(int)), this, SLOT(onPackageFinished(int)));
m_heclProc.start(m_heclPath, {"package", "-y", "-g"},
QIODevice::ReadOnly | QIODevice::Unbuffered);
m_heclProc.start(m_heclPath, {"package", "-y", "-g"}, QIODevice::ReadOnly | QIODevice::Unbuffered);
m_ui->heclTabs->setCurrentIndex(0);
@@ -178,8 +166,7 @@ void MainWindow::onPackage()
resize(size);
}
void MainWindow::onPackageFinished(int returnCode)
{
void MainWindow::onPackageFinished(int returnCode) {
m_cursor.movePosition(QTextCursor::End);
m_cursor.insertBlock();
disconnect(m_ui->packageBtn, SIGNAL(clicked()), nullptr, nullptr);
@@ -187,8 +174,7 @@ void MainWindow::onPackageFinished(int returnCode)
checkDownloadedBinary();
}
void MainWindow::onLaunch()
{
void MainWindow::onLaunch() {
if (m_path.isEmpty())
return;
m_ui->processOutput->clear();
@@ -201,38 +187,30 @@ void MainWindow::onLaunch()
m_heclProc.setProcessEnvironment(env);
disconnect(&m_heclProc, SIGNAL(finished(int)), nullptr, nullptr);
connect(&m_heclProc, SIGNAL(finished(int)), this, SLOT(onLaunchFinished(int)));
m_heclProc.start(m_urdePath, {"--no-shader-warmup", m_path + "/out"},
QIODevice::ReadOnly | QIODevice::Unbuffered);
m_heclProc.start(m_urdePath, {"--no-shader-warmup", m_path + "/out"}, QIODevice::ReadOnly | QIODevice::Unbuffered);
m_ui->heclTabs->setCurrentIndex(0);
disableOperations();
}
void MainWindow::onLaunchFinished(int returnCode)
{
void MainWindow::onLaunchFinished(int returnCode) {
m_cursor.movePosition(QTextCursor::End);
m_cursor.insertBlock();
checkDownloadedBinary();
}
void MainWindow::doHECLTerminate()
{
KillProcessTree(m_heclProc);
}
void MainWindow::doHECLTerminate() { KillProcessTree(m_heclProc); }
void MainWindow::onReturnPressed()
{
void MainWindow::onReturnPressed() {
if (sender() == m_ui->pathEdit)
setPath(m_ui->pathEdit->text());
}
void MainWindow::onIndexDownloaded(const QStringList& index)
{
void MainWindow::onIndexDownloaded(const QStringList& index) {
int bestVersion = 0;
m_ui->binaryComboBox->clear();
for (const QString& str : index)
{
for (const QString& str : index) {
URDEVersion version(str);
if (m_ui->sysReqTable->willRun(version))
bestVersion = m_ui->binaryComboBox->count();
@@ -243,15 +221,13 @@ void MainWindow::onIndexDownloaded(const QStringList& index)
m_ui->recommendedBinaryLabel->setText(m_recommendedVersion.fileString(false));
m_ui->binaryComboBox->setEnabled(true);
if (!m_path.isEmpty())
{
if (!m_path.isEmpty()) {
checkDownloadedBinary();
m_ui->downloadButton->setEnabled(true);
}
}
void MainWindow::onDownloadPressed()
{
void MainWindow::onDownloadPressed() {
m_updateURDEButton->hide();
QString filename = m_ui->binaryComboBox->currentData().value<URDEVersion>().fileString(true);
disableOperations();
@@ -259,14 +235,12 @@ void MainWindow::onDownloadPressed()
m_dlManager.fetchBinary(filename, m_path + '/' + filename);
}
void MainWindow::onUpdateURDEPressed()
{
void MainWindow::onUpdateURDEPressed() {
m_ui->heclTabs->setCurrentIndex(1);
onDownloadPressed();
}
void MainWindow::onBinaryDownloaded(QuaZip& file)
{
void MainWindow::onBinaryDownloaded(QuaZip& file) {
bool err = !ExtractZip::extractDir(file, m_path);
if (err)
@@ -284,14 +258,12 @@ void MainWindow::onBinaryDownloaded(QuaZip& file)
QStringLiteral("Blender 2.78+ must be installed. Please download via Steam or blender.org."));
}
void MainWindow::onBinaryFailed()
{
void MainWindow::onBinaryFailed() {
m_ui->downloadButton->setEnabled(true);
checkDownloadedBinary();
}
void MainWindow::disableOperations()
{
void MainWindow::disableOperations() {
m_ui->extractBtn->setEnabled(false);
m_ui->packageBtn->setEnabled(false);
m_ui->launchBtn->setEnabled(false);
@@ -300,8 +272,7 @@ void MainWindow::disableOperations()
m_ui->downloadButton->setEnabled(false);
}
void MainWindow::enableOperations()
{
void MainWindow::enableOperations() {
disableOperations();
m_ui->pathEdit->setEnabled(true);
m_ui->browseBtn->setEnabled(true);
@@ -319,8 +290,7 @@ void MainWindow::enableOperations()
m_ui->launchBtn->setText(QStringLiteral("Launch"));
m_ui->extractBtn->setEnabled(true);
if (QFile::exists(m_path + "/MP1/!original_ids.yaml"))
{
if (QFile::exists(m_path + "/MP1/!original_ids.yaml")) {
m_ui->packageBtn->setEnabled(true);
if (isPackageComplete())
m_ui->launchBtn->setEnabled(true);
@@ -336,38 +306,26 @@ void MainWindow::enableOperations()
insertContinueNote("Press 'Extract' to begin.");
}
bool MainWindow::isPackageComplete() const
{
bool MainWindow::isPackageComplete() const {
return
#if RUNTIME_ORIGINAL_IDS
QFile::exists(m_path + "/out/files/!original_ids.upak") &&
#endif
QFile::exists(m_path + "/out/files/AudioGrp.upak") &&
QFile::exists(m_path + "/out/files/GGuiSys.upak") &&
QFile::exists(m_path + "/out/files/Metroid1.upak") &&
QFile::exists(m_path + "/out/files/Metroid2.upak") &&
QFile::exists(m_path + "/out/files/Metroid3.upak") &&
QFile::exists(m_path + "/out/files/Metroid4.upak") &&
QFile::exists(m_path + "/out/files/metroid5.upak") &&
QFile::exists(m_path + "/out/files/Metroid6.upak") &&
QFile::exists(m_path + "/out/files/Metroid7.upak") &&
QFile::exists(m_path + "/out/files/Metroid8.upak") &&
QFile::exists(m_path + "/out/files/MidiData.upak") &&
QFile::exists(m_path + "/out/files/MiscData.upak") &&
QFile::exists(m_path + "/out/files/NoARAM.upak") &&
QFile::exists(m_path + "/out/files/SamGunFx.upak") &&
QFile::exists(m_path + "/out/files/SamusGun.upak") &&
QFile::exists(m_path + "/out/files/SlideShow.upak") &&
QFile::exists(m_path + "/out/files/TestAnim.upak") &&
QFile::exists(m_path + "/out/files/Tweaks.upak");
QFile::exists(m_path + "/out/files/AudioGrp.upak") && QFile::exists(m_path + "/out/files/GGuiSys.upak") &&
QFile::exists(m_path + "/out/files/Metroid1.upak") && QFile::exists(m_path + "/out/files/Metroid2.upak") &&
QFile::exists(m_path + "/out/files/Metroid3.upak") && QFile::exists(m_path + "/out/files/Metroid4.upak") &&
QFile::exists(m_path + "/out/files/metroid5.upak") && QFile::exists(m_path + "/out/files/Metroid6.upak") &&
QFile::exists(m_path + "/out/files/Metroid7.upak") && QFile::exists(m_path + "/out/files/Metroid8.upak") &&
QFile::exists(m_path + "/out/files/MidiData.upak") && QFile::exists(m_path + "/out/files/MiscData.upak") &&
QFile::exists(m_path + "/out/files/NoARAM.upak") && QFile::exists(m_path + "/out/files/SamGunFx.upak") &&
QFile::exists(m_path + "/out/files/SamusGun.upak") && QFile::exists(m_path + "/out/files/SlideShow.upak") &&
QFile::exists(m_path + "/out/files/TestAnim.upak") && QFile::exists(m_path + "/out/files/Tweaks.upak");
}
static bool GetDLPackage(const QString& path, QString& dlPackage)
{
static bool GetDLPackage(const QString& path, QString& dlPackage) {
QProcess proc;
proc.start(path, {"--dlpackage"}, QIODevice::ReadOnly);
if (proc.waitForStarted())
{
if (proc.waitForStarted()) {
proc.waitForFinished();
if (proc.exitCode() == 100)
dlPackage = QString::fromUtf8(proc.readLine()).trimmed();
@@ -376,15 +334,13 @@ static bool GetDLPackage(const QString& path, QString& dlPackage)
return false;
}
bool MainWindow::checkDownloadedBinary()
{
bool MainWindow::checkDownloadedBinary() {
m_updateURDEButton->hide();
m_urdePath = QString();
m_heclPath = QString();
if (m_path.isEmpty())
{
if (m_path.isEmpty()) {
m_ui->heclTabs->setCurrentIndex(1);
m_ui->downloadErrorLabel->setText(QStringLiteral("Set working directory to continue."), true);
enableOperations();
@@ -409,24 +365,15 @@ bool MainWindow::checkDownloadedBinary()
visigenPath = QFileInfo(visigenPath).absoluteFilePath();
QString urdeDlPackage, heclDlPackage, visigenDlPackage;
if (GetDLPackage(urdePath, urdeDlPackage) &&
GetDLPackage(heclPath, heclDlPackage) &&
GetDLPackage(visigenPath, visigenDlPackage))
{
if (!urdeDlPackage.isEmpty() &&
urdeDlPackage == heclDlPackage &&
urdeDlPackage == visigenDlPackage)
{
if (GetDLPackage(urdePath, urdeDlPackage) && GetDLPackage(heclPath, heclDlPackage) &&
GetDLPackage(visigenPath, visigenDlPackage)) {
if (!urdeDlPackage.isEmpty() && urdeDlPackage == heclDlPackage && urdeDlPackage == visigenDlPackage) {
URDEVersion v(urdeDlPackage);
m_ui->currentBinaryLabel->setText(v.fileString(false));
if (m_recommendedVersion.isValid() && v.isValid() &&
m_recommendedVersion.getVersion() > v.getVersion())
{
if (m_recommendedVersion.isValid() && v.isValid() && m_recommendedVersion.getVersion() > v.getVersion()) {
m_updateURDEButton->show();
}
}
else
{
} else {
m_ui->currentBinaryLabel->setText(QStringLiteral("unknown -- re-download recommended"));
}
@@ -435,9 +382,7 @@ bool MainWindow::checkDownloadedBinary()
m_ui->downloadErrorLabel->setText({}, true);
enableOperations();
return true;
}
else
{
} else {
m_ui->currentBinaryLabel->setText(QStringLiteral("none"));
m_ui->heclTabs->setCurrentIndex(1);
m_ui->downloadErrorLabel->setText(QStringLiteral("Press 'Download' to fetch latest URDE binary."), true);
@@ -447,14 +392,12 @@ bool MainWindow::checkDownloadedBinary()
return false;
}
void MainWindow::setPath(const QString& path)
{
void MainWindow::setPath(const QString& path) {
QFileInfo finfo(path);
QString usePath;
if (!path.isEmpty())
usePath = finfo.absoluteFilePath();
if (!usePath.isEmpty() && !finfo.exists())
{
if (!usePath.isEmpty() && !finfo.exists()) {
if (QMessageBox::question(this, QStringLiteral("Make Directory"),
QStringLiteral("%1 does not exist. Create it now?").arg(usePath)) == QMessageBox::Yes)
QDir().mkpath(usePath);
@@ -462,10 +405,8 @@ void MainWindow::setPath(const QString& path)
usePath = QString();
}
if (!usePath.isEmpty() && !finfo.isDir())
{
QMessageBox::warning(this, QStringLiteral("Directory Error"),
QStringLiteral("%1 is not a directory").arg(usePath),
if (!usePath.isEmpty() && !finfo.isDir()) {
QMessageBox::warning(this, QStringLiteral("Directory Error"), QStringLiteral("%1 is not a directory").arg(usePath),
QMessageBox::Ok, QMessageBox::NoButton);
usePath = QString();
}
@@ -473,14 +414,11 @@ void MainWindow::setPath(const QString& path)
m_path = usePath;
m_settings.setValue(QStringLiteral("working_dir"), m_path);
if (!m_path.isEmpty())
{
if (!m_path.isEmpty()) {
m_ui->pathEdit->setText(m_path);
m_ui->downloadButton->setToolTip(QString());
m_ui->downloadButton->setEnabled(m_ui->binaryComboBox->isEnabled());
}
else
{
} else {
m_ui->downloadButton->setToolTip(QStringLiteral("Working directory must be set"));
m_ui->downloadButton->setEnabled(false);
m_ui->currentBinaryLabel->setText(QStringLiteral("none"));
@@ -490,8 +428,7 @@ void MainWindow::setPath(const QString& path)
checkDownloadedBinary();
}
void MainWindow::initSlots()
{
void MainWindow::initSlots() {
connect(&m_heclProc, &QProcess::readyRead, [=]() {
QByteArray bytes = m_heclProc.readAll();
setTextTermFormatting(bytes);
@@ -519,8 +456,7 @@ void MainWindow::initSlots()
connect(m_ui->downloadButton, SIGNAL(clicked()), this, SLOT(onDownloadPressed()));
}
void MainWindow::setTextTermFormatting(const QString& text)
{
void MainWindow::setTextTermFormatting(const QString& text) {
m_inContinueNote = false;
QRegExp const escapeSequenceExpression(R"(\x1B\[([\d;\?FA]+)([mlh]?))");
@@ -531,8 +467,7 @@ void MainWindow::setTextTermFormatting(const QString& text)
while (offset >= 0) {
int previousOffset = offset + escapeSequenceExpression.matchedLength();
QStringList captures = escapeSequenceExpression.capturedTexts();
if (captures.size() >= 3 && captures[2] == "m")
{
if (captures.size() >= 3 && captures[2] == "m") {
QStringList capturedTexts = captures[1].split(';');
QListIterator<QString> i(capturedTexts);
while (i.hasNext()) {
@@ -541,14 +476,11 @@ void MainWindow::setTextTermFormatting(const QString& text)
Q_ASSERT(ok);
ParseEscapeSequence(attribute, i, textCharFormat, defaultTextCharFormat);
}
}
else if (captures.size() >= 2 && (captures[1].endsWith('F') || captures[1].endsWith('A')))
{
} else if (captures.size() >= 2 && (captures[1].endsWith('F') || captures[1].endsWith('A'))) {
int lineCount = captures[1].chopped(1).toInt();
if (!lineCount)
lineCount = 1;
for (int i=0 ; i<lineCount ; ++i)
{
for (int i = 0; i < lineCount; ++i) {
m_cursor.movePosition(QTextCursor::PreviousBlock);
m_cursor.select(QTextCursor::BlockUnderCursor);
m_cursor.removeSelectedText();
@@ -566,8 +498,7 @@ void MainWindow::setTextTermFormatting(const QString& text)
m_ui->processOutput->ensureCursorVisible();
}
void MainWindow::insertContinueNote(const QString& text)
{
void MainWindow::insertContinueNote(const QString& text) {
if (m_inContinueNote)
return;
m_inContinueNote = true;

View File

@@ -18,8 +18,7 @@ namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
class MainWindow : public QMainWindow {
Q_OBJECT
hecl::Runtime::FileStoreManager m_fileMgr;
hecl::CVarManager m_cvarManager;
@@ -36,6 +35,7 @@ class MainWindow : public QMainWindow
URDEVersion m_recommendedVersion;
QPushButton* m_updateURDEButton;
bool m_inContinueNote = false;
public:
explicit MainWindow(QWidget* parent = 0);
~MainWindow();
@@ -52,6 +52,7 @@ private slots:
void onReturnPressed();
void onDownloadPressed();
void onUpdateURDEPressed();
private:
bool checkDownloadedBinary();
void setPath(const QString& path);
@@ -63,4 +64,3 @@ private:
void enableOperations();
bool isPackageComplete() const;
};

View File

@@ -21,8 +21,7 @@
#if __APPLE__
#include "MacOSSystemVersion.hpp"
#elif _WIN32
static QString GetWindowsVersionString()
{
static QString GetWindowsVersionString() {
if (IsWindows10OrGreater())
return QStringLiteral("Windows 10");
else if (IsWindows8Point1OrGreater())
@@ -42,13 +41,10 @@ static QString GetWindowsVersionString()
}
#endif
SysReqTableModel::SysReqTableModel(QObject* parent)
: QAbstractTableModel(parent)
{
SysReqTableModel::SysReqTableModel(QObject* parent) : QAbstractTableModel(parent) {
#ifdef __linux__
QFile file("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq");
if (file.open(QFile::ReadOnly))
{
if (file.open(QFile::ReadOnly)) {
QString str(file.readAll());
m_cpuSpeed = str.toInt() / 1000;
m_cpuSpeedStr.sprintf("%g GHz", m_cpuSpeed / 1000.0);
@@ -63,13 +59,11 @@ SysReqTableModel::SysReqTableModel(QObject* parent)
QDomElement n = spDocElem.firstChildElement("array").firstChildElement("dict").firstChildElement("key");
while (!n.isNull() && n.text() != "_items")
n = n.nextSiblingElement("key");
if (!n.isNull())
{
if (!n.isNull()) {
n = n.nextSiblingElement("array").firstChildElement("dict").firstChildElement("key");
while (!n.isNull() && n.text() != "current_processor_speed")
n = n.nextSiblingElement("key");
if (!n.isNull())
{
if (!n.isNull()) {
n = n.nextSiblingElement("string");
double speed = n.text().split(' ').front().toDouble();
m_cpuSpeed = uint64_t(speed * 1000.0);
@@ -78,15 +72,11 @@ SysReqTableModel::SysReqTableModel(QObject* parent)
}
#elif _WIN32
HKEY hkey;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
_SYS_STR("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"),
0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
{
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _SYS_STR("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0,
KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) {
DWORD MHz;
DWORD size = sizeof(MHz);
if (RegQueryValueEx(hkey, _SYS_STR("~MHz"), nullptr, nullptr,
(LPBYTE)&MHz, &size) == ERROR_SUCCESS)
{
if (RegQueryValueEx(hkey, _SYS_STR("~MHz"), nullptr, nullptr, (LPBYTE)&MHz, &size) == ERROR_SUCCESS) {
m_cpuSpeed = uint64_t(MHz);
m_cpuSpeedStr.sprintf("%1.1f GHz", MHz / 1000.f);
}
@@ -96,8 +86,7 @@ SysReqTableModel::SysReqTableModel(QObject* parent)
/* This only works for Skylake+ */
int regs[4] = {};
zeus::getCpuInfo(0, regs);
if (regs[0] >= 0x16)
{
if (regs[0] >= 0x16) {
zeus::getCpuInfo(0x16, regs);
m_cpuSpeed = uint64_t(regs[0]);
}
@@ -125,48 +114,34 @@ SysReqTableModel::SysReqTableModel(QObject* parent)
#endif
hecl::blender::FindBlender(m_blendMajor, m_blendMinor);
if (m_blendMajor)
m_blendVersionStr = QStringLiteral("Blender ") + QString::number(m_blendMajor) +
'.' + QString::number(m_blendMinor);
m_blendVersionStr =
QStringLiteral("Blender ") + QString::number(m_blendMajor) + '.' + QString::number(m_blendMinor);
else
m_blendVersionStr = QStringLiteral("Not Found");
}
void SysReqTableModel::updateFreeDiskSpace(const QString& path)
{
if (path.isEmpty())
{
void SysReqTableModel::updateFreeDiskSpace(const QString& path) {
if (path.isEmpty()) {
m_freeDiskSpace = 0;
m_freeDiskSpaceStr = QStringLiteral("<Set Working Directory>");
}
else
{
} else {
m_freeDiskSpace = QStorageInfo(path).bytesFree();
m_freeDiskSpaceStr.sprintf("%1.1f GB", m_freeDiskSpace / 1000.f / 1000.f / 1000.f);
}
emit dataChanged(index(3, 0), index(3, 0));
}
int SysReqTableModel::rowCount(const QModelIndex& parent) const
{
return 7;
}
int SysReqTableModel::rowCount(const QModelIndex& parent) const { return 7; }
int SysReqTableModel::columnCount(const QModelIndex& parent) const
{
return 2;
}
int SysReqTableModel::columnCount(const QModelIndex& parent) const { return 2; }
QVariant SysReqTableModel::data(const QModelIndex& index, int role) const
{
if (role != Qt::DisplayRole && role != Qt::UserRole)
{
QVariant SysReqTableModel::data(const QModelIndex& index, int role) const {
if (role != Qt::DisplayRole && role != Qt::UserRole) {
return {};
}
if (role == Qt::UserRole)
{
switch (index.row())
{
if (role == Qt::UserRole) {
switch (index.row()) {
case 0:
return true;
case 1:
@@ -186,14 +161,10 @@ QVariant SysReqTableModel::data(const QModelIndex& index, int role) const
case 5:
return isBlenderVersionOk();
}
}
else
{
if (index.column() == 0)
{
} else {
if (index.column() == 0) {
/* Recommended */
switch (index.row())
{
switch (index.row()) {
case 0:
#if ZEUS_ARCH_X86 || ZEUS_ARCH_X86_64
return QStringLiteral("x86_64");
@@ -219,12 +190,9 @@ QVariant SysReqTableModel::data(const QModelIndex& index, int role) const
case 5:
return QStringLiteral("Blender 2.78");
}
}
else if (index.column() == 1)
{
} else if (index.column() == 1) {
/* Your System */
switch (index.row())
{
switch (index.row()) {
case 0:
#if ZEUS_ARCH_X86 || ZEUS_ARCH_X86_64
return CurArchitectureString;
@@ -247,28 +215,21 @@ QVariant SysReqTableModel::data(const QModelIndex& index, int role) const
return {};
}
QVariant SysReqTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole)
{
QVariant SysReqTableModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (role != Qt::DisplayRole) {
return {};
}
if (orientation == Qt::Horizontal)
{
switch (section)
{
if (orientation == Qt::Horizontal) {
switch (section) {
case 0:
default:
return QStringLiteral("Recommended");
case 1:
return QStringLiteral("Your System");
}
}
else
{
switch (section)
{
} else {
switch (section) {
case 0:
default:
return QStringLiteral("Architecture");
@@ -288,13 +249,11 @@ QVariant SysReqTableModel::headerData(int section, Qt::Orientation orientation,
}
}
void SysReqTableView::paintEvent(QPaintEvent* e)
{
void SysReqTableView::paintEvent(QPaintEvent* e) {
int tableWidth = columnWidth(0) + columnWidth(1);
int tableX = verticalHeader()->width() + columnViewportPosition(0);
int tableY = horizontalHeader()->height();
for (int i = 0; i < 6; ++i)
{
for (int i = 0; i < 6; ++i) {
QWidget* w = std::get<0>(m_backgroundWidgets[i]);
QPalette pal = palette();
@@ -307,8 +266,7 @@ void SysReqTableView::paintEvent(QPaintEvent* e)
QSequentialAnimationGroup* animation = std::get<1>(m_backgroundWidgets[i]);
QPropertyAnimation* pAnimation = static_cast<QPropertyAnimation*>(animation->animationAt(1));
bool& running = std::get<2>(m_backgroundWidgets[i]);
if (!running)
{
if (!running) {
w->setGeometry(QRect(tableX, tableY + rowViewportPosition(i), 0, rowHeight(i)));
pAnimation->setStartValue(QRect(tableX, tableY + rowViewportPosition(i), 0, rowHeight(i)));
pAnimation->setEndValue(QRect(tableX, tableY + rowViewportPosition(i), tableWidth, rowHeight(i)));
@@ -323,9 +281,7 @@ void SysReqTableView::paintEvent(QPaintEvent* e)
QTableView::paintEvent(e);
}
SysReqTableView::SysReqTableView(QWidget* parent)
: QTableView(parent), m_vectorISATable(this)
{
SysReqTableView::SysReqTableView(QWidget* parent) : QTableView(parent), m_vectorISATable(this) {
setModel(&m_model);
setIndexWidget(m_model.index(6, 0), &m_vectorISATable);
setSpan(6, 0, 1, 2);
@@ -335,8 +291,7 @@ SysReqTableView::SysReqTableView(QWidget* parent)
setSelectionMode(QAbstractItemView::SelectionMode::NoSelection);
setFocusPolicy(Qt::NoFocus);
for (int i = 0; i < 6; ++i)
{
for (int i = 0; i < 6; ++i) {
QWidget* w = new QWidget(this);
std::get<0>(m_backgroundWidgets[i]) = w;

View File

@@ -5,8 +5,7 @@
class QSequentialAnimationGroup;
class SysReqTableModel : public QAbstractTableModel
{
class SysReqTableModel : public QAbstractTableModel {
Q_OBJECT
uint64_t m_cpuSpeed = 0;
QString m_cpuSpeedStr;
@@ -25,34 +24,32 @@ class SysReqTableModel : public QAbstractTableModel
int m_blendMajor = 0;
int m_blendMinor = 0;
QString m_blendVersionStr;
public:
SysReqTableModel(QObject* parent = Q_NULLPTR);
int rowCount(const QModelIndex& parent = QModelIndex()) const;
int columnCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
bool isBlenderVersionOk() const
{ return m_blendMajor > 2 || (m_blendMajor == 2 && m_blendMinor >= 78); }
bool isBlenderVersionOk() const { return m_blendMajor > 2 || (m_blendMajor == 2 && m_blendMinor >= 78); }
void updateFreeDiskSpace(const QString& path);
};
class SysReqTableView : public QTableView
{
class SysReqTableView : public QTableView {
Q_OBJECT
SysReqTableModel m_model;
VectorISATableView m_vectorISATable;
std::tuple<QWidget*, QSequentialAnimationGroup*, bool> m_backgroundWidgets[6] = {};
public:
SysReqTableView(QWidget* parent = Q_NULLPTR);
void paintEvent(QPaintEvent* e) Q_DECL_OVERRIDE;
const SysReqTableModel& getModel() const { return m_model; }
const VectorISATableView& getVectorISATable() const { return m_vectorISATable; }
bool willRun(const URDEVersion& v) const
{
bool willRun(const URDEVersion& v) const {
return v.getArchitecture() == CurArchitecture && v.getPlatform() == CurPlatform &&
m_vectorISATable.willRun(v.getVectorISA());
}
bool isBlenderVersionOk() const { return m_model.isBlenderVersionOk(); }
void updateFreeDiskSpace(const QString& path) { m_model.updateFreeDiskSpace(path); }
};

View File

@@ -3,13 +3,12 @@
#include <QTableView>
#include "zeus/Math.hpp"
class VectorISATableModel : public QAbstractTableModel
{
class VectorISATableModel : public QAbstractTableModel {
Q_OBJECT
protected:
const zeus::CPUInfo& m_features = zeus::cpuFeatures();
public:
VectorISATableModel(QObject* parent = Q_NULLPTR) : QAbstractTableModel(parent) {}
int rowCount(const QModelIndex& parent = QModelIndex()) const { return 1; }
};

View File

@@ -2,23 +2,19 @@
#include "VectorISATableModel.hpp"
class VectorISATableModelIntel : public VectorISATableModel
{
class VectorISATableModelIntel : public VectorISATableModel {
Q_OBJECT
public:
VectorISATableModelIntel(QObject* parent = Q_NULLPTR) : VectorISATableModel(parent) {}
int columnCount(const QModelIndex& parent = QModelIndex()) const { return 7; }
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
{
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const {
if (role != Qt::DisplayRole && role != Qt::UserRole)
return {};
if (role == Qt::UserRole)
{
switch (index.column())
{
if (role == Qt::UserRole) {
switch (index.column()) {
case 0:
default:
return true;
@@ -35,11 +31,8 @@ public:
case 6:
return m_features.AVX2;
}
}
else
{
switch (index.column())
{
} else {
switch (index.column()) {
case 0:
default:
return QStringLiteral("x87");
@@ -59,10 +52,8 @@ public:
}
}
VectorISA getISA(int idx) const
{
switch (idx)
{
VectorISA getISA(int idx) const {
switch (idx) {
default:
return VectorISA::Invalid;
case 0:
@@ -82,10 +73,8 @@ public:
}
}
bool willRun(VectorISA visa) const
{
switch (visa)
{
bool willRun(VectorISA visa) const {
switch (visa) {
default:
return false;
case VectorISA::X87:
@@ -105,4 +94,3 @@ public:
}
}
};

View File

@@ -3,23 +3,18 @@
#include <QPropertyAnimation>
#include <QSequentialAnimationGroup>
void VectorISATableView::paintEvent(QPaintEvent* e)
{
void VectorISATableView::paintEvent(QPaintEvent* e) {
QTableView* p = static_cast<QTableView*>(parent()->parent());
int tableY = p->horizontalHeader()->height() + p->rowViewportPosition(6);
int rHeight = rowHeight(0);
for (int i = 0; i < 2; ++i)
{
for (int i = 0; i < 2; ++i) {
int tableX;
int width = 0;
if (i == 0)
{
if (i == 0) {
tableX = p->verticalHeader()->width() + columnViewportPosition(0);
for (int j = 0; j <= m_maxISA; ++j)
width += columnWidth(j);
}
else
{
} else {
tableX = p->verticalHeader()->width() + columnViewportPosition(m_maxISA + 1);
for (int j = m_maxISA + 1; j < m_model.columnCount({}); ++j)
width += columnWidth(j);
@@ -29,8 +24,7 @@ void VectorISATableView::paintEvent(QPaintEvent* e)
QSequentialAnimationGroup* animation = std::get<1>(m_backgroundWidgets[i]);
QPropertyAnimation* pAnimation = static_cast<QPropertyAnimation*>(animation->animationAt(1));
bool& running = std::get<2>(m_backgroundWidgets[i]);
if (!running)
{
if (!running) {
w->setGeometry(QRect(tableX, tableY, 0, rHeight));
pAnimation->setStartValue(QRect(tableX, tableY, 0, rHeight));
pAnimation->setEndValue(QRect(tableX, tableY, width, rHeight));
@@ -45,13 +39,10 @@ void VectorISATableView::paintEvent(QPaintEvent* e)
QTableView::paintEvent(e);
}
VectorISATableView::VectorISATableView(QWidget* parent)
: QTableView(parent)
{
VectorISATableView::VectorISATableView(QWidget* parent) : QTableView(parent) {
setModel(&m_model);
for (int i = 0; i < m_model.columnCount({}); ++i)
{
for (int i = 0; i < m_model.columnCount({}); ++i) {
if (m_model.data(m_model.index(0, i), Qt::UserRole).toBool())
m_maxISA = i;
else
@@ -67,8 +58,7 @@ VectorISATableView::VectorISATableView(QWidget* parent)
setSelectionMode(QAbstractItemView::SelectionMode::NoSelection);
setFocusPolicy(Qt::NoFocus);
for (int i = 0; i < 2; ++i)
{
for (int i = 0; i < 2; ++i) {
QWidget* w = new QWidget(parent);
std::get<0>(m_backgroundWidgets[i]) = w;

View File

@@ -9,18 +9,17 @@
class QSequentialAnimationGroup;
class VectorISATableView : public QTableView
{
class VectorISATableView : public QTableView {
Q_OBJECT
#if ZEUS_ARCH_X86_64 || ZEUS_ARCH_X86
VectorISATableModelIntel m_model;
#endif
std::tuple<QWidget*, QSequentialAnimationGroup*, bool> m_backgroundWidgets[2] = {};
int m_maxISA = 0;
public:
VectorISATableView(QWidget* parent = Q_NULLPTR);
void paintEvent(QPaintEvent* e) Q_DECL_OVERRIDE;
VectorISA getISA() const { return m_model.getISA(m_maxISA); }
bool willRun(VectorISA visa) const { return m_model.willRun(visa); }
};

View File

@@ -5,13 +5,11 @@
extern "C" const uint8_t MAINICON_QT[];
static QIcon MakeAppIcon()
{
static QIcon MakeAppIcon() {
QIcon ret;
const uint8_t* ptr = MAINICON_QT;
for (int i = 0; i < 6; ++i)
{
for (int i = 0; i < 6; ++i) {
uint32_t size = *reinterpret_cast<const uint32_t*>(ptr);
ptr += 4;
@@ -24,8 +22,7 @@ static QIcon MakeAppIcon()
return ret;
}
int main(int argc, char* argv[])
{
int main(int argc, char* argv[]) {
InitializePlatform();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))