factored out finderwindow reference again
parent
187fa40413
commit
9062622933
|
@ -51,7 +51,7 @@ public class FinderWindow extends JFrame {
|
|||
//UI Manager:
|
||||
pane.setLayout(new BorderLayout());
|
||||
loadMinecraft();
|
||||
(new UpdateManager(this, true)).start();
|
||||
new UpdateManager(this, true).start();
|
||||
setJMenuBar(menuBar = new AmidstMenu(this));
|
||||
setVisible(true);
|
||||
Image icon = ResourceLoader.getImage("icon.png");
|
||||
|
|
|
@ -8,21 +8,16 @@ import java.io.IOException;
|
|||
public class Amidst {
|
||||
public final static int version_major = 3;
|
||||
public final static int version_minor = 0;
|
||||
private static FinderWindow mainWindow;
|
||||
|
||||
public static void main(String args[]) throws IOException {
|
||||
Util.setLookAndFeel();
|
||||
Google.startTracking();
|
||||
Google.track("Run");
|
||||
//TODO: load options
|
||||
mainWindow = new FinderWindow();
|
||||
new FinderWindow(); //as long as we design it well, we won’t need a reference to it ;)
|
||||
}
|
||||
|
||||
public static String version() {
|
||||
return version_major + "." + version_minor;
|
||||
}
|
||||
|
||||
public static FinderWindow getActiveWindow() {
|
||||
return mainWindow;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,28 +4,28 @@ public class Log {
|
|||
private static LogListener listener;
|
||||
private static boolean isUsingListener;
|
||||
|
||||
public static void i(Object s) {
|
||||
System.out.println("[info] " + s);
|
||||
public static void i(Object... s) {
|
||||
printwithTag("info", s);
|
||||
if (isUsingListener)
|
||||
listener.info(s);
|
||||
}
|
||||
public static void debug(Object s) {
|
||||
System.out.println("[debug] " + s);
|
||||
public static void debug(Object... s) {
|
||||
printwithTag("debug", s);
|
||||
if (isUsingListener)
|
||||
listener.debug(s);
|
||||
}
|
||||
public static void w(Object s) {
|
||||
System.err.println("[warning] " + s);
|
||||
public static void w(Object... s) {
|
||||
printwithTag("warning", s);
|
||||
if (isUsingListener)
|
||||
listener.warning(s);
|
||||
}
|
||||
public static void e(Object s) {
|
||||
System.err.println("[error] " + s);
|
||||
public static void e(Object... s) {
|
||||
printwithTag("error", s);
|
||||
if (isUsingListener)
|
||||
listener.error(s);
|
||||
}
|
||||
public static void kill(Object s) {
|
||||
System.err.println("[kill] " + s);
|
||||
public static void kill(Object... s) {
|
||||
printwithTag("kill", s);
|
||||
if (isUsingListener)
|
||||
listener.kill(s);
|
||||
System.exit(0);
|
||||
|
@ -35,4 +35,12 @@ public class Log {
|
|||
listener = l;
|
||||
isUsingListener = (l != null);
|
||||
}
|
||||
|
||||
private static void printwithTag(String tag, Object... msgs) {
|
||||
System.out.print("[" + tag + "] ");
|
||||
for (int i=0; i<msgs.length; i++) {
|
||||
System.out.print(msgs[i]);
|
||||
System.out.print((i < msgs.length) ? ", " : "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package amidst;
|
||||
|
||||
public interface LogListener {
|
||||
public void debug(Object o);
|
||||
public void info(Object o);
|
||||
public void warning(Object o);
|
||||
public void error(Object o);
|
||||
public void kill(Object o);
|
||||
public void debug(Object... o);
|
||||
public void info(Object... o);
|
||||
public void warning(Object... o);
|
||||
public void error(Object... o);
|
||||
public void kill(Object... o);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package amidst.map;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.util.Stack;
|
||||
|
||||
|
@ -28,7 +27,7 @@ public class Map {
|
|||
|
||||
private boolean isLoaded = false;
|
||||
|
||||
private Object resizeLock = new Object();
|
||||
private final Object resizeLock = new Object();
|
||||
private AffineTransform mat;
|
||||
private ChunkManager chunkManager;
|
||||
|
||||
|
@ -41,13 +40,11 @@ public class Map {
|
|||
|
||||
public void draw(Graphics2D g) {
|
||||
if (!isLoaded) return;
|
||||
// TODO : Change this to directly reference the window that renders it.
|
||||
int width = Amidst.getActiveWindow().getWidth();
|
||||
int height = Amidst.getActiveWindow().getHeight();
|
||||
Rectangle b = g.getClipBounds();
|
||||
|
||||
double size = ((double)Fragment.SIZE)*scale;
|
||||
int w = (width) / (int)size + 2;
|
||||
int h = (height) / (int)size + 2;
|
||||
int size = (int) (Fragment.SIZE * scale);
|
||||
int w = b.width / size + 2;
|
||||
int h = b.height / size + 2;
|
||||
|
||||
while (tileWidth < w) addColumn(END);
|
||||
while (tileWidth > w) removeColumn(END);
|
||||
|
@ -63,12 +60,12 @@ public class Map {
|
|||
//g.fillRect(5, 5, width - 10, height - 10);
|
||||
|
||||
Fragment frag = startNode;
|
||||
size = (double)Fragment.SIZE;
|
||||
size = Fragment.SIZE;
|
||||
if (frag.hasNext) {
|
||||
Fragment corner = frag.nextFragment;
|
||||
double drawX = startX;
|
||||
double drawY = startY;
|
||||
|
||||
|
||||
mat.setToIdentity();
|
||||
mat.translate(drawX, drawY);
|
||||
mat.scale(scale, scale);
|
||||
|
@ -187,7 +184,6 @@ public class Map {
|
|||
frag.setNext(newFrag);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void removeColumn(boolean start) {
|
||||
synchronized (resizeLock) {
|
||||
|
@ -234,11 +230,11 @@ public class Map {
|
|||
public void load() {
|
||||
fManager.load();
|
||||
fManager.start();
|
||||
|
||||
|
||||
addStart(0, 0);
|
||||
isLoaded = true;
|
||||
|
||||
}
|
||||
|
||||
public void setZoom(double scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
@ -247,13 +243,11 @@ public class Map {
|
|||
}
|
||||
public double getScaledX(double oldScale, double newScale, double x) {
|
||||
double baseX = x - startX;
|
||||
double dif = baseX - (baseX/oldScale) * newScale;
|
||||
return dif;
|
||||
return baseX - (baseX/oldScale) * newScale;
|
||||
}
|
||||
public double getScaledY(double oldScale, double newScale, double y) {
|
||||
double baseY = y - startY;
|
||||
double dif = baseY - (baseY/oldScale) * newScale;
|
||||
return dif;
|
||||
return baseY - (baseY/oldScale) * newScale;
|
||||
}
|
||||
public void close() {
|
||||
isLoaded = false;
|
||||
|
|
Loading…
Reference in New Issue