Selaa lähdekoodia

selection screen

Unknown 6 vuotta sitten
vanhempi
sitoutus
d3e88dc7eb

+ 3 - 0
src/main/java/me/shedaniel/rei/api/ClientHelper.java

@@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack;
 import net.minecraft.util.Identifier;
 
 import java.util.List;
+import java.util.Map;
 
 public interface ClientHelper extends ClientModInitializer {
     static ClientHelper getInstance() {
@@ -20,6 +21,8 @@ public interface ClientHelper extends ClientModInitializer {
     
     List<ItemStack> getInventoryItemsTypes();
     
+    void openRecipeViewingScreen(Map<RecipeCategory, List<RecipeDisplay>> map);
+    
     void registerFabricKeyBinds();
     
     boolean tryCheatingStack(ItemStack stack);

+ 4 - 0
src/main/java/me/shedaniel/rei/client/ClientHelperImpl.java

@@ -9,6 +9,7 @@ import me.shedaniel.rei.api.ClientHelper;
 import me.shedaniel.rei.api.RecipeCategory;
 import me.shedaniel.rei.api.RecipeDisplay;
 import me.shedaniel.rei.api.RecipeHelper;
+import me.shedaniel.rei.gui.PreRecipeViewingScreen;
 import me.shedaniel.rei.gui.RecipeViewingScreen;
 import me.shedaniel.rei.gui.VillagerRecipeViewingScreen;
 import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
@@ -189,9 +190,12 @@ public class ClientHelperImpl implements ClientHelper {
         return map.keySet().size() > 0;
     }
     
+    @Override
     public void openRecipeViewingScreen(Map<RecipeCategory, List<RecipeDisplay>> map) {
         if (RoughlyEnoughItemsCore.getConfigManager().getConfig().screenType == RecipeScreenType.VILLAGER)
             MinecraftClient.getInstance().openScreen(new VillagerRecipeViewingScreen(map));
+        else if (RoughlyEnoughItemsCore.getConfigManager().getConfig().screenType == RecipeScreenType.UNSET)
+            MinecraftClient.getInstance().openScreen(new PreRecipeViewingScreen(map));
         else
             MinecraftClient.getInstance().openScreen(new RecipeViewingScreen(map));
     }

+ 1 - 1
src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java

@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
 
 public class ContainerScreenOverlay extends AbstractParentElement implements Drawable {
     
-    private static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui" + "/recipecontainer.png");
+    private static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png");
     private static final List<QueuedTooltip> QUEUED_TOOLTIPS = Lists.newArrayList();
     public static String searchTerm = "";
     private static int page = 0;

+ 127 - 0
src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java

@@ -0,0 +1,127 @@
+package me.shedaniel.rei.gui;
+
+import com.google.common.collect.Lists;
+import me.shedaniel.rei.RoughlyEnoughItemsCore;
+import me.shedaniel.rei.api.ClientHelper;
+import me.shedaniel.rei.api.RecipeCategory;
+import me.shedaniel.rei.api.RecipeDisplay;
+import me.shedaniel.rei.client.RecipeScreenType;
+import me.shedaniel.rei.client.ScreenHelper;
+import me.shedaniel.rei.gui.widget.ButtonWidget;
+import me.shedaniel.rei.gui.widget.HighlightableWidget;
+import me.shedaniel.rei.gui.widget.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.sound.SoundEvents;
+import net.minecraft.text.TranslatableTextComponent;
+import net.minecraft.util.Identifier;
+
+import java.awt.*;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class PreRecipeViewingScreen extends Screen {
+    
+    private static final Identifier IDENTIFIER = new Identifier("roughlyenoughitems", "textures/gui/screenshot.png");
+    private final List<Widget> widgets;
+    private boolean original;
+    private Map<RecipeCategory, List<RecipeDisplay>> map;
+    
+    public PreRecipeViewingScreen(Map<RecipeCategory, List<RecipeDisplay>> map) {
+        super(new TranslatableTextComponent("text.rei.recipe_screen_type.selection"));
+        this.widgets = Lists.newArrayList();
+        this.original = true;
+        this.map = map;
+    }
+    
+    @Override
+    protected void init() {
+        this.children.clear();
+        this.widgets.clear();
+        this.widgets.add(new ButtonWidget(width / 2 - 100, height - 40, 200, 20, I18n.translate("text.rei.select")) {
+            @Override
+            public void onPressed() {
+                RoughlyEnoughItemsCore.getConfigManager().getConfig().screenType = original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER;
+                ClientHelper.getInstance().openRecipeViewingScreen(map);
+            }
+        });
+        this.widgets.add(new ScreenTypeSelection(width / 2 - 200 - 5, height / 2 - 112 / 2 - 10, 0));
+        this.widgets.add(new ScreenTypeSelection(width / 2 + 5, height / 2 - 112 / 2 - 10, 112));
+        this.children.addAll(widgets);
+    }
+    
+    @Override
+    public void render(int int_1, int int_2, float float_1) {
+        this.renderBackground();
+        this.drawCenteredString(this.font, this.title.getFormattedText(), this.width / 2, 20, 16777215);
+        int i = 30;
+        for(String s : this.font.wrapStringToWidthAsList(I18n.translate("text.rei.recipe_screen_type.selection.sub"), width - 30)) {
+            this.drawCenteredString(this.font, "§7" + s, width / 2, i, -1);
+            i += 10;
+        }
+        super.render(int_1, int_2, float_1);
+        this.widgets.forEach(widget -> {
+            GuiLighting.disable();
+            widget.render(int_1, int_2, float_1);
+        });
+    }
+    
+    @Override
+    public boolean keyPressed(int int_1, int int_2, int int_3) {
+        if ((int_1 == 256 || this.minecraft.options.keyInventory.matchesKey(int_1, int_2)) && this.shouldCloseOnEsc()) {
+            MinecraftClient.getInstance().openScreen(ScreenHelper.getLastContainerScreen());
+            ScreenHelper.getLastOverlay().init();
+            return true;
+        }
+        return super.keyPressed(int_1, int_2, int_3);
+    }
+    
+    public class ScreenTypeSelection extends HighlightableWidget {
+        
+        private Rectangle bounds;
+        private int u, v;
+        
+        public ScreenTypeSelection(int x, int y, int v) {
+            this.bounds = new Rectangle(x - 4, y - 4, 208, 120);
+            this.u = 0;
+            this.v = v;
+        }
+        
+        @Override
+        public Rectangle getBounds() {
+            return bounds;
+        }
+        
+        @Override
+        public void render(int i, int i1, float delta) {
+            MinecraftClient.getInstance().getTextureManager().bindTexture(IDENTIFIER);
+            blit(bounds.x + 4, bounds.y + 4, u, v, 200, 112);
+            if (original == (v == 0)) {
+                fillGradient(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + 2, 0xFFFFFFFF, 0xFFFFFFFF);
+                fillGradient(bounds.x, bounds.y + bounds.height - 2, bounds.x + bounds.width, bounds.y + bounds.height, 0xFFFFFFFF, 0xFFFFFFFF);
+                fillGradient(bounds.x, bounds.y, bounds.x + 2, bounds.y + bounds.height, 0xFFFFFFFF, 0xFFFFFFFF);
+                fillGradient(bounds.x + bounds.width - 2, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height, 0xFFFFFFFF, 0xFFFFFFFF);
+            }
+        }
+        
+        @Override
+        public boolean mouseClicked(double double_1, double double_2, int int_1) {
+            if (isHighlighted(double_1, double_2)) {
+                minecraft.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
+                original = (v == 0);
+                return true;
+            }
+            return false;
+        }
+        
+        @Override
+        public List<? extends Element> children() {
+            return Collections.emptyList();
+        }
+    }
+}

+ 2 - 0
src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java

@@ -192,6 +192,8 @@ public class VillagerRecipeViewingScreen extends Screen {
             GuiLighting.disable();
             widget.render(mouseX, mouseY, delta);
         });
+        GuiLighting.disable();
+        ScreenHelper.getLastOverlay().render(mouseX, mouseY, delta);
         GL11.glPushMatrix();
         Scissors.begin();
         Scissors.scissor(0, scrollListBounds.y + 1, width, scrollListBounds.height - 2);

+ 6 - 1
src/main/resources/assets/roughlyenoughitems/lang/en_us.json

@@ -94,6 +94,12 @@
   "text.rei.config_api_failed": "You arrived here either if Cloth Config API failed or you don't have it installed!\nUpdate / Install the API and report to the bug tracker.",
   "text.rei.back": "Back",
   "text.rei.config.recipe_screen_type": "Screen Type",
+  "text.rei.config.recipe_screen_type.unset": "Not Set",
+  "text.rei.config.recipe_screen_type.original": "Original",
+  "text.rei.config.recipe_screen_type.villager": "Villager",
+  "text.rei.select": "Select",
+  "text.rei.recipe_screen_type.selection": "Recipe Screen Type Selection",
+  "text.rei.recipe_screen_type.selection.sub": "You can always edit this setting again via the config screen.",
 
   "_comment": "Config Tooltips",
   "tooltip.rei.config.side_search_box": "Declares the location of the search field:\nYes: Left / Right\nNo: Center\n \nDefaulted: No",
@@ -102,7 +108,6 @@
   "tooltip.rei.config.max_recipes_per_page": "Declares the maximum possible displayed recipes:\nValues: 2 - 99\n \nDefaulted: 3",
   "tooltip.rei.config.light_gray_recipe_border": "Declares the appearance of the recipe border:\nYes: Light Gray\nNo: Hard Black\n \nDefaulted: No",
   "tooltip.rei.config.april_fools.2019": "Forcefully enables the 2019 april fools joke:\nValues: Yes / No\n \nDefaulted: No",
-
   "_comment": "Don't change / translate the credit down below if you are doing it :)",
   "text.rei.credit.text": "§lRoughly Enough Items\n§7Originally a fork for Almost Enough Items.\n\n§lDevelopers\n  - Originally by ZenDarva\n  - Created by Danielshe\n  - Plugin Support by TehNut\n\n§lLanguage Translation\n  English - Danielshe\n  Simplified Chinese - XuyuEre & Danielshe\n  Traditional Chinese - hugoalh, gxy17886 & Danielshe\n  French - Yanis48\n  German - MelanX\n  Estonian - Madis0\n  Portuguese - thiagokenis\n  LOLCAT - Danielshe\n  Upside Down - Danielshe\n  Brazilian Portuguese - thiagokenis\n  Bulgarian - geniiii\n\n§lLicense\n§7Roughly Enough Items is using MIT."
 }

BIN
src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.png