Add ability to search for blender version dynamically

This commit is contained in:
Phillip Stephens 2021-02-21 18:52:17 -08:00
parent e0da690d7c
commit daef7dfe00
5 changed files with 129 additions and 99 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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."));
}
}

View File

@ -21,7 +21,7 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
@ -76,7 +76,95 @@
</item>
</layout>
</item>
<item row="1" column="0">
<item row="5" column="0" rowspan="3">
<layout class="QHBoxLayout" name="bottomButtonBox">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>167</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="extractBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Extract</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="packageBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Package</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="launchBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Launch</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="warpBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Launch &amp;&amp; &amp;Warp</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>166</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QTabWidget" name="heclTabs">
<property name="currentIndex">
<number>1</number>
@ -1120,7 +1208,7 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:6pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:600;&quot;&gt;About HECL Frontend&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt;&quot;&gt;&lt;br /&gt;The HECL frontend UI is designed and built by &lt;/span&gt;&lt;a href=&quot;https://axiodl.com&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt; text-decoration: underline; color:#007af4;&quot;&gt;Axiomatic Data Laboratories&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt;&quot;&gt; Copyright 2020&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:600;&quot;&gt;Authors:&lt;/span&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt;&quot;&gt;&lt;br /&gt;Phillip &amp;quot;Antidote&amp;quot; Stephens&lt;br /&gt;Jack &amp;quot;jackoalan&amp;quot; Andersen&lt;br /&gt;Luke &amp;quot;encounter&amp;quot; Street&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Courier New'; font-size:10pt;&quot;&gt;The MIT License&lt;/span&gt;&lt;/p&gt;
@ -1143,93 +1231,12 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
<item row="4" column="0" rowspan="3">
<layout class="QHBoxLayout" name="bottomButtonBox">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>167</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="extractBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Extract</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="packageBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Package</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="launchBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Launch</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="warpBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Launch &amp;&amp; &amp;Warp</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>166</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;center&gt;&lt;h1 style=&quot;color:red&quot;&gt;ALPHA VERSION&lt;/h1&gt;&lt;/center&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>

View File

@ -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);
};