mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-07 00:38:21 +00:00
Moved randoms from provider to client
This commit is contained in:
@@ -2,21 +2,17 @@ package org.rev317.min.ui;
|
|||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.paint.PaintDebugger;
|
import org.parabot.core.paint.PaintDebugger;
|
||||||
import org.parabot.environment.scripts.randoms.Random;
|
|
||||||
import org.rev317.min.debug.*;
|
import org.rev317.min.debug.*;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JKetelaar, Everel
|
* @author JKetelaar, Everel
|
||||||
*/
|
*/
|
||||||
public class BotMenu implements ActionListener {
|
public class BotMenu implements ActionListener {
|
||||||
|
|
||||||
private RandomUI randomUI;
|
|
||||||
|
|
||||||
public BotMenu(JMenuBar bar) {
|
public BotMenu(JMenuBar bar) {
|
||||||
PaintDebugger debugger = Context.getInstance().getPaintDebugger();
|
PaintDebugger debugger = Context.getInstance().getPaintDebugger();
|
||||||
|
|
||||||
@@ -58,23 +54,6 @@ public class BotMenu implements ActionListener {
|
|||||||
debug.add(bank);
|
debug.add(bank);
|
||||||
debug.add(mouse);
|
debug.add(mouse);
|
||||||
|
|
||||||
JMenuItem randoms = new JMenuItem("Randoms");
|
|
||||||
bar.getMenu(0).add(randoms, 0);
|
|
||||||
|
|
||||||
randoms.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (randomUI == null){
|
|
||||||
randomUI = new RandomUI();
|
|
||||||
}
|
|
||||||
ArrayList<String> randoms = new ArrayList<>();
|
|
||||||
for (Random r : Context.getInstance().getRandomHandler().getRandoms()){
|
|
||||||
randoms.add(r.getName());
|
|
||||||
}
|
|
||||||
randomUI.openFrame(randoms);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
bar.add(debug);
|
bar.add(debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
package org.rev317.min.ui;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
|
||||||
import org.parabot.core.Core;
|
|
||||||
import org.parabot.environment.scripts.randoms.Random;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author JKetelaar
|
|
||||||
*/
|
|
||||||
public class RandomUI implements ActionListener {
|
|
||||||
|
|
||||||
private JFrame frame;
|
|
||||||
private ArrayList<JCheckBox> checkBoxes;
|
|
||||||
|
|
||||||
public void openFrame(ArrayList<String> randoms) {
|
|
||||||
frame = new JFrame();
|
|
||||||
frame.setBounds(100, 100, 351, 100 + (randoms.size() * 35));
|
|
||||||
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
|
||||||
frame.getContentPane().setLayout(null);
|
|
||||||
|
|
||||||
JButton btnSubmit = new JButton("Submit");
|
|
||||||
btnSubmit.setBounds(228, 35 + (randoms.size() * 35), 117, 29);
|
|
||||||
frame.getContentPane().add(btnSubmit);
|
|
||||||
|
|
||||||
JLabel lblRandoms = new JLabel("Randoms:");
|
|
||||||
lblRandoms.setBounds(6, 6, 250, 16);
|
|
||||||
frame.getContentPane().add(lblRandoms);
|
|
||||||
|
|
||||||
if (randoms.size() > 0) {
|
|
||||||
checkBoxes = new ArrayList<>();
|
|
||||||
for (int i = 0; i < randoms.size(); i++) {
|
|
||||||
JCheckBox checkBox = new JCheckBox(randoms.get(i));
|
|
||||||
checkBox.setBounds(6, 35 + (i * 35), 250, 23);
|
|
||||||
frame.getContentPane().add(checkBox);
|
|
||||||
if (isActive(randoms.get(i))) {
|
|
||||||
checkBox.setSelected(true);
|
|
||||||
}
|
|
||||||
checkBoxes.add(checkBox);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
JLabel lblNone = new JLabel("None (yet).");
|
|
||||||
lblNone.setBounds(6, 35, 120, 16);
|
|
||||||
frame.getContentPane().add(lblNone);
|
|
||||||
}
|
|
||||||
|
|
||||||
btnSubmit.addActionListener(this);
|
|
||||||
this.frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
|
||||||
this.frame.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Context.getInstance().getRandomHandler().clearActiveRandoms();
|
|
||||||
if (checkBoxes != null && checkBoxes.size() > 0) {
|
|
||||||
for (JCheckBox checkBox : this.checkBoxes) {
|
|
||||||
if (checkBox.isSelected()) {
|
|
||||||
for (Random r : Context.getInstance().getRandomHandler().getRandoms()) {
|
|
||||||
if (r.getName().equalsIgnoreCase(checkBox.getText().toLowerCase())) {
|
|
||||||
Core.verbose("Actived random '" + r.getName() + "'");
|
|
||||||
Context.getInstance().getRandomHandler().setActive(r.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.frame.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isActive(String random){
|
|
||||||
for (Random r : Context.getInstance().getRandomHandler().getActiveRandoms()){
|
|
||||||
if (r.getName().equalsIgnoreCase(random.toLowerCase())){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user