From e9e01c18f481b1ec4b2416556920a121d8d1a640 Mon Sep 17 00:00:00 2001 From: SomeoneWithAnInternetConnection <34518321+SomeoneWithAnInternetConnection@users.noreply.github.com> Date: Sun, 21 Jan 2018 17:51:41 -0500 Subject: [PATCH] Add bounding/clickbox buttons to the devtools plugin The first button (yellow square) will toggle drawing of 2D bounding boxes The second button (RGB cubeframe) will toggle 3D bounding box drawing The third button (cursor over red square) will toggle clickbox geometry drawing The fourth button (cursor over cubeframe) switches between "draw all 3D bounding boxes" and "draw bounding box for object under cursor" modes of the 3D bounding box drawing. T --- .../plugins/devtools/DevToolsPanel.java | 71 ++++++++++++++++++ .../plugins/devtools/2D_bounding_box.png | Bin 0 -> 233 bytes .../plugins/devtools/2D_clickbox_geometry.png | Bin 0 -> 285 bytes .../plugins/devtools/3D_bounding_box.png | Bin 0 -> 430 bytes .../devtools/mouseover_3D_bounding_box.png | Bin 0 -> 312 bytes 5 files changed, 71 insertions(+) create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/devtools/2D_bounding_box.png create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/devtools/2D_clickbox_geometry.png create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/devtools/3D_bounding_box.png create mode 100644 runelite-client/src/main/resources/net/runelite/client/plugins/devtools/mouseover_3D_bounding_box.png diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java index cd8d125da8..6b46ce2505 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPanel.java @@ -30,10 +30,13 @@ import static net.runelite.api.widgets.WidgetInfo.TO_GROUP; import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; +import java.io.IOException; import java.util.Collection; import java.util.concurrent.ExecutionException; import javax.annotation.Nullable; +import javax.imageio.ImageIO; import javax.inject.Inject; +import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; @@ -61,6 +64,7 @@ public class DevToolsPanel extends PluginPanel private JButton renderDecorBtn = new JButton(); private JButton renderInventoryBtn = new JButton(); private JButton renderProjectilesBtn = new JButton(); + private JPanel boundsDebugPanel = new JPanel(); private JLabel textLbl = new JLabel(); private JLabel textColorLbl = new JLabel(); @@ -167,6 +171,9 @@ public class DevToolsPanel extends PluginPanel }); container.add(renderProjectilesBtn); + boundsDebugPanel = createBoundsDebugMultiButton(); + container.add(boundsDebugPanel); + JButton settingsSnapshotBtn = new JButton("Get Settings"); settingsSnapshotBtn.addActionListener(settingsTracker::snapshot); container.add(settingsSnapshotBtn); @@ -178,6 +185,70 @@ public class DevToolsPanel extends PluginPanel return container; } + private JPanel createBoundsDebugMultiButton() + { + ImageIcon bBox2DIcon; + ImageIcon bBox3DIcon; + ImageIcon clickBoxIcon; + ImageIcon bBox3DMousoverIcon; + + try + { + bBox2DIcon = new ImageIcon(ImageIO.read(DevToolsPlugin.class.getResourceAsStream("2D_bounding_box.png"))); + bBox3DIcon = new ImageIcon(ImageIO.read(DevToolsPlugin.class.getResourceAsStream("3D_bounding_box.png"))); + clickBoxIcon = new ImageIcon(ImageIO.read(DevToolsPlugin.class.getResourceAsStream("2D_clickbox_geometry.png"))); + bBox3DMousoverIcon = new ImageIcon(ImageIO.read(DevToolsPlugin.class.getResourceAsStream("mouseover_3D_bounding_box.png"))); + } + catch (IOException ex) + { + log.warn("unable to load bounding box images", ex); + return new JPanel(); + } + + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new GridLayout(1, 4)); + JButton bBox2DButton = new JButton(bBox2DIcon); + bBox2DButton.addActionListener(e -> + { + client.setDrawBoundingBoxes2D(!client.getDrawBoundingBoxes2D()); + highlightButton(bBox2DButton); + }); + buttonPanel.add(bBox2DButton); + + JButton bBox3DButton = new JButton(bBox3DIcon); + bBox3DButton.addActionListener(e -> + { + client.setDrawBoundingBoxes3D(!client.getDrawBoundingBoxes3D()); + highlightButton(bBox3DButton); + }); + buttonPanel.add(bBox3DButton); + + JButton clickBoxButton = new JButton(clickBoxIcon); + clickBoxButton.addActionListener(e -> + { + client.setdrawObjectGeometry2D(!client.getdrawObjectGeometry2D()); + highlightButton(clickBoxButton); + }); + buttonPanel.add(clickBoxButton); + + JButton mouseoverModeButton = new JButton(client.getBoundingBoxAlwaysOnMode() ? bBox3DIcon : bBox3DMousoverIcon); + mouseoverModeButton.addActionListener(e -> + { + client.setBoundingBoxAlwaysOnMode(!client.getBoundingBoxAlwaysOnMode()); + if (client.getBoundingBoxAlwaysOnMode()) + { + mouseoverModeButton.setIcon(bBox3DIcon); + } + else + { + mouseoverModeButton.setIcon(bBox3DMousoverIcon); + } + }); + buttonPanel.add(mouseoverModeButton); + + return buttonPanel; + } + private JPanel createWidgetTreePanel() { JPanel container = new JPanel(); diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/devtools/2D_bounding_box.png b/runelite-client/src/main/resources/net/runelite/client/plugins/devtools/2D_bounding_box.png new file mode 100644 index 0000000000000000000000000000000000000000..d4449a42d3efc4a20c5407c0aae09aa26e6f4222 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPdqo^p0=)J}F9DqWynIRD+&iT2ysd*(pE(3#eQEFmI zYKlU6W=V#EyQgnJie4%^P~6wk#WBR77|LvJo8#)`E4lpJE`E`z`oJ;z7yjxD! z#+8YROD1H9D=;U;GzhX8`0g-y9OPW6&?nW9!l2XjVJTxy7Mq=-Azwuv3qzo)4(FVX Qv;dHep00i_>zopr0I2apBLDyZ literal 0 HcmV?d00001 diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/devtools/2D_clickbox_geometry.png b/runelite-client/src/main/resources/net/runelite/client/plugins/devtools/2D_clickbox_geometry.png new file mode 100644 index 0000000000000000000000000000000000000000..bf6a1930b60b9ddf121ebf8fb513941b01e936c7 GIT binary patch literal 285 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkEUnfx)>bHL)Z$ zMWH;iBtya7(>EYRFO?lA-stJ#7-DgH>EzQwhZT63Rr&w_KYiPKj)4eAUTyM$*X=D| zSbixcS$q~}&~UCveZa18JGyJVjc3+o_J*AMtZkAv-!8E6d!y&C@Gz<)^mS!_#3(At&#PxW|1MBSHZvrm#5q4VH#M&W$Yo$~E=o-- zNlj5G&n(GMaQE~LNYP7WXJB9y@^o--2bs|C(LyE&4S1iw_5)e z2rppaeZ4DV+bjjmIkP&xe0^B5{z#0cT=}BCzo+ewd=q+i#%XVh=06M;pZ@#(VQlm} UI>nEN+XNJBp00i_>zopr06ej-9RL6T literal 0 HcmV?d00001 diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/devtools/mouseover_3D_bounding_box.png b/runelite-client/src/main/resources/net/runelite/client/plugins/devtools/mouseover_3D_bounding_box.png new file mode 100644 index 0000000000000000000000000000000000000000..6af91bffa8a6dd51c5f349157d13df29e0dd2f0e GIT binary patch literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkEYGO%h zib8p2Nrr;Er*A-tUMf3Ke2%A!V~EA+sgo`W9yZ``o?j!Ue7JH8-*nq6{nspO6csNn z7c^oznecX5leyxBottjA`5c`1x!&TVRD;9P6Rhj+iq_WD=w8~K^d(C=bE{ls()OES z#|-|xnDOAcilNZtx$PX2HR`TZH0G$UXEB;6_kPcsmD`dV=Bb_e@zU>>Z-?B?m6IYC y-EV!tWf-ycRMj<;^9FO~7|u>uR?v0B&LjTy`=|tVXR{L^4|uxzxvX