mirror of
https://github.com/2006-Scape/2006RebottedClient.git
synced 2026-07-03 00:31:48 +00:00
removed javaFX
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package org.rebotted.archive;
|
||||
|
||||
|
||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||
import jdk.internal.org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.rebotted.archive;
|
||||
|
||||
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||
import jdk.internal.org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.rebotted.directory.DirectoryManager;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.rebotted.bot.loader;
|
||||
|
||||
import jdk.internal.org.objectweb.asm.tree.AnnotationNode;
|
||||
import jdk.internal.org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.AnnotationNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.rebotted.Client;
|
||||
import org.rebotted.archive.ASMClassLoader;
|
||||
import org.rebotted.archive.ClassArchive;
|
||||
|
||||
@@ -4,8 +4,9 @@ import org.rebotted.Client;
|
||||
import org.rebotted.Configuration;
|
||||
import org.rebotted.GameApplet;
|
||||
import org.rebotted.script.ScriptHandler;
|
||||
import org.rebotted.script.loader.ScriptLoader;
|
||||
import org.rebotted.ui.menu.BotMenuBar;
|
||||
import org.rebotted.ui.script.ScriptUI;
|
||||
import org.rebotted.ui.script.ScriptSelector;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -18,7 +19,6 @@ public final class BotFrame extends JFrame implements ActionListener {
|
||||
|
||||
private static BotMenuBar botMenuBar;
|
||||
private final Client client;
|
||||
private final ScriptUI scriptUI;
|
||||
|
||||
public BotFrame(Client client, boolean resizable) {
|
||||
this.client = client;
|
||||
@@ -38,7 +38,6 @@ public final class BotFrame extends JFrame implements ActionListener {
|
||||
requestFocus();
|
||||
toFront();
|
||||
applet.initClientFrame(766, 536);
|
||||
scriptUI = new ScriptUI(client.getApiData());
|
||||
System.out.println("Client Launched.");
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ public final class BotFrame extends JFrame implements ActionListener {
|
||||
switch (e.getActionCommand().toLowerCase()) {
|
||||
case "run":
|
||||
if (ScriptHandler.getInstance().getScriptState() == ScriptHandler.State.STOPPED) {
|
||||
scriptUI.show();
|
||||
new ScriptSelector(new ScriptLoader(client.getApiData()));
|
||||
} else if (ScriptHandler.getInstance().getScriptState() == ScriptHandler.State.PAUSE) {
|
||||
ScriptHandler.getInstance().setScriptState(ScriptHandler.State.RUNNING);
|
||||
setRunning();
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
package org.rebotted.ui.script;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import org.rebotted.script.ScriptHandler;
|
||||
import org.rebotted.script.scriptdata.ScriptData;
|
||||
import org.rebotted.script.scriptdata.SkillCategory;
|
||||
import org.rebotted.script.types.Script;
|
||||
import org.rebotted.ui.BotFrame;
|
||||
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ScriptController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private Button startButton;
|
||||
|
||||
@FXML
|
||||
private TableView<ScriptData> scriptTable;
|
||||
|
||||
@FXML
|
||||
private TableColumn<ScriptData, SkillCategory> category;
|
||||
|
||||
@FXML
|
||||
private TableColumn<ScriptData, String> scriptName;
|
||||
|
||||
@FXML
|
||||
private TableColumn<ScriptData, String> author;
|
||||
|
||||
@FXML
|
||||
private TableColumn<ScriptData, String> description;
|
||||
|
||||
@FXML
|
||||
private TableColumn<ScriptData, Double> version;
|
||||
|
||||
public void startScript() {
|
||||
if (ScriptHandler.getInstance().getScriptState() == ScriptHandler.State.PAUSE) {
|
||||
ScriptHandler.getInstance().pause();
|
||||
} else if (ScriptHandler.getInstance().getScriptState() == ScriptHandler.State.STOPPED) {
|
||||
final ScriptData scriptData = scriptTable.getSelectionModel().getSelectedItem();
|
||||
if(scriptData == null) {
|
||||
System.err.println("Please select a script before pressing start!");
|
||||
return;
|
||||
}
|
||||
startScript(scriptData);
|
||||
ScriptUI.hide();
|
||||
BotFrame.setRunning();
|
||||
} else if (ScriptHandler.getInstance().getScriptState() == ScriptHandler.State.RUNNING) {
|
||||
System.out.println("You already have a script running!");
|
||||
}
|
||||
}
|
||||
|
||||
public void searchScripts() {
|
||||
|
||||
}
|
||||
|
||||
public TableView<ScriptData> getScriptTable() {
|
||||
return scriptTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
category.setCellValueFactory(new PropertyValueFactory<>("skillCategory"));
|
||||
|
||||
scriptName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
||||
|
||||
author.setCellValueFactory(new PropertyValueFactory<>("author"));
|
||||
|
||||
description.setCellValueFactory(new PropertyValueFactory<>("desc"));
|
||||
|
||||
version.setCellValueFactory(new PropertyValueFactory<>("version"));
|
||||
|
||||
}
|
||||
|
||||
private void startScript(ScriptData scriptData) {
|
||||
Script script = null;
|
||||
try {
|
||||
script = (Script) scriptData.getMainClass().newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ScriptHandler.getInstance().start(script, scriptData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.rebotted.ui.script;
|
||||
|
||||
import org.rebotted.script.scriptdata.ScriptData;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import java.awt.*;
|
||||
|
||||
public class ScriptPanel extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = -5181188196122580695L;
|
||||
private JButton button;
|
||||
|
||||
public ScriptPanel(final ScriptData scriptData) {
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
setToolTipText(scriptData.getDesc());
|
||||
|
||||
button = new JButton("Start");
|
||||
|
||||
add(button, BorderLayout.SOUTH);
|
||||
|
||||
final JLabel scriptName = new JLabel(scriptData.getName());
|
||||
|
||||
scriptName.setHorizontalAlignment(JLabel.CENTER);
|
||||
|
||||
add(scriptName, BorderLayout.NORTH);
|
||||
|
||||
setBorder(new EtchedBorder());
|
||||
}
|
||||
|
||||
public JButton getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package org.rebotted.ui.script;
|
||||
|
||||
import org.rebotted.script.ScriptHandler;
|
||||
import org.rebotted.script.loader.ScriptLoader;
|
||||
import org.rebotted.script.scriptdata.ScriptData;
|
||||
import org.rebotted.script.types.Script;
|
||||
import org.rebotted.ui.BotFrame;
|
||||
import org.rebotted.ui.menu.BotMenuBar;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class ScriptSelector extends JFrame {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final ScriptLoader scriptLoader;
|
||||
private JTextField searchField;
|
||||
private JComboBox<String> accounts;
|
||||
private JPanel topPanel;
|
||||
private JPanel scriptPanel;
|
||||
private JScrollPane scrollPane;
|
||||
|
||||
public ScriptSelector(ScriptLoader scriptLoader) {
|
||||
super("Script Selector");
|
||||
this.scriptLoader = scriptLoader;
|
||||
setResizable(false);
|
||||
searchField = new JTextField(20);
|
||||
searchField.setForeground(Color.LIGHT_GRAY);
|
||||
searchField.setText("Search");
|
||||
searchField.setMaximumSize(new Dimension(100, 30));
|
||||
searchField.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
super.focusGained(e);
|
||||
searchField.setForeground(Color.BLACK);
|
||||
searchField.setText("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
super.focusLost(e);
|
||||
searchField.setForeground(Color.LIGHT_GRAY);
|
||||
searchField.setText("Search");
|
||||
}
|
||||
});
|
||||
searchField.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
super.keyTyped(e);
|
||||
}
|
||||
});
|
||||
|
||||
accounts = new JComboBox<>();
|
||||
|
||||
|
||||
topPanel = new JPanel();
|
||||
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS));
|
||||
topPanel.add(accounts);
|
||||
topPanel.add(Box.createHorizontalGlue());
|
||||
topPanel.add(searchField);
|
||||
|
||||
scriptPanel = new JPanel();
|
||||
scriptPanel.setLayout(null);
|
||||
|
||||
scrollPane = new JScrollPane(scriptPanel);
|
||||
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
getContentPane().add(topPanel, BorderLayout.NORTH);
|
||||
getContentPane().add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setSize(535, 405);
|
||||
loadScripts();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
private void loadScripts() {
|
||||
scriptPanel.removeAll();
|
||||
java.util.List<ScriptData> scripts = scriptLoader.getScripts();
|
||||
|
||||
final int width = 170;
|
||||
final int height = 115;
|
||||
final int spacing = 3;
|
||||
final int scriptPerRow = 3;
|
||||
int realIndex = 0;
|
||||
for (int scriptIndex = 0; scriptIndex < scripts.size(); scriptIndex++) {
|
||||
final ScriptData scriptData = scripts.get(scriptIndex);
|
||||
final ScriptPanel panel = new ScriptPanel(scriptData);
|
||||
int col = realIndex / scriptPerRow;
|
||||
int row = realIndex - (col * scriptPerRow);
|
||||
int x = row * width + spacing;
|
||||
int y = col * height + spacing;
|
||||
panel.setBounds(x, y, width, height);
|
||||
panel.getButton().addActionListener(e -> {
|
||||
startScript(scriptData);
|
||||
dispose();
|
||||
});
|
||||
scriptPanel.add(panel);
|
||||
realIndex++;
|
||||
}
|
||||
searchField.setText("");
|
||||
scriptPanel.setPreferredSize(new Dimension(535, (int) (Math.ceil((Double.valueOf(scriptPanel.getComponentCount()) / 3.0)) * height)));
|
||||
|
||||
}
|
||||
|
||||
private void startScript(ScriptData scriptData) {
|
||||
Script script = null;
|
||||
try {
|
||||
script = (Script) scriptData.getMainClass().newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ScriptHandler.getInstance().start(script, scriptData);
|
||||
BotFrame.setRunning();
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package org.rebotted.ui.script;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.embed.swing.JFXPanel;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import org.rebotted.bot.data.APIData;
|
||||
import org.rebotted.script.loader.ScriptLoader;
|
||||
import org.rebotted.script.scriptdata.ScriptData;
|
||||
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
||||
public class ScriptUI {
|
||||
private static ScriptController controller;
|
||||
private static JFrame frame;
|
||||
private JFXPanel jfxPanel = new JFXPanel();
|
||||
private ScriptLoader scriptLoader;
|
||||
|
||||
public ScriptUI(final APIData apiData) {
|
||||
scriptLoader = new ScriptLoader(apiData);
|
||||
loadUI();
|
||||
}
|
||||
|
||||
public static ScriptController getController() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
public void loadUI() {
|
||||
Platform.runLater(() -> {
|
||||
try {
|
||||
frame = new JFrame("2006Rebotted - Script Selector");
|
||||
jfxPanel = new JFXPanel();
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/ScriptUI.fxml"));
|
||||
final Parent root = fxmlLoader.load();
|
||||
final Scene scene = new Scene(root, 597, 353);
|
||||
scene.getStylesheets().add(getClass().getResource("/dark.css").toExternalForm());
|
||||
jfxPanel.setScene(scene);
|
||||
controller = fxmlLoader.getController();
|
||||
controller.getScriptTable().setItems(loadLocalScripts());
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
frame.add(jfxPanel);
|
||||
frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setResizable(false);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void show() {
|
||||
controller.getScriptTable().setItems(loadLocalScripts());
|
||||
frame.setVisible(true);
|
||||
System.out.println("Script Selector Loaded.");
|
||||
}
|
||||
|
||||
public static void hide() {
|
||||
frame.setVisible(false);
|
||||
}
|
||||
|
||||
private ObservableList<ScriptData> loadLocalScripts() {
|
||||
final ObservableList<ScriptData> scripts = FXCollections.observableArrayList();
|
||||
for (ScriptData scriptData : scriptLoader.getScripts()) {
|
||||
scripts.add(scriptData);
|
||||
}
|
||||
return scripts;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user