Merge branch 'master' of github.com:Parabot/Parabot
@@ -122,3 +122,4 @@ releases
|
|||||||
._*
|
._*
|
||||||
|
|
||||||
Test.java
|
Test.java
|
||||||
|
*.DS_Store
|
||||||
@@ -96,6 +96,17 @@
|
|||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<nonFilteredFileExtensions>
|
||||||
|
<nonFilteredFileExtension>ttf</nonFilteredFileExtension>
|
||||||
|
</nonFilteredFileExtensions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
|||||||
@@ -26,4 +26,7 @@ public class Configuration {
|
|||||||
public static final String BUGSNAG_API = "d79752cf94dd4beb24c3d312a8609f53";
|
public static final String BUGSNAG_API = "d79752cf94dd4beb24c3d312a8609f53";
|
||||||
|
|
||||||
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
|
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
|
||||||
|
|
||||||
|
public static final String BOT_TITLE = "Parabot";
|
||||||
|
public static final String BOT_SLOGAN = "The best RuneScape private server bot";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
|
|
||||||
setTitle("Parabot");
|
setTitle("Parabot");
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
createMenu();
|
createMenu();
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
|
|||||||
@@ -1,36 +1,32 @@
|
|||||||
package org.parabot.core.ui;
|
package org.parabot.core.ui;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import javax.swing.Box;
|
|
||||||
import javax.swing.BoxLayout;
|
|
||||||
import javax.swing.JEditorPane;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTree;
|
|
||||||
import javax.swing.event.TreeSelectionEvent;
|
|
||||||
import javax.swing.event.TreeSelectionListener;
|
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
|
||||||
import javax.swing.tree.TreePath;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.asm.ASMClassLoader;
|
import org.parabot.core.asm.ASMClassLoader;
|
||||||
import org.parabot.core.classpath.ClassPath;
|
import org.parabot.core.classpath.ClassPath;
|
||||||
import org.parabot.core.reflect.RefClass;
|
import org.parabot.core.reflect.RefClass;
|
||||||
import org.parabot.core.reflect.RefField;
|
import org.parabot.core.reflect.RefField;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.TreeSelectionEvent;
|
||||||
|
import javax.swing.event.TreeSelectionListener;
|
||||||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
|
import javax.swing.tree.TreeNode;
|
||||||
|
import javax.swing.tree.TreePath;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A Reflection explorer
|
* A Reflection explorer
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ReflectUI extends JFrame {
|
public class ReflectUI extends JFrame {
|
||||||
private static final long serialVersionUID = 98565034137367257L;
|
private static final long serialVersionUID = 98565034137367257L;
|
||||||
|
private JTree tree;
|
||||||
private DefaultMutableTreeNode root;
|
private DefaultMutableTreeNode root;
|
||||||
private DefaultTreeModel model;
|
private DefaultTreeModel model;
|
||||||
private JEditorPane basicInfoPane;
|
private JEditorPane basicInfoPane;
|
||||||
@@ -64,7 +60,75 @@ public class ReflectUI extends JFrame {
|
|||||||
JPanel infoContent = new JPanel();
|
JPanel infoContent = new JPanel();
|
||||||
infoContent.setLayout(new BoxLayout(infoContent, BoxLayout.Y_AXIS));
|
infoContent.setLayout(new BoxLayout(infoContent, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
JTree tree = new JTree();
|
JPanel searchContent = new JPanel();
|
||||||
|
searchContent.setLayout(new BoxLayout(searchContent, BoxLayout.X_AXIS));
|
||||||
|
|
||||||
|
final JTextField searchFunction = new JTextField(10);
|
||||||
|
searchFunction.setHorizontalAlignment(JTextField.CENTER);
|
||||||
|
searchFunction.setSize(30, 30);
|
||||||
|
searchFunction.setColumns(1);
|
||||||
|
searchFunction.setPreferredSize(new Dimension(30, 30));
|
||||||
|
|
||||||
|
final JButton searchButton = new JButton("Search");
|
||||||
|
searchFunction.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
searchButton.getActionListeners()[0].actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
searchButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
RefField result = null;
|
||||||
|
String search = searchFunction.getText();
|
||||||
|
for (RefField f : fields.values()) {
|
||||||
|
if (f != null && (f.asObject()) != null) {
|
||||||
|
String value;
|
||||||
|
if ((value = f.asObject().toString()).equalsIgnoreCase(search)) {
|
||||||
|
result = f;
|
||||||
|
} else if (value.toLowerCase().startsWith(search.toLowerCase())) {
|
||||||
|
result = f;
|
||||||
|
} else if (value.toLowerCase().endsWith(search.toLowerCase())) {
|
||||||
|
result = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result != null) {
|
||||||
|
setFieldInfo(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
final JButton adjustClasses = new JButton("Expand");
|
||||||
|
adjustClasses.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
Enumeration<?> topLevelNodes
|
||||||
|
= ((TreeNode) tree.getModel().getRoot()).children();
|
||||||
|
while (topLevelNodes.hasMoreElements()) {
|
||||||
|
DefaultMutableTreeNode node
|
||||||
|
= (DefaultMutableTreeNode) topLevelNodes.nextElement();
|
||||||
|
TreePath treePath = new TreePath(node.getPath());
|
||||||
|
if (adjustClasses.getText().equalsIgnoreCase("expand")) {
|
||||||
|
tree.expandPath(treePath);
|
||||||
|
} else {
|
||||||
|
tree.collapsePath(treePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
adjustClasses.setText(adjustClasses.getText().equalsIgnoreCase("expand") ? "Collapse" : "Expand");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
searchContent.add(adjustClasses);
|
||||||
|
searchContent.add(searchFunction);
|
||||||
|
searchContent.setMaximumSize(new Dimension(500, (int) searchContent.getPreferredSize().getHeight()));
|
||||||
|
searchContent.add(searchButton);
|
||||||
|
|
||||||
|
|
||||||
|
tree = new JTree();
|
||||||
tree.setRootVisible(true);
|
tree.setRootVisible(true);
|
||||||
tree.setShowsRootHandles(true);
|
tree.setShowsRootHandles(true);
|
||||||
tree.setModel(model);
|
tree.setModel(model);
|
||||||
@@ -76,12 +140,12 @@ public class ReflectUI extends JFrame {
|
|||||||
Object[] pathElements = path.getPath();
|
Object[] pathElements = path.getPath();
|
||||||
Object element = pathElements[pathElements.length - 1];
|
Object element = pathElements[pathElements.length - 1];
|
||||||
if (pathElements.length == 2) {
|
if (pathElements.length == 2) {
|
||||||
// class
|
|
||||||
setClassInfo(classes.get(element));
|
setClassInfo(classes.get(element));
|
||||||
}
|
} else if (pathElements.length == 3) {
|
||||||
if(pathElements.length == 3) {
|
RefField field = fields.get(element);
|
||||||
// field
|
setFieldInfo(field);
|
||||||
setFieldInfo(fields.get(element));
|
DefaultMutableTreeNode el = (DefaultMutableTreeNode) element;
|
||||||
|
el.setUserObject("Field: " + field.getName() + " [type: " + field.getASMType() + "] [value: " + field.asObject() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +175,7 @@ public class ReflectUI extends JFrame {
|
|||||||
exploreContent.add(infoContent);
|
exploreContent.add(infoContent);
|
||||||
|
|
||||||
content.add(exploreContent);
|
content.add(exploreContent);
|
||||||
|
content.add(searchContent);
|
||||||
|
|
||||||
JScrollPane contentPane = new JScrollPane(content);
|
JScrollPane contentPane = new JScrollPane(content);
|
||||||
Dimension prefSize = content.getPreferredSize();
|
Dimension prefSize = content.getPreferredSize();
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ public class ServerSelector extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ServerSelector() {
|
public ServerSelector() {
|
||||||
|
|
||||||
Queue<ServerComponent> widgets = getServers();
|
Queue<ServerComponent> widgets = getServers();
|
||||||
if (initServer != null) {
|
if (initServer != null) {
|
||||||
if (runServer(widgets)) {
|
if (runServer(widgets)) {
|
||||||
@@ -42,7 +41,7 @@ public class ServerSelector extends JPanel {
|
|||||||
|
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setPreferredSize(new Dimension(600, 400));
|
setPreferredSize(new Dimension(600, 350));
|
||||||
|
|
||||||
JPanel interior = new JPanel(null);
|
JPanel interior = new JPanel(null);
|
||||||
|
|
||||||
@@ -66,8 +65,7 @@ public class ServerSelector extends JPanel {
|
|||||||
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
scrlInterior
|
scrlInterior
|
||||||
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
|
add(scrlInterior);
|
||||||
add(scrlInterior, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.awt.event.MouseMotionListener;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import org.parabot.core.desc.ServerDescription;
|
import org.parabot.core.desc.ServerDescription;
|
||||||
|
import org.parabot.core.ui.fonts.Fonts;
|
||||||
import org.parabot.environment.Environment;
|
import org.parabot.environment.Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,13 +62,13 @@ public class ServerComponent extends JPanel implements MouseListener,
|
|||||||
g2d.setColor(bgColor);
|
g2d.setColor(bgColor);
|
||||||
g2d.fillRect(0, 0, w, h);
|
g2d.fillRect(0, 0, w, h);
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
Font title = new Font("Arial", Font.BOLD, 16);
|
Font title = Fonts.getResource("leelawadee.ttf", 16);
|
||||||
g.setFont(title);
|
g.setFont(title);
|
||||||
String serverName = desc.getServerName();
|
String serverName = desc.getServerName();
|
||||||
int sw = g.getFontMetrics().stringWidth(serverName);
|
int sw = g.getFontMetrics().stringWidth(serverName);
|
||||||
g.drawString(serverName, (w / 2) - (sw / 2), 30);
|
g.drawString(serverName, (w / 2) - (sw / 2), 30);
|
||||||
|
|
||||||
Font normal = new Font("Arial", Font.PLAIN, 12);
|
Font normal = Fonts.getResource("leelawadee.ttf");
|
||||||
g.setFont(normal);
|
g.setFont(normal);
|
||||||
FontMetrics fm = g.getFontMetrics();
|
FontMetrics fm = g.getFontMetrics();
|
||||||
String author = "Author: " + desc.getAuthor();
|
String author = "Author: " + desc.getAuthor();
|
||||||
|
|||||||
@@ -1,39 +1,42 @@
|
|||||||
package org.parabot.core.ui.components;
|
package org.parabot.core.ui.components;
|
||||||
|
|
||||||
|
import org.parabot.core.Configuration;
|
||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.forum.AccountManager;
|
import org.parabot.core.forum.AccountManager;
|
||||||
import org.parabot.core.forum.AccountManagerAccess;
|
import org.parabot.core.forum.AccountManagerAccess;
|
||||||
import org.parabot.core.io.ProgressListener;
|
import org.parabot.core.io.ProgressListener;
|
||||||
import org.parabot.core.ui.ServerSelector;
|
import org.parabot.core.ui.ServerSelector;
|
||||||
import org.parabot.core.ui.images.Images;
|
import org.parabot.core.ui.images.Images;
|
||||||
|
import org.parabot.core.ui.fonts.Fonts;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.geom.Line2D;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.image.RescaleOp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An informative JPanel which tells the user what bot is doing
|
* An informative JPanel which tells the user what bot is doing
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class VerboseLoader extends JPanel implements ProgressListener {
|
public class VerboseLoader extends JPanel implements ProgressListener {
|
||||||
private static final long serialVersionUID = 7412412644921803896L;
|
private static final long serialVersionUID = 7412412644921803896L;
|
||||||
private static VerboseLoader current;
|
private static VerboseLoader current;
|
||||||
private static String state = "Initializing loader...";
|
private static String state = "Initializing loader...";
|
||||||
|
|
||||||
public static final int STATE_AUTHENTICATION = 0;
|
private static final int STATE_AUTHENTICATION = 0;
|
||||||
public static final int STATE_LOADING = 1;
|
public static final int STATE_LOADING = 1;
|
||||||
public static final int STATE_SERVER_SELECT = 2;
|
private static final int STATE_SERVER_SELECT = 2;
|
||||||
private int currentState;
|
private int currentState;
|
||||||
|
|
||||||
private static AccountManager manager;
|
private static AccountManager manager;
|
||||||
|
|
||||||
private FontMetrics fontMetrics;
|
private FontMetrics fontMetrics;
|
||||||
private BufferedImage background;
|
private BufferedImage background, banner, loginBox;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
private JPanel loginPanel;
|
private JPanel loginPanel;
|
||||||
|
|
||||||
@@ -52,6 +55,8 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
}
|
}
|
||||||
current = this;
|
current = this;
|
||||||
this.background = Images.getResource("/storage/images/background.png");
|
this.background = Images.getResource("/storage/images/background.png");
|
||||||
|
this.banner = Images.getResource("/storage/images/logo.png");
|
||||||
|
this.loginBox = Images.getResource("/storage/images/login.png");
|
||||||
this.progressBar = new ProgressBar(400, 20);
|
this.progressBar = new ProgressBar(400, 20);
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
setSize(775, 510);
|
setSize(775, 510);
|
||||||
@@ -74,7 +79,18 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
|
|
||||||
public void addServerPanel() {
|
public void addServerPanel() {
|
||||||
JPanel servers = ServerSelector.getInstance();
|
JPanel servers = ServerSelector.getInstance();
|
||||||
add(servers, new GridBagConstraints());
|
GridBagLayout bagLayout = (GridBagLayout) getLayout();
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
|
||||||
|
c.weightx = 1;
|
||||||
|
c.weighty = 1;
|
||||||
|
c.gridx = 0;
|
||||||
|
c.gridy = 0;
|
||||||
|
c.anchor = GridBagConstraints.SOUTH;
|
||||||
|
c.insets = new Insets(0, 0, 25, 0);
|
||||||
|
|
||||||
|
bagLayout.setConstraints(servers, c);
|
||||||
|
add(servers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLoginPanel() {
|
public void addLoginPanel() {
|
||||||
@@ -83,15 +99,15 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
|
|
||||||
loginPanel.setLayout(new BoxLayout(loginPanel, BoxLayout.Y_AXIS));
|
loginPanel.setLayout(new BoxLayout(loginPanel, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
Font labelFont = new Font("Times New Roman", Font.PLAIN, 11);
|
Font labelFont = Fonts.getResource("leelawadee.ttf");
|
||||||
|
|
||||||
JLabel usernameLabel = new JLabel("Username");
|
JLabel usernameLabel = new JLabel("Username");
|
||||||
usernameLabel.setFont(labelFont);
|
usernameLabel.setFont(labelFont);
|
||||||
usernameLabel.setAlignmentX(Box.CENTER_ALIGNMENT);
|
usernameLabel.setAlignmentX(Box.CENTER_ALIGNMENT);
|
||||||
usernameLabel.setForeground(Color.white);
|
usernameLabel.setForeground(Color.white);
|
||||||
|
|
||||||
final JTextField userInput = new JTextField(25);
|
final JTextField userInput = new JTextField(20);
|
||||||
final JTextField passInput = new JPasswordField(25);
|
final JTextField passInput = new JPasswordField(20);
|
||||||
userInput.addActionListener(new ActionListener() {
|
userInput.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -181,30 +197,49 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||||
|
|
||||||
g.drawImage(background, 0, 0, null);
|
g.drawImage(background, 0, 0, null);
|
||||||
|
float[] scales = {1f, 1f, 1f, 0.9f};
|
||||||
|
float[] offsets = new float[4];
|
||||||
|
RescaleOp rop = new RescaleOp(scales, offsets, null);
|
||||||
|
g.drawImage(banner, rop, 0, 0);
|
||||||
|
|
||||||
|
g.setStroke(new BasicStroke(5));
|
||||||
|
g.setPaint(Color.WHITE);
|
||||||
|
|
||||||
|
g.draw(new Line2D.Float(0, 0, this.getWidth(), 0));
|
||||||
|
g.draw(new Line2D.Float(0, 0, 0, 120));
|
||||||
|
g.draw(new Line2D.Float(0, 120, this.getWidth(), 120));
|
||||||
|
g.draw(new Line2D.Float(this.getWidth() - 6, 0, this.getWidth() - 6, 120));
|
||||||
|
|
||||||
|
g.setColor(Color.white);
|
||||||
|
|
||||||
|
g.setFont(Fonts.getResource("leelawadee.ttf", 30));
|
||||||
|
g.getFont().deriveFont(Font.BOLD);
|
||||||
|
g.drawString(Configuration.BOT_TITLE, 20, 50);
|
||||||
|
|
||||||
|
g.setFont(Fonts.getResource("leelawadee.ttf", 15));
|
||||||
|
g.getFont().deriveFont(Font.ITALIC);
|
||||||
|
g.drawString(Configuration.BOT_SLOGAN, 20, 85);
|
||||||
|
|
||||||
if (fontMetrics == null) {
|
if (fontMetrics == null) {
|
||||||
fontMetrics = g.getFontMetrics();
|
fontMetrics = g.getFontMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentState == STATE_AUTHENTICATION) {
|
if (currentState == STATE_AUTHENTICATION) {
|
||||||
g.setColor(new Color(74, 74, 72, 100));
|
g.drawImage(loginBox, loginPanel.getX() - 30, loginPanel.getY() - 22, null);
|
||||||
g.fillRect(loginPanel.getX() - 10, loginPanel.getY(), loginPanel.getWidth() + 20, loginPanel.getHeight());
|
|
||||||
g.setColor(Color.black);
|
|
||||||
g.drawRect(loginPanel.getX() - 10, loginPanel.getY(), loginPanel.getWidth() + 20, loginPanel.getHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
|
|
||||||
if (currentState == STATE_LOADING) {
|
if (currentState == STATE_LOADING) {
|
||||||
progressBar.draw(g, (getWidth() / 2) - 200, 220);
|
progressBar.draw(g, (getWidth() / 2) - 200, 220);
|
||||||
g.setFont(new Font("Times New Roman", Font.PLAIN, 14));
|
g.setFont(Fonts.getResource("leelawadee.ttf"));
|
||||||
int x = (getWidth() / 2) - (fontMetrics.stringWidth(state) / 2);
|
int x = (getWidth() / 2) - (fontMetrics.stringWidth(state) / 2);
|
||||||
g.drawString(state, x, 200);
|
g.drawString(state, x, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
g.setFont(new Font("Times New Roman", Font.PLAIN, 12));
|
g.setFont(Fonts.getResource("leelawadee.ttf"));
|
||||||
final String version = "v2.1";
|
final String version = Configuration.BOT_VERSION.get();
|
||||||
g.drawString(version,
|
g.drawString(version,
|
||||||
getWidth() - g.getFontMetrics().stringWidth(version) - 10,
|
getWidth() - g.getFontMetrics().stringWidth(version) - 10,
|
||||||
getHeight() - 12);
|
getHeight() - 12);
|
||||||
@@ -212,6 +247,7 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets instance of this panel
|
* Gets instance of this panel
|
||||||
|
*
|
||||||
* @return instance of this panel
|
* @return instance of this panel
|
||||||
*/
|
*/
|
||||||
public static VerboseLoader get(String username, String password) {
|
public static VerboseLoader get(String username, String password) {
|
||||||
@@ -220,6 +256,7 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets instance of this panel
|
* Gets instance of this panel
|
||||||
|
*
|
||||||
* @return instance of this panel
|
* @return instance of this panel
|
||||||
*/
|
*/
|
||||||
public static VerboseLoader get() {
|
public static VerboseLoader get() {
|
||||||
@@ -229,6 +266,7 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the status message and repaints the panel
|
* Updates the status message and repaints the panel
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public static void setState(final String message) {
|
public static void setState(final String message) {
|
||||||
@@ -246,5 +284,4 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
public void updateDownloadSpeed(double mbPerSecond) {
|
public void updateDownloadSpeed(double mbPerSecond) {
|
||||||
progressBar.setText(String.format("(%.2fMB/s)", mbPerSecond));
|
progressBar.setText(String.format("(%.2fMB/s)", mbPerSecond));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package org.parabot.core.ui.fonts;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Capslock
|
||||||
|
*/
|
||||||
|
public class Fonts {
|
||||||
|
private static final java.util.List<ParabotFont> FONT_CACHE = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the getResource with the default size of 12
|
||||||
|
*
|
||||||
|
* @param resource
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Font getResource(final String resource) {
|
||||||
|
return getResource(resource, 12f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Font getResource(final String fileName, float size) {
|
||||||
|
ParabotFont parabotFont = null;
|
||||||
|
|
||||||
|
for (ParabotFont font : FONT_CACHE) {
|
||||||
|
if (font.getLocation().equalsIgnoreCase(fileName) && font.getSize() == size) {
|
||||||
|
parabotFont = font;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parabotFont == null) {
|
||||||
|
parabotFont = new ParabotFont(fileName, size);
|
||||||
|
FONT_CACHE.add(parabotFont);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parabotFont.getFont();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package org.parabot.core.ui.fonts;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Capslock
|
||||||
|
*/
|
||||||
|
public class ParabotFont {
|
||||||
|
|
||||||
|
private String location;
|
||||||
|
private Font font;
|
||||||
|
|
||||||
|
public ParabotFont(String location, float size) {
|
||||||
|
if (!location.toLowerCase().startsWith("/storage/fonts/")) {
|
||||||
|
location = "/storage/fonts/" + location;
|
||||||
|
}
|
||||||
|
this.location = location;
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.font = createFont(size);
|
||||||
|
} catch (FontFormatException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Font createFont(float size) throws IOException, FontFormatException {
|
||||||
|
return Font.createFont(Font.TRUETYPE_FONT, Fonts.class.getResourceAsStream(this.location)).deriveFont(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getSize() {
|
||||||
|
return font.getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Font getFont() {
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj != null) {
|
||||||
|
if (obj instanceof ParabotFont) {
|
||||||
|
ParabotFont otherFont = (ParabotFont) obj;
|
||||||
|
if (otherFont.getSize() == this.getSize()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 152 B After Width: | Height: | Size: 152 B |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 299 B After Width: | Height: | Size: 299 B |
|
Before Width: | Height: | Size: 332 B After Width: | Height: | Size: 332 B |
|
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 331 B |
|
Before Width: | Height: | Size: 325 B After Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 489 B |
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 357 B |
|
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
|
Before Width: | Height: | Size: 307 B After Width: | Height: | Size: 307 B |
|
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 311 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 611 B After Width: | Height: | Size: 611 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 343 B After Width: | Height: | Size: 343 B |
|
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 893 B |
|
Before Width: | Height: | Size: 328 B After Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 431 B |
|
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
|
Before Width: | Height: | Size: 452 B After Width: | Height: | Size: 452 B |
|
Before Width: | Height: | Size: 668 B After Width: | Height: | Size: 668 B |
|
Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 354 B |
|
Before Width: | Height: | Size: 276 B After Width: | Height: | Size: 276 B |
|
Before Width: | Height: | Size: 310 B After Width: | Height: | Size: 310 B |
|
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 377 B |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 125 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 155 B |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |