|
1 | 1 | package bwapi; |
2 | 2 |
|
3 | 3 |
|
| 4 | +import java.util.HashMap; |
| 5 | +import java.util.Map; |
4 | 6 | import java.util.Objects; |
5 | 7 |
|
6 | 8 | /** |
@@ -59,6 +61,22 @@ public class Color { |
59 | 61 | */ |
60 | 62 | public final static Color Grey = new Color(74); |
61 | 63 |
|
| 64 | + private final static Map<Integer, String> defaultColors = new HashMap<>(); |
| 65 | + static { |
| 66 | + defaultColors.put(Color.Red.id, "Red"); |
| 67 | + defaultColors.put(Color.Blue.id, "Blue"); |
| 68 | + defaultColors.put(Color.Teal.id, "Teal"); |
| 69 | + defaultColors.put(Color.Purple.id, "Purple"); |
| 70 | + defaultColors.put(Color.Orange.id, "Orange"); |
| 71 | + defaultColors.put(Color.Brown.id, "Brown"); |
| 72 | + defaultColors.put(Color.White.id, "White"); |
| 73 | + defaultColors.put(Color.Yellow.id, "Yellow"); |
| 74 | + defaultColors.put(Color.Green.id, "Green"); |
| 75 | + defaultColors.put(Color.Cyan.id, "Cyan"); |
| 76 | + defaultColors.put(Color.Black.id, "Black"); |
| 77 | + defaultColors.put(Color.Grey.id, "Grey"); |
| 78 | + } |
| 79 | + |
62 | 80 | private static final RGBQUAD RGBRESERVE = new RGBQUAD(0, 0, 0, 0xFF); |
63 | 81 |
|
64 | 82 | private static final RGBQUAD[] defaultPalette = { |
@@ -188,6 +206,17 @@ public int hashCode() { |
188 | 206 | return Objects.hash(id); |
189 | 207 | } |
190 | 208 |
|
| 209 | + @Override |
| 210 | + public String toString() { |
| 211 | + if (defaultColors.containsKey(id)) { |
| 212 | + return "Color." + defaultColors.get(id); |
| 213 | + } |
| 214 | + return "Color{" + |
| 215 | + "red=" + red() + |
| 216 | + ", green=" + green() + |
| 217 | + ", blue=" + blue() + "}"; |
| 218 | + } |
| 219 | + |
191 | 220 | /// BROODWAR COLOR IMPLEMENTATION |
192 | 221 | private static class RGBQUAD { |
193 | 222 | final int rgbRed; |
|
0 commit comments