[color] Patch unavailabel global/special function if not available

Resolves #295
This commit is contained in:
Raphael Coeffic
2021-06-23 12:49:42 +02:00
parent 6126241f0b
commit 68cb9c2d92
+14 -1
View File
@@ -384,10 +384,23 @@ class SpecialFunctionEditPage : public Page
}); });
grid.nextLine(); grid.nextLine();
// Patch function in case not available
if (!isAssignableFunctionAvailable(CFN_FUNC(cfn), functions)) {
auto func = 0;
while(!isAssignableFunctionAvailable(func, functions)
&& (func < FUNC_MAX - 1)) {
func++;
}
if (func < FUNC_MAX - 1) {
CFN_FUNC(cfn) = func;
}
}
// Function // Function
new StaticText(window, grid.getLabelSlot(), STR_FUNC); new StaticText(window, grid.getLabelSlot(), STR_FUNC);
auto functionChoice = auto functionChoice =
new Choice(window, grid.getFieldSlot(), STR_VFSWFUNC, 0, FUNC_MAX - 1, new Choice(window, grid.getFieldSlot(), STR_VFSWFUNC,
0, FUNC_MAX - 1,
GET_DEFAULT(CFN_FUNC(cfn))); GET_DEFAULT(CFN_FUNC(cfn)));
functionChoice->setSetValueHandler([=](int32_t newValue) { functionChoice->setSetValueHandler([=](int32_t newValue) {
CFN_FUNC(cfn) = newValue; CFN_FUNC(cfn) = newValue;