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

The following examples show how to use net.runelite.api.widgets.Widget#setOpacity() . 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: BronzeManPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void filterResults()
{
	Widget grandExchangeWindow = client.getWidget(162, 53);
	if (grandExchangeWindow == null)
	{
		return;
	}
	if (client.getWidget(162, 53) == null)
	{
		return;
	}

	Widget[] children = client.getWidget(162, 53).getChildren();
	if (children == null)
	{
		return;
	}

	for (int i = 0; i < children.length; i += 3)
	{
		if (children[i] == null)
		{
			continue;
		}
		if (i + 2 > children.length - 1 || children[i + 2] == null)
		{
			continue;
		}

		if (!unlockedItems.contains(children[i + 2].getItemId()))
		{
			children[i].setHidden(true);
			Widget text = children[i + 1];
			Widget image = children[i + 2];
			text.setTextColor(textColor.getRGB());
			text.setOpacity(210);
			image.setOpacity(210);
		}
	}
}
 
Example 2
Source File: ChatboxPerformancePlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void fixDarkBackground()
{
	int currOpacity = 256;
	int prevY = 0;
	Widget[] children = client.getWidget(WidgetInfo.CHATBOX_TRANSPARENT_BACKGROUND).getDynamicChildren();
	Widget prev = null;
	for (Widget w : children)
	{
		if (w.getType() != WidgetType.RECTANGLE)
		{
			continue;
		}

		if (prev != null)
		{
			int relY = w.getRelativeY();
			prev.setHeightMode(WidgetSizeMode.ABSOLUTE);
			prev.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP);
			prev.setRelativeY(prevY);
			prev.setOriginalY(prev.getRelativeY());
			prev.setHeight(relY - prevY);
			prev.setOriginalHeight(prev.getHeight());
			prev.setOpacity(currOpacity);
		}

		prevY = w.getRelativeY();
		currOpacity -= 3; // Rough number, can't get exactly the same as Jagex because of rounding
		prev = w;
	}
	if (prev != null)
	{
		prev.setOpacity(currOpacity);
	}
}
 
Example 3
Source File: ChatboxPerformancePlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 4
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 5
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 6
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));
		}
	}
}