mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-16 10:55:39 +01:00
Add orientation setting for AddServerScreen button (#191)
* Update MixinAddServerScreen.java AddServerScreen: button use config * New config for the add server screen button * Simplified code --------- Co-authored-by: EnZaXD <60033407+FlorianMichael@users.noreply.github.com>
This commit is contained in:
parent
0d7743395a
commit
50cc26c56a
@ -31,6 +31,12 @@ public class GeneralSettings extends SettingGroup {
|
||||
Text.translatable("words.viafabricplus.lb"),
|
||||
Text.translatable("words.viafabricplus.rb")
|
||||
);
|
||||
public final ModeSetting addServerScreenButtonOrientation = new ModeSetting(this, Text.translatable("general.viafabricplus.addserverscreenbutton"),
|
||||
Text.translatable("words.viafabricplus.lt"),
|
||||
Text.translatable("words.viafabricplus.rt"),
|
||||
Text.translatable("words.viafabricplus.lb"),
|
||||
Text.translatable("words.viafabricplus.rb")
|
||||
);
|
||||
public final BooleanSetting removeNotAvailableItemsFromCreativeTab = new BooleanSetting(this, Text.translatable("general.viafabricplus.creative"), true);
|
||||
public final BooleanSetting showSuperSecretSettings = new BooleanSetting(this, Text.translatable("general.viafabricplus.secret"), true);
|
||||
public final BooleanSetting showExtraInformationInDebugHud = new BooleanSetting(this, Text.translatable("general.viafabricplus.extrainformation"), true);
|
||||
@ -41,5 +47,6 @@ public class GeneralSettings extends SettingGroup {
|
||||
public GeneralSettings() {
|
||||
super(Text.translatable("settings.viafabricplus.general"));
|
||||
mainButtonOrientation.setValue(1); // Default value
|
||||
addServerScreenButtonOrientation.setValue(1); // Default value
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||
|
||||
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||
import de.florianmichael.viafabricplus.screen.impl.base.ForceVersionScreen;
|
||||
import net.minecraft.client.gui.screen.AddServerScreen;
|
||||
@ -44,8 +45,18 @@ public class MixinAddServerScreen extends Screen {
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void injectButton(CallbackInfo ci) {
|
||||
final VersionEnum forcedVersion = ((IServerInfo) server).viafabricplus_forcedVersion();
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.literal(forcedVersion == null ? "Set version for this server" : forcedVersion.getName()), button ->
|
||||
client.setScreen(new ForceVersionScreen(this, version -> ((IServerInfo) server).viafabricplus_forceVersion(version)))).
|
||||
position(width - (forcedVersion == null ? 150 : 98) - 5, 5).size(forcedVersion == null ? 150 : 98, 20).build());
|
||||
|
||||
ButtonWidget.Builder builder = ButtonWidget.builder(forcedVersion == null ? Text.translatable("words.viafabricplus.addserverscreenbuttontitle") : Text.literal(forcedVersion.getName()), button ->
|
||||
client.setScreen(new ForceVersionScreen(this, version -> ((IServerInfo) server).viafabricplus_forceVersion(version))));
|
||||
|
||||
final int orientation = GeneralSettings.INSTANCE.addServerScreenButtonOrientation.getIndex();
|
||||
switch (orientation) {
|
||||
case 0 -> builder = builder.position(5, 5);
|
||||
case 1 -> builder = builder.position(width - (forcedVersion == null ? 150 : 98) - 5, 5);
|
||||
case 2 -> builder = builder.position(5, height - 20 - 5);
|
||||
case 3 -> builder = builder.position(width - (forcedVersion == null ? 150 : 98) - 5, height - 20 - 5);
|
||||
}
|
||||
|
||||
this.addDrawableChild(builder.size(forcedVersion == null ? 150 : 98, 20).build());
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
"words.viafabricplus.translate": "Via translates to: %s",
|
||||
"words.viafabricplus.serverversion": "Server version: %s",
|
||||
"words.viafabricplus.auto": "Auto",
|
||||
"words.viafabricplus.addserverscreenbuttontitle": "Set version for this server",
|
||||
|
||||
"settings.viafabricplus.authentication": "Authentication",
|
||||
"settings.viafabricplus.experimental": "Experimental",
|
||||
@ -30,6 +31,7 @@
|
||||
"general.viafabricplus.extrainformation": "Show extra information in Debug Hud",
|
||||
"general.viafabricplus.classicloading": "Show classic loading progress in connect screen",
|
||||
"general.viafabricplus.main": "Main button orientation",
|
||||
"general.viafabricplus.addserverscreenbutton": "Add server screen button orientation",
|
||||
"general.viafabricplus.creative": "Remove not available items from creative tab",
|
||||
"general.viafabricplus.autodetect": "Auto detect version",
|
||||
"general.viafabricplus.advertised": "Show advertised/server version in Multiplayer",
|
||||
|
@ -18,6 +18,7 @@
|
||||
"words.viafabricplus.translate": "连接所用版本:%s",
|
||||
"words.viafabricplus.serverversion": "服务器版本:%s",
|
||||
"words.viafabricplus.auto": "自动",
|
||||
"words.viafabricplus.addserverscreenbuttontitle": "更改当前服务器版本",
|
||||
|
||||
"settings.viafabricplus.authentication": "身份与认证",
|
||||
"settings.viafabricplus.experimental": "实验性功能",
|
||||
@ -30,6 +31,7 @@
|
||||
"general.viafabricplus.extrainformation": "在§6[调试]§r中显示额外信息",
|
||||
"general.viafabricplus.classicloading": "在连接服务器时使用旧版加载进度条",
|
||||
"general.viafabricplus.main": "模组按钮位置",
|
||||
"general.viafabricplus.addserverscreenbutton": "编辑服务器页面按钮位置",
|
||||
"general.viafabricplus.creative": "从创造模式选项卡中移除不可用的物品",
|
||||
"general.viafabricplus.autodetect": "自动检测版本",
|
||||
"general.viafabricplus.advertised": "在服务器列表-延迟中显示连接所用版本/服务器版本",
|
||||
|
Loading…
Reference in New Issue
Block a user