-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #280 from Ridanisaurus/main
Textures Update
- Loading branch information
Showing
40 changed files
with
352 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package de.mari_023.ae2wtlib.terminal; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import appeng.client.gui.style.Blitter; | ||
import appeng.core.AppEng; | ||
|
||
/** | ||
* Edit in {@code assets/ae2/textures/wtlib/guis/icons.png}. | ||
*/ | ||
public class Icon { | ||
public static final Texture TEXTURE = new Texture(AppEng.makeId("textures/wtlib/guis/icons.png"), 128, 128); | ||
public static final Texture AE2TEXTURE = new Texture(appeng.client.gui.Icon.TEXTURE, | ||
appeng.client.gui.Icon.TEXTURE_WIDTH, appeng.client.gui.Icon.TEXTURE_HEIGHT); | ||
|
||
public static final Icon BUTTON_BACKGROUND = new Icon(79, 0, 16, 17); | ||
public static final Icon BUTTON_BACKGROUND_HOVER = new Icon(95, 1, 16, 16); | ||
|
||
public static final Icon TOOLBAR_BUTTON_BACKGROUND = new Icon(176, 128, 18, 20, AE2TEXTURE); | ||
public static final Icon TOOLBAR_BUTTON_BACKGROUND_HOVER = new Icon(208, 128, 18, 20, AE2TEXTURE); | ||
|
||
public static final Icon MAGNET = new Icon(0, 0); | ||
public static final Icon MAGNET_FILTER = new Icon(0, 16); | ||
public static final Icon TRASH = new Icon(0, 32); | ||
|
||
public static final Icon PATTERN_ACCESS = new Icon(16, 0); | ||
public static final Icon PATTERN_ENCODING = new Icon(16, 16); | ||
public static final Icon CRAFTING = new Icon(16, 32); | ||
|
||
public static final Icon NO = new Icon(32, 0); | ||
public static final Icon YES = new Icon(32, 16); | ||
public static final Icon UP = new Icon(32, 32); | ||
public static final Icon DOWN = new Icon(32, 48); | ||
public static final Icon SWITCH = new Icon(32, 64); | ||
|
||
public static final Icon EMPTY_ARMOR_SLOT_HELMET = new Icon(112, 0); | ||
public static final Icon EMPTY_ARMOR_SLOT_CHESTPLATE = new Icon(112, 16); | ||
public static final Icon EMPTY_ARMOR_SLOT_LEGGINGS = new Icon(112, 32); | ||
public static final Icon EMPTY_ARMOR_SLOT_BOOTS = new Icon(112, 48); | ||
public static final Icon EMPTY_ARMOR_SLOT_SHIELD = new Icon(112, 64); | ||
|
||
public final Texture texture; | ||
public final int x; | ||
public final int y; | ||
public final int width; | ||
public final int height; | ||
|
||
private Icon(int x, int y) { | ||
this(x, y, 16, 16); | ||
} | ||
|
||
private Icon(int x, int y, int width, int height) { | ||
this(x, y, width, height, TEXTURE); | ||
} | ||
|
||
public Icon(int x, int y, int width, int height, Texture texture) { | ||
this.x = x; | ||
this.y = y; | ||
this.width = width; | ||
this.height = height; | ||
this.texture = texture; | ||
} | ||
|
||
public Blitter getBlitter() { | ||
return Blitter.texture(texture.location(), texture.width(), texture.height()) | ||
.src(x, y, width, height); | ||
} | ||
|
||
public record Texture(ResourceLocation location, int width, int height) { | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
src/main/java/de/mari_023/ae2wtlib/terminal/IconButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package de.mari_023.ae2wtlib.terminal; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.gui.components.Button; | ||
import net.minecraft.client.renderer.Rect2i; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import appeng.client.gui.widgets.ITooltip; | ||
|
||
public class IconButton extends Button implements ITooltip { | ||
private final Icon icon; | ||
private final Icon bg; | ||
private final Icon bg_hovered; | ||
@Nullable | ||
private List<Component> tooltip; | ||
|
||
public IconButton(OnPress onPress, Icon icon) { | ||
this(onPress, icon, Icon.BUTTON_BACKGROUND, Icon.BUTTON_BACKGROUND_HOVER); | ||
} | ||
|
||
public IconButton(OnPress onPress, Icon icon, Icon bg, Icon bg_hovered) { | ||
super(0, 0, 16, 16, Component.empty(), onPress, Button.DEFAULT_NARRATION); | ||
this.icon = icon; | ||
this.bg = bg; | ||
this.bg_hovered = bg_hovered; | ||
} | ||
|
||
public static IconButton withAE2Background(OnPress onPress, Icon icon) { | ||
return new IconButton(onPress, icon, Icon.TOOLBAR_BUTTON_BACKGROUND, Icon.TOOLBAR_BUTTON_BACKGROUND_HOVER); | ||
} | ||
|
||
public void setVisibility(boolean vis) { | ||
visible = vis; | ||
active = vis; | ||
} | ||
|
||
@Override | ||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partial) { | ||
if (!visible) | ||
return; | ||
|
||
var yOffset = isHoveredOrFocused() ? 1 : 0; | ||
var bg = getBG(); | ||
var bgSizeOffset = bg.width > 16 ? 1 : 0; | ||
|
||
bg.getBlitter() | ||
.dest(getX() - 1, getY() + yOffset, bg.width, bg.height) | ||
.zOffset(2) | ||
.blit(guiGraphics); | ||
getIcon().getBlitter().dest(getX() - 1 + bgSizeOffset, getY() + bgSizeOffset + yOffset).zOffset(3) | ||
.blit(guiGraphics); | ||
} | ||
|
||
protected Icon getIcon() { | ||
return icon; | ||
} | ||
|
||
private Icon getBG() { | ||
return isHoveredOrFocused() ? bg_hovered : bg; | ||
} | ||
|
||
@Override | ||
public List<Component> getTooltipMessage() { | ||
if (tooltip == null) | ||
return Collections.singletonList(getMessage()); | ||
return tooltip; | ||
} | ||
|
||
@Override | ||
public Rect2i getTooltipArea() { | ||
return new Rect2i( | ||
getX(), | ||
getY(), | ||
getBG().width, | ||
getBG().height); | ||
} | ||
|
||
@Override | ||
public boolean isTooltipAreaVisible() { | ||
return visible; | ||
} | ||
|
||
@Contract("_ -> this") | ||
public IconButton withTooltip(Component message) { | ||
super.setMessage(message); | ||
return this; | ||
} | ||
|
||
@Contract("_ -> this") | ||
public IconButton withTooltip(List<Component> tooltip) { | ||
this.tooltip = tooltip; | ||
return this; | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
src/main/java/de/mari_023/ae2wtlib/terminal/ItemButton.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.