From 02a484ed7541c41e9af903c2296620a41345c4db Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Sun, 28 Apr 2019 20:33:18 -0300 Subject: [PATCH] Use icon for enable ViaVersion button for workaround the text overflow --- build.gradle.kts | 18 ++++++++++++------ .../mixin/client/MixinMultiplayerScreen.java | 15 +++++++++++---- .../viafabric/textures/gui/via_button.png | Bin 0 -> 4690 bytes 3 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/assets/viafabric/textures/gui/via_button.png diff --git a/build.gradle.kts b/build.gradle.kts index ffc3c45..55260e5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,11 @@ plugins { group = "com.github.creeper123123321.viafabric" val gitVersion: groovy.lang.Closure by extra -version = "0.1.0-SNAPSHOT+" + gitVersion() +version = "0.1.0-SNAPSHOT+" + try { + gitVersion() +} catch (e: Exception) { + "unknown" +} extra.set("archivesBaseName", "ViaFabric") description = "Client-side and server-side ViaVersion for Fabric" @@ -32,10 +36,12 @@ repositories { tasks.named("processResources") { - filter("tokens" to mapOf( - "version" to project.property("version"), - "description" to project.property("description") - )) + filesMatching("fabric.mod.json") { + filter("tokens" to mapOf( + "version" to project.property("version"), + "description" to project.property("description") + )) + } } dependencies { @@ -51,7 +57,7 @@ dependencies { minecraft("com.mojang:minecraft:1.14") mappings("net.fabricmc:yarn:1.14+build.3") - modCompile("net.fabricmc:fabric-loader:0.4.4+build.139") + modCompile("net.fabricmc:fabric-loader:0.4.4+build.140") modCompile("net.fabricmc:fabric:0.2.7+build.127") diff --git a/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinMultiplayerScreen.java b/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinMultiplayerScreen.java index 184ca04..c5a4454 100644 --- a/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinMultiplayerScreen.java +++ b/src/main/java/com/github/creeper123123321/viafabric/mixin/client/MixinMultiplayerScreen.java @@ -32,10 +32,12 @@ import net.minecraft.client.gui.Screen; import net.minecraft.client.gui.menu.MultiplayerScreen; import net.minecraft.client.gui.menu.YesNoScreen; import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.gui.widget.RecipeBookButtonWidget; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.resource.language.I18n; import net.minecraft.text.TextComponent; import net.minecraft.text.TranslatableTextComponent; +import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -108,9 +110,13 @@ public abstract class MixinMultiplayerScreen extends Screen { : Integer.toString(clientSideVersion)); this.children.add(protocolVersion); - enableClientSideViaVersion = new ButtonWidget(this.width / 2 + 48, 13, 105, 15, // TODO replace it with a button with icon - I18n.translate("gui.enable_client_side_button"), button -> - MinecraftClient.getInstance().openScreen(new YesNoScreen( + enableClientSideViaVersion = new RecipeBookButtonWidget(this.width / 2 + 113, 10, + 40, 20, // Size + 0, 0, // Start pos of texture + 20, // v Hover offset + new Identifier("viafabric:textures/gui/via_button.png"), + 64, 64, // Texture size + button -> MinecraftClient.getInstance().openScreen(new YesNoScreen( answer -> { MinecraftClient.getInstance().openScreen(this); if (answer) { @@ -127,7 +133,8 @@ public abstract class MixinMultiplayerScreen extends Screen { new TranslatableTextComponent("gui.enable_client_side.warning"), I18n.translate("gui.enable_client_side.enable"), I18n.translate("gui.cancel") - ))); + )), + I18n.translate("gui.enable_client_side_button")); protocolVersion.setVisible(FabricLoader.getInstance().getConfigDirectory().toPath().resolve("ViaFabric").resolve("enable_client_side").toFile().exists()); enableClientSideViaVersion.visible = !protocolVersion.isVisible(); addButton(enableClientSideViaVersion); diff --git a/src/main/resources/assets/viafabric/textures/gui/via_button.png b/src/main/resources/assets/viafabric/textures/gui/via_button.png new file mode 100644 index 0000000000000000000000000000000000000000..ff9fa86c306b054bbb7baae2e142885d1b6cad7a GIT binary patch literal 4690 zcmb`L^;gr6+s5CcB}9-8hk$?*qQodkVYCxT=?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