Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/codechicken/nei/config/DataDumper.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void drawPrefix() {
}

public Rectangle4i dumpButtonSize() {
int width = 80;
int width = 50;
return new Rectangle4i(getSlot().slotWidth() - width, 0, width, 20);
}

Expand Down
27 changes: 20 additions & 7 deletions src/main/java/codechicken/nei/config/GuiHighlightTips.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import codechicken.core.gui.GuiCCButton;
import codechicken.core.gui.GuiScreenWidget;
import codechicken.lib.config.ConfigTag;
import codechicken.lib.math.MathHelper;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.HUDRenderer;
Expand All @@ -27,12 +28,16 @@ public class GuiHighlightTips extends GuiScreenWidget {
private final String name;
private GuiCCButton toggleButton;
private final Option opt;
private final GuiOptionList parentGui;
private final boolean world;
private Point dragDown;

public GuiHighlightTips(Option opt) {
super(80, 20);
this.opt = opt;
name = opt.name;
this.parentGui = (GuiOptionList) Minecraft.getMinecraft().currentScreen;
this.world = parentGui.worldConfig();
}

@Override
Expand All @@ -48,7 +53,7 @@ public void addWidgets() {
@Override
public void actionPerformed(String ident, Object... params) {
if (ident.equals("show")) {
opt.getTag(name).setBooleanValue(!show());
getTag(name).setBooleanValue(!show());
updateNames();
}
}
Expand All @@ -58,13 +63,21 @@ private void updateNames() {
}

private boolean show() {
return opt.renderTag(name).getBooleanValue();
return renderTag(name).getBooleanValue();
}

private ConfigTag getTag(String s) {
return (world ? opt.worldConfigSet() : opt.globalConfigSet()).config.getTag(s);
}

private ConfigTag renderTag(String s) {
return (world && opt.worldSpecific(s) ? opt.worldConfigSet() : opt.globalConfigSet()).config.getTag(s);
}

@Override
public void keyTyped(char c, int keycode) {
if (keycode == Keyboard.KEY_ESCAPE || keycode == Keyboard.KEY_BACK) {
Minecraft.getMinecraft().displayGuiScreen(opt.getSlot().getGui());
Minecraft.getMinecraft().displayGuiScreen(parentGui);
return;
}
super.keyTyped(c, keycode);
Expand All @@ -82,7 +95,7 @@ public void drawScreen(int mousex, int mousey, float f) {
}

public Point getPos() {
return new Point(opt.renderTag(name + ".x").getIntValue(), opt.renderTag(name + ".y").getIntValue());
return new Point(renderTag(name + ".x").getIntValue(), renderTag(name + ".y").getIntValue());
}

public Dimension sampleSize() // copied from HUDManager when running with the sample for this gui
Expand Down Expand Up @@ -148,8 +161,8 @@ protected void mouseClicked(int x, int y, int button) {
}

private void setPos(Point p) {
opt.getTag(name).setBooleanValue(show()); // duplicates global tag for the option gui if in world mode
opt.getTag(name + ".x").setIntValue(p.x);
opt.getTag(name + ".y").setIntValue(p.y);
getTag(name).setBooleanValue(show()); // duplicates global tag for the option gui if in world mode
getTag(name + ".x").setIntValue(p.x);
getTag(name + ".y").setIntValue(p.y);
}
}
4 changes: 3 additions & 1 deletion src/main/java/codechicken/nei/config/GuiItemIconDumper.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class GuiItemIconDumper extends GuiScreen {
}

private Option opt;
private final GuiOptionList parentGui;
private int drawIndex;
private int parseIndex;
private final File dir = new File(CommonUtils.getMinecraftDir(), "dumps/itempanel_icons");
Expand All @@ -52,6 +53,7 @@ public class GuiItemIconDumper extends GuiScreen {

public GuiItemIconDumper(Option opt, int iconSize) {
this.opt = opt;
this.parentGui = (GuiOptionList) Minecraft.getMinecraft().currentScreen;
this.iconSize = iconSize;
borderSize = iconSize / 16;
boxSize = iconSize + borderSize * 2;
Expand All @@ -62,7 +64,7 @@ public GuiItemIconDumper(Option opt, int iconSize) {
}

private void returnScreen(IChatComponent msg) {
Minecraft.getMinecraft().displayGuiScreen(opt.getSlot().getGui());
Minecraft.getMinecraft().displayGuiScreen(parentGui);
NEIClientUtils.printChatMessage(msg);
}

Expand Down
22 changes: 18 additions & 4 deletions src/main/java/codechicken/nei/config/GuiItemSorter.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import java.util.ArrayList;
import java.util.List;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;

import org.lwjgl.opengl.GL11;

import codechicken.lib.config.ConfigTag;
import codechicken.lib.math.MathHelper;
import codechicken.nei.ItemSorter;
import codechicken.nei.ItemSorter.SortEntry;
Expand Down Expand Up @@ -48,6 +50,8 @@ public boolean contains(int my) {
public final Option opt;
public final List<SortItem> slots = new ArrayList<>();
public final List<SortEntry> list;
private final GuiOptionList parentGui;
private final boolean world;

boolean dragging;
public SortItem dragged;
Expand All @@ -56,7 +60,9 @@ public boolean contains(int my) {

public GuiItemSorter(Option opt) {
this.opt = opt;
list = ItemSorter.fromSaveString(opt.renderTag().getValue());
this.parentGui = (GuiOptionList) Minecraft.getMinecraft().currentScreen;
this.world = parentGui.worldConfig();
list = ItemSorter.fromSaveString(renderTag(opt.configName()).getValue());
for (SortEntry e : list) slots.add(new SortItem(e));
}

Expand Down Expand Up @@ -98,7 +104,7 @@ public String getTitle() {

@Override
public GuiScreen getParentScreen() {
return opt.getSlot().getGui();
return parentGui;
}

@Override
Expand All @@ -114,16 +120,24 @@ public void updateScreen() {
list.remove(dragged.e);
list.add(nslot, dragged.e);

opt.getTag().setValue(ItemSorter.getSaveString(list));
getTag(opt.configName()).setValue(ItemSorter.getSaveString(list));
LayoutManager.markItemsDirty();

if (opt.activeTag() == opt.getTag()) {
if (opt.activeTag() == getTag(opt.configName())) {
ItemSorter.list = new ArrayList<>(list);
}
}
}
}

private ConfigTag getTag(String s) {
return (world ? opt.worldConfigSet() : opt.globalConfigSet()).config.getTag(s);
}

private ConfigTag renderTag(String s) {
return (world && opt.worldSpecific(s) ? opt.worldConfigSet() : opt.globalConfigSet()).config.getTag(s);
}

public SortItem itemAt(int mx, int my) {
if (!pane.windowBounds().contains(mx, my)) return null;

Expand Down
36 changes: 22 additions & 14 deletions src/main/java/codechicken/nei/config/GuiPanelSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.lwjgl.opengl.GL12;

import codechicken.core.gui.GuiScreenWidget;
import codechicken.lib.config.ConfigTag;
import codechicken.lib.gui.GuiDraw;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.vec.Rectangle4i;
Expand All @@ -21,7 +22,7 @@

public class GuiPanelSettings extends GuiScreenWidget {

private final Option opt;
private final GuiOptionList parentGui;

private PanelPlaceholder bookmarksPanel;
private PanelPlaceholder itemsPanel;
Expand Down Expand Up @@ -54,6 +55,7 @@ protected static class PanelPlaceholder {

private final Option opt;
private final String name;
private final boolean world;
private Rectangle4i margin;
private Point dragDown;
private String dragDir;
Expand All @@ -67,9 +69,10 @@ protected static class PanelPlaceholder {
private PanelResizeButton rightButton = new PanelResizeButton(PANEL_SIZE, PANEL_SIZE * 2);
private PanelResizeButton bottomButton = new PanelResizeButton(PANEL_SIZE * 2, PANEL_SIZE);

public PanelPlaceholder(Option opt, String name) {
public PanelPlaceholder(Option opt, String name, boolean world) {
this.opt = opt;
this.name = name;
this.world = world;
}

public void resize(Rectangle4i margin) {
Expand Down Expand Up @@ -116,10 +119,10 @@ protected int[] getPaddings() {
final int minWidth = ItemsGrid.SLOT_SIZE;
final int minHeight = ItemsGrid.SLOT_SIZE;

int paddingLeft = (int) Math.ceil(margin.w * opt.renderTag(name + ".left").getIntValue() / 100000.0);
int paddingTop = (int) Math.ceil(margin.h * opt.renderTag(name + ".top").getIntValue() / 100000.0);
int paddingRight = (int) Math.ceil(margin.w * opt.renderTag(name + ".right").getIntValue() / 100000.0);
int paddingBottom = (int) Math.ceil(margin.h * opt.renderTag(name + ".bottom").getIntValue() / 100000.0);
int paddingLeft = (int) Math.ceil(margin.w * getTag(name + ".left").getIntValue() / 100000.0);
int paddingTop = (int) Math.ceil(margin.h * getTag(name + ".top").getIntValue() / 100000.0);
int paddingRight = (int) Math.ceil(margin.w * getTag(name + ".right").getIntValue() / 100000.0);
int paddingBottom = (int) Math.ceil(margin.h * getTag(name + ".bottom").getIntValue() / 100000.0);

if (dragDir != null) {
final Point mouse = GuiDraw.getMousePosition();
Expand Down Expand Up @@ -159,6 +162,10 @@ protected int[] getPaddings() {
return new int[] { paddingLeft, paddingTop, paddingRight, paddingBottom };
}

private ConfigTag getTag(String s) {
return (world ? opt.worldConfigSet() : opt.globalConfigSet()).config.getTag(s);
}

protected void drawItems() {
final int columns = (w - 2) / ItemsGrid.SLOT_SIZE;
final int rows = (h - (PANEL_SIZE + 2) * 2 - 2) / ItemsGrid.SLOT_SIZE;
Expand Down Expand Up @@ -219,10 +226,10 @@ protected void mouseMovedOrUp(int x, int y, int button) {
if (button == 0 && dragDown != null) {
int[] padding = getPaddings();

opt.renderTag(name + ".left").setIntValue(padding[0] * 100000 / margin.w);
opt.renderTag(name + ".top").setIntValue(padding[1] * 100000 / margin.h);
opt.renderTag(name + ".right").setIntValue(padding[2] * 100000 / margin.w);
opt.renderTag(name + ".bottom").setIntValue(padding[3] * 100000 / margin.h);
getTag(name + ".left").setIntValue(padding[0] * 100000 / margin.w);
getTag(name + ".top").setIntValue(padding[1] * 100000 / margin.h);
getTag(name + ".right").setIntValue(padding[2] * 100000 / margin.w);
getTag(name + ".bottom").setIntValue(padding[3] * 100000 / margin.h);

dragDir = null;
dragDown = null;
Expand All @@ -232,10 +239,11 @@ protected void mouseMovedOrUp(int x, int y, int button) {

public GuiPanelSettings(Option opt) {
super(176, 198);
this.opt = opt;
this.parentGui = (GuiOptionList) Minecraft.getMinecraft().currentScreen;

bookmarksPanel = new PanelPlaceholder(opt, opt.name + ".bookmarks");
itemsPanel = new PanelPlaceholder(opt, opt.name + ".items");
boolean world = parentGui.worldConfig();
bookmarksPanel = new PanelPlaceholder(opt, opt.name + ".bookmarks", world);
itemsPanel = new PanelPlaceholder(opt, opt.name + ".items", world);
}

@Override
Expand All @@ -247,7 +255,7 @@ public boolean doesGuiPauseGame() {
public void keyTyped(char c, int keycode) {

if (keycode == Keyboard.KEY_ESCAPE || keycode == Keyboard.KEY_BACK) {
Minecraft.getMinecraft().displayGuiScreen(opt.getSlot().getGui());
Minecraft.getMinecraft().displayGuiScreen(parentGui);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PresetsList;
import codechicken.nei.PresetsList.Preset;
import codechicken.nei.config.GuiOptionList;
import codechicken.nei.config.GuiOptionPane;
import codechicken.nei.config.Option;

public class GuiPresetList extends GuiOptionPane {

private final Option opt;
private final GuiOptionList parentGui;
protected static final int SLOT_HEIGHT = 24;
protected static final int BUTTON_HEIGHT = 20;
protected GuiCCButton createButton;
Expand All @@ -31,6 +33,7 @@ public class GuiPresetList extends GuiOptionPane {

public GuiPresetList(Option opt) {
this.opt = opt;
this.parentGui = (GuiOptionList) Minecraft.getMinecraft().currentScreen;
this.createButton = new GuiCCButton(0, 2, 0, 16, NEIClientUtils.translate("presets.new"))
.setActionCommand("create");
this.toggleButton = new GuiCCButton(0, 2, 0, 16, NEIClientUtils.translate("presets.toggle"))
Expand Down Expand Up @@ -253,7 +256,7 @@ protected void drawSlot(Rectangle w, int slot, int x, int y, int mx, int my) {

@Override
public GuiScreen getParentScreen() {
return opt.getSlot().getGui();
return parentGui;
}

@Override
Expand Down