Skip to content

Commit

Permalink
allow prompt subclassing
Browse files Browse the repository at this point in the history
  • Loading branch information
RacoonDog authored and Wide-Cat committed Dec 19, 2024
1 parent a8483f8 commit 43a9842
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

@SuppressWarnings("unchecked") // cant instantiate a Prompt directly so this is fine
public abstract class Prompt<T> {
final GuiTheme theme;
final Screen parent;
protected final GuiTheme theme;
protected final Screen parent;

String title = "";
final List<String> messages = new ArrayList<>();
boolean dontShowAgainCheckboxVisible = true;
String id = null;
protected String title = "";
protected final List<String> messages = new ArrayList<>();
protected boolean dontShowAgainCheckboxVisible = true;
protected String id = null;

protected Prompt(GuiTheme theme, Screen parent) {
this.theme = theme;
Expand Down Expand Up @@ -54,8 +54,7 @@ public T id(String from) {
}

public boolean show() {
if (id == null) this.id(this.title);
if (Config.get().dontShowAgainPrompts.contains(id)) return false;
if (id != null && Config.get().dontShowAgainPrompts.contains(id)) return false;

if (!RenderSystem.isOnRenderThread()) {
RenderSystem.recordRenderCall(() -> mc.setScreen(new PromptScreen(theme)));
Expand All @@ -67,11 +66,11 @@ public boolean show() {
return true;
}

abstract void initialiseWidgets(PromptScreen screen);
protected abstract void initialiseWidgets(PromptScreen screen);

protected class PromptScreen extends WindowScreen {
WCheckbox dontShowAgainCheckbox;
WHorizontalList list;
protected WCheckbox dontShowAgainCheckbox;
protected WHorizontalList list;

public PromptScreen(GuiTheme theme) {
super(theme, Prompt.this.title);
Expand Down

0 comments on commit 43a9842

Please sign in to comment.