diff --git a/loader/src/loader/SettingNodeV3.cpp b/loader/src/loader/SettingNodeV3.cpp index 10ecfc15..74e5da14 100644 --- a/loader/src/loader/SettingNodeV3.cpp +++ b/loader/src/loader/SettingNodeV3.cpp @@ -453,13 +453,28 @@ bool FileSettingNodeV3::init(std::shared_ptr setting, float width } void FileSettingNodeV3::updateState(CCNode* invoker) { + // This is because people tend to put `"default": "Please pick a good file"` + // which is clever and good UX but also a hack so I also need to hack to support that + const auto isTextualDefaultValue = [this, setting = this->getSetting()]() { + if (this->hasNonDefaultValue()) return false; + std::error_code ec; + return setting->isFolder() ? + !std::filesystem::is_directory(setting->getDefaultValue(), ec) : + !std::filesystem::is_regular_file(setting->getDefaultValue(), ec); + }(); + SettingValueNodeV3::updateState(invoker); m_fileIcon->setDisplayFrame(CCSpriteFrameCache::get()->spriteFrameByName( this->getSetting()->isFolder() ? "folderIcon_001.png" : "file.png"_spr )); limitNodeSize(m_fileIcon, ccp(10, 10), 1.f, .1f); - if (this->getValue().empty()) { - m_nameLabel->setString(this->getSetting()->isFolder() ? "No Folder Selected" : "No File Selected"); + if (this->getValue().empty() || isTextualDefaultValue) { + if (isTextualDefaultValue) { + m_nameLabel->setString(this->getSetting()->getDefaultValue().string().c_str()); + } + else { + m_nameLabel->setString(this->getSetting()->isFolder() ? "No Folder Selected" : "No File Selected"); + } m_nameLabel->setColor(ccGRAY); m_nameLabel->setOpacity(155); } diff --git a/loader/src/loader/SettingV3.cpp b/loader/src/loader/SettingV3.cpp index 4c8398f1..ab6da9a3 100644 --- a/loader/src/loader/SettingV3.cpp +++ b/loader/src/loader/SettingV3.cpp @@ -1106,6 +1106,11 @@ Result> FileSettingV3::parse(std::string const& k } Result<> FileSettingV3::isValid(std::filesystem::path const& value) const { + // This is because people tend to put `"default": "Please pick a good file"` + // which is clever and good UX but also a hack so I also need to hack to support that + if (value == this->getDefaultValue()) { + return Ok(); + } std::error_code ec; if (m_impl->folder) { if (!std::filesystem::is_directory(value, ec)) {