2018-04-25 13:00:18 +02:00
|
|
|
package com.minelittlepony.pony.data;
|
|
|
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Individual trigger pixels for a pony skin.
|
|
|
|
*
|
|
|
|
*/
|
2018-04-25 13:00:18 +02:00
|
|
|
public enum TriggerPixels {
|
|
|
|
RACE(PonyRace.HUMAN, 0, 0),
|
|
|
|
TAIL(TailLengths.FULL, 1, 0),
|
|
|
|
GENDER(PonyGender.MARE, 2, 0),
|
|
|
|
SIZE(PonySize.NORMAL, 3, 0),
|
|
|
|
GLOW(null, 0, 1);
|
|
|
|
|
|
|
|
private int x, y;
|
|
|
|
|
|
|
|
ITriggerPixelMapped<?> def;
|
|
|
|
|
|
|
|
TriggerPixels(ITriggerPixelMapped<?> def, int x, int y) {
|
|
|
|
this.def = def;
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
}
|
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Reads tis trigger pixel's value and returns the raw colour value.
|
|
|
|
* @param image Image to read
|
|
|
|
* @param mask Colour mask (0xffffff for rgb, -1 for rgba)
|
|
|
|
*/
|
2018-04-25 13:00:18 +02:00
|
|
|
public int readColor(BufferedImage image, int mask) {
|
|
|
|
return image.getRGB(x, y) & mask;
|
|
|
|
}
|
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Reads this trigger pixel's value and parses it to an Enum instance.
|
|
|
|
*
|
|
|
|
* @param image Image to read
|
|
|
|
*/
|
2018-04-25 13:00:18 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
public <T extends Enum<T> & ITriggerPixelMapped<T>> T readValue(BufferedImage image) {
|
|
|
|
return ITriggerPixelMapped.getByTriggerPixel((T)def, readColor(image, 0xffffff));
|
|
|
|
}
|
|
|
|
}
|