Skip to content

Commit

Permalink
Revert "Refactor "Icon" to use the new GUI sprite-sheet system and re…
Browse files Browse the repository at this point in the history
…move the states.png file. (AppliedEnergistics#8086)"

This reverts commit e48fefd.
  • Loading branch information
shartte committed Aug 9, 2024
1 parent 7a9a539 commit fbc2621
Show file tree
Hide file tree
Showing 180 changed files with 303 additions and 333 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ emi_version=1.1.10+1.21
# please learn how to use semver...
top_version_range=[1.20.0,)
jade_version_range=[15.0.0,)
rei_version=16.0.744
rei_version=16.0.729
wthit_version=12.1.2
jade_file_id=5427817
curios_version=7.1.0+1.20.4
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/appeng/client/gui/AEBaseScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import appeng.client.Point;
import appeng.client.gui.layout.SlotGridLayout;
import appeng.client.gui.style.BackgroundGenerator;
import appeng.client.gui.style.Blitter;
import appeng.client.gui.style.ScreenStyle;
import appeng.client.gui.style.SlotPosition;
import appeng.client.gui.style.Text;
Expand Down Expand Up @@ -519,7 +518,7 @@ private void drawOptionalSlotBackground(GuiGraphics guiGraphics, IOptionalSlot s

Point pos = slot.getBackgroundPos();

Blitter.guiSprite(Icon.SLOT_BACKGROUND)
Icon.SLOT_BACKGROUND.getBlitter()
.dest(leftPos + pos.getX(), topPos + pos.getY())
.color(1, 1, 1, alpha)
.blit(guiGraphics);
Expand Down Expand Up @@ -828,7 +827,7 @@ private void renderAppEngSlot(GuiGraphics guiGraphics, AppEngSlot s) {
// If the slot has a background icon, render it, but only if the slot is empty
// or it requests the icon to be always drawn
if ((s.renderIconWithItem() || is.isEmpty()) && s.isSlotEnabled() && s.getIcon() != null) {
Blitter.guiSprite(s.getIcon())
s.getIcon().getBlitter()
.dest(s.x, s.y)
.opacity(s.getOpacityOfIcon())
.blit(guiGraphics);
Expand Down
385 changes: 217 additions & 168 deletions src/main/java/appeng/client/gui/Icon.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;

import appeng.api.config.FuzzyMode;
Expand Down Expand Up @@ -87,7 +86,7 @@ public SetAmountButton(OnPress onPress) {
}

@Override
protected ResourceLocation getSprite() {
protected Icon getIcon() {
return isHoveredOrFocused() ? Icon.COG : Icon.COG_DISABLED;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;

import appeng.api.client.AEKeyRendering;
Expand All @@ -17,7 +16,6 @@
import appeng.client.gui.ICompositeWidget;
import appeng.client.gui.Icon;
import appeng.client.gui.Tooltip;
import appeng.client.gui.style.Blitter;
import appeng.core.localization.GuiText;
import appeng.core.localization.InGameTooltip;

Expand Down Expand Up @@ -60,7 +58,7 @@ public void setVisible(boolean visible) {
public void drawForegroundLayer(GuiGraphics guiGraphics, Rect2i bounds, Point mouse) {
var menu = screen.getMenu();

ResourceLocation icon;
Icon icon;
Component lockStatusText;
if (menu.getCraftingLockedReason() == LockCraftingMode.NONE) {
icon = Icon.UNLOCKED;
Expand All @@ -72,7 +70,7 @@ public void drawForegroundLayer(GuiGraphics guiGraphics, Rect2i bounds, Point mo
.setStyle(Style.EMPTY.withColor(Mth.color(193 / 255f, 66 / 255f, 75 / 255f)));
}

Blitter.guiSprite(icon).dest(x, y).blit(guiGraphics);
icon.getBlitter().dest(x, y).blit(guiGraphics);
guiGraphics.drawString(Minecraft.getInstance().font, lockStatusText, x + 15, y + 5, -1, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.Slot;

import appeng.api.config.ActionItems;
Expand Down Expand Up @@ -40,7 +39,7 @@ public CraftingEncodingPanel(PatternEncodingTermScreen<?> screen, WidgetContaine
}

@Override
ResourceLocation getIcon() {
Icon getIcon() {
return Icon.TAB_CRAFTING;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

import appeng.client.Point;
import appeng.client.gui.ICompositeWidget;
import appeng.client.gui.Icon;
import appeng.client.gui.WidgetContainer;
import appeng.menu.me.items.PatternEncodingTermMenu;

Expand All @@ -23,7 +23,10 @@ public EncodingModePanel(PatternEncodingTermScreen<?> screen, WidgetContainer wi
this.widgets = widgets;
}

abstract ResourceLocation getIcon();
// TODO (Rid): Replaced the ItemStack and an Icon
// abstract ItemStack getTabIconItem();

abstract Icon getIcon();

abstract Component getTabTooltip();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

import appeng.api.config.ActionItems;
import appeng.client.Point;
Expand Down Expand Up @@ -87,7 +86,7 @@ private void updateTooltipVisibility() {
}

@Override
ResourceLocation getIcon() {
Icon getIcon() {
return Icon.TAB_PROCESSING;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -45,7 +44,7 @@ public SmithingTableEncodingPanel(PatternEncodingTermScreen<?> screen, WidgetCon
}

@Override
ResourceLocation getIcon() {
Icon getIcon() {
return Icon.TAB_SMITHING;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeHolder;
Expand Down Expand Up @@ -160,7 +159,7 @@ public boolean onMouseWheel(Point mousePos, double delta) {
}

@Override
ResourceLocation getIcon() {
Icon getIcon() {
return Icon.TAB_STONECUTTING;
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/appeng/client/gui/widgets/ActionButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
import org.jetbrains.annotations.Nullable;

import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

import appeng.api.config.ActionItems;
import appeng.client.gui.Icon;
import appeng.core.localization.ButtonToolTips;

public class ActionButton extends IconButton {
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
private final ResourceLocation icon;
private final Icon icon;

public ActionButton(ActionItems action, Runnable onPress) {
this(action, a -> onPress.run());
Expand Down Expand Up @@ -106,7 +105,7 @@ public ActionButton(ActionItems action, Consumer<ActionItems> onPress) {
}

@Override
protected ResourceLocation getSprite() {
protected Icon getIcon() {
return icon;
}

Expand Down
18 changes: 8 additions & 10 deletions src/main/java/appeng/client/gui/widgets/IconButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.client.sounds.SoundManager;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

Expand Down Expand Up @@ -63,7 +62,7 @@ public void playDownSound(SoundManager soundHandler) {
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partial) {

if (this.visible) {
var icon = this.getSprite();
var icon = this.getIcon();
var item = this.getItemOverlay();

if (this.halfSize) {
Expand All @@ -75,41 +74,40 @@ public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float

if (this.halfSize) {
if (!disableBackground) {
Blitter.guiSprite(Icon.TOOLBAR_BUTTON_BACKGROUND).dest(getX(), getY()).zOffset(10)
.blit(guiGraphics);
Icon.TOOLBAR_BUTTON_BACKGROUND.getBlitter().dest(getX(), getY()).zOffset(10).blit(guiGraphics);
}
if (item != null) {
guiGraphics.renderItem(new ItemStack(item), getX(), getY(), 0, 20);
} else if (icon != null) {
Blitter blitter = Blitter.guiSprite(icon);
Blitter blitter = icon.getBlitter();
if (!this.active) {
blitter.opacity(0.5f);
}
blitter.dest(getX(), getY()).zOffset(20).blit(guiGraphics);
}
} else {
if (!disableBackground) {
var bgIcon = isHovered() ? Icon.TOOLBAR_BUTTON_BACKGROUND_HOVER
Icon bgIcon = isHovered() ? Icon.TOOLBAR_BUTTON_BACKGROUND_HOVER
: isFocused() ? Icon.TOOLBAR_BUTTON_BACKGROUND_FOCUS : Icon.TOOLBAR_BUTTON_BACKGROUND;

Blitter.guiSprite(bgIcon)
bgIcon.getBlitter()
.dest(getX() - 1, getY() + yOffset, 18, 20)
.zOffset(2)
.blit(guiGraphics);
}
if (item != null) {
guiGraphics.renderItem(new ItemStack(item), getX(), getY() + 1 + yOffset, 0, 3);
} else if (icon != null) {
Blitter.guiSprite(icon).dest(getX(), getY() + 1 + yOffset).zOffset(3).blit(guiGraphics);
icon.getBlitter().dest(getX(), getY() + 1 + yOffset).zOffset(3).blit(guiGraphics);
}
}
}
}

protected abstract ResourceLocation getSprite();
protected abstract Icon getIcon();

/**
* Prioritized over {@link #getSprite()} if not null.
* Prioritized over {@link #getIcon()} if not null.
*/
@Nullable
protected Item getItemOverlay() {
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/appeng/client/gui/widgets/InfoBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.ItemLike;

import appeng.api.client.AEKeyRendering;
import appeng.api.stacks.AEItemKey;
import appeng.api.stacks.AEKey;
import appeng.client.gui.style.Blitter;
import appeng.client.gui.Icon;

public class InfoBar {
private final List<Widget> widgets = new ArrayList<>();
Expand All @@ -39,7 +38,7 @@ interface Widget {
}

// TODO (RID): Added xPos and yPos to give me better control over render, but the code below might need refactoring
void add(ResourceLocation icon, float scale, int xPos, int yPos) {
void add(Icon icon, float scale, int xPos, int yPos) {
widgets.add(new IconWidget(icon, scale, xPos, yPos));
}

Expand Down Expand Up @@ -85,7 +84,7 @@ public void render(GuiGraphics guiGraphics, int x, int y) {
}
}

private record IconWidget(ResourceLocation icon, float scale, int xPos, int yPos) implements Widget {
private record IconWidget(Icon icon, float scale, int xPos, int yPos) implements Widget {
@Override
public int getWidth() {
return Math.round(16 * scale);
Expand All @@ -102,7 +101,7 @@ public void render(GuiGraphics guiGraphics, int x, int y) {
poseStack.pushPose();
poseStack.translate(xPos, yPos, 0);
poseStack.scale(scale, scale, 1);
Blitter.guiSprite(icon)
icon.getBlitter()
.dest(0, 0)
.blit(guiGraphics);
poseStack.popPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

import appeng.api.stacks.AEKeyType;
import appeng.api.storage.ISubMenuHost;
Expand Down Expand Up @@ -102,7 +101,7 @@ public List<Component> getTooltipMessage() {
}

@Override
protected ResourceLocation getSprite() {
protected Icon getIcon() {
return Icon.TYPE_FILTER_ALL;
}
}
3 changes: 1 addition & 2 deletions src/main/java/appeng/client/gui/widgets/OpenGuideButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.List;

import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

import appeng.client.gui.Icon;
import appeng.core.localization.ButtonToolTips;
Expand All @@ -21,7 +20,7 @@ public List<Component> getTooltipMessage() {
}

@Override
protected ResourceLocation getSprite() {
protected Icon getIcon() {
return Icon.HELP;
}
}
Loading

0 comments on commit fbc2621

Please sign in to comment.