Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make Back a keybind #119

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,8 @@ public void handleMouseInput() throws IOException {

@Override
public void keyTyped(char c, int keyCode) {
if (keyCode == 1) {
if (this.isVolatile || this instanceof IVolatileScreen) {
openPopup(new PopChoice(QuestTranslation.translate("betterquesting.gui.closing_warning") + "\n\n" + QuestTranslation.translate("betterquesting.gui.closing_confirm"), PresetIcon.ICON_NOTICE.getTexture(), this::confirmClose, QuestTranslation.translate("gui.yes"), QuestTranslation.translate("gui.no")));
} else {
this.mc.displayGuiScreen(null);
if (this.mc.currentScreen == null) this.mc.setIngameFocus();
}

if (keyCode == Keyboard.KEY_ESCAPE) {
confirmVolatileClose();
return;
}

Expand Down Expand Up @@ -314,17 +308,20 @@ public boolean onKeyTyped(char c, int keycode) {
}

if (!used && (BQ_Keybindings.openQuests.getKeyCode() == keycode || mc.gameSettings.keyBindInventory.getKeyCode() == keycode)) {
if (this.isVolatile || this instanceof IVolatileScreen) {
openPopup(new PopChoice(QuestTranslation.translate("betterquesting.gui.closing_warning") + "\n\n" + QuestTranslation.translate("betterquesting.gui.closing_confirm"), PresetIcon.ICON_NOTICE.getTexture(), this::confirmClose, QuestTranslation.translate("gui.yes"), QuestTranslation.translate("gui.no")));
} else {
this.mc.displayGuiScreen(null);
if (this.mc.currentScreen == null) this.mc.setIngameFocus();
}
confirmVolatileClose();
}

return used;
}

private void confirmVolatileClose() {
if (this.isVolatile || this instanceof IVolatileScreen) {
openPopup(new PopChoice(QuestTranslation.translate("betterquesting.gui.closing_warning") + "\n\n" + QuestTranslation.translate("betterquesting.gui.closing_confirm"), PresetIcon.ICON_NOTICE.getTexture(), this::confirmClose, QuestTranslation.translate("gui.yes"), QuestTranslation.translate("gui.no")));
} else {
confirmClose(0);
}
}

@Override
public List<String> getTooltip(int mx, int my) {
ListIterator<IGuiPanel> pnIter = guiPanels.listIterator(guiPanels.size());
Expand Down
28 changes: 12 additions & 16 deletions src/main/java/betterquesting/api2/client/gui/GuiScreenCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,11 @@ public void handleMouseInput() throws IOException {

@Override
public void keyTyped(char c, int keyCode) {
if (keyCode == 1) // ESCAPE
{
if (this.isVolatile || this instanceof IVolatileScreen) {
openPopup(new PopChoice(QuestTranslation.translate("betterquesting.gui.closing_warning") + "\n\n" + QuestTranslation.translate("betterquesting.gui.closing_confirm"), PresetIcon.ICON_NOTICE.getTexture(), this::confirmClose, QuestTranslation.translate("gui.yes"), QuestTranslation.translate("gui.no")));
} else {
this.mc.displayGuiScreen(null);
if (this.mc.currentScreen == null) this.mc.setIngameFocus();
}

if (keyCode == Keyboard.KEY_ESCAPE) {
confirmVolatileClose();
return;
}
if (keyCode == 14) { // BACKSPACE
if (keyCode == BQ_Keybindings.backPage.getKeyCode()) { // BACKSPACE
if (this.mc.currentScreen instanceof GuiScreenCanvas) {
GuiScreenCanvas canvas = (GuiScreenCanvas) mc.currentScreen;
boolean hasKeyAction = false;
Expand Down Expand Up @@ -330,17 +323,20 @@ public boolean onKeyTyped(char c, int keycode) {
}

if (!used && (BQ_Keybindings.openQuests.getKeyCode() == keycode || mc.gameSettings.keyBindInventory.getKeyCode() == keycode)) {
if (this.isVolatile || this instanceof IVolatileScreen) {
openPopup(new PopChoice(QuestTranslation.translate("betterquesting.gui.closing_warning") + "\n\n" + QuestTranslation.translate("betterquesting.gui.closing_confirm"), PresetIcon.ICON_NOTICE.getTexture(), this::confirmClose, QuestTranslation.translate("gui.yes"), QuestTranslation.translate("gui.no")));
} else {
this.mc.displayGuiScreen(null);
if (this.mc.currentScreen == null) this.mc.setIngameFocus();
}
confirmVolatileClose();
}

return used;
}

private void confirmVolatileClose() {
if (this.isVolatile || this instanceof IVolatileScreen) {
openPopup(new PopChoice(QuestTranslation.translate("betterquesting.gui.closing_warning") + "\n\n" + QuestTranslation.translate("betterquesting.gui.closing_confirm"), PresetIcon.ICON_NOTICE.getTexture(), this::confirmClose, QuestTranslation.translate("gui.yes"), QuestTranslation.translate("gui.no")));
} else {
confirmClose(0);
}
}

@Override
public List<String> getTooltip(int mx, int my) {
ListIterator<IGuiPanel> pnIter = guiPanels.listIterator(guiPanels.size());
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/betterquesting/client/BQ_Keybindings.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@

public class BQ_Keybindings {
public static KeyBinding openQuests;
public static KeyBinding backPage;

public static void RegisterKeys() {
openQuests = new KeyBinding("key.betterquesting.quests", Keyboard.KEY_GRAVE, ModReference.NAME);
backPage = new KeyBinding("key.betterquesting.back", Keyboard.KEY_BACK, ModReference.NAME);

ClientRegistry.registerKeyBinding(openQuests);
ClientRegistry.registerKeyBinding(backPage);
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/betterquesting/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ betterquesting.msg.copy_quest_copied=§eCopied to clipboard: §b%s
betterquesting.msg.copy_quest_failed=§cCould not copy §b%s§r§c to clipboard!

key.betterquesting.quests=Open Quests
key.betterquesting.back=Page Back
Rongmario marked this conversation as resolved.
Show resolved Hide resolved
key.betterquesting.party=Party Manager
key.betterquesting.themes=Change Theme

Expand Down
Loading