Allow custom NPC id for thieving

This commit is contained in:
RedSparr0w
2019-10-21 10:19:09 +13:00
parent 35fea8a48b
commit 48082ce491
3 changed files with 57 additions and 9 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" /> <output url="file://$USER_HOME$/OneDrive/Documents/Parabot/scripts/compiled" />
<output-test url="file://$MODULE_DIR$/target/test-classes" /> <output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
@@ -5,7 +5,8 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
public enum Npcs { 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 String name;
private int[] ids; private int[] ids;
@@ -19,13 +20,13 @@ public enum Npcs {
public static String[] toStringArray() { public static String[] toStringArray() {
List<Npcs> enumList = Arrays.asList(Npcs.values()); List<Npcs> enumList = Arrays.asList(Npcs.values());
List<String> locationsArray = new ArrayList<>(); List<String> npcsArray = new ArrayList<>();
for (Npcs npc : enumList) { for (Npcs npc : enumList) {
locationsArray.add(npc.name); npcsArray.add(npc.name);
} }
String[] simpleArray = new String[ locationsArray.size() ]; String[] simpleArray = new String[ npcsArray.size() ];
locationsArray.toArray( simpleArray ); npcsArray.toArray( simpleArray );
return(simpleArray); return(simpleArray);
} }
@@ -33,5 +34,11 @@ public enum Npcs {
public int[] getIDs() { return this.ids; } public int[] getIDs() { return this.ids; }
public void setIDs(int[] ids) {
if (this == CUSTOM){
this.ids = ids;
}
}
public double getXP() { return this.xp; } public double getXP() { return this.xp; }
} }
+44 -3
View File
@@ -14,6 +14,8 @@ import javax.swing.border.EmptyBorder;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
public class UI extends JFrame { public class UI extends JFrame {
private final ButtonGroup woodcutOptionButtonGroup = new ButtonGroup(); private final ButtonGroup woodcutOptionButtonGroup = new ButtonGroup();
@@ -39,7 +41,8 @@ public class UI extends JFrame {
//Thieving //Thieving
private JComboBox npcSelect = new JComboBox(); 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 // Our colors
private Color Color_MidnightBlue = new Color(44, 62, 80); 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 // Select which npc should be our victim
JLabel lblNpc = new JLabel("NPC"); JLabel lblNpc = new JLabel("NPC");
lblOre.setForeground(Color_WhiteSmoke); lblNpc.setForeground(Color_WhiteSmoke);
lblOre.setBounds(20, 20, 73, 20); lblNpc.setBounds(20, 20, 73, 20);
thievingPanel.add(lblNpc); thievingPanel.add(lblNpc);
npcSelect.setModel(new DefaultComboBoxModel(Npcs.toStringArray())); npcSelect.setModel(new DefaultComboBoxModel(Npcs.toStringArray()));
npcSelect.setBounds(20, 40, 150, 20); npcSelect.setBounds(20, 40, 150, 20);
@@ -285,10 +288,48 @@ public class UI extends JFrame {
Variables.thieving_npc_selected = npc; 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); 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 * Slave Panel
*/ */