mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2025-01-17 20:52:02 +01:00
Save scroll states in important slot list screens
Closes https://github.com/ViaVersion/ViaFabricPlus/issues/499
This commit is contained in:
parent
a64de56869
commit
e3fa5a4864
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.screen;
|
||||
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
|
||||
@ -29,9 +30,26 @@ public class VFPList<T extends AlwaysSelectedEntryListWidget.Entry<T>> extends A
|
||||
super(minecraftClient, width, height - top - bottom, top, entryHeight);
|
||||
}
|
||||
|
||||
public void initScrollAmount(final double amount) {
|
||||
// Needs calling last in init to have data loaded before setting scroll amount
|
||||
if (GeneralSettings.global().saveScrollPositionInSlotScreens.getValue()) {
|
||||
this.setScrollAmount(amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScrollAmountOnly(double amount) {
|
||||
super.setScrollAmountOnly(amount);
|
||||
updateSlotAmount(getScrollAmount()); // Ensure value is clamped
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawSelectionHighlight(DrawContext context, int y, int entryWidth, int entryHeight, int borderColor, int fillColor) {
|
||||
// Remove selection box
|
||||
}
|
||||
|
||||
protected void updateSlotAmount(final double amount) {
|
||||
// To be overridden
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,11 +66,18 @@ public class ProtocolSelectionScreen extends VFPScreen {
|
||||
}
|
||||
|
||||
public static class SlotList extends VFPList<VFPListEntry> {
|
||||
private static double scrollAmount;
|
||||
|
||||
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
|
||||
super(minecraftClient, width, height, top, bottom, entryHeight);
|
||||
|
||||
ProtocolVersionList.getProtocolsNewToOld().stream().map(ProtocolSlot::new).forEach(this::addEntry);
|
||||
initScrollAmount(scrollAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateSlotAmount(double amount) {
|
||||
scrollAmount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,7 @@ public class BetaCraftScreen extends VFPScreen {
|
||||
}
|
||||
|
||||
public static class SlotList extends VFPList<VFPListEntry> {
|
||||
private static double scrollAmount;
|
||||
|
||||
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
|
||||
super(minecraftClient, width, height, top, bottom, entryHeight);
|
||||
@ -86,12 +87,19 @@ public class BetaCraftScreen extends VFPScreen {
|
||||
addEntry(new ServerSlot(server));
|
||||
}
|
||||
}
|
||||
|
||||
initScrollAmount(scrollAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth() {
|
||||
return super.getRowWidth() + 140;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateSlotAmount(double amount) {
|
||||
scrollAmount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ServerSlot extends VFPListEntry {
|
||||
|
@ -97,17 +97,24 @@ public class ClassiCubeServerListScreen extends VFPScreen {
|
||||
}
|
||||
|
||||
public static class SlotList extends VFPList<VFPListEntry> {
|
||||
private static double scrollAmount;
|
||||
|
||||
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
|
||||
super(minecraftClient, width, height, top, bottom, entryHeight);
|
||||
|
||||
SERVER_LIST.forEach(serverInfo -> this.addEntry(new ServerSlot(serverInfo)));
|
||||
initScrollAmount(scrollAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth() {
|
||||
return super.getRowWidth() + 140;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateSlotAmount(double amount) {
|
||||
scrollAmount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,6 +53,7 @@ public class SettingsScreen extends VFPScreen {
|
||||
}
|
||||
|
||||
public static class SlotList extends VFPList<VFPListEntry> {
|
||||
private static double scrollAmount;
|
||||
|
||||
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
|
||||
super(minecraftClient, width, height, top, bottom, entryHeight);
|
||||
@ -64,12 +65,18 @@ public class SettingsScreen extends VFPScreen {
|
||||
this.addEntry(setting.makeSettingRenderer());
|
||||
}
|
||||
}
|
||||
initScrollAmount(scrollAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth() {
|
||||
return super.getRowWidth() + 140;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateSlotAmount(double amount) {
|
||||
scrollAmount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ public class GeneralSettings extends SettingGroup {
|
||||
);
|
||||
public final BooleanSetting loadSkinsAndSkullsInLegacyVersions = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions"), true);
|
||||
public final BooleanSetting emulateInventoryActionsInAlphaVersions = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions"), true);
|
||||
public final BooleanSetting saveScrollPositionInSlotScreens = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.save_scroll_position_in_slot_screens"), true);
|
||||
|
||||
public GeneralSettings() {
|
||||
super(Text.translatable("setting_group_name.viafabricplus.general"));
|
||||
|
@ -52,6 +52,7 @@
|
||||
"general_settings.viafabricplus.ignore_packet_translation_errors": "Fehler bei der Übersetzung von Paketen ignorieren",
|
||||
"general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "Skins und Schädel in alten Versionen laden",
|
||||
"general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Inventaraktionen in Alpha-Versionen emulieren",
|
||||
"general_settings.viafabricplus.save_scroll_position_in_slot_screens": "Scroll-Position in Slot-Bildschirmen speichern",
|
||||
|
||||
"bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Klicke, um den Account für die Bedrock-Edition einzustellen",
|
||||
"bedrock_settings.viafabricplus.replace_default_port": "Standardport in der Serverliste ersetzen",
|
||||
|
@ -53,6 +53,7 @@
|
||||
"general_settings.viafabricplus.ignore_packet_translation_errors": "Ignore packet translation errors",
|
||||
"general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "Load skins and skulls in legacy versions",
|
||||
"general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Emulate inventory actions in alpha versions",
|
||||
"general_settings.viafabricplus.save_scroll_position_in_slot_screens": "Save scroll position in slot screens",
|
||||
|
||||
"bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click to set account for Bedrock Edition",
|
||||
"bedrock_settings.viafabricplus.replace_default_port": "Replace default port in server list",
|
||||
|
Loading…
Reference in New Issue
Block a user