BWMirror v1.2
This commit is contained in:
parent
05901f5562
commit
d86336dad3
147507
bwapi-data/BWTA/953f70aff5c809932a8d3df611dc1cb0c171d102.bwta
Normal file
147507
bwapi-data/BWTA/953f70aff5c809932a8d3df611dc1cb0c171d102.bwta
Normal file
File diff suppressed because it is too large
Load diff
30
bwapi/AbstractPoint.java
Normal file
30
bwapi/AbstractPoint.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package bwapi;
|
||||
|
||||
/**
|
||||
* Common ancestor for location based objects to simplify distance computation.
|
||||
* This will be refactored into interface with default methods when java 8 becomes widely used.
|
||||
*
|
||||
* Idea by Rafa³ Poniatowski
|
||||
*/
|
||||
public abstract class AbstractPoint<T extends AbstractPoint> {
|
||||
|
||||
public abstract T getPoint();
|
||||
|
||||
public int getX(){
|
||||
return getPoint().getX();
|
||||
}
|
||||
|
||||
public int getY(){
|
||||
return getPoint().getY();
|
||||
}
|
||||
|
||||
public double distanceTo(AbstractPoint<T> otherPosition) {
|
||||
return distanceTo(otherPosition.getX(), otherPosition.getY());
|
||||
}
|
||||
|
||||
public double distanceTo(int x, int y) {
|
||||
double dx = x - getX();
|
||||
double dy = y - getY();
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
}
|
15
bwapi/CenteredObject.java
Normal file
15
bwapi/CenteredObject.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package bwapi;
|
||||
|
||||
import bwapi.Position;
|
||||
|
||||
/**
|
||||
* Interrmediate class used to translate getPoint() calls to getCenter() calls.
|
||||
*/
|
||||
public abstract class CenteredObject extends AbstractPoint<Position> {
|
||||
|
||||
public Position getPoint(){
|
||||
return getCenter();
|
||||
}
|
||||
|
||||
public abstract Position getCenter();
|
||||
}
|
|
@ -56,7 +56,7 @@ public class Mirror {
|
|||
|
||||
private static final boolean EXTRACT_JAR = true;
|
||||
|
||||
private static final String VERSION = "1_1";
|
||||
private static final String VERSION = "1_2";
|
||||
|
||||
static {
|
||||
String arch = System.getProperty("os.arch");
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
|||
/**
|
||||
* Positions are measured in pixels and are the highest resolution.
|
||||
*/
|
||||
public class Position {
|
||||
public class Position extends AbstractPoint<Position>{
|
||||
|
||||
private int x, y;
|
||||
|
||||
|
@ -83,4 +83,8 @@ public class Position {
|
|||
}
|
||||
|
||||
private long pointer;
|
||||
|
||||
public Position getPoint(){
|
||||
return this;
|
||||
}
|
||||
}
|
15
bwapi/PositionedObject.java
Normal file
15
bwapi/PositionedObject.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package bwapi;
|
||||
|
||||
import bwapi.Position;
|
||||
|
||||
/**
|
||||
* Interrmediate class used to translate getPoint() calls to getPosition() calls.
|
||||
*/
|
||||
public abstract class PositionedObject extends AbstractPoint<Position> {
|
||||
|
||||
public Position getPoint(){
|
||||
return getPosition();
|
||||
}
|
||||
|
||||
public abstract Position getPosition();
|
||||
}
|
|
@ -6,8 +6,10 @@ import java.util.Map;
|
|||
import java.util.HashMap;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import bwapi.CenteredObject;
|
||||
|
||||
public class Region {
|
||||
public class Region extends CenteredObject
|
||||
{
|
||||
|
||||
public int getID() {
|
||||
return getID_native(pointer);
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Map;
|
|||
* These are called build tiles because buildability data is available at this resolution, and correspond to the tiles seen in game.
|
||||
* For example, a Command Center occupies an area of 4x3 build tiles.
|
||||
*/
|
||||
public class TilePosition {
|
||||
public class TilePosition extends AbstractPoint<TilePosition>{
|
||||
private int x, y;
|
||||
|
||||
public TilePosition(int x, int y) {
|
||||
|
@ -82,4 +82,8 @@ public class TilePosition {
|
|||
result = 31 * result + y;
|
||||
return result;
|
||||
}
|
||||
|
||||
public TilePosition getPoint(){
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -6,8 +6,10 @@ import java.util.Map;
|
|||
import java.util.HashMap;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import bwapi.PositionedObject;
|
||||
|
||||
public class Unit {
|
||||
public class Unit extends PositionedObject
|
||||
{
|
||||
|
||||
public int getID() {
|
||||
return getID_native(pointer);
|
||||
|
|
52
bwapi/Utils.java
Normal file
52
bwapi/Utils.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package bwapi;
|
||||
|
||||
import java.lang.String;
|
||||
import java.lang.System;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Utils {
|
||||
|
||||
public static final byte Previous = 0x01;
|
||||
public static final byte Cyan = 0x02;
|
||||
public static final byte Yellow = 0x03;
|
||||
public static final byte White = 0x04;
|
||||
public static final byte Grey = 0x05;
|
||||
public static final byte Red = 0x06;
|
||||
public static final byte Green = 0x07;
|
||||
public static final byte Red_P1 = 0x08;
|
||||
public static final byte Tab = 0x09;
|
||||
public static final byte Newline = 0x0A;
|
||||
public static final byte Invisible_no_override = 0x0B;
|
||||
public static final byte Remove_beyond = 0x0C;
|
||||
public static final byte Clear_formatting = 0x0D;
|
||||
public static final byte Blue = 0x0E;
|
||||
public static final byte Teal = 0x0F;
|
||||
public static final byte Purple = 0x10;
|
||||
public static final byte Orange = 0x11;
|
||||
public static final byte Right_Align = 0x12;
|
||||
public static final byte Center_Align = 0x13;
|
||||
public static final byte Invisible = 0x14;
|
||||
public static final byte Brown = 0x15;
|
||||
public static final byte White_p7 = 0x16;
|
||||
public static final byte Yellow_p8 = 0x17;
|
||||
public static final byte Green_p9 = 0x18;
|
||||
public static final byte Brighter_Yellow = 0x19;
|
||||
public static final byte Cyan_default = 0x1A;
|
||||
public static final byte Pinkish = 0x1B;
|
||||
public static final byte Dark_Cyan = 0x1C;
|
||||
public static final byte Greygreen = 0x1D;
|
||||
public static final byte Bluegrey = 0x1E;
|
||||
public static final byte Turquoise = 0x1F;
|
||||
|
||||
public static String formatText(String text, byte format){
|
||||
byte[] textData = text.getBytes();
|
||||
int textDataLength = text.length();
|
||||
|
||||
byte[] newTextData = new byte[textDataLength + 1];
|
||||
newTextData[0] = format;
|
||||
System.arraycopy(textData, 0, newTextData, 1, textDataLength);
|
||||
return new String(newTextData);
|
||||
}
|
||||
}
|
Binary file not shown.
BIN
bwapi_bridge1_2.exp
Normal file
BIN
bwapi_bridge1_2.exp
Normal file
Binary file not shown.
BIN
bwmirror_v1_2.jar
Normal file
BIN
bwmirror_v1_2.jar
Normal file
Binary file not shown.
|
@ -9,8 +9,10 @@ import java.util.List;
|
|||
import bwapi.Position;
|
||||
import bwapi.TilePosition;
|
||||
import bwapi.Player;
|
||||
import bwapi.PositionedObject;
|
||||
|
||||
public class BaseLocation {
|
||||
public class BaseLocation extends PositionedObject
|
||||
{
|
||||
|
||||
public Position getPosition() {
|
||||
return getPosition_native(pointer);
|
||||
|
|
|
@ -9,8 +9,10 @@ import java.util.List;
|
|||
import bwapi.Position;
|
||||
import bwapi.TilePosition;
|
||||
import bwapi.Player;
|
||||
import bwapi.CenteredObject;
|
||||
|
||||
public class Chokepoint {
|
||||
public class Chokepoint extends CenteredObject
|
||||
{
|
||||
|
||||
public Position getCenter() {
|
||||
return getCenter_native(pointer);
|
||||
|
|
|
@ -9,8 +9,10 @@ import java.util.List;
|
|||
import bwapi.Position;
|
||||
import bwapi.TilePosition;
|
||||
import bwapi.Player;
|
||||
import bwapi.CenteredObject;
|
||||
|
||||
public class Region {
|
||||
public class Region extends CenteredObject
|
||||
{
|
||||
|
||||
public Polygon getPolygon() {
|
||||
return getPolygon_native(pointer);
|
||||
|
|
BIN
compiled/bwapi/AbstractPoint.class
Normal file
BIN
compiled/bwapi/AbstractPoint.class
Normal file
Binary file not shown.
BIN
compiled/bwapi/AbstractPosition.class
Normal file
BIN
compiled/bwapi/AbstractPosition.class
Normal file
Binary file not shown.
BIN
compiled/bwapi/CenteredObject.class
Normal file
BIN
compiled/bwapi/CenteredObject.class
Normal file
Binary file not shown.
BIN
compiled/bwapi/CenteredPositionedObject.class
Normal file
BIN
compiled/bwapi/CenteredPositionedObject.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
compiled/bwapi/PositionedObject.class
Normal file
BIN
compiled/bwapi/PositionedObject.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
compiled/bwapi/Utils.class
Normal file
BIN
compiled/bwapi/Utils.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
128
concat_header.h
128
concat_header.h
|
@ -1,5 +1,27 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class bwapi_AbstractPoint */
|
||||
|
||||
#ifndef _Included_bwapi_AbstractPoint
|
||||
#define _Included_bwapi_AbstractPoint
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Header for class bwapi_AbstractPosition */
|
||||
|
||||
#ifndef _Included_bwapi_AbstractPosition
|
||||
#define _Included_bwapi_AbstractPosition
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Header for class bwapi_ActionID */
|
||||
|
||||
#ifndef _Included_bwapi_ActionID
|
||||
|
@ -353,6 +375,28 @@ extern "C" {
|
|||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Header for class bwapi_CenteredObject */
|
||||
|
||||
#ifndef _Included_bwapi_CenteredObject
|
||||
#define _Included_bwapi_CenteredObject
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Header for class bwapi_CenteredPositionedObject */
|
||||
|
||||
#ifndef _Included_bwapi_CenteredPositionedObject
|
||||
#define _Included_bwapi_CenteredPositionedObject
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Header for class bwapi_Client */
|
||||
|
||||
#ifndef _Included_bwapi_Client
|
||||
|
@ -4309,6 +4353,17 @@ JNIEXPORT jdouble JNICALL Java_bwapi_Position_getLength
|
|||
JNIEXPORT jboolean JNICALL Java_bwapi_Position_hasPath
|
||||
(JNIEnv *, jobject, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Header for class bwapi_PositionedObject */
|
||||
|
||||
#ifndef _Included_bwapi_PositionedObject
|
||||
#define _Included_bwapi_PositionedObject
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -8617,6 +8672,79 @@ JNIEXPORT jobject JNICALL Java_bwapi_UpgradeType_whatsRequired_1native__JI
|
|||
JNIEXPORT jobject JNICALL Java_bwapi_UpgradeType_whatUses_1native
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Header for class bwapi_Utils */
|
||||
|
||||
#ifndef _Included_bwapi_Utils
|
||||
#define _Included_bwapi_Utils
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef bwapi_Utils_Previous
|
||||
#define bwapi_Utils_Previous 1L
|
||||
#undef bwapi_Utils_Cyan
|
||||
#define bwapi_Utils_Cyan 2L
|
||||
#undef bwapi_Utils_Yellow
|
||||
#define bwapi_Utils_Yellow 3L
|
||||
#undef bwapi_Utils_White
|
||||
#define bwapi_Utils_White 4L
|
||||
#undef bwapi_Utils_Grey
|
||||
#define bwapi_Utils_Grey 5L
|
||||
#undef bwapi_Utils_Red
|
||||
#define bwapi_Utils_Red 6L
|
||||
#undef bwapi_Utils_Green
|
||||
#define bwapi_Utils_Green 7L
|
||||
#undef bwapi_Utils_Red_P1
|
||||
#define bwapi_Utils_Red_P1 8L
|
||||
#undef bwapi_Utils_Tab
|
||||
#define bwapi_Utils_Tab 9L
|
||||
#undef bwapi_Utils_Newline
|
||||
#define bwapi_Utils_Newline 10L
|
||||
#undef bwapi_Utils_Invisible_no_override
|
||||
#define bwapi_Utils_Invisible_no_override 11L
|
||||
#undef bwapi_Utils_Remove_beyond
|
||||
#define bwapi_Utils_Remove_beyond 12L
|
||||
#undef bwapi_Utils_Clear_formatting
|
||||
#define bwapi_Utils_Clear_formatting 13L
|
||||
#undef bwapi_Utils_Blue
|
||||
#define bwapi_Utils_Blue 14L
|
||||
#undef bwapi_Utils_Teal
|
||||
#define bwapi_Utils_Teal 15L
|
||||
#undef bwapi_Utils_Purple
|
||||
#define bwapi_Utils_Purple 16L
|
||||
#undef bwapi_Utils_Orange
|
||||
#define bwapi_Utils_Orange 17L
|
||||
#undef bwapi_Utils_Right_Align
|
||||
#define bwapi_Utils_Right_Align 18L
|
||||
#undef bwapi_Utils_Center_Align
|
||||
#define bwapi_Utils_Center_Align 19L
|
||||
#undef bwapi_Utils_Invisible
|
||||
#define bwapi_Utils_Invisible 20L
|
||||
#undef bwapi_Utils_Brown
|
||||
#define bwapi_Utils_Brown 21L
|
||||
#undef bwapi_Utils_White_p7
|
||||
#define bwapi_Utils_White_p7 22L
|
||||
#undef bwapi_Utils_Yellow_p8
|
||||
#define bwapi_Utils_Yellow_p8 23L
|
||||
#undef bwapi_Utils_Green_p9
|
||||
#define bwapi_Utils_Green_p9 24L
|
||||
#undef bwapi_Utils_Brighter_Yellow
|
||||
#define bwapi_Utils_Brighter_Yellow 25L
|
||||
#undef bwapi_Utils_Cyan_default
|
||||
#define bwapi_Utils_Cyan_default 26L
|
||||
#undef bwapi_Utils_Pinkish
|
||||
#define bwapi_Utils_Pinkish 27L
|
||||
#undef bwapi_Utils_Dark_Cyan
|
||||
#define bwapi_Utils_Dark_Cyan 28L
|
||||
#undef bwapi_Utils_Greygreen
|
||||
#define bwapi_Utils_Greygreen 29L
|
||||
#undef bwapi_Utils_Bluegrey
|
||||
#define bwapi_Utils_Bluegrey 30L
|
||||
#undef bwapi_Utils_Turquoise
|
||||
#define bwapi_Utils_Turquoise 31L
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
13
headers/bwapi_AbstractPoint.h
Normal file
13
headers/bwapi_AbstractPoint.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class bwapi_AbstractPoint */
|
||||
|
||||
#ifndef _Included_bwapi_AbstractPoint
|
||||
#define _Included_bwapi_AbstractPoint
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
13
headers/bwapi_AbstractPosition.h
Normal file
13
headers/bwapi_AbstractPosition.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class bwapi_AbstractPosition */
|
||||
|
||||
#ifndef _Included_bwapi_AbstractPosition
|
||||
#define _Included_bwapi_AbstractPosition
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
13
headers/bwapi_CenteredObject.h
Normal file
13
headers/bwapi_CenteredObject.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class bwapi_CenteredObject */
|
||||
|
||||
#ifndef _Included_bwapi_CenteredObject
|
||||
#define _Included_bwapi_CenteredObject
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
13
headers/bwapi_CenteredPositionedObject.h
Normal file
13
headers/bwapi_CenteredPositionedObject.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class bwapi_CenteredPositionedObject */
|
||||
|
||||
#ifndef _Included_bwapi_CenteredPositionedObject
|
||||
#define _Included_bwapi_CenteredPositionedObject
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
13
headers/bwapi_PositionedObject.h
Normal file
13
headers/bwapi_PositionedObject.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class bwapi_PositionedObject */
|
||||
|
||||
#ifndef _Included_bwapi_PositionedObject
|
||||
#define _Included_bwapi_PositionedObject
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
75
headers/bwapi_Utils.h
Normal file
75
headers/bwapi_Utils.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class bwapi_Utils */
|
||||
|
||||
#ifndef _Included_bwapi_Utils
|
||||
#define _Included_bwapi_Utils
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef bwapi_Utils_Previous
|
||||
#define bwapi_Utils_Previous 1L
|
||||
#undef bwapi_Utils_Cyan
|
||||
#define bwapi_Utils_Cyan 2L
|
||||
#undef bwapi_Utils_Yellow
|
||||
#define bwapi_Utils_Yellow 3L
|
||||
#undef bwapi_Utils_White
|
||||
#define bwapi_Utils_White 4L
|
||||
#undef bwapi_Utils_Grey
|
||||
#define bwapi_Utils_Grey 5L
|
||||
#undef bwapi_Utils_Red
|
||||
#define bwapi_Utils_Red 6L
|
||||
#undef bwapi_Utils_Green
|
||||
#define bwapi_Utils_Green 7L
|
||||
#undef bwapi_Utils_Red_P1
|
||||
#define bwapi_Utils_Red_P1 8L
|
||||
#undef bwapi_Utils_Tab
|
||||
#define bwapi_Utils_Tab 9L
|
||||
#undef bwapi_Utils_Newline
|
||||
#define bwapi_Utils_Newline 10L
|
||||
#undef bwapi_Utils_Invisible_no_override
|
||||
#define bwapi_Utils_Invisible_no_override 11L
|
||||
#undef bwapi_Utils_Remove_beyond
|
||||
#define bwapi_Utils_Remove_beyond 12L
|
||||
#undef bwapi_Utils_Clear_formatting
|
||||
#define bwapi_Utils_Clear_formatting 13L
|
||||
#undef bwapi_Utils_Blue
|
||||
#define bwapi_Utils_Blue 14L
|
||||
#undef bwapi_Utils_Teal
|
||||
#define bwapi_Utils_Teal 15L
|
||||
#undef bwapi_Utils_Purple
|
||||
#define bwapi_Utils_Purple 16L
|
||||
#undef bwapi_Utils_Orange
|
||||
#define bwapi_Utils_Orange 17L
|
||||
#undef bwapi_Utils_Right_Align
|
||||
#define bwapi_Utils_Right_Align 18L
|
||||
#undef bwapi_Utils_Center_Align
|
||||
#define bwapi_Utils_Center_Align 19L
|
||||
#undef bwapi_Utils_Invisible
|
||||
#define bwapi_Utils_Invisible 20L
|
||||
#undef bwapi_Utils_Brown
|
||||
#define bwapi_Utils_Brown 21L
|
||||
#undef bwapi_Utils_White_p7
|
||||
#define bwapi_Utils_White_p7 22L
|
||||
#undef bwapi_Utils_Yellow_p8
|
||||
#define bwapi_Utils_Yellow_p8 23L
|
||||
#undef bwapi_Utils_Green_p9
|
||||
#define bwapi_Utils_Green_p9 24L
|
||||
#undef bwapi_Utils_Brighter_Yellow
|
||||
#define bwapi_Utils_Brighter_Yellow 25L
|
||||
#undef bwapi_Utils_Cyan_default
|
||||
#define bwapi_Utils_Cyan_default 26L
|
||||
#undef bwapi_Utils_Pinkish
|
||||
#define bwapi_Utils_Pinkish 27L
|
||||
#undef bwapi_Utils_Dark_Cyan
|
||||
#define bwapi_Utils_Dark_Cyan 28L
|
||||
#undef bwapi_Utils_Greygreen
|
||||
#define bwapi_Utils_Greygreen 29L
|
||||
#undef bwapi_Utils_Bluegrey
|
||||
#define bwapi_Utils_Bluegrey 30L
|
||||
#undef bwapi_Utils_Turquoise
|
||||
#define bwapi_Utils_Turquoise 31L
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
30
manual-bwapi/AbstractPoint.java
Normal file
30
manual-bwapi/AbstractPoint.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package bwapi;
|
||||
|
||||
/**
|
||||
* Common ancestor for location based objects to simplify distance computation.
|
||||
* This will be refactored into interface with default methods when java 8 becomes widely used.
|
||||
*
|
||||
* Idea by Rafa³ Poniatowski
|
||||
*/
|
||||
public abstract class AbstractPoint<T extends AbstractPoint> {
|
||||
|
||||
public abstract T getPoint();
|
||||
|
||||
public int getX(){
|
||||
return getPoint().getX();
|
||||
}
|
||||
|
||||
public int getY(){
|
||||
return getPoint().getY();
|
||||
}
|
||||
|
||||
public double distanceTo(AbstractPoint<T> otherPosition) {
|
||||
return distanceTo(otherPosition.getX(), otherPosition.getY());
|
||||
}
|
||||
|
||||
public double distanceTo(int x, int y) {
|
||||
double dx = x - getX();
|
||||
double dy = y - getY();
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
}
|
15
manual-bwapi/CenteredObject.java
Normal file
15
manual-bwapi/CenteredObject.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package bwapi;
|
||||
|
||||
import bwapi.Position;
|
||||
|
||||
/**
|
||||
* Interrmediate class used to translate getPoint() calls to getCenter() calls.
|
||||
*/
|
||||
public abstract class CenteredObject extends AbstractPoint<Position> {
|
||||
|
||||
public Position getPoint(){
|
||||
return getCenter();
|
||||
}
|
||||
|
||||
public abstract Position getCenter();
|
||||
}
|
|
@ -56,7 +56,7 @@ public class Mirror {
|
|||
|
||||
private static final boolean EXTRACT_JAR = true;
|
||||
|
||||
private static final String VERSION = "1_1";
|
||||
private static final String VERSION = "1_2";
|
||||
|
||||
static {
|
||||
String arch = System.getProperty("os.arch");
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
|||
/**
|
||||
* Positions are measured in pixels and are the highest resolution.
|
||||
*/
|
||||
public class Position {
|
||||
public class Position extends AbstractPoint<Position>{
|
||||
|
||||
private int x, y;
|
||||
|
||||
|
@ -83,4 +83,8 @@ public class Position {
|
|||
}
|
||||
|
||||
private long pointer;
|
||||
|
||||
public Position getPoint(){
|
||||
return this;
|
||||
}
|
||||
}
|
15
manual-bwapi/PositionedObject.java
Normal file
15
manual-bwapi/PositionedObject.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package bwapi;
|
||||
|
||||
import bwapi.Position;
|
||||
|
||||
/**
|
||||
* Interrmediate class used to translate getPoint() calls to getPosition() calls.
|
||||
*/
|
||||
public abstract class PositionedObject extends AbstractPoint<Position> {
|
||||
|
||||
public Position getPoint(){
|
||||
return getPosition();
|
||||
}
|
||||
|
||||
public abstract Position getPosition();
|
||||
}
|
|
@ -9,7 +9,7 @@ import java.util.Map;
|
|||
* These are called build tiles because buildability data is available at this resolution, and correspond to the tiles seen in game.
|
||||
* For example, a Command Center occupies an area of 4x3 build tiles.
|
||||
*/
|
||||
public class TilePosition {
|
||||
public class TilePosition extends AbstractPoint<TilePosition>{
|
||||
private int x, y;
|
||||
|
||||
public TilePosition(int x, int y) {
|
||||
|
@ -82,4 +82,8 @@ public class TilePosition {
|
|||
result = 31 * result + y;
|
||||
return result;
|
||||
}
|
||||
|
||||
public TilePosition getPoint(){
|
||||
return this;
|
||||
}
|
||||
}
|
52
manual-bwapi/Utils.java
Normal file
52
manual-bwapi/Utils.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package bwapi;
|
||||
|
||||
import java.lang.String;
|
||||
import java.lang.System;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Utils {
|
||||
|
||||
public static final byte Previous = 0x01;
|
||||
public static final byte Cyan = 0x02;
|
||||
public static final byte Yellow = 0x03;
|
||||
public static final byte White = 0x04;
|
||||
public static final byte Grey = 0x05;
|
||||
public static final byte Red = 0x06;
|
||||
public static final byte Green = 0x07;
|
||||
public static final byte Red_P1 = 0x08;
|
||||
public static final byte Tab = 0x09;
|
||||
public static final byte Newline = 0x0A;
|
||||
public static final byte Invisible_no_override = 0x0B;
|
||||
public static final byte Remove_beyond = 0x0C;
|
||||
public static final byte Clear_formatting = 0x0D;
|
||||
public static final byte Blue = 0x0E;
|
||||
public static final byte Teal = 0x0F;
|
||||
public static final byte Purple = 0x10;
|
||||
public static final byte Orange = 0x11;
|
||||
public static final byte Right_Align = 0x12;
|
||||
public static final byte Center_Align = 0x13;
|
||||
public static final byte Invisible = 0x14;
|
||||
public static final byte Brown = 0x15;
|
||||
public static final byte White_p7 = 0x16;
|
||||
public static final byte Yellow_p8 = 0x17;
|
||||
public static final byte Green_p9 = 0x18;
|
||||
public static final byte Brighter_Yellow = 0x19;
|
||||
public static final byte Cyan_default = 0x1A;
|
||||
public static final byte Pinkish = 0x1B;
|
||||
public static final byte Dark_Cyan = 0x1C;
|
||||
public static final byte Greygreen = 0x1D;
|
||||
public static final byte Bluegrey = 0x1E;
|
||||
public static final byte Turquoise = 0x1F;
|
||||
|
||||
public static String formatText(String text, byte format){
|
||||
byte[] textData = text.getBytes();
|
||||
int textDataLength = text.length();
|
||||
|
||||
byte[] newTextData = new byte[textDataLength + 1];
|
||||
newTextData[0] = format;
|
||||
System.arraycopy(textData, 0, newTextData, 1, textDataLength);
|
||||
return new String(newTextData);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -14,12 +14,10 @@ import impl.Clazz;
|
|||
import util.FileUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Array;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
|
@ -45,6 +43,15 @@ public class CJavaPipeline {
|
|||
"Interface", "RectangleArray", "UnitImpl", "PlayerImpl", "GameImpl", "BulletImpl", "ForceImpl", "TournamentModule", "RegionImpl"));
|
||||
|
||||
|
||||
private static final HashMap<String, String> superClasses = new HashMap<>();
|
||||
|
||||
static {
|
||||
superClasses.put("Unit", "PositionedObject");
|
||||
superClasses.put("Region", "CenteredObject");
|
||||
superClasses.put("Chokepoint", "CenteredObject");
|
||||
superClasses.put("BaseLocation", "PositionedObject");
|
||||
}
|
||||
|
||||
public void run(PackageProcessOptions[] packages, Properties processingOptions) {
|
||||
/**
|
||||
Init
|
||||
|
@ -55,6 +62,7 @@ public class CJavaPipeline {
|
|||
|
||||
MirrorContext context = new MirrorContext();
|
||||
Generator generator = new Generator(context);
|
||||
generator.setJavaSuperClasses(superClasses);
|
||||
List<CDeclaration> allDecs = new ArrayList<>();
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,6 +7,7 @@ import generator.java.EnumMirror;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -22,6 +23,8 @@ public class Generator {
|
|||
|
||||
private MirrorContext context;
|
||||
|
||||
private HashMap<String,String> javaSuperClasses = new HashMap<>();
|
||||
|
||||
public Generator(MirrorContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
@ -34,6 +37,10 @@ public class Generator {
|
|||
enums.add(cenum);
|
||||
}
|
||||
|
||||
public void setJavaSuperClasses(HashMap<String, String> javaSuperClasses) {
|
||||
this.javaSuperClasses = javaSuperClasses;
|
||||
}
|
||||
|
||||
public void run(File javaRoot){
|
||||
context.prepareWrite(javaRoot);
|
||||
for(CClass cclass : classes){
|
||||
|
@ -52,7 +59,7 @@ public class Generator {
|
|||
protected void processClass(File root, CClass cClass){
|
||||
ClassMirror mirror = new ClassMirror(cClass);
|
||||
try {
|
||||
mirror.write(root, context);
|
||||
mirror.write(root, context, javaSuperClasses.get(cClass.getName()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ClassMirror extends Mirror {
|
|||
this.cClass = cClass;
|
||||
}
|
||||
|
||||
public void write(File root, MirrorContext context) throws Exception {
|
||||
public void write(File root, MirrorContext context, String superClass) throws Exception {
|
||||
nativeBinds = "";
|
||||
this.context = context;
|
||||
File file = new File(new File(root, context.getPackageDirs()), cClass.getName() + ".java");
|
||||
|
@ -31,8 +31,13 @@ public class ClassMirror extends Mirror {
|
|||
out = new PrintStream(file);
|
||||
|
||||
writePackage();
|
||||
writeImports();
|
||||
out.println("public" + SPACE + "class" + SPACE + cClass.getName() + SPACE + "{");
|
||||
writeImports(superClass);
|
||||
out.print("public" + SPACE + "class" + SPACE + cClass.getName() + SPACE );
|
||||
if(superClass != null){
|
||||
out.println("extends" + SPACE + superClass + SPACE);
|
||||
}
|
||||
out.println("{");
|
||||
|
||||
out.println();
|
||||
writeFields(cClass.getFields());
|
||||
if (!cClass.isStatic()) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public class EnumMirror extends Mirror {
|
|||
out = new PrintStream(file);
|
||||
|
||||
writePackage();
|
||||
writeImports();
|
||||
writeImports(null);
|
||||
out.println("public" + SPACE + "enum" + SPACE + cEnum.getName() + SPACE + "{");
|
||||
out.println();
|
||||
writeValues(cEnum.getValues());
|
||||
|
|
|
@ -83,7 +83,7 @@ public abstract class Mirror {
|
|||
}
|
||||
|
||||
|
||||
protected void writeImports() {
|
||||
protected void writeImports(String superClass) {
|
||||
out.println("import" + SPACE + context.getPackage() + ".*" + SEMICOLON);
|
||||
out.println();
|
||||
out.println("import java.util.Map" + SEMICOLON);
|
||||
|
@ -93,6 +93,9 @@ public abstract class Mirror {
|
|||
for (String pkg : context.getAdditionalImports()) {
|
||||
out.println("import" + SPACE + pkg + SEMICOLON);
|
||||
}
|
||||
if(superClass != null){
|
||||
out.println("import bwapi."+superClass + SEMICOLON);
|
||||
}
|
||||
out.println();
|
||||
writeJavadoc(getDecl());
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package test.api;
|
|||
|
||||
import bwapi.*;
|
||||
import bwta.BWTA;
|
||||
import bwta.BaseLocation;
|
||||
import org.jsoup.Connection;
|
||||
|
||||
/**
|
||||
* User: PC
|
||||
|
@ -59,14 +61,17 @@ public class TestBot1 {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (closestMineral != null) {
|
||||
myUnit.gather(closestMineral, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//draw my units on screen
|
||||
game.drawTextScreen(10, 25, units.toString());
|
||||
game.drawTextScreen(10, 25, Utils.formatText("hello world", Utils.Blue));
|
||||
}
|
||||
});
|
||||
/*
|
||||
|
|
Reference in a new issue