OpenBLCMM
OpenBLCMM copied to clipboard
Add option to automatically make hotfix when warning about using hotfix syntax
When using hotfix syntax and trying to save a command as a regular command you get this warning about it being wrong, maybe add a option in this dialog to automatically make it into a hotfix as just an any level hotfix since that is the default for them, I just forget to check the hotfix checkbox a lot so would be a nice shortcut to be able to click a button to automatically make it so
Ah yeah, makes sense; will have to play around a bit to see what kind of UI makes sense... Probably the most sensible default would be a Level "matchall" (in BL3 parlance). Would hopefully be able to figure out a combination of buttons which provides the following options without being confusing:
- Cancel and set hotfix parameters directly
- Continue and default to Level-Matchall
- Continue leaving it invalid
Option 3 wouldn't ordinarily be a great idea, of course, but we allow users to do it already, and we've run into trouble with trying to force users into mod behavior in the past, so leaving it as an option seems sensible
Mmm, I may end up putting this on the backburner, actually. The hotfix check here is just one of a bunch of checkers which get run against the code, and the dialog that gets shown here is technically an aggregate of all those. If more than one checker gets triggered, you'd end up having a weird sort of compound dialog.
Not difficult to get around, really -- the checkers would just have to have the ability to provide custom resolution actions which could then be picked up by the checker-handler code, I suppose, and if more than one triggered checks offer resolution actions, maybe fall back to the previous behavior or something, but it's got the potential to be somewhat messy and I don't think I've got the energy to do that much refactoring on it at the moment.
Anyway, will leave this open, of course -- I like the idea and think it'd be useful to have in there.
For reference, the PropertyChecker objects get set up in blcmm.model.properties.GlobalListOfProperties, and looped-through inside blcmm.gui.panels.EditPanel.isInputCodeValid(). The current check is merely this:
public static class HotfixSyntaxInNormalCommandChecker extends SyntaxPropertyChecker {
public HotfixSyntaxInNormalCommandChecker() {
super(true, false);
}
@Override
public boolean checkProperty(ModelElement element) {
if (!(element instanceof SetCommand) || element instanceof HotfixCommand) {
return false;
}
SetCommand command = (SetCommand) element;
return command.getField().contains("[") || command.getField().contains("]") || command.getField().contains(".") || command.getValue().startsWith("+(");
}
@Override
public String getPropertyDescription() {
return "This normal set command uses hotfix syntax";
}
}