mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-25 14:34:54 +00:00
Added item icon dumping
Changed world overrides to activate on option change, rather than requiring the W button to be clicked
This commit is contained in:
1 parent
edb6225c43
commit
ec56527b74
17 files changed
+367
-81
No files matched your search
@@ -51,6 +51,25 @@ ACONST_NULL
|
||||
ARETURN
|
||||
LCONT
|
||||
|
||||
list d_glintAlphaFix
|
||||
ICONST_2
|
||||
IF_ICMPGE LBREAK
|
||||
SIPUSH 772
|
||||
ICONST_1
|
||||
ICONST_0
|
||||
ICONST_0
|
||||
INVOKESTATIC net/minecraft/client/renderer/OpenGlHelper.func_148821_a (IIII)V
|
||||
|
||||
list glintAlphaFix
|
||||
ICONST_1 #only do one loop. Normally the first one wipes the alpha, and the second one multiplies by the wiped alpha (0) and is redundant
|
||||
IF_ICMPGE LBREAK
|
||||
SIPUSH 772
|
||||
ICONST_1
|
||||
ICONST_0
|
||||
ICONST_1 #keep the destination alpha
|
||||
INVOKESTATIC net/minecraft/client/renderer/OpenGlHelper.func_148821_a (IIII)V
|
||||
|
||||
|
||||
#begin GuiContainer patches
|
||||
|
||||
list m_getManager
|
||||
|
||||
@@ -152,6 +152,9 @@ nei.options.tools.dump.itempanel.dumped=Item Panel contents were dumped to %s
|
||||
nei.options.tools.dump.itempanel.mode.0=CSV
|
||||
nei.options.tools.dump.itempanel.mode.1=NBT
|
||||
nei.options.tools.dump.itempanel.mode.2=Json
|
||||
nei.options.tools.dump.itempanel.mode.3=PNG
|
||||
nei.options.tools.dump.itempanel.icon.dumped=Item Panel icons were dumped to %s
|
||||
nei.options.tools.dump.itempanel.icon.cancelled=Dump cancelled
|
||||
|
||||
nei.layoutstyle.minecraft=Minecraft
|
||||
nei.layoutstyle.oldtmi=Old TMI
|
||||
|
||||
@@ -68,16 +68,6 @@ public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback
|
||||
ordering = newMap;
|
||||
}
|
||||
|
||||
public static String getSaveString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(SortEntry e : list) {
|
||||
if(sb.length() > 0)
|
||||
sb.append(',');
|
||||
sb.append(e.name);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static SortEntry find(String name) {
|
||||
for(SortEntry e : entries)
|
||||
if(e.name.equals(name))
|
||||
@@ -158,26 +148,45 @@ public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
});
|
||||
tag.getTag("inventory.itemsort").setDefaultValue(getSaveString());
|
||||
API.addOption(new OptionOpenGui("inventory.itemsort", GuiItemSorter.class));
|
||||
tag.getTag("inventory.itemsort").setDefaultValue(getSaveString(list));
|
||||
API.addOption(new OptionOpenGui("inventory.itemsort", GuiItemSorter.class) {
|
||||
@Override
|
||||
public void useGlobals() {
|
||||
super.useGlobals();
|
||||
list = fromSaveString(activeTag().getValue());
|
||||
}
|
||||
});
|
||||
ItemList.loadCallbacks.add(instance);
|
||||
}
|
||||
|
||||
public static void loadConfig() {
|
||||
String s = NEIClientConfig.getStringSetting("inventory.itemsort");
|
||||
if(s == null)
|
||||
list = new ArrayList<SortEntry>(entries);
|
||||
else {
|
||||
ArrayList<SortEntry> nlist = new ArrayList<SortEntry>();
|
||||
for(String s2 : s.split(",")) {
|
||||
SortEntry e = find(s2.trim());
|
||||
if(e != null)
|
||||
nlist.add(e);
|
||||
}
|
||||
for(SortEntry e : entries)
|
||||
if(!nlist.contains(e))
|
||||
nlist.add(e);
|
||||
list = nlist;
|
||||
public static String getSaveString(List<SortEntry> list) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(SortEntry e : list) {
|
||||
if(sb.length() > 0)
|
||||
sb.append(',');
|
||||
sb.append(e.name);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static ArrayList<SortEntry> fromSaveString(String s) {
|
||||
if(s == null)
|
||||
return new ArrayList<SortEntry>(entries);
|
||||
|
||||
ArrayList<SortEntry> list = new ArrayList<SortEntry>();
|
||||
for(String s2 : s.split(",")) {
|
||||
SortEntry e = find(s2.trim());
|
||||
if(e != null)
|
||||
list.add(e);
|
||||
}
|
||||
for(SortEntry e : entries)
|
||||
if(!list.contains(e))
|
||||
list.add(e);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void loadConfig() {
|
||||
list = fromSaveString(NEIClientConfig.getStringSetting("inventory.itemsort"));
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class NEIClientConfig
|
||||
|
||||
Collections.sort(list);
|
||||
|
||||
int nextLayout = getTag().getIntValue();
|
||||
int nextLayout = renderTag().getIntValue();
|
||||
if (nextLayout == list.getLast())//loop list
|
||||
nextLayout = -1;
|
||||
for (Integer i : list) {
|
||||
@@ -292,7 +292,9 @@ public class NEIClientConfig
|
||||
}
|
||||
|
||||
public static boolean isWorldSpecific(String setting) {
|
||||
return world != null && world.config.containsTag(setting);
|
||||
if(world == null) return false;
|
||||
ConfigTag tag = world.config.getTag(setting, false);
|
||||
return tag != null && tag.value != null;
|
||||
}
|
||||
|
||||
public static boolean isStateSaved(int i) {
|
||||
|
||||
@@ -52,6 +52,10 @@ public class NEITransformer implements IClassTransformer
|
||||
}
|
||||
});
|
||||
|
||||
//put glint alpha into the buffer correctly for exporting
|
||||
transformer.add(new MethodReplacer(new ObfMapping("net/minecraft/client/renderer/entity/RenderItem", "func_77018_a", "(IIIII)V"),
|
||||
asmblocks.get("d_glintAlphaFix"), asmblocks.get("glintAlphaFix")));
|
||||
|
||||
|
||||
String GuiContainer = "net/minecraft/client/gui/inventory/GuiContainer";
|
||||
//add manager field
|
||||
|
||||
@@ -86,8 +86,8 @@ public abstract class DataDumper extends Option
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
drawPrefix();
|
||||
if(modeCount() > 1)
|
||||
drawModeButton(mousex, mousey);
|
||||
drawDumpButton(mousex, mousey);
|
||||
drawButton(mousex, mousey, modeButtonSize(), modeButtonText());
|
||||
drawButton(mousex, mousey, dumpButtonSize(), dumpButtonText());
|
||||
}
|
||||
|
||||
public void drawPrefix() {
|
||||
@@ -101,7 +101,7 @@ public abstract class DataDumper extends Option
|
||||
|
||||
public Rectangle4i modeButtonSize() {
|
||||
int width = 60;
|
||||
return new Rectangle4i(slot.slotWidth() - width - 10 - dumpButtonSize().w, 0, width, 20);
|
||||
return new Rectangle4i(dumpButtonSize().x - width - 6, 0, width, 20);
|
||||
}
|
||||
|
||||
public String dumpButtonText() {
|
||||
@@ -113,23 +113,14 @@ public abstract class DataDumper extends Option
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return getTag().getIntValue(0);
|
||||
return renderTag().getIntValue(0);
|
||||
}
|
||||
|
||||
public void drawModeButton(int mousex, int mousey) {
|
||||
public void drawButton(int mousex, int mousey, Rectangle4i b, String text) {
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
Rectangle4i b = modeButtonSize();
|
||||
boolean hover = b.contains(mousex, mousey);
|
||||
LayoutManager.drawButtonBackground(b.x, b.y, b.w, b.h, true, getButtonTex(hover));
|
||||
drawStringC(modeButtonText(), b.x, b.y, b.w, b.h, getTextColour(hover));
|
||||
}
|
||||
|
||||
public void drawDumpButton(int mousex, int mousey) {
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
Rectangle4i b = dumpButtonSize();
|
||||
boolean hover = b.contains(mousex, mousey);
|
||||
LayoutManager.drawButtonBackground(b.x, b.y, b.w, b.h, true, getButtonTex(hover));
|
||||
drawStringC(dumpButtonText(), b.x, b.y, b.w, b.h, getTextColour(hover));
|
||||
drawStringC(text, b.x, b.y, b.w, b.h, getTextColour(hover));
|
||||
}
|
||||
|
||||
public int getButtonTex(boolean hover) {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class GuiHighlightTips extends GuiScreenWidget
|
||||
}
|
||||
|
||||
private boolean show() {
|
||||
return opt.getTag(name).getBooleanValue();
|
||||
return opt.renderTag(name).getBooleanValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,7 +74,7 @@ public class GuiHighlightTips extends GuiScreenWidget
|
||||
}
|
||||
|
||||
public Point getPos() {
|
||||
return new Point(opt.getTag(name + ".x").getIntValue(), opt.getTag(name + ".y").getIntValue());
|
||||
return new Point(opt.renderTag(name + ".x").getIntValue(), opt.renderTag(name + ".y").getIntValue());
|
||||
}
|
||||
|
||||
public Dimension sampleSize()//copied from HUDManager when running with the sample for this gui
|
||||
@@ -143,6 +143,7 @@ public class GuiHighlightTips extends GuiScreenWidget
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
package codechicken.nei.config;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemPanel;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class GuiItemIconDumper extends GuiScreen
|
||||
{
|
||||
final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47};
|
||||
static {
|
||||
Arrays.sort(illegalChars);
|
||||
}
|
||||
|
||||
private Option opt;
|
||||
private int drawIndex;
|
||||
private int parseIndex;
|
||||
private File dir = new File(CommonUtils.getMinecraftDir(), "dumps/itempanel_icons");
|
||||
private int iconSize;
|
||||
private int borderSize;
|
||||
private int boxSize;
|
||||
|
||||
public GuiItemIconDumper(Option opt, int iconSize) {
|
||||
this.opt = opt;
|
||||
this.iconSize = iconSize;
|
||||
borderSize = iconSize/16;
|
||||
boxSize = iconSize + borderSize*2;
|
||||
|
||||
if (dir.exists()) {
|
||||
for (File f : dir.listFiles())
|
||||
if (f.isFile()) f.delete();
|
||||
} else
|
||||
dir.mkdirs();
|
||||
|
||||
}
|
||||
|
||||
private void returnScreen(IChatComponent msg) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(opt.slot.getGui());
|
||||
NEIClientUtils.printChatMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char c, int keycode) {
|
||||
if (keycode == Keyboard.KEY_ESCAPE || keycode == Keyboard.KEY_BACK) {
|
||||
returnScreen(new ChatComponentTranslation(opt.fullName()+".icon.cancelled"));
|
||||
return;
|
||||
}
|
||||
super.keyTyped(c, keycode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mousex, int mousey, float frame) {
|
||||
try {
|
||||
drawItems();
|
||||
exportItems();
|
||||
}
|
||||
catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Error dumping item icons", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawItems() {
|
||||
Dimension d = GuiDraw.displayRes();
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glOrtho(0.0D, d.width*16D/iconSize, d.height*16D/iconSize, 0.0D, 1000.0D, 3000.0D);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glClearColor(0, 0, 0, 0);
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
int rows = d.height / boxSize;
|
||||
int cols = d.width / boxSize;
|
||||
int fit = rows*cols;
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
|
||||
for(int i = 0; drawIndex < ItemPanel.items.size() && i < fit; drawIndex++, i++) {
|
||||
int x = i%cols * 18;
|
||||
int y = i/cols * 18;
|
||||
GuiContainerManager.drawItem(x+1, y+1, ItemPanel.items.get(drawIndex));
|
||||
}
|
||||
|
||||
GL11.glFlush();
|
||||
}
|
||||
|
||||
private void exportItems() throws IOException {
|
||||
BufferedImage img = screenshot();
|
||||
int rows = img.getHeight() / boxSize;
|
||||
int cols = img.getWidth() / boxSize;
|
||||
int fit = rows*cols;
|
||||
for(int i = 0; parseIndex < ItemPanel.items.size() && i < fit; parseIndex++, i++) {
|
||||
int x = i%cols * boxSize;
|
||||
int y = i/cols * boxSize;
|
||||
exportImage(dir, img.getSubimage(x+borderSize, y+borderSize, iconSize, iconSize), ItemPanel.items.get(parseIndex));
|
||||
}
|
||||
|
||||
if(parseIndex >= ItemPanel.items.size())
|
||||
returnScreen(new ChatComponentTranslation(opt.fullName()+".icon.dumped", "dumps/itempanel_icons"));
|
||||
}
|
||||
|
||||
public static String cleanFileName(String name) {
|
||||
StringBuilder cleanName = new StringBuilder();
|
||||
for (int i = 0; i < name.length(); i++) {
|
||||
int c = (int)name.charAt(i);
|
||||
if (Arrays.binarySearch(illegalChars, c) < 0)
|
||||
cleanName.append((char)c);
|
||||
else
|
||||
cleanName.append('_');
|
||||
}
|
||||
return cleanName.toString();
|
||||
}
|
||||
|
||||
private void exportImage(File dir, BufferedImage img, ItemStack stack) throws IOException {
|
||||
String name = EnumChatFormatting.getTextWithoutFormattingCodes(GuiContainerManager.itemDisplayNameShort(stack));
|
||||
name = cleanFileName(name);
|
||||
File file = new File(dir, name+".png");
|
||||
for(int i = 2; file.exists(); i++)
|
||||
file = new File(dir, name+'_'+i+".png");
|
||||
ImageIO.write(img, "png", file);
|
||||
}
|
||||
|
||||
private IntBuffer pixelBuffer;
|
||||
private int[] pixelValues;
|
||||
|
||||
private BufferedImage screenshot() {
|
||||
Framebuffer fb = Minecraft.getMinecraft().getFramebuffer();
|
||||
Dimension mcSize = GuiDraw.displayRes();
|
||||
Dimension texSize = mcSize;
|
||||
|
||||
if (OpenGlHelper.isFramebufferEnabled())
|
||||
texSize = new Dimension(fb.framebufferTextureWidth, fb.framebufferTextureHeight);
|
||||
|
||||
int k = texSize.width * texSize.height;
|
||||
if (pixelBuffer == null || pixelBuffer.capacity() < k) {
|
||||
pixelBuffer = BufferUtils.createIntBuffer(k);
|
||||
pixelValues = new int[k];
|
||||
}
|
||||
|
||||
GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
|
||||
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
|
||||
pixelBuffer.clear();
|
||||
|
||||
if (OpenGlHelper.isFramebufferEnabled()) {
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, fb.framebufferTexture);
|
||||
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
|
||||
} else {
|
||||
GL11.glReadPixels(0, 0, texSize.width, texSize.height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
|
||||
}
|
||||
|
||||
pixelBuffer.get(pixelValues);
|
||||
TextureUtil.func_147953_a(pixelValues, texSize.width, texSize.height);
|
||||
|
||||
BufferedImage img = new BufferedImage(mcSize.width, mcSize.height, BufferedImage.TYPE_INT_ARGB);
|
||||
if (OpenGlHelper.isFramebufferEnabled()) {
|
||||
int yOff = texSize.height - mcSize.height;
|
||||
for (int y = 0; y < mcSize.height; ++y)
|
||||
for (int x = 0; x < mcSize.width; ++x)
|
||||
img.setRGB(x, y, pixelValues[(y + yOff) * texSize.width + x]);
|
||||
} else {
|
||||
img.setRGB(0, 0, texSize.width, height, pixelValues, 0, texSize.width);
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
public static void renderGlint(RenderItem r, int p_77018_2_, int p_77018_3_, int p_77018_4_, int p_77018_5_) {
|
||||
for (int j1 = 0; j1 < 1; ++j1)
|
||||
{
|
||||
OpenGlHelper.glBlendFunc(772, 1, 0, 1);
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
float f2 = (float)(Minecraft.getSystemTime() % (long)(3000 + j1 * 1873)) / (3000.0F + (float)(j1 * 1873)) * 256.0F;
|
||||
float f3 = 0.0F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
float f4 = 4.0F;
|
||||
|
||||
if (j1 == 1)
|
||||
{
|
||||
f4 = -1.0F;
|
||||
}
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double)(p_77018_2_ + 0), (double)(p_77018_3_ + p_77018_5_), (double)r.zLevel, (double)((f2 + (float)p_77018_5_ * f4) * f), (double)((f3 + (float)p_77018_5_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_77018_2_ + p_77018_4_), (double)(p_77018_3_ + p_77018_5_), (double)r.zLevel, (double)((f2 + (float)p_77018_4_ + (float)p_77018_5_ * f4) * f), (double)((f3 + (float)p_77018_5_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_77018_2_ + p_77018_4_), (double)(p_77018_3_ + 0), (double)r.zLevel, (double)((f2 + (float)p_77018_4_) * f), (double)((f3 + 0.0F) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_77018_2_ + 0), (double)(p_77018_3_ + 0), (double)r.zLevel, (double)((f2 + 0.0F) * f), (double)((f3 + 0.0F) * f1));
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class GuiItemSorter extends GuiOptionPane
|
||||
}
|
||||
|
||||
public int slotY() {
|
||||
return GuiItemSorter.this.slotY(ItemSorter.list.indexOf(e));
|
||||
return GuiItemSorter.this.slotY(list.indexOf(e));
|
||||
}
|
||||
|
||||
public void update(int my) {
|
||||
@@ -47,6 +47,7 @@ public class GuiItemSorter extends GuiOptionPane
|
||||
|
||||
public Option opt;
|
||||
public List<SortItem> slots = new ArrayList<SortItem>();
|
||||
public List<SortEntry> list;
|
||||
|
||||
boolean dragging;
|
||||
public SortItem dragged;
|
||||
@@ -55,7 +56,8 @@ public class GuiItemSorter extends GuiOptionPane
|
||||
|
||||
public GuiItemSorter(Option opt) {
|
||||
this.opt = opt;
|
||||
for(SortEntry e : ItemSorter.list)
|
||||
list = ItemSorter.fromSaveString(opt.renderTag().getValue());
|
||||
for(SortEntry e : list)
|
||||
slots.add(new SortItem(e));
|
||||
}
|
||||
|
||||
@@ -65,7 +67,7 @@ public class GuiItemSorter extends GuiOptionPane
|
||||
|
||||
@Override
|
||||
public int contentHeight() {
|
||||
return ItemSorter.list.size()*24;
|
||||
return slots.size()*24;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,12 +115,12 @@ public class GuiItemSorter extends GuiOptionPane
|
||||
|
||||
if(dragging) {
|
||||
int nslot = (int)MathHelper.clip((dragged.y-(2-12))/24, 0, slots.size()-1);
|
||||
if(nslot != ItemSorter.list.indexOf(dragged.e)) {
|
||||
ArrayList<SortEntry> list = new ArrayList<SortEntry>(ItemSorter.list);
|
||||
if(nslot != list.indexOf(dragged.e)) {
|
||||
list.remove(dragged.e);
|
||||
list.add(nslot, dragged.e);
|
||||
ItemSorter.list = list;//just to be safe with concurrency
|
||||
opt.getTag().setValue(ItemSorter.getSaveString());
|
||||
opt.getTag().setValue(ItemSorter.getSaveString(list));
|
||||
if(opt.activeTag() == opt.getTag())
|
||||
ItemSorter.list = new ArrayList<SortEntry>(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package codechicken.nei.config;
|
||||
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemPanel;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
@@ -19,6 +22,8 @@ import java.util.LinkedList;
|
||||
|
||||
public class ItemPanelDumper extends DataDumper
|
||||
{
|
||||
private static int[] resolutions = new int[]{16, 32, 48, 64, 128, 256};
|
||||
|
||||
public ItemPanelDumper(String name) {
|
||||
super(name);
|
||||
}
|
||||
@@ -48,6 +53,36 @@ public class ItemPanelDumper extends DataDumper
|
||||
return translateN(name);
|
||||
}
|
||||
|
||||
public int getRes() {
|
||||
int i = renderTag(name+".res").getIntValue(0);
|
||||
if(i >= resolutions.length || i < 0) renderTag().setIntValue(i = 0);
|
||||
return resolutions[i];
|
||||
}
|
||||
|
||||
public Rectangle4i resButtonSize() {
|
||||
int width = 50;
|
||||
return new Rectangle4i(modeButtonSize().x - width - 6, 0, width, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
super.draw(mousex, mousey, frame);
|
||||
if(getMode() == 3) {
|
||||
int res = getRes();
|
||||
drawButton(mousex, mousey, resButtonSize(), res+"x"+res);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mousex, int mousey, int button) {
|
||||
if(getMode() == 3 && resButtonSize().contains(mousex, mousey)) {
|
||||
NEIClientUtils.playClickSound();
|
||||
getTag(name+".res").setIntValue((renderTag(name+".res").getIntValue(0) + 1) % resolutions.length);
|
||||
}
|
||||
else
|
||||
super.mouseClicked(mousex, mousey, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileExtension() {
|
||||
switch(getMode()) {
|
||||
@@ -68,6 +103,14 @@ public class ItemPanelDumper extends DataDumper
|
||||
return translateN(name + ".mode." + getMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpFile() {
|
||||
if(getMode() == 3)
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiItemIconDumper(this, getRes()));
|
||||
else
|
||||
super.dumpFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpTo(File file) throws IOException {
|
||||
if (getMode() == 0)
|
||||
@@ -102,6 +145,6 @@ public class ItemPanelDumper extends DataDumper
|
||||
|
||||
@Override
|
||||
public int modeCount() {
|
||||
return 3;
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,8 @@ public abstract class Option
|
||||
* @return true if the world config contains a tag with this name
|
||||
*/
|
||||
public boolean worldSpecific(String s) {
|
||||
return worldConfigSet().config.containsTag(s);
|
||||
ConfigTag tag = worldConfigSet().config.getTag(s, false);
|
||||
return tag != null && tag.value != null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,6 +112,20 @@ public abstract class Option
|
||||
return configSet().config.getTag(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The tag currently being used ingame, world if a world override exists, otherwise global
|
||||
*/
|
||||
public ConfigTag activeTag() {
|
||||
return activeTag(configName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The tag currently being used ingame, world if a world override exists, otherwise global
|
||||
*/
|
||||
public ConfigTag activeTag(String s) {
|
||||
return (worldSpecific() ? worldConfigSet() : globalConfigSet()).config.getTag(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the gui is in world config mode
|
||||
*/
|
||||
@@ -151,7 +166,7 @@ public abstract class Option
|
||||
* Called when world specific is activated for this option. Should copy the global value into a world specific override
|
||||
*/
|
||||
public void copyGlobals() {
|
||||
copyGlobal(configName());
|
||||
copyGlobal(configName(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,9 +31,6 @@ public class OptionCycled extends OptionButton
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
if (defaulting())
|
||||
return false;
|
||||
|
||||
return cycle();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,6 @@ public class OptionKeyBind extends OptionButton
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
if (defaulting())
|
||||
return false;
|
||||
|
||||
if (button == 0) {
|
||||
hasFocus = true;
|
||||
return true;
|
||||
|
||||
@@ -12,16 +12,8 @@ public class OptionOpenGui extends OptionButton
|
||||
this.guiClass = guiClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyGlobals() {
|
||||
copyGlobal(name, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
if (defaulting())
|
||||
return false;
|
||||
|
||||
try {
|
||||
Minecraft.getMinecraft().displayGuiScreen(guiClass.getConstructor(Option.class).newInstance(this));
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -63,9 +63,6 @@ public abstract class OptionStringSet extends Option
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int x, int y, int button) {
|
||||
if (defaulting())
|
||||
return;
|
||||
|
||||
if (clickButton(x, y, button))
|
||||
playClickSound();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ public class OptionTextField extends Option
|
||||
@Override
|
||||
public void onTextChange(String oldText) {
|
||||
if(focused() && isValidValue(text()))
|
||||
getTag().setValue(text());
|
||||
if(!defaulting() || !text().equals(getTag().getValue()))//don't override global if text hasn't changed
|
||||
getTag().setValue(text());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,11 +33,8 @@ public class OptionTextField extends Option
|
||||
|
||||
@Override
|
||||
public void setFocus(boolean focus) {
|
||||
if (focus && defaulting())
|
||||
return;
|
||||
|
||||
if (!focus && !isValidValue(text()))
|
||||
setText(getTag().getValue());
|
||||
setText(renderTag().getValue());
|
||||
|
||||
focused = focus;
|
||||
}
|
||||
|
||||
@@ -28,9 +28,6 @@ public class OptionToggleButton extends OptionButton
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
if (defaulting())
|
||||
return false;
|
||||
|
||||
getTag().setBooleanValue(!state());
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user