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")
@Override
public String getPromptText(ConversationContext context) {
// Check/add newly made override
if (context.getSessionData(classPrefix + "-override") != null) {
LinkedList<String> overrides = new LinkedList<String>();
if (context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null) {
overrides.addAll((List<String>) context.getSessionData(CK.REW_DETAILS_OVERRIDE));
final String input = (String) context.getSessionData(classPrefix + "-override");
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>();
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);
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);

View File

@ -390,15 +390,19 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
@SuppressWarnings("unchecked")
@Override
public String getPromptText(ConversationContext context) {
// Check/add newly made override
if (context.getSessionData(classPrefix + "-override") != null) {
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));
final String input = (String) context.getSessionData(classPrefix + "-override");
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>();
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);
checkObjective(context);