Situation
My mod have couple of slider entries synced via CSync. They represent probabilities of something happening mid-round, so they should only be writable while not on a moon (i.e. in main menu or orbiting). So I wrote this callback:
public static CanModifyResult CanModifyWeightsNow()
{
var startOfRound = StartOfRound.Instance;
if (!startOfRound)
{
return CanModifyResult.True(); // Main menu
}
if (!startOfRound.IsHost)
{
return CanModifyResult.False("Only for host");
}
if (!startOfRound.inShipPhase)
{
return CanModifyResult.False("Only in orbit");
}
return CanModifyResult.True();
}
and assigned it to the sliders:
var slider = new IntSliderConfigItem(MyEntry, new IntSliderOptions
{
RequiresRestart = false,
CanModifyCallback = CanModifyCallback,
});
When I open the config window, I see my debug logs that the callback got called for every slider immediately, but not when modifying and applying the change.
Problem
- Pull the lever
- Immediately press Escape to open the menu
- Click LethalConfig, then choose my mod on the left
- Wait for the round to actually start / ship to land.
- Click on a slider to change it
- Click [Apply]
Now the entries are not supposed to be mutable anymore, but we just modified one!
Expected result
Upon trying to change the entries, or at least before actually Applying changes, LethalConfig should check the provided callback once again.
Actual result
After step 5 that slider's callback is invoked, and the slider is locked from further modifications, but the damage has been done — the new value will be written (and synchronized) on Apply. You can actually modify each individual slider once before applying.
Combined with missing reason string in the tooltip #59 these issues kinda make callbacks less useful than I'd wish them to be.
Situation
My mod have couple of slider entries synced via CSync. They represent probabilities of something happening mid-round, so they should only be writable while not on a moon (i.e. in main menu or orbiting). So I wrote this callback:
and assigned it to the sliders:
When I open the config window, I see my debug logs that the callback got called for every slider immediately, but not when modifying and applying the change.
Problem
Now the entries are not supposed to be mutable anymore, but we just modified one!
Expected result
Upon trying to change the entries, or at least before actually Applying changes, LethalConfig should check the provided callback once again.
Actual result
After step 5 that slider's callback is invoked, and the slider is locked from further modifications, but the damage has been done — the new value will be written (and synchronized) on Apply. You can actually modify each individual slider once before applying.
Combined with missing reason string in the tooltip #59 these issues kinda make callbacks less useful than I'd wish them to be.