2016-07-23 19:20:53 +02:00
|
|
|
/*
|
|
|
|
* This file ("FilterSettingsGui.java") is part of the Actually Additions mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://ellpeck.de/actaddlicense
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2016-07-23 19:20:53 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
2018-05-10 11:38:58 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
2016-07-23 19:20:53 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.ChatFormatting;
|
2016-07-23 19:20:53 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.client.gui.GuiComponent;
|
|
|
|
import net.minecraft.client.gui.components.AbstractWidget;
|
|
|
|
import net.minecraft.client.gui.components.Button;
|
|
|
|
import net.minecraft.client.gui.components.Widget;
|
|
|
|
import net.minecraft.network.chat.Component;
|
|
|
|
import net.minecraft.network.chat.TextComponent;
|
|
|
|
import net.minecraft.network.chat.TranslatableComponent;
|
2021-03-01 20:14:50 +01:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2021-02-26 22:15:48 +01:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2016-07-23 19:20:53 +02:00
|
|
|
|
2021-02-26 22:15:48 +01:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2024-03-02 21:23:08 +01:00
|
|
|
public class FilterSettingsGui extends GuiComponent {
|
2016-07-23 19:20:53 +02:00
|
|
|
|
|
|
|
private final FilterSettings theSettings;
|
|
|
|
|
2021-11-14 00:20:29 +01:00
|
|
|
public Buttons.SmallerButton whitelistButton;
|
|
|
|
public Buttons.SmallerButton nbtButton;
|
|
|
|
public Buttons.SmallerButton modButton;
|
2016-07-23 19:20:53 +02:00
|
|
|
|
2023-03-16 00:17:57 +01:00
|
|
|
public FilterSettingsGui(FilterSettings settings, int x, int y, List<Widget> buttonList) {
|
2016-07-23 19:20:53 +02:00
|
|
|
this.theSettings = settings;
|
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
this.whitelistButton = new Buttons.SmallerButton( x, y, new TextComponent("WH"), true, Button::onPress); //TODO these need translation keys
|
2016-07-23 19:20:53 +02:00
|
|
|
buttonList.add(this.whitelistButton);
|
2016-11-26 21:32:27 +01:00
|
|
|
y += 14;
|
2024-03-02 21:23:08 +01:00
|
|
|
this.nbtButton = new Buttons.SmallerButton( x, y, new TextComponent("NB"), true, Button::onPress);//TODO also button actions
|
2016-07-23 19:20:53 +02:00
|
|
|
buttonList.add(this.nbtButton);
|
2016-11-26 21:32:27 +01:00
|
|
|
y += 14;
|
2024-03-02 21:23:08 +01:00
|
|
|
this.modButton = new Buttons.SmallerButton( x, y, new TextComponent("MO"), true, Button::onPress);
|
2016-11-17 14:56:26 +01:00
|
|
|
buttonList.add(this.modButton);
|
2016-07-24 18:58:08 +02:00
|
|
|
|
2021-03-01 20:55:50 +01:00
|
|
|
this.tick();
|
2016-07-23 19:20:53 +02:00
|
|
|
}
|
|
|
|
|
2021-03-01 20:55:50 +01:00
|
|
|
public void tick() {
|
2024-03-02 21:23:08 +01:00
|
|
|
this.whitelistButton.setMessage(new TextComponent("WH").withStyle(this.theSettings.isWhitelist
|
|
|
|
? ChatFormatting.DARK_GREEN
|
|
|
|
: ChatFormatting.RED));
|
|
|
|
this.whitelistButton.setMessage(new TextComponent("NB").withStyle(this.theSettings.respectNBT
|
|
|
|
? ChatFormatting.DARK_GREEN
|
|
|
|
: ChatFormatting.RED));
|
|
|
|
this.whitelistButton.setMessage(new TextComponent("MO").withStyle(this.theSettings.respectMod
|
|
|
|
? ChatFormatting.DARK_GREEN
|
|
|
|
: ChatFormatting.RED));
|
2016-07-23 19:20:53 +02:00
|
|
|
}
|
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
public void drawHover(PoseStack stack, int mouseX, int mouseY) {
|
2021-02-26 22:15:48 +01:00
|
|
|
Minecraft mc = Minecraft.getInstance();
|
2024-03-02 21:23:08 +01:00
|
|
|
List<Component> list = new ArrayList<>();
|
2021-03-01 20:55:50 +01:00
|
|
|
if (this.whitelistButton.isMouseOver(mouseX, mouseY)) {
|
2023-03-16 00:17:57 +01:00
|
|
|
list.add((this.theSettings.isWhitelist
|
2024-03-02 21:23:08 +01:00
|
|
|
? new TranslatableComponent("info." + ActuallyAdditions.MODID + ".gui.whitelist")
|
|
|
|
: new TranslatableComponent("info." + ActuallyAdditions.MODID + ".gui.blacklist")).withStyle(ChatFormatting.BOLD));
|
|
|
|
list.add(new TranslatableComponent("info." + ActuallyAdditions.MODID + ".gui.whitelistInfo"));
|
2021-03-01 20:55:50 +01:00
|
|
|
} else if (this.nbtButton.isMouseOver(mouseX, mouseY)) {
|
2023-03-16 00:17:57 +01:00
|
|
|
list.add((this.theSettings.respectNBT
|
2024-03-02 21:23:08 +01:00
|
|
|
? new TranslatableComponent("info." + ActuallyAdditions.MODID + ".gui.respectNBT")
|
|
|
|
: new TranslatableComponent("info." + ActuallyAdditions.MODID + ".gui.ignoreNBT")).withStyle(ChatFormatting.BOLD));
|
2021-03-01 20:55:50 +01:00
|
|
|
} else if (this.modButton.isMouseOver(mouseX, mouseY)) {
|
2023-03-16 00:17:57 +01:00
|
|
|
list.add((this.theSettings.respectMod
|
2024-03-02 21:23:08 +01:00
|
|
|
? new TranslatableComponent("info." + ActuallyAdditions.MODID + ".gui.respectMod")
|
|
|
|
: new TranslatableComponent("info." + ActuallyAdditions.MODID + ".gui.ignoreMod")).withStyle(ChatFormatting.BOLD));
|
|
|
|
list.add(new TranslatableComponent("info." + ActuallyAdditions.MODID + ".gui.respectModInfo"));
|
2017-04-01 19:40:39 +02:00
|
|
|
|
2016-07-24 18:58:08 +02:00
|
|
|
|
|
|
|
}
|
2023-03-16 00:17:57 +01:00
|
|
|
//TODO tooltips still jank
|
2024-03-02 21:23:08 +01:00
|
|
|
if (!list.isEmpty() && mc.screen != null) {
|
|
|
|
mc.screen.renderComponentTooltip(stack, list, mouseX, mouseY, mc.font); //TODO: Check if this is correct, used to call GuiUtils.drawHoveringText
|
|
|
|
}
|
2016-07-23 19:20:53 +02:00
|
|
|
}
|
|
|
|
}
|