From 54833af3600b00fcdbb083d07a071f1e02131199 Mon Sep 17 00:00:00 2001 From: UltraBlackLinux Date: Fri, 18 Jun 2021 18:22:21 +0200 Subject: [PATCH] - last bugfixes - slight code cleanup - Update README.md --- README.md | 7 ++-- .../client/screen/MineMenuSelectScreen.java | 15 +++++-- .../client/screen/MineMenuSettingsScreen.java | 42 +++---------------- 3 files changed, 19 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index a223b68..c1b7a36 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,11 @@ -# MineMenuFabric -**Minemenu, but for Fabric** +# MineMenu(for)Fabric -Note: This project doesn't have anything to do with Girafi's Minemenu, This is only a fabric port! +**Note: This project is completely seperate from Girafi's MineMenu mod - This is only a very customized port for the Fabric-modloader!** -MineMenuFabric is a customizable menu, that lets you manage commands and chat messages in a simple, yet powerful circular menu +MineMenuFabric assists you with sending and queueing chat messages, copying text, opening links and even pressing (un)bound keybinds in a simple, yet powerful circular and customizable menu with support for categories. Supports enchanted/playerhead icons and copying text, opening links, saying a message in the chat and creating categories to keep your menu sorted! diff --git a/src/main/java/me/ultrablacklinux/minemenufabric/client/screen/MineMenuSelectScreen.java b/src/main/java/me/ultrablacklinux/minemenufabric/client/screen/MineMenuSelectScreen.java index 953e5e8..b8bce59 100644 --- a/src/main/java/me/ultrablacklinux/minemenufabric/client/screen/MineMenuSelectScreen.java +++ b/src/main/java/me/ultrablacklinux/minemenufabric/client/screen/MineMenuSelectScreen.java @@ -10,6 +10,7 @@ import me.ultrablacklinux.minemenufabric.client.util.GsonUtil; import me.ultrablacklinux.minemenufabric.client.util.RandomUtil; import me.ultrablacklinux.minemenufabric.access.KeyBindingInterface; +import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; @@ -276,6 +277,7 @@ private void handleTypes(JsonObject value) { switch (type) { case "empty": + close(); RandomUtil.openConfigScreen(this); break; @@ -289,18 +291,19 @@ private void handleTypes(JsonObject value) { case "print": + close(); client.player.sendChatMessage(value.get("data").getAsString()); - this.client.openScreen(null); break; case "chatbox": + close(); client.openScreen(new ChatScreen(value.get("data").getAsString())); break; case "clipboard": + close(); this.client.keyboard.setClipboard(value.get("data").getAsString()); client.player.sendMessage(new TranslatableText("minemenu.select.copied"), true); - this.client.openScreen(null); break; /*case "keydetect": @@ -327,8 +330,6 @@ private void handleTypes(JsonObject value) { break;*/ case "keyselect": - if (client.currentScreen instanceof MineMenuSelectScreen) this.client.openScreen(null); - KeyBinding tmpBinding = keyBindings.stream() .filter(keyBindingstream -> keyBindingstream.getTranslationKey().equals(value.get("data") .getAsJsonObject().get("key").getAsString())).findFirst().get(); @@ -345,10 +346,12 @@ private void handleTypes(JsonObject value) { if (delay != 25001) pressKey(false, tmpBinding); }); + close(); press.start(); break; case "link": + close(); String link = value.get("data").getAsString(); try { if (!link.startsWith("http")) link = "http://" + link; @@ -376,6 +379,10 @@ public static void updateRepeatData(String type, JsonObject value) { repeatDatapath = (ArrayList) datapath.clone(); } } + } + private static void close() { + MinecraftClient.getInstance().openScreen(null); + datapath = new ArrayList<>(); } } \ No newline at end of file diff --git a/src/main/java/me/ultrablacklinux/minemenufabric/client/screen/MineMenuSettingsScreen.java b/src/main/java/me/ultrablacklinux/minemenufabric/client/screen/MineMenuSettingsScreen.java index a5bd6b3..59225bd 100644 --- a/src/main/java/me/ultrablacklinux/minemenufabric/client/screen/MineMenuSettingsScreen.java +++ b/src/main/java/me/ultrablacklinux/minemenufabric/client/screen/MineMenuSettingsScreen.java @@ -12,7 +12,6 @@ import me.ultrablacklinux.minemenufabric.client.util.GsonUtil; import me.ultrablacklinux.minemenufabric.client.util.RandomUtil; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.Element; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ScreenTexts; import net.minecraft.client.gui.widget.ButtonWidget; @@ -64,7 +63,7 @@ public class MineMenuSettingsScreen extends Screen { private boolean enchanted = false; private boolean firstRun = true; private int customModelData = 0; - private int keyBindReleaseTime = 0; + private int keyBindReleaseTime = 10; public MineMenuSettingsScreen(Screen parent, boolean repeat) { super(new TranslatableText("minemenu.settings.title")); @@ -79,10 +78,6 @@ public MineMenuSettingsScreen(Screen parent, boolean repeat) { } private void updateData() { - /*if (localDPath == null) { - client.openScreen(null); - return; - }*/ localData = minemenuData; for (String s : localDPath) localData = localData.get(s).getAsJsonObject(); } @@ -140,16 +135,7 @@ protected void init() { this.keyBindButton = this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, 140, 200, 20, InputUtil.UNKNOWN_KEY.getLocalizedText(), (buttonWidget) -> { - /*if (itemTypes == itemTypes.KEYDETECT) { - this.keyListenerActive = !this.keyListenerActive; - this.updateInput(); - if (keyListenerActive) this.keyBindButton.setMessage((new LiteralText("> ")) - .append(this.keyBindButton.getMessage().shallowCopy().formatted(Formatting.YELLOW)) - .append(" <").formatted(Formatting.YELLOW)); //Definitely not stolen from minecraft's code - } - else */if (itemTypes == itemTypes.KEYSELECT) { - this.keyBindCycle(false); - } + if (itemTypes == itemTypes.KEYSELECT) this.keyBindCycle(false); })); this.itemType = this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, 180, 200, @@ -166,7 +152,7 @@ protected void init() { } this.keyBindreleaseSlider = this.addDrawableChild(new SliderWidget(this.width / 2 - 100, 160, 200, - 20, LiteralText.EMPTY, this.keyBindReleaseTime / 25001D) { + 20, LiteralText.EMPTY, (this.keyBindReleaseTime - 10) / (25001 - 10)) { { //hippedy, hoppedy, your code is now my property this.updateMessage(); } @@ -183,7 +169,7 @@ protected void updateMessage() { protected void applyValue() { MineMenuSettingsScreen.this.keyBindReleaseTime - = MathHelper.floor(MathHelper.clampedLerp(0, 25001, this.value)); + = MathHelper.floor(MathHelper.clampedLerp(10, 25001, this.value)); } }); @@ -200,7 +186,6 @@ protected void applyValue() { private void keyBindCycle(boolean reverse) { int index = keyBindings.indexOf(usedBinding); - //KeyBindingHelper.getBoundKeyOf() if (this.usedBinding == null || (index == keyBindings.size() - 1 && !reverse)) { this.usedBinding = keyBindings.get(0); } @@ -257,7 +242,7 @@ private void updateInput() { break; } - if (/*itemTypes == MenuTypes.KEYDETECT ||*/ itemTypes == MenuTypes.KEYSELECT) { + if (itemTypes == MenuTypes.KEYSELECT) { this.keyBindButton.visible = true; this.keyBindreleaseSlider.visible = true; this.itemData.visible = false; @@ -279,13 +264,6 @@ private void updateInput() { this.itemData.setEditable(true); break; - /*case KEYDETECT: - this.itemData.setEditable(false); - try { - this.keyBindButton.setMessage(this.usedKey.getLocalizedText()); - } catch (Exception ingore) {} - break;*/ - case KEYSELECT: this.itemData.setEditable(false); try { @@ -490,11 +468,6 @@ private void applySettings() { subDataOut = new JsonPrimitive(dataTextOut); break; - /*case KEYDETECT: - subDataOut.getAsJsonObject().add("key", new JsonPrimitive(this.usedKey.getTranslationKey())); - subDataOut.getAsJsonObject().add("releaseDelay", new JsonPrimitive(keyBindReleaseTime)); - break;*/ - case KEYSELECT: subDataOut.getAsJsonObject().add("key", new JsonPrimitive(this.usedBinding.getTranslationKey())); subDataOut.getAsJsonObject().add("releaseDelay", new JsonPrimitive(keyBindReleaseTime)); @@ -538,11 +511,6 @@ private void readTypes(JsonObject data) { this.itemData.setText(data.get("data").getAsString()); break; - /*case KEYDETECT: - this.usedKey = InputUtil.fromTranslationKey(data.get("data").getAsJsonObject().get("key").getAsString()); - this.keyBindReleaseTime = data.get("data").getAsJsonObject().get("releaseDelay").getAsInt(); - break;*/ - case KEYSELECT: try { this.usedBinding = this.keyBindings.stream()