Address inability to clear overrides in editor, part 2. Fixes #1168

This commit is contained in:
PikaMug 2020-04-07 00:05:49 -04:00
parent aca13cde84
commit b91574efc3
2 changed files with 25 additions and 17 deletions

View File

@ -334,16 +334,20 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
// Check/add newly made override final String input = (String) context.getSessionData(classPrefix + "-override");
if (context.getSessionData(classPrefix + "-override") != null) { if (input != null && !input.equalsIgnoreCase(Lang.get("cancel"))) {
if (input.equalsIgnoreCase(Lang.get("clear"))) {
context.setSessionData(CK.REW_DETAILS_OVERRIDE, null);
} else {
LinkedList<String> overrides = new LinkedList<String>(); LinkedList<String> overrides = new LinkedList<String>();
if (context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null) { if (context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null) {
overrides.addAll((List<String>) context.getSessionData(CK.REW_DETAILS_OVERRIDE)); overrides.addAll((List<String>) context.getSessionData(CK.REW_DETAILS_OVERRIDE));
} }
overrides.add((String) context.getSessionData(classPrefix + "-override")); overrides.add(input);
context.setSessionData(CK.REW_DETAILS_OVERRIDE, overrides); context.setSessionData(CK.REW_DETAILS_OVERRIDE, overrides);
context.setSessionData(classPrefix + "-override", null); context.setSessionData(classPrefix + "-override", null);
} }
}
checkReward(context); checkReward(context);
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this); QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);

View File

@ -390,16 +390,20 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
// Check/add newly made override final String input = (String) context.getSessionData(classPrefix + "-override");
if (context.getSessionData(classPrefix + "-override") != null) { if (input != null && !input.equalsIgnoreCase(Lang.get("cancel"))) {
if (input.equalsIgnoreCase(Lang.get("clear"))) {
context.setSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY, null);
} else {
LinkedList<String> overrides = new LinkedList<String>(); LinkedList<String> overrides = new LinkedList<String>();
if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) != null) { if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) != null) {
overrides.addAll((List<String>) context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY)); overrides.addAll((List<String>) context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY));
} }
overrides.add((String) context.getSessionData(classPrefix + "-override")); overrides.add(input);
context.setSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY, overrides); context.setSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY, overrides);
context.setSessionData(classPrefix + "-override", null); context.setSessionData(classPrefix + "-override", null);
} }
}
context.setSessionData(stagePrefix, Boolean.TRUE); context.setSessionData(stagePrefix, Boolean.TRUE);
checkObjective(context); checkObjective(context);