|
| 1 | +package org.chris; |
| 2 | + |
| 3 | +import org.chris.util.CheckLevels; |
| 4 | +import org.chris.util.Targets; |
| 5 | + |
| 6 | +import java.awt.*; |
| 7 | +import java.awt.event.*; |
| 8 | +import java.io.IOException; |
| 9 | +import java.nio.charset.StandardCharsets; |
| 10 | +import java.nio.file.Files; |
| 11 | +import java.nio.file.Paths; |
| 12 | +import java.util.ArrayList; |
| 13 | +import java.util.HashMap; |
| 14 | +import javax.swing.*; |
| 15 | +/* |
| 16 | + * Created by JFormDesigner on Wed Dec 27 10:46:51 EST 2017 |
| 17 | + */ |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +/** |
| 22 | + * @author Christopher d |
| 23 | + */ |
| 24 | +public class GUI extends JFrame { |
| 25 | + |
| 26 | + private java.util.List<String> accsToInput = new ArrayList<>(); |
| 27 | + private HashMap<String, Integer> accsToOutput = new HashMap<>(); |
| 28 | + private int search, targetLevel; |
| 29 | + private String nameOfSkill; |
| 30 | + |
| 31 | + public GUI() { |
| 32 | + initComponents(); |
| 33 | + } |
| 34 | + |
| 35 | + private void buttonFilterAccountsActionPerformed(ActionEvent e) { |
| 36 | + // TODO add your code here |
| 37 | + long start = System.currentTimeMillis(); |
| 38 | + textOutputArea.setText(""); |
| 39 | + printToOutput("Grabbing accounts from file................\n"); |
| 40 | + try { |
| 41 | + accsToInput = Files.readAllLines(Paths.get("C:\\Users\\Chris\\Desktop\\Accounts.txt") |
| 42 | + , StandardCharsets.UTF_8); |
| 43 | + } catch (IOException f) { |
| 44 | + printToOutput(f + "\n"); |
| 45 | + } |
| 46 | + printToOutput("Loaded accounts: " + (accsToInput.size()) + "\n"); |
| 47 | + |
| 48 | + printToOutput("Grabbing hiscore search value...\n"); |
| 49 | + for (Targets s : Targets.values()) { |
| 50 | + if (s.getName().equals(comboSkillTarget.getSelectedItem().toString())) { |
| 51 | + search = s.getSearchValue(); |
| 52 | + targetLevel = Integer.parseInt(textTargetLevel.getText()); |
| 53 | + nameOfSkill = s.getName(); |
| 54 | + printToOutput("Searching: " + nameOfSkill + " >= " + targetLevel + "\n"); |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + printToOutput("Saving each player's highscore value to our map.....\n"); |
| 59 | + for (String playerName : accsToInput){ |
| 60 | + int target = 0; |
| 61 | + while (target == 0){ |
| 62 | + printToOutput("Checking the highscores...please wait while I load data...\n"); |
| 63 | + target = new CheckLevels(playerName, search).getTargetLevel(); |
| 64 | + /*try { |
| 65 | + Thread.sleep(600); |
| 66 | + } catch (InterruptedException e1) { |
| 67 | + e1.printStackTrace(); |
| 68 | + }*/ |
| 69 | + } |
| 70 | + if (target >= targetLevel){ |
| 71 | + printToOutput("Found: " + playerName + " Level: " + target + "\n"); |
| 72 | + accsToOutput.put(playerName, target); |
| 73 | + } |
| 74 | + } |
| 75 | + printToOutput("Finished loading data for all accounts..sorting....\n"); |
| 76 | + printToOutput("Clearing our output to display the sort.....\n"); |
| 77 | + textOutputArea.setText(""); |
| 78 | + printToOutput("Filtered Accounts for " + nameOfSkill + " Level:" + targetLevel + " or greater.\n"); |
| 79 | + for (String name : accsToOutput.keySet()){ |
| 80 | + printToOutput("Account: " + name + " | " + nameOfSkill + " Level: " + accsToOutput.get(name) + " \n"); |
| 81 | + } |
| 82 | + printToOutput("Output time " + (System.currentTimeMillis() - start) + "ms.\n"); |
| 83 | + } |
| 84 | + |
| 85 | + private void printToOutput(String outputMessage){ |
| 86 | + textOutputArea.append(outputMessage); |
| 87 | + } |
| 88 | + |
| 89 | + private void initComponents() { |
| 90 | + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents |
| 91 | + // Generated using JFormDesigner Evaluation license - Christopher d |
| 92 | + label1 = new JLabel(); |
| 93 | + scrollPane1 = new JScrollPane(); |
| 94 | + textOutputArea = new JTextArea(); |
| 95 | + label2 = new JLabel(); |
| 96 | + comboSkillTarget = new JComboBox<>(); |
| 97 | + label3 = new JLabel(); |
| 98 | + textTargetLevel = new JTextField(); |
| 99 | + buttonFilterAccounts = new JButton(); |
| 100 | + |
| 101 | + //======== this ======== |
| 102 | + setTitle("HiScore Filter Tool"); |
| 103 | + Container contentPane = getContentPane(); |
| 104 | + contentPane.setLayout(null); |
| 105 | + |
| 106 | + //---- label1 ---- |
| 107 | + label1.setText("Output"); |
| 108 | + label1.setFont(label1.getFont().deriveFont(label1.getFont().getStyle() | Font.BOLD, label1.getFont().getSize() + 5f)); |
| 109 | + contentPane.add(label1); |
| 110 | + label1.setBounds(15, 10, 60, 30); |
| 111 | + |
| 112 | + //======== scrollPane1 ======== |
| 113 | + { |
| 114 | + scrollPane1.setViewportView(textOutputArea); |
| 115 | + } |
| 116 | + contentPane.add(scrollPane1); |
| 117 | + scrollPane1.setBounds(15, 45, 295, 540); |
| 118 | + |
| 119 | + //---- label2 ---- |
| 120 | + label2.setText("Target:"); |
| 121 | + label2.setFont(label2.getFont().deriveFont(label2.getFont().getStyle() | Font.BOLD, label2.getFont().getSize() + 5f)); |
| 122 | + contentPane.add(label2); |
| 123 | + label2.setBounds(new Rectangle(new Point(325, 290), label2.getPreferredSize())); |
| 124 | + |
| 125 | + //---- comboSkillTarget ---- |
| 126 | + comboSkillTarget.setFont(comboSkillTarget.getFont().deriveFont(comboSkillTarget.getFont().getSize() + 5f)); |
| 127 | + comboSkillTarget.setModel(new DefaultComboBoxModel<>(new String[] { |
| 128 | + "Attack", |
| 129 | + "Defence", |
| 130 | + "Strength", |
| 131 | + "Hitpoints", |
| 132 | + "Range", |
| 133 | + "Prayer", |
| 134 | + "Magic", |
| 135 | + "Cooking", |
| 136 | + "Woodcutting", |
| 137 | + "Fletching", |
| 138 | + "Fishing", |
| 139 | + "Firemaking", |
| 140 | + "Crafting", |
| 141 | + "Smithing", |
| 142 | + "Mining", |
| 143 | + "Herblore", |
| 144 | + "Agility", |
| 145 | + "Theiving", |
| 146 | + "Slayer", |
| 147 | + "Farming", |
| 148 | + "Runecrafting", |
| 149 | + "Hunter", |
| 150 | + "Construction" |
| 151 | + })); |
| 152 | + contentPane.add(comboSkillTarget); |
| 153 | + comboSkillTarget.setBounds(395, 290, 115, comboSkillTarget.getPreferredSize().height); |
| 154 | + |
| 155 | + //---- label3 ---- |
| 156 | + label3.setText("Target Level:"); |
| 157 | + label3.setFont(label3.getFont().deriveFont(label3.getFont().getStyle() | Font.BOLD, label3.getFont().getSize() + 5f)); |
| 158 | + contentPane.add(label3); |
| 159 | + label3.setBounds(new Rectangle(new Point(325, 350), label3.getPreferredSize())); |
| 160 | + |
| 161 | + //---- textTargetLevel ---- |
| 162 | + textTargetLevel.setText("1"); |
| 163 | + textTargetLevel.setFont(textTargetLevel.getFont().deriveFont(textTargetLevel.getFont().getSize() + 4f)); |
| 164 | + contentPane.add(textTargetLevel); |
| 165 | + textTargetLevel.setBounds(440, 345, 35, 30); |
| 166 | + |
| 167 | + //---- buttonFilterAccounts ---- |
| 168 | + buttonFilterAccounts.setText("Start Filter"); |
| 169 | + buttonFilterAccounts.setFont(buttonFilterAccounts.getFont().deriveFont(buttonFilterAccounts.getFont().getStyle() | Font.BOLD, buttonFilterAccounts.getFont().getSize() + 4f)); |
| 170 | + buttonFilterAccounts.addActionListener(e -> buttonFilterAccountsActionPerformed(e)); |
| 171 | + contentPane.add(buttonFilterAccounts); |
| 172 | + buttonFilterAccounts.setBounds(330, 420, 190, 60); |
| 173 | + |
| 174 | + contentPane.setPreferredSize(new Dimension(550, 640)); |
| 175 | + setSize(550, 640); |
| 176 | + setLocationRelativeTo(getOwner()); |
| 177 | + // JFormDesigner - End of component initialization //GEN-END:initComponents |
| 178 | + } |
| 179 | + |
| 180 | + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables |
| 181 | + // Generated using JFormDesigner Evaluation license - Christopher d |
| 182 | + private JLabel label1; |
| 183 | + private JScrollPane scrollPane1; |
| 184 | + private JTextArea textOutputArea; |
| 185 | + private JLabel label2; |
| 186 | + private JComboBox<String> comboSkillTarget; |
| 187 | + private JLabel label3; |
| 188 | + private JTextField textTargetLevel; |
| 189 | + private JButton buttonFilterAccounts; |
| 190 | + // JFormDesigner - End of variables declaration //GEN-END:variables |
| 191 | +} |
0 commit comments