Skip to content

Commit

Permalink
Rename RecipeGui to RecipeWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Nov 23, 2015
1 parent 7d52f4b commit de2601e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;

public class RecipeGui {
public class RecipeWidget {

@Nonnull
private final IRecipeCategory recipeCategory;
Expand All @@ -21,7 +21,7 @@ public class RecipeGui {
private int posX;
private int posY;

public RecipeGui(@Nonnull IRecipeCategory recipeCategory) {
public RecipeWidget(@Nonnull IRecipeCategory recipeCategory) {
this.recipeCategory = recipeCategory;
this.guiItemStacks = new GuiItemStacks();
this.recipeCategory.init(guiItemStacks);
Expand Down
36 changes: 17 additions & 19 deletions src/main/java/mezz/jei/gui/RecipesGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler;

import org.lwjgl.opengl.GL11;
Expand Down Expand Up @@ -54,9 +52,9 @@ private enum Mode {
@Nonnull
private ImmutableList<IRecipeCategory> recipeCategories = ImmutableList.of();

/* List of RecipeGui to display */
/* List of RecipeWidget to display */
@Nonnull
private final List<RecipeGui> recipeGuis = new ArrayList<RecipeGui>();
private final List<RecipeWidget> recipeWidgets = new ArrayList<RecipeWidget>();

/* List of recipes for the currently selected recipeClass */
@Nonnull
Expand Down Expand Up @@ -117,7 +115,7 @@ public void initGui(@Nonnull Minecraft minecraft) {
addButtons();

// on screen resize
if (recipeGuis.size() > 0) {
if (recipeWidgets.size() > 0) {
resetLayout();
}
}
Expand All @@ -135,7 +133,7 @@ public void setWorldAndResolution(Minecraft mc, int width, int height) {
}

private void resetLayout() {
recipeGuis.clear();
recipeWidgets.clear();
pageIndex = 0;
updateLayout();
}
Expand All @@ -154,8 +152,8 @@ public ItemStack getStackUnderMouse(int mouseX, int mouseY) {
if (!isOpen) {
return null;
}
for (RecipeGui recipeGui : recipeGuis) {
ItemStack stack = recipeGui.getStackUnderMouse(mouseX, mouseY);
for (RecipeWidget recipeWidget : recipeWidgets) {
ItemStack stack = recipeWidget.getStackUnderMouse(mouseX, mouseY);
if (stack != null) {
return stack;
}
Expand Down Expand Up @@ -324,22 +322,22 @@ private void updateLayout() {
final int posX = guiLeft + recipeXOffset;
int posY = guiTop + headerHeight + recipeSpacing;

recipeGuis.clear();
for (int recipeIndex = pageIndex * recipesPerPage; recipeIndex < recipes.size() && recipeGuis.size() < recipesPerPage; recipeIndex++) {
recipeWidgets.clear();
for (int recipeIndex = pageIndex * recipesPerPage; recipeIndex < recipes.size() && recipeWidgets.size() < recipesPerPage; recipeIndex++) {
Object recipe = recipes.get(recipeIndex);
IRecipeHandler recipeHandler = JEIManager.recipeRegistry.getRecipeHandler(recipe.getClass());
if (recipeHandler == null) {
Log.error("Couldn't find recipe handler for recipe: " + recipe);
continue;
}

RecipeGui recipeGui = new RecipeGui(recipeCategory);
recipeGui.setPosition(posX, posY);
RecipeWidget recipeWidget = new RecipeWidget(recipeCategory);
recipeWidget.setPosition(posX, posY);
posY += recipeBackground.getHeight() + recipeSpacing;

IRecipeWrapper recipeWrapper = recipeHandler.getRecipeWrapper(recipe);
recipeGui.setRecipe(recipeWrapper, focusStack);
recipeGuis.add(recipeGui);
recipeWidget.setRecipe(recipeWrapper, focusStack);
recipeWidgets.add(recipeWidget);
}

nextPage.enabled = previousPage.enabled = (pageCount() > 1);
Expand Down Expand Up @@ -367,12 +365,12 @@ public void draw(int mouseX, int mouseY) {
}
GL11.glPopMatrix();

RecipeGui hovered = null;
for (RecipeGui recipeGui : recipeGuis) {
if (recipeGui.getStackUnderMouse(mouseX, mouseY) != null) {
hovered = recipeGui;
RecipeWidget hovered = null;
for (RecipeWidget recipeWidget : recipeWidgets) {
if (recipeWidget.getStackUnderMouse(mouseX, mouseY) != null) {
hovered = recipeWidget;
} else {
recipeGui.draw(minecraft, mouseX, mouseY);
recipeWidget.draw(minecraft, mouseX, mouseY);
}
}
if (hovered != null) {
Expand Down

0 comments on commit de2601e

Please sign in to comment.