Use icon for enable ViaVersion button for workaround the text overflow

This commit is contained in:
creeper123123321 2019-04-28 20:33:18 -03:00
parent 3f2be47045
commit 02a484ed75
No known key found for this signature in database
GPG Key ID: 0AC57D54786721D1
3 changed files with 23 additions and 10 deletions

View File

@ -9,7 +9,11 @@ plugins {
group = "com.github.creeper123123321.viafabric"
val gitVersion: groovy.lang.Closure<Any> 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,11 +36,13 @@ repositories {
tasks.named<ProcessResources>("processResources") {
filesMatching("fabric.mod.json") {
filter<ReplaceTokens>("tokens" to mapOf(
"version" to project.property("version"),
"description" to project.property("description")
))
}
}
dependencies {
// transitive = false, viabackwards-core because Guava is conflicting on runClient
@ -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")

View File

@ -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);

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB