mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 08:39:12 +00:00
Enable resize
This commit is contained in:
@@ -16,6 +16,7 @@ import org.parabot.environment.scripts.Script;
|
|||||||
import org.parabot.environment.servers.ServerProvider;
|
import org.parabot.environment.servers.ServerProvider;
|
||||||
|
|
||||||
import java.applet.Applet;
|
import java.applet.Applet;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
@@ -161,28 +162,37 @@ public class Context {
|
|||||||
setClientInstance(gameApplet);
|
setClientInstance(gameApplet);
|
||||||
}
|
}
|
||||||
Core.verbose("Applet fetched.");
|
Core.verbose("Applet fetched.");
|
||||||
serverProvider.addMenuItems(BotUI.getInstance().getJMenuBar());
|
|
||||||
BotUI.getInstance().validate();
|
|
||||||
final GamePanel panel = GamePanel.getInstance();
|
final GamePanel panel = GamePanel.getInstance();
|
||||||
|
final Dimension appletSize = serverProvider.getGameDimensions();
|
||||||
|
|
||||||
|
panel.setPreferredSize(appletSize);
|
||||||
|
serverProvider.addMenuItems(BotUI.getInstance().getJMenuBar());
|
||||||
|
BotUI.getInstance().pack();
|
||||||
|
BotUI.getInstance().validate();
|
||||||
|
|
||||||
panel.removeLoader();
|
panel.removeLoader();
|
||||||
gameApplet.setSize(765, 503);
|
gameApplet.setSize(appletSize);
|
||||||
panel.add(gameApplet);
|
panel.add(gameApplet);
|
||||||
panel.validate();
|
panel.validate();
|
||||||
|
|
||||||
gameApplet.init();
|
gameApplet.init();
|
||||||
gameApplet.start();
|
gameApplet.start();
|
||||||
java.util.Timer t = new java.util.Timer();
|
java.util.Timer t = new java.util.Timer();
|
||||||
t.schedule(new TimerTask() {
|
t.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
gameApplet.setBounds(0, 0, 765, 503);
|
gameApplet.setBounds(0, 0, appletSize.width, appletSize.height);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
Core.verbose("Initializing mouse...");
|
Core.verbose("Initializing mouse...");
|
||||||
serverProvider.initMouse();
|
serverProvider.initMouse();
|
||||||
Core.verbose("Done.");
|
Core.verbose("Done.");
|
||||||
Core.verbose("Initializing keyboard...");
|
Core.verbose("Initializing keyboard...");
|
||||||
serverProvider.initKeyboard();
|
serverProvider.initKeyboard();
|
||||||
Core.verbose("Done.");
|
Core.verbose("Done.");
|
||||||
|
|
||||||
BotDialog.getInstance().validate();
|
BotDialog.getInstance().validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,19 @@ public class BotDialog extends JDialog {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setDimensions(Dimension dimension) {
|
||||||
|
setUndecorated(true);
|
||||||
|
getRootPane().setOpaque(false);
|
||||||
|
setBackground(new Color(0, 0, 0, 0));
|
||||||
|
setFocusableWindowState(true);
|
||||||
|
setPreferredSize(dimension);
|
||||||
|
setSize(dimension);
|
||||||
|
setVisible(true);
|
||||||
|
setContentPane(PaintComponent.getInstance());
|
||||||
|
PaintComponent.getInstance().setDimensions(dimension);
|
||||||
|
}
|
||||||
|
|
||||||
public static BotDialog getInstance(BotUI botUI) {
|
public static BotDialog getInstance(BotUI botUI) {
|
||||||
return instance == null ? instance = new BotDialog(botUI) : instance;
|
return instance == null ? instance = new BotDialog(botUI) : instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentMoved(ComponentEvent e) {
|
public void componentMoved(ComponentEvent e) {
|
||||||
if(dialog == null) {
|
if(dialog == null || !isVisible()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Point gameLocation = GamePanel.getInstance().getLocationOnScreen();
|
Point gameLocation = GamePanel.getInstance().getLocationOnScreen();
|
||||||
@@ -168,6 +168,9 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentResized(ComponentEvent e) {
|
public void componentResized(ComponentEvent e) {
|
||||||
|
if(isVisible()) {
|
||||||
|
BotDialog.getInstance().setSize(getSize());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -39,6 +39,18 @@ public class PaintComponent extends JComponent implements Runnable {
|
|||||||
setIgnoreRepaint(true);
|
setIgnoreRepaint(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDimensions(Dimension dimensions) {
|
||||||
|
this.dimensions = dimensions;
|
||||||
|
this.dimensions = dimensions;
|
||||||
|
this.buffer = new BufferedImage(dimensions.width, dimensions.height, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
this.g2 = buffer.createGraphics();
|
||||||
|
|
||||||
|
setPreferredSize(dimensions);
|
||||||
|
setSize(dimensions);
|
||||||
|
setOpaque(false);
|
||||||
|
setIgnoreRepaint(true);
|
||||||
|
}
|
||||||
|
|
||||||
public static PaintComponent getInstance(Dimension dimensions) {
|
public static PaintComponent getInstance(Dimension dimensions) {
|
||||||
return instance == null ? instance = new PaintComponent(dimensions) : instance;
|
return instance == null ? instance = new PaintComponent(dimensions) : instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import javax.swing.*;
|
|||||||
|
|
||||||
import java.applet.Applet;
|
import java.applet.Applet;
|
||||||
import java.applet.AppletStub;
|
import java.applet.AppletStub;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,10 +24,13 @@ import java.net.URL;
|
|||||||
*/
|
*/
|
||||||
public abstract class ServerProvider implements Opcodes {
|
public abstract class ServerProvider implements Opcodes {
|
||||||
|
|
||||||
// public static Handler.RandomChecker getRandomChecker() {
|
/**
|
||||||
// Handler.RandomChecker randomChecker = new Handler.RandomChecker();
|
* Get the game/applet dimensions
|
||||||
// return randomChecker;
|
* @return game/applet dimensions
|
||||||
// }
|
*/
|
||||||
|
public Dimension getGameDimensions() {
|
||||||
|
return new Dimension(765, 503);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hooks to parse
|
* Hooks to parse
|
||||||
|
|||||||
Reference in New Issue
Block a user