mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-03-02 04:01:28 +01:00
Added report issues screen and moved server lists into one screen
This commit is contained in:
parent
27f8156c47
commit
87b27861b7
src/main
java/de/florianmichael/viafabricplus/screen/base
resources/assets/viafabricplus/lang
@ -20,18 +20,12 @@
|
||||
package de.florianmichael.viafabricplus.screen.base;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.classic4j.BetaCraftHandler;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import de.florianmichael.viafabricplus.screen.VFPScreen;
|
||||
import de.florianmichael.viafabricplus.screen.classic4j.BetaCraftScreen;
|
||||
import de.florianmichael.viafabricplus.screen.classic4j.ClassiCubeLoginScreen;
|
||||
import de.florianmichael.viafabricplus.screen.classic4j.ClassiCubeServerListScreen;
|
||||
import de.florianmichael.viafabricplus.screen.settings.SettingsScreen;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.tooltip.Tooltip;
|
||||
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
@ -44,62 +38,25 @@ public class ProtocolSelectionScreen extends VFPScreen {
|
||||
|
||||
public static final ProtocolSelectionScreen INSTANCE = new ProtocolSelectionScreen();
|
||||
|
||||
private ButtonWidget betaCraftButton;
|
||||
|
||||
protected ProtocolSelectionScreen() {
|
||||
super("ViaFabricPlus", true);
|
||||
this.setupDefaultSubtitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
// List and Settings
|
||||
this.setupDefaultSubtitle();
|
||||
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, 30, textRenderer.fontHeight + 4));
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.translatable("base.viafabricplus.settings"), button -> SettingsScreen.INSTANCE.open(this)).position(width - 98 - 5, 5).size(98, 20).build());
|
||||
|
||||
// ClassiCube
|
||||
final boolean loggedIn = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount() != null;
|
||||
|
||||
ButtonWidget.Builder classiCubeBuilder = ButtonWidget.builder(Text.literal("ClassiCube"), button -> {
|
||||
if (!loggedIn) {
|
||||
ClassiCubeLoginScreen.INSTANCE.open(prevScreen);
|
||||
return;
|
||||
}
|
||||
ClassiCubeServerListScreen.INSTANCE.open(prevScreen);
|
||||
}).position(width - 98 - 5, height - 25).size(98, 20);
|
||||
if (!loggedIn) {
|
||||
classiCubeBuilder = classiCubeBuilder.tooltip(Tooltip.of(Text.translatable("classicube.viafabricplus.warning")));
|
||||
}
|
||||
this.addDrawableChild(classiCubeBuilder.build());
|
||||
|
||||
// BetaCraft
|
||||
ButtonWidget.Builder betaCraftBuilder = ButtonWidget.builder(Text.literal("BetaCraft"), button -> {
|
||||
if (BetaCraftScreen.SERVER_LIST == null) {
|
||||
betaCraftButton = button;
|
||||
|
||||
BetaCraftHandler.requestV1ServerList(serverList -> {
|
||||
BetaCraftScreen.SERVER_LIST = serverList;
|
||||
|
||||
BetaCraftScreen.INSTANCE.open(this);
|
||||
}, throwable -> showErrorScreen("BetaCraft", throwable, this));
|
||||
|
||||
} else {
|
||||
BetaCraftScreen.INSTANCE.open(this);
|
||||
}
|
||||
}).position(5, height - 25).size(98, 20);
|
||||
if (BetaCraftScreen.SERVER_LIST == null) {
|
||||
betaCraftBuilder = betaCraftBuilder.tooltip(Tooltip.of(Text.translatable("betacraft.viafabricplus.warning")));
|
||||
}
|
||||
this.addDrawableChild(betaCraftBuilder.build());
|
||||
this.addDrawableChild(ButtonWidget.builder(ServerListScreen.INSTANCE.getTitle(), button -> ServerListScreen.INSTANCE.open(this))
|
||||
.position(5, height - 25).size(98, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.translatable("report.viafabricplus.button"), button -> ReportIssuesScreen.INSTANCE.open(this))
|
||||
.position(width - 98 - 5, height - 25).size(98, 20).build());
|
||||
|
||||
super.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (betaCraftButton != null) betaCraftButton.setMessage(Text.of("Loading..."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(context, mouseX, mouseY, delta);
|
||||
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.screen.base;
|
||||
|
||||
import com.viaversion.viaversion.util.DumpUtil;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.screen.VFPScreen;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Util;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReportIssuesScreen extends VFPScreen {
|
||||
|
||||
public static final ReportIssuesScreen INSTANCE = new ReportIssuesScreen();
|
||||
|
||||
private final Map<String, Runnable> actions = new LinkedHashMap<>();
|
||||
|
||||
private long delay = -1;
|
||||
|
||||
public ReportIssuesScreen() {
|
||||
super("Report issues", true);
|
||||
|
||||
if (actions.isEmpty()) {
|
||||
actions.put("report.viafabricplus.bug_report", () -> {
|
||||
Util.getOperatingSystem().open(URI.create("https://github.com/ViaVersion/ViaFabricPlus/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml"));
|
||||
this.setupSubtitle(Text.of("Opened GitHub issue page!"));
|
||||
});
|
||||
actions.put("report.viafabricplus.create_via_dump", () -> DumpUtil.postDump(client.getSession().getUuidOrNull()).whenComplete((s, throwable) -> {
|
||||
if (throwable != null) {
|
||||
this.setupSubtitle(Text.of("Failed to create a dump! See logs for more information."));
|
||||
ViaFabricPlus.global().getLogger().error("Failed to create a dump", throwable);
|
||||
return;
|
||||
}
|
||||
this.setupSubtitle(Text.of("Dump created and copied to clipboard!"));
|
||||
client.keyboard.setClipboard(s);
|
||||
}));
|
||||
actions.put("report.viafabricplus.open_logs", () -> {
|
||||
Util.getOperatingSystem().open(new File(client.runDirectory, "logs") /* there is no constant for this in the game */);
|
||||
this.setupSubtitle(Text.of("Logs folder opened!"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
this.setupDefaultSubtitle();
|
||||
|
||||
int i = 0;
|
||||
for (Map.Entry<String, Runnable> entry : actions.entrySet()) {
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.translatable(entry.getKey()), button -> entry.getValue().run()).
|
||||
position(this.width / 2 - 100, this.height / 2 - 25 + i * (20 + 3)).size(200, 20).build());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupSubtitle(@Nullable Text subtitle) {
|
||||
super.setupSubtitle(subtitle);
|
||||
|
||||
this.delay = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.delay != -1 && System.currentTimeMillis() - this.delay > 5000 /* 5 seconds */) {
|
||||
this.setupDefaultSubtitle();
|
||||
this.delay = -1; // Don't recall this method all the time
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
this.renderTitle(context);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.screen.base;
|
||||
|
||||
import de.florianmichael.classic4j.BetaCraftHandler;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.screen.VFPScreen;
|
||||
import de.florianmichael.viafabricplus.screen.classic4j.BetaCraftScreen;
|
||||
import de.florianmichael.viafabricplus.screen.classic4j.ClassiCubeLoginScreen;
|
||||
import de.florianmichael.viafabricplus.screen.classic4j.ClassiCubeServerListScreen;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.tooltip.Tooltip;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class ServerListScreen extends VFPScreen {
|
||||
|
||||
public static final ServerListScreen INSTANCE = new ServerListScreen();
|
||||
|
||||
private ButtonWidget betaCraftButton;
|
||||
|
||||
public ServerListScreen() {
|
||||
super("Server lists", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
this.setupDefaultSubtitle();
|
||||
|
||||
// ClassiCube
|
||||
final boolean loggedIn = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount() != null;
|
||||
|
||||
ButtonWidget.Builder classiCubeBuilder = ButtonWidget.builder(ClassiCubeServerListScreen.INSTANCE.getTitle(), button -> {
|
||||
if (!loggedIn) {
|
||||
ClassiCubeLoginScreen.INSTANCE.open(this);
|
||||
return;
|
||||
}
|
||||
ClassiCubeServerListScreen.INSTANCE.open(this);
|
||||
}).position(this.width / 2 - 50, this.height / 2 - 25).size(98, 20);
|
||||
if (!loggedIn) {
|
||||
classiCubeBuilder = classiCubeBuilder.tooltip(Tooltip.of(Text.translatable("classicube.viafabricplus.warning")));
|
||||
}
|
||||
this.addDrawableChild(classiCubeBuilder.build());
|
||||
|
||||
ButtonWidget.Builder betaCraftBuilder = ButtonWidget.builder(BetaCraftScreen.INSTANCE.getTitle(), button -> {
|
||||
if (BetaCraftScreen.SERVER_LIST == null) {
|
||||
betaCraftButton = button;
|
||||
|
||||
BetaCraftHandler.requestV1ServerList(serverList -> {
|
||||
BetaCraftScreen.SERVER_LIST = serverList;
|
||||
|
||||
BetaCraftScreen.INSTANCE.open(this);
|
||||
}, throwable -> showErrorScreen(BetaCraftScreen.INSTANCE.getTitle().getString(), throwable, this));
|
||||
|
||||
} else {
|
||||
BetaCraftScreen.INSTANCE.open(this);
|
||||
}
|
||||
}).position(this.width / 2 - 50, this.height / 2 - 25 + 20 + 3).size(98, 20);
|
||||
if (BetaCraftScreen.SERVER_LIST == null) {
|
||||
betaCraftBuilder = betaCraftBuilder.tooltip(Tooltip.of(Text.translatable("betacraft.viafabricplus.warning")));
|
||||
}
|
||||
this.addDrawableChild(betaCraftBuilder.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (betaCraftButton != null) betaCraftButton.setMessage(Text.of("Loading..."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
this.renderTitle(context);
|
||||
}
|
||||
|
||||
}
|
@ -88,6 +88,11 @@
|
||||
"bedrock.viafabricplus.confirm_transfer_server_prompt": "Do you want to transfer to the following server?\n%s\n\nThis will disconnect the current server and connect to the new one.",
|
||||
"authentication.viafabricplus.failed_to_verify_session": "ViaFabricPlus failed to verify your session! Please log in into an Account or disable the BetaCraft authentication in the ViaFabricPlus Settings",
|
||||
|
||||
"report.viafabricplus.button": "Report issues",
|
||||
"report.viafabricplus.bug_report": "Report a bug on GitHub",
|
||||
"report.viafabricplus.create_via_dump": "Create a ViaVersion dump",
|
||||
"report.viafabricplus.open_logs": "Open the logs folder",
|
||||
|
||||
"classicube.viafabricplus.account": "You can create an account here: https://www.classicube.net/",
|
||||
"classicube.viafabricplus.loading": "Loading profile information and server list...",
|
||||
"classicube.viafabricplus.warning": "This feature will send API requests to the ClassiCube API.",
|
||||
|
Loading…
Reference in New Issue
Block a user