diff options
| author | viciscat <51047087+viciscat@users.noreply.github.com> | 2024-09-27 15:47:16 +0200 |
|---|---|---|
| committer | viciscat <51047087+viciscat@users.noreply.github.com> | 2024-12-12 18:21:12 +0100 |
| commit | 0cb8e3dc05c43d3e1a64765a77179657c1e38373 (patch) | |
| tree | 0e1fee22a1dd2cfad11bba6591ea9aab40a1e69f /src | |
| parent | 929728f8a52447931a234c231ddca904ebb8564b (diff) | |
| download | Skyblocker-0cb8e3dc05c43d3e1a64765a77179657c1e38373.tar.gz Skyblocker-0cb8e3dc05c43d3e1a64765a77179657c1e38373.tar.bz2 Skyblocker-0cb8e3dc05c43d3e1a64765a77179657c1e38373.zip | |
Random things
* Method renaming
* Button in Ui & Visuals for config screen
* Localization a bit
Diffstat (limited to 'src')
8 files changed, 87 insertions, 49 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java index 41b62cac..499a174c 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/UIAndVisualsCategory.java @@ -3,9 +3,14 @@ package de.hysky.skyblocker.config.categories; import de.hysky.skyblocker.config.ConfigUtils; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.skyblock.fancybars.StatusBarsConfigScreen; +import de.hysky.skyblocker.skyblock.tabhud.config.WidgetsConfigurationScreen; import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenBuilder; +import de.hysky.skyblocker.skyblock.tabhud.screenbuilder.ScreenMaster; import de.hysky.skyblocker.skyblock.waypoint.WaypointsScreen; +import de.hysky.skyblocker.utils.Location; +import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.title.TitleContainerConfigScreen; +import de.hysky.skyblocker.utils.scheduler.MessageScheduler; import de.hysky.skyblocker.utils.waypoint.Waypoint; import dev.isxander.yacl3.api.ConfigCategory; import dev.isxander.yacl3.api.*; @@ -177,6 +182,17 @@ public class UIAndVisualsCategory { newValue -> config.uiAndVisuals.tabHud.tabHudEnabled = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(ButtonOption.createBuilder() + .name(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.configScreen")) + .text(Text.translatable("text.skyblocker.open")) + .action((screen, opt) -> { + if (Utils.isOnSkyblock()) { + MessageScheduler.INSTANCE.sendMessageAfterCooldown("/widgets"); + } else { + MinecraftClient.getInstance().setScreen(new WidgetsConfigurationScreen(Location.HUB, ScreenMaster.ScreenLayer.MAIN_TAB, screen)); + } + }) + .build()) .option(Option.<Integer>createBuilder() .name(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.tabHudScale")) .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.tabHudScale.@Tooltip"))) @@ -194,15 +210,15 @@ public class UIAndVisualsCategory { .controller(ConfigUtils::createBooleanController) .build()) .option(Option.<Boolean>createBuilder() - .name(Text.literal("Effects from footer")) - .description(OptionDescription.of(Text.literal("If on, will fetch current effects from the tab footer if the Hypixel Effects Widget is disabled"))) + .name(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.effectsFooter")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.effectsFooter.@Tooltip"))) .controller(ConfigUtils::createBooleanController) .binding(defaults.uiAndVisuals.tabHud.effectsFromFooter, () -> config.uiAndVisuals.tabHud.effectsFromFooter, newValue -> config.uiAndVisuals.tabHud.effectsFromFooter = newValue) .build()) .option(Option.<ScreenBuilder.DefaultPositioner>createBuilder() - .name(Text.literal("Default positioning behavior")) + .name(Text.translatable("skyblocker.config.uiAndVisuals.tabHud.defaultPositioning")) .binding(defaults.uiAndVisuals.tabHud.defaultPositioning, () -> config.uiAndVisuals.tabHud.defaultPositioning, newValue -> config.uiAndVisuals.tabHud.defaultPositioning = newValue) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java index 0b7029a6..3bf5028a 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsConfigurationScreen.java @@ -34,10 +34,10 @@ import java.util.function.Consumer; public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerListener { public static final Logger LOGGER = LogUtils.getLogger(); - private GenericContainerScreenHandler handler; + private @Nullable GenericContainerScreenHandler handler; private String titleLowercase; public final boolean noHandler; - private String widgetsLayer = null; + private ScreenMaster.ScreenLayer widgetsLayer = null; private Screen parent = null; private boolean tabPreview = false; @@ -74,7 +74,6 @@ public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerL // Tabs and stuff private final TabManager tabManager = new TabManager(this::addDrawableChild, this::remove); - @Nullable private TabNavigationWidget tabNavigation; private WidgetsListTab widgetsListTab; @@ -85,7 +84,7 @@ public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerL * @param handler the container handler * @param titleLowercase the title in lowercase */ - private WidgetsConfigurationScreen(@Nullable GenericContainerScreenHandler handler, String titleLowercase, Location targetLocation, @Nullable String widgetLayerToGoTo) { + private WidgetsConfigurationScreen(@Nullable GenericContainerScreenHandler handler, String titleLowercase, Location targetLocation, @Nullable ScreenMaster.ScreenLayer widgetLayerToGoTo) { super(Text.literal("Widgets Configuration")); this.handler = handler; this.titleLowercase = titleLowercase; @@ -115,27 +114,33 @@ public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerL * @param widgetLayerToGoTo go to this widget's layer */ public WidgetsConfigurationScreen(Location targetLocation, String widgetLayerToGoTo, Screen parent) { - this(null, "", targetLocation, widgetLayerToGoTo); + this(null, "", targetLocation, ScreenMaster.getScreenBuilder(targetLocation).getPositionRuleOrDefault(widgetLayerToGoTo).screenLayer()); this.parent = parent; } + /** + * Create the screen specifically for the config screen, the widgets tab will be unavailable + * @param targetLocation open the preview to this location + * @param layerToGo go to this layer + */ + public WidgetsConfigurationScreen(Location targetLocation, ScreenMaster.ScreenLayer layerToGo, Screen parent) { + this(null, "", targetLocation, layerToGo); + this.parent = parent; + } @Override protected void init() { - previewTab = new PreviewTab(this.client, this, noHandler ? PreviewTab.Mode.EDITABLE_LOCATION : PreviewTab.Mode.NORMAL); + previewTab = new PreviewTab(this.client, this, noHandler ? PreviewTab.Mode.EDITABLE_LOCATION : PreviewTab.Mode.NORMAL); PreviewTab previewDungeons = new PreviewTab(this.client, this, PreviewTab.Mode.DUNGEON); if (noHandler) { - this.tabNavigation = TabNavigationWidget.builder(this.tabManager, this.width) - .tabs(this.previewTab, previewDungeons) - .build(); - previewTab.goToLayer(ScreenMaster.getScreenBuilder(currentLocation).getPositionRuleOrDefault(widgetsLayer).screenLayer()); - } else { - widgetsListTab = new WidgetsListTab(this.client, this.handler); - this.tabNavigation = TabNavigationWidget.builder(this.tabManager, this.width) - .tabs(this.widgetsListTab, this.previewTab, previewDungeons) - .build(); - widgetsListTab.setShouldShowEntries(titleLowercase.startsWith("widgets ")); - updateCustomWidgets(); + previewTab.goToLayer(widgetsLayer); } + widgetsListTab = new WidgetsListTab(this.client, this.handler); + this.tabNavigation = TabNavigationWidget.builder(this.tabManager, this.width) + .tabs(this.widgetsListTab, this.previewTab, previewDungeons) + .build(); + widgetsListTab.setShouldShowCustomWidgetEntries(titleLowercase.startsWith("widgets ") || noHandler); + updateCustomWidgets(); + this.tabNavigation.selectTab(0, false); switchingToPopup = false; this.addDrawableChild(tabNavigation); @@ -153,8 +158,8 @@ public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerL } } - public void updateHandler(GenericContainerScreenHandler newHandler, String titleLowercase) { - if (noHandler) return; + public void updateHandler(@NotNull GenericContainerScreenHandler newHandler, String titleLowercase) { + if (handler == null) return; handler.removeListener(this); handler = newHandler; handler.addListener(this); @@ -169,7 +174,7 @@ public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerL if (!value.availableLocations().contains(currentLocation)) continue; entries.add(new WidgetEntry(value, currentLocation)); } - widgetsListTab.setEntries(entries); + widgetsListTab.setCustomWidgetEntries(entries); } public void setCurrentLocation(Location location) { @@ -183,7 +188,7 @@ public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerL private void parseLocation() { boolean b = titleLowercase.startsWith("widgets "); - if (widgetsListTab != null) widgetsListTab.setShouldShowEntries(b); + if (widgetsListTab != null) widgetsListTab.setShouldShowCustomWidgetEntries(b); String trim = this.titleLowercase .replace("widgets in", "") .replace("widgets on", "") @@ -198,7 +203,7 @@ public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerL } } - public GenericContainerScreenHandler getHandler() { + public @Nullable GenericContainerScreenHandler getHandler() { return handler; } @@ -206,7 +211,7 @@ public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerL @Override public void onSlotUpdate(ScreenHandler handler, int slotId, ItemStack stack) { - if (noHandler) return; + if (this.handler == null) return; if (slotId == 4) { tabPreview = stack.isOf(Items.PLAYER_HEAD); } @@ -234,18 +239,22 @@ public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerL widgetsListTab.hopper(ItemUtils.getLore(slotThirteenBacklog)); slotThirteenBacklog = null; } - if (!this.client.player.isAlive() || this.client.player.isRemoved()) { + assert this.client != null; + assert this.client.player != null; + if (!this.client.player.isAlive() || this.client.player.isRemoved()) { this.client.player.closeHandledScreen(); } } @Override public void close() { - if (!noHandler) { - this.client.player.closeHandledScreen(); + assert this.client != null; + if (handler != null) { + assert this.client.player != null; + this.client.player.closeHandledScreen(); super.close(); } else { - client.setScreen(parent); + client.setScreen(parent); } } @@ -254,7 +263,7 @@ public class WidgetsConfigurationScreen extends Screen implements ScreenHandlerL @Override public void removed() { - if (noHandler) return; + if (handler == null) return; if (!switchingToPopup && this.client != null && this.client.player != null) { this.handler.onClosed(this.client.player); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsElementList.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsElementList.java index 804bc222..f379ca8d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsElementList.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsElementList.java @@ -62,9 +62,9 @@ public class WidgetsElementList extends ElementListWidget<WidgetsListEntry> { .sorted((a, b) -> IntComparators.NATURAL_COMPARATOR.compare(a.getIntKey(), b.getIntKey())) .map(Map.Entry::getValue) .forEach(this::addEntry); - if (!parent.getWidgetEntries().isEmpty() && parent.shouldShowEntries()) { + if (!parent.getCustomWidgetEntries().isEmpty() && parent.shouldShowCustomWidgetEntries()) { if (!children().isEmpty()) addEntry(SEPARATOR); - parent.getWidgetEntries().forEach(this::addEntry); + parent.getCustomWidgetEntries().forEach(this::addEntry); } setScrollAmount(getScrollAmount()); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsListTab.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsListTab.java index 97233c5d..cced73ae 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsListTab.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/WidgetsListTab.java @@ -37,18 +37,19 @@ public class WidgetsListTab implements Tab { private boolean waitingForServer = false; private final Int2ObjectMap<WidgetsListSlotEntry> entries = new Int2ObjectOpenHashMap<>(); - private final List<WidgetEntry> widgetEntries = new ArrayList<>(); + private final List<WidgetEntry> customWidgetEntries = new ArrayList<>(); private boolean listNeedsUpdate = false; - private boolean shouldShowEntries = false; + private boolean shouldShowCustomWidgetEntries = false; - public void setEntries(Collection<WidgetEntry> entries) { - this.widgetEntries.clear(); - this.widgetEntries.addAll(entries); + public void setCustomWidgetEntries(Collection<WidgetEntry> entries) { + this.customWidgetEntries.clear(); + this.customWidgetEntries.addAll(entries); + listNeedsUpdate = true; } - public List<WidgetEntry> getWidgetEntries() { - return widgetEntries; + public List<WidgetEntry> getCustomWidgetEntries() { + return customWidgetEntries; } public boolean listNeedsUpdate() { @@ -78,7 +79,12 @@ public class WidgetsListTab implements Tab { nextPage = ButtonWidget.builder(Text.literal("Next Page"), button -> clickAndWaitForServer(53, 0)) .size(100, 15) .build(); - if (handler == null) back.visible = false; + if (handler == null) { + back.visible = false; + previousPage.visible = false; + nextPage.visible = false; + thirdColumnButton.visible = false; + } } @Override @@ -193,11 +199,11 @@ public class WidgetsListTab implements Tab { thirdColumnButton.setPosition(widgetsElementList.getScrollbarX() + 5, widgetsElementList.getBottom() + 4); } - public boolean shouldShowEntries() { - return shouldShowEntries; + public boolean shouldShowCustomWidgetEntries() { + return shouldShowCustomWidgetEntries; } - public void setShouldShowEntries(boolean shouldShowEntries) { - this.shouldShowEntries = shouldShowEntries; + public void setShouldShowCustomWidgetEntries(boolean shouldShowCustomWidgetEntries) { + this.shouldShowCustomWidgetEntries = shouldShowCustomWidgetEntries; } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/preview/PreviewTab.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/preview/PreviewTab.java index 9cc320fd..1b1f4ffd 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/preview/PreviewTab.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/config/preview/PreviewTab.java @@ -197,7 +197,7 @@ public class PreviewTab implements Tab { PlayerListMgr.updateDungeons(DungeonsTabPlaceholder.get()); return; } - if (!parent.isPreviewVisible()) return; + if (!parent.isPreviewVisible() || parent.getHandler() == null) return; List<Text> lines = new ArrayList<>(); // Preview doesn't include any players, so adding this as default diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java index 9cdb4667..8764f74e 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java @@ -171,6 +171,9 @@ public class ScreenMaster { } + /** + * Filled at compile item with ASM. Do not fill this. + */ private static void instantiateWidgets() {} public static void addWidgetInstance(HudWidget widget) { diff --git a/src/main/java/de/hysky/skyblocker/utils/Location.java b/src/main/java/de/hysky/skyblocker/utils/Location.java index 80546486..90a5264a 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Location.java +++ b/src/main/java/de/hysky/skyblocker/utils/Location.java @@ -1,5 +1,7 @@ package de.hysky.skyblocker.utils; +import org.apache.commons.lang3.ArrayUtils; + import com.mojang.serialization.Codec; import net.minecraft.util.StringIdentifiable; @@ -135,9 +137,7 @@ public enum Location implements StringIdentifiable { } public static Location[] locationsWithout(Location... locations) { - ArrayList<Location> locationList = new ArrayList<>(List.of(values())); - locationList.removeAll(List.of(locations)); - return locationList.toArray(new Location[0]); + return ArrayUtils.removeElements(values(), locations); } private static Location[] hudLocations = null; diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 45780006..3d7faf6b 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -798,8 +798,12 @@ "skyblocker.config.uiAndVisuals.showEquipmentInInventory": "Show Equipment in Inventory", "skyblocker.config.uiAndVisuals.tabHud": "Fancy HUD and TAB", + "skyblocker.config.uiAndVisuals.tabHud.configScreen": "Open Config Screen", + "skyblocker.config.uiAndVisuals.tabHud.defaultPositioning": "Default Positioning Behavior", "skyblocker.config.uiAndVisuals.tabHud.enableHudBackground": "Enable HUD Background", "skyblocker.config.uiAndVisuals.tabHud.enableHudBackground.@Tooltip": "Enables the background of the non-tab HUD.", + "skyblocker.config.uiAndVisuals.tabHud.effectsFooter": "Effects from footer", + "skyblocker.config.uiAndVisuals.tabHud.effectsFooter.@Tooltip": "If on, will fetch current effects from the tab footer if the Hypixel Effects Widget is disabled.", "skyblocker.config.uiAndVisuals.tabHud.nameSorting": "Player Name Sorting Method", "skyblocker.config.uiAndVisuals.tabHud.nameSorting.@Tooltip": "Alphabetical sorting sorts names alphabetically while Default has no particular order.", "skyblocker.config.uiAndVisuals.tabHud.plainPlayerNames": "Plain Player Names", |
