Skip to content

Commit

Permalink
visibility fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Serghei Borovetchi authored and mitchej123 committed Feb 18, 2022
1 parent db6e3d3 commit 1e93f71
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/main/java/codechicken/nei/ItemPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;

Expand Down Expand Up @@ -472,9 +473,9 @@ protected boolean handleSearchInputClick(int mouseX, int mouseY, int button)
final FluidStack fluidStack = StackInfo.getFluid(draggedStack);

if (fluidStack != null) {
searchField.setText(SPECIAL_REGEX_CHARS.matcher(fluidStack.getLocalizedName()).replaceAll("\\\\$0"));
searchField.setText(SPECIAL_REGEX_CHARS.matcher(EnumChatFormatting.getTextWithoutFormattingCodes(fluidStack.getLocalizedName())).replaceAll("\\\\$0"));
} else {
searchField.setText(SPECIAL_REGEX_CHARS.matcher(draggedStack.getDisplayName()).replaceAll("\\\\$0"));
searchField.setText(SPECIAL_REGEX_CHARS.matcher(EnumChatFormatting.getTextWithoutFormattingCodes(draggedStack.getDisplayName())).replaceAll("\\\\$0"));
}

return true;
Expand Down
16 changes: 6 additions & 10 deletions src/main/java/codechicken/nei/ItemsGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,14 @@ public int getColumns()
public void setGridSize(int mleft, int mtop, int w, int h)
{

//I don't like this big condition
if (marginLeft != mleft || marginTop != mtop || width != w || height != h) {
marginLeft = mleft;
marginTop = mtop;

marginLeft = mleft;
marginTop = mtop;
width = Math.max(0, w);
height = Math.max(0, h);

width = Math.max(0, w);
height = Math.max(0, h);

columns = width / SLOT_SIZE;
rows = height / SLOT_SIZE;
}
columns = width / SLOT_SIZE;
rows = height / SLOT_SIZE;

}

Expand Down
10 changes: 9 additions & 1 deletion src/main/java/codechicken/nei/LayoutManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ public static void layout(GuiContainer gui) {
if (gui.height - gui.ySize <= 40)
visiblity.showSearchSection = false;

if (visiblity.showBookmarkPanel || gui.guiTop <= 20)
visiblity.showSubsetDropdown = false;

if (!visiblity.showBookmarkPanel || gui.guiTop <= 20)
visiblity.showPresetsDropdown = false;

if (gui.guiLeft - 4 < 76)
visiblity.showWidgets = false;
try {
Expand Down Expand Up @@ -690,7 +696,9 @@ public static void updateWidgetVisiblities(GuiContainer gui, VisiblityData visib
if (visiblity.showBookmarkPanel) {
addWidget(bookmarkPanel);
bookmarkPanel.setVisible();
}

if (visiblity.showPresetsDropdown) {
addWidget(presetsPanel);
}

Expand All @@ -717,7 +725,7 @@ public static void updateWidgetVisiblities(GuiContainer gui, VisiblityData visib
addWidget(delete);
}

if (!visiblity.showBookmarkPanel) {
if (visiblity.showSubsetDropdown) {
// Bookmarks or Subset/dropdown
addWidget(dropDown);
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/codechicken/nei/VisiblityData.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ public class VisiblityData
* Bookmark panel and associated buttons
*/
public boolean showBookmarkPanel = true;
/**
* Subset dropdown
*/
public boolean showSubsetDropdown = true;
/**
* Presets dropdown
*/
public boolean showPresetsDropdown = true;
/**
* Item and search section
*/
Expand Down Expand Up @@ -40,6 +48,6 @@ public void translateDependancies()
if(!showWidgets)
showItemSection = showUtilityButtons = false;
if(!showItemSection)
showBookmarkPanel = showSearchSection = showItemPanel = false;
showBookmarkPanel = showSubsetDropdown = showPresetsDropdown = showSearchSection = showItemPanel = false;
}
}

0 comments on commit 1e93f71

Please sign in to comment.