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,15 +334,19 @@ 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"))) {
LinkedList<String> overrides = new LinkedList<String>(); if (input.equalsIgnoreCase(Lang.get("clear"))) {
if (context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null) { context.setSessionData(CK.REW_DETAILS_OVERRIDE, null);
overrides.addAll((List<String>) context.getSessionData(CK.REW_DETAILS_OVERRIDE)); } else {
LinkedList<String> overrides = new LinkedList<String>();
if (context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null) {
overrides.addAll((List<String>) context.getSessionData(CK.REW_DETAILS_OVERRIDE));
}
overrides.add(input);
context.setSessionData(CK.REW_DETAILS_OVERRIDE, overrides);
context.setSessionData(classPrefix + "-override", null);
} }
overrides.add((String) context.getSessionData(classPrefix + "-override"));
context.setSessionData(CK.REW_DETAILS_OVERRIDE, overrides);
context.setSessionData(classPrefix + "-override", null);
} }
checkReward(context); checkReward(context);

View File

@ -390,15 +390,19 @@ 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"))) {
LinkedList<String> overrides = new LinkedList<String>(); if (input.equalsIgnoreCase(Lang.get("clear"))) {
if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) != null) { context.setSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY, null);
overrides.addAll((List<String>) context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY)); } else {
LinkedList<String> overrides = new LinkedList<String>();
if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) != null) {
overrides.addAll((List<String>) context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY));
}
overrides.add(input);
context.setSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY, overrides);
context.setSessionData(classPrefix + "-override", null);
} }
overrides.add((String) context.getSessionData(classPrefix + "-override"));
context.setSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY, overrides);
context.setSessionData(classPrefix + "-override", null);
} }
context.setSessionData(stagePrefix, Boolean.TRUE); context.setSessionData(stagePrefix, Boolean.TRUE);
checkObjective(context); checkObjective(context);