Mostly working. Tinker Table GUI has some bugs
This commit is contained in:
parent
e7392b29d2
commit
a177803885
|
@ -53,23 +53,21 @@ public class CosmeticGui extends MuseGui {
|
|||
Colour.DARKBLUE.withAlpha(0.8F));
|
||||
frames.add(renderframe);
|
||||
|
||||
//FIXME!!!!
|
||||
ColourPickerFrame colourpicker = new ColourPickerFrame(
|
||||
new MuseRect(absX(0.18f), absY(-0.95f),
|
||||
absX(0.95f), absY(-0.025f)),
|
||||
Colour.LIGHTBLUE.withAlpha(0.8F),
|
||||
Colour.DARKBLUE.withAlpha(0.8F),
|
||||
itemSelect);
|
||||
frames.add(colourpicker);
|
||||
|
||||
// ColourPickerFrame colourpicker = new ColourPickerFrame(
|
||||
// new MuseRect(absX(0.18f), absY(-0.95f),
|
||||
// absX(0.95f), absY(-0.025f)),
|
||||
// Colour.LIGHTBLUE.withAlpha(0.8F),
|
||||
// Colour.DARKBLUE.withAlpha(0.8F),
|
||||
// itemSelect);
|
||||
// frames.add(colourpicker);
|
||||
//
|
||||
// PartManipContainer partframe = new PartManipContainer(
|
||||
// itemSelect, colourpicker,
|
||||
// new MusePoint2D(absX(-0.95F), absY(0.025f)),
|
||||
// new MusePoint2D(absX(+0.95F), absY(0.95f)),
|
||||
// Colour.LIGHTBLUE.withAlpha(0.8F),
|
||||
// Colour.DARKBLUE.withAlpha(0.8F));
|
||||
// frames.add(partframe);
|
||||
PartManipContainer partframe = new PartManipContainer(
|
||||
itemSelect, colourpicker,
|
||||
new MusePoint2D(absX(-0.95F), absY(0.025f)),
|
||||
new MusePoint2D(absX(+0.95F), absY(0.95f)),
|
||||
Colour.LIGHTBLUE.withAlpha(0.8F),
|
||||
Colour.DARKBLUE.withAlpha(0.8F));
|
||||
frames.add(partframe);
|
||||
|
||||
TabSelectFrame tabFrame = new TabSelectFrame(
|
||||
player,
|
||||
|
|
|
@ -12,22 +12,19 @@ public class ArmorModelInstance {
|
|||
private static ModelBiped instance = null;
|
||||
private static NBTTagCompound renderSpec;
|
||||
|
||||
private static boolean smartMoving = false;
|
||||
|
||||
public static ModelBiped getInstance() {
|
||||
// TODO: Actual (skinned) vanilla model as low bandwitdth alternative
|
||||
|
||||
if (instance == null) {
|
||||
// try {
|
||||
// MuseLogger.logInfo("Attempting to load Smart Moving armor model.");
|
||||
// instance = SMovingArmorModel.getInstance();
|
||||
// smartMoving = true;
|
||||
// MuseLogger.logInfo("Smart Moving armor model loaded successfully!");
|
||||
// } catch (Throwable e) {
|
||||
// MuseLogger.logInfo("Smart Moving armor model did not load successfully. Either Smart Moving is not installed, or there was another problem.");
|
||||
try {
|
||||
MuseLogger.logInfo("Attempting to load Smart Moving armor model.");
|
||||
instance = SMovingArmorModel.getInstance();
|
||||
MuseLogger.logInfo("Smart Moving armor model loaded successfully!");
|
||||
} catch (Throwable e) {
|
||||
MuseLogger.logInfo("Smart Moving armor model did not load successfully. Either Smart Moving is not installed, or there was another problem.");
|
||||
instance = VanillaArmorModel.getInstance();
|
||||
// }
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -72,9 +72,6 @@ public class SMovingArmorModel extends ModelPlayer implements IArmorModel {
|
|||
*/
|
||||
@Override
|
||||
public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float scale) {
|
||||
System.out.println("Stuff is happening here!!");
|
||||
|
||||
|
||||
prep(entity, par2, par3, par4, par5, par6, scale);
|
||||
renderPlayerBase.setRotationAngles(par2, par3, par4, par5, par6, scale, entity);
|
||||
renderPlayerBase.render(entity, par2, par3, par4, par5, par6, scale);
|
||||
|
|
|
@ -113,8 +113,15 @@ public class DefaultModelSpec {
|
|||
public static List<NBTTagCompound> makePrefs(String modelname, String[] partnames, int colour, boolean glow) {
|
||||
List<NBTTagCompound> prefArray = new ArrayList<>();
|
||||
ModelSpec model = ModelRegistry.getInstance().get(modelname);
|
||||
for (String name: partnames)
|
||||
for (String name: partnames) {
|
||||
prefArray.add(makePref(model.get(name), colour, glow));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return prefArray;
|
||||
}
|
||||
|
|
@ -53,7 +53,6 @@ public class ModelSpecXMLReader {
|
|||
|
||||
if (modelNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
parseModel(modelNode);
|
||||
Element eElement = (Element) modelNode;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -69,9 +68,10 @@ public class ModelSpecXMLReader {
|
|||
|
||||
if (modelnode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element eElement = (Element) modelnode;
|
||||
|
||||
file = eElement.getAttribute("file");
|
||||
textures = eElement.getAttribute("textures").split(",");
|
||||
|
||||
// These are null because they are not used in the files
|
||||
offset = parseVector(eElement.getAttribute("offset"));
|
||||
rotation = parseVector(eElement.getAttribute("rotation"));
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class ModelSpecXMLReader {
|
|||
ModelSpec modelspec = new ModelSpec(model, textures, offset, rotation, file);
|
||||
ModelSpec existingspec = ModelRegistry.getInstance().put(MuseStringUtils.extractName(file), modelspec);
|
||||
|
||||
NodeList bindingNodeList = eElement.getElementsByTagName("model");
|
||||
NodeList bindingNodeList = eElement.getElementsByTagName("binding");
|
||||
for (int temp = 0; temp < bindingNodeList.getLength(); temp++) {
|
||||
Node bindingnode = bindingNodeList.item(temp);
|
||||
parseBinding(bindingnode, existingspec);
|
||||
|
@ -96,7 +96,6 @@ public class ModelSpecXMLReader {
|
|||
Element eElement = (Element) bindingnode;
|
||||
int slot = parseInt(eElement.getAttribute("slot"));
|
||||
MorphTarget target = parseTarget(eElement.getAttribute("target"));
|
||||
|
||||
NodeList partNodeList = eElement.getElementsByTagName("part");
|
||||
for (int temp = 0; temp < partNodeList.getLength(); temp++) {
|
||||
Node partnode = partNodeList.item(temp);
|
||||
|
@ -108,11 +107,11 @@ public class ModelSpecXMLReader {
|
|||
public void parseParts(Node partNode, ModelSpec modelspec, int slot, MorphTarget target) {
|
||||
if (partNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element eElement = (Element) partNode;
|
||||
Colour defaultcolor = parseColour(eElement.getAttribute("defaultcolor"));
|
||||
// Colour defaultcolor = parseColour(eElement.getAttribute("defaultcolor"));
|
||||
Boolean defaultglow = parseBool(eElement.getAttribute("defaultglow"));
|
||||
String name = eElement.getAttribute("name");
|
||||
|
||||
String polygroup = validatePolygroup(eElement.getAttribute("name"), modelspec);
|
||||
String polygroup = validatePolygroup(eElement.getAttribute("polygroup"), modelspec);
|
||||
|
||||
if (polygroup != null) {
|
||||
ModelPartSpec partspec = new ModelPartSpec(modelspec, target, polygroup, slot, 0, (defaultglow != null) ? defaultglow :false, name);
|
||||
|
@ -179,7 +178,6 @@ public class ModelSpecXMLReader {
|
|||
double x = Double.parseDouble(ss[0]);
|
||||
double y = Double.parseDouble(ss[1]);
|
||||
double z = Double.parseDouble(ss[2]);
|
||||
|
||||
return Vec3.createVectorHelper(x, y, z);
|
||||
} catch (Exception e) {
|
||||
return null;
|
|
@ -0,0 +1,48 @@
|
|||
package net.machinemuse.powersuits.client.render.modelspec;
|
||||
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 2:09 AM, 29/04/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/8/16.
|
||||
*/
|
||||
public enum MorphTarget {
|
||||
Cloak,
|
||||
Head,
|
||||
Body,
|
||||
RightArm,
|
||||
LeftArm,
|
||||
RightLeg,
|
||||
LeftLeg;
|
||||
|
||||
public ModelRenderer apply(ModelBiped m) {
|
||||
switch(this) {
|
||||
case Cloak:
|
||||
return m.bipedCloak;
|
||||
|
||||
case Head:
|
||||
return m.bipedHead;
|
||||
|
||||
case Body:
|
||||
return m.bipedBody;
|
||||
|
||||
case RightArm:
|
||||
return m.bipedRightArm;
|
||||
|
||||
case LeftArm:
|
||||
return m.bipedLeftArm;
|
||||
|
||||
case RightLeg:
|
||||
return m.bipedRightLeg;
|
||||
|
||||
case LeftLeg:
|
||||
return m.bipedLeftLeg;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,26 +15,8 @@ import org.lwjgl.opengl.GL11;
|
|||
* Ported to Java by lehjr on 10/19/16.
|
||||
*/
|
||||
public class GuiIcons {
|
||||
private GuiIcons() {
|
||||
}
|
||||
public static class GuiIcon {
|
||||
|
||||
public GuiIcons INSTANCE = new GuiIcons();
|
||||
|
||||
|
||||
public interface IGuiIcon {
|
||||
double size = 0;
|
||||
String filepath = null;
|
||||
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
Colour c = null;
|
||||
double xmin = 0;
|
||||
double ymin = 0;
|
||||
double xmax = 0;
|
||||
double yma = 0;
|
||||
}
|
||||
|
||||
public static class GuiIcon implements IGuiIcon {
|
||||
final double size;
|
||||
final String filepath;
|
||||
|
||||
|
@ -71,72 +53,48 @@ public class GuiIcons {
|
|||
}
|
||||
|
||||
public static class Checkmark extends GuiIcon {
|
||||
// double size = 16.0;
|
||||
// String filepath = Config.TEXTURE_PREFIX() + "gui/checkmark.png";
|
||||
|
||||
public Checkmark(double x, double y, Colour c, Double xmin, Double ymin, Double xmax, Double ymax) {
|
||||
super(16.0, Config.TEXTURE_PREFIX() + "gui/checkmark.png", x, y, c, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TransparentArmor extends GuiIcon {
|
||||
// double size = 8.0;
|
||||
// String filepath = Config.TEXTURE_PREFIX() + "gui/transparentarmor.png";
|
||||
|
||||
public TransparentArmor(double x, double y, Colour c, Double xmin, Double ymin, Double xmax, Double ymax) {
|
||||
super(8.0, Config.TEXTURE_PREFIX() + "gui/transparentarmor.png", x, y, c, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
|
||||
public static class NormalArmor extends GuiIcon {
|
||||
// double size = 8.0;
|
||||
// String filepath = Config.TEXTURE_PREFIX() + "gui/normalarmor.png";
|
||||
|
||||
public NormalArmor(double x, double y, Colour c, Double xmin, Double ymin, Double xmax, Double ymax) {
|
||||
super(8.0, Config.TEXTURE_PREFIX() + "gui/normalarmor.png", x, y, c, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
|
||||
public static class GlowArmor extends GuiIcon {
|
||||
// double size = 8.0;
|
||||
// String filepath = Config.TEXTURE_PREFIX() + "gui/glowarmor.png";
|
||||
|
||||
public GlowArmor(double x, double y, Colour c, Double xmin, Double ymin, Double xmax, Double ymax) {
|
||||
super(8.0, Config.TEXTURE_PREFIX() + "gui/glowarmor.png", x, y, c, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SelectedArmorOverlay extends GuiIcon {
|
||||
// double size = 8.0;
|
||||
// String filepath = Config.TEXTURE_PREFIX() + "gui/armordisplayselect.png";
|
||||
|
||||
public SelectedArmorOverlay(double x, double y, Colour c, Double xmin, Double ymin, Double xmax, Double ymax) {
|
||||
super(8.0, Config.TEXTURE_PREFIX() + "gui/armordisplayselect.png", x, y, c, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ArmourColourPatch extends GuiIcon {
|
||||
// double size = 8.0;
|
||||
// String filepath = Config.TEXTURE_PREFIX() + "gui/colourclicker.png";
|
||||
|
||||
public ArmourColourPatch(double x, double y, Colour c, Double xmin, Double ymin, Double xmax, Double ymax) {
|
||||
super(8.0, Config.TEXTURE_PREFIX() + "gui/colourclicker.png", x, y, c, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MinusSign extends GuiIcon {
|
||||
// double size = 8.0;
|
||||
// String filepath = Config.TEXTURE_PREFIX() + "gui/minussign.png";
|
||||
|
||||
public MinusSign(double x, double y, Colour c, Double xmin, Double ymin, Double xmax, Double ymax) {
|
||||
super(8.0, Config.TEXTURE_PREFIX() + "gui/minussign.png", x, y, c, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlusSign extends GuiIcon {
|
||||
// double size = 8.0;
|
||||
// String filepath = Config.TEXTURE_PREFIX() + "gui/plussign.png";
|
||||
|
||||
public PlusSign(double x, double y, Colour c, Double xmin, Double ymin, Double xmax, Double ymax) {
|
||||
super(8.0, Config.TEXTURE_PREFIX() + "gui/plussign.png", x, y, c, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
|
|
|
@ -1,236 +1,222 @@
|
|||
//package net.machinemuse.general.gui.frame;
|
||||
//
|
||||
//import com.google.common.collect.Sets;
|
||||
//import net.minecraft.util.StatCollector;
|
||||
//import net.machinemuse.numina.geometry.MusePoint2D;
|
||||
//import net.machinemuse.numina.general.MuseLogger;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//import net.machinemuse.utils.render.GuiIcons;
|
||||
//import org.apache.commons.lang3.ArrayUtils;
|
||||
//import scala.Predef$;
|
||||
//import net.minecraft.nbt.NBTBase;
|
||||
//import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
//import net.minecraft.item.Item;
|
||||
//import net.minecraft.nbt.NBTTagCompound;
|
||||
//import net.machinemuse.numina.network.PacketSender;
|
||||
//import net.minecraft.entity.player.EntityPlayer;
|
||||
//import net.machinemuse.powersuits.network.packets.MusePacketColourInfo;
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import scala.runtime.BoxedUnit;
|
||||
//import net.machinemuse.powersuits.item.ItemPowerArmor;
|
||||
//import scala.Some;
|
||||
//import net.machinemuse.utils.MuseItemUtils;
|
||||
//import net.minecraft.nbt.NBTTagIntArray;
|
||||
//import net.machinemuse.general.gui.clickable.ClickableSlider;
|
||||
//import net.machinemuse.numina.geometry.DrawableMuseRect;
|
||||
//import net.machinemuse.numina.geometry.Colour;
|
||||
//import net.machinemuse.numina.geometry.MuseRect;
|
||||
//
|
||||
///**
|
||||
// * Author: MachineMuse (Claire Semple)
|
||||
// * Created: 4:19 AM, 03/05/13
|
||||
// *
|
||||
// * Ported to Java by lehjr on 11/2/16.
|
||||
// */
|
||||
//
|
||||
//public class ColourPickerFrame implements IGuiFrame {
|
||||
// private final MuseRect borderRef;
|
||||
// private final Colour insideColour;
|
||||
// private final Colour borderColour;
|
||||
// private final ItemSelectionFrame itemSelector;
|
||||
// private final DrawableMuseRect border;
|
||||
// private final ClickableSlider rslider;
|
||||
// private final ClickableSlider gslider;
|
||||
// private final ClickableSlider bslider;
|
||||
// private ClickableSlider selectedSlider;
|
||||
// public int selectedColour;
|
||||
// public int decrAbove;
|
||||
//
|
||||
// public ColourPickerFrame(final MuseRect borderRef, final Colour insideColour, final Colour borderColour, final ItemSelectionFrame itemSelector) {
|
||||
// this.borderRef = borderRef;
|
||||
// this.insideColour = insideColour;
|
||||
// this.borderColour = borderColour;
|
||||
// this.itemSelector = itemSelector;
|
||||
// this.border = new DrawableMuseRect(borderRef, insideColour, borderColour);
|
||||
// this.rslider = new ClickableSlider(new MusePoint2D(this.border.centerx(), this.border.top() + 8), this.border.width() - 10, StatCollector.translateToLocal("gui.red"));
|
||||
// this.gslider = new ClickableSlider(new MusePoint2D(this.border.centerx(), this.border.top() + 24), this.border.width() - 10, StatCollector.translateToLocal("gui.green"));
|
||||
// this.bslider = new ClickableSlider(new MusePoint2D(this.border.centerx(), this.border.top() + 40), this.border.width() - 10, StatCollector.translateToLocal("gui.blue"));
|
||||
// this.selectedSlider = null;
|
||||
// this.selectedColour = 0;
|
||||
// this.decrAbove = -1;
|
||||
// }
|
||||
//
|
||||
//// public Colour borderColour() {
|
||||
//// return this.borderColour;
|
||||
//// }
|
||||
////
|
||||
//// public ItemSelectionFrame itemSelector() {
|
||||
//// return this.itemSelector;
|
||||
//// }
|
||||
////
|
||||
//// public DrawableMuseRect border() {
|
||||
//// return this.border;
|
||||
//// }
|
||||
////
|
||||
//// public ClickableSlider rslider() {
|
||||
//// return this.rslider;
|
||||
//// }
|
||||
////
|
||||
//// public ClickableSlider gslider() {
|
||||
//// return this.gslider;
|
||||
//// }
|
||||
////
|
||||
//// public ClickableSlider bslider() {
|
||||
//// return this.bslider;
|
||||
//// }
|
||||
//
|
||||
//// public int selectedColour() {
|
||||
//// return this.selectedColour;
|
||||
//// }
|
||||
//
|
||||
// public int[] colours() {
|
||||
// return (getOrCreateColourTag() != null) ? getOrCreateColourTag().func_150302_c() /*getIntArray()*/ : new int[0];
|
||||
// }
|
||||
//
|
||||
// public NBTTagIntArray getOrCreateColourTag() {
|
||||
// if (this.itemSelector.getSelectedItem() == null) {
|
||||
// return null;
|
||||
// }
|
||||
// final NBTTagCompound renderSpec = MuseItemUtils.getMuseRenderTag(this.itemSelector.getSelectedItem().getItem());
|
||||
// Some some;
|
||||
// if (renderSpec.hasKey("colours") && renderSpec.getTag("colours") instanceof NBTTagIntArray) {
|
||||
// return (NBTTagIntArray) renderSpec.getTag("colours");
|
||||
// }
|
||||
// else {
|
||||
// final Item item = this.itemSelector.getSelectedItem().getItem().getItem();
|
||||
// if (item instanceof ItemPowerArmor) {
|
||||
// ItemPowerArmor itemPowerArmor = (ItemPowerArmor)item;
|
||||
// int[] intArray = { itemPowerArmor.getColorFromItemStack(this.itemSelector.getSelectedItem().getItem()).getInt(),
|
||||
// itemPowerArmor.getGlowFromItemStack(this.itemSelector.getSelectedItem().getItem()).getInt() };
|
||||
// renderSpec.setIntArray("colours", intArray);
|
||||
// final BoxedUnit unit = BoxedUnit.UNIT;
|
||||
// }
|
||||
// else {
|
||||
// int[] intArray2 = new int[0];
|
||||
// renderSpec.setIntArray("colours", intArray2);
|
||||
// }
|
||||
// EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
// if (player.worldObj.isRemote) {
|
||||
// PacketSender.sendToServer(new MusePacketColourInfo((EntityPlayer)player, this.itemSelector.getSelectedItem().inventorySlot, this.colours()));
|
||||
// }
|
||||
// return (NBTTagIntArray) renderSpec.getTag("colours");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public NBTTagIntArray setColourTagMaybe(final int[] newarray) {
|
||||
// if (this.itemSelector.getSelectedItem() == null) {
|
||||
// return null;
|
||||
// }
|
||||
// final NBTTagCompound renderSpec = MuseItemUtils.getMuseRenderTag(this.itemSelector.getSelectedItem().getItem());
|
||||
// renderSpec.setTag("colours", (NBTBase)new NBTTagIntArray(newarray));
|
||||
// final EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
// if (player.worldObj.isRemote) {
|
||||
// PacketSender.sendToServer(new MusePacketColourInfo((EntityPlayer)player, this.itemSelector.getSelectedItem().inventorySlot, this.colours()));
|
||||
// }
|
||||
// return (NBTTagIntArray) renderSpec.getTag("colours");
|
||||
// }
|
||||
//
|
||||
// public ArrayList<Integer> importColours() {
|
||||
// return new ArrayList<Integer>();
|
||||
// }
|
||||
//
|
||||
// public void refreshColours() {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onMouseUp(final double x, final double y, final int button) {
|
||||
// this.selectedSlider = null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void update(final double mousex, final double mousey) {
|
||||
// if (this.selectedSlider != null) {
|
||||
// this.selectedSlider.setValueByX(mousex);
|
||||
// if (colours().length > selectedColour) {
|
||||
// colours()[selectedColour] = Colour.getInt(rslider.value(), gslider.value(), bslider.value(), 1.0);
|
||||
// EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
// if (player.worldObj.isRemote)
|
||||
// PacketSender.sendToServer(new MusePacketColourInfo(player, itemSelector.getSelectedItem().inventorySlot, colours()));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void draw() {
|
||||
// this.border.draw();
|
||||
// this.rslider.draw();
|
||||
// this.gslider.draw();
|
||||
// this.bslider.draw();
|
||||
// for (int i : colours()) {
|
||||
// new GuiIcons.ArmourColourPatch(border.left() + 8 + i * 8, border.bottom() - 16, new Colour(colours()[i]), null, null, null, null);
|
||||
// }
|
||||
// new GuiIcons.ArmourColourPatch(this.border.left() + 8 + Predef$.MODULE$.intArrayOps(this.colours()).size() * 8, this.border.bottom() - 16, Colour.WHITE, null, null, null, null);
|
||||
// new GuiIcons.SelectedArmorOverlay(this.border.left() + 8 + this.selectedColour * 8, this.border.bottom() - 16, Colour.WHITE, null, null, null, null);
|
||||
// new GuiIcons.MinusSign(this.border.left() + 8 + this.selectedColour * 8, this.border.bottom() - 24, Colour.RED, null, null, null, null);
|
||||
// new GuiIcons.PlusSign(this.border.left() + 8 + this.colours().length * 8, this.border.bottom() - 16, Colour.GREEN, null, null, null, null);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<String> getToolTip(final int x, final int y) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public void onSelectColour(final int i) {
|
||||
// final Colour c = new Colour(this.colours()[i]);
|
||||
// this.rslider.setValue(c.r);
|
||||
// this.gslider.setValue(c.g);
|
||||
// this.bslider.setValue(c.b);
|
||||
// this.selectedColour = i;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onMouseDown(final double x, final double y, final int button) {
|
||||
// if (this.rslider.hitBox(x, y))
|
||||
// this.selectedSlider = this.rslider;
|
||||
// else if (this.gslider.hitBox(x, y))
|
||||
// this.selectedSlider = this.gslider;
|
||||
// else if (this.bslider.hitBox(x, y))
|
||||
// this.selectedSlider = this.bslider;
|
||||
// else
|
||||
// this.selectedSlider = null;
|
||||
//
|
||||
// // add
|
||||
// if (y > this.border.bottom() - 16 && y < this.border.bottom() - 8) {
|
||||
// int colourCol = (int)(x - this.border.left() - 8.0) / 8;
|
||||
// if (colourCol >= 0 && colourCol < colours().length) {
|
||||
// this.onSelectColour(colourCol);
|
||||
// } else if (colourCol == this.colours().length) {
|
||||
// MuseLogger.logDebug("Adding");
|
||||
// setColourTagMaybe(ArrayUtils.add(getIntArray(getOrCreateColourTag()), Colour.WHITE.getInt()));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // remove
|
||||
// if (y > border.bottom() - 24 && y < border.bottom() - 16 && x > border.left() + 8 + selectedColour * 8 && x < border.left() + 16 + selectedColour * 8) {
|
||||
//
|
||||
// NBTTagIntArray nbtTagIntArray = getOrCreateColourTag();
|
||||
// if (getIntArray(nbtTagIntArray).length > 1) {
|
||||
// setColourTagMaybe( getIntArray(nbtTagIntArray) diff ArrayUtils.add(getIntArray(nbtTagIntArray),(selectedColour)));
|
||||
// decrAbove = selectedColour;
|
||||
// if (selectedColour == getIntArray(nbtTagIntArray).length) {
|
||||
// selectedColour = selectedColour - 1;
|
||||
// }
|
||||
// EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
// if (player.worldObj.isRemote)
|
||||
// PacketSender.sendToServer(new MusePacketColourInfo(player, itemSelector.getSelectedItem().inventorySlot, nbtTagIntArray.func_150302_c()));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public int[] getIntArray(final NBTTagIntArray e) {
|
||||
// return e.func_150302_c();
|
||||
// }
|
||||
//}
|
||||
package net.machinemuse.general.gui.frame;
|
||||
|
||||
import net.machinemuse.general.gui.clickable.ClickableSlider;
|
||||
import net.machinemuse.numina.general.MuseLogger;
|
||||
import net.machinemuse.numina.geometry.Colour;
|
||||
import net.machinemuse.numina.geometry.DrawableMuseRect;
|
||||
import net.machinemuse.numina.geometry.MusePoint2D;
|
||||
import net.machinemuse.numina.geometry.MuseRect;
|
||||
import net.machinemuse.numina.network.PacketSender;
|
||||
import net.machinemuse.powersuits.item.ItemPowerArmor;
|
||||
import net.machinemuse.powersuits.network.packets.MusePacketColourInfo;
|
||||
import net.machinemuse.utils.MuseItemUtils;
|
||||
import net.machinemuse.utils.render.GuiIcons;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagIntArray;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 4:19 AM, 03/05/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/2/16.
|
||||
*/
|
||||
|
||||
public class ColourPickerFrame implements IGuiFrame {
|
||||
public ItemSelectionFrame itemSelector;
|
||||
public DrawableMuseRect border;
|
||||
public ClickableSlider rslider;
|
||||
public ClickableSlider gslider;
|
||||
public ClickableSlider bslider;
|
||||
public ClickableSlider selectedSlider;
|
||||
public int selectedColour;
|
||||
public int decrAbove;
|
||||
|
||||
public ColourPickerFrame(MuseRect borderRef, Colour insideColour, Colour borderColour, ItemSelectionFrame itemSelector) {
|
||||
this.itemSelector = itemSelector;
|
||||
this.border = new DrawableMuseRect(borderRef, insideColour, borderColour);
|
||||
this.rslider = new ClickableSlider(new MusePoint2D(this.border.centerx(), this.border.top() + 8), this.border.width() - 10, StatCollector.translateToLocal("gui.red"));
|
||||
this.gslider = new ClickableSlider(new MusePoint2D(this.border.centerx(), this.border.top() + 24), this.border.width() - 10, StatCollector.translateToLocal("gui.green"));
|
||||
this.bslider = new ClickableSlider(new MusePoint2D(this.border.centerx(), this.border.top() + 40), this.border.width() - 10, StatCollector.translateToLocal("gui.blue"));
|
||||
this.selectedSlider = null;
|
||||
this.selectedColour = 0;
|
||||
this.decrAbove = -1;
|
||||
}
|
||||
|
||||
public int[] colours() {
|
||||
return (getOrCreateColourTag() != null) ? getOrCreateColourTag().func_150302_c() /*getIntArray()*/ : new int[0];
|
||||
}
|
||||
|
||||
public NBTTagIntArray getOrCreateColourTag() {
|
||||
if (this.itemSelector.getSelectedItem() == null) {
|
||||
return null;
|
||||
}
|
||||
NBTTagCompound renderSpec = MuseItemUtils.getMuseRenderTag(this.itemSelector.getSelectedItem().getItem());
|
||||
if (renderSpec.hasKey("colours") && renderSpec.getTag("colours") instanceof NBTTagIntArray) {
|
||||
return (NBTTagIntArray) renderSpec.getTag("colours");
|
||||
}
|
||||
else {
|
||||
Item item = this.itemSelector.getSelectedItem().getItem().getItem();
|
||||
if (item instanceof ItemPowerArmor) {
|
||||
ItemPowerArmor itemPowerArmor = (ItemPowerArmor)item;
|
||||
int[] intArray = { itemPowerArmor.getColorFromItemStack(this.itemSelector.getSelectedItem().getItem()).getInt(),
|
||||
itemPowerArmor.getGlowFromItemStack(this.itemSelector.getSelectedItem().getItem()).getInt() };
|
||||
renderSpec.setIntArray("colours", intArray);
|
||||
}
|
||||
else {
|
||||
int[] intArray2 = new int[0];
|
||||
renderSpec.setIntArray("colours", intArray2);
|
||||
}
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player.worldObj.isRemote) {
|
||||
PacketSender.sendToServer(new MusePacketColourInfo((EntityPlayer)player, this.itemSelector.getSelectedItem().inventorySlot, this.colours()));
|
||||
}
|
||||
return (NBTTagIntArray) renderSpec.getTag("colours");
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagIntArray setColourTagMaybe(int[] newarray) {
|
||||
if (this.itemSelector.getSelectedItem() == null) {
|
||||
return null;
|
||||
}
|
||||
NBTTagCompound renderSpec = MuseItemUtils.getMuseRenderTag(this.itemSelector.getSelectedItem().getItem());
|
||||
renderSpec.setTag("colours", (NBTBase)new NBTTagIntArray(newarray));
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player.worldObj.isRemote) {
|
||||
PacketSender.sendToServer(new MusePacketColourInfo((EntityPlayer)player, this.itemSelector.getSelectedItem().inventorySlot, this.colours()));
|
||||
}
|
||||
return (NBTTagIntArray) renderSpec.getTag("colours");
|
||||
}
|
||||
|
||||
public ArrayList<Integer> importColours() {
|
||||
return new ArrayList<Integer>();
|
||||
}
|
||||
|
||||
public void refreshColours() {
|
||||
// getOrCreateColourTag.map(coloursTag => {
|
||||
// val colourints: Array[Int] = coloursTag.intArray
|
||||
// val colourset: HashSet[Int] = HashSet.empty ++ colours ++ colourints
|
||||
// val colourarray = colourset.toArray
|
||||
// coloursTag.intArray = colourarray
|
||||
// })
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseUp(double x, double y, int button) {
|
||||
this.selectedSlider = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(double mousex, double mousey) {
|
||||
if (this.selectedSlider != null) {
|
||||
this.selectedSlider.setValueByX(mousex);
|
||||
if (colours().length > selectedColour) {
|
||||
colours()[selectedColour] = Colour.getInt(rslider.value(), gslider.value(), bslider.value(), 1.0);
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player.worldObj.isRemote)
|
||||
PacketSender.sendToServer(new MusePacketColourInfo(player, itemSelector.getSelectedItem().inventorySlot, colours()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
this.border.draw();
|
||||
this.rslider.draw();
|
||||
this.gslider.draw();
|
||||
this.bslider.draw();
|
||||
System.out.println("colours().length: " + colours().length);
|
||||
|
||||
for (int i = 0; i < colours().length; i++) {
|
||||
System.out.println("colours()[i] " + colours()[i]);
|
||||
new GuiIcons.ArmourColourPatch(border.left() + 8 + i * 8, border.bottom() - 16, new Colour(colours()[i]), null, null, null, null);
|
||||
}
|
||||
new GuiIcons.ArmourColourPatch(this.border.left() + 8 + this.colours().length * 8, this.border.bottom() - 16, Colour.WHITE, null, null, null, null);
|
||||
new GuiIcons.SelectedArmorOverlay(this.border.left() + 8 + this.selectedColour * 8, this.border.bottom() - 16, Colour.WHITE, null, null, null, null);
|
||||
new GuiIcons.MinusSign(this.border.left() + 8 + this.selectedColour * 8, this.border.bottom() - 24, Colour.RED, null, null, null, null);
|
||||
new GuiIcons.PlusSign(this.border.left() + 8 + this.colours().length * 8, this.border.bottom() - 16, Colour.GREEN, null, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getToolTip(int x, int y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onSelectColour(int i) {
|
||||
Colour c = new Colour(this.colours()[i]);
|
||||
this.rslider.setValue(c.r);
|
||||
this.gslider.setValue(c.g);
|
||||
this.bslider.setValue(c.b);
|
||||
this.selectedColour = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDown(double x, double y, int button) {
|
||||
if (this.rslider.hitBox(x, y))
|
||||
this.selectedSlider = this.rslider;
|
||||
else if (this.gslider.hitBox(x, y))
|
||||
this.selectedSlider = this.gslider;
|
||||
else if (this.bslider.hitBox(x, y))
|
||||
this.selectedSlider = this.bslider;
|
||||
else
|
||||
this.selectedSlider = null;
|
||||
|
||||
// add
|
||||
if (y > this.border.bottom() - 16 && y < this.border.bottom() - 8) {
|
||||
int colourCol = (int)(x - this.border.left() - 8.0) / 8;
|
||||
if (colourCol >= 0 && colourCol < colours().length) {
|
||||
this.onSelectColour(colourCol);
|
||||
} else if (colourCol == this.colours().length) {
|
||||
MuseLogger.logDebug("Adding");
|
||||
setColourTagMaybe(ArrayUtils.add(getIntArray(getOrCreateColourTag()), Colour.WHITE.getInt()));
|
||||
}
|
||||
}
|
||||
|
||||
// remove
|
||||
if (y > border.bottom() - 24 && y < border.bottom() - 16 && x > border.left() + 8 + selectedColour * 8 && x < border.left() + 16 + selectedColour * 8) {
|
||||
NBTTagIntArray nbtTagIntArray = getOrCreateColourTag();
|
||||
|
||||
int[] intArray = getIntArray(nbtTagIntArray);
|
||||
if (intArray.length > 1) {
|
||||
/* TODO - for 1.10.2 and above, simplyfy with Java 8 collections and streams. Seriously, all this to remove an element fron an int array*/
|
||||
List<Integer> integerArray = new ArrayList<>();
|
||||
int intToRemove = intArray[selectedColour];
|
||||
for (int i = 0; i < intArray.length; i++) {
|
||||
if (intArray[i] != intToRemove)
|
||||
integerArray.add(intArray[i]);
|
||||
}
|
||||
int[] newIntArray = new int[integerArray.size()];
|
||||
int j = 0;
|
||||
for (Integer i : integerArray) {
|
||||
newIntArray[j] = i;
|
||||
j+=1;
|
||||
}
|
||||
setColourTagMaybe(newIntArray);
|
||||
|
||||
decrAbove = selectedColour;
|
||||
if (selectedColour == getIntArray(nbtTagIntArray).length) {
|
||||
selectedColour = selectedColour -1;
|
||||
}
|
||||
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player.worldObj.isRemote)
|
||||
PacketSender.sendToServer(new MusePacketColourInfo(player, itemSelector.getSelectedItem().inventorySlot, nbtTagIntArray.func_150302_c()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getIntArray(NBTTagIntArray e) {
|
||||
return e.func_150302_c();
|
||||
}
|
||||
}
|
|
@ -139,19 +139,21 @@
|
|||
// }
|
||||
// }
|
||||
// // remove
|
||||
// if (y > border.bottom - 24 && y < border.bottom - 16 && x > border.left + 8 + selectedColour * 8 && x < border.left + 16 + selectedColour * 8) {
|
||||
// getOrCreateColourTag.foreach(e => {
|
||||
// if (getIntArray(e).size > 1) {
|
||||
// setColourTagMaybe( getIntArray(e) diff Array(getIntArray(e)(selectedColour)))
|
||||
// decrAbove = selectedColour
|
||||
// if (selectedColour == getIntArray(e).size) {
|
||||
// selectedColour = selectedColour - 1
|
||||
// }
|
||||
// val player = Minecraft.getMinecraft.thePlayer
|
||||
// if (y.>(border.bottom.-(24)).&&(y.<(border.bottom.-(16))).&&(x.>(border.left.+(8).+(selectedColour.*(8)))).&&(x.<(border.left.+(16).+(selectedColour.*(8))))) {
|
||||
// getOrCreateColourTag.foreach((e: NBTTagIntArray) => {
|
||||
//
|
||||
// // if (getIntArray(nbtTagIntArray).length > 1) {
|
||||
// if (Predef.intArrayOps(getIntArray(e)).size.>(1)) {
|
||||
// setColourTagMaybe( Predef.intArrayOps(getIntArray(e)).diff(Predef.wrapIntArray(Array.apply(getIntArray(e)(selectedColour)))));
|
||||
// decrAbove_=(selectedColour);
|
||||
// if (selectedColour.==(Predef.intArrayOps(getIntArray(e)).size)) {
|
||||
// selectedColour_=(selectedColour.-(1));
|
||||
// };
|
||||
// val player: net.minecraft.client.entity.EntityClientPlayerMP = Minecraft.getMinecraft.thePlayer;
|
||||
// if (player.worldObj.isRemote)
|
||||
// PacketSender.sendToServer(new MusePacketColourInfo(player, itemSelector.getSelectedItem.inventorySlot, e.func_150302_c))
|
||||
// }
|
||||
// })
|
||||
// PacketSender.sendToServer(new MusePacketColourInfo(player, itemSelector.getSelectedItem.inventorySlot, e.func_150302_c));
|
||||
// };
|
||||
// });
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -1,234 +1,140 @@
|
|||
//package net.machinemuse.general.gui.frame;
|
||||
//
|
||||
//import net.machinemuse.numina.geometry.Colour;
|
||||
//import net.machinemuse.numina.geometry.MusePoint2D;
|
||||
//import net.machinemuse.numina.geometry.MuseRect;
|
||||
//import net.machinemuse.numina.geometry.MuseRelativeRect;
|
||||
//import net.machinemuse.powersuits.client.render.modelspec.ModelRegistry;
|
||||
//import net.machinemuse.powersuits.client.render.modelspec.ModelSpec;
|
||||
//import org.lwjgl.opengl.GL11;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * Author: MachineMuse (Claire Semple)
|
||||
// * Created: 6:39 PM, 29/04/13
|
||||
// *
|
||||
// * Ported to Java by lehjr on 11/9/16.
|
||||
// */
|
||||
//public class PartManipContainer extends ScrollableFrame
|
||||
//{
|
||||
// private ItemSelectionFrame itemSelect;
|
||||
// private ColourPickerFrame colourSelect;
|
||||
// private MusePoint2D topleft;
|
||||
// private MusePoint2D bottomright;
|
||||
// private Integer lastItemSlot;
|
||||
// private int lastColour;
|
||||
// private int lastColourIndex;
|
||||
// private List<PartManipSubFrame> modelframes = new ArrayList<>();
|
||||
//
|
||||
// public PartManipContainer(ItemSelectionFrame itemSelect,
|
||||
// ColourPickerFrame colourSelect,
|
||||
// MusePoint2D topleft,
|
||||
// MusePoint2D bottomright,
|
||||
// Colour borderColour,
|
||||
// Colour insideColour) {
|
||||
// super(topleft, bottomright, borderColour, insideColour);
|
||||
//
|
||||
// this.itemSelect = itemSelect;
|
||||
// this.colourSelect = colourSelect;
|
||||
// this.lastItemSlot = null;
|
||||
// this.lastColour = this.getColour();
|
||||
// this.lastColourIndex = this.getColourIndex();
|
||||
// this.modelframes =
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// (Seq<PartManipSubFrame>)((Tuple2)ModelRegistry$.MODULE$.apply().values().$div$colon((Object)new Tuple2((Object)Seq$.MODULE$.empty(), (Object)None$.MODULE$), (Function2)new Serializable() {
|
||||
// public Tuple2<Seq<PartManipSubFrame>, Option<PartManipSubFrame>> apply(Tuple2<Seq<PartManipSubFrame>, Option<PartManipSubFrame>> x0$1, ModelSpec x1$1) {
|
||||
// Tuple2 tuple2 = new Tuple2((Object)x0$1, (Object)x1$1);
|
||||
// if (tuple2 != null) {
|
||||
// Tuple2 tuple3 = (Tuple2)tuple2._1();
|
||||
// ModelSpec modelspec = (ModelSpec)tuple2._2();
|
||||
// if (tuple3 != null) {
|
||||
// Seq frameseq = (Seq)tuple3._1();
|
||||
// Option prev = (Option)tuple3._2();
|
||||
// if (modelspec != null) {
|
||||
// PartManipSubFrame newframe = PartManipContainer.this.createNewFrame(modelspec, (Option<PartManipSubFrame>)prev);
|
||||
// return (Tuple2<Seq<PartManipSubFrame>, Option<PartManipSubFrame>>)new Tuple2(frameseq.$colon$plus((Object)newframe, Seq$.MODULE$.canBuildFrom()), (Object)new Some((Object)newframe));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// throw new MatchError((Object)tuple2);
|
||||
// }
|
||||
// }))._1();
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// public ItemSelectionFrame itemSelect() {
|
||||
// return this.itemSelect;
|
||||
// }
|
||||
//
|
||||
// public ColourPickerFrame colourSelect() {
|
||||
// return this.colourSelect;
|
||||
// }
|
||||
//
|
||||
// public Option<ItemStack> getItem() {
|
||||
// return (Option<ItemStack>)Option$.MODULE$.apply((Object)this.itemSelect().getSelectedItem()).map((Function1)new PartManipContainer$$anonfun$getItem.PartManipContainer$$anonfun$getItem$1(this));
|
||||
// }
|
||||
//
|
||||
// public int getItemSlot() {
|
||||
// return (Option<Object>)Option$.MODULE$.apply((Object)this.itemSelect().getSelectedItem()).map((Function1)new PartManipContainer$$anonfun$getItemSlot.PartManipContainer$$anonfun$getItemSlot$1(this));
|
||||
// }
|
||||
//
|
||||
// public Option<Object> lastItemSlot() {
|
||||
// return this.lastItemSlot;
|
||||
// }
|
||||
//
|
||||
// public void lastItemSlot_$eq(Option<Object> x$1) {
|
||||
// this.lastItemSlot = x$1;
|
||||
// }
|
||||
//
|
||||
// public int getColour() {
|
||||
// Option<ItemStack> item = this.getItem();
|
||||
// None$ module$ = None$.MODULE$;
|
||||
// if (item == null) {
|
||||
// if (module$ == null) {
|
||||
// return Colour.WHITE.getInt();
|
||||
// }
|
||||
// }
|
||||
// else if (item.equals(module$)) {
|
||||
// return Colour.WHITE.getInt();
|
||||
// }
|
||||
// if (this.colourSelect().selectedColour() < Predef$.MODULE$.intArrayOps(this.colourSelect().colours()).size() && this.colourSelect().selectedColour() >= 0) {
|
||||
// return this.colourSelect().colours()[this.colourSelect().selectedColour()];
|
||||
// }
|
||||
// return Colour.WHITE.getInt();
|
||||
// }
|
||||
//
|
||||
// public int lastColour() {
|
||||
// return this.lastColour;
|
||||
// }
|
||||
//
|
||||
// public void lastColour_$eq(int x$1) {
|
||||
// this.lastColour = x$1;
|
||||
// }
|
||||
//
|
||||
// public int getColourIndex() {
|
||||
// return this.colourSelect().selectedColour();
|
||||
// }
|
||||
//
|
||||
// public int lastColourIndex() {
|
||||
// return this.lastColourIndex;
|
||||
// }
|
||||
//
|
||||
// public void lastColourIndex_$eq(int x$1) {
|
||||
// this.lastColourIndex = x$1;
|
||||
// }
|
||||
//
|
||||
// public List<PartManipSubFrame> modelframes() {
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// return this.modelframes;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// val modelframes: Seq[PartManipSubFrame] =
|
||||
// ((Seq.empty[PartManipSubFrame], None: Option[PartManipSubFrame]) /: ModelRegistry.getInstance().apply.values) {
|
||||
// case ((frameseq, prev), modelspec: ModelSpec) => {
|
||||
// val newframe = createNewFrame(modelspec, prev)
|
||||
// (frameseq :+ newframe, Some(newframe))
|
||||
// }
|
||||
//}._1
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// public PartManipSubFrame createNewFrame(ModelSpec modelspec, PartManipSubFrame prev) {
|
||||
// MuseRelativeRect newborder = new MuseRelativeRect(this.topleft.x() + 4, this.topleft.y() + 4, this.bottomright.x(), this.topleft.y() + 10);
|
||||
// newborder.setBelow(prev.border());
|
||||
// return new PartManipSubFrame(modelspec, this.colourSelect(), this.itemSelect(), newborder);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onMouseDown(double x, double y, int button) {
|
||||
// if (button == 0) {
|
||||
// for (PartManipSubFrame frame : modelframes) {
|
||||
// frame.tryMouseClick(x, y + currentscrollpixels);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void update(double mousex, double mousey) {
|
||||
// super.update(mousex, mousey);
|
||||
// if (lastItemSlot != getItemSlot()) {
|
||||
// lastItemSlot = getItemSlot();
|
||||
// colourSelect.refreshColours();
|
||||
//
|
||||
// double x = 0;
|
||||
// for (PartManipSubFrame subframe : modelframes) {
|
||||
// subframe.updateItems();
|
||||
// x += subframe.border().bottom();
|
||||
// }
|
||||
// this.totalsize = (int) x;
|
||||
// }
|
||||
// if (colourSelect.decrAbove() > -1) {
|
||||
// decrAbove(colourSelect.decrAbove());
|
||||
//// colourSelect.decrAbove() = -1;
|
||||
// this.colourSelect().decrAbove_$eq(-1);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void decrAbove(int index) {
|
||||
// for(PartManipSubFrame frame : modelframes) frame.decrAbove(index);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void draw() {
|
||||
// super.preDraw();
|
||||
// GL11.glPushMatrix();
|
||||
// GL11.glTranslated(0.0, (double)(-this.currentscrollpixels), 0.0);
|
||||
// for (PartManipSubFrame f : modelframes)
|
||||
// f.drawPartial(currentscrollpixels + 4 + border.top(), this.currentscrollpixels + border.bottom() - 4);
|
||||
// GL11.glPopMatrix();
|
||||
// super.postDraw();
|
||||
// }
|
||||
//}
|
||||
////class PartManipContainer(val itemSelect: ItemSelectionFrame, val colourSelect: ColourPickerFrame, topleft: MusePoint2D, bottomright: MusePoint2D, borderColour: Colour, insideColour: Colour)
|
||||
//// extends ScrollableFrame(topleft, bottomright, borderColour, insideColour) {
|
||||
////
|
||||
////
|
||||
//// def getItem = Option(itemSelect.getSelectedItem).map(e => e.getItem)
|
||||
////
|
||||
//// def getItemSlot = Option(itemSelect.getSelectedItem).map(e => e.inventorySlot)
|
||||
//// var lastItemSlot: Option[Int] = None
|
||||
////
|
||||
//// def getColour = if(getItem != None && colourSelect.selectedColour < colourSelect.colours.size && colourSelect.selectedColour >= 0)
|
||||
//// colourSelect.colours(colourSelect.selectedColour)
|
||||
//// else
|
||||
//// Colour.WHITE.getInt
|
||||
//// var lastColour = getColour
|
||||
////
|
||||
//// def getColourIndex = colourSelect.selectedColour
|
||||
//// var lastColourIndex = getColourIndex
|
||||
////
|
||||
////
|
||||
//
|
||||
//
|
||||
package net.machinemuse.general.gui.frame;
|
||||
|
||||
import net.machinemuse.general.gui.clickable.ClickableItem;
|
||||
import net.machinemuse.numina.geometry.Colour;
|
||||
import net.machinemuse.numina.geometry.MusePoint2D;
|
||||
import net.machinemuse.numina.geometry.MuseRect;
|
||||
import net.machinemuse.numina.geometry.MuseRelativeRect;
|
||||
import net.machinemuse.powersuits.client.render.modelspec.ModelRegistry;
|
||||
import net.machinemuse.powersuits.client.render.modelspec.ModelSpec;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: MachineMuse (Claire Semple)
|
||||
* Created: 6:39 PM, 29/04/13
|
||||
*
|
||||
* Ported to Java by lehjr on 11/9/16.
|
||||
*/
|
||||
public class PartManipContainer extends ScrollableFrame {
|
||||
public ItemSelectionFrame itemSelect;
|
||||
public ColourPickerFrame colourSelect;
|
||||
public MusePoint2D topleft;
|
||||
public MusePoint2D bottomright;
|
||||
public Integer lastItemSlot;
|
||||
public int lastColour;
|
||||
public int lastColourIndex;
|
||||
public List<PartManipSubFrame> modelframes = new ArrayList<>();
|
||||
|
||||
public PartManipContainer(ItemSelectionFrame itemSelect,
|
||||
ColourPickerFrame colourSelect,
|
||||
MusePoint2D topleft,
|
||||
MusePoint2D bottomright,
|
||||
Colour borderColour,
|
||||
Colour insideColour) {
|
||||
super(topleft, bottomright, borderColour, insideColour);
|
||||
|
||||
this.itemSelect = itemSelect;
|
||||
this.colourSelect = colourSelect;
|
||||
this.topleft = topleft;
|
||||
this.bottomright = bottomright;
|
||||
this.lastItemSlot = null;
|
||||
this.lastColour = this.getColour();
|
||||
this.lastColourIndex = this.getColourIndex();
|
||||
this.modelframes = getModelframes();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getItem() {
|
||||
return (itemSelect.getSelectedItem() != null) ? itemSelect.getSelectedItem().getItem() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getItemSlot() {
|
||||
return (itemSelect.getSelectedItem() != null) ? itemSelect.getSelectedItem().inventorySlot : null;
|
||||
}
|
||||
|
||||
public int getColour() {
|
||||
if (getItem() == null)
|
||||
return Colour.WHITE.getInt();
|
||||
if(colourSelect.selectedColour < colourSelect.colours().length && colourSelect.selectedColour >= 0)
|
||||
return colourSelect.colours()[colourSelect.selectedColour];
|
||||
else
|
||||
return Colour.WHITE.getInt();
|
||||
}
|
||||
|
||||
public int getColourIndex() {
|
||||
return this.colourSelect.selectedColour;
|
||||
}
|
||||
|
||||
public List<PartManipSubFrame> getModelframes() {
|
||||
List<PartManipSubFrame> modelframesList = new ArrayList<>();
|
||||
Collection<ModelSpec> specCollection = ModelRegistry.getInstance().apply().values();
|
||||
|
||||
PartManipSubFrame prev = null;
|
||||
PartManipSubFrame newframe = null;
|
||||
for (ModelSpec modelspec : specCollection) {
|
||||
newframe = createNewFrame(modelspec, prev);
|
||||
prev = newframe;
|
||||
modelframesList.add(newframe);
|
||||
}
|
||||
return modelframesList;
|
||||
}
|
||||
|
||||
public PartManipSubFrame createNewFrame(ModelSpec modelspec, PartManipSubFrame prev) {
|
||||
MuseRelativeRect newborder = new MuseRelativeRect(this.topleft.x() + 4, this.topleft.y() + 4, this.bottomright.x(), this.topleft.y() + 10);
|
||||
newborder.setBelow((prev!= null) ? prev.border : null);
|
||||
return new PartManipSubFrame(modelspec, this.colourSelect, this.itemSelect, newborder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDown(double x, double y, int button) {
|
||||
if (button == 0) {
|
||||
for (PartManipSubFrame frame : modelframes) {
|
||||
frame.tryMouseClick(x, y + currentscrollpixels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(double mousex, double mousey) {
|
||||
super.update(mousex, mousey);
|
||||
if (lastItemSlot != getItemSlot()) {
|
||||
lastItemSlot = getItemSlot();
|
||||
colourSelect.refreshColours();
|
||||
|
||||
double x = 0;
|
||||
for (PartManipSubFrame subframe : modelframes) {
|
||||
subframe.updateItems();
|
||||
x += subframe.border.bottom();
|
||||
}
|
||||
this.totalsize = (int) x;
|
||||
}
|
||||
if (colourSelect.decrAbove > -1) {
|
||||
decrAbove(colourSelect.decrAbove);
|
||||
this.colourSelect.decrAbove = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void decrAbove(int index) {
|
||||
for(PartManipSubFrame frame : modelframes) frame.decrAbove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
super.preDraw();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0.0, (double)(-this.currentscrollpixels), 0.0);
|
||||
for (PartManipSubFrame f : modelframes) {
|
||||
f.drawPartial(currentscrollpixels + 4 + border.top(), this.currentscrollpixels + border.bottom() - 4);
|
||||
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
super.postDraw();
|
||||
}
|
||||
}
|
|
@ -28,12 +28,12 @@
|
|||
//
|
||||
//
|
||||
// val modelframes: Seq[PartManipSubFrame] =
|
||||
// ((Seq.empty[PartManipSubFrame], None: Option[PartManipSubFrame]) /: ModelRegistry.getInstance().apply.values) {
|
||||
// (ModelRegistry.getInstance().apply.values./:(Tuple2.apply(Seq.empty[PartManipSubFrame], scala.None: Option[PartManipSubFrame]))) ({
|
||||
// case ((frameseq, prev), modelspec: ModelSpec) => {
|
||||
// val newframe = createNewFrame(modelspec, prev)
|
||||
// (frameseq :+ newframe, Some(newframe))
|
||||
// val newframe: PartManipSubFrame = createNewFrame(modelspec, prev);
|
||||
// Tuple2.apply(frameseq.:+(newframe), Some.apply(newframe));
|
||||
// }
|
||||
// }._1
|
||||
// })._1;
|
||||
//
|
||||
// def createNewFrame(modelspec: ModelSpec, prev: Option[PartManipSubFrame]) = {
|
||||
// val newborder = new MuseRelativeRect(topleft.x + 4, topleft.y + 4, bottomright.x, topleft.y + 10)
|
||||
|
@ -66,7 +66,6 @@
|
|||
//
|
||||
// def decrAbove(index:Int) {for(frame<-modelframes) frame.decrAbove(index)}
|
||||
//
|
||||
//
|
||||
// override def draw() {
|
||||
// super.preDraw()
|
||||
// glPushMatrix()
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,57 +0,0 @@
|
|||
//package net.machinemuse.powersuits.client.render.modelspec
|
||||
//
|
||||
//import net.minecraft.client.model.{ModelBiped, ModelRenderer}
|
||||
//
|
||||
///**
|
||||
// * Author: MachineMuse (Claire Semple)
|
||||
// * Created: 2:09 AM, 29/04/13
|
||||
// */
|
||||
//
|
||||
//sealed trait MorphTarget {
|
||||
// val name: String
|
||||
// val degrad = 180F / Math.PI.asInstanceOf[Float]
|
||||
//
|
||||
// def apply(m: ModelBiped): ModelRenderer
|
||||
//}
|
||||
//
|
||||
//case object Cloak extends MorphTarget {
|
||||
// val name = "Cloak"
|
||||
//
|
||||
// def apply(m: ModelBiped) = m.bipedCloak
|
||||
//}
|
||||
//
|
||||
//case object Head extends MorphTarget {
|
||||
// val name = "Head"
|
||||
//
|
||||
// def apply(m: ModelBiped) = m.bipedHead
|
||||
//}
|
||||
//
|
||||
//case object Body extends MorphTarget {
|
||||
// val name = "Body"
|
||||
//
|
||||
// def apply(m: ModelBiped) = m.bipedBody
|
||||
//}
|
||||
//
|
||||
//case object RightArm extends MorphTarget {
|
||||
// val name = "RightArm"
|
||||
//
|
||||
// def apply(m: ModelBiped) = m.bipedRightArm
|
||||
//}
|
||||
//
|
||||
//case object LeftArm extends MorphTarget {
|
||||
// val name = "LeftArm"
|
||||
//
|
||||
// def apply(m: ModelBiped) = m.bipedLeftArm
|
||||
//}
|
||||
//
|
||||
//case object RightLeg extends MorphTarget {
|
||||
// val name = "RightLeg"
|
||||
//
|
||||
// def apply(m: ModelBiped) = m.bipedRightLeg
|
||||
//}
|
||||
//
|
||||
//case object LeftLeg extends MorphTarget {
|
||||
// val name = "LeftLeg"
|
||||
//
|
||||
// def apply(m: ModelBiped) = m.bipedLeftLeg
|
||||
//}
|
|
@ -1,101 +0,0 @@
|
|||
//package net.machinemuse.powersuits.client.render.modelspec
|
||||
//
|
||||
//import net.machinemuse.numina.general.MuseLogger
|
||||
//import net.machinemuse.numina.geometry.Colour
|
||||
//import net.machinemuse.powersuits.item.ItemPowerArmor
|
||||
//import net.machinemuse.utils.MuseStringUtils
|
||||
//import net.minecraft.item.ItemStack
|
||||
//import net.minecraft.nbt.NBTTagCompound
|
||||
//import net.minecraft.util.ResourceLocation
|
||||
//
|
||||
///**
|
||||
// * Author: MachineMuse (Claire Semple)
|
||||
// * Created: 9:11 AM, 29/04/13
|
||||
// */
|
||||
//object DefaultModelSpec {
|
||||
// val normalcolour: Colour = Colour.WHITE
|
||||
// val glowcolour: Colour = new Colour(17.0 / 255, 78.0 / 255, 1, 1)
|
||||
// val tex = "/assets/powersuits/textures/models/diffuse.png"
|
||||
//
|
||||
// def loadDefaultModel: Option[ModelSpec] = {
|
||||
// loadModel(new ResourceLocation("powersuits:models/mps_helm.obj"), tex.split(";")).map(model => {
|
||||
// makeEntries(Head, 0, 0, false, "helm_main;helm_tube_entry1;helm_tubes;helm_tube_entry2".split(";"), model)
|
||||
// makeEntries(Head, 0, 1, true, "visor".split(";"), model)
|
||||
// model
|
||||
// })
|
||||
// loadModel(new ResourceLocation("powersuits:models/mps_arms.obj"), tex.split(";")).map(model => {
|
||||
// makeEntries(RightArm, 1, 0, false, "arms3".split(";"), model)
|
||||
// makeEntries(RightArm, 1, 1, true, "crystal_shoulder_2".split(";"), model)
|
||||
// makeEntries(LeftArm, 1, 0, false, "arms2".split(";"), model)
|
||||
// makeEntries(LeftArm, 1, 1, true, "crystal_shoulder_1".split(";"), model)
|
||||
// model
|
||||
// })
|
||||
// loadModel(new ResourceLocation("powersuits:models/mps_chest.obj"), tex.split(";")).map(model => {
|
||||
// makeEntries(Body, 1, 0, false, "belt;chest_main;polySurface36;backpack;chest_padding".split(";"), model)
|
||||
// makeEntries(Body, 1, 1, true, "crystal_belt".split(";"), model)
|
||||
// model
|
||||
// })
|
||||
// loadModel(new ResourceLocation("powersuits:models/mps_pantaloons.obj"), tex.split(";")).map(model => {
|
||||
// makeEntries(RightLeg, 2, 0, false, "leg1".split(";"), model)
|
||||
// makeEntries(LeftLeg, 2, 0, false, "leg2".split(";"), model)
|
||||
// model
|
||||
// })
|
||||
// loadModel(new ResourceLocation("powersuits:models/mps_boots.obj"), tex.split(";")).map(model => {
|
||||
// makeEntries(RightLeg, 3, 0, false, "boots1".split(";"), model)
|
||||
// makeEntries(LeftLeg, 3, 0, false, "boots2".split(";"), model)
|
||||
// model
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// def loadModel(file: ResourceLocation, textures: Array[String]): Option[ModelSpec] = {
|
||||
// ModelRegistry.loadModel(file) match {
|
||||
// case Some(m) => Some(ModelRegistry.put(MuseStringUtils.extractName(file), new ModelSpec(m, textures, None, None, file.toString)))
|
||||
// case None => MuseLogger.logError("Model file " + file + " not found! D:")
|
||||
// None
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// def makeEntries(target: MorphTarget, slot: Int, colourIndex: Int, glow: Boolean, names: Array[String], model: ModelSpec) {
|
||||
// for (name <- names) {
|
||||
// model.put(name, new ModelPartSpec(model, target, name, slot, colourIndex, glow, name))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// def makeModelPrefs(stack: ItemStack, slot: Int): NBTTagCompound = {
|
||||
// val item = stack.getItem.asInstanceOf[ItemPowerArmor]
|
||||
// val normalcolour = item.getColorFromItemStack(stack)
|
||||
// val glowcolour = item.getGlowFromItemStack(stack)
|
||||
// val list = slot match {
|
||||
// case 0 => {
|
||||
// makePrefs("mps_helm", "helm_main;helm_tube_entry1;helm_tubes;helm_tube_entry2".split(";"), 0, false) ++
|
||||
// makePrefs("mps_helm", "visor".split(";"), 1, true)
|
||||
// }
|
||||
// case 1 => {
|
||||
// makePrefs("mps_arms", "arms2;arms3".split(";"), 0, false) ++
|
||||
// makePrefs("mps_arms", "crystal_shoulder_2;crystal_shoulder_1".split(";"), 1, true) ++
|
||||
// makePrefs("mps_chest", "belt;chest_main;polySurface36;backpack;chest_padding".split(";"), 0, false) ++
|
||||
// makePrefs("mps_chest", "crystal_belt".split(";"), 1, true)
|
||||
// }
|
||||
// case 2 => {
|
||||
// makePrefs("mps_pantaloons", "leg1;leg2".split(";"), 0, false)
|
||||
// }
|
||||
// case 3 => {
|
||||
// makePrefs("mps_boots", "boots1;boots2".split(";"), 0, false)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// (new NBTTagCompound() /: list) {
|
||||
// case (taglist, elem) => taglist.setTag(elem.getString("model") + "." + elem.getString("part"), elem); taglist
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// def makePrefs(modelname: String, partnames: Array[String], colour: Int, glow: Boolean): Array[NBTTagCompound] = {
|
||||
// ModelRegistry.get(modelname).map(model =>
|
||||
// for (name <- partnames) yield makePref(model.get(name).get, Some(colour), Some(glow))
|
||||
// ) getOrElse Array.empty[NBTTagCompound]
|
||||
// }
|
||||
//
|
||||
// def makePref(partSpec: ModelPartSpec, colourindex: Option[Int], glow: Option[Boolean]): NBTTagCompound = {
|
||||
// partSpec.multiSet(new NBTTagCompound(), None, glow, colourindex)
|
||||
// }
|
||||
//}
|
|
@ -1,64 +0,0 @@
|
|||
//package net.machinemuse.powersuits.client.render.modelspec
|
||||
//
|
||||
//import net.minecraft.nbt.NBTTagCompound
|
||||
//
|
||||
///**
|
||||
// * Ported to Java by lehjr on 11/8/16.
|
||||
// */
|
||||
//class ModelPartSpec(val modelSpec: ModelSpec,
|
||||
// val morph: MorphTarget,
|
||||
// val partName: String,
|
||||
// val slot: Int,
|
||||
// val defaultcolourindex: Int = 0,
|
||||
// val defaultglow: Boolean = false,
|
||||
// val displayName: String) {
|
||||
//
|
||||
// def getTexture(nbt: NBTTagCompound): String = {
|
||||
// if (nbt hasKey "texture") nbt getString "texture" else modelSpec.textures.head
|
||||
// }
|
||||
//
|
||||
// def setTexture(nbt: NBTTagCompound, s: String) {
|
||||
// if (s.equals("") || s.equalsIgnoreCase(modelSpec.textures.head)) nbt removeTag "texture" else nbt setString("texture", s)
|
||||
// }
|
||||
//
|
||||
// def getColourIndex(nbt: NBTTagCompound): Int = {
|
||||
// if (nbt hasKey "colourindex") nbt getInteger "colourindex" else defaultcolourindex
|
||||
// }
|
||||
//
|
||||
// def setColourIndex(nbt: NBTTagCompound, c: Int) {
|
||||
// if (c == defaultcolourindex) nbt removeTag "colourindex" else nbt setInteger("colourindex", c)
|
||||
// }
|
||||
//
|
||||
// def getGlow(nbt: NBTTagCompound): Boolean = {
|
||||
// if (nbt hasKey "glow") nbt getBoolean "glow" else defaultglow
|
||||
// }
|
||||
//
|
||||
// def setGlow(nbt: NBTTagCompound, g: Boolean) {
|
||||
// if (g == defaultglow) nbt removeTag "glow" else nbt setBoolean("glow", g)
|
||||
// }
|
||||
//
|
||||
// def setModel(nbt: NBTTagCompound, model: ModelSpec) {
|
||||
// setModel(nbt, ModelRegistry.inverse.getOrElse(model, ""))
|
||||
// }
|
||||
//
|
||||
// def setModel(nbt: NBTTagCompound, modelname: String) {
|
||||
// nbt setString("model", modelname)
|
||||
// }
|
||||
//
|
||||
// def setPart(nbt: NBTTagCompound) {
|
||||
// nbt setString("part", partName)
|
||||
// }
|
||||
//
|
||||
// def setPartAndModel(nbt: NBTTagCompound) {
|
||||
// }
|
||||
//
|
||||
// def multiSet(nbt: NBTTagCompound, tex: Option[String], glow: Option[Boolean], c: Option[Int]): NBTTagCompound = {
|
||||
// setPart(nbt)
|
||||
// setModel(nbt, this.modelSpec)
|
||||
// setTexture(nbt, tex.getOrElse(""))
|
||||
// setGlow(nbt, glow.getOrElse(false))
|
||||
// setColourIndex(nbt, c.getOrElse(defaultcolourindex))
|
||||
// nbt
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -1,124 +0,0 @@
|
|||
//package net.machinemuse.powersuits.client.render.modelspec
|
||||
//
|
||||
//import net.machinemuse.numina.general.MuseLogger
|
||||
//import net.machinemuse.numina.scala.MuseRegistry
|
||||
//import net.machinemuse.utils.MuseStringUtils
|
||||
//import net.minecraft.nbt.NBTTagCompound
|
||||
//import net.minecraft.util.{ResourceLocation, Vec3}
|
||||
//import net.minecraftforge.client.model.AdvancedModelLoader
|
||||
//import net.minecraftforge.client.model.obj.WavefrontObject
|
||||
//
|
||||
///**
|
||||
// * Author: MachineMuse (Claire Semple)
|
||||
// * Created: 7:44 AM, 4/28/13
|
||||
// */
|
||||
////object ModelRegistry extends MuseRegistry[ModelSpec] {
|
||||
//// def loadModel(resource: ResourceLocation): Option[WavefrontObject] = {
|
||||
//// val name = MuseStringUtils.extractName(resource)
|
||||
//// get(name) match {
|
||||
//// case Some(i) => Some(i.model)
|
||||
//// case None => wrap(resource)
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// def wrap(resource: ResourceLocation): Option[WavefrontObject] = {
|
||||
//// MuseLogger.logDebug("Loading " + resource + " as " + MuseStringUtils.extractName(resource))
|
||||
//// AdvancedModelLoader.loadModel(resource) match {
|
||||
//// case m: WavefrontObject => Some(m)
|
||||
//// case _ => MuseLogger.logError("Model loading failed :( " + resource)
|
||||
//// None
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// def getModel(nbt: NBTTagCompound): Option[ModelSpec] = {
|
||||
//// get(nbt.getString("model"))
|
||||
//// }
|
||||
////
|
||||
//// def getPart(nbt: NBTTagCompound, model: ModelSpec) = {
|
||||
//// model.get(nbt getString "part")
|
||||
//// }
|
||||
////
|
||||
//// def getPart(nbt: NBTTagCompound): Option[ModelPartSpec] = {
|
||||
//// getModel(nbt).flatMap(m => m.get(nbt getString "part"))
|
||||
//// }
|
||||
////
|
||||
//// def getSpecTag(museRenderTag: NBTTagCompound, spec: ModelPartSpec): Option[NBTTagCompound] = {
|
||||
//// val name = makeName(spec)
|
||||
//// if (museRenderTag.hasKey(name)) Some(museRenderTag.getCompoundTag(name)) else None
|
||||
//// }
|
||||
////
|
||||
//// def makeName(spec: ModelPartSpec) = spec.modelSpec.getOwnName + "." + spec.partName
|
||||
////}
|
||||
//
|
||||
////class ModelSpec(val model: WavefrontObject,
|
||||
//// val textures: Array[String],
|
||||
//// val offset: Option[Vec3],
|
||||
//// val rotation: Option[Vec3],
|
||||
//// val filename: String
|
||||
//// ) extends MuseRegistry[ModelPartSpec] {
|
||||
//// def applyOffsetAndRotation() = {
|
||||
//// // TODO: Implement
|
||||
//// }
|
||||
////
|
||||
//// def getOwnName = {
|
||||
//// ModelRegistry.getName(this).getOrElse("")
|
||||
//// }
|
||||
////}
|
||||
//
|
||||
//class ModelPartSpec(val modelSpec: ModelSpec,
|
||||
// val morph: MorphTarget,
|
||||
// val partName: String,
|
||||
// val slot: Int,
|
||||
// val defaultcolourindex: Int = 0,
|
||||
// val defaultglow: Boolean = false,
|
||||
// val displayName: String) {
|
||||
//
|
||||
// def getTexture(nbt: NBTTagCompound): String = {
|
||||
// if (nbt hasKey "texture") nbt getString "texture" else modelSpec.textures.head
|
||||
// }
|
||||
//
|
||||
// def setTexture(nbt: NBTTagCompound, s: String) {
|
||||
// if (s.equals("") || s.equalsIgnoreCase(modelSpec.textures.head)) nbt removeTag "texture" else nbt setString("texture", s)
|
||||
// }
|
||||
//
|
||||
// def getColourIndex(nbt: NBTTagCompound): Int = {
|
||||
// if (nbt hasKey "colourindex") nbt getInteger "colourindex" else defaultcolourindex
|
||||
// }
|
||||
//
|
||||
// def setColourIndex(nbt: NBTTagCompound, c: Int) {
|
||||
// if (c == defaultcolourindex) nbt removeTag "colourindex" else nbt setInteger("colourindex", c)
|
||||
// }
|
||||
//
|
||||
// def getGlow(nbt: NBTTagCompound): Boolean = {
|
||||
// if (nbt hasKey "glow") nbt getBoolean "glow" else defaultglow
|
||||
// }
|
||||
//
|
||||
// def setGlow(nbt: NBTTagCompound, g: Boolean) {
|
||||
// if (g == defaultglow) nbt removeTag "glow" else nbt setBoolean("glow", g)
|
||||
// }
|
||||
//
|
||||
// def setModel(nbt: NBTTagCompound, model: ModelSpec) {
|
||||
// setModel(nbt, ModelRegistry.inverse.getOrElse(model, ""))
|
||||
// }
|
||||
//
|
||||
// def setModel(nbt: NBTTagCompound, modelname: String) {
|
||||
// nbt setString("model", modelname)
|
||||
// }
|
||||
//
|
||||
// def setPart(nbt: NBTTagCompound) {
|
||||
// nbt setString("part", partName)
|
||||
// }
|
||||
//
|
||||
// def setPartAndModel(nbt: NBTTagCompound) {
|
||||
// }
|
||||
//
|
||||
// def multiSet(nbt: NBTTagCompound, tex: Option[String], glow: Option[Boolean], c: Option[Int]): NBTTagCompound = {
|
||||
// setPart(nbt)
|
||||
// setModel(nbt, this.modelSpec)
|
||||
// setTexture(nbt, tex.getOrElse(""))
|
||||
// setGlow(nbt, glow.getOrElse(false))
|
||||
// setColourIndex(nbt, c.getOrElse(defaultcolourindex))
|
||||
// nbt
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -1,24 +0,0 @@
|
|||
//package net.machinemuse.powersuits.client.render.modelspec
|
||||
//
|
||||
//import net.machinemuse.numina.scala.MuseRegistry
|
||||
//import net.minecraft.util.Vec3
|
||||
//import net.minecraftforge.client.model.obj.WavefrontObject
|
||||
//
|
||||
///**
|
||||
// * Ported to Java by lehjr on 11/8/16.
|
||||
// */
|
||||
//class ModelSpec(val model: WavefrontObject,
|
||||
// val textures: Array[String],
|
||||
// val offset: Option[Vec3],
|
||||
// val rotation: Option[Vec3],
|
||||
// val filename: String
|
||||
// ) extends MuseRegistry[ModelPartSpec] {
|
||||
// def applyOffsetAndRotation() = {
|
||||
// // TODO: Implement
|
||||
// }
|
||||
//
|
||||
// def getOwnName = {
|
||||
// ModelRegistry.getName(this).getOrElse("")
|
||||
// }
|
||||
//}
|
||||
//
|
|
@ -1,121 +0,0 @@
|
|||
//package net.machinemuse.powersuits.client.render.modelspec
|
||||
//
|
||||
//import java.awt.Color
|
||||
//import java.net.URL
|
||||
//
|
||||
//import net.machinemuse.numina.general.MuseLogger
|
||||
//import net.machinemuse.numina.geometry.Colour
|
||||
//import net.machinemuse.utils.MuseStringUtils
|
||||
//import net.minecraft.util.{ResourceLocation, Vec3}
|
||||
//
|
||||
//import scala.xml.{NodeSeq, XML}
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * Author: MachineMuse (Claire Semple)
|
||||
// * Created: 8:44 AM, 4/28/13
|
||||
// */
|
||||
//object ModelSpecXMLReader {
|
||||
// def parseFile(file: URL) = {
|
||||
// val xml = XML.load(file)
|
||||
// (xml \\ "model") foreach {
|
||||
// modelnode => parseModel(modelnode)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// def parseModel(modelnode: NodeSeq) = {
|
||||
// val file = (modelnode \ "@file").text
|
||||
// val textures = (modelnode \ "@textures").text.split(",")
|
||||
// val offset = parseVector((modelnode \ "@offset").text)
|
||||
// val rotation = parseVector((modelnode \ "@rotation").text)
|
||||
//
|
||||
// ModelRegistry.loadModel(new ResourceLocation(file)) match {
|
||||
// case Some(m) => {
|
||||
// val modelspec = new ModelSpec(m, textures, offset, rotation, file)
|
||||
// val existingspec = ModelRegistry.put(MuseStringUtils.extractName(file), modelspec)
|
||||
// (modelnode \ "binding").foreach {
|
||||
// bindingnode => parseBinding(bindingnode, existingspec)
|
||||
// }
|
||||
// }
|
||||
// case None => MuseLogger logError "Model file " + file + " not found! D:"
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// def parseBinding(bindingnode: NodeSeq, modelspec: ModelSpec) = {
|
||||
// val slot = parseInt((bindingnode \ "@slot").text)
|
||||
// val target = parseTarget((bindingnode \ "@target").text)
|
||||
// slot.foreach(slot => {
|
||||
// target.foreach(target =>
|
||||
// (bindingnode \ "part").foreach {
|
||||
// partnode =>
|
||||
// parseParts(partnode, modelspec, slot, target)
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// def parseParts(partNode: NodeSeq, modelspec: ModelSpec, slot: Int, target: MorphTarget) = {
|
||||
// val defaultcolor = parseColour((partNode \ "@defaultcolor").text)
|
||||
// val defaultglow = parseBool((partNode \ "@defaultglow").text)
|
||||
// val name = (partNode \ "@name").text
|
||||
// val polygroup = validatePolygroup((partNode \ "@polygroup").text, modelspec)
|
||||
// polygroup.map(polygroup => {
|
||||
// val partspec = new ModelPartSpec(modelspec, target, polygroup, slot, 0, defaultglow.getOrElse(false), name)
|
||||
// modelspec.put(polygroup, partspec)
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// def validatePolygroup(s: String, m: ModelSpec): Option[String] = {
|
||||
// val it = m.model.groupObjects.iterator
|
||||
// while (it.hasNext) {
|
||||
// if (it.next().name.equals(s)) return Some(s)
|
||||
// }
|
||||
// return None
|
||||
// }
|
||||
//
|
||||
// def parseBool(s: String): Option[Boolean] = {
|
||||
// try Some(s.toBoolean) catch {
|
||||
// case _: Throwable => None
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// def parseColour(s: String): Option[Colour] = {
|
||||
// try {
|
||||
// val c = Color.decode(s)
|
||||
// Some(new Colour(c.getRed, c.getGreen, c.getBlue, c.getAlpha))
|
||||
// } catch {
|
||||
// case _: Throwable => None
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// def parseTarget(s: String): Option[MorphTarget] = {
|
||||
// s.toLowerCase match {
|
||||
// case "head" => Some(Head)
|
||||
// case "body" => Some(Body)
|
||||
// case "leftarm" => Some(LeftArm)
|
||||
// case "rightarm" => Some(RightArm)
|
||||
// case "leftleg" => Some(LeftLeg)
|
||||
// case "rightleg" => Some(RightLeg)
|
||||
// case "cloak" => Some(Cloak)
|
||||
// case _ => None
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// def parseInt(s: String): Option[Int] = {
|
||||
// try Some(s.toInt) catch {
|
||||
// case _: Throwable => None
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// def parseVector(s: String): Option[Vec3] = {
|
||||
// try {
|
||||
// val ss = s.split(",")
|
||||
// val x = ss(0).toDouble
|
||||
// val y = ss(1).toDouble
|
||||
// val z = ss(2).toDouble
|
||||
// Some(Vec3.createVectorHelper(x, y, z))
|
||||
// } catch {
|
||||
// case _: Throwable => None
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -11,6 +11,9 @@ import com.google.gson.Gson
|
|||
*/
|
||||
object ModelSpecXMLWriter {
|
||||
def writeRegistry(file: String) {
|
||||
println("Writing XML file to " + file)
|
||||
|
||||
|
||||
// val xmlwrite =
|
||||
// <models>
|
||||
// {for ((modelname, modelspec) <- ModelRegistry.getInstance()) yield
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
package net.machinemuse.powersuits.client.render.modelspec;
|
||||
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
/**
|
||||
* Ported to Java by lehjr on 11/8/16.
|
||||
*/
|
||||
public enum MorphTarget {
|
||||
Cloak,
|
||||
Head,
|
||||
Body,
|
||||
RightArm,
|
||||
LeftArm,
|
||||
RightLeg,
|
||||
LeftLeg;
|
||||
|
||||
private interface iMorphTarget {
|
||||
String name = null;
|
||||
float degrad = (float) (180F / Math.PI);
|
||||
|
||||
ModelRenderer apply(ModelBiped m);
|
||||
}
|
||||
|
||||
public ModelRenderer apply(ModelBiped m) {
|
||||
switch(this) {
|
||||
case Cloak:
|
||||
return Cloak.apply(m);
|
||||
|
||||
case Head:
|
||||
return Head.apply(m);
|
||||
|
||||
case Body:
|
||||
return Body.apply(m);
|
||||
|
||||
case RightArm:
|
||||
return RightArm.apply(m);
|
||||
|
||||
case LeftArm:
|
||||
return LeftArm.apply(m);
|
||||
|
||||
case RightLeg:
|
||||
return RightLeg.apply(m);
|
||||
|
||||
case LeftLeg:
|
||||
return LeftLeg.apply(m);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class Cloak implements iMorphTarget {
|
||||
String name = "Cloak";
|
||||
|
||||
@Override
|
||||
public ModelRenderer apply(ModelBiped m) {
|
||||
return m.bipedCloak;
|
||||
}
|
||||
}
|
||||
|
||||
public class Head implements iMorphTarget {
|
||||
String name = "Head";
|
||||
|
||||
@Override
|
||||
public ModelRenderer apply(ModelBiped m) {
|
||||
return m.bipedHead;
|
||||
}
|
||||
}
|
||||
|
||||
public class Body implements iMorphTarget {
|
||||
String name = "Body";
|
||||
|
||||
@Override
|
||||
public ModelRenderer apply(ModelBiped m) {
|
||||
return m.bipedBody;
|
||||
}
|
||||
}
|
||||
|
||||
public class RightArm implements iMorphTarget {
|
||||
String name = "RightArm";
|
||||
|
||||
@Override
|
||||
public ModelRenderer apply(ModelBiped m) {
|
||||
return m.bipedRightArm;
|
||||
}
|
||||
}
|
||||
|
||||
public class LeftArm implements iMorphTarget {
|
||||
String name = "LeftArm";
|
||||
|
||||
@Override
|
||||
public ModelRenderer apply(ModelBiped m) {
|
||||
return m.bipedLeftArm;
|
||||
}
|
||||
}
|
||||
|
||||
public class RightLeg implements iMorphTarget {
|
||||
String name = "RightLeg";
|
||||
|
||||
@Override
|
||||
public ModelRenderer apply(ModelBiped m) {
|
||||
return m.bipedRightLeg;
|
||||
}
|
||||
}
|
||||
|
||||
public class LeftLeg implements iMorphTarget {
|
||||
String name = "LeftLeg";
|
||||
|
||||
@Override
|
||||
public ModelRenderer apply(ModelBiped m) {
|
||||
return m.bipedLeftLeg;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,7 +68,6 @@ class ClientProxy extends CommonProxy {
|
|||
ModelSpecXMLReader.getINSTANCE.parseFile(resource)
|
||||
val otherResource: URL = classOf[ClientProxy].getResource("/assets/powersuits/models/armor2.xml")
|
||||
ModelSpecXMLReader.getINSTANCE.parseFile(otherResource)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue