Refactoring of container gui implementation and package structure improvements
This commit is contained in:
@@ -3,8 +3,8 @@ package exopandora.worldhandler.gui.container;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.gui.menu.Menu;
|
||||
import exopandora.worldhandler.gui.menu.IMenu;
|
||||
import exopandora.worldhandler.gui.menu.Menu;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
@@ -16,6 +16,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
public abstract class Container extends Screen implements IContainer
|
||||
{
|
||||
protected final List<IMenu> menus = new ArrayList<IMenu>();
|
||||
protected final List<Widget> widgetButtons = new ArrayList<Widget>();
|
||||
|
||||
protected Container(ITextComponent title)
|
||||
{
|
||||
@@ -40,8 +41,16 @@ public abstract class Container extends Screen implements IContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Menu menu)
|
||||
public Menu add(Menu menu)
|
||||
{
|
||||
this.menus.add(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Widget addWidget(Widget button)
|
||||
{
|
||||
this.widgetButtons.add(button);
|
||||
return button;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,19 @@ public interface IContainer
|
||||
<T extends Widget> T add(T button);
|
||||
|
||||
void initButtons();
|
||||
void add(Menu menu);
|
||||
Menu add(Menu menu);
|
||||
Widget addWidget(Widget button);
|
||||
|
||||
String getPlayer();
|
||||
void setPlayer(String text);
|
||||
|
||||
Content getContent();
|
||||
|
||||
int getBackgroundX();
|
||||
int getBackgroundY();
|
||||
|
||||
int getBackgroundWidth();
|
||||
int getBackgroundHeight();
|
||||
|
||||
void bindBackground();
|
||||
}
|
||||
|
||||
@@ -1,43 +1,32 @@
|
||||
package exopandora.worldhandler.gui.container.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWorldHandler;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.event.KeyHandler;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTab;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.IContent;
|
||||
import exopandora.worldhandler.gui.menu.IMenu;
|
||||
import exopandora.worldhandler.gui.widget.IContainerWidget;
|
||||
import exopandora.worldhandler.gui.widget.IContainerWidget.EnumLayer;
|
||||
import exopandora.worldhandler.gui.widget.WidgetCommandSyntax;
|
||||
import exopandora.worldhandler.gui.widget.WidgetNameField;
|
||||
import exopandora.worldhandler.gui.widget.WidgetShortcuts;
|
||||
import exopandora.worldhandler.gui.widget.WidgetWatch;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.RenderUtils;
|
||||
import exopandora.worldhandler.util.ResourceHelper;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -45,242 +34,117 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
public class GuiWorldHandler extends Container
|
||||
{
|
||||
private final Content content;
|
||||
private final int tabSize;
|
||||
private final int bgTextureWidth = 248;
|
||||
private final int bgTextureHeight = 166;
|
||||
private final int tabDistance = 2;
|
||||
private final int tabDistanceTotal;
|
||||
private final double tabWidth;
|
||||
private final double tabHalf;
|
||||
private final double tabEpsilon;
|
||||
private final String splash = this.getSplash();
|
||||
private final List<Widget> finalButtons = new ArrayList<Widget>();
|
||||
|
||||
private GuiTextFieldTooltip syntaxField;
|
||||
private GuiTextFieldTooltip nameField;
|
||||
private final List<IContainerWidget> widgets = Util.make(Lists.newArrayList(), widgets ->
|
||||
{
|
||||
widgets.add(new TabRenderer());
|
||||
widgets.add(new WidgetWatch());
|
||||
widgets.add(new WidgetNameField());
|
||||
widgets.add(new WidgetCommandSyntax());
|
||||
widgets.add(new WidgetShortcuts());
|
||||
});
|
||||
|
||||
private static String player = Minecraft.getInstance().getSession().getUsername();
|
||||
|
||||
private static final BuilderWorldHandler BUILDER_WORLD_HANDLER = new BuilderWorldHandler();
|
||||
|
||||
public GuiWorldHandler(Content content) throws Exception
|
||||
{
|
||||
super(content.getTitle());
|
||||
this.content = content;
|
||||
this.tabSize = this.content.getCategory().getSize();
|
||||
this.tabDistanceTotal = Math.max(this.tabSize - 1, 1) * this.tabDistance;
|
||||
this.tabWidth = (this.bgTextureWidth - this.tabDistanceTotal) / Math.max(this.tabSize, 2);
|
||||
this.tabHalf = this.tabWidth / 2D;
|
||||
this.tabEpsilon = this.bgTextureWidth - (this.tabDistanceTotal + this.tabHalf * Math.max(this.tabSize, 2) * 2D);
|
||||
this.content.init(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
ActionHelper.tryRun(() ->
|
||||
{
|
||||
this.finalButtons.clear();
|
||||
this.widgetButtons.clear();
|
||||
this.menus.clear();
|
||||
this.buttons.clear();
|
||||
this.children.clear();
|
||||
|
||||
//INIT
|
||||
this.content.onPlayerNameChanged(this.getPlayer());
|
||||
this.content.initGui(this, this.getContentX(), this.getContentY());
|
||||
final int x = this.getContentX();
|
||||
final int y = this.getContentY();
|
||||
|
||||
//MENUS
|
||||
this.content.onPlayerNameChanged(this.getPlayer());
|
||||
this.content.initGui(this, x, y);
|
||||
|
||||
for(IMenu menu : this.menus)
|
||||
{
|
||||
menu.initGui(this);
|
||||
}
|
||||
|
||||
//SHORTCUTS
|
||||
|
||||
final int x = this.width / 2 - 10;
|
||||
final int delta = 21;
|
||||
|
||||
if(Config.getSettings().shortcuts())
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
this.finalButtons.add(new GuiButtonIcon(x - delta * 7, 0, 20, 20, EnumIcon.TIME_DAWN, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time.dawn", Config.getSettings().getDawn())), ActionHelper::timeDawn));
|
||||
this.finalButtons.add(new GuiButtonIcon(x - delta * 6, 0, 20, 20, EnumIcon.TIME_NOON, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time.noon", Config.getSettings().getNoon())), ActionHelper::timeNoon));
|
||||
this.finalButtons.add(new GuiButtonIcon(x - delta * 5, 0, 20, 20, EnumIcon.TIME_SUNSET, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time.sunset", Config.getSettings().getSunset())), ActionHelper::timeSunset));
|
||||
this.finalButtons.add(new GuiButtonIcon(x - delta * 4, 0, 20, 20, EnumIcon.TIME_MIDNIGHT, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time.midnight", Config.getSettings().getMidnight())), ActionHelper::timeMidnight));
|
||||
this.finalButtons.add(new GuiButtonIcon(x - delta * 3, 0, 20, 20, EnumIcon.WEATHER_SUN, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather.clear")), ActionHelper::weatherClear));
|
||||
this.finalButtons.add(new GuiButtonIcon(x - delta * 2, 0, 20, 20, EnumIcon.WEATHER_RAIN, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather.rainy")), ActionHelper::weatherRain));
|
||||
this.finalButtons.add(new GuiButtonIcon(x - delta * 1, 0, 20, 20, EnumIcon.WEATHER_STORM, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather.thunder")), ActionHelper::weatherThunder));
|
||||
this.finalButtons.add(new GuiButtonIcon(x - delta * 0, 0, 20, 20, EnumIcon.DIFFICULTY_PEACEFUL, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), ActionHelper::difficultyPeaceful));
|
||||
this.finalButtons.add(new GuiButtonIcon(x + delta * 1, 0, 20, 20, EnumIcon.DIFFICULTY_EASY, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), ActionHelper::difficultyEasy));
|
||||
this.finalButtons.add(new GuiButtonIcon(x + delta * 2, 0, 20, 20, EnumIcon.DIFFICULTY_NORMAL, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), ActionHelper::difficultyNormal));
|
||||
this.finalButtons.add(new GuiButtonIcon(x + delta * 3, 0, 20, 20, EnumIcon.DIFFICULTY_HARD, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), ActionHelper::difficultyHard));
|
||||
this.finalButtons.add(new GuiButtonIcon(x + delta * 4, 0, 20, 20, EnumIcon.GAMEMODE_SURVIVAL, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), ActionHelper::gamemodeSurvival));
|
||||
this.finalButtons.add(new GuiButtonIcon(x + delta * 5, 0, 20, 20, EnumIcon.GAMEMODE_CREATIVE, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), ActionHelper::gamemodeCreative));
|
||||
this.finalButtons.add(new GuiButtonIcon(x + delta * 6, 0, 20, 20, EnumIcon.GAMEMODE_ADVENTURE, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), ActionHelper::gamemodeAdventure));
|
||||
this.finalButtons.add(new GuiButtonIcon(x + delta * 7, 0, 20, 20, EnumIcon.GAMEMODE_SPECTATOR, new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), ActionHelper::gamemodeSpectator));
|
||||
if(widget.isEnabled())
|
||||
{
|
||||
widget.initGui(this, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
//SYNTAX
|
||||
|
||||
if(Config.getSettings().commandSyntax())
|
||||
{
|
||||
this.syntaxField = new GuiTextFieldTooltip(x - delta * 7 + 1, this.height - 22, delta * 15 - 3, 20);
|
||||
this.updateSyntax();
|
||||
}
|
||||
|
||||
//NAME
|
||||
|
||||
this.nameField = new GuiTextFieldTooltip(0, 0, 0, 11);
|
||||
this.nameField.setMaxStringLength(16);
|
||||
this.nameField.setText(this.getPlayer());
|
||||
this.nameField.setResponder(text ->
|
||||
{
|
||||
GuiWorldHandler.player = text;
|
||||
this.updateNameField();
|
||||
});
|
||||
this.updateNameField();
|
||||
|
||||
//BUTTONS
|
||||
|
||||
this.forEachTab(this::addTabButtons);
|
||||
this.initButtons();
|
||||
});
|
||||
}
|
||||
|
||||
private void addTabButtons(int index, double xOffset)
|
||||
{
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
IContent tab = this.content.getCategory().getContent(index);
|
||||
|
||||
if(!tab.equals(this.content.getActiveContent()))
|
||||
{
|
||||
this.finalButtons.add(new GuiButtonTab((int) (backgroundX + xOffset), backgroundY - 20, (int) this.tabWidth + (int) Math.ceil(this.tabEpsilon / this.tabSize), 21, tab.getTabTitle())
|
||||
{
|
||||
@Override
|
||||
public void onPress()
|
||||
{
|
||||
ActionHelper.changeTab(GuiWorldHandler.this.content, index);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons()
|
||||
{
|
||||
this.buttons.clear();
|
||||
this.children.clear();
|
||||
this.content.initButtons(this, this.getContentX(), this.getContentY());
|
||||
|
||||
if(this.finalButtons != null && !this.finalButtons.isEmpty())
|
||||
ActionHelper.tryRun(() ->
|
||||
{
|
||||
this.finalButtons.forEach(this::add);
|
||||
}
|
||||
|
||||
if(Config.getSettings().commandSyntax())
|
||||
{
|
||||
this.add(this.syntaxField);
|
||||
}
|
||||
|
||||
this.add(this.nameField);
|
||||
|
||||
for(IMenu menu : this.menus)
|
||||
{
|
||||
menu.initButtons(this);
|
||||
}
|
||||
this.buttons.clear();
|
||||
this.children.clear();
|
||||
this.content.initButtons(this, this.getContentX(), this.getContentY());
|
||||
this.widgetButtons.forEach(this::add);
|
||||
|
||||
int x = this.getContentX();
|
||||
int y = this.getContentY();
|
||||
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
if(widget.isEnabled())
|
||||
{
|
||||
widget.initButtons(this, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
for(IMenu menu : this.menus)
|
||||
{
|
||||
menu.initButtons(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
ActionHelper.tryRun(this::update);
|
||||
}
|
||||
|
||||
private void update()
|
||||
{
|
||||
this.content.tick(this);
|
||||
|
||||
for(IMenu menu : this.menus)
|
||||
ActionHelper.tryRun(() ->
|
||||
{
|
||||
menu.tick();
|
||||
}
|
||||
|
||||
this.updateSyntax();
|
||||
}
|
||||
|
||||
private int getBackgroundX()
|
||||
{
|
||||
return (this.width - this.bgTextureWidth) / 2 + this.getXOffset();
|
||||
}
|
||||
|
||||
private int getBackgroundY()
|
||||
{
|
||||
return (this.height - this.bgTextureHeight) / 2 + this.getYOffset();
|
||||
}
|
||||
|
||||
private int getWatchOffset()
|
||||
{
|
||||
return Config.getSettings().watch() ? 9 : 0;
|
||||
}
|
||||
|
||||
private void forEachTab(BiConsumer<Integer, Double> consumer)
|
||||
{
|
||||
double xOffset = 0D;
|
||||
|
||||
for(int index = 0; index < this.tabSize; index++)
|
||||
{
|
||||
consumer.accept(index, xOffset);
|
||||
xOffset += this.tabWidth + this.tabDistance + this.tabEpsilon / this.tabSize;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSyntax()
|
||||
{
|
||||
if(Config.getSettings().commandSyntax() && this.syntaxField != null)
|
||||
{
|
||||
if(!this.syntaxField.isFocused())
|
||||
this.content.tick(this);
|
||||
|
||||
for(IMenu menu : this.menus)
|
||||
{
|
||||
this.syntaxField.setValidator(Predicates.alwaysTrue());
|
||||
|
||||
if(this.content.getCommandBuilder() != null)
|
||||
{
|
||||
this.syntaxField.setText(this.content.getCommandBuilder().toCommand());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.syntaxField.setText(BUILDER_WORLD_HANDLER.toCommand());
|
||||
}
|
||||
|
||||
this.syntaxField.setValidator(string -> string.equals(this.syntaxField.getText()));
|
||||
this.syntaxField.setCursorPositionZero();
|
||||
menu.tick();
|
||||
}
|
||||
|
||||
this.syntaxField.tick();
|
||||
}
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
if(widget.isEnabled())
|
||||
{
|
||||
widget.tick(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateNameField()
|
||||
@Override
|
||||
public int getBackgroundX()
|
||||
{
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
if(GuiWorldHandler.player.isEmpty())
|
||||
{
|
||||
int width = this.font.getStringWidth(I18n.format("gui.worldhandler.generic.edit_username")) + 2;
|
||||
this.nameField.setWidth(width);
|
||||
this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - (this.font.func_238414_a_(this.content.getTitle()) + 2), backgroundY + 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
int width = this.font.getStringWidth(GuiWorldHandler.player) + 2;
|
||||
this.nameField.setWidth(width);
|
||||
this.nameField.setPosition(backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - width, backgroundY + 6);
|
||||
}
|
||||
|
||||
this.content.onPlayerNameChanged(GuiWorldHandler.player);
|
||||
return (this.width - this.getBackgroundWidth()) / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBackgroundY()
|
||||
{
|
||||
return (this.height - this.getBackgroundHeight()) / 2 + 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -291,115 +155,57 @@ public class GuiWorldHandler extends Container
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
//DEFAULT BACKGROUND
|
||||
|
||||
if(Config.getSkin().drawBackground())
|
||||
{
|
||||
this.setBlitOffset(-1);
|
||||
super.renderBackground(matrix);
|
||||
}
|
||||
|
||||
//COLOR
|
||||
|
||||
this.defaultColor();
|
||||
|
||||
//BACKGROUND
|
||||
RenderSystem.enableBlend();
|
||||
RenderUtils.colorDefaultBackground();
|
||||
|
||||
this.bindBackground();
|
||||
this.blit(matrix, backgroundX, backgroundY, 0, 0, this.bgTextureWidth, this.bgTextureHeight);
|
||||
|
||||
//TABS
|
||||
|
||||
this.setBlitOffset(0);
|
||||
this.forEachTab((index, xOffset) -> this.drawTab(matrix, index, xOffset));
|
||||
this.defaultColor();
|
||||
|
||||
//VERSION LABEL
|
||||
this.blit(matrix, backgroundX, backgroundY, 0, 0, this.getBackgroundWidth(), this.getBackgroundHeight());
|
||||
|
||||
final String label = Main.MC_VERSION + "-" + Main.MOD_VERSION;
|
||||
final int hexAlpha = (int) (0xFF * 0.2) << 24;
|
||||
final int color = Config.getSkin().getLabelColor() + hexAlpha;
|
||||
final int versionWidth = this.width - this.font.getStringWidth(label) - 2;
|
||||
final int versionHeight = this.height - 10;
|
||||
this.font.drawString(matrix, label, versionWidth, versionHeight, Config.getSkin().getLabelColor() + 0x33000000);
|
||||
|
||||
this.font.drawString(matrix, label, versionWidth, versionHeight, color);
|
||||
int x = this.getContentX();
|
||||
int y = this.getContentY();
|
||||
|
||||
//TITLE
|
||||
|
||||
final int maxWidth = this.bgTextureWidth - 7 - 2 - this.font.getStringWidth(GuiWorldHandler.player) - 2 - this.getWatchOffset() - 7;
|
||||
this.font.func_243248_b(matrix, TextUtils.stripText(this.content.getTitle(), maxWidth, this.font), backgroundX + 7, backgroundY + 7, Config.getSkin().getLabelColor());
|
||||
|
||||
//NAME FIELD
|
||||
|
||||
final String username = GuiWorldHandler.player.isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : GuiWorldHandler.player;
|
||||
this.font.drawString(matrix, username, backgroundX + this.bgTextureWidth - this.getWatchOffset() - 7 - this.font.getStringWidth(username), backgroundY + 7, Config.getSkin().getLabelColor());
|
||||
|
||||
//WATCH
|
||||
|
||||
if(Config.getSettings().watch())
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
final int watchX = backgroundX + 233;
|
||||
final int watchY = backgroundY + 5;
|
||||
|
||||
RenderUtils.drawWatchIntoGui(matrix, this, watchX, watchY, Minecraft.getInstance().world.getWorldInfo().getDayTime(), Config.getSettings().smoothWatch());
|
||||
|
||||
if(Config.getSettings().tooltips())
|
||||
if(widget.isEnabled() && EnumLayer.BACKGROUND == widget.getLayer())
|
||||
{
|
||||
if(mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
|
||||
{
|
||||
this.renderTooltip(matrix, new StringTextComponent(TextUtils.formatWorldTime(Minecraft.getInstance().world.getDayTime())), mouseX, mouseY + 9);
|
||||
RenderUtils.disableLighting();
|
||||
}
|
||||
widget.drawScreen(matrix, this, x, y, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
//BUTTONS
|
||||
final int maxWidth = this.getBackgroundWidth() - 18 - this.font.getStringWidth(this.getPlayer()) - (Config.getSettings().watch() ? 9 : 0);
|
||||
this.font.func_243248_b(matrix, TextUtils.stripText(this.content.getTitle(), maxWidth, this.font), backgroundX + 7, backgroundY + 7, Config.getSkin().getLabelColor());
|
||||
|
||||
for(int x = 0; x < this.buttons.size(); x++)
|
||||
for(int i = 0; i < this.buttons.size(); i++)
|
||||
{
|
||||
this.buttons.get(x).render(matrix, mouseX, mouseY, partialTicks);
|
||||
this.buttons.get(i).render(matrix, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
//CONTAINER
|
||||
|
||||
this.content.drawScreen(matrix, this, this.getContentX(), this.getContentY(), mouseX, mouseY, partialTicks);
|
||||
|
||||
//MENUS
|
||||
this.content.drawScreen(matrix, this, x, y, mouseX, mouseY, partialTicks);
|
||||
|
||||
for(IMenu menu : this.menus)
|
||||
{
|
||||
menu.draw(matrix, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
//SYNTAX
|
||||
|
||||
if(Config.getSettings().commandSyntax() && this.syntaxField != null)
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
this.syntaxField.renderButton(matrix, mouseX, mouseY, partialTicks);
|
||||
if(widget.isEnabled() && EnumLayer.FOREGROUND == widget.getLayer())
|
||||
{
|
||||
widget.drawScreen(matrix, this, x, y, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
//SPLASHTEXT
|
||||
|
||||
if(this.splash != null)
|
||||
{
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
RenderUtils.disableLighting();
|
||||
|
||||
matrix.push();
|
||||
matrix.translate((float) (backgroundX + 212), backgroundY + 15, 0.0F);
|
||||
matrix.rotate(new Quaternion(17.0F, 0.0F, 0.0F, 1.0F));
|
||||
|
||||
float scale = 1.1F - MathHelper.abs(MathHelper.sin((float) (System.currentTimeMillis() % 1000L) / 1000.0F * (float) Math.PI * 2.0F) * 0.1F);
|
||||
scale = scale * 100.0F / this.font.getStringWidth(this.splash);
|
||||
matrix.scale(scale, scale, scale);
|
||||
|
||||
AbstractGui.drawCenteredString(matrix, this.font, this.splash, 0, (int) scale, 0xFFFF00);
|
||||
|
||||
matrix.pop();
|
||||
}
|
||||
|
||||
//TOOLTIPS
|
||||
|
||||
if(Config.getSettings().tooltips())
|
||||
{
|
||||
for(Widget button : this.buttons)
|
||||
@@ -411,8 +217,6 @@ public class GuiWorldHandler extends Container
|
||||
}
|
||||
}
|
||||
|
||||
//VERSION LABEL TOOLTIP
|
||||
|
||||
if(mouseX >= versionWidth && mouseY >= versionHeight)
|
||||
{
|
||||
matrix.push();
|
||||
@@ -422,139 +226,34 @@ public class GuiWorldHandler extends Container
|
||||
|
||||
matrix.pop();
|
||||
}
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
});
|
||||
}
|
||||
|
||||
private void drawTab(MatrixStack matrix, int index, double xOffset)
|
||||
{
|
||||
final IContent tab = this.content.getCategory().getContent(index);
|
||||
|
||||
final int backgroundX = this.getBackgroundX();
|
||||
final int backgroundY = this.getBackgroundY();
|
||||
|
||||
int yOffset;
|
||||
int fHeight;
|
||||
int color;
|
||||
|
||||
if(this.content.getActiveContent().equals(tab))
|
||||
{
|
||||
yOffset = -22;
|
||||
fHeight = 25;
|
||||
color = 0xFFFFFF;
|
||||
this.defaultColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
yOffset = -20;
|
||||
fHeight = 20;
|
||||
color = 0xE0E0E0;
|
||||
this.darkColor();
|
||||
}
|
||||
|
||||
this.bindBackground();
|
||||
this.setBlitOffset(-1);
|
||||
this.blit(matrix, (int) (backgroundX + xOffset), (int) (backgroundY + yOffset), 0, 0, (int) Math.ceil(this.tabHalf), fHeight);
|
||||
this.blit(matrix, (int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY + yOffset), this.bgTextureWidth - (int) Math.floor(this.tabHalf + 1), 0, (int) Math.floor(this.tabHalf + 1), fHeight);
|
||||
|
||||
if(!Config.getSkin().sharpEdges())
|
||||
{
|
||||
if(this.content.getActiveContent().equals(tab))
|
||||
{
|
||||
//RIGHT TAB CURVATURE
|
||||
|
||||
if(index < this.tabSize - 1 || this.tabSize == 1)
|
||||
{
|
||||
int factor = 2;
|
||||
|
||||
for(int x = 0; x < factor; x++)
|
||||
{
|
||||
this.blit(matrix, (int) (backgroundX + xOffset - x - 1 + Math.floor(this.tabHalf + 1) + this.tabHalf), (int) (backgroundY + x + 1), (int) (this.tabWidth - x - 1), x + 1, x + 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//LEFT TAB CURVATURE
|
||||
|
||||
if(index > 0)
|
||||
{
|
||||
int factor = 2;
|
||||
|
||||
for(int x = 0; x < factor; x++)
|
||||
{
|
||||
this.blit(matrix, (int) (backgroundX + xOffset), (int) (backgroundY + x + 1), (int) xOffset, x + 1, x + 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int width = (int)(this.tabWidth - 3);
|
||||
int interval = 5;
|
||||
|
||||
//LEFT GRADIENT
|
||||
|
||||
if(index == 0)
|
||||
{
|
||||
for(int x = 0; x < width; x += interval)
|
||||
{
|
||||
this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
|
||||
this.blit(matrix, (int) (backgroundX + xOffset), (int) (backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//RIGHT GRADIENT
|
||||
|
||||
if(index == this.tabSize - 1 && this.tabSize > 1)
|
||||
{
|
||||
int offset = 3;
|
||||
|
||||
for(int x = 0; x < width; x += interval)
|
||||
{
|
||||
this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
|
||||
this.blit(matrix, (int) (backgroundX + Math.ceil(xOffset) + x + offset), (int) (backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//LEFT CORNER FILLER
|
||||
|
||||
if(index == 0)
|
||||
{
|
||||
int factor = 2;
|
||||
|
||||
for(int x = 0; x < factor; x++)
|
||||
{
|
||||
this.blit(matrix, backgroundX, backgroundY + x, 0, fHeight, factor - x, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//RIGHT CORNER FILLER
|
||||
|
||||
if(index == this.tabSize - 1)
|
||||
{
|
||||
int factor = 3;
|
||||
|
||||
for(int x = 0; x < factor + 1; x++)
|
||||
{
|
||||
this.blit(matrix, backgroundX + this.bgTextureWidth - x, backgroundY + factor - x, this.bgTextureWidth - x, fHeight, x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setBlitOffset(0);
|
||||
AbstractGui.drawCenteredString(matrix, this.font, TextUtils.stripText(tab.getTabTitle().mergeStyle(TextFormatting.UNDERLINE), (int) this.tabWidth, this.font), (int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY - 13), color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(double xPos, double mouseY)
|
||||
{
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
if(widget.isEnabled())
|
||||
{
|
||||
widget.mouseMoved(xPos, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
this.content.mouseMoved(xPos, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int keyCode)
|
||||
{
|
||||
if(this.nameField.isFocused())
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
this.nameField.setCursorPositionEnd();
|
||||
if(widget.isEnabled() && widget.mouseClicked(mouseX, mouseY, keyCode))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.content.mouseClicked(mouseX, mouseY, keyCode))
|
||||
@@ -568,6 +267,14 @@ public class GuiWorldHandler extends Container
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int keyCode)
|
||||
{
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
if(widget.isEnabled() && widget.mouseReleased(mouseX, mouseY, keyCode))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.content.mouseReleased(mouseX, mouseY, keyCode))
|
||||
{
|
||||
return true;
|
||||
@@ -579,6 +286,14 @@ public class GuiWorldHandler extends Container
|
||||
@Override
|
||||
public boolean mouseDragged(double mouseX, double mouseY, int keyCode, double deltaX, double deltaY)
|
||||
{
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
if(widget.isEnabled() && widget.mouseDragged(mouseX, mouseY, keyCode, deltaX, deltaY))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.content.mouseDragged(mouseX, mouseY, keyCode, deltaX, deltaY))
|
||||
{
|
||||
return true;
|
||||
@@ -590,6 +305,14 @@ public class GuiWorldHandler extends Container
|
||||
@Override
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double distance)
|
||||
{
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
if(widget.isEnabled() && widget.mouseScrolled(mouseX, mouseY, distance))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.content.mouseScrolled(mouseX, mouseY, distance))
|
||||
{
|
||||
return true;
|
||||
@@ -614,6 +337,14 @@ public class GuiWorldHandler extends Container
|
||||
return true;
|
||||
}
|
||||
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
if(widget.isEnabled() && widget.keyPressed(keyCode, scanCode, modifiers))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.content.keyPressed(keyCode, scanCode, modifiers))
|
||||
{
|
||||
return true;
|
||||
@@ -625,6 +356,14 @@ public class GuiWorldHandler extends Container
|
||||
@Override
|
||||
public boolean keyReleased(int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
if(widget.isEnabled() && widget.keyReleased(keyCode, scanCode, modifiers))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.content.keyReleased(keyCode, scanCode, modifiers))
|
||||
{
|
||||
return true;
|
||||
@@ -636,9 +375,12 @@ public class GuiWorldHandler extends Container
|
||||
@Override
|
||||
public boolean charTyped(char charTyped, int keyCode)
|
||||
{
|
||||
if(this.nameField.isFocused())
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
this.nameField.setCursorPositionEnd();
|
||||
if(widget.isEnabled() && widget.charTyped(charTyped, keyCode))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.content.charTyped(charTyped, keyCode))
|
||||
@@ -652,6 +394,14 @@ public class GuiWorldHandler extends Container
|
||||
@Override
|
||||
public boolean changeFocus(boolean focus)
|
||||
{
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
if(widget.isEnabled() && widget.changeFocus(focus))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.content.changeFocus(focus))
|
||||
{
|
||||
return true;
|
||||
@@ -663,6 +413,14 @@ public class GuiWorldHandler extends Container
|
||||
@Override
|
||||
public boolean isMouseOver(double mouseX, double mouseY)
|
||||
{
|
||||
for(IContainerWidget widget : this.widgets)
|
||||
{
|
||||
if(widget.isEnabled() && widget.isMouseOver(mouseX, mouseY))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.content.isMouseOver(mouseX, mouseY))
|
||||
{
|
||||
return true;
|
||||
@@ -671,28 +429,6 @@ public class GuiWorldHandler extends Container
|
||||
return super.isMouseOver(mouseX, mouseY);
|
||||
}
|
||||
|
||||
private void defaultColor()
|
||||
{
|
||||
this.defaultColor(1.0F);
|
||||
}
|
||||
|
||||
private void defaultColor(float alpha)
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
RenderUtils.color(Config.getSkin().getBackgroundRedF(), Config.getSkin().getBackgroundGreenF(), Config.getSkin().getBackgroundBlueF(), alpha * Config.getSkin().getBackgroundAlphaF());
|
||||
}
|
||||
|
||||
private void darkColor()
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
RenderUtils.color(Config.getSkin().getBackgroundRedF() - 0.3F, Config.getSkin().getBackgroundGreenF() - 0.3F, Config.getSkin().getBackgroundBlueF() - 0.3F, Config.getSkin().getBackgroundAlphaF());
|
||||
}
|
||||
|
||||
private void bindBackground()
|
||||
{
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getBackgroundTexture());
|
||||
}
|
||||
|
||||
private int getContentX()
|
||||
{
|
||||
return this.getBackgroundX() + 8;
|
||||
@@ -703,48 +439,10 @@ public class GuiWorldHandler extends Container
|
||||
return this.getBackgroundY() + 33;
|
||||
}
|
||||
|
||||
private int getXOffset()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getYOffset()
|
||||
{
|
||||
return Config.getSettings().shortcuts() ? 11 : 8;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getSplash()
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
int month = calendar.get(Calendar.MONTH) + 1;
|
||||
|
||||
if(day == 12 && month == 24)
|
||||
{
|
||||
return "Merry X-mas!";
|
||||
}
|
||||
else if(day == 1 && month == 1)
|
||||
{
|
||||
return "Happy new year!";
|
||||
}
|
||||
else if(day == 10 && month == 31)
|
||||
{
|
||||
return "OOoooOOOoooo! Spooky!";
|
||||
}
|
||||
else if(day == 3 && month == 28)
|
||||
{
|
||||
return (calendar.get(Calendar.YEAR) - 2013) + " Years of World Handler!";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose()
|
||||
{
|
||||
ActionHelper.tryRun(this.content::onGuiClosed);
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -759,6 +457,12 @@ public class GuiWorldHandler extends Container
|
||||
return GuiWorldHandler.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
GuiWorldHandler.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getContent()
|
||||
{
|
||||
@@ -770,4 +474,22 @@ public class GuiWorldHandler extends Container
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBackgroundWidth()
|
||||
{
|
||||
return 248;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBackgroundHeight()
|
||||
{
|
||||
return 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindBackground()
|
||||
{
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.backgroundTexture());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package exopandora.worldhandler.gui.container.impl;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.widget.IContainerWidget;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTab;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.RenderUtils;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class TabRenderer implements IContainerWidget
|
||||
{
|
||||
private static final int SPACING = 2;
|
||||
private static final int WEDGE_HEIGHT = 10;
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
Content content = container.getContent();
|
||||
Category category = content.getCategory();
|
||||
|
||||
int xPos = container.getBackgroundX();
|
||||
int yPos = container.getBackgroundY() - 20;
|
||||
|
||||
int size = category.getSize();
|
||||
|
||||
for(int index = 0; index < size; index++)
|
||||
{
|
||||
Content tab = category.getContent(index);
|
||||
|
||||
if(!tab.equals(content.getActiveContent()))
|
||||
{
|
||||
int width = TabRenderer.width(container, index, size);
|
||||
int offset = TabRenderer.offset(container, index, size);
|
||||
|
||||
container.addWidget(new GuiButtonTab(xPos + offset, yPos, width, 21, tab.getTabTitle(), () -> ActionHelper.open(tab)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(MatrixStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
Content content = container.getContent();
|
||||
Category category = content.getCategory();
|
||||
|
||||
int xPos = container.getBackgroundX();
|
||||
int yPos = container.getBackgroundY();
|
||||
|
||||
int size = category.getSize();
|
||||
|
||||
container.setBlitOffset(0);
|
||||
|
||||
for(int index = 0; index < size; index++)
|
||||
{
|
||||
int width = TabRenderer.width(container, index, size);
|
||||
int offset = TabRenderer.offset(container, index, size);
|
||||
|
||||
Content tab = category.getContent(index);
|
||||
ITextComponent title = TextUtils.stripText(tab.getTabTitle().mergeStyle(TextFormatting.UNDERLINE), width, Minecraft.getInstance().fontRenderer);
|
||||
|
||||
if(content.getActiveContent().equals(tab))
|
||||
{
|
||||
this.drawActiveTab(matrix, container, index, size, xPos + offset, yPos - 22, width, 25, title);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawInactiveTab(matrix, container, index, size, xPos + offset, yPos - 20, width, 20, title);
|
||||
}
|
||||
}
|
||||
|
||||
RenderUtils.colorDefaultBackground();
|
||||
}
|
||||
|
||||
private void drawActiveTab(MatrixStack matrix, Container container, int index, int size, int x, int y, int width, int height, ITextComponent title)
|
||||
{
|
||||
RenderUtils.colorDefaultBackground();
|
||||
this.drawTabBackground(matrix, container, x, y, width, height);
|
||||
|
||||
if(!Config.getSkin().sharpEdges())
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
if(index > 0)
|
||||
{
|
||||
RenderUtils.drawTexturedTriangleBL(matrix, container, x, y + height - 2, x - container.getBackgroundX(), 1, 2);
|
||||
}
|
||||
|
||||
if(index < size - 1 || size == 1)
|
||||
{
|
||||
RenderUtils.drawTexturedTriangleBR(matrix, container, x + width - 2, y + height - 2, x - container.getBackgroundX() + width, 1, 2);
|
||||
}
|
||||
|
||||
if(index == 0)
|
||||
{
|
||||
RenderUtils.drawTexturedWedgeGradientTL(matrix, container, x, y + height, 0, height, width, TabRenderer.WEDGE_HEIGHT);
|
||||
}
|
||||
|
||||
if(index == size - 1 && size > 1)
|
||||
{
|
||||
RenderUtils.drawTexturedWedgeGradientTR(matrix, container, x, y + height, x - container.getBackgroundX(), height, width, TabRenderer.WEDGE_HEIGHT);
|
||||
}
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
this.drawTabTitle(matrix, container, title, x + width / 2, y + 9, 0xFFFFFF);
|
||||
}
|
||||
|
||||
private void drawInactiveTab(MatrixStack matrix, Container container, int index, int size, int x, int y, int width, int height, ITextComponent title)
|
||||
{
|
||||
RenderUtils.colorDarkBackground();
|
||||
this.drawTabBackground(matrix, container, x, y, width, 20);
|
||||
|
||||
if(!Config.getSkin().sharpEdges())
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
if(index == 0)
|
||||
{
|
||||
RenderUtils.drawTexturedTriangleTL(matrix, container, x, y + height, 0, height, 2);
|
||||
}
|
||||
|
||||
if(index == size - 1)
|
||||
{
|
||||
RenderUtils.drawTexturedTriangleTR(matrix, container, x + width - 3, y + height, container.getBackgroundWidth() - 3, height, 3);
|
||||
}
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
this.drawTabTitle(matrix, container, title, x + width / 2, y + 7, 0xE0E0E0);
|
||||
}
|
||||
|
||||
private void drawTabBackground(MatrixStack matrix, Container container, int x, int y, int width, int height)
|
||||
{
|
||||
container.bindBackground();
|
||||
container.setBlitOffset(-1);
|
||||
|
||||
int left = MathHelper.ceil(width / 2D);
|
||||
int right = MathHelper.floor(width / 2D);
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
container.blit(matrix, x, y, 0, 0, left, height);
|
||||
container.blit(matrix, x + left, y, container.getBackgroundWidth() - right, 0, right, height);
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
private void drawTabTitle(MatrixStack matrix, AbstractGui gui, ITextComponent title, int x, int y, int color)
|
||||
{
|
||||
gui.setBlitOffset(0);
|
||||
AbstractGui.drawCenteredString(matrix, Minecraft.getInstance().fontRenderer, title, x, y, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumLayer getLayer()
|
||||
{
|
||||
return EnumLayer.BACKGROUND;
|
||||
}
|
||||
|
||||
private static int width(Container container, int index, int size)
|
||||
{
|
||||
int adjust = 0;
|
||||
|
||||
if(index == 1 && size == 3)
|
||||
{
|
||||
adjust = 1;
|
||||
}
|
||||
|
||||
return (int) Math.round((container.getBackgroundWidth() - Math.max(size - 1, 1) * TabRenderer.SPACING) / Math.max(size, 2)) + adjust;
|
||||
}
|
||||
|
||||
private static int offset(Container container, int index, int size)
|
||||
{
|
||||
return (int) Math.round(index * (double) (container.getBackgroundWidth() + TabRenderer.SPACING) / size);
|
||||
}
|
||||
}
|
||||
@@ -3,46 +3,16 @@ package exopandora.worldhandler.gui.content;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import exopandora.worldhandler.gui.widget.IWidget;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface IContent extends IGuiEventListener
|
||||
public interface IContent extends IWidget
|
||||
{
|
||||
default void init(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void initGui(Container container, int x, int y)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void initButtons(Container container, int x, int y);
|
||||
|
||||
default void tick(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void drawScreen(MatrixStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void onPlayerNameChanged(String username)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Category getCategory();
|
||||
|
||||
IFormattableTextComponent getTitle();
|
||||
|
||||
@@ -8,9 +8,6 @@ import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumActionType;
|
||||
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumMode;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
@@ -20,6 +17,9 @@ import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicMapped;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.AdvancementHelper;
|
||||
|
||||
@@ -10,14 +10,14 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderButcher;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -3,9 +3,9 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
|
||||
@@ -4,11 +4,11 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.entity.EntityType;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.gui.DummyScreen;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.IConnection;
|
||||
import exopandora.worldhandler.util.IConnection.DedicatedConnection;
|
||||
|
||||
@@ -19,12 +19,12 @@ import exopandora.worldhandler.builder.types.BlockResourceLocation;
|
||||
import exopandora.worldhandler.builder.types.Coordinate.EnumType;
|
||||
import exopandora.worldhandler.builder.types.CoordinateDouble;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.widget.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -5,13 +5,13 @@ import exopandora.worldhandler.builder.impl.BuilderSetBlock;
|
||||
import exopandora.worldhandler.builder.types.Coordinate.EnumType;
|
||||
import exopandora.worldhandler.builder.types.CoordinateInt;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonItem;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonItem;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.ICommandBuilderSyntax;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -9,11 +9,6 @@ import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentAttribute;
|
||||
import exopandora.worldhandler.builder.impl.BuilderCustomItem;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.button.LogicSliderAttribute;
|
||||
import exopandora.worldhandler.gui.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
@@ -22,6 +17,11 @@ import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuColorField;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderAttribute;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
|
||||
@@ -13,15 +13,15 @@ import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask;
|
||||
import exopandora.worldhandler.builder.impl.BuilderFill;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWH;
|
||||
import exopandora.worldhandler.command.CommandWH.StringBlockPredicateArgument;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicMapped;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
|
||||
@@ -4,10 +4,6 @@ import java.util.ArrayList;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderEnchantment;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
@@ -15,6 +11,10 @@ import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
|
||||
@@ -3,15 +3,15 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderExperience;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
|
||||
@@ -11,9 +11,6 @@ import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderGamerule;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
@@ -21,6 +18,9 @@ import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
|
||||
@@ -2,15 +2,15 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
|
||||
import exopandora.worldhandler.Main;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.widget.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.OptionsScreen;
|
||||
|
||||
@@ -10,17 +10,17 @@ import exopandora.worldhandler.builder.impl.BuilderPlayer;
|
||||
import exopandora.worldhandler.builder.impl.BuilderPlayerReason;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWhitelist;
|
||||
import exopandora.worldhandler.builder.impl.BuilderWhitelist.EnumMode;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.widget.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -7,14 +7,14 @@ import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderNoteEditor;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.event.KeyHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonPiano;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonPiano.Type;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonPiano;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonPiano.Type;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
|
||||
@@ -8,14 +8,14 @@ import exopandora.worldhandler.builder.impl.BuilderGeneric;
|
||||
import exopandora.worldhandler.builder.impl.BuilderMultiCommand;
|
||||
import exopandora.worldhandler.builder.impl.BuilderPlayer;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSpawnpoint;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.RenderUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -7,13 +7,13 @@ import exopandora.worldhandler.builder.impl.BuilderMultiCommand;
|
||||
import exopandora.worldhandler.builder.impl.BuilderPotionEffect;
|
||||
import exopandora.worldhandler.builder.impl.BuilderPotionItem;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
|
||||
@@ -6,8 +6,6 @@ import java.util.stream.Collectors;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderRecipe;
|
||||
import exopandora.worldhandler.builder.impl.BuilderRecipe.EnumMode;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
@@ -15,6 +13,8 @@ import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
|
||||
@@ -11,13 +11,13 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardObjectives;
|
||||
import exopandora.worldhandler.builder.impl.BuilderScoreboardObjectives.EnumMode;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicButtonList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import exopandora.worldhandler.util.RegistryHelper;
|
||||
|
||||
@@ -10,14 +10,14 @@ import exopandora.worldhandler.builder.impl.BuilderScoreboardPlayers.EnumMode;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTag;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTrigger;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
|
||||
@@ -9,13 +9,13 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTeams;
|
||||
import exopandora.worldhandler.builder.impl.BuilderTeams.EnumMode;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicButtonList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
@@ -8,14 +8,14 @@ import java.util.function.Supplier;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSettings.Setting.BooleanSetting;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentSettings.Setting.IntegerSetting;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
|
||||
@@ -8,8 +8,6 @@ import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSignEditor;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.event.KeyHandler;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
@@ -17,6 +15,8 @@ import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicColorMenu;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuColorField;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.BlockHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
|
||||
@@ -12,14 +12,6 @@ import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentAttribute;
|
||||
import exopandora.worldhandler.builder.impl.BuilderSummon;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonItem;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.button.LogicSliderAttribute;
|
||||
import exopandora.worldhandler.gui.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
@@ -27,6 +19,14 @@ import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonItem;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderAttribute;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.CommandHelper;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@@ -55,9 +56,9 @@ public class ContentUsercontent extends Content
|
||||
private final List<VisibleObject<BuilderUsercontent>> builders;
|
||||
private final Map<String, VisibleActiveObject<TextFieldWidget>> textfields = new HashMap<String, VisibleActiveObject<TextFieldWidget>>();
|
||||
private final List<VisibleActiveObject<Widget>> buttons = new ArrayList<VisibleActiveObject<Widget>>();
|
||||
private UsercontentAPI api;
|
||||
private ButtonFactory buttonFactory;
|
||||
private MenuFactory menuFactory;
|
||||
private final UsercontentAPI api;
|
||||
private final ButtonFactory buttonFactory;
|
||||
private final MenuFactory menuFactory;
|
||||
|
||||
public ContentUsercontent(UsercontentConfig config) throws Exception
|
||||
{
|
||||
@@ -66,7 +67,7 @@ public class ContentUsercontent extends Content
|
||||
this.engineAdapter = new ScriptEngineAdapter(config.getScriptEngine());
|
||||
this.builders = this.createBuilders(this.content.getModel());
|
||||
this.api = new UsercontentAPI(this.builders.stream().map(VisibleObject::getObject).collect(Collectors.toList()));
|
||||
ActionHandlerFactory actionHandlerFactory = new ActionHandlerFactory(this.api,this. builders, this.engineAdapter);
|
||||
ActionHandlerFactory actionHandlerFactory = new ActionHandlerFactory(this.api, this.builders, this.engineAdapter);
|
||||
this.buttonFactory = new ButtonFactory(this.api, actionHandlerFactory);
|
||||
this.menuFactory = new MenuFactory(this.api, actionHandlerFactory);
|
||||
this.engineAdapter.addObject("api", this.api);
|
||||
@@ -117,8 +118,7 @@ public class ContentUsercontent extends Content
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
this.textfields.values().stream().map(VisibleObject::getObject).forEach(container::add);
|
||||
this.buttons.stream().map(VisibleObject::getObject).forEach(container::add);
|
||||
Stream.concat(this.textfields.values().stream(), this.buttons.stream()).map(VisibleObject::getObject).forEach(container::add);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,13 +4,13 @@ import java.util.function.Function;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.category.Categories;
|
||||
import exopandora.worldhandler.gui.category.Category;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.content.Contents;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package exopandora.worldhandler.gui.menu.impl;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
@@ -9,11 +9,11 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList.Persistence;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.menu.Menu;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonList.Persistence;
|
||||
import exopandora.worldhandler.util.Node;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.menu.Menu;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.util.MutableStringTextComponent;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
@@ -6,9 +6,9 @@ import java.util.Objects;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.menu.Menu;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package exopandora.worldhandler.gui.widget;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface IContainerWidget extends IWidget
|
||||
{
|
||||
default boolean isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
EnumLayer getLayer();
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static enum EnumLayer
|
||||
{
|
||||
BACKGROUND,
|
||||
FOREGROUND;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package exopandora.worldhandler.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public interface IWidget extends IGuiEventListener
|
||||
{
|
||||
default void init(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void initGui(Container container, int x, int y)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void initButtons(Container container, int x, int y)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void tick(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void drawScreen(MatrixStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
default void onPlayerNameChanged(String username)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package exopandora.worldhandler.gui.widget;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.builder.impl.BuilderWorldHandler;
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class WidgetCommandSyntax implements IContainerWidget
|
||||
{
|
||||
private static final BuilderWorldHandler BUILDER_WORLD_HANDLER = new BuilderWorldHandler();
|
||||
|
||||
private GuiTextFieldTooltip syntaxField;
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.syntaxField = new GuiTextFieldTooltip(container.width / 2 - 156, container.height - 22, 312, 20);
|
||||
this.updateSyntax(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(this.syntaxField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(Container container)
|
||||
{
|
||||
this.updateSyntax(container);
|
||||
|
||||
if(this.syntaxField != null)
|
||||
{
|
||||
this.syntaxField.tick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(MatrixStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if(this.syntaxField != null)
|
||||
{
|
||||
this.syntaxField.renderButton(matrix, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSyntax(Container container)
|
||||
{
|
||||
if(this.syntaxField != null && !this.syntaxField.isFocused())
|
||||
{
|
||||
this.syntaxField.setValidator(Predicates.alwaysTrue());
|
||||
|
||||
if(container.getContent().getCommandBuilder() != null)
|
||||
{
|
||||
this.syntaxField.setText(container.getContent().getCommandBuilder().toCommand());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.syntaxField.setText(BUILDER_WORLD_HANDLER.toCommand());
|
||||
}
|
||||
|
||||
this.syntaxField.setValidator(string -> string.equals(this.syntaxField.getText()));
|
||||
this.syntaxField.setCursorPositionZero();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return Config.getSettings().commandSyntax();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumLayer getLayer()
|
||||
{
|
||||
return EnumLayer.FOREGROUND;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package exopandora.worldhandler.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class WidgetNameField implements IContainerWidget
|
||||
{
|
||||
private final GuiTextFieldTooltip nameField = Util.make(new GuiTextFieldTooltip(0, 0, 0, 11), textfield -> textfield.setMaxStringLength(16));
|
||||
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
this.nameField.setText(container.getPlayer());
|
||||
this.nameField.setResponder(text ->
|
||||
{
|
||||
container.setPlayer(text);
|
||||
this.updateNameField(container);
|
||||
});
|
||||
this.updateNameField(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initButtons(Container container, int x, int y)
|
||||
{
|
||||
container.add(this.nameField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(MatrixStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
String username = container.getPlayer().isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : container.getPlayer();
|
||||
|
||||
int xPos = container.getBackgroundX() + container.getBackgroundWidth() - this.watchOffset() - 7 - Minecraft.getInstance().fontRenderer.getStringWidth(username);
|
||||
int yPos = container.getBackgroundY() + 7;
|
||||
|
||||
Minecraft.getInstance().fontRenderer.drawString(matrix, username, xPos, yPos, Config.getSkin().getLabelColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int keyCode)
|
||||
{
|
||||
if(this.nameField.isFocused())
|
||||
{
|
||||
this.nameField.setCursorPositionEnd();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char charTyped, int keyCode)
|
||||
{
|
||||
if(this.nameField.isFocused())
|
||||
{
|
||||
this.nameField.setCursorPositionEnd();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private int watchOffset()
|
||||
{
|
||||
return Config.getSettings().watch() ? 9 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumLayer getLayer()
|
||||
{
|
||||
return EnumLayer.BACKGROUND;
|
||||
}
|
||||
|
||||
private void updateNameField(Container container)
|
||||
{
|
||||
final FontRenderer font = Minecraft.getInstance().fontRenderer;
|
||||
|
||||
int x = container.getBackgroundX() + container.getBackgroundWidth() - this.watchOffset() - 7;
|
||||
int y = container.getBackgroundY() + 6;
|
||||
|
||||
if(container.getPlayer().isEmpty())
|
||||
{
|
||||
int width = font.getStringWidth(I18n.format("gui.worldhandler.generic.edit_username")) + 2;
|
||||
this.nameField.setWidth(width);
|
||||
this.nameField.setPosition(x - (font.func_238414_a_(container.getContent().getTitle()) + 2), y);
|
||||
}
|
||||
else
|
||||
{
|
||||
int width = font.getStringWidth(container.getPlayer()) + 2;
|
||||
this.nameField.setWidth(width);
|
||||
this.nameField.setPosition(x - width, y);
|
||||
}
|
||||
|
||||
container.getContent().onPlayerNameChanged(container.getPlayer());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package exopandora.worldhandler.gui.widget;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.widget.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import exopandora.worldhandler.util.ActionHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class WidgetShortcuts implements IContainerWidget
|
||||
{
|
||||
@Override
|
||||
public void initGui(Container container, int x, int y)
|
||||
{
|
||||
int start = container.width / 2 - 157;
|
||||
EnumShortcuts shortcuts[] = EnumShortcuts.values();
|
||||
|
||||
for(int i = 0; i < shortcuts.length; i++)
|
||||
{
|
||||
EnumShortcuts shortcut = shortcuts[i];
|
||||
container.addWidget(new GuiButtonIcon(start + i * 21, 0, 20, 20, shortcut.getIcon(), shortcut.getTextSupplier().get(), shortcut.getActionHandler()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return Config.getSettings().shortcuts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumLayer getLayer()
|
||||
{
|
||||
return EnumLayer.FOREGROUND;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static enum EnumShortcuts
|
||||
{
|
||||
TIME_DAWN(EnumIcon.TIME_DAWN, ActionHelper::timeDawn, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time.dawn", Config.getSettings().getDawn()));
|
||||
}),
|
||||
TIME_NOON(EnumIcon.TIME_NOON, ActionHelper::timeNoon, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time.noon", Config.getSettings().getNoon()));
|
||||
}),
|
||||
TIME_SUNSET(EnumIcon.TIME_SUNSET, ActionHelper::timeSunset, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time.sunset", Config.getSettings().getSunset()));
|
||||
}),
|
||||
TIME_MIDNIGHT(EnumIcon.TIME_MIDNIGHT, ActionHelper::timeMidnight, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.time.midnight", Config.getSettings().getMidnight()));
|
||||
}),
|
||||
WEATHER_SUN(EnumIcon.WEATHER_SUN, ActionHelper::weatherClear, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather.clear"));
|
||||
}),
|
||||
WEATHER_RAIN(EnumIcon.WEATHER_RAIN, ActionHelper::weatherRain, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather.rainy"));
|
||||
}),
|
||||
WEATHER_STORM(EnumIcon.WEATHER_STORM, ActionHelper::weatherThunder, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.weather.thunder"));
|
||||
}),
|
||||
DIFFICULTY_PEACEFUL(EnumIcon.DIFFICULTY_PEACEFUL, ActionHelper::difficultyPeaceful, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful"));
|
||||
}),
|
||||
DIFFICULTY_EASY(EnumIcon.DIFFICULTY_EASY, ActionHelper::difficultyEasy, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty.easy"));
|
||||
}),
|
||||
DIFFICULTY_NORMAL(EnumIcon.DIFFICULTY_NORMAL, ActionHelper::difficultyNormal, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty.normal"));
|
||||
}),
|
||||
DIFFICULTY_HARD(EnumIcon.DIFFICULTY_HARD, ActionHelper::difficultyHard, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.difficulty.hard"));
|
||||
}),
|
||||
GAMEMODE_SURVIVAL(EnumIcon.GAMEMODE_SURVIVAL, ActionHelper::gamemodeSurvival, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode.survival"));
|
||||
}),
|
||||
GAMEMODE_CREATIVE(EnumIcon.GAMEMODE_CREATIVE, ActionHelper::gamemodeCreative, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode.creative"));
|
||||
}),
|
||||
GAMEMODE_ADVENTURE(EnumIcon.GAMEMODE_ADVENTURE, ActionHelper::gamemodeAdventure, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode.adventure"));
|
||||
}),
|
||||
GAMEMODE_SPECTATOR(EnumIcon.GAMEMODE_SPECTATOR, ActionHelper::gamemodeSpectator, () ->
|
||||
{
|
||||
return new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode", new TranslationTextComponent("gui.worldhandler.shortcuts.tooltip.gamemode.spectator"));
|
||||
});
|
||||
|
||||
private final EnumIcon icon;
|
||||
private final Supplier<ITextComponent> text;
|
||||
private final ActionHandler actionHandler;
|
||||
|
||||
private EnumShortcuts(EnumIcon icon, ActionHandler actionHandler, Supplier<ITextComponent> text)
|
||||
{
|
||||
this.icon = icon;
|
||||
this.text = text;
|
||||
this.actionHandler = actionHandler;
|
||||
}
|
||||
|
||||
public EnumIcon getIcon()
|
||||
{
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
public Supplier<ITextComponent> getTextSupplier()
|
||||
{
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public ActionHandler getActionHandler()
|
||||
{
|
||||
return this.actionHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package exopandora.worldhandler.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.util.RenderUtils;
|
||||
import exopandora.worldhandler.util.TextUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class WidgetWatch implements IContainerWidget
|
||||
{
|
||||
@Override
|
||||
public void drawScreen(MatrixStack matrix, Container container, int x, int y, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
final int watchX = container.getBackgroundX() + 233;
|
||||
final int watchY = container.getBackgroundY() + 5;
|
||||
|
||||
RenderUtils.drawWatchIntoGui(matrix, container, watchX, watchY, Minecraft.getInstance().world.getWorldInfo().getDayTime(), Config.getSettings().smoothWatch());
|
||||
|
||||
if(Config.getSettings().tooltips())
|
||||
{
|
||||
if(mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
|
||||
{
|
||||
container.renderTooltip(matrix, new StringTextComponent(TextUtils.formatWorldTime(Minecraft.getInstance().world.getDayTime())), mouseX, mouseY + 9);
|
||||
RenderUtils.disableLighting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return Config.getSettings().watch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumLayer getLayer()
|
||||
{
|
||||
return EnumLayer.BACKGROUND;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
@@ -34,10 +34,10 @@ public class GuiButtonBase extends Button
|
||||
protected void renderBg(MatrixStack matrix, Minecraft minecraft, int mouseX, int mouseY)
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
RenderUtils.color(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
|
||||
RenderUtils.colorDefaultButton();
|
||||
|
||||
int hovered = this.getYImage(this.isHovered());
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getButtonTexture());
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.buttonTexture());
|
||||
|
||||
int hWidth = this.width / 2;
|
||||
int hHeight = this.height / 2;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class GuiButtonIcon extends GuiButtonTooltip
|
||||
|
||||
private void renderIcon(MatrixStack matrix)
|
||||
{
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getIconTexture());
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.iconTexture());
|
||||
|
||||
if(this.active)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import exopandora.worldhandler.util.ActionHandler;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.gui.widget.button.AbstractButton;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class GuiButtonTab extends AbstractButton
|
||||
public class GuiButtonTab extends GuiButtonBase
|
||||
{
|
||||
public GuiButtonTab(int x, int y, int widthIn, int heightIn, ITextComponent narration)
|
||||
public GuiButtonTab(int x, int y, int widthIn, int heightIn, ITextComponent narration, ActionHandler actionHandler)
|
||||
{
|
||||
super(x, y, widthIn, heightIn, narration);
|
||||
super(x, y, widthIn, heightIn, narration, actionHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack p_230430_1_, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(MatrixStack matrix, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class GuiSlider extends GuiButtonBase
|
||||
int textureOffset = (Config.getSkin().getTextureType().equals("resourcepack") ? 46 : 0) + hovered * 20;
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderUtils.color(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
|
||||
RenderUtils.colorDefaultButton();
|
||||
|
||||
this.blit(matrix, this.x + (int) (this.persistence.getValue() * (float) (this.width - 8)), this.y, 0, textureOffset, 4, 20);
|
||||
this.blit(matrix, this.x + (int) (this.persistence.getValue() * (float) (this.width - 8)) + 4, this.y, 196, textureOffset, 4, 20);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package exopandora.worldhandler.gui.button;
|
||||
package exopandora.worldhandler.gui.widget.button;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiSlider.ILogicSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider.ILogicSlider;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
import exopandora.worldhandler.builder.types.ArgumentType;
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.EnumIcon;
|
||||
import exopandora.worldhandler.usercontent.model.Action;
|
||||
import exopandora.worldhandler.usercontent.model.BooleanExpression;
|
||||
import exopandora.worldhandler.usercontent.model.JsonButton;
|
||||
|
||||
@@ -6,15 +6,15 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonItem;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonItem;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiSlider;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiTextFieldTooltip;
|
||||
import exopandora.worldhandler.gui.widget.button.LogicSliderSimple;
|
||||
import exopandora.worldhandler.usercontent.UsercontentAPI;
|
||||
import exopandora.worldhandler.usercontent.model.JsonButton;
|
||||
import exopandora.worldhandler.usercontent.model.JsonItem;
|
||||
|
||||
@@ -4,13 +4,13 @@ import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.gui.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.gui.container.Container;
|
||||
import exopandora.worldhandler.gui.content.Content;
|
||||
import exopandora.worldhandler.gui.menu.Menu;
|
||||
import exopandora.worldhandler.gui.menu.impl.ILogicPageList;
|
||||
import exopandora.worldhandler.gui.menu.impl.MenuPageList;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonBase;
|
||||
import exopandora.worldhandler.gui.widget.button.GuiButtonTooltip;
|
||||
import exopandora.worldhandler.usercontent.UsercontentAPI;
|
||||
import exopandora.worldhandler.usercontent.model.JsonItem;
|
||||
import exopandora.worldhandler.usercontent.model.JsonMenu;
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import exopandora.worldhandler.gui.button.EnumIcon;
|
||||
import exopandora.worldhandler.gui.widget.button.EnumIcon;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
||||
@@ -46,11 +46,6 @@ public class ActionHelper
|
||||
}
|
||||
}
|
||||
|
||||
public static void changeTab(Content content, int index)
|
||||
{
|
||||
ActionHelper.tryRun(() -> ActionHelper.open(content.getCategory().getContent(index)));
|
||||
}
|
||||
|
||||
public static void open(String id) throws Exception
|
||||
{
|
||||
if(id != null)
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RenderUtils
|
||||
matrix.pop();
|
||||
|
||||
RenderUtils.color(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getIconTexture());
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.iconTexture());
|
||||
|
||||
gui.blit(matrix, width + 0, height, 48, 0, 10, 10);
|
||||
|
||||
@@ -152,4 +152,103 @@ public class RenderUtils
|
||||
{
|
||||
RenderSystem.disableLighting();
|
||||
}
|
||||
|
||||
public static void colorDefaultButton()
|
||||
{
|
||||
float r = Config.getSkin().getButtonRedF();
|
||||
float g = Config.getSkin().getButtonGreenF();
|
||||
float b = Config.getSkin().getButtonBlueF();
|
||||
float a = Config.getSkin().getButtonAlphaF();
|
||||
|
||||
RenderUtils.color(r, g, b, a);
|
||||
}
|
||||
|
||||
public static void colorDefaultBackground()
|
||||
{
|
||||
RenderUtils.colorDefaultBackground(1.0F);
|
||||
}
|
||||
|
||||
public static void colorDefaultBackground(double alpha)
|
||||
{
|
||||
float r = Config.getSkin().getBackgroundRedF();
|
||||
float g = Config.getSkin().getBackgroundGreenF();
|
||||
float b = Config.getSkin().getBackgroundBlueF();
|
||||
float a = (float) alpha * Config.getSkin().getBackgroundAlphaF();
|
||||
|
||||
RenderUtils.color(r, g, b, a);
|
||||
}
|
||||
|
||||
public static void colorDarkBackground()
|
||||
{
|
||||
float r = Config.getSkin().getBackgroundRedF();
|
||||
float g = Config.getSkin().getBackgroundGreenF();
|
||||
float b = Config.getSkin().getBackgroundBlueF();
|
||||
float a = Config.getSkin().getBackgroundAlphaF();
|
||||
|
||||
RenderUtils.color(Math.max(0, r - 0.3F), Math.max(0, g - 0.3F), Math.max(0, b - 0.3F), a);
|
||||
}
|
||||
|
||||
public static void drawTexturedTriangleBL(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int size)
|
||||
{
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
gui.blit(matrix, x, y + i, textureX, textureY + i, i + 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawTexturedTriangleBR(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int size)
|
||||
{
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
gui.blit(matrix, x + size - i - 1, y + i, textureX + size - i - 1, textureY + i, i + 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawTexturedTriangleTL(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int size)
|
||||
{
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
gui.blit(matrix, x, y + i, textureX, textureY, size - i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawTexturedTriangleTR(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int size)
|
||||
{
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
gui.blit(matrix, x + i, y + i, textureX + i, textureY, size - i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawTexturedWedgeGradientTR(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int width, int height)
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
for(int i = 0; i < height; i++)
|
||||
{
|
||||
double w = (height - i) / (double) (height + 1);
|
||||
int z = width - (int) (w * width);
|
||||
|
||||
RenderUtils.colorDefaultBackground(w);
|
||||
gui.blit(matrix, x + z, y + i, textureX + z, textureY + i, width - z, 1);
|
||||
}
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
public static void drawTexturedWedgeGradientTL(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int width, int height)
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
for(int i = 0; i < height; i++)
|
||||
{
|
||||
double w = (height - i) / (double) (height + 1);
|
||||
int z = width - (int) (w * width);
|
||||
|
||||
RenderUtils.colorDefaultBackground(w);
|
||||
gui.blit(matrix, x, y + i, textureX, textureY + i, z, 1);
|
||||
}
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ResourceHelper
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ResourceLocation getBackgroundTexture()
|
||||
public static ResourceLocation backgroundTexture()
|
||||
{
|
||||
if(Config.getSkin().getTextureType().equals("resourcepack"))
|
||||
{
|
||||
@@ -88,12 +88,12 @@ public class ResourceHelper
|
||||
return BACKGROUND_VANILLA;
|
||||
}
|
||||
|
||||
public static ResourceLocation getIconTexture()
|
||||
public static ResourceLocation iconTexture()
|
||||
{
|
||||
return new ResourceLocation(Main.MODID, "textures/icons/icons_" + Config.getSkin().getIconSize().name() + ".png");
|
||||
}
|
||||
|
||||
public static ResourceLocation getButtonTexture()
|
||||
public static ResourceLocation buttonTexture()
|
||||
{
|
||||
if(Config.getSkin().getTextureType().equals("resourcepack"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user