mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 00:37:55 +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 java.applet.Applet;
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.TimerTask;
|
||||
@@ -161,28 +162,37 @@ public class Context {
|
||||
setClientInstance(gameApplet);
|
||||
}
|
||||
Core.verbose("Applet fetched.");
|
||||
serverProvider.addMenuItems(BotUI.getInstance().getJMenuBar());
|
||||
BotUI.getInstance().validate();
|
||||
|
||||
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();
|
||||
gameApplet.setSize(765, 503);
|
||||
gameApplet.setSize(appletSize);
|
||||
panel.add(gameApplet);
|
||||
panel.validate();
|
||||
|
||||
gameApplet.init();
|
||||
gameApplet.start();
|
||||
java.util.Timer t = new java.util.Timer();
|
||||
t.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
gameApplet.setBounds(0, 0, 765, 503);
|
||||
gameApplet.setBounds(0, 0, appletSize.width, appletSize.height);
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
Core.verbose("Initializing mouse...");
|
||||
serverProvider.initMouse();
|
||||
Core.verbose("Done.");
|
||||
Core.verbose("Initializing keyboard...");
|
||||
serverProvider.initKeyboard();
|
||||
Core.verbose("Done.");
|
||||
|
||||
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) {
|
||||
return instance == null ? instance = new BotDialog(botUI) : instance;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
if(dialog == null) {
|
||||
if(dialog == null || !isVisible()) {
|
||||
return;
|
||||
}
|
||||
Point gameLocation = GamePanel.getInstance().getLocationOnScreen();
|
||||
@@ -168,6 +168,9 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
if(isVisible()) {
|
||||
BotDialog.getInstance().setSize(getSize());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,6 +39,18 @@ public class PaintComponent extends JComponent implements Runnable {
|
||||
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) {
|
||||
return instance == null ? instance = new PaintComponent(dimensions) : instance;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import javax.swing.*;
|
||||
|
||||
import java.applet.Applet;
|
||||
import java.applet.AppletStub;
|
||||
import java.awt.Dimension;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
@@ -23,10 +24,13 @@ import java.net.URL;
|
||||
*/
|
||||
public abstract class ServerProvider implements Opcodes {
|
||||
|
||||
// public static Handler.RandomChecker getRandomChecker() {
|
||||
// Handler.RandomChecker randomChecker = new Handler.RandomChecker();
|
||||
// return randomChecker;
|
||||
// }
|
||||
/**
|
||||
* Get the game/applet dimensions
|
||||
* @return game/applet dimensions
|
||||
*/
|
||||
public Dimension getGameDimensions() {
|
||||
return new Dimension(765, 503);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks to parse
|
||||
|
||||
Reference in New Issue
Block a user