removed javaFX

This commit is contained in:
Ethan
2019-12-17 00:12:46 -06:00
parent dee970aa2b
commit e38ac33066
17 changed files with 185 additions and 257 deletions
@@ -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;
+3 -4
View File
@@ -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;
}
}
-25
View File
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="353.0" prefWidth="605.0" xmlns="http://javafx.com/javafx/11.0.1"
fx:controller="org.rebotted.ui.script.ScriptController">
<children>
<TableView fx:id="scriptTable" prefHeight="325.0" prefWidth="605.0">
<columns>
<TableColumn fx:id="category" prefWidth="84.0" text="Category"/>
<TableColumn fx:id="scriptName" prefWidth="107.0" text="Script"/>
<TableColumn fx:id="version" prefWidth="62.0" text="Version"/>
<TableColumn fx:id="description" prefWidth="250.0" text="Description"/>
<TableColumn fx:id="author" prefWidth="100.0" text="Author"/>
</columns>
</TableView>
<Button fx:id="startButton" layoutX="528.0" layoutY="327.0" mnemonicParsing="false" onAction="#startScript"
prefHeight="25.0" prefWidth="73.0" text="Start"/>
<ComboBox layoutX="5.0" layoutY="327.0" prefHeight="25.0" prefWidth="251.0" promptText="Accounts..."/>
<TextField layoutX="263.0" layoutY="327.0" onAction="#searchScripts" prefHeight="25.0" prefWidth="259.0"
promptText="Search scripts..."/>
</children>
</AnchorPane>
-56
View File
@@ -1,56 +0,0 @@
/*
* This is an adjustment of the original modena.css for a consistent dark theme.
* Original modena.css here: https://gist.github.com/maxd/63691840fc372f22f470.
*/
/* Redefine base colors */
.root {
-fx-base: rgb(50, 50, 50);
-fx-background: rgb(50, 50, 50);
/* make controls (buttons, thumb, etc.) slightly lighter */
-fx-color: derive(-fx-base, 10%);
/* text fields and table rows background */
-fx-control-inner-background: rgb(20, 20, 20);
/* version of -fx-control-inner-background for alternative rows */
-fx-control-inner-background-alt: derive(-fx-control-inner-background, 2.5%);
/* text colors depending on background's brightness */
-fx-light-text-color: rgb(220, 220, 220);
-fx-mid-text-color: rgb(100, 100, 100);
-fx-dark-text-color: rgb(20, 20, 20);
/* A bright blue for highlighting/accenting objects. For example: selected
* text; selected items in menus, lists, trees, and tables; progress bars */
-fx-accent: rgb(0, 80, 100);
/* color of non-focused yet selected elements */
-fx-selection-bar-non-focused: rgb(50, 50, 50);
}
/* Fix derived prompt color for text fields */
.text-input {
-fx-prompt-text-fill: derive(-fx-control-inner-background, +50%);
}
/* Keep prompt invisible when focused (above color fix overrides it) */
.text-input:focused {
-fx-prompt-text-fill: transparent;
}
/* Fix scroll bar buttons arrows colors */
.scroll-bar > .increment-button > .increment-arrow,
.scroll-bar > .decrement-button > .decrement-arrow {
-fx-background-color: -fx-mark-highlight-color, rgb(220, 220, 220);
}
.scroll-bar > .increment-button:hover > .increment-arrow,
.scroll-bar > .decrement-button:hover > .decrement-arrow {
-fx-background-color: -fx-mark-highlight-color, rgb(240, 240, 240);
}
.scroll-bar > .increment-button:pressed > .increment-arrow,
.scroll-bar > .decrement-button:pressed > .decrement-arrow {
-fx-background-color: -fx-mark-highlight-color, rgb(255, 255, 255);
}