Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.04 KB | None | 0 0
  1. import org.rsbot.script.Script;
  2. import org.rsbot.script.ScriptManifest;
  3. import org.rsbot.script.util.Filter;
  4. ***********GUI************
  5. **************************/
  6.  
  7.  
  8. @SuppressWarnings("serial")
  9. private class LJGUI extends JFrame implements ActionListener, ItemListener {
  10. private JLabel treeLabel = new JLabel("Tree Type:");
  11. private JComboBox treeBox = new JComboBox(getTrees());
  12. private JLabel locationLabel = new JLabel("Location:");
  13. private JComboBox locationBox = new JComboBox(getloc());
  14. private JLabel mouseSpeedLabel = new JLabel("Mouse Speed:");
  15. private SpinnerModel model1 = new SpinnerNumberModel(7,1,15,1);
  16. private JSpinner mouseSpeedSpinner = new JSpinner(model1);
  17. private JCheckBox powerChopB = new JCheckBox("Power Chop");
  18. private JCheckBox skillerB = new JCheckBox("Skiller");
  19. private JCheckBox mouseKeysB = new JCheckBox("Mouse Keys");
  20. private JCheckBox miniBreaksB = new JCheckBox("Mini Breaks");
  21. private JCheckBox nestsB = new JCheckBox("Collect Nests");
  22. private JButton startB = new JButton("Start");
  23. private JButton cancelB = new JButton("Cancel");
  24.  
  25. public LJGUI(){
  26. super("ProgBots Lumberjack Settings");
  27. treeBox.addActionListener(this);
  28. locationBox.addActionListener(this);
  29. mouseSpeedSpinner.addChangeListener(listener);
  30. powerChopB.addItemListener(this);
  31. skillerB.addItemListener(this);
  32. mouseKeysB.addItemListener(this);
  33. startB.addActionListener(this);
  34. cancelB.addActionListener(this);
  35. treeBoxUpdate();
  36. initComponents();
  37. setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  38. }
  39.  
  40. public void actionPerformed(ActionEvent e) {
  41. Object source = e.getSource();
  42. if (source == treeBox){
  43. treeBoxUpdate();
  44. }
  45. if (source == locationBox){
  46. locationBoxUpdate();
  47. }
  48. if (source == startB) {
  49. Object o = locationBox.getSelectedItem();
  50. for (int i = 0; i < aLocations.length; i++) {
  51. if (o.equals(aLocations[i].name)) {
  52. treeType type = aLocations[i].treeType;
  53. bankArea = aLocations[i].bankArea;
  54. treeArea = aLocations[i].treeArea;
  55. path = aLocations[i].path;
  56. treeType = type.name;
  57. treeID = type.treeIDs;
  58. stumpID = type.stumpID;
  59. logsID = type.logID;
  60. xpPerLog = type.exp;
  61. break;
  62. }
  63. }
  64. if (powerChopB.isSelected())
  65. powerChop = true;
  66. if (skillerB.isSelected())
  67. skiller = true;
  68. if (mouseKeysB.isSelected())
  69. mouseKeys = true;
  70. if (miniBreaksB.isSelected())
  71. miniBreaks = true;
  72. if (nestsB.isSelected())
  73. collectNests = true;
  74. start = true;
  75. }
  76. if (source == cancelB) {
  77. cancelled = true;
  78. }
  79. }
  80.  
  81. public void itemStateChanged(ItemEvent e) {
  82. Object source = e.getSource();
  83. if (source == mouseKeysB) {
  84. if (e.getStateChange() == ItemEvent.SELECTED) {
  85. powerChopB.setSelected(true);
  86. powerChopB.setEnabled(false);
  87. } else if (e.getStateChange() == ItemEvent.DESELECTED) {
  88. Object o = locationBox.getSelectedItem();
  89. if (o.toString().endsWith("(P)")) {
  90. powerChopB.setEnabled(false);
  91. } else {
  92. powerChopB.setEnabled(true);
  93. }
  94. }
  95. }
  96. }
  97.  
  98. ChangeListener listener = new ChangeListener() {
  99. public void stateChanged(ChangeEvent c) {
  100. mouse.setSpeed((Integer) mouseSpeedSpinner.getValue());
  101. }
  102. };
  103.  
  104. private void treeBoxUpdate(){
  105. int i = treeBox.getSelectedIndex();
  106. treeType = tTypes[i].name;
  107. ComboBoxModel temp = new DefaultComboBoxModel(getloc());
  108. locationBox.setModel(temp);
  109. }
  110.  
  111. private void locationBoxUpdate() {
  112. Object o = locationBox.getSelectedItem();
  113. if (o.toString().endsWith("(P)")) {
  114. powerChopB.setSelected(true);
  115. powerChopB.setEnabled(false);
  116. } else {
  117. powerChopB.setEnabled(true);
  118. }
  119.  
  120. if (o == "Port Sarim - Willows") {
  121. useDepositBox = true;
  122. } else {
  123. useDepositBox = false;
  124. }
  125. if (o.toString().contains("Tree Gnome")){
  126. tgy = true;
  127. } else {
  128. tgy = false;
  129. }
  130. }
  131.  
  132. private void initComponents(){
  133. Container contentPane = getContentPane();
  134. contentPane.setLayout(new GridBagLayout());
  135. ((GridBagLayout)contentPane.getLayout()).columnWidths = new int[] {100, 95, 0};
  136.  
  137. contentPane.add(treeLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
  138. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  139. new Insets(5, 5, 5, 5), 0, 0));
  140. contentPane.add(treeBox, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0,
  141. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  142. new Insets(0, 5, 5, 5), 0, 0));
  143.  
  144. contentPane.add(locationLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
  145. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  146. new Insets(0, 5, 5, 5), 0, 0));
  147. contentPane.add(locationBox, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0,
  148. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  149. new Insets(0, 5, 5, 5), 0, 0));
  150.  
  151. contentPane.add(mouseSpeedLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0,
  152. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  153. new Insets(0, 5, 5, 5), 0, 0));
  154.  
  155. contentPane.add(mouseSpeedSpinner, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0,
  156. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  157. new Insets(0, 5, 5, 5), 0, 0));
  158.  
  159. contentPane.add(powerChopB, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0,
  160. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  161. new Insets(0, 0, 5, 0), 0, 0));
  162.  
  163. contentPane.add(skillerB, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0,
  164. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  165. new Insets(0, 5, 5, 5), 0, 0));
  166.  
  167. contentPane.add(mouseKeysB, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0,
  168. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  169. new Insets(0, 0, 5, 0), 0, 0));
  170.  
  171. contentPane.add(miniBreaksB, new GridBagConstraints(0, 7, 1, 1, 0, 0,
  172. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  173. new Insets(0, 5, 5, 5), 0 ,0));
  174.  
  175. contentPane.add(nestsB, new GridBagConstraints(1, 7, 1, 1, 0, 0,
  176. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  177. new Insets(0, 0, 5, 5), 0 ,0));
  178.  
  179. contentPane.add(startB, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0,
  180. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  181. new Insets(0, 5, 5, 5), 0, 0));
  182.  
  183. contentPane.add(cancelB, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0,
  184. GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  185. new Insets(0, 0, 5, 5), 0, 0));
  186. pack();
  187. setLocationRelativeTo(getOwner());
  188. }
  189.  
  190. private String[] getTrees(){
  191. String[] trees;
  192. trees = new String[tTypes.length];
  193. for (int i = 0; i < tTypes.length; i++){
  194. trees[i] = tTypes[i].name;
  195. }
  196. return trees;
  197. }
  198. private String[] getloc(){
  199. ArrayList<String> temp = new ArrayList<String>();
  200. int j = treeBox.getSelectedIndex();
  201. for (int i = 0; i < aLocations.length; i++){
  202. if (aLocations[i].treeType.name.equals(tTypes[j].name)){
  203. temp.add(aLocations[i].name);
  204. }
  205. }
  206. String[] loc = new String[temp.size()];
  207. for (int i = 0; i < temp.size(); i++){
  208. loc[i] = temp.get(i);
  209. }
  210. return loc;
  211. }
  212. }
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement