Removed IContent#getHeadline and refactoring

This commit is contained in:
Marcel Konrad
2019-11-11 23:04:16 +01:00
parent 3ce935d714
commit 6a3c762559
3 changed files with 13 additions and 46 deletions

View File

@@ -192,12 +192,12 @@ public class GuiWorldHandler extends Container
private int getContentX()
{
return (this.width - this.bgTextureWidth) / 2 + 8 + this.getXOffset();
return this.getBackgroundX() + 8;
}
private int getContentY()
{
return this.height / 2 - 50 + this.getYOffset();
return this.getBackgroundY() + 33;
}
private int getXOffset()
@@ -393,21 +393,6 @@ public class GuiWorldHandler extends Container
final int maxWidth = this.bgTextureWidth - 7 - 2 - this.font.getStringWidth(GuiWorldHandler.player) - 2 - this.getWatchOffset() - 7;
this.font.drawString(TextFormatting.shortenString(this.content.getTitle(), maxWidth, this.font), backgroundX + 7, backgroundY + 7, Config.getSkin().getLabelColor());
//HEADLINE
if(this.content.getHeadline() != null)
{
if(this.content.getHeadline().length > 0)
{
this.font.drawString(this.content.getHeadline()[0], backgroundX + 8, backgroundY + 22, Config.getSkin().getHeadlineColor());
}
if(this.content.getHeadline().length > 1)
{
this.font.drawString(this.content.getHeadline()[1], backgroundX + 126, backgroundY + 22, Config.getSkin().getHeadlineColor());
}
}
//NAME FIELD
final String username = GuiWorldHandler.player.isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : GuiWorldHandler.player;

View File

@@ -1,5 +1,6 @@
package exopandora.worldhandler.gui.content;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.ICommandBuilder;
@@ -45,7 +46,7 @@ public interface IContent
Content getActiveContent();
@Nullable
@Nonnull
default Content getBackContent()
{
return Contents.MAIN;
@@ -57,12 +58,6 @@ public interface IContent
return null;
}
@Nullable
default String[] getHeadline()
{
return null;
}
default void onGuiClosed()
{

View File

@@ -1,6 +1,5 @@
package exopandora.worldhandler.gui.content.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -588,6 +587,10 @@ public class ContentSummon extends Content
this.customNameField.renderButton(mouseX, mouseY, partialTicks);
this.passengerField.renderButton(mouseX, mouseY, partialTicks);
}
else if(this.page.equals("potionEffects"))
{
Minecraft.getInstance().fontRenderer.drawString((this.potionPage + 1) + "/" + (ForgeRegistries.POTIONS.getKeys().size() - 2), x + 118, y - 11, Config.getSkin().getHeadlineColor());
}
else if(this.page.equals("equipment"))
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
@@ -597,15 +600,16 @@ public class ContentSummon extends Content
{
container.blit(x + 116 + 99, y + 2 + 24 * row, 112, 221, 16, 16);
}
Minecraft.getInstance().fontRenderer.drawString((this.equipmentPage + 1) + "/2", x + 118, y - 11, Config.getSkin().getHeadlineColor());
}
}
private List<ResourceLocation> getSortedPotionList()
{
List<ResourceLocation> potions = new ArrayList<ResourceLocation>(ForgeRegistries.POTIONS.getKeys());
potions.sort((a, b) -> I18n.format(ForgeRegistries.POTIONS.getValue(a).getName()).compareTo(I18n.format(ForgeRegistries.POTIONS.getValue(b).getName())));
return potions;
return ForgeRegistries.POTIONS.getKeys().stream()
.sorted((a, b) -> I18n.format(ForgeRegistries.POTIONS.getValue(a).getName()).compareTo(I18n.format(ForgeRegistries.POTIONS.getValue(b).getName())))
.collect(Collectors.toList());
}
@Override
@@ -626,23 +630,6 @@ public class ContentSummon extends Content
return I18n.format("gui.worldhandler.tab.entities.summon");
}
@Override
public String[] getHeadline()
{
String[] headline = new String[2];
if(this.page.equals("potionEffects"))
{
headline[1] = (this.potionPage + 1) + "/" + (ForgeRegistries.POTIONS.getKeys().size() - 2);
}
else if(this.page.equals("equipment"))
{
headline[1] = (this.equipmentPage + 1) + "/2";
}
return headline;
}
@Override
public Content getActiveContent()
{