From 7689bdbb42ad10b2ad99e2bae55ddaceac15bca7 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 3 Jun 2019 21:39:36 +0800 Subject: Dark Mode --- src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java') diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index 8884fb380..e420ec1c6 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -36,7 +36,6 @@ import java.util.function.Supplier; public class RecipeViewingScreen extends Screen { public static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png"); - public static final Color SUB_COLOR = new Color(159, 159, 159); private static final int TABS_PER_PAGE = 5; private final List widgets; private final List tabs; @@ -344,8 +343,13 @@ public class RecipeViewingScreen extends Screen { selectedCategory.drawCategoryBackground(bounds, mouseX, mouseY, delta); else { new CategoryBaseWidget(bounds).render(); - fill(bounds.x + 17, bounds.y + 5, bounds.x + bounds.width - 17, bounds.y + 17, SUB_COLOR.getRGB()); - fill(bounds.x + 17, bounds.y + 21, bounds.x + bounds.width - 17, bounds.y + 33, SUB_COLOR.getRGB()); + if (RoughlyEnoughItemsCore.getConfigManager().getConfig().darkTheme) { + fill(bounds.x + 17, bounds.y + 5, bounds.x + bounds.width - 17, bounds.y + 17, 0xFF404040); + fill(bounds.x + 17, bounds.y + 21, bounds.x + bounds.width - 17, bounds.y + 33, 0xFF404040); + } else { + fill(bounds.x + 17, bounds.y + 5, bounds.x + bounds.width - 17, bounds.y + 17, 0xFF9E9E9E); + fill(bounds.x + 17, bounds.y + 21, bounds.x + bounds.width - 17, bounds.y + 33, 0xFF9E9E9E); + } } tabs.stream().filter(tabWidget -> !tabWidget.isSelected()).forEach(tabWidget -> tabWidget.render(mouseX, mouseY, delta)); GuiLighting.disable(); -- cgit From 98c2c0f1af8b264cfce5c005f4694318cce001b2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 6 Jun 2019 18:36:51 +0800 Subject: alterative solution to the working stations --- .../me/shedaniel/rei/gui/RecipeViewingScreen.java | 42 ++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java') diff --git a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index e420ec1c6..5dd88c61e 100644 --- a/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -12,6 +12,7 @@ import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.*; import me.shedaniel.rei.client.ScreenHelper; import me.shedaniel.rei.gui.widget.*; +import net.minecraft.ChatFormat; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.Element; import net.minecraft.client.gui.screen.Screen; @@ -20,6 +21,7 @@ import net.minecraft.client.render.GuiLighting; import net.minecraft.client.resource.language.I18n; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.util.Window; +import net.minecraft.item.ItemStack; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.sound.SoundEvents; @@ -27,16 +29,15 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import java.awt.*; -import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.function.Supplier; public class RecipeViewingScreen extends Screen { public static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png"); private static final int TABS_PER_PAGE = 5; + private final List preWidgets; private final List widgets; private final List tabs; private final Map> categoriesMap; @@ -54,6 +55,7 @@ public class RecipeViewingScreen extends Screen { public RecipeViewingScreen(Map> categoriesMap) { super(new TextComponent("")); this.categoryPages = 0; + this.preWidgets = Lists.newArrayList(); this.widgets = Lists.newArrayList(); Window window = MinecraftClient.getInstance().window; this.bounds = new Rectangle(window.getScaledWidth() / 2 - guiWidth / 2, window.getScaledHeight() / 2 - guiHeight / 2, 176, 186); @@ -121,6 +123,7 @@ public class RecipeViewingScreen extends Screen { super.init(); this.children.clear(); this.tabs.clear(); + this.preWidgets.clear(); this.widgets.clear(); this.largestWidth = width - 100; this.largestHeight = height - 40; @@ -294,9 +297,38 @@ public class RecipeViewingScreen extends Screen { else recipeChoosePageWidget = null; + List> workingStations = RoughlyEnoughItemsCore.getRecipeHelper().getWorkingStations(selectedCategory.getIdentifier()); + if (!workingStations.isEmpty()) { + int hh = MathHelper.floor((bounds.height - 16) / 18f); + int actualHeight = Math.min(hh, workingStations.size()); + int innerWidth = MathHelper.ceil(workingStations.size() / ((float) hh)); + int xx = bounds.x - (10 + innerWidth * 18) + 6; + int yy = bounds.y + 16; + preWidgets.add(new CategoryBaseWidget(new Rectangle(xx - 6, yy - 6, 15 + innerWidth * 18, 11 + actualHeight * 18))); + int index = 0; + List list = Collections.singletonList(ChatFormat.YELLOW.toString() + I18n.translate("text.rei.working_station")); + xx += (innerWidth - 1) * 18; + for(List workingStation : workingStations) { + preWidgets.add(new SlotWidget(xx, yy, workingStation, true, true, true) { + @Override + protected List getExtraToolTips(ItemStack stack) { + return list; + } + }); + index++; + yy += 18; + if (index >= hh) { + index = 0; + yy = bounds.y + 16; + xx -= 18; + } + } + } + children.addAll(tabs); children.add(ScreenHelper.getLastOverlay(true, false)); children.addAll(widgets); + children.addAll(preWidgets); } public List getWidgets() { @@ -339,6 +371,10 @@ public class RecipeViewingScreen extends Screen { @Override public void render(int mouseX, int mouseY, float delta) { this.fillGradient(0, 0, this.width, this.height, -1072689136, -804253680); + preWidgets.forEach(widget -> { + GuiLighting.disable(); + widget.render(mouseX, mouseY, delta); + }); if (selectedCategory != null) selectedCategory.drawCategoryBackground(bounds, mouseX, mouseY, delta); else { -- cgit