mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Save which page of the hud is selected
This commit is contained in:
parent
10758fc25d
commit
a5c1d2ead8
5 changed files with 11 additions and 8 deletions
|
@ -26,6 +26,9 @@ public class Config extends com.minelittlepony.common.util.settings.Config {
|
|||
.addComment("If true Mine Little Pony will not be considered when determining the race to use")
|
||||
.addComment("The result will always be what is set by this config file.");
|
||||
|
||||
public final Setting<Integer> hudPage = value("client", "hudActivePage", 0)
|
||||
.addComment("The page of abilities currently visible in the HUD. You can change this in-game using the PG_UP and PG_DWN keys (configurable)");
|
||||
|
||||
public final Setting<Boolean> disableWaterPlantsFix = value("compatibility", "disableWaterPlantsFix", false)
|
||||
.addComment("Disables this mod's built in fix for making sea plants waterlogged")
|
||||
.addComment("Turn this ON if you're using another mod that does something similar of if you encounter copatibility issues with other mods.");
|
||||
|
|
|
@ -8,8 +8,7 @@ import java.util.Optional;
|
|||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.*;
|
||||
import com.minelittlepony.unicopia.ability.data.Hit;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Set;
|
|||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.ability.Ability;
|
||||
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
||||
import com.minelittlepony.unicopia.ability.AbilitySlot;
|
||||
|
@ -35,8 +36,6 @@ public class KeyBindingsHandler {
|
|||
private final Binding pageDown = register(GLFW.GLFW_KEY_PAGE_DOWN, "hud_page_dn");
|
||||
private final Binding pageUp = register(GLFW.GLFW_KEY_PAGE_UP, "hud_page_up");
|
||||
|
||||
public long page = 0;
|
||||
|
||||
private final Set<KeyBinding> pressed = new HashSet<>();
|
||||
|
||||
public KeyBindingsHandler() {
|
||||
|
@ -68,7 +67,7 @@ public class KeyBindingsHandler {
|
|||
AbilityDispatcher abilities = iplayer.getAbilities();
|
||||
long maxPage = abilities.getMaxPage();
|
||||
|
||||
page = MathHelper.clamp(page, 0, maxPage);
|
||||
long page = MathHelper.clamp(Unicopia.getConfig().hudPage.get(), 0, maxPage);
|
||||
|
||||
if (page > 0 && pageDown.getState() == PressedState.PRESSED) {
|
||||
changePage(client, maxPage, -1);
|
||||
|
@ -103,7 +102,9 @@ public class KeyBindingsHandler {
|
|||
}
|
||||
|
||||
private void changePage(MinecraftClient client, long max, int sigma) {
|
||||
int page = Unicopia.getConfig().hudPage.get();
|
||||
page += sigma;
|
||||
Unicopia.getConfig().hudPage.set(page);
|
||||
client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.75F + (0.25F * sigma)));
|
||||
UHud.INSTANCE.setMessage(Text.translatable("gui.unicopia.page_num", page + 1, max + 1));
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.minelittlepony.unicopia.client.gui;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
||||
import com.minelittlepony.unicopia.ability.AbilitySlot;
|
||||
import com.minelittlepony.unicopia.client.KeyBindingsHandler;
|
||||
import com.minelittlepony.unicopia.entity.player.MagicReserves;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.entity.player.MagicReserves.Bar;
|
||||
|
@ -33,7 +33,7 @@ class ManaRingSlot extends Slot {
|
|||
renderRing(matrices, 13, 9, 0, mana.getXp(), 0x88880099, tickDelta);
|
||||
|
||||
double cost = abilities.getStats().stream()
|
||||
.mapToDouble(s -> s.getCost(KeyBindingsHandler.INSTANCE.page))
|
||||
.mapToDouble(s -> s.getCost(Unicopia.getConfig().hudPage.get()))
|
||||
.reduce(Double::sum)
|
||||
.getAsDouble();
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@ public class UHud extends DrawableHelper {
|
|||
}
|
||||
|
||||
void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) {
|
||||
stat.getAbility(KeyBindingsHandler.INSTANCE.page).ifPresent(ability -> {
|
||||
stat.getAbility(Unicopia.getConfig().hudPage.get()).ifPresent(ability -> {
|
||||
RenderSystem.setShaderTexture(0, ability.getIcon(Pony.of(client.player), client.options.sneakKey.isPressed()));
|
||||
drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v);
|
||||
RenderSystem.setShaderTexture(0, HUD_TEXTURE);
|
||||
|
|
Loading…
Reference in a new issue