Skip to content

Commit 61cc103

Browse files
authored
Merge pull request #43 from JavaBWAPI/text
change Text(Color) to conform to BWAPI/BWMirror
2 parents c200b55 + 616f125 commit 61cc103

File tree

5 files changed

+52
-53
lines changed

5 files changed

+52
-53
lines changed

src/main/java/bwapi/Game.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public class Game {
9696
private short[] mapSplitTilesRegion1;
9797
private short[] mapSplitTilesRegion2;
9898
// USER DEFINED
99-
private TextSize textSize = TextSize.Default;
99+
private Text.Size textSize = Text.Size.Default;
100100

101101
Game(Client client) {
102102
this.client = client;
@@ -1487,7 +1487,7 @@ public List<TilePosition> getStartLocations() {
14871487

14881488
/**
14891489
* Prints text to the screen as a notification. This function allows text
1490-
* formatting using {@link TextColor#formatText}.
1490+
* formatting using {@link Text#formatText}.
14911491
* <p>
14921492
* That text printed through this function is not seen by other players or in replays.
14931493
*
@@ -2394,16 +2394,16 @@ public boolean hasPath(final Position source, final Position destination) {
23942394
}
23952395

23962396
public void setTextSize() {
2397-
setTextSize(TextSize.Default);
2397+
setTextSize(Text.Size.Default);
23982398
}
23992399

24002400
/**
24012401
* Sets the size of the text for all calls to {@link #drawText} following this one.
24022402
*
2403-
* @param size The size of the text. This value is one of Text#Size. If this value is omitted, then a default value of {@link TextSize#Default} is used.
2404-
* @see TextSize
2403+
* @param size The size of the text. This value is one of Text#Size. If this value is omitted, then a default value of {@link Text.Size#Default} is used.
2404+
* @see Text.Size
24052405
*/
2406-
public void setTextSize(final TextSize size) {
2406+
public void setTextSize(final Text.Size size) {
24072407
textSize = size;
24082408
}
24092409

src/main/java/bwapi/Player.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -520,34 +520,34 @@ public Color getColor() {
520520
*
521521
* @return character code to use for text in Broodwar.
522522
*/
523-
public TextColor getTextColor() {
523+
public Text getTextColor() {
524524
switch (playerData.getColor()) {
525525
case 111: // red
526-
return TextColor.BrightRed;
526+
return Text.BrightRed;
527527
case 165: // blue
528-
return TextColor.Blue;
528+
return Text.Blue;
529529
case 159: // teal
530-
return TextColor.Teal;
530+
return Text.Teal;
531531
case 164: // purp
532-
return TextColor.Purple;
532+
return Text.Purple;
533533
case 156: // orange with fix from @n00byEdge
534-
return TextColor.Orange;
534+
return Text.Orange;
535535
case 19: // brown
536-
return TextColor.Brown;
536+
return Text.Brown;
537537
case 84: // white
538-
return TextColor.PlayerWhite;
538+
return Text.PlayerWhite;
539539
case 135: // yellow
540-
return TextColor.PlayerYellow;
540+
return Text.PlayerYellow;
541541
case 185: // green p9
542-
return TextColor.DarkGreen;
542+
return Text.DarkGreen;
543543
case 136: // p10
544-
return TextColor.LightYellow;
544+
return Text.LightYellow;
545545
case 134: // p11
546-
return TextColor.Tan;
546+
return Text.Tan;
547547
case 51: // p12
548-
return TextColor.GreyBlue;
548+
return Text.GreyBlue;
549549
default:
550-
return TextColor.Default;
550+
return Text.Default;
551551
}
552552
}
553553

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* <p>
66
* Such codes are used in calls to {@link Game#drawText}, {@link Game#printf}
77
*/
8-
public enum TextColor {
8+
public enum Text {
99
/**
1010
* Uses the previous color that was specified before the current one.
1111
*/
@@ -117,14 +117,14 @@ public enum TextColor {
117117

118118
final byte id;
119119

120-
TextColor(final int id) {
120+
Text(final int id) {
121121
this.id = (byte) id;
122122
}
123123

124124
/**
125125
* Format text with a textcolor to display on broodwar
126126
*/
127-
public static String formatText(final String text, final TextColor format) {
127+
public static String formatText(final String text, final Text format) {
128128
final byte[] data = text.getBytes();
129129
final int len = text.length();
130130
final byte[] formatted = new byte[len + 1];
@@ -143,4 +143,32 @@ boolean isColor() {
143143
final int c = this.id;
144144
return (2 <= c && c <= 8) || (14 <= c && c <= 17) || (21 <= c && c <= 31);
145145
}
146+
147+
/**
148+
* Enumeration of available text sizes.
149+
*/
150+
public enum Size {
151+
/**
152+
* The smallest text size in the game.
153+
*/
154+
Small(0),
155+
/**
156+
* The standard text size, used for most things in the game such as chat messages.
157+
*/
158+
Default(1),
159+
/**
160+
* A larger text size. This size is used for the in-game countdown timer seen in @CTF and @UMS game types.
161+
*/
162+
Large(2),
163+
/**
164+
* The largest text size in the game.
165+
*/
166+
Huge(3);
167+
168+
final int id;
169+
170+
Size(final int id) {
171+
this.id = id;
172+
}
173+
}
146174
}

src/main/java/bwapi/TextSize.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/test/java/marinehell/MarineHell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void onStart() {
7575

7676
@Override
7777
public void onFrame() {
78-
// game.setTextSize(10);
78+
// game.setText.Size(10);
7979
game.drawTextScreen(10, 10, "Playing as " + self.getName() + " - " + self.getRace());
8080
game.drawTextScreen(10, 20, "Units: " + self.getUnits().size() + "; Enemies: " + enemyBuildingMemory.size());
8181
game.drawTextScreen(10, 30,

0 commit comments

Comments
 (0)