Java Code Examples for net.runelite.api.widgets.Widget#setOriginalX()
The following examples show how to use
net.runelite.api.widgets.Widget#setOriginalX() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FriendsChatPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void loadFriendsChats() { Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST); if (chatList == null) { return; } int y = 2; chatList.setChildren(null); for (String chat : Lists.reverse(chats)) { Widget widget = chatList.createChild(-1, WidgetType.TEXT); widget.setFontId(494); widget.setTextColor(0xffffff); widget.setText(chat); widget.setOriginalHeight(14); widget.setOriginalWidth(142); widget.setOriginalY(y); widget.setOriginalX(20); widget.revalidate(); y += 14; } }
Example 2
Source File: VirtualLevelsInterfaceInput.java From plugins with GNU General Public License v3.0 | 6 votes |
private static void buildWidgetModel(Widget chatboxContainer, SkillModel model) { final Widget levelUpModel = chatboxContainer.createChild(-1, WidgetType.MODEL); levelUpModel.setModelId(model.getModelID()); levelUpModel.setXPositionMode(WidgetPositionMode.ABSOLUTE_TOP); levelUpModel.setOriginalX(model.getOriginalX() + X_OFFSET); levelUpModel.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); levelUpModel.setOriginalY(model.getOriginalY() + Y_OFFSET); levelUpModel.setOriginalWidth(model.getIconWidth()); levelUpModel.setOriginalHeight(model.getIconHeight()); levelUpModel.setRotationX(model.getRotationX()); levelUpModel.setRotationY(model.getRotationY()); levelUpModel.setRotationZ(model.getRotationZ()); levelUpModel.setModelZoom(model.getModelZoom()); levelUpModel.revalidate(); }
Example 3
Source File: WidgetOverlay.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Override public Dimension render(Graphics2D graphics) { final Widget widget = client.getWidget(widgetInfo); final Rectangle bounds = super.getBounds(); final Rectangle parent = getParentBounds(widget); if (parent.isEmpty()) { return null; } int x = bounds.x; int y = bounds.y; x = Math.max(parent.x, x); y = Math.max(parent.y, y); x = Math.min((int)parent.getMaxX() - bounds.width, x); y = Math.min((int)parent.getMaxY() - bounds.height, y); bounds.setLocation(x, y); widget.setOriginalX(0); widget.setOriginalY(0); widget.setRelativeX(bounds.x - parent.x); widget.setRelativeY(bounds.y - parent.y); return new Dimension(widget.getWidth(), widget.getHeight()); }
Example 4
Source File: ChatboxTextInput.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
protected void update() { Widget container = chatboxPanelManager.getContainerWidget(); container.deleteAllChildren(); Widget promptWidget = container.createChild(-1, WidgetType.TEXT); promptWidget.setText(this.prompt); promptWidget.setTextColor(0x800000); promptWidget.setFontId(fontID); promptWidget.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); promptWidget.setOriginalX(0); promptWidget.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); promptWidget.setOriginalY(8); promptWidget.setOriginalHeight(24); promptWidget.setXTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setYTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setWidthMode(WidgetSizeMode.MINUS); promptWidget.revalidate(); buildEdit(0, 50, container.getWidth(), 0); }
Example 5
Source File: BronzeManPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void addItemToCollectionLog(Widget collectionView, Integer itemId, int x, int y, int index) { String itemName = itemManager.getItemDefinition(itemId).getName(); Widget newItem = collectionView.createChild(index, 5); newItem.setContentType(0); newItem.setItemId(itemId); newItem.setItemQuantity(1); newItem.setItemQuantityMode(0); newItem.setModelId(-1); newItem.setModelType(1); newItem.setSpriteId(-1); newItem.setBorderType(1); newItem.setFilled(false); newItem.setRelativeX(x); newItem.setRelativeY(y); newItem.setOriginalX(x); newItem.setOriginalY(y); newItem.setOriginalWidth(36); newItem.setOriginalHeight(32); newItem.setWidth(36); newItem.setHeight(32); newItem.setHasListener(true); newItem.setAction(1, "Inspect"); newItem.setOnOpListener((JavaScriptCallback) e -> handleItemAction(itemName)); newItem.setName(itemName); newItem.revalidate(); }
Example 6
Source File: BankPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void updateBankPinSizes() { for (final WidgetInfo widgetInfo : BANK_PINS) { final Widget pin = client.getWidget(widgetInfo); if (pin == null) { continue; } final Widget[] children = pin.getDynamicChildren(); if (children.length < 2) { continue; } final Widget button = children[0]; final Widget number = children[1]; // Change to a bigger font size number.setFontId(FontID.QUILL_CAPS_LARGE); number.setYTextAlignment(0); // Change size to match container widths number.setOriginalWidth(button.getWidth()); // The large font id text isn't centered, we need to offset it slightly number.setOriginalHeight(button.getHeight() + PIN_FONT_OFFSET); number.setOriginalY(-PIN_FONT_OFFSET); number.setOriginalX(0); number.revalidate(); } }
Example 7
Source File: TabInterface.java From plugins with GNU General Public License v3.0 | 5 votes |
private Widget createGraphic(Widget container, String name, int spriteId, int itemId, int width, int height, int x, int y, boolean hasListener) { Widget widget = container.createChild(-1, WidgetType.GRAPHIC); widget.setOriginalWidth(width); widget.setOriginalHeight(height); widget.setOriginalX(x); widget.setOriginalY(y); widget.setSpriteId(spriteId); if (itemId > -1) { widget.setItemId(itemId); widget.setItemQuantity(-1); widget.setBorderType(1); } if (hasListener) { widget.setOnOpListener(ScriptID.NULL); widget.setHasListener(true); } widget.setName(name); widget.revalidate(); return widget; }
Example 8
Source File: ChatboxPerformancePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private void fixWhiteLines(boolean upperLine) { int currOpacity = 256; int prevWidth = 0; Widget[] children = client.getWidget(WidgetInfo.CHATBOX_TRANSPARENT_LINES).getDynamicChildren(); Widget prev = null; for (Widget w : children) { if (w.getType() != WidgetType.RECTANGLE) { continue; } if ((w.getRelativeY() == 0 && !upperLine) || (w.getRelativeY() != 0 && upperLine)) { continue; } if (prev != null) { int width = w.getWidth(); prev.setWidthMode(WidgetSizeMode.ABSOLUTE); prev.setRelativeX(width); prev.setOriginalX(width); prev.setWidth(prevWidth - width); prev.setOriginalWidth(prev.getWidth()); prev.setOpacity(currOpacity); } prevWidth = w.getWidth(); currOpacity -= upperLine ? 3 : 4; // Rough numbers, can't get exactly the same as Jagex because of rounding prev = w; } if (prev != null) { prev.setOpacity(currOpacity); } }
Example 9
Source File: ItemStatPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private static Widget createText(Widget parent, String text, int fontId, int textColor, int x, int y, int width, int height) { final Widget widget = parent.createChild(-1, WidgetType.TEXT); widget.setText(text); widget.setFontId(fontId); widget.setTextColor(textColor); widget.setTextShadowed(true); widget.setOriginalHeight(height == -1 ? TEXT_HEIGHT : height); widget.setOriginalWidth(width); widget.setOriginalY(y); widget.setOriginalX(x); widget.revalidate(); return widget; }
Example 10
Source File: FriendsChatPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void loadFriendsChats() { Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST); if (chatList == null) { return; } int y = 2; chatList.setChildren(null); for (String chat : Lists.reverse(chats)) { Widget widget = chatList.createChild(-1, WidgetType.TEXT); widget.setFontId(494); widget.setHasListener(true); widget.setTextColor(0xffffff); widget.setText(chat); widget.setTextShadowed(true); widget.setBorderType(1); widget.setAction(0, String.format("Join %s", chat)); widget.setOnOpListener(ScriptID.CUSTOM_JOIN_CLAN, widget.getText()); widget.setOriginalHeight(14); widget.setOriginalWidth(142); widget.setOriginalY(y); widget.setOriginalX(20); widget.revalidate(); y += 14; } }
Example 11
Source File: ItemStatPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private static Widget createText(Widget parent, String text, int fontId, int textColor, int x, int y, int width, int height) { final Widget widget = parent.createChild(-1, WidgetType.TEXT); widget.setText(text); widget.setFontId(fontId); widget.setTextColor(textColor); widget.setTextShadowed(true); widget.setOriginalHeight(height == -1 ? TEXT_HEIGHT : height); widget.setOriginalWidth(width); widget.setOriginalY(y); widget.setOriginalX(x); widget.revalidate(); return widget; }
Example 12
Source File: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
private void updateTabs() { int y = bounds.y + MARGIN + BUTTON_HEIGHT; if (maxTabs >= tabManager.size()) { currentTabIndex = 0; } else { y -= (currentTabIndex * TAB_HEIGHT + currentTabIndex * MARGIN); } int itemX = BANK_ITEM_START_X; int itemY = BANK_ITEM_START_Y; int rowIndex = 0; for (TagTab tab : tabManager.getTabs()) { updateWidget(tab.getBackground(), y); updateWidget(tab.getIcon(), y + 4); // Edge case where item icon is 1 pixel out of bounds tab.getIcon().setHidden(tab.getBackground().isHidden()); // Keep item widget shown while drag scrolling if (client.getDraggedWidget() == tab.getIcon()) { tab.getIcon().setHidden(false); } y += TAB_HEIGHT + MARGIN; Widget item = tab.getMenu(); item.setOriginalX(itemX); item.setOriginalY(itemY); item.revalidate(); rowIndex++; if (rowIndex == BANK_ITEMS_PER_ROW) { itemX = BANK_ITEM_START_X; itemY += BANK_ITEM_Y_PADDING + BANK_ITEM_HEIGHT; rowIndex = 0; } else { itemX += BANK_ITEM_X_PADDING + BANK_ITEM_WIDTH; } } boolean hidden = !(tabManager.size() > 0); upButton.setHidden(hidden); upButton.setOriginalY(bounds.y); upButton.revalidate(); downButton.setHidden(hidden); downButton.setOriginalY(bounds.y + maxTabs * TAB_HEIGHT + MARGIN * maxTabs + BUTTON_HEIGHT + MARGIN); downButton.revalidate(); }
Example 13
Source File: WikiSearchChatboxTextInput.java From plugins with GNU General Public License v3.0 | 4 votes |
@Override protected void update() { Widget container = chatboxPanelManager.getContainerWidget(); container.deleteAllChildren(); Widget promptWidget = container.createChild(-1, WidgetType.TEXT); promptWidget.setText(getPrompt()); promptWidget.setTextColor(0x800000); promptWidget.setFontId(getFontID()); promptWidget.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); promptWidget.setOriginalX(0); promptWidget.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); promptWidget.setOriginalY(5); promptWidget.setOriginalHeight(LINE_HEIGHT); promptWidget.setXTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setYTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setWidthMode(WidgetSizeMode.MINUS); promptWidget.revalidate(); buildEdit(0, 5 + LINE_HEIGHT, container.getWidth(), LINE_HEIGHT); Widget separator = container.createChild(-1, WidgetType.LINE); separator.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); separator.setOriginalX(0); separator.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); separator.setOriginalY(4 + (LINE_HEIGHT * 2)); separator.setOriginalHeight(0); separator.setOriginalWidth(16); separator.setWidthMode(WidgetSizeMode.MINUS); separator.revalidate(); for (int i = 0; i < predictions.size(); i++) { String pred = predictions.get(i); int y = 6 + (LINE_HEIGHT * (2 + i)); Widget bg = container.createChild(-1, WidgetType.RECTANGLE); bg.setTextColor(0x4444DD); bg.setFilled(true); bg.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); bg.setOriginalX(1); bg.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); bg.setOriginalY(y); bg.setOriginalHeight(LINE_HEIGHT); bg.setOriginalWidth(16); bg.setWidthMode(WidgetSizeMode.MINUS); bg.revalidate(); bg.setName("<col=ff9040>" + pred); bg.setAction(0, "Open"); bg.setHasListener(true); bg.setOnOpListener((JavaScriptCallback) ev -> search(pred)); Widget text = container.createChild(-1, WidgetType.TEXT); text.setText(pred); text.setFontId(getFontID()); text.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); text.setOriginalX(0); text.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); text.setOriginalY(y); text.setOriginalHeight(LINE_HEIGHT); text.setXTextAlignment(WidgetTextAlignment.CENTER); text.setYTextAlignment(WidgetTextAlignment.CENTER); text.setWidthMode(WidgetSizeMode.MINUS); text.revalidate(); if (i == selectedPrediction) { text.setTextColor(0xFFFFFF); } else { bg.setOpacity(255); text.setTextColor(0x000000); bg.setOnMouseRepeatListener((JavaScriptCallback) ev -> text.setTextColor(0xFFFFFF)); bg.setOnMouseLeaveListener((JavaScriptCallback) ev -> text.setTextColor(0x000000)); } } }
Example 14
Source File: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
public void init() { if (isHidden()) { return; } currentTabIndex = config.position(); parent = client.getWidget(WidgetInfo.BANK_CONTENT_CONTAINER); updateBounds(); upButton = createGraphic("", TabSprites.UP_ARROW.getSpriteId(), -1, TAB_WIDTH, BUTTON_HEIGHT, bounds.x, 0, true); upButton.setAction(1, SCROLL_UP); int clickmask = upButton.getClickMask(); clickmask |= WidgetConfig.DRAG; upButton.setClickMask(clickmask); upButton.setOnOpListener((JavaScriptCallback) (event) -> scrollTab(-1)); downButton = createGraphic("", TabSprites.DOWN_ARROW.getSpriteId(), -1, TAB_WIDTH, BUTTON_HEIGHT, bounds.x, 0, true); downButton.setAction(1, SCROLL_DOWN); clickmask = downButton.getClickMask(); clickmask |= WidgetConfig.DRAG; downButton.setClickMask(clickmask); downButton.setOnOpListener((JavaScriptCallback) (event) -> scrollTab(1)); newTab = createGraphic("", TabSprites.NEW_TAB.getSpriteId(), -1, TAB_WIDTH, 39, bounds.x, 0, true); newTab.setAction(1, NEW_TAB); newTab.setAction(2, IMPORT_TAB); newTab.setAction(3, OPEN_TAB_MENU); newTab.setOnOpListener((JavaScriptCallback) this::handleNewTab); tabManager.clear(); tabManager.getAllTabs().forEach(this::loadTab); activateTab(null); scrollTab(0); if (config.rememberTab() && !Strings.isNullOrEmpty(config.tab())) { // the server will resync the last opened vanilla tab when the bank is opened client.setVarbit(Varbits.CURRENT_BANK_TAB, 0); openTag(config.tab()); } Widget equipmentButton = client.getWidget(WidgetInfo.BANK_EQUIPMENT_BUTTON); Widget titleBar = client.getWidget(WidgetInfo.BANK_TITLE_BAR); if (equipmentButton == null || titleBar == null || titleBar.getOriginalX() > 0) { // don't keep moving widgets if they have already been moved return; } equipmentButton.setOriginalX(6); equipmentButton.setOriginalY(4); equipmentButton.revalidate(); // the bank item count is 3 widgets for (int child = WidgetInfo.BANK_ITEM_COUNT_TOP.getChildId(); child <= WidgetInfo.BANK_ITEM_COUNT_BOTTOM.getChildId(); child++) { Widget widget = client.getWidget(WidgetID.BANK_GROUP_ID, child); if (widget == null) { return; } widget.setOriginalX(widget.getOriginalX() + equipmentButton.getWidth()); widget.revalidate(); } titleBar.setOriginalX(equipmentButton.getWidth() / 2); titleBar.setOriginalWidth(titleBar.getWidth() - equipmentButton.getWidth()); titleBar.revalidate(); }
Example 15
Source File: WikiSearchChatboxTextInput.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Override protected void update() { Widget container = chatboxPanelManager.getContainerWidget(); container.deleteAllChildren(); Widget promptWidget = container.createChild(-1, WidgetType.TEXT); promptWidget.setText(getPrompt()); promptWidget.setTextColor(0x800000); promptWidget.setFontId(getFontID()); promptWidget.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); promptWidget.setOriginalX(0); promptWidget.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); promptWidget.setOriginalY(5); promptWidget.setOriginalHeight(LINE_HEIGHT); promptWidget.setXTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setYTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setWidthMode(WidgetSizeMode.MINUS); promptWidget.revalidate(); buildEdit(0, 5 + LINE_HEIGHT, container.getWidth(), LINE_HEIGHT); Widget separator = container.createChild(-1, WidgetType.LINE); separator.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); separator.setOriginalX(0); separator.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); separator.setOriginalY(4 + (LINE_HEIGHT * 2)); separator.setOriginalHeight(0); separator.setOriginalWidth(16); separator.setWidthMode(WidgetSizeMode.MINUS); separator.revalidate(); for (int i = 0; i < predictions.size(); i++) { String pred = predictions.get(i); int y = 6 + (LINE_HEIGHT * (2 + i)); Widget bg = container.createChild(-1, WidgetType.RECTANGLE); bg.setTextColor(0x4444DD); bg.setFilled(true); bg.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); bg.setOriginalX(1); bg.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); bg.setOriginalY(y); bg.setOriginalHeight(LINE_HEIGHT); bg.setOriginalWidth(16); bg.setWidthMode(WidgetSizeMode.MINUS); bg.revalidate(); bg.setName("<col=ff9040>" + pred); bg.setAction(0, "Open"); bg.setHasListener(true); bg.setOnOpListener((JavaScriptCallback) ev -> search(pred)); Widget text = container.createChild(-1, WidgetType.TEXT); text.setText(pred); text.setFontId(getFontID()); text.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); text.setOriginalX(0); text.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); text.setOriginalY(y); text.setOriginalHeight(LINE_HEIGHT); text.setXTextAlignment(WidgetTextAlignment.CENTER); text.setYTextAlignment(WidgetTextAlignment.CENTER); text.setWidthMode(WidgetSizeMode.MINUS); text.revalidate(); if (i == selectedPrediction) { text.setTextColor(0xFFFFFF); } else { bg.setOpacity(255); text.setTextColor(0x000000); bg.setOnMouseRepeatListener((JavaScriptCallback) ev -> text.setTextColor(0xFFFFFF)); bg.setOnMouseLeaveListener((JavaScriptCallback) ev -> text.setTextColor(0x000000)); } } }
Example 16
Source File: ChatboxTextMenuInput.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Override protected void open() { Widget container = chatboxPanelManager.getContainerWidget(); Widget prompt = container.createChild(-1, WidgetType.TEXT); prompt.setText(title); prompt.setTextColor(0x800000); prompt.setFontId(FontID.QUILL_8); prompt.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); prompt.setOriginalX(0); prompt.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); prompt.setOriginalY(8); prompt.setOriginalHeight(24); prompt.setXTextAlignment(WidgetTextAlignment.CENTER); prompt.setYTextAlignment(WidgetTextAlignment.CENTER); prompt.setWidthMode(WidgetSizeMode.MINUS); prompt.revalidate(); int y = prompt.getRelativeX() + prompt.getHeight() + 6; int height = container.getHeight() - y - 8; int step = height / options.size(); int maxStep = options.size() >= 3 ? 25 : 30; if (step > maxStep) { int ds = step - maxStep; step = maxStep; y += (ds * options.size()) / 2; } for (Entry option : options) { Widget optWidget = container.createChild(-1, WidgetType.TEXT); optWidget.setText(option.text); optWidget.setFontId(FontID.QUILL_8); optWidget.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); optWidget.setOriginalX(0); optWidget.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); optWidget.setOriginalY(y); optWidget.setOriginalHeight(24); optWidget.setXTextAlignment(WidgetTextAlignment.CENTER); optWidget.setYTextAlignment(WidgetTextAlignment.CENTER); optWidget.setWidthMode(WidgetSizeMode.MINUS); optWidget.setAction(0, "Continue"); optWidget.setOnOpListener((JavaScriptCallback) ev -> callback(option)); optWidget.setOnMouseOverListener((JavaScriptCallback) ev -> optWidget.setTextColor(0xFFFFFF)); optWidget.setOnMouseLeaveListener((JavaScriptCallback) ev -> optWidget.setTextColor(0)); optWidget.setHasListener(true); optWidget.revalidate(); y += step; } }
Example 17
Source File: Anonymizer.java From ExternalPlugins with GNU General Public License v3.0 | 4 votes |
@Subscribe public void onBeforeRender(BeforeRender event) { if (!config.hideRsn() || client == null || client.getGameState() != GameState.LOGGED_IN || name.isBlank() || name.isEmpty()) { return; } RSClient rsClient = (RSClient) client; if (rsClient == null || rsClient.getWidgets() == null) { return; } for (RSWidget[] parent : rsClient.getWidgets()) { if (parent == null) { continue; } for (RSWidget widget : parent) { parseWidget(widget); if (widget.getDynamicChildren() != null && widget.getDynamicChildren().length > 0) { Widget[] dynamicChildren = widget.getDynamicChildren(); for (int i = 0; i < dynamicChildren.length; i++) { Widget dynamicChild = dynamicChildren[i]; if (dynamicChild.getId() == 10616890 && dynamicChild.getText().contains(name)) { parseWidget(dynamicChild); try { Widget text = dynamicChildren[i + 1]; text.setOriginalX(80); text.revalidate(); } catch (Exception ignored) { } } } } if (widget.getStaticChildren() != null && widget.getStaticChildren().length > 0) { for (Widget staticChild : widget.getStaticChildren()) { parseWidget(staticChild); } } if (widget.getNestedChildren() != null && widget.getNestedChildren().length > 0) { for (Widget nestedChild : widget.getNestedChildren()) { parseWidget(nestedChild); } } } } }
Example 18
Source File: VirtualLevelsInterfaceInput.java From plugins with GNU General Public License v3.0 | 4 votes |
@Override public void open() { // TODO: add sound event for level-up (need to find sound IDs) plugin.getClientThread().invoke(this::setFireworksGraphic); final Widget chatboxContainer = plugin.getChatboxPanelManager().getContainerWidget(); final String skillName = skill.getName(); final int skillLevel = Experience.getLevelForXp(plugin.getClient().getSkillExperience(skill)); final List<SkillModel> skillModels = SkillModel.getSKILL_MODELS(skill); final String prefix = (skill == Skill.AGILITY || skill == Skill.ATTACK) ? "an " : "a "; final Widget levelUpLevel = chatboxContainer.createChild(-1, WidgetType.TEXT); final Widget levelUpText = chatboxContainer.createChild(-1, WidgetType.TEXT); final Widget levelUpContinue = chatboxContainer.createChild(-1, WidgetType.TEXT); levelUpLevel.setText("Congratulations, you just advanced " + prefix + skillName + " level."); levelUpLevel.setTextColor(Color.BLACK.getRGB()); levelUpLevel.setFontId(FontID.QUILL_8); levelUpLevel.setXPositionMode(WidgetPositionMode.ABSOLUTE_TOP); levelUpLevel.setOriginalX(73 + X_OFFSET); levelUpLevel.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); levelUpLevel.setOriginalY(15 + Y_OFFSET); levelUpLevel.setOriginalWidth(390); levelUpLevel.setOriginalHeight(30); levelUpLevel.setXTextAlignment(WidgetTextAlignment.CENTER); levelUpLevel.setYTextAlignment(WidgetTextAlignment.LEFT); levelUpLevel.setWidthMode(WidgetSizeMode.ABSOLUTE); levelUpLevel.revalidate(); levelUpText.setText((skill == Skill.HITPOINTS ? "Your Hitpoints are now " + skillLevel : "Your " + skillName + " level is now " + skillLevel) + '.'); levelUpText.setFontId(FontID.QUILL_8); levelUpText.setXPositionMode(WidgetPositionMode.ABSOLUTE_TOP); levelUpText.setOriginalX(73 + X_OFFSET); levelUpText.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); levelUpText.setOriginalY(44 + Y_OFFSET); levelUpText.setOriginalWidth(390); levelUpText.setOriginalHeight(30); levelUpText.setXTextAlignment(WidgetTextAlignment.CENTER); levelUpText.setYTextAlignment(WidgetTextAlignment.LEFT); levelUpText.setWidthMode(WidgetSizeMode.ABSOLUTE); levelUpText.revalidate(); levelUpContinue.setText("Click here to continue"); levelUpContinue.setTextColor(Color.BLUE.getRGB()); levelUpContinue.setFontId(FontID.QUILL_8); levelUpContinue.setXPositionMode(WidgetPositionMode.ABSOLUTE_TOP); levelUpContinue.setOriginalX(73 + X_OFFSET); levelUpContinue.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); levelUpContinue.setOriginalY(74 + Y_OFFSET); levelUpContinue.setOriginalWidth(390); levelUpContinue.setOriginalHeight(17); levelUpContinue.setXTextAlignment(WidgetTextAlignment.CENTER); levelUpContinue.setYTextAlignment(WidgetTextAlignment.LEFT); levelUpContinue.setWidthMode(WidgetSizeMode.ABSOLUTE); levelUpContinue.setAction(0, "Continue"); levelUpContinue.setOnOpListener((JavaScriptCallback) ev -> triggerCloseViaMessage()); levelUpContinue.setOnMouseOverListener((JavaScriptCallback) ev -> levelUpContinue.setTextColor(Color.WHITE.getRGB())); levelUpContinue.setOnMouseLeaveListener((JavaScriptCallback) ev -> levelUpContinue.setTextColor(Color.BLUE.getRGB())); levelUpContinue.setHasListener(true); levelUpContinue.revalidate(); for (SkillModel skillModel : skillModels) { buildWidgetModel(chatboxContainer, skillModel); } plugin.takeScreenshot(skill); }
Example 19
Source File: TabInterface.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateTabs() { int y = bounds.y + MARGIN + BUTTON_HEIGHT; if (maxTabs >= tabManager.size()) { currentTabIndex = 0; } else { y -= (currentTabIndex * TAB_HEIGHT + currentTabIndex * MARGIN); } int itemX = BANK_ITEM_START_X; int itemY = BANK_ITEM_START_Y; int rowIndex = 0; for (TagTab tab : tabManager.getTabs()) { updateWidget(tab.getBackground(), y); updateWidget(tab.getIcon(), y + 4); // Edge case where item icon is 1 pixel out of bounds tab.getIcon().setHidden(tab.getBackground().isHidden()); // Keep item widget shown while drag scrolling if (client.getDraggedWidget() == tab.getIcon()) { tab.getIcon().setHidden(false); } y += TAB_HEIGHT + MARGIN; Widget item = tab.getMenu(); item.setOriginalX(itemX); item.setOriginalY(itemY); item.revalidate(); rowIndex++; if (rowIndex == BANK_ITEMS_PER_ROW) { itemX = BANK_ITEM_START_X; itemY += BANK_ITEM_Y_PADDING + BANK_ITEM_HEIGHT; rowIndex = 0; } else { itemX += BANK_ITEM_X_PADDING + BANK_ITEM_WIDTH; } } boolean hidden = !(tabManager.size() > 0); upButton.setHidden(hidden); upButton.setOriginalY(bounds.y); upButton.revalidate(); downButton.setHidden(hidden); downButton.setOriginalY(bounds.y + maxTabs * TAB_HEIGHT + MARGIN * maxTabs + BUTTON_HEIGHT + MARGIN); downButton.revalidate(); }
Example 20
Source File: BronzeManPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateList(Widget collectionView, String filter) { if (itemEntries == null) { itemEntries = Arrays.stream(collectionView.getDynamicChildren()) .sorted(Comparator.comparing(Widget::getRelativeY)) .collect(Collectors.toList()); } itemEntries.forEach(w -> w.setHidden(true)); Collection<Widget> matchingItems = itemEntries.stream() .filter(w -> w.getName().toLowerCase().contains(filter)) .collect(Collectors.toList()); int x = 0; int y = 0; for (Widget entry : matchingItems) { entry.setHidden(false); entry.setOriginalY(y); entry.setOriginalX(x); entry.revalidate(); x = x + 42; if (x > 210) { x = 0; y = y + 40; } } y += 3; int newHeight = 0; if (collectionView.getScrollHeight() > 0) { newHeight = (collectionView.getScrollY() * y) / collectionView.getScrollHeight(); } collectionView.setScrollHeight(y); collectionView.revalidateScroll(); Widget scrollbar = client.getWidget(COLLECTION_LOG_GROUP_ID, COLLECTION_VIEW_SCROLLBAR); client.runScript( ScriptID.UPDATE_SCROLLBAR, scrollbar.getId(), collectionView.getId(), newHeight ); }