aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui/widget
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-05-08 00:55:25 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-05-08 00:55:25 +0800
commita5c90bb7d4748ba2da024ce468ffeeda99bf4a0f (patch)
tree4bcc51bdcee2dbc521d2bf74f0f913ec04485f67 /src/main/java/me/shedaniel/rei/gui/widget
parent5357ec90f80768b69b197161e877e3ef884650a4 (diff)
downloadRoughlyEnoughItems-a5c90bb7d4748ba2da024ce468ffeeda99bf4a0f.tar.gz
RoughlyEnoughItems-a5c90bb7d4748ba2da024ce468ffeeda99bf4a0f.tar.bz2
RoughlyEnoughItems-a5c90bb7d4748ba2da024ce468ffeeda99bf4a0f.zip
start of 2.9 update beta
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/widget')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java62
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/SlotBaseWidget.java21
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java38
3 files changed, 76 insertions, 45 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java
index 57dbd5e89..a139d7d34 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java
@@ -12,9 +12,9 @@ import java.util.List;
public class RecipeBaseWidget extends HighlightableWidget {
private static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png");
- private static final Color INNER_COLOR = new Color(198, 198, 198);
private Rectangle bounds;
+ protected boolean render = true;
public RecipeBaseWidget(Rectangle bounds) {
this.bounds = bounds;
@@ -22,6 +22,14 @@ public class RecipeBaseWidget extends HighlightableWidget {
throw new IllegalArgumentException("Base too small, at least 8x8!");
}
+ public boolean isRender() {
+ return render;
+ }
+
+ public void setRender(boolean render) {
+ this.render = render;
+ }
+
@Override
public Rectangle getBounds() {
return bounds;
@@ -38,30 +46,36 @@ public class RecipeBaseWidget extends HighlightableWidget {
@Override
public void render(int mouseX, int mouseY, float delta) {
- GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
- GuiLighting.disable();
- minecraft.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
- int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
- int textureOffset = getTextureOffset();
-
- //Four Corners
- this.blit(x, y, 106, 124 + textureOffset, 4, 4);
- this.blit(x + width - 4, y, 252, 124 + textureOffset, 4, 4);
- this.blit(x, y + height - 4, 106, 186 + textureOffset, 4, 4);
- this.blit(x + width - 4, y + height - 4, 252, 186 + textureOffset, 4, 4);
-
- //Sides
- for(int xx = 4; xx < width - 4; xx += 128) {
- int thisWidth = Math.min(128, width - 4 - xx);
- this.blit(x + xx, y, 110, 124 + textureOffset, thisWidth, 4);
- this.blit(x + xx, y + height - 4, 110, 186 + textureOffset, thisWidth, 4);
- }
- for(int yy = 4; yy < height - 4; yy += 50) {
- int thisHeight = Math.min(50, height - 4 - yy);
- this.blit(x, y + yy, 106, 128 + textureOffset, 4, thisHeight);
- this.blit(x + width - 4, y + yy, 252, 128 + textureOffset, 4, thisHeight);
+ if (render) {
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiLighting.disable();
+ minecraft.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
+ int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
+ int textureOffset = getTextureOffset();
+
+ //Four Corners
+ this.blit(x, y, 106, 124 + textureOffset, 4, 4);
+ this.blit(x + width - 4, y, 252, 124 + textureOffset, 4, 4);
+ this.blit(x, y + height - 4, 106, 186 + textureOffset, 4, 4);
+ this.blit(x + width - 4, y + height - 4, 252, 186 + textureOffset, 4, 4);
+
+ //Sides
+ for(int xx = 4; xx < width - 4; xx += 128) {
+ int thisWidth = Math.min(128, width - 4 - xx);
+ this.blit(x + xx, y, 110, 124 + textureOffset, thisWidth, 4);
+ this.blit(x + xx, y + height - 4, 110, 186 + textureOffset, thisWidth, 4);
+ }
+ for(int yy = 4; yy < height - 4; yy += 50) {
+ int thisHeight = Math.min(50, height - 4 - yy);
+ this.blit(x, y + yy, 106, 128 + textureOffset, 4, thisHeight);
+ this.blit(x + width - 4, y + yy, 252, 128 + textureOffset, 4, thisHeight);
+ }
+ fillGradient(x + 4, y + 4, x + width - 4, y + height - 4, getInnerColor(), getInnerColor());
}
- fillGradient(x + 4, y + 4, x + width - 4, y + height - 4, INNER_COLOR.getRGB(), INNER_COLOR.getRGB());
+ }
+
+ protected int getInnerColor() {
+ return -3750202;
}
protected int getTextureOffset() {
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/SlotBaseWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/SlotBaseWidget.java
new file mode 100644
index 000000000..8ab19cfd3
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/gui/widget/SlotBaseWidget.java
@@ -0,0 +1,21 @@
+package me.shedaniel.rei.gui.widget;
+
+import java.awt.*;
+
+public class SlotBaseWidget extends RecipeBaseWidget {
+
+ public SlotBaseWidget(Rectangle bounds) {
+ super(bounds);
+ }
+
+ @Override
+ public int getInnerColor() {
+ return -7631989;
+ }
+
+ @Override
+ protected int getTextureOffset() {
+ return -66;
+ }
+
+}
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java
index 07493792c..b86be1927 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/TabWidget.java
@@ -1,11 +1,12 @@
package me.shedaniel.rei.gui.widget;
import com.mojang.blaze3d.platform.GlStateManager;
+import me.shedaniel.rei.api.ClientHelper;
+import me.shedaniel.rei.api.RecipeCategory;
+import me.shedaniel.rei.api.Renderable;
import me.shedaniel.rei.client.ScreenHelper;
import me.shedaniel.rei.gui.RecipeViewingScreen;
import net.minecraft.client.render.GuiLighting;
-import net.minecraft.client.render.item.ItemRenderer;
-import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import java.awt.*;
@@ -17,28 +18,28 @@ public class TabWidget extends HighlightableWidget {
public static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png");
public boolean shown = false, selected = false;
- public ItemStack item;
+ public Renderable renderable;
public int id;
public RecipeViewingScreen recipeViewingWidget;
public String categoryName;
public Rectangle bounds;
- private ItemRenderer itemRenderer;
+ public RecipeCategory category;
public TabWidget(int id, RecipeViewingScreen recipeViewingWidget, Rectangle bounds) {
this.id = id;
this.recipeViewingWidget = recipeViewingWidget;
this.bounds = bounds;
- this.itemRenderer = minecraft.getItemRenderer();
}
- public void setItem(ItemStack item, String categoryName, boolean selected) {
- if (item == null) {
+ public void setRenderable(RecipeCategory category, Renderable renderable, String categoryName, boolean selected) {
+ if (renderable == null) {
shown = false;
- this.item = null;
+ this.renderable = null;
} else {
shown = true;
- this.item = item;
+ this.renderable = renderable;
}
+ this.category = category;
this.selected = selected;
this.categoryName = categoryName;
}
@@ -55,8 +56,8 @@ public class TabWidget extends HighlightableWidget {
return shown;
}
- public ItemStack getItemStack() {
- return item;
+ public Renderable getRenderable() {
+ return renderable;
}
@Override
@@ -67,26 +68,21 @@ public class TabWidget extends HighlightableWidget {
@Override
public void render(int mouseX, int mouseY, float delta) {
if (shown) {
- int l = (int) this.bounds.getCenterX() - 8, i1 = (int) this.bounds.getCenterY() - 6;
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiLighting.disable();
minecraft.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
this.blit(bounds.x, bounds.y + 2, selected ? 28 : 0, 192, 28, (selected ? 30 : 27));
- this.blitOffset = 100;
- this.itemRenderer.zOffset = 100.0F;
- GuiLighting.enableForItems();
- this.itemRenderer.renderGuiItem(getItemStack(), l, i1);
- this.itemRenderer.renderGuiItemOverlay(minecraft.textRenderer, getItemStack(), l, i1);
- GlStateManager.disableLighting();
- this.itemRenderer.zOffset = 0.0F;
- this.blitOffset = 0;
+ renderable.render((int) bounds.getCenterX(), (int) bounds.getCenterY(), mouseX, mouseY, delta);
if (isHighlighted(mouseX, mouseY))
drawTooltip();
}
}
private void drawTooltip() {
- ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(categoryName));
+ if (this.minecraft.options.advancedItemTooltips)
+ ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(categoryName, "ยง8" + category.getIdentifier().toString(), ClientHelper.getInstance().getFormattedModFromIdentifier(category.getIdentifier())));
+ else
+ ScreenHelper.getLastOverlay().addTooltip(QueuedTooltip.create(categoryName, ClientHelper.getInstance().getFormattedModFromIdentifier(category.getIdentifier())));
}
@Override