From 95556aadc75a602ca9166fd9bc86252895512a94 Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Wed, 18 Mar 2020 17:53:34 -0700 Subject: [PATCH] widget: Expose widget model getters and setters This commit also adds these widget properties to the widget inspector dev tool. --- .../java/net/runelite/api/widgets/Widget.java | 84 ++++++++++++++++++- .../runelite/api/widgets/WidgetModelType.java | 35 ++++++++ .../devtools/WidgetInfoTableModel.java | 7 +- 3 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 runelite-api/src/main/java/net/runelite/api/widgets/WidgetModelType.java diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java b/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java index f44e61e448..5a827a8ed6 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java @@ -243,11 +243,91 @@ public interface Widget /** * Gets the model ID displayed in the widget. - * - * @return the model ID */ int getModelId(); + /** + * Sets the model ID displayed in the widget. + * + * @param modelId the new model ID + */ + void setModelId(int modelId); + + /** + * Gets the model type of the widget. + * + * @see WidgetModelType + */ + int getModelType(); + + /** + * Sets the model type of the widget. + * + * @param type the new model type + * @see WidgetModelType + */ + void setModelType(int type); + + /** + * Gets the x rotation of the model displayed in the widget. + * 0 = no rotation, 2047 = full rotation + */ + int getRotationX(); + + /** + * Sets the x rotation of the model displayed in the widget. + *
+ * Note: Setting this value outside of the input range defined by {@link Widget#getRotationX()} will cause a client + * crash. + * + * @param modelX the new model x rotation value + */ + void setRotationX(int modelX); + + /** + * Gets the y rotation of the model displayed in the widget. + * 0 = no rotation, 2047 = full rotation + */ + int getRotationY(); + + /** + * Sets the y rotation of the model displayed in the widget. + *
+ * Note: Setting this value outside of the input range defined by {@link Widget#getRotationY()} will cause a client + * crash. + * + * @param modelY the new model y rotation value + */ + void setRotationY(int modelY); + + /** + * Gets the z rotation of the model displayed in the widget. + * 0 = no rotation, 2047 = full rotation + */ + int getRotationZ(); + + /** + * Sets the z rotation of the model displayed in the widget. + *
+ * Note: Setting this value outside of the input range defined by {@link Widget#getRotationZ()} will cause a client + * crash. + * + * @param modelZ the new model z rotation value + */ + void setRotationZ(int modelZ); + + /** + * Gets the amount zoomed in on the model displayed in the widget. + */ + int getModelZoom(); + + /** + * Sets the amount zoomed in on the model displayed in the widget. + * + * @param modelZoom the new model zoom value + */ + void setModelZoom(int modelZoom); + /** * Gets the sprite ID displayed in the widget. * diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetModelType.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetModelType.java new file mode 100644 index 0000000000..ff68eef617 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetModelType.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2020, Jordan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api.widgets; + +public class WidgetModelType +{ + public static final int NULL = 0; + public static final int MODEL = 1; + public static final int NPC_CHATHEAD = 2; + public static final int LOCAL_PLAYER_CHATHEAD = 3; + public static final int ITEM = 4; + public static final int PLAYER = 5; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInfoTableModel.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInfoTableModel.java index acd8851c0b..6623838871 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInfoTableModel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/WidgetInfoTableModel.java @@ -155,7 +155,12 @@ public class WidgetInfoTableModel extends AbstractTableModel out.add(new WidgetField<>("ItemId", Widget::getItemId, Widget::setItemId, Integer.class)); out.add(new WidgetField<>("ItemQuantity", Widget::getItemQuantity, Widget::setItemQuantity, Integer.class)); out.add(new WidgetField<>("ItemQuantityMode", Widget::getItemQuantityMode, Widget::setItemQuantityMode, Integer.class)); - out.add(new WidgetField<>("ModelId", Widget::getModelId)); + out.add(new WidgetField<>("ModelId", Widget::getModelId, Widget::setModelId, Integer.class)); + out.add(new WidgetField<>("ModelType", Widget::getModelType, Widget::setModelType, Integer.class)); + out.add(new WidgetField<>("RotationX", Widget::getRotationX, Widget::setRotationX, Integer.class)); + out.add(new WidgetField<>("RotationY", Widget::getRotationY, Widget::setRotationY, Integer.class)); + out.add(new WidgetField<>("RotationZ", Widget::getRotationZ, Widget::setRotationZ, Integer.class)); + out.add(new WidgetField<>("ModelZoom", Widget::getModelZoom, Widget::setModelZoom, Integer.class)); out.add(new WidgetField<>("SpriteId", Widget::getSpriteId, Widget::setSpriteId, Integer.class)); out.add(new WidgetField<>("BorderType", Widget::getBorderType, Widget::setBorderType, Integer.class)); out.add(new WidgetField<>("IsIf3", Widget::isIf3));