Skip to content

Commit

Permalink
simplify dontShowAgain
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 43a9842 commit 83f9d3f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import meteordevelopment.meteorclient.gui.GuiTheme;
import meteordevelopment.meteorclient.gui.GuiThemes;
import meteordevelopment.meteorclient.gui.widgets.pressable.WButton;
import meteordevelopment.meteorclient.systems.config.Config;
import net.minecraft.client.gui.screen.Screen;

import static meteordevelopment.meteorclient.MeteorClient.mc;
Expand Down Expand Up @@ -37,7 +36,7 @@ public OkPrompt onOk(Runnable action) {
protected void initialiseWidgets(PromptScreen screen) {
WButton okButton = screen.list.add(theme.button("Ok")).expandX().widget();
okButton.action = () -> {
if (screen.dontShowAgainCheckbox != null && screen.dontShowAgainCheckbox.checked) Config.get().dontShowAgainPrompts.add(id);
dontShowAgain(screen);
onOk.run();
screen.close();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public boolean show() {
return true;
}

protected void dontShowAgain(PromptScreen screen) {
if (screen.dontShowAgainCheckbox != null && screen.dontShowAgainCheckbox.checked && id != null) {
Config.get().dontShowAgainPrompts.add(id);
}
}

protected abstract void initialiseWidgets(PromptScreen screen);

protected class PromptScreen extends WindowScreen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import meteordevelopment.meteorclient.gui.GuiTheme;
import meteordevelopment.meteorclient.gui.GuiThemes;
import meteordevelopment.meteorclient.gui.widgets.pressable.WButton;
import meteordevelopment.meteorclient.systems.config.Config;
import net.minecraft.client.gui.screen.Screen;

import static meteordevelopment.meteorclient.MeteorClient.mc;
Expand Down Expand Up @@ -43,14 +42,14 @@ public YesNoPrompt onNo(Runnable action) {
protected void initialiseWidgets(PromptScreen screen) {
WButton yesButton = screen.list.add(theme.button("Yes")).expandX().widget();
yesButton.action = () -> {
if (screen.dontShowAgainCheckbox != null && screen.dontShowAgainCheckbox.checked) Config.get().dontShowAgainPrompts.add(id);
dontShowAgain(screen);
onYes.run();
screen.close();
};

WButton noButton = screen.list.add(theme.button("No")).expandX().widget();
noButton.action = () -> {
if (screen.dontShowAgainCheckbox != null && screen.dontShowAgainCheckbox.checked) Config.get().dontShowAgainPrompts.add(id);
dontShowAgain(screen);
onNo.run();
screen.close();
};
Expand Down

0 comments on commit 83f9d3f

Please sign in to comment.