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;
|
|
|
|
|
2023-03-16 00:17:57 +01:00
|
|
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
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;
|
|
|
|
import net.minecraft.client.Minecraft;
|
2021-03-01 20:55:50 +01:00
|
|
|
import net.minecraft.client.gui.AbstractGui;
|
2023-03-16 00:17:57 +01:00
|
|
|
import net.minecraft.client.gui.widget.Widget;
|
2021-03-01 20:14:50 +01:00
|
|
|
import net.minecraft.client.gui.widget.button.Button;
|
2023-03-16 00:17:57 +01:00
|
|
|
import net.minecraft.util.text.ITextComponent;
|
2021-03-01 20:55:50 +01:00
|
|
|
import net.minecraft.util.text.StringTextComponent;
|
2016-07-23 19:20:53 +02:00
|
|
|
import net.minecraft.util.text.TextFormatting;
|
2021-11-21 17:57:50 +01:00
|
|
|
import net.minecraft.util.text.TranslationTextComponent;
|
2021-03-01 20:14:50 +01:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2023-03-16 00:17:57 +01:00
|
|
|
import net.minecraftforge.fml.client.gui.GuiUtils;
|
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)
|
2021-03-01 20:55:50 +01:00
|
|
|
public class FilterSettingsGui extends AbstractGui {
|
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;
|
|
|
|
|
2023-03-16 00:17:57 +01:00
|
|
|
this.whitelistButton = new Buttons.SmallerButton( x, y, new StringTextComponent("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;
|
2023-03-16 00:17:57 +01:00
|
|
|
this.nbtButton = new Buttons.SmallerButton( x, y, new StringTextComponent("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;
|
2023-03-16 00:17:57 +01:00
|
|
|
this.modButton = new Buttons.SmallerButton( x, y, new StringTextComponent("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() {
|
2021-08-22 17:09:06 +02:00
|
|
|
this.whitelistButton.setMessage(new StringTextComponent("WH").withStyle(this.theSettings.isWhitelist
|
2021-02-26 22:15:48 +01:00
|
|
|
? TextFormatting.DARK_GREEN
|
2021-03-01 20:55:50 +01:00
|
|
|
: TextFormatting.RED));
|
2021-08-22 17:09:06 +02:00
|
|
|
this.whitelistButton.setMessage(new StringTextComponent("NB").withStyle(this.theSettings.respectNBT
|
2021-02-26 22:15:48 +01:00
|
|
|
? TextFormatting.DARK_GREEN
|
2021-03-01 20:55:50 +01:00
|
|
|
: TextFormatting.RED));
|
2021-08-22 17:09:06 +02:00
|
|
|
this.whitelistButton.setMessage(new StringTextComponent("MO").withStyle(this.theSettings.respectMod
|
2021-03-01 20:55:50 +01:00
|
|
|
? TextFormatting.DARK_GREEN
|
|
|
|
: TextFormatting.RED));
|
2016-07-23 19:20:53 +02:00
|
|
|
}
|
|
|
|
|
2023-03-16 00:17:57 +01:00
|
|
|
public void drawHover(MatrixStack stack, int mouseX, int mouseY) {
|
2021-02-26 22:15:48 +01:00
|
|
|
Minecraft mc = Minecraft.getInstance();
|
2023-03-16 00:17:57 +01:00
|
|
|
List<ITextComponent> 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
|
|
|
|
? new TranslationTextComponent("info." + ActuallyAdditions.MODID + ".gui.whitelist")
|
|
|
|
: new TranslationTextComponent("info." + ActuallyAdditions.MODID + ".gui.blacklist")).withStyle(TextFormatting.BOLD));
|
|
|
|
list.add(new TranslationTextComponent("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
|
|
|
|
? new TranslationTextComponent("info." + ActuallyAdditions.MODID + ".gui.respectNBT")
|
|
|
|
: new TranslationTextComponent("info." + ActuallyAdditions.MODID + ".gui.ignoreNBT")).withStyle(TextFormatting.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
|
|
|
|
? new TranslationTextComponent("info." + ActuallyAdditions.MODID + ".gui.respectMod")
|
|
|
|
: new TranslationTextComponent("info." + ActuallyAdditions.MODID + ".gui.ignoreMod")).withStyle(TextFormatting.BOLD));
|
|
|
|
list.add(new TranslationTextComponent("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
|
|
|
|
if (!list.isEmpty())
|
|
|
|
GuiUtils.drawHoveringText(stack, list, mouseX, mouseY, mc.getWindow().getGuiScaledWidth(), mc.getWindow().getGuiScaledHeight(), 200, mc.font);
|
2016-07-23 19:20:53 +02:00
|
|
|
}
|
|
|
|
}
|