Skip to content

Commit

Permalink
Merge pull request #9 from psiberx/main
Browse files Browse the repository at this point in the history
Implement display values for list selector
  • Loading branch information
jackhumbert authored Jan 2, 2023
2 parents ae445b8 + 2c95644 commit c5a4755
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/red4ext/ModRuntimeSettingsVar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,19 @@ struct ModRuntimeSettingsVarEnum : public ModRuntimeSettingsVar {

auto e = RED4ext::CRTTISystem::Get()->GetEnumByScriptName(prop->type->name);
if (e) {
const auto displayValuesPrefix = RED4ext::FNV1a64("ModSettings.displayValues.");

for (const auto &value : e->hashList) {
displayValues.EmplaceBack(value);
const auto displayValueAttr = RED4ext::FNV1a64(value.ToString(), displayValuesPrefix);
const auto displayValue = prop->runtimeProperties.Get(displayValueAttr);
if (displayValue) {
RED4ext::CNamePool::Add(displayValue->c_str());
displayValues.EmplaceBack(displayValue->c_str());
} else {
displayValues.EmplaceBack(value);
}
}

for (const auto &value : e->valueList) {
values.EmplaceBack((int32_t)value);
}
Expand Down
6 changes: 5 additions & 1 deletion src/redscript/mod_settings/_SettingsSelectorControllers.reds
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,11 @@ public class ModStngsSelectorControllerListInt extends SettingsSelectorControlle
if !value.ListHasDisplayValues() {
inkTextRef.SetText(this.m_ValueText, IntToString(value.GetValue()));
} else {
inkTextRef.SetText(this.m_ValueText, ToString(value.GetDisplayValue(index)));
let text = GetLocalizedTextByKey(value.GetDisplayValue(index));
if StrLen(text) == 0 {
text = ToString(value.GetDisplayValue(index));
};
inkTextRef.SetText(this.m_ValueText, text);
};
this.SelectDot(index);
}
Expand Down

0 comments on commit c5a4755

Please sign in to comment.