Browse Source

Fixed scaling for guidebook ui

1.12.2
kingbdogz 4 days ago
parent
commit
0ca97393ff

+ 15
- 15
src/main/java/com/gildedgames/aether/client/gui/container/guidebook/discovery/GuiGuidebookDiscovery.java View File

@@ -39,20 +39,6 @@ public class GuiGuidebookDiscovery extends AbstractGuidebookPage
public void build(final IGuiContext context)
{
super.build(context);

final DiscoveryTab.DiscoveryTabType openedTab = this.aePlayer.getModule(PlayerProgressModule.class).getOpenedDiscoveryTabType();

this.bestiaryTab = new DiscoveryTab(Pos2D.build().x(89).y(61).flush(), DiscoveryTab.DiscoveryTabType.BESTIARY, openedTab);
this.structureTab = new DiscoveryTab(Pos2D.build().x(121).y(61).flush(), DiscoveryTab.DiscoveryTabType.STRUCTURES, openedTab);
this.characterTab = new DiscoveryTab(Pos2D.build().x(153).y(61).flush(), DiscoveryTab.DiscoveryTabType.CHARACTERS, openedTab);
this.biomeTab = new DiscoveryTab(Pos2D.build().x(185).y(61).flush(), DiscoveryTab.DiscoveryTabType.BIOMES, openedTab);

this.bestiaryTab.addAdvancedClickEvent(this::onClickTab);
this.structureTab.addAdvancedClickEvent(this::onClickTab);
this.characterTab.addAdvancedClickEvent(this::onClickTab);
this.biomeTab.addAdvancedClickEvent(this::onClickTab);

context.addChildren(this.bestiaryTab, this.structureTab, this.characterTab, this.biomeTab);
}

private void onClickTab(final DiscoveryTab tab)
@@ -96,7 +82,21 @@ public class GuiGuidebookDiscovery extends AbstractGuidebookPage
{
final GuiTexture leftPage = new GuiTexture(Dim2D.build().width(this.PAGE_WIDTH).height(this.PAGE_HEIGHT).x(screenX).y(screenY).flush(), LEFT_PAGE);

return Lists.newArrayList(leftPage);
final DiscoveryTab.DiscoveryTabType openedTab = this.aePlayer.getModule(PlayerProgressModule.class).getOpenedDiscoveryTabType();

Pos2D screen = Pos2D.flush(screenX, screenY);

this.bestiaryTab = new DiscoveryTab(screen.clone().addX(24).addY(26).flush(), DiscoveryTab.DiscoveryTabType.BESTIARY, openedTab);
this.structureTab = new DiscoveryTab(screen.clone().addX(24 + 32).addY(26).flush(), DiscoveryTab.DiscoveryTabType.STRUCTURES, openedTab);
this.characterTab = new DiscoveryTab(screen.clone().addX(24 + 64).addY(26).flush(), DiscoveryTab.DiscoveryTabType.CHARACTERS, openedTab);
this.biomeTab = new DiscoveryTab(screen.clone().addX(24 + 96).addY(26).flush(), DiscoveryTab.DiscoveryTabType.BIOMES, openedTab);

this.bestiaryTab.addAdvancedClickEvent(this::onClickTab);
this.structureTab.addAdvancedClickEvent(this::onClickTab);
this.characterTab.addAdvancedClickEvent(this::onClickTab);
this.biomeTab.addAdvancedClickEvent(this::onClickTab);

return Lists.newArrayList(leftPage, this.bestiaryTab, this.structureTab, this.characterTab, this.biomeTab);
}

@Override

+ 40
- 37
src/main/java/com/gildedgames/aether/client/gui/container/guidebook/discovery/GuiGuidebookDiscoveryBestiary.java View File

@@ -56,18 +56,50 @@ public class GuiGuidebookDiscoveryBestiary extends GuiGuidebookDiscovery
public void build(final IGuiContext context)
{
super.build(context);
}

private IGuiElement buildStats(final TGEntryBestiaryPage page)
{
final IEntityStats stats = page.getEntityStats();
final IGuiElement statsElement = new GuiElement(Dim2D.build().width(52).flush(), false);

final GuiStat healthStat = new GuiStat(
new GuiTexture(Dim2D.build().width(14).height(14).flush(), HEALTH_ICON),
new Text(new TextComponentString(String.valueOf(MathHelper.floor(stats.getMaxHealth()))), 1.0F));
final GuiStat slashStat = new GuiStat(
new GuiTexture(Dim2D.build().width(14).height(14).flush(), SLASH_DEFENSE_ICON),
new Text(new TextComponentString(String.valueOf(MathHelper.floor(stats.getSlashDefenseLevel()))), 1.0F));
final GuiStat pierceStat = new GuiStat(
new GuiTexture(Dim2D.build().width(14).height(14).flush(), PIERCE_DEFENSE_ICON),
new Text(new TextComponentString(String.valueOf(MathHelper.floor(stats.getPierceDefenseLevel()))), 1.0F));
final GuiStat impactStat = new GuiStat(
new GuiTexture(Dim2D.build().width(14).height(14).flush(), IMPACT_DEFENSE_ICON),
new Text(new TextComponentString(String.valueOf(MathHelper.floor(stats.getImpactDefenseLevel()))), 1.0F));

statsElement.build(this);

GuiLibHelper.alignVertically(this, Pos2D.flush(5, 5), 5, healthStat, slashStat, pierceStat, impactStat);

statsElement.context().addChildren(healthStat, slashStat, pierceStat, impactStat);

GuiLibHelper.assembleMinMaxArea(statsElement);

return statsElement;
}

@Override
protected List<IGuiElement> createLeftPage(final int screenX, final int screenY, final float u, final float v) {
List<IGuiElement> elements = super.createLeftPage(screenX, screenY, u, v);
final ITGManager tgManager = AetherCore.PROXY.content().tgManager();

this.bestiaryEntries = tgManager.getEntriesWithTagAndClass("bestiary", TGEntryBestiaryPage.class);
this.slots = Lists.newArrayList();

for (int i = 0; i < this.bestiaryEntries.size(); i++)
{
for (int i = 0; i < this.bestiaryEntries.size(); i++) {
final TGEntryBestiaryPage page = this.bestiaryEntries.get(i);

final int x = 95 + ((i % 6) * 18);
final int y = 94 + ((i / 6) * 18);
final int x = screenX + 29 + ((i % 6) * 18);
final int y = screenY + 58 + ((i / 6) * 18);

final BestiarySlot slot = new BestiarySlot(this.aePlayer, Pos2D.flush(x, y), page);

@@ -80,8 +112,7 @@ public class GuiGuidebookDiscoveryBestiary extends GuiGuidebookDiscovery

this.beastTitle.setText(new Text(new TextComponentTranslation(page.getEntityName()), 1.0F));

if (!isUnderstood)
{
if (!isUnderstood) {
// Replace beast name with ? characters
this.beastTitle.setTextMutator((text) -> text.replaceAll("[^\\s]", "?"));
}
@@ -92,8 +123,7 @@ public class GuiGuidebookDiscoveryBestiary extends GuiGuidebookDiscovery

this.beastDescription.tryRebuild();

if (isUnderstood)
{
if (isUnderstood) {
final IGuiElement statsContent = this.buildStats(page);

statsContent.dim().mod().pos(this.statsArea.dim().min()).flush();
@@ -103,37 +133,10 @@ public class GuiGuidebookDiscoveryBestiary extends GuiGuidebookDiscovery
});

this.slots.add(slot);
context.addChildren(slot);
elements.add(slot);
}
}

private IGuiElement buildStats(final TGEntryBestiaryPage page)
{
final IEntityStats stats = page.getEntityStats();
final IGuiElement statsElement = new GuiElement(Dim2D.build().width(52).flush(), false);

final GuiStat healthStat = new GuiStat(
new GuiTexture(Dim2D.build().width(14).height(14).flush(), HEALTH_ICON),
new Text(new TextComponentString(String.valueOf(MathHelper.floor(stats.getMaxHealth()))), 1.0F));
final GuiStat slashStat = new GuiStat(
new GuiTexture(Dim2D.build().width(14).height(14).flush(), SLASH_DEFENSE_ICON),
new Text(new TextComponentString(String.valueOf(MathHelper.floor(stats.getSlashDefenseLevel()))), 1.0F));
final GuiStat pierceStat = new GuiStat(
new GuiTexture(Dim2D.build().width(14).height(14).flush(), PIERCE_DEFENSE_ICON),
new Text(new TextComponentString(String.valueOf(MathHelper.floor(stats.getPierceDefenseLevel()))), 1.0F));
final GuiStat impactStat = new GuiStat(
new GuiTexture(Dim2D.build().width(14).height(14).flush(), IMPACT_DEFENSE_ICON),
new Text(new TextComponentString(String.valueOf(MathHelper.floor(stats.getImpactDefenseLevel()))), 1.0F));

statsElement.build(this);

GuiLibHelper.alignVertically(this, Pos2D.flush(5, 5), 5, healthStat, slashStat, pierceStat, impactStat);

statsElement.context().addChildren(healthStat, slashStat, pierceStat, impactStat);

GuiLibHelper.assembleMinMaxArea(statsElement);

return statsElement;
return elements;
}

@Override

Loading…
Cancel
Save