From daef7dfe00053ae25f10afcbf994bf014f75de53 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 21 Feb 2021 18:52:17 -0800 Subject: [PATCH] Add ability to search for blender version dynamically --- hecl-gui/CMakeLists.txt | 2 +- hecl-gui/FindBlender.cpp | 27 +++-- hecl-gui/MainWindow.cpp | 2 +- hecl-gui/MainWindow.ui | 187 ++++++++++++++++++----------------- hecl-gui/SysReqTableView.hpp | 10 +- 5 files changed, 129 insertions(+), 99 deletions(-) diff --git a/hecl-gui/CMakeLists.txt b/hecl-gui/CMakeLists.txt index c493401c6..290e8dca9 100644 --- a/hecl-gui/CMakeLists.txt +++ b/hecl-gui/CMakeLists.txt @@ -26,7 +26,7 @@ set(BUILD_SHARED_LIBS OFF CACHE BOOL "") set(QUAZIP_INSTALL OFF CACHE BOOL "") add_subdirectory(quazip) -add_executable(hecl-gui WIN32 MACOSX_BUNDLE +add_executable(hecl-gui MACOSX_BUNDLE ArgumentEditor.cpp ArgumentEditor.hpp ArgumentEditor.ui diff --git a/hecl-gui/FindBlender.cpp b/hecl-gui/FindBlender.cpp index 222bb3ed9..d9d278792 100644 --- a/hecl-gui/FindBlender.cpp +++ b/hecl-gui/FindBlender.cpp @@ -12,6 +12,10 @@ namespace hecl::blender { #define DEFAULT_BLENDER_BIN "blender" #endif +static const uint32_t MinBlenderMajorSearch = 2; +static const uint32_t MaxBlenderMajorSearch = 2; +static const uint32_t MinBlenderMinorSearch = 90; +static const uint32_t MaxBlenderMinorSearch = 91; static const std::regex regBlenderVersion(R"(Blender (\d+)\.(\d+)(?:\.(\d+))?)", std::regex::ECMAScript | std::regex::optimize); @@ -51,14 +55,25 @@ hecl::SystemString FindBlender(int& major, int& minor) { /* No steam; try default */ wchar_t progFiles[256]; if (GetEnvironmentVariableW(L"ProgramFiles", progFiles, 256)) { - _snwprintf(BLENDER_BIN_BUF, 2048, L"%s\\Blender Foundation\\Blender 2.90\\blender.exe", progFiles); - blenderBin = BLENDER_BIN_BUF; - if (!RegFileExists(blenderBin)) - blenderBin = nullptr; - } else - blenderBin = nullptr; + for (size_t major = MinBlenderMajorSearch; major <= MaxBlenderMajorSearch; ++major) { + bool found = false; + for (size_t minor = MinBlenderMinorSearch; minor <= MaxBlenderMinorSearch; ++minor) { + _snwprintf(BLENDER_BIN_BUF, 2048, L"%s\\Blender Foundation\\Blender %i.%i\\blender.exe", progFiles, major, + minor); + if (RegFileExists(BLENDER_BIN_BUF)) { + blenderBin = BLENDER_BIN_BUF; + found = true; + break; + } + } + if (found) { + break; + } + } + } } } + #else if (!RegFileExists(blenderBin)) { /* Try steam */ diff --git a/hecl-gui/MainWindow.cpp b/hecl-gui/MainWindow.cpp index 44c0fcf4c..c67aee378 100644 --- a/hecl-gui/MainWindow.cpp +++ b/hecl-gui/MainWindow.cpp @@ -306,7 +306,7 @@ void MainWindow::onBinaryDownloaded(QuaZip& file) { m_ui->downloadErrorLabel->setText(tr("Download successful - Press 'Extract' to continue."), true); } if (!err && !m_ui->sysReqTable->isBlenderVersionOk()) { - m_ui->downloadErrorLabel->setText(tr("Blender 2.83 must be installed. Please download via Steam or blender.org.")); + m_ui->downloadErrorLabel->setText(tr("Blender 2.90 or greater must be installed. Please download via Steam or blender.org.")); } } diff --git a/hecl-gui/MainWindow.ui b/hecl-gui/MainWindow.ui index 6ca9f184d..3ec68d679 100644 --- a/hecl-gui/MainWindow.ui +++ b/hecl-gui/MainWindow.ui @@ -21,7 +21,7 @@ - + @@ -76,7 +76,95 @@ - + + + + + + Qt::Horizontal + + + + 167 + 20 + + + + + + + + false + + + + 16777215 + 16777215 + + + + &Extract + + + + + + + false + + + + 16777215 + 16777215 + + + + &Package + + + + + + + false + + + + 16777215 + 16777215 + + + + &Launch + + + + + + + false + + + Launch && &Warp + + + + + + + Qt::Horizontal + + + + 166 + 20 + + + + + + + 1 @@ -1120,7 +1208,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:6pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Noto Sans'; font-size:10pt; font-weight:600;">About HECL Frontend</span></p> <p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Noto Sans'; font-size:10pt;"><br />The HECL frontend UI is designed and built by </span><a href="https://axiodl.com"><span style=" font-family:'Noto Sans'; font-size:10pt; text-decoration: underline; color:#007af4;">Axiomatic Data Laboratories</span></a><span style=" font-family:'Noto Sans'; font-size:10pt;"> Copyright 2020<br /><br /></span><span style=" font-family:'Noto Sans'; font-size:10pt; font-weight:600;">Authors:</span><span style=" font-family:'Noto Sans'; font-size:10pt;"><br />Phillip &quot;Antidote&quot; Stephens<br />Jack &quot;jackoalan&quot; Andersen<br />Luke &quot;encounter&quot; Street</span></p> <p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:10pt;">The MIT License</span></p> @@ -1143,93 +1231,12 @@ p, li { white-space: pre-wrap; } - - - - - - Qt::Horizontal - - - - 167 - 20 - - - - - - - - false - - - - 16777215 - 16777215 - - - - &Extract - - - - - - - false - - - - 16777215 - 16777215 - - - - &Package - - - - - - - false - - - - 16777215 - 16777215 - - - - &Launch - - - - - - - false - - - Launch && &Warp - - - - - - - Qt::Horizontal - - - - 166 - 20 - - - - - + + + + <center><h1 style="color:red">ALPHA VERSION</h1></center> + + diff --git a/hecl-gui/SysReqTableView.hpp b/hecl-gui/SysReqTableView.hpp index 1d8e03d99..4ed85e0b5 100644 --- a/hecl-gui/SysReqTableView.hpp +++ b/hecl-gui/SysReqTableView.hpp @@ -5,6 +5,11 @@ class QSequentialAnimationGroup; +const uint32_t MinBlenderVersionMajor = 2; +const uint32_t MaxBlenderVersionMajor = 2; +const uint32_t MinBlenderVersionMinor = 90; +const uint32_t MaxBlenderVersionMinor = 91; + class SysReqTableModel : public QAbstractTableModel { Q_OBJECT uint64_t m_cpuSpeed = 0; @@ -31,7 +36,10 @@ public: int columnCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - bool isBlenderVersionOk() const { return m_blendMajor == 2 && m_blendMinor == 90; } + bool isBlenderVersionOk() const { + return (m_blendMajor >= MinBlenderVersionMajor && m_blendMajor <= MaxBlenderVersionMajor) && + (m_blendMinor >= MinBlenderVersionMinor && m_blendMinor <= MaxBlenderVersionMinor); + } void updateFreeDiskSpace(const QString& path); };