use of com.lilithsthrone.utils.Colour in project liliths-throne-public by Innoxia.
the class AbstractClothing method loadFromXML.
public static AbstractClothing loadFromXML(Element parentElement, Document doc) {
AbstractClothing clothing = null;
try {
clothing = AbstractClothingType.generateClothing(ClothingType.getClothingTypeFromId(parentElement.getAttribute("id")), false);
} catch (Exception ex) {
System.err.println("Warning: An instance of AbstractClothing was unable to be imported. (" + parentElement.getAttribute("id") + ")");
return null;
}
if (clothing == null) {
System.err.println("Warning: An instance of AbstractClothing was unable to be imported. (" + parentElement.getAttribute("id") + ")");
return null;
}
// Try to load colour:
try {
clothing.setColour(Colour.valueOf(parentElement.getAttribute("colour")));
if (!parentElement.getAttribute("colourSecondary").isEmpty()) {
Colour secColour = Colour.valueOf(parentElement.getAttribute("colourSecondary"));
if (clothing.clothingType.getAllAvailableSecondaryColours().contains(secColour)) {
clothing.setSecondaryColour(secColour);
}
}
if (!parentElement.getAttribute("colourTertiary").isEmpty()) {
Colour terColour = Colour.valueOf(parentElement.getAttribute("colourTertiary"));
if (clothing.clothingType.getAllAvailableTertiaryColours().contains(terColour)) {
clothing.setTertiaryColour(terColour);
}
}
} catch (Exception ex) {
}
// Try to load core features:
try {
if (!parentElement.getAttribute("sealed").isEmpty()) {
clothing.setSealed(Boolean.valueOf(parentElement.getAttribute("sealed")));
}
clothing.setDirty(Boolean.valueOf(parentElement.getAttribute("isDirty")));
clothing.setEnchantmentKnown(Boolean.valueOf(parentElement.getAttribute("enchantmentKnown")));
} catch (Exception ex) {
}
if (parentElement.getElementsByTagName("attributeModifiers") != null && parentElement.getElementsByTagName("attributeModifiers").getLength() > 0) {
if (clothing.getClothingType().getClothingSet() == null) {
clothing.getEffects().clear();
Element element = (Element) parentElement.getElementsByTagName("attributeModifiers").item(0);
for (int i = 0; i < element.getElementsByTagName("modifier").getLength(); i++) {
Element e = ((Element) element.getElementsByTagName("modifier").item(i));
try {
Attribute att = Attribute.valueOf(e.getAttribute("attribute"));
int value = Integer.valueOf(e.getAttribute("value"));
TFPotency pot = TFPotency.BOOST;
if (value <= -5) {
pot = TFPotency.MAJOR_DRAIN;
} else if (value <= -3) {
pot = TFPotency.DRAIN;
} else if (value <= -1) {
pot = TFPotency.MINOR_DRAIN;
} else if (value <= 1) {
pot = TFPotency.MINOR_BOOST;
} else if (value <= 3) {
pot = TFPotency.BOOST;
} else {
pot = TFPotency.MAJOR_BOOST;
}
for (TFModifier mod : TFModifier.getClothingAttributeList()) {
if (mod.getAssociatedAttribute() == att) {
clothing.addEffect(new ItemEffect(ItemEffectType.CLOTHING, TFModifier.CLOTHING_ATTRIBUTE, mod, pot, 0));
break;
}
}
} catch (Exception ex) {
}
}
}
} else {
try {
clothing.getEffects().clear();
Element element = (Element) parentElement.getElementsByTagName("effects").item(0);
for (int i = 0; i < element.getElementsByTagName("effect").getLength(); i++) {
Element e = ((Element) element.getElementsByTagName("effect").item(i));
clothing.addEffect(ItemEffect.loadFromXML(e, doc));
}
} catch (Exception ex) {
}
}
// Try to load displacements:
try {
clothing.displacedList = new ArrayList<>();
Element displacementElement = (Element) parentElement.getElementsByTagName("displacedList").item(0);
for (int i = 0; i < displacementElement.getElementsByTagName("displacementType").getLength(); i++) {
Element e = ((Element) displacementElement.getElementsByTagName("displacementType").item(i));
clothing.displacedList.add(DisplacementType.valueOf(e.getAttribute("value")));
}
} catch (Exception ex) {
}
return clothing;
}
use of com.lilithsthrone.utils.Colour in project liliths-throne-public by Innoxia.
the class AbstractClothingType method generateClothing.
/**
* Generates clothing with the provided enchantments.
*/
public static AbstractClothing generateClothing(AbstractClothingType clothingType, Colour primaryColour, Colour secondaryColour, Colour tertiaryColour, List<ItemEffect> effects) {
Colour c1 = primaryColour;
Colour c2 = secondaryColour;
Colour c3 = tertiaryColour;
if (clothingType.getAllAvailablePrimaryColours() != null) {
if (!clothingType.getAllAvailablePrimaryColours().contains(primaryColour)) {
c1 = clothingType.getAllAvailablePrimaryColours().get(Util.random.nextInt(clothingType.getAllAvailablePrimaryColours().size()));
}
}
if (secondaryColour == null || !clothingType.getAllAvailableSecondaryColours().contains(secondaryColour)) {
if (clothingType.getAvailableSecondaryColours().isEmpty()) {
c2 = Colour.CLOTHING_BLACK;
} else {
c2 = clothingType.getAvailableSecondaryColours().get(Util.random.nextInt(clothingType.getAvailableSecondaryColours().size()));
}
}
if (tertiaryColour == null || !clothingType.getAllAvailableTertiaryColours().contains(tertiaryColour)) {
if (clothingType.getAvailableTertiaryColours().isEmpty()) {
c3 = Colour.CLOTHING_BLACK;
} else {
c3 = clothingType.getAvailableTertiaryColours().get(Util.random.nextInt(clothingType.getAvailableTertiaryColours().size()));
}
}
return new AbstractClothing(clothingType, c1, c2, c3, effects) {
private static final long serialVersionUID = 1L;
};
}
use of com.lilithsthrone.utils.Colour in project liliths-throne-public by Innoxia.
the class AbstractClothingType method generateClothing.
public static AbstractClothing generateClothing(AbstractClothingType clothingType, Colour primaryColour, Colour secondaryColour, Colour tertiaryColour, boolean allowRandomEnchantment) {
Colour c1 = primaryColour;
Colour c2 = secondaryColour;
Colour c3 = tertiaryColour;
if (clothingType.getAllAvailablePrimaryColours() != null) {
if (!clothingType.getAllAvailablePrimaryColours().contains(primaryColour)) {
c1 = clothingType.getAllAvailablePrimaryColours().get(Util.random.nextInt(clothingType.getAllAvailablePrimaryColours().size()));
}
}
if (secondaryColour == null) {
if (clothingType.getAvailableSecondaryColours().isEmpty()) {
c2 = Colour.CLOTHING_BLACK;
} else {
c2 = clothingType.getAvailableSecondaryColours().get(Util.random.nextInt(clothingType.getAvailableSecondaryColours().size()));
}
} else if (!clothingType.getAllAvailableSecondaryColours().contains(secondaryColour)) {
if (clothingType.getAllAvailableSecondaryColours().isEmpty()) {
c2 = Colour.CLOTHING_BLACK;
} else {
c2 = clothingType.getAllAvailableSecondaryColours().get(Util.random.nextInt(clothingType.getAllAvailableSecondaryColours().size()));
}
}
if (tertiaryColour == null) {
if (clothingType.getAvailableTertiaryColours().isEmpty()) {
c3 = Colour.CLOTHING_BLACK;
} else {
c3 = clothingType.getAvailableTertiaryColours().get(Util.random.nextInt(clothingType.getAvailableTertiaryColours().size()));
}
} else if (!clothingType.getAllAvailableTertiaryColours().contains(tertiaryColour)) {
if (clothingType.getAllAvailableTertiaryColours().isEmpty()) {
c3 = Colour.CLOTHING_BLACK;
} else {
c3 = clothingType.getAllAvailableTertiaryColours().get(Util.random.nextInt(clothingType.getAllAvailableTertiaryColours().size()));
}
}
return new AbstractClothing(clothingType, c1, c2, c3, allowRandomEnchantment) {
private static final long serialVersionUID = 1L;
};
}
use of com.lilithsthrone.utils.Colour in project liliths-throne-public by Innoxia.
the class EnchantingUtils method getImportedSVGString.
public static String getImportedSVGString(AbstractCoreItem item, Colour importedColour, List<ItemEffect> effects) {
if (((AbstractItem) item).getItemType().getId().equals(ItemType.ORIENTATION_HYPNO_WATCH.getId())) {
if (effects.isEmpty() || effects.get(0).getPrimaryModifier() == TFModifier.REMOVAL) {
return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchBase();
}
if (effects.get(0).getPrimaryModifier() == TFModifier.ORIENTATION_GYNEPHILIC) {
return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchGynephilic();
} else if (effects.get(0).getPrimaryModifier() == TFModifier.ORIENTATION_AMBIPHILIC) {
return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchAmbiphilic();
} else {
return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchAndrophilic();
}
}
StringBuilder SVGImageSB = new StringBuilder();
String importedColourString = SVGImages.SVG_IMAGE_PROVIDER.getRefinedBackgroundMap().get(importedColour);
if (importedColourString == null || importedColourString.isEmpty() || importedColourString.equals("null")) {
importedColourString = SVGImages.SVG_IMAGE_PROVIDER.getRefinedBackgroundMap().get(effects.get(0).getItemEffectType().getColour());
}
SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + importedColourString + "</div>");
String s = item.getSVGString();
Colour colour = Colour.CLOTHING_BLUE_LIGHT;
for (ItemEffect ie : effects) {
if (ie.getPrimaryModifier() != null && ie.getPrimaryModifier() != TFModifier.NONE) {
colour = ie.getPrimaryModifier().getColour();
break;
}
}
s = s.replaceAll("#ff2a2a", colour.getShades()[0]);
s = s.replaceAll("#ff5555", colour.getShades()[1]);
s = s.replaceAll("#ff8080", colour.getShades()[2]);
s = s.replaceAll("#ffaaaa", colour.getShades()[3]);
s = s.replaceAll("#ffd5d5", colour.getShades()[4]);
SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + s + "</div>");
for (ItemEffect ie : effects) {
if (ie.getSecondaryModifier() != null && ie.getSecondaryModifier() != TFModifier.NONE) {
SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + SVGImages.SVG_IMAGE_PROVIDER.getRefinedSwirlsMap().get(ie.getSecondaryModifier().getColour()) + "</div>");
break;
}
}
return SVGImageSB.toString();
}
use of com.lilithsthrone.utils.Colour in project liliths-throne-public by Innoxia.
the class EnchantingUtils method getSVGString.
public static String getSVGString(AbstractCoreItem ingredient, List<ItemEffect> effects) {
if (ingredient.getEnchantmentItemType(effects) instanceof AbstractClothingType) {
return ingredient.getSVGString();
}
if (((AbstractItem) ingredient).getItemType().getId().equals(ItemType.ORIENTATION_HYPNO_WATCH.getId())) {
if (effects.isEmpty() || effects.get(0).getPrimaryModifier() == TFModifier.REMOVAL) {
return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchBase();
}
if (effects.get(0).getPrimaryModifier() == TFModifier.ORIENTATION_GYNEPHILIC) {
return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchGynephilic();
} else if (effects.get(0).getPrimaryModifier() == TFModifier.ORIENTATION_AMBIPHILIC) {
return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchAmbiphilic();
} else {
return SVGImages.SVG_IMAGE_PROVIDER.getHypnoWatchAndrophilic();
}
}
StringBuilder SVGImageSB = new StringBuilder();
SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + SVGImages.SVG_IMAGE_PROVIDER.getRefinedBackgroundMap().get(ingredient.getEnchantmentEffect().getColour()) + "</div>");
String s = ((AbstractItemType) ingredient.getEnchantmentItemType(effects)).getSVGString();
Colour colour = Colour.CLOTHING_BLUE_LIGHT;
for (ItemEffect ie : effects) {
if (ie.getPrimaryModifier() != null && ie.getPrimaryModifier() != TFModifier.NONE) {
colour = ie.getPrimaryModifier().getColour();
break;
}
}
s = s.replaceAll("#ff2a2a", colour.getShades()[0]);
s = s.replaceAll("#ff5555", colour.getShades()[1]);
s = s.replaceAll("#ff8080", colour.getShades()[2]);
s = s.replaceAll("#ffaaaa", colour.getShades()[3]);
s = s.replaceAll("#ffd5d5", colour.getShades()[4]);
SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + s + "</div>");
for (ItemEffect ie : effects) {
if (ie.getSecondaryModifier() != null && ie.getSecondaryModifier() != TFModifier.NONE) {
SVGImageSB.append("<div style='width:100%;height:100%;position:absolute;left:0;bottom:0;'>" + SVGImages.SVG_IMAGE_PROVIDER.getRefinedSwirlsMap().get(ie.getSecondaryModifier().getColour()) + "</div>");
break;
}
}
return SVGImageSB.toString();
}
Aggregations