in-game. More data and overlay info can be added later.dev
parent
dc79351730
commit
4868ccdb0f
Binary file not shown.
@ -0,0 +1,144 @@ |
||||
package sig.modules.RabiRibi; |
||||
|
||||
import java.awt.Point; |
||||
import java.lang.reflect.Field; |
||||
|
||||
import com.sun.jna.Memory; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.platform.win32.Kernel32; |
||||
|
||||
import sig.modules.RabiRibiModule; |
||||
import sig.modules.RabiRibi.SmoothObjects.EntityMarker; |
||||
import sig.utils.ReflectUtils; |
||||
|
||||
public class Entity { |
||||
int id = 0; |
||||
int uuid = 0; |
||||
int hp = 0; |
||||
int maxhp = 0; |
||||
boolean active = false; |
||||
int animation = 0; |
||||
float x = 0; |
||||
float y = 0; |
||||
RabiRibiModule parent = null; |
||||
int lastTookDamage = 0; |
||||
long pointer; |
||||
int color = 0; |
||||
public EntityMarker marker; |
||||
|
||||
public Entity(long memoryOffset, int uuid, RabiRibiModule parent) { |
||||
this.parent=parent; |
||||
pointer = memoryOffset; |
||||
this.uuid = uuid; |
||||
this.marker = new EntityMarker((int)x,(int)y,(int)x,(int)y,this,parent); |
||||
UpdateValues(); |
||||
this.active = readIntFromMemoryOffset(MemoryOffset.ENTITY_ISACTIVE, pointer)==1 && |
||||
id!=0 && id!=1 && maxhp!=0; |
||||
if (this.active) { |
||||
parent.overlay.objects.add(this.marker); |
||||
} |
||||
} |
||||
|
||||
public boolean run() { |
||||
this.active = readIntFromMemoryOffset(MemoryOffset.ENTITY_ISACTIVE, pointer)==1 && |
||||
id!=0 && id!=1 && maxhp!=0; |
||||
|
||||
if (!active) { |
||||
return false; |
||||
} |
||||
|
||||
if (readIntFromMemoryOffset(MemoryOffset.ENTITY_HP, pointer)<hp) { |
||||
lastTookDamage = parent.readIntFromMemory(MemoryOffset.PLAYTIME); |
||||
} |
||||
|
||||
UpdateValues(); |
||||
return true; |
||||
} |
||||
|
||||
/*public Point getScreenPosition() { |
||||
//The screen supports 20x11.5 tiles per map tile.
|
||||
//A map tile is 1280x720
|
||||
//float xtile = x
|
||||
}*/ |
||||
|
||||
public int getHealth() { |
||||
return hp; |
||||
} |
||||
|
||||
public int getMaxHealth() { |
||||
return maxhp; |
||||
} |
||||
|
||||
public int getLastHitTime() { |
||||
return lastTookDamage; |
||||
} |
||||
|
||||
public int getID() { |
||||
return id; |
||||
} |
||||
|
||||
private void UpdateValues() { |
||||
this.id = readIntFromMemoryOffset(MemoryOffset.ENTITY_ID, pointer); |
||||
this.animation = readIntFromMemoryOffset(MemoryOffset.ENTITY_ANIMATION, pointer); |
||||
if (this.animation!=-9999) { |
||||
this.hp = readIntFromMemoryOffset(MemoryOffset.ENTITY_HP, pointer); |
||||
} else { |
||||
this.hp = 0; |
||||
} |
||||
this.maxhp = readIntFromMemoryOffset(MemoryOffset.ENTITY_MAXHP, pointer); |
||||
this.x = readFloatFromMemoryOffset(MemoryOffset.ENTITY_XPOS, pointer); |
||||
this.y = readFloatFromMemoryOffset(MemoryOffset.ENTITY_YPOS, pointer); |
||||
this.color = readIntFromMemoryOffset(MemoryOffset.ENTITY_COLOR, pointer); |
||||
this.marker.setTarget(parent.overlay.getScreenPosition(x,y)); |
||||
} |
||||
|
||||
public int getUniqueID() { |
||||
return uuid; |
||||
} |
||||
|
||||
public boolean isActive() { |
||||
return active; |
||||
} |
||||
|
||||
public float readFloatFromMemoryOffset(MemoryOffset val, long pointer) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(pointer+val.getOffset()), mem, 4, null); |
||||
return mem.getFloat(0); |
||||
} |
||||
|
||||
public int readIntFromMemoryOffset(MemoryOffset val, long pointer) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(pointer+val.getOffset()), mem, 4, null); |
||||
return mem.getInt(0); |
||||
} |
||||
|
||||
public String toString() { |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append(this.getClass().getName()+"("); |
||||
boolean first=false; |
||||
for (Field f : this.getClass().getDeclaredFields()) { |
||||
//if (!ReflectUtils.isCloneable(f)) {
|
||||
if (!first) { |
||||
try { |
||||
sb.append(f.getName()+"="+f.get(this)); |
||||
first=true; |
||||
} catch (IllegalArgumentException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} else { |
||||
try { |
||||
sb.append(","+f.getName()+"="+f.get(this)); |
||||
} catch (IllegalArgumentException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
//}
|
||||
} |
||||
sb.append(")"); |
||||
return sb.toString(); |
||||
} |
||||
} |
@ -0,0 +1,163 @@ |
||||
package sig.modules.RabiRibi; |
||||
|
||||
import com.sun.jna.Memory; |
||||
import com.sun.jna.Pointer; |
||||
import com.sun.jna.platform.win32.Kernel32; |
||||
|
||||
import sig.modules.RabiRibiModule; |
||||
import sig.utils.DebugUtils; |
||||
|
||||
public class MemoryValue { |
||||
RabiRibiModule parent; |
||||
MemoryValueType type; |
||||
long offset=-1; |
||||
long pointer=-1; |
||||
public boolean needsUpdating=false; |
||||
int lastIntValue; |
||||
float lastFloatValue; |
||||
|
||||
public MemoryValue(MemoryValueType type, long offset, RabiRibiModule parent) { |
||||
this.type=type; |
||||
this.offset=offset; |
||||
this.parent=parent; |
||||
} |
||||
|
||||
public MemoryValue(long offset, long pointer, RabiRibiModule parent) { |
||||
this(MemoryValueType.POINTER,offset, parent); |
||||
this.pointer=pointer; |
||||
} |
||||
|
||||
public MemoryValue(MemoryValueType type, MemoryOffset offset, RabiRibiModule parent) { |
||||
this(type,offset.getOffset(),parent); |
||||
} |
||||
|
||||
public MemoryValue(MemoryOffset offset, MemoryOffset pointer, RabiRibiModule parent) { |
||||
this(offset.getOffset(),pointer.getOffset(),parent); |
||||
} |
||||
|
||||
public int getInt() { |
||||
if (needsUpdating) { |
||||
switch (type) { |
||||
case ABSOLUTE: |
||||
lastIntValue = readDirectIntFromMemoryLocation(offset); |
||||
break; |
||||
case LOCAL: |
||||
lastIntValue = readIntFromMemory(offset); |
||||
break; |
||||
case POINTER: |
||||
lastIntValue = readIntFromPointer(offset,pointer); |
||||
break; |
||||
} |
||||
needsUpdating=false; |
||||
} |
||||
return lastIntValue; |
||||
} |
||||
|
||||
public float getFloat() { |
||||
if (needsUpdating) { |
||||
switch (type) { |
||||
case ABSOLUTE: |
||||
lastFloatValue = readDirectFloatFromMemoryLocation(offset); |
||||
break; |
||||
case LOCAL: |
||||
lastFloatValue = readFloatFromMemory(offset); |
||||
break; |
||||
case POINTER: |
||||
lastFloatValue = readFloatFromPointer(offset,pointer); |
||||
break; |
||||
} |
||||
needsUpdating=false; |
||||
} |
||||
return lastFloatValue; |
||||
} |
||||
|
||||
int readIntFromErinaData(MemoryOffset val) { |
||||
return readIntFromPointer(val,MemoryOffset.ENTITY_ARRAY); |
||||
} |
||||
|
||||
float readFloatFromErinaData(MemoryOffset val) { |
||||
return readFloatFromPointer(val,MemoryOffset.ENTITY_ARRAY); |
||||
} |
||||
|
||||
int readIntFromMemory(long offset) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(parent.rabiRibiMemOffset+offset), mem, 4, null); |
||||
return mem.getInt(0); |
||||
} |
||||
|
||||
float readFloatFromMemory(long offset) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(parent.rabiRibiMemOffset+offset), mem, 4, null); |
||||
return mem.getFloat(0); |
||||
} |
||||
|
||||
float readFloatFromMemoryOffset(MemoryOffset val, long pointer) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(pointer+val.getOffset()), mem, 4, null); |
||||
return mem.getFloat(0); |
||||
} |
||||
|
||||
int readIntFromMemoryOffset(MemoryOffset val, long pointer) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(pointer+val.getOffset()), mem, 4, null); |
||||
return mem.getInt(0); |
||||
} |
||||
|
||||
float readDirectFloatFromMemoryLocation(long pointer) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(pointer), mem, 4, null); |
||||
return mem.getFloat(0); |
||||
} |
||||
|
||||
int readDirectIntFromMemoryLocation(long pointer) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(pointer), mem, 4, null); |
||||
return mem.getInt(0); |
||||
} |
||||
|
||||
int readIntFromPointer(MemoryOffset val, MemoryOffset pointer) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(readIntFromMemory(pointer.getOffset())+val.getOffset()), mem, 4, null); |
||||
return mem.getInt(0); |
||||
} |
||||
|
||||
int readIntFromPointer(long val, long pointer) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(readIntFromMemory(pointer)+val), mem, 4, null); |
||||
return mem.getInt(0); |
||||
} |
||||
|
||||
float readFloatFromPointer(MemoryOffset val, MemoryOffset pointer) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(readIntFromMemory(pointer.getOffset())+val.getOffset()), mem, 4, null); |
||||
return mem.getFloat(0); |
||||
} |
||||
|
||||
float readFloatFromPointer(long val, long pointer) { |
||||
Memory mem = new Memory(4); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(readIntFromMemory(pointer)+val), mem, 4, null); |
||||
return mem.getFloat(0); |
||||
} |
||||
|
||||
int readIntFromMemory(MemoryOffset val) { |
||||
return (int)readFromMemory(val,MemoryType.INTEGER); |
||||
} |
||||
|
||||
float readFloatFromMemory(MemoryOffset val) { |
||||
return (float)readFromMemory(val,MemoryType.FLOAT); |
||||
} |
||||
|
||||
Object readFromMemory(MemoryOffset val, MemoryType type) { |
||||
Memory mem = new Memory(type.getSize()); |
||||
Kernel32.INSTANCE.ReadProcessMemory(parent.rabiribiProcess, new Pointer(parent.rabiRibiMemOffset+val.getOffset()), mem, type.getSize(), null); |
||||
switch (type) { |
||||
case FLOAT: |
||||
return mem.getFloat(0); |
||||
case INTEGER: |
||||
return mem.getInt(0); |
||||
default: |
||||
System.out.println("WARNING! Type "+type+" does not have a defined value."); |
||||
return -1; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,7 @@ |
||||
package sig.modules.RabiRibi; |
||||
|
||||
public enum MemoryValueType { |
||||
LOCAL, //Memory offset found relative to base address.
|
||||
ABSOLUTE, //Memory found absolute in the memory table.
|
||||
POINTER; //A value that points to a memory address.
|
||||
} |
@ -0,0 +1,141 @@ |
||||
package sig.modules.RabiRibi; |
||||
|
||||
import java.awt.Graphics; |
||||
import java.awt.Point; |
||||
import java.awt.geom.Point2D; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
|
||||
import sig.modules.RabiRibiModule; |
||||
import sig.modules.RabiRibi.SmoothObjects.ErinaMarker; |
||||
|
||||
public class Overlay { |
||||
float xcoord=-1f,ycoord=-1f; |
||||
boolean changedRooms=false; |
||||
RabiRibiModule parent; |
||||
public float xpos,ypos,xspd,yspd; |
||||
public float camera_xpos,camera_ypos; |
||||
public List<SmoothObject> objects = new ArrayList<SmoothObject>(); |
||||
|
||||
ErinaMarker ERINA_MARKER; |
||||
|
||||
public Overlay(RabiRibiModule parent){ |
||||
this.parent = parent; |
||||
/*this.xcoord = (int)(parent.readFloatFromErinaData(MemoryOffset.ERINA_XPOS)/1280); |
||||
this.ycoord = (int)(parent.readFloatFromErinaData(MemoryOffset.ERINA_YPOS)/720);*/ |
||||
ERINA_MARKER = new ErinaMarker(0,0,0,0,parent); |
||||
|
||||
objects.add(ERINA_MARKER); |
||||
} |
||||
|
||||
public void run() { |
||||
camera_xpos = parent.readIntFromMemory(MemoryOffset.CAMERA_XPOS); |
||||
camera_ypos = parent.readIntFromMemory(MemoryOffset.CAMERA_YPOS); |
||||
|
||||
float prev_camera_xpos = camera_xpos; |
||||
float prev_camera_ypos = camera_ypos; |
||||
xpos = parent.readFloatFromErinaData(MemoryOffset.ERINA_XPOS); |
||||
ypos = parent.readFloatFromErinaData(MemoryOffset.ERINA_YPOS); |
||||
|
||||
xspd = camera_xpos-prev_camera_xpos; |
||||
yspd = camera_ypos-prev_camera_ypos; |
||||
for (SmoothObject so : objects) { |
||||
so.run(); |
||||
} |
||||
/*int new_xcoord,new_ycoord; |
||||
|
||||
float prev_xpos = xpos; |
||||
float prev_ypos = ypos; |
||||
float prev_camera_xpos = camera_xpos; |
||||
float prev_camera_ypos = camera_ypos; |
||||
|
||||
xpos = parent.readFloatFromErinaData(MemoryOffset.ERINA_XPOS)/1280; |
||||
ypos = parent.readFloatFromErinaData(MemoryOffset.ERINA_YPOS)/720; |
||||
camera_xpos = parent.readIntFromMemory(MemoryOffset.CAMERA_XPOS); |
||||
camera_ypos = parent.readIntFromMemory(MemoryOffset.CAMERA_YPOS); |
||||
|
||||
if (Math.abs(parent.readFloatFromErinaData(MemoryOffset.ERINA_XSPEED))>0.5f) { |
||||
if ((Math.abs(prev_xpos-xpos)>0.005 && xpos%1>0.01 && xpos%1<0.99) || (Math.abs(prev_ypos-ypos)>0.005 && ypos%1>0.01 && ypos%1<0.99)) { |
||||
if (Math.abs(prev_xpos-xpos)>0.005) { |
||||
if (edgeOfScreenX) { |
||||
if (prev_camera_xpos!=camera_xpos) { |
||||
edgeOfScreenX = false; |
||||
//System.out.println("Not on edge of X screen anymore.");
|
||||
} |
||||
} else { |
||||
if (prev_camera_xpos==camera_xpos) { |
||||
edgeOfScreenX = true; |
||||
//System.out.println("Now on edge of X screen.");
|
||||
} |
||||
} |
||||
} |
||||
if (Math.abs(prev_ypos-ypos)>0.005) { |
||||
if (edgeOfScreenY) { |
||||
if (prev_camera_ypos!=camera_ypos) { |
||||
edgeOfScreenY = false; |
||||
//System.out.println("Not on edge of Y screen anymore.");
|
||||
} |
||||
} else { |
||||
if (prev_camera_ypos==camera_ypos) { |
||||
edgeOfScreenY = true; |
||||
//System.out.println("Now on edge of Y screen.");
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
new_xcoord = (int)(xpos); |
||||
new_ycoord = (int)(ypos); |
||||
int xchange = (int)Math.signum(xcoord-new_xcoord); //-1 = Moving Right (Left edge), 1 = Moving Left(Right edge)
|
||||
int ychange = (int)Math.signum(ycoord-new_ycoord); //-1 = Moving Down(Top edge), 1 = Moving Up (Bottom edge)
|
||||
if (xchange!=0 || ychange!=0) { |
||||
//Re-orient the camera, there has been a room change.
|
||||
float pct_xroom = xpos%1 + ((edgeOfScreenX)?0:0.5f); |
||||
float pct_yroom = ypos%1 + ((edgeOfScreenY)?0:0.5f); |
||||
camera_offset_x = -(pct_xroom*20); |
||||
camera_offset_y = -(pct_yroom*11.25f); |
||||
System.out.println(pct_xroom+"%,"+pct_yroom+"%. Change detected. Camera is offset by ("+camera_offset_x+","+camera_offset_y+")"); |
||||
this.xcoord = new_xcoord; |
||||
this.ycoord = new_ycoord; |
||||
camera_x = parent.readFloatFromErinaData(MemoryOffset.ERINA_XPOS) + camera_offset_x*64; |
||||
camera_y = parent.readFloatFromErinaData(MemoryOffset.ERINA_YPOS) + camera_offset_y*64; |
||||
System.out.println("Camera position is ("+camera_x+","+camera_y+")"); |
||||
starting_camera_x = camera_xpos; |
||||
starting_camera_y = camera_ypos; |
||||
}*/ |
||||
} |
||||
|
||||
public Point.Double getScreenPosition(float xpos, float ypos) { |
||||
/*float diffx = xpos-camera_x; |
||||
float diffy = ypos-camera_y; |
||||
|
||||
double screen_blocksize_x = parent.getPosition().getWidth()/20; |
||||
double screen_blocksize_y = parent.getPosition().getHeight()/11.25; |
||||
|
||||
float camera_diffx = starting_camera_x-parent.readIntFromMemory(MemoryOffset.CAMERA_XPOS); |
||||
float camera_diffy = starting_camera_y-parent.readIntFromMemory(MemoryOffset.CAMERA_YPOS); |
||||
|
||||
//System.out.println("Block size is ("+screen_blocksize_x+","+screen_blocksize_y+"). Diff is ("+diffx+","+diffy+").");
|
||||
/*System.out.println("Starting Camera: ("+starting_camera_x+","+starting_camera_y+")"); |
||||
System.out.println("Camera: ("+camera_diffx+","+camera_diffy+")"); |
||||
System.out.println("Block Coords: ("+(camera_diffx/64)+","+(camera_diffy/64)+")");*/ |
||||
|
||||
double screen_blocksize_x = parent.getPosition().getWidth()/20; |
||||
double screen_blocksize_y = parent.getPosition().getHeight()/11.25; |
||||
|
||||
return new Point.Double(((xpos-(-camera_xpos)+xspd*2)/64)*screen_blocksize_x, |
||||
((ypos-(-camera_ypos)+yspd*2)/64)*screen_blocksize_y); |
||||
} |
||||
|
||||
public void draw(Graphics g) { |
||||
if (parent.readIntFromMemory(MemoryOffset.TRANSITION_COUNTER)<300) { |
||||
for (SmoothObject so : objects) { |
||||
so.draw(g); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,51 @@ |
||||
package sig.modules.RabiRibi; |
||||
|
||||
import java.awt.Graphics; |
||||
import java.awt.Point; |
||||
|
||||
import sig.modules.RabiRibiModule; |
||||
|
||||
public class SmoothObject { |
||||
protected int x,y; |
||||
int targetx,targety; |
||||
protected RabiRibiModule parent; |
||||
|
||||
public SmoothObject(int x, int y, int targetx, int targety, RabiRibiModule parent) { |
||||
this.x=x; |
||||
this.y=y; |
||||
this.targetx=targetx; |
||||
this.targety=targety; |
||||
this.parent=parent; |
||||
} |
||||
|
||||
public void setTarget(Point target) { |
||||
targetx = (int)target.getX(); |
||||
targety = (int)target.getY(); |
||||
} |
||||
|
||||
public void setTarget(Point.Double target) { |
||||
targetx = (int)target.getX(); |
||||
targety = (int)target.getY(); |
||||
} |
||||
|
||||
public Point getTarget() { |
||||
return new Point(targetx,targety); |
||||
} |
||||
|
||||
public void setPosition(Point position) { |
||||
x = (int)position.getX(); |
||||
y = (int)position.getY(); |
||||
} |
||||
|
||||
public void run() { |
||||
int xdiff = targetx-x; |
||||
int ydiff = targety-y; |
||||
x+=xdiff/1.3; |
||||
y+=ydiff/1.3; |
||||
//System.out.println("X:"+x+", Y:"+y+" TargetX:"+targetx+" TargetY:"+targety);
|
||||
} |
||||
|
||||
public void draw(Graphics g) { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,37 @@ |
||||
package sig.modules.RabiRibi.SmoothObjects; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Graphics; |
||||
|
||||
import sig.modules.RabiRibiModule; |
||||
import sig.modules.RabiRibi.Entity; |
||||
import sig.modules.RabiRibi.MemoryOffset; |
||||
import sig.modules.RabiRibi.SmoothObject; |
||||
|
||||
public class EntityMarker extends SmoothObject{ |
||||
Entity ent; |
||||
|
||||
public EntityMarker(int x, int y, int targetx, int targety, Entity ent, RabiRibiModule parent) { |
||||
super(x, y, targetx, targety, parent); |
||||
this.ent=ent; |
||||
} |
||||
|
||||
public void draw(Graphics g) { |
||||
super.draw(g); |
||||
int alphaval = (ent.getLastHitTime()>parent.readIntFromMemory(MemoryOffset.PLAYTIME)-180)?255:110; |
||||
float pct = ent.getHealth()/(float)ent.getMaxHealth(); |
||||
if (pct>=0.66) { |
||||
g.setColor(new Color(64,255,64,alphaval)); |
||||
} else |
||||
if (pct>=0.33) { |
||||
g.setColor(new Color(255,255,64,alphaval)); |
||||
} else { |
||||
g.setColor(new Color(255,64,64,alphaval)); |
||||
} |
||||
g.fillRect(x, y-56, (int)(48*pct), 16); |
||||
g.setColor(new Color(0,0,0,alphaval)); |
||||
g.drawRect(x, y-56, 48, 16); |
||||
g.setColor(Color.BLACK); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,23 @@ |
||||
package sig.modules.RabiRibi.SmoothObjects; |
||||
|
||||
import java.awt.Graphics; |
||||
import java.awt.Point; |
||||
import java.awt.geom.Point2D; |
||||
|
||||
import sig.modules.RabiRibiModule; |
||||
import sig.modules.RabiRibi.SmoothObject; |
||||
|
||||
public class ErinaMarker extends SmoothObject{ |
||||
|
||||
|
||||
public ErinaMarker(int x, int y, int targetx, int targety, RabiRibiModule parent) { |
||||
super(x, y, targetx, targety, parent); |
||||
} |
||||
|
||||
public void draw(Graphics g) { |
||||
super.draw(g); |
||||
Point2D.Double erina_pos = parent.overlay.getScreenPosition(parent.overlay.xpos, parent.overlay.ypos); |
||||
setTarget(new Point((int)erina_pos.getX(),(int)erina_pos.getY()-72)); |
||||
g.fillOval(x, y, 16, 16); |
||||
} |
||||
} |
@ -0,0 +1,13 @@ |
||||
package sig.utils; |
||||
|
||||
|
||||
public class DebugUtils { |
||||
public static void showStackTrace() { |
||||
StackTraceElement[] stacktrace = new Throwable().getStackTrace(); |
||||
StringBuilder stack = new StringBuilder("Mini stack tracer:"); |
||||
for (int i=0;i<Math.min(10, stacktrace.length);i++) { |
||||
stack.append("\n"+stacktrace[i].getClassName()+": **"+stacktrace[i].getFileName()+"** "+stacktrace[i].getMethodName()+"():"+stacktrace[i].getLineNumber()); |
||||
} |
||||
System.out.println("Trace:"+stack); |
||||
} |
||||
} |
@ -0,0 +1,50 @@ |
||||
package sig.utils; |
||||
|
||||
import java.lang.reflect.Field; |
||||
|
||||
public class JavaUtils { |
||||
public JavaUtils clone() { |
||||
JavaUtils newpos = new JavaUtils(); |
||||
for (Field f : this.getClass().getDeclaredFields()) { |
||||
if (ReflectUtils.isCloneable(f)) { |
||||
try { |
||||
f.set(newpos, f.get(this)); |
||||
} catch (IllegalArgumentException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
return newpos; |
||||
} |
||||
public String toString() { |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append(this.getClass().getName()+"("); |
||||
boolean first=false; |
||||
for (Field f : this.getClass().getDeclaredFields()) { |
||||
if (!ReflectUtils.isCloneable(f)) { |
||||
if (!first) { |
||||
try { |
||||
sb.append(f.getName()+"="+f.get(this)); |
||||
first=true; |
||||
} catch (IllegalArgumentException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} else { |
||||
try { |
||||
sb.append(","+f.getName()+"="+f.get(this)); |
||||
} catch (IllegalArgumentException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
sb.append(")"); |
||||
return sb.toString(); |
||||
} |
||||
} |
@ -0,0 +1,10 @@ |
||||
package sig.utils; |
||||
|
||||
import java.lang.reflect.Field; |
||||
|
||||
public class ReflectUtils { |
||||
public static boolean isCloneable(Field f) { |
||||
int mods = f.getModifiers(); |
||||
return mods<8; |
||||
} |
||||
} |
Loading…
Reference in new issue