From 45ed37cc8d0088b57cd2605482f471e69e5885f4 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 12 May 2019 16:26:48 +0800 Subject: Update Mappings --- .../rei/gui/VillagerRecipeViewingScreen.java | 31 +++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java') diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index 9d04b9168..2cf4990a3 100644 --- a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -9,19 +9,20 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.mojang.blaze3d.platform.GlStateManager; import com.zeitheron.hammercore.client.utils.Scissors; +import me.shedaniel.cloth.api.ClientUtils; import me.shedaniel.rei.api.*; import me.shedaniel.rei.client.ScreenHelper; import me.shedaniel.rei.gui.renderables.RecipeRenderer; import me.shedaniel.rei.gui.widget.*; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.audio.PositionedSoundInstance; import net.minecraft.client.gui.Element; import net.minecraft.client.gui.Screen; import net.minecraft.client.render.GuiLighting; import net.minecraft.client.resource.language.I18n; +import net.minecraft.client.sound.PositionedSoundInstance; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.sound.SoundEvents; -import net.minecraft.text.StringTextComponent; -import net.minecraft.text.TranslatableTextComponent; import net.minecraft.util.math.MathHelper; import org.lwjgl.BufferUtils; import org.lwjgl.glfw.GLFW; @@ -51,7 +52,7 @@ public class VillagerRecipeViewingScreen extends Screen { private int tabsPage; public VillagerRecipeViewingScreen(Map> map) { - super(new StringTextComponent("")); + super(new TextComponent("")); this.widgets = Lists.newArrayList(); this.categoryMap = Maps.newLinkedHashMap(); this.selectedCategoryIndex = 0; @@ -140,7 +141,7 @@ public class VillagerRecipeViewingScreen extends Screen { } } ButtonWidget w, w2; - this.widgets.add(w = new ButtonWidget(bounds.x + 2, bounds.y - 16, 10, 10, new TranslatableTextComponent("text.rei.left_arrow")) { + this.widgets.add(w = new ButtonWidget(bounds.x + 2, bounds.y - 16, 10, 10, new TranslatableComponent("text.rei.left_arrow")) { @Override public void onPressed() { tabsPage--; @@ -149,7 +150,7 @@ public class VillagerRecipeViewingScreen extends Screen { VillagerRecipeViewingScreen.this.init(); } }); - this.widgets.add(w2 = new ButtonWidget(bounds.x + bounds.width - 12, bounds.y - 16, 10, 10, new TranslatableTextComponent("text.rei.right_arrow")) { + this.widgets.add(w2 = new ButtonWidget(bounds.x + bounds.width - 12, bounds.y - 16, 10, 10, new TranslatableComponent("text.rei.right_arrow")) { @Override public void onPressed() { tabsPage++; @@ -206,6 +207,24 @@ public class VillagerRecipeViewingScreen extends Screen { scroll = MathHelper.clamp(scroll, 0, height - scrollListBounds.height + 2); return true; } + for(Element listener : children()) + if (listener.mouseScrolled(double_1, double_2, double_3)) + return true; + if (bounds.contains(ClientUtils.getMouseLocation())) { + if (double_3 < 0 && categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) { + selectedCategoryIndex++; + if (selectedCategoryIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size()) + selectedCategoryIndex = 0; + init(); + return true; + } else if (categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) { + selectedCategoryIndex--; + if (selectedCategoryIndex < 0) + selectedCategoryIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1; + init(); + return true; + } + } return super.mouseScrolled(double_1, double_2, double_3); } -- cgit From a98d9191f1a97925a8a3e2e23c0a07867540a93a Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 12 May 2019 18:10:15 +0800 Subject: Out of beta: Build 110 --- .../rei/gui/VillagerRecipeViewingScreen.java | 40 ++++++++-------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java') diff --git a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java index 2cf4990a3..7b70cfb93 100644 --- a/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java +++ b/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java @@ -24,12 +24,8 @@ import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.MathHelper; -import org.lwjgl.BufferUtils; -import org.lwjgl.glfw.GLFW; -import org.lwjgl.opengl.GL11; import java.awt.*; -import java.nio.IntBuffer; import java.util.List; import java.util.Map; import java.util.Optional; @@ -212,15 +208,14 @@ public class VillagerRecipeViewingScreen extends Screen { return true; if (bounds.contains(ClientUtils.getMouseLocation())) { if (double_3 < 0 && categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) { - selectedCategoryIndex++; - if (selectedCategoryIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size()) - selectedCategoryIndex = 0; + selectedRecipeIndex++; + if (selectedRecipeIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size()) + selectedRecipeIndex = 0; init(); - return true; } else if (categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) { - selectedCategoryIndex--; - if (selectedCategoryIndex < 0) - selectedCategoryIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1; + selectedRecipeIndex--; + if (selectedRecipeIndex < 0) + selectedRecipeIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1; init(); return true; } @@ -238,7 +233,7 @@ public class VillagerRecipeViewingScreen extends Screen { }); GuiLighting.disable(); ScreenHelper.getLastOverlay().render(mouseX, mouseY, delta); - GL11.glPushMatrix(); + GlStateManager.pushMatrix(); Scissors.begin(); Scissors.scissor(0, scrollListBounds.y + 1, width, scrollListBounds.height - 2); for(int i = 0; i < buttonWidgets.size(); i++) { @@ -258,17 +253,10 @@ public class VillagerRecipeViewingScreen extends Screen { } } Scissors.end(); - GL11.glPopMatrix(); + GlStateManager.popMatrix(); ScreenHelper.getLastOverlay().lateRender(mouseX, mouseY, delta); } - private int getTitleBarHeight() { - IntBuffer useless = BufferUtils.createIntBuffer(3), top = BufferUtils.createIntBuffer(1); - GLFW.glfwGetWindowFrameSize(minecraft.window.getHandle(), useless, top, useless, useless); - System.out.println(top.get(0)); - return top.get(0) / 3 * 2; - } - private int getReal(int i) { return (int) (i / ((double) minecraft.window.getScaledWidth() / (double) minecraft.window.getWidth())); } @@ -288,18 +276,18 @@ public class VillagerRecipeViewingScreen extends Screen { } if (ClientHelper.getInstance().getNextPageKeyBinding().matchesKey(int_1, int_2)) { if (categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) { - selectedCategoryIndex++; - if (selectedCategoryIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size()) - selectedCategoryIndex = 0; + selectedRecipeIndex ++; + if (selectedRecipeIndex >= categoryMap.get(categories.get(selectedCategoryIndex)).size()) + selectedRecipeIndex = 0; init(); return true; } return false; } else if (ClientHelper.getInstance().getPreviousPageKeyBinding().matchesKey(int_1, int_2)) { if (categoryMap.get(categories.get(selectedCategoryIndex)).size() > 1) { - selectedCategoryIndex--; - if (selectedCategoryIndex < 0) - selectedCategoryIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1; + selectedRecipeIndex--; + if (selectedRecipeIndex < 0) + selectedRecipeIndex = categoryMap.get(categories.get(selectedCategoryIndex)).size() - 1; init(); return true; } -- cgit