Java Code Examples for net.runelite.api.widgets.Widget#deleteAllChildren()

The following examples show how to use net.runelite.api.widgets.Widget#deleteAllChildren() . 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: ItemStatPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void resetGEInventory()
{
	final Widget invContainer = getInventoryContainer();

	if (invContainer == null)
	{
		return;
	}

	if (itemInformationTitle != null && invContainer.getChild(0) == itemInformationTitle)
	{
		invContainer.deleteAllChildren();
		itemInformationTitle = null;
	}

	final Widget geInv = client.getWidget(WidgetInfo.GRAND_EXCHANGE_INVENTORY_ITEMS_CONTAINER);
	if (geInv != null)
	{
		geInv.setHidden(false);
	}
}
 
Example 2
Source File: ChatboxTextInput.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 3
Source File: ItemStatPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void resetGEInventory()
{
	final Widget invContainer = getInventoryContainer();

	if (invContainer == null)
	{
		return;
	}

	if (itemInformationTitle != null && invContainer.getChild(0) == itemInformationTitle)
	{
		invContainer.deleteAllChildren();
		itemInformationTitle = null;
	}

	final Widget geInv = client.getWidget(WidgetInfo.GRAND_EXCHANGE_INVENTORY_ITEMS_CONTAINER);
	if (geInv != null)
	{
		geInv.setHidden(false);
	}
}
 
Example 4
Source File: MusicPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void shutDown()
{
	Widget header = client.getWidget(WidgetInfo.MUSIC_WINDOW);
	if (header != null)
	{
		header.deleteAllChildren();
	}

	tracks = null;
	hoveredSlider = null;

	clientThread.invoke(this::teardownMusicOptions);
}
 
Example 5
Source File: MusicPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void addMusicButtons()
{
	Widget header = client.getWidget(WidgetInfo.MUSIC_WINDOW);

	if (header == null)
	{
		return;
	}

	header.deleteAllChildren();

	//Creation of the search and toggle status buttons
	musicSearchButton = header.createChild(-1, WidgetType.GRAPHIC);
	musicSearchButton.setSpriteId(SpriteID.GE_SEARCH);
	musicSearchButton.setOriginalWidth(18);
	musicSearchButton.setOriginalHeight(17);
	musicSearchButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
	musicSearchButton.setOriginalX(5);
	musicSearchButton.setOriginalY(32);
	musicSearchButton.setHasListener(true);
	musicSearchButton.setAction(1, "Open");
	musicSearchButton.setOnOpListener((JavaScriptCallback) e -> openSearch());
	musicSearchButton.setName("Search");
	musicSearchButton.revalidate();

	musicFilterButton = header.createChild(-1, WidgetType.GRAPHIC);
	musicFilterButton.setSpriteId(SpriteID.MINIMAP_ORB_PRAYER);
	musicFilterButton.setOriginalWidth(15);
	musicFilterButton.setOriginalHeight(15);
	musicFilterButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
	musicFilterButton.setOriginalX(25);
	musicFilterButton.setOriginalY(34);
	musicFilterButton.setHasListener(true);
	musicFilterButton.setAction(1, "Toggle");
	musicFilterButton.setOnOpListener((JavaScriptCallback) e -> toggleStatus());
	musicFilterButton.setName("All");
	musicFilterButton.revalidate();
}
 
Example 6
Source File: QuestListPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void shutDown()
{
	currentFilterState = null;
	Widget header = client.getWidget(WidgetInfo.QUESTLIST_BOX);
	if (header != null)
	{
		header.deleteAllChildren();
	}
}
 
Example 7
Source File: QuestListPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void addQuestButtons()
{
	Widget header = client.getWidget(WidgetInfo.QUESTLIST_BOX);
	if (header != null)
	{
		header.deleteAllChildren();

		questSearchButton = header.createChild(-1, WidgetType.GRAPHIC);
		questSearchButton.setSpriteId(SpriteID.GE_SEARCH);
		questSearchButton.setOriginalWidth(18);
		questSearchButton.setOriginalHeight(17);
		questSearchButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
		questSearchButton.setOriginalX(5);
		questSearchButton.setOriginalY(0);
		questSearchButton.setHasListener(true);
		questSearchButton.setAction(1, MENU_OPEN);
		questSearchButton.setOnOpListener((JavaScriptCallback) e -> openSearch());
		questSearchButton.setName(MENU_SEARCH);
		questSearchButton.revalidate();

		questHideButton = header.createChild(-1, WidgetType.GRAPHIC);
		redrawHideButton();

		questHideButton.setOriginalWidth(13);
		questHideButton.setOriginalHeight(13);
		questHideButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
		questHideButton.setOriginalX(24);
		questHideButton.setOriginalY(2);
		questHideButton.setHasListener(true);
		questHideButton.setOnOpListener((JavaScriptCallback) e -> toggleHidden());
		questHideButton.setAction(1, MENU_TOGGLE);
		questHideButton.revalidate();

		questSet = new EnumMap<>(QuestContainer.class);

		updateFilter();
	}
}
 
Example 8
Source File: ChatboxPanelManager.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void unsafeOpenInput(ChatboxInput input)
{
	client.runScript(ScriptID.MESSAGE_LAYER_OPEN, 0);

	eventBus.register(input);
	if (input instanceof KeyListener)
	{
		keyManager.registerKeyListener((KeyListener) input);
	}
	if (input instanceof MouseListener)
	{
		mouseManager.registerMouseListener((MouseListener) input);
	}
	if (input instanceof MouseWheelListener)
	{
		mouseManager.registerMouseWheelListener((MouseWheelListener) input);
	}

	if (currentInput != null)
	{
		killCurrentPanel();
	}

	currentInput = input;
	client.setVar(VarClientInt.INPUT_TYPE, InputType.RUNELITE_CHATBOX_PANEL.getType());
	client.getWidget(WidgetInfo.CHATBOX_TITLE).setHidden(true);
	client.getWidget(WidgetInfo.CHATBOX_FULL_INPUT).setHidden(true);

	Widget c = getContainerWidget();
	c.deleteAllChildren();
	c.setOnDialogAbortListener((JavaScriptCallback) ev -> this.unsafeCloseInput());
	input.open();
}
 
Example 9
Source File: MusicPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void shutDown()
{
	Widget header = client.getWidget(WidgetInfo.MUSIC_WINDOW);
	if (header != null)
	{
		header.deleteAllChildren();
	}

	tracks = null;
	hoveredSlider = null;
	clientThread.invoke(this::teardownMusicOptions);
}
 
Example 10
Source File: MusicPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addMusicButtons()
{
	Widget header = client.getWidget(WidgetInfo.MUSIC_WINDOW);

	if (header == null)
	{
		return;
	}

	header.deleteAllChildren();

	//Creation of the search and toggle status buttons
	musicSearchButton = header.createChild(-1, WidgetType.GRAPHIC);
	musicSearchButton.setSpriteId(SpriteID.GE_SEARCH);
	musicSearchButton.setOriginalWidth(18);
	musicSearchButton.setOriginalHeight(17);
	musicSearchButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
	musicSearchButton.setOriginalX(5);
	musicSearchButton.setOriginalY(32);
	musicSearchButton.setHasListener(true);
	musicSearchButton.setAction(1, "Open");
	musicSearchButton.setOnOpListener((JavaScriptCallback) e -> openSearch());
	musicSearchButton.setName("Search");
	musicSearchButton.revalidate();

	musicFilterButton = header.createChild(-1, WidgetType.GRAPHIC);
	musicFilterButton.setSpriteId(SpriteID.MINIMAP_ORB_PRAYER);
	musicFilterButton.setOriginalWidth(15);
	musicFilterButton.setOriginalHeight(15);
	musicFilterButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
	musicFilterButton.setOriginalX(25);
	musicFilterButton.setOriginalY(34);
	musicFilterButton.setHasListener(true);
	musicFilterButton.setAction(1, "Toggle");
	musicFilterButton.setOnOpListener((JavaScriptCallback) e -> toggleStatus());
	musicFilterButton.setName("All");
	musicFilterButton.revalidate();
}
 
Example 11
Source File: QuestListPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void shutDown()
{
	currentFilterState = null;
	Widget header = client.getWidget(WidgetInfo.QUESTLIST_BOX);
	if (header != null)
	{
		header.deleteAllChildren();
	}
}
 
Example 12
Source File: QuestListPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addQuestButtons()
{
	Widget header = client.getWidget(WidgetInfo.QUESTLIST_BOX);
	if (header != null)
	{
		header.deleteAllChildren();

		questSearchButton = header.createChild(-1, WidgetType.GRAPHIC);
		questSearchButton.setSpriteId(SpriteID.GE_SEARCH);
		questSearchButton.setOriginalWidth(18);
		questSearchButton.setOriginalHeight(17);
		questSearchButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
		questSearchButton.setOriginalX(5);
		questSearchButton.setOriginalY(0);
		questSearchButton.setHasListener(true);
		questSearchButton.setAction(1, MENU_OPEN);
		questSearchButton.setOnOpListener((JavaScriptCallback) e -> openSearch());
		questSearchButton.setName(MENU_SEARCH);
		questSearchButton.revalidate();

		questHideButton = header.createChild(-1, WidgetType.GRAPHIC);
		redrawHideButton();

		questHideButton.setOriginalWidth(13);
		questHideButton.setOriginalHeight(13);
		questHideButton.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
		questHideButton.setOriginalX(24);
		questHideButton.setOriginalY(2);
		questHideButton.setHasListener(true);
		questHideButton.setOnOpListener((JavaScriptCallback) e -> toggleHidden());
		questHideButton.setAction(1, MENU_TOGGLE);
		questHideButton.revalidate();

		questSet = new EnumMap<>(QuestContainer.class);

		updateFilter();
	}
}
 
Example 13
Source File: WikiSearchChatboxTextInput.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@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: ChatboxItemSearch.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@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.setOriginalX(0);
	promptWidget.setOriginalY(5);
	promptWidget.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER);
	promptWidget.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP);
	promptWidget.setOriginalHeight(FONT_SIZE);
	promptWidget.setXTextAlignment(WidgetTextAlignment.CENTER);
	promptWidget.setYTextAlignment(WidgetTextAlignment.CENTER);
	promptWidget.setWidthMode(WidgetSizeMode.MINUS);
	promptWidget.revalidate();

	buildEdit(0, 5 + FONT_SIZE, container.getWidth(), FONT_SIZE);

	Widget separator = container.createChild(-1, WidgetType.LINE);
	separator.setOriginalX(0);
	separator.setOriginalY(8 + (FONT_SIZE * 2));
	separator.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER);
	separator.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP);
	separator.setOriginalHeight(0);
	separator.setOriginalWidth(16);
	separator.setWidthMode(WidgetSizeMode.MINUS);
	separator.setTextColor(0x666666);
	separator.revalidate();

	int x = PADDING;
	int y = PADDING * 3;
	int idx = 0;
	for (ItemComposition itemComposition : results.values())
	{
		Widget item = container.createChild(-1, WidgetType.GRAPHIC);
		item.setXPositionMode(WidgetPositionMode.ABSOLUTE_LEFT);
		item.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP);
		item.setOriginalX(x);
		item.setOriginalY(y + FONT_SIZE * 2);
		item.setOriginalHeight(ICON_HEIGHT);
		item.setOriginalWidth(ICON_WIDTH);
		item.setName("<col=ff9040>" + itemComposition.getName());
		item.setItemId(itemComposition.getId());
		item.setItemQuantity(10000);
		item.setItemQuantityMode(ItemQuantityMode.NEVER);
		item.setBorderType(1);
		item.setAction(0, tooltipText);
		item.setHasListener(true);

		if (index == idx)
		{
			item.setOpacity(HOVERED_OPACITY);
		}
		else
		{
			item.setOnMouseOverListener((JavaScriptCallback) ev -> item.setOpacity(HOVERED_OPACITY));
			item.setOnMouseLeaveListener((JavaScriptCallback) ev -> item.setOpacity(0));
		}

		item.setOnOpListener((JavaScriptCallback) ev ->
		{
			if (onItemSelected != null)
			{
				onItemSelected.accept(itemComposition.getId());
			}

			chatboxPanelManager.close();
		});

		x += ICON_WIDTH + PADDING;
		if (x + ICON_WIDTH >= container.getWidth())
		{
			y += ICON_HEIGHT + PADDING;
			x = PADDING;
		}

		item.revalidate();
		++idx;
	}
}
 
Example 15
Source File: WikiSearchChatboxTextInput.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@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));
		}
	}
}