2013-12-01 06:03:40 +01:00
|
|
|
package mekanism.api;
|
2013-11-30 06:28:02 +01:00
|
|
|
|
2013-12-01 06:15:52 +01:00
|
|
|
import net.minecraft.util.StatCollector;
|
2013-11-30 06:28:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple color enum for adding colors to in-game GUI strings of text.
|
|
|
|
* @author AidanBrady
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public enum EnumColor
|
|
|
|
{
|
2013-12-22 06:42:46 +01:00
|
|
|
BLACK("\u00a70", "black", new int[] {0, 0, 0}, 0),
|
|
|
|
DARK_BLUE("\u00a71", "darkBlue", new int[] {0, 0, 170}, 4),
|
|
|
|
DARK_GREEN("\u00a72", "darkGreen", new int[] {0, 170, 0}, 2),
|
|
|
|
DARK_AQUA("\u00a73", "darkAqua", new int[] {0, 170, 170}, 6),
|
2014-04-10 04:05:28 +02:00
|
|
|
DARK_RED("\u00a74", "darkRed", new int[] {170, 0, 0}, -1),
|
2013-12-22 06:42:46 +01:00
|
|
|
PURPLE("\u00a75", "purple", new int[] {170, 0, 170}, 5),
|
|
|
|
ORANGE("\u00a76", "orange", new int[] {255, 170, 0}, 14),
|
|
|
|
GREY("\u00a77", "grey", new int[] {170, 170, 170}, 7),
|
|
|
|
DARK_GREY("\u00a78", "darkGrey", new int[] {85, 85, 85}, 8),
|
|
|
|
INDIGO("\u00a79", "indigo", new int[] {85, 85, 255}, 12),
|
|
|
|
BRIGHT_GREEN("\u00a7a", "brightGreen", new int[] {85, 255, 85}, 10),
|
|
|
|
AQUA("\u00a7b", "aqua", new int[] {85, 255, 255}, -1),
|
2014-04-11 04:32:52 +02:00
|
|
|
RED("\u00a7c", "red", new int[] {255, 0, 0}, 1),
|
2014-04-10 04:05:28 +02:00
|
|
|
PINK("\u00a7d", "pink", new int[] {255, 85, 255}, 13),
|
2013-12-22 06:42:46 +01:00
|
|
|
YELLOW("\u00a7e", "yellow", new int[] {255, 255, 85}, 11),
|
2014-04-10 04:05:28 +02:00
|
|
|
WHITE("\u00a7f", "white", new int[] {255, 255, 255}, 15),
|
|
|
|
//Extras for dye-completeness
|
|
|
|
BROWN("\u00a73", "brown", new int[] {150, 75, 0}, 3),
|
|
|
|
BRIGHT_PINK("\u00a7d", "brightPink", new int[] {255, 192, 203}, 9);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-04-10 04:05:28 +02:00
|
|
|
public static EnumColor[] DYES = new EnumColor[] {BLACK, RED, DARK_GREEN, BROWN, DARK_BLUE, PURPLE, DARK_AQUA, GREY, DARK_GREY, BRIGHT_PINK, BRIGHT_GREEN, YELLOW, INDIGO, PINK, ORANGE, WHITE};
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-11-30 06:28:02 +01:00
|
|
|
/** The color code that will be displayed */
|
|
|
|
public final String code;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-11-30 06:28:02 +01:00
|
|
|
public final int[] rgbCode;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-22 06:42:46 +01:00
|
|
|
public final int mcMeta;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-11-30 06:28:02 +01:00
|
|
|
/** A friendly name of the color. */
|
|
|
|
public String unlocalizedName;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-22 06:42:46 +01:00
|
|
|
private EnumColor(String s, String n, int[] rgb, int meta)
|
2013-11-30 06:28:02 +01:00
|
|
|
{
|
|
|
|
code = s;
|
|
|
|
unlocalizedName = n;
|
|
|
|
rgbCode = rgb;
|
2013-12-22 06:42:46 +01:00
|
|
|
mcMeta = meta;
|
2013-11-30 06:28:02 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-23 23:06:22 +01:00
|
|
|
/**
|
|
|
|
* Gets the localized name of this color by translating the unlocalized name.
|
|
|
|
* @return localized name
|
|
|
|
*/
|
2013-11-30 06:28:02 +01:00
|
|
|
public String getLocalizedName()
|
|
|
|
{
|
2013-12-01 06:15:52 +01:00
|
|
|
return StatCollector.translateToLocal("color." + unlocalizedName);
|
2013-11-30 06:28:02 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-04-10 04:05:28 +02:00
|
|
|
public String getDyeName()
|
|
|
|
{
|
|
|
|
return StatCollector.translateToLocal("dye." + unlocalizedName);
|
|
|
|
}
|
|
|
|
|
2013-12-23 23:06:22 +01:00
|
|
|
/**
|
|
|
|
* Gets the name of this color with it's color prefix code.
|
|
|
|
* @return the color's name and color prefix
|
|
|
|
*/
|
2013-11-30 06:28:02 +01:00
|
|
|
public String getName()
|
|
|
|
{
|
|
|
|
return code + getLocalizedName();
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-04-10 04:05:28 +02:00
|
|
|
public String getDyedName()
|
|
|
|
{
|
|
|
|
return code + getDyeName();
|
|
|
|
}
|
|
|
|
|
2013-12-23 23:06:22 +01:00
|
|
|
/**
|
|
|
|
* Gets the 0-1 of this color's RGB value by dividing by 255 (used for OpenGL coloring).
|
|
|
|
* @param index - R:0, G:1, B:2
|
|
|
|
* @return the color value
|
|
|
|
*/
|
2013-11-30 06:28:02 +01:00
|
|
|
public float getColor(int index)
|
|
|
|
{
|
|
|
|
return (float)rgbCode[index]/255F;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-23 23:06:22 +01:00
|
|
|
/**
|
|
|
|
* Gets the value of this color mapped to MC in-game item colors present in dyes and wool.
|
|
|
|
* @return mc meta value
|
|
|
|
*/
|
2013-12-22 06:42:46 +01:00
|
|
|
public int getMetaValue()
|
|
|
|
{
|
|
|
|
return mcMeta;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-11-30 06:28:02 +01:00
|
|
|
@Override
|
|
|
|
public String toString()
|
|
|
|
{
|
|
|
|
return code;
|
|
|
|
}
|
|
|
|
}
|