diff --git a/ParaScript.iml b/ParaScript.iml index 666191e..b12236a 100644 --- a/ParaScript.iml +++ b/ParaScript.iml @@ -1,7 +1,7 @@ - + diff --git a/src/main/java/ParaScript/data/variables/Npcs.java b/src/main/java/ParaScript/data/variables/Npcs.java index c38cc24..2b4c6a9 100644 --- a/src/main/java/ParaScript/data/variables/Npcs.java +++ b/src/main/java/ParaScript/data/variables/Npcs.java @@ -5,7 +5,8 @@ import java.util.Arrays; import java.util.List; public enum Npcs { - MAN_WOMAN("Man & Woman", new int[]{1, 2, 3, 4, 5, 6}, 8); + MAN_WOMAN("Man & Woman", new int[]{1, 2, 3, 4, 5, 6}, 8), + CUSTOM("Custom (specify IDs)", new int[]{-1}, 0); private String name; private int[] ids; @@ -19,13 +20,13 @@ public enum Npcs { public static String[] toStringArray() { List enumList = Arrays.asList(Npcs.values()); - List locationsArray = new ArrayList<>(); + List npcsArray = new ArrayList<>(); for (Npcs npc : enumList) { - locationsArray.add(npc.name); + npcsArray.add(npc.name); } - String[] simpleArray = new String[ locationsArray.size() ]; - locationsArray.toArray( simpleArray ); + String[] simpleArray = new String[ npcsArray.size() ]; + npcsArray.toArray( simpleArray ); return(simpleArray); } @@ -33,5 +34,11 @@ public enum Npcs { public int[] getIDs() { return this.ids; } + public void setIDs(int[] ids) { + if (this == CUSTOM){ + this.ids = ids; + } + } + public double getXP() { return this.xp; } } diff --git a/src/main/java/ParaScript/ui/UI.java b/src/main/java/ParaScript/ui/UI.java index dc8477a..84a9f67 100644 --- a/src/main/java/ParaScript/ui/UI.java +++ b/src/main/java/ParaScript/ui/UI.java @@ -14,6 +14,8 @@ import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; public class UI extends JFrame { private final ButtonGroup woodcutOptionButtonGroup = new ButtonGroup(); @@ -39,7 +41,8 @@ public class UI extends JFrame { //Thieving private JComboBox npcSelect = new JComboBox(); - private JComboBox thievingMethod = new JComboBox(); + private JLabel lblNpcThievingCustomID = new JLabel("Custom NPC IDs"); + private JTextField npcThievingCustomID = new JTextField(); // Our colors private Color Color_MidnightBlue = new Color(44, 62, 80); @@ -273,8 +276,8 @@ public class UI extends JFrame { // Select which npc should be our victim JLabel lblNpc = new JLabel("NPC"); - lblOre.setForeground(Color_WhiteSmoke); - lblOre.setBounds(20, 20, 73, 20); + lblNpc.setForeground(Color_WhiteSmoke); + lblNpc.setBounds(20, 20, 73, 20); thievingPanel.add(lblNpc); npcSelect.setModel(new DefaultComboBoxModel(Npcs.toStringArray())); npcSelect.setBounds(20, 40, 150, 20); @@ -285,10 +288,48 @@ public class UI extends JFrame { Variables.thieving_npc_selected = npc; } } + if (Variables.thieving_npc_selected == Npcs.CUSTOM) { + lblNpcThievingCustomID.setVisible(true); + npcThievingCustomID.setVisible(true); + } else { + lblNpcThievingCustomID.setVisible(false); + npcThievingCustomID.setVisible(false); + } + UI.this.revalidate(); + UI.this.repaint(); } }); thievingPanel.add(npcSelect); + // Custom npc id to steal from + lblNpcThievingCustomID.setForeground(Color_WhiteSmoke); + lblNpcThievingCustomID.setBounds(200, 20, 150, 20); + thievingPanel.add(lblNpcThievingCustomID); + npcThievingCustomID.setBounds(200, 40, 150, 20); + npcThievingCustomID.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + // we don't need to do anything here + } + + @Override + public void focusLost(FocusEvent e) { + try { + String[] sample = npcThievingCustomID.getText().split("(,|;)\\s*"); + int[] customIDs = new int[sample.length]; + + for (int i = 0; i < sample.length; i++) + customIDs[i] = Integer.parseInt(sample[i]); + Variables.thieving_npc_selected.setIDs(customIDs); + } catch (Exception err) { + Npcs.CUSTOM.setIDs(new int[]{0}); + } + } + }); + thievingPanel.add(npcThievingCustomID); + lblNpcThievingCustomID.setVisible(false); + npcThievingCustomID.setVisible(false); + /* * Slave Panel */