Advertisement
iant06

Untitled

Oct 16th, 2015
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.88 KB | None | 0 0
  1. package scripts.clues;
  2.  
  3. import java.awt.Font;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import java.awt.font.TextAttribute;
  7. import java.lang.reflect.InvocationTargetException;
  8. import java.util.HashMap;
  9. import java.util.Map;
  10.  
  11. import javax.swing.DefaultComboBoxModel;
  12. import javax.swing.JButton;
  13. import javax.swing.JComboBox;
  14. import javax.swing.JFrame;
  15. import javax.swing.JLabel;
  16. import javax.swing.JPanel;
  17. import javax.swing.JSlider;
  18. import javax.swing.JTextField;
  19. import javax.swing.SwingUtilities;
  20. import javax.swing.border.EmptyBorder;
  21.  
  22. import org.tribot.api.General;
  23. import org.tribot.api.input.Mouse;
  24.  
  25. import scripts.clues.HamDungeon.AcquiringMethod;
  26.  
  27. @SuppressWarnings("serial")
  28. public class GUI extends JFrame {
  29.  
  30. private Main main;
  31.  
  32. private JPanel contentPane;
  33.  
  34. private JComboBox<Teleporting.TeleportMethod> comboBox;
  35. private JComboBox<AcquiringMethod> comboBox_3;
  36.  
  37. private JTextField foodName;
  38. private JTextField foodAmount;
  39.  
  40. private Profile guiProfile = null;
  41.  
  42. private AcquiringMethod setAcquiringMethod;
  43. private Teleporting.TeleportMethod setTeleportMethod;
  44. private String setFoodName;
  45. private int setFoodAmount;
  46.  
  47. public GUI(Main main) {
  48. setMain(main);
  49. try {
  50. SwingUtilities.invokeAndWait(new Runnable() {
  51.  
  52. @Override
  53. public void run() {
  54.  
  55. if(getMain().getProfile() == null) {
  56. getMain().setProfile(ProfileHandler.loadProfile(getMain().getName()));
  57. }
  58.  
  59. setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  60. setBounds(100, 100, 280, 350);
  61.  
  62. contentPane = new JPanel();
  63. contentPane.setName("iClueSolver by iant06");
  64. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  65. contentPane.setOpaque(true);
  66.  
  67. setContentPane(contentPane);
  68.  
  69. contentPane.setLayout(null);
  70. contentPane.setFont(new Font("Arial", Font.PLAIN, 12));
  71.  
  72. JLabel title = new JLabel("iClueSolver by iant06");
  73. Font h = new Font("Helvetica", Font.ITALIC, 24);
  74. title.setFont(h);
  75.  
  76. Font ffont = title.getFont();
  77. Map<TextAttribute, Object> fattributes = new HashMap<TextAttribute, Object>();
  78. fattributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
  79. Font fnewFont = ffont.deriveFont(fattributes);
  80. title.setFont(fnewFont);
  81.  
  82. title.setBounds(20, -30, 480, 100);
  83. contentPane.add(title);
  84.  
  85. JLabel taskLabel = new JLabel("Acquiring Method:");
  86. taskLabel.setFont(new Font("Arial", Font.BOLD, 12));
  87. taskLabel.setBounds(15, 77-20, 135, 23);
  88. contentPane.add(taskLabel);
  89. setComboBox_3(new JComboBox<AcquiringMethod>(new DefaultComboBoxModel<AcquiringMethod>(AcquiringMethod.values())));
  90. contentPane.add(getComboBox_3());
  91. comboBox_3.setBounds(123, 77-20, 135, 23);
  92. getComboBox_3().setSelectedItem(getMain().getProfile().getAcquiringMethod());
  93.  
  94. JLabel barLabel = new JLabel("Teleport Method:");
  95. barLabel.setFont(new Font("Arial", Font.BOLD, 12));
  96. barLabel.setBounds(15, 108-20, 135, 23);
  97. contentPane.add(barLabel);
  98. setComboBox(new JComboBox<Teleporting.TeleportMethod>(new DefaultComboBoxModel<Teleporting.TeleportMethod>(Teleporting.TeleportMethod.values())));
  99. contentPane.add(getComboBox());
  100. comboBox.setBounds(123, 108-20, 135, 23);
  101. getComboBox().setSelectedItem(getMain().getProfile().getTeleportMethod());
  102.  
  103. JLabel foodNameLabel = new JLabel("Food Name:");
  104. contentPane.add(foodNameLabel);
  105. foodNameLabel.setBounds(20, 142-20, 120, 18);
  106. foodNameLabel.setFont(new Font("Arial", Font.BOLD, 12));
  107. foodName = new JTextField();
  108. contentPane.add(foodName);
  109. String pFoodName = getMain().getProfile().getFoodName();
  110. foodName.setText(!pFoodName.equals("") ? pFoodName : "Lobster");
  111. foodName.setColumns(10);
  112. foodName.setBounds(123, 139-20, 135, 23);
  113.  
  114. JLabel locationLabel = new JLabel("Food Amount:");
  115. contentPane.add(locationLabel);
  116. locationLabel.setBounds(20, 174-20, 120, 18);
  117. locationLabel.setFont(new Font("Arial", Font.BOLD, 12));
  118. foodAmount = new JTextField();
  119. contentPane.add(foodAmount);
  120. int pFoodAmount = getMain().getProfile().getFoodAmount();
  121. foodAmount.setText("" + (pFoodAmount == -1 ? 10 : pFoodAmount));
  122. foodAmount.setColumns(10);
  123. foodAmount.setBounds(123, 170-20, 135, 23);
  124.  
  125. JLabel mouseSpeedLabel = new JLabel("Mouse Speed:");
  126. contentPane.add(mouseSpeedLabel);
  127. mouseSpeedLabel.setBounds(105, 213-20, 120, 18);
  128. mouseSpeedLabel.setFont(new Font("Arial", Font.BOLD, 12));
  129.  
  130. JSlider mouseSpeed = new JSlider(JSlider.HORIZONTAL,
  131. 90, 120, General.random(90, 105));
  132. mouseSpeed.setMajorTickSpacing(10);
  133. mouseSpeed.setMinorTickSpacing(5);
  134. mouseSpeed.setPaintTicks(true);
  135. mouseSpeed.setPaintLabels(true);
  136. mouseSpeed.setBounds(20, 235-20, 250, 50);
  137. contentPane.add(mouseSpeed);
  138.  
  139. JButton btnStart = new JButton("Start");
  140. btnStart.setBounds(100, 313-30, 89, 23);
  141. btnStart.addActionListener(new ActionListener()
  142. {
  143. public void actionPerformed(ActionEvent arg0)
  144. {
  145. AcquiringMethod a = (AcquiringMethod) getComboBox_3().getSelectedItem();
  146. Teleporting.TeleportMethod t = (Teleporting.TeleportMethod) getComboBox().getSelectedItem();
  147. getMain().setAcquiringMethod(a);
  148. getMain().setTeleportMethod(t);
  149. getMain().setFoodName(foodName.getText());
  150. getMain().setFoodAmount(Integer.parseInt(foodAmount.getText()));
  151. Mouse.setSpeed((int) mouseSpeed.getValue());
  152. getMain().println("Starting iClueSolver by iant06.");
  153. ProfileHandler.saveProfile(getMain().getProfile(), new Object[] {
  154. a, t, foodName.getText(), Integer.parseInt(foodAmount.getText())
  155. });
  156. setVisible(false);
  157. dispose();
  158. }
  159. });
  160. contentPane.add(btnStart);
  161. contentPane.repaint();
  162. setVisible(true);
  163. }
  164.  
  165. });
  166. } catch (InvocationTargetException e) {
  167. // TODO Auto-generated catch block
  168. e.printStackTrace();
  169. } catch (InterruptedException e) {
  170. // TODO Auto-generated catch block
  171. e.printStackTrace();
  172. }
  173. }
  174.  
  175. public Main getMain() {
  176. return main;
  177. }
  178.  
  179. public void setMain(Main main) {
  180. this.main = main;
  181. }
  182.  
  183. public JTextField getFoodName() {
  184. return foodName;
  185. }
  186.  
  187. public void setFoodName(JTextField foodName) {
  188. this.foodName = foodName;
  189. }
  190.  
  191. public JTextField getFoodAmount() {
  192. return foodAmount;
  193. }
  194.  
  195. public void setFoodAmount(JTextField foodAmount) {
  196. this.foodAmount = foodAmount;
  197. }
  198.  
  199. public JComboBox<Teleporting.TeleportMethod> getComboBox() {
  200. return comboBox;
  201. }
  202.  
  203. public void setComboBox(JComboBox<Teleporting.TeleportMethod> comboBox) {
  204. this.comboBox = comboBox;
  205. }
  206.  
  207. public JComboBox<AcquiringMethod> getComboBox_3() {
  208. return comboBox_3;
  209. }
  210.  
  211. public void setComboBox_3(JComboBox<AcquiringMethod> comboBox_3) {
  212. this.comboBox_3 = comboBox_3;
  213. }
  214.  
  215. public Profile getGuiProfile() {
  216. return guiProfile;
  217. }
  218.  
  219. public void setGuiProfile(Profile guiProfile) {
  220. this.guiProfile = guiProfile;
  221. }
  222.  
  223. public AcquiringMethod getSetAcquiringMethod() {
  224. return setAcquiringMethod;
  225. }
  226.  
  227. public void setSetAcquiringMethod(AcquiringMethod setAcquiringMethod) {
  228. this.setAcquiringMethod = setAcquiringMethod;
  229. }
  230.  
  231. public Teleporting.TeleportMethod getSetTeleportMethod() {
  232. return setTeleportMethod;
  233. }
  234.  
  235. public void setSetTeleportMethod(Teleporting.TeleportMethod setTeleportMethod) {
  236. this.setTeleportMethod = setTeleportMethod;
  237. }
  238.  
  239. public String getSetFoodName() {
  240. return setFoodName;
  241. }
  242.  
  243. public void setSetFoodName(String setFoodName) {
  244. this.setFoodName = setFoodName;
  245. }
  246.  
  247. public int getSetFoodAmount() {
  248. return setFoodAmount;
  249. }
  250.  
  251. public void setSetFoodAmount(int setFoodAmount) {
  252. this.setFoodAmount = setFoodAmount;
  253. }
  254.  
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement