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

The following examples show how to use net.runelite.api.widgets.Widget#setText() . 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 vote down vote up
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: 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: CombatLevelPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void shutDown() throws Exception
{
	overlayManager.remove(overlay);
	Widget combatLevelWidget = client.getWidget(WidgetInfo.COMBAT_LEVEL);

	if (combatLevelWidget != null)
	{
		String widgetText = combatLevelWidget.getText();

		if (widgetText.contains("."))
		{
			combatLevelWidget.setText(widgetText.substring(0, widgetText.indexOf(".")));
		}
	}

	shutDownAttackLevelRange();
}
 
Example 4
Source File: CombatLevelPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameTick(GameTick event)
{
	if (client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	Widget combatLevelWidget = client.getWidget(WidgetInfo.COMBAT_LEVEL);
	if (combatLevelWidget == null || !config.showPreciseCombatLevel())
	{
		return;
	}

	double combatLevelPrecise = Experience.getCombatLevelPrecise(
		client.getRealSkillLevel(Skill.ATTACK),
		client.getRealSkillLevel(Skill.STRENGTH),
		client.getRealSkillLevel(Skill.DEFENCE),
		client.getRealSkillLevel(Skill.HITPOINTS),
		client.getRealSkillLevel(Skill.MAGIC),
		client.getRealSkillLevel(Skill.RANGED),
		client.getRealSkillLevel(Skill.PRAYER)
	);

	combatLevelWidget.setText("Combat Lvl: " + DECIMAL_FORMAT.format(combatLevelPrecise));
}
 
Example 5
Source File: BankPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void updateSeedVaultTotal()
{
	final Widget titleContainer = client.getWidget(WidgetInfo.SEED_VAULT_TITLE_CONTAINER);
	if (titleContainer == null)
	{
		return;
	}

	final Widget[] children = titleContainer.getDynamicChildren();
	if (children == null || children.length < 2)
	{
		return;
	}

	final ContainerPrices prices = calculate(getSeedVaultItems());
	if (prices == null)
	{
		return;
	}

	final String titleText = createValueText(prices);

	final Widget title = children[1];
	title.setText(SEED_VAULT_TITLE + titleText);
}
 
Example 6
Source File: BankPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void updateSeedVaultTotal()
{
	final Widget titleContainer = client.getWidget(WidgetInfo.SEED_VAULT_TITLE_CONTAINER);
	if (titleContainer == null)
	{
		return;
	}

	final Widget[] children = titleContainer.getDynamicChildren();
	if (children == null || children.length < 2)
	{
		return;
	}

	final ContainerPrices prices = calculate(getSeedVaultItems());
	if (prices == null)
	{
		return;
	}

	final String titleText = createValueText(prices);

	final Widget title = children[1];
	title.setText(SEED_VAULT_TITLE + titleText);
}
 
Example 7
Source File: FriendsChatPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onGameTick(GameTick gameTick)
{
	if (client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	client.setVar(VarClientStr.RECENT_FRIENDS_CHAT, config.friendschatName());

	Widget chatTitleWidget = client.getWidget(WidgetInfo.FRIENDS_CHAT_TITLE);
	if (chatTitleWidget != null)
	{
		Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST);
		Widget owner = client.getWidget(WidgetInfo.FRIENDS_CHAT_OWNER);
		FriendsChatManager friendsChatManager = client.getFriendsChatManager();
		if (friendsChatManager != null && friendsChatManager.getCount() > 0)
		{
			chatTitleWidget.setText(TITLE + " (" + friendsChatManager.getCount() + "/100)");
		}
		else if (config.recentChats() && chatList.getChildren() == null && !Strings.isNullOrEmpty(owner.getText()))
		{
			chatTitleWidget.setText(RECENT_TITLE);

			loadFriendsChats();
		}
	}

	if (!config.showJoinLeave())
	{
		return;
	}

	timeoutMessages();

	addActivityMessages();
}
 
Example 8
Source File: FriendsChatPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
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 9
Source File: ReportButtonPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void updateReportButtonTime()
{
	if (client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	Widget reportButton = client.getWidget(WidgetInfo.CHATBOX_REPORT_TEXT);
	if (reportButton == null)
	{
		return;
	}

	switch (config.time())
	{
		case UTC:
			reportButton.setText(getUTCTime());
			break;
		case JAGEX:
			reportButton.setText(getJagexTime());
			break;
		case LOCAL_TIME:
			reportButton.setText(getLocalTime());
			break;
		case LOGIN_TIME:
			reportButton.setText(getLoginTime());
			break;
		case DATE:
			reportButton.setText(getDate());
			break;
		case GAME_TICKS:
			reportButton.setText(getGameTicks());
			break;
		case OFF:
			reportButton.setText("Report");
			break;
	}
}
 
Example 10
Source File: KeyRemappingPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void setChatboxWidgetInput(Widget widget, String input)
{
	String text = widget.getText();
	int idx = text.indexOf(':');
	if (idx != -1)
	{
		String newText = text.substring(0, idx) + ": " + input;
		widget.setText(newText);
	}
}
 
Example 11
Source File: PuzzleSolverPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onWidgetLoaded(WidgetLoaded widget)
{
	if (widget.getGroupId() != WidgetID.VARROCK_MUSEUM_QUIZ_GROUP_ID)
	{
		return;
	}

	final Widget questionWidget = client.getWidget(WidgetInfo.VARROCK_MUSEUM_QUESTION);

	if (questionWidget == null)
	{
		return;
	}

	final Widget answerWidget = VarrockMuseumAnswer.findCorrect(
		client,
		questionWidget.getText(),
		WidgetInfo.VARROCK_MUSEUM_FIRST_ANSWER,
		WidgetInfo.VARROCK_MUSEUM_SECOND_ANSWER,
		WidgetInfo.VARROCK_MUSEUM_THIRD_ANSWER);

	if (answerWidget == null)
	{
		return;
	}

	final String answerText = answerWidget.getText();
	if (answerText.equals(Text.removeTags(answerText)))
	{
		answerWidget.setText(ColorUtil.wrapWithColorTag(answerText, CORRECT_MUSEUM_PUZZLE_ANSWER_COLOR));
	}
}
 
Example 12
Source File: FriendsChatPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onGameTick(GameTick gameTick)
{
	if (client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	Widget chatTitleWidget = client.getWidget(WidgetInfo.FRIENDS_CHAT_TITLE);
	if (chatTitleWidget != null)
	{
		Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST);
		Widget owner = client.getWidget(WidgetInfo.FRIENDS_CHAT_OWNER);
		FriendsChatManager friendsChatManager = client.getFriendsChatManager();
		if (friendsChatManager != null && friendsChatManager.getCount() > 0)
		{
			chatTitleWidget.setText(TITLE + " (" + friendsChatManager.getCount() + "/100)");
		}
		else if (config.recentChats() && chatList.getChildren() == null && !Strings.isNullOrEmpty(owner.getText()))
		{
			chatTitleWidget.setText(RECENT_TITLE);

			loadFriendsChats();
		}
	}

	if (!config.showJoinLeave())
	{
		return;
	}

	timeoutMessages();

	addActivityMessages();
}
 
Example 13
Source File: LeagueChatIconsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Update the player name in the chatbox input
 */
private void setChatboxName(String name)
{
	Widget chatboxInput = client.getWidget(WidgetInfo.CHATBOX_INPUT);
	if (chatboxInput != null)
	{
		String text = chatboxInput.getText();
		int idx = text.indexOf(':');
		if (idx != -1)
		{
			String newText = name + text.substring(idx);
			chatboxInput.setText(newText);
		}
	}
}
 
Example 14
Source File: Anonymizer.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
private void parseWidget(Widget widget)
{
	if (widget == null || widget.isHidden() || widget.isSelfHidden())
	{
		return;
	}

	if (widget.getText() != null && widget.getText().contains(name))
	{
		String text = widget.getText().replace(name, ANON);
		widget.setText(text);
		widget.revalidate();
	}
}
 
Example 15
Source File: FriendListPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void setIgnoreListTitle(final String title)
{
	Widget ignoreTitleWidget = client.getWidget(WidgetInfo.IGNORE_TITLE);
	if (ignoreTitleWidget != null)
	{
		ignoreTitleWidget.setText(title);
	}
}
 
Example 16
Source File: TimerOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	Round round = plugin.getCurrentRound();
	if (round == null)
	{
		return null;
	}

	Role role = round.getRoundRole();
	if (role == null)
	{
		return null;
	}

	Widget roleText = client.getWidget(role.getRoleText());
	Widget roleSprite = client.getWidget(role.getRoleSprite());

	if (config.showTimer() && roleText != null && roleSprite != null)
	{
		roleText.setText(String.format("00:%02d", round.getTimeToChange()));
		Rectangle spriteBounds = roleSprite.getBounds();
		roleSprite.setHidden(true);
		graphics.drawImage(plugin.getClockImage(), spriteBounds.x, spriteBounds.y, null);
	}

	return null;
}
 
Example 17
Source File: CombatLevelPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void shutDownAttackLevelRange()
{
	if (WorldType.isPvpWorld(client.getWorldType()))
	{
		return;
	}

	final Widget wildernessLevelWidget = client.getWidget(WidgetInfo.PVP_WILDERNESS_LEVEL);
	if (wildernessLevelWidget != null)
	{
		String wildernessLevelText = wildernessLevelWidget.getText();
		if (wildernessLevelText.contains("<br>"))
		{
			wildernessLevelWidget.setText(wildernessLevelText.substring(0, wildernessLevelText.indexOf("<br>")));
		}
		wildernessLevelWidget.setOriginalY(originalWildernessLevelTextPosition);
		clientThread.invoke(wildernessLevelWidget::revalidate);
	}
	originalWildernessLevelTextPosition = -1;

	final Widget skullContainer = client.getWidget(WidgetInfo.PVP_SKULL_CONTAINER);
	if (skullContainer != null)
	{
		skullContainer.setOriginalY(originalSkullContainerPosition);
		clientThread.invoke(skullContainer::revalidate);
	}
	originalSkullContainerPosition = -1;
}
 
Example 18
Source File: AboveWidgetsOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void renderTimer(Graphics2D graphics, Role role)
{
	Widget roleText = client.getWidget(role.getRoleText());
	Widget roleSprite = client.getWidget(role.getRoleSprite());

	if (roleText == null || roleSprite == null)
	{
		return;
	}

	if (role == Role.COLLECTOR && config.showEggCountOverlay() && plugin.getWave() != null)
	{
		roleText.setText("(" + plugin.getWave().getCollectedEggCount() + ") " + formatClock());
	}
	else if (role == Role.HEALER && config.showHpCountOverlay() && plugin.getWave() != null)
	{
		roleText.setText("(" + plugin.getWave().getHpHealed() + ") " + formatClock());
	}
	else
	{
		roleText.setText(formatClock());
	}

	Rectangle spriteBounds = roleSprite.getBounds();
	graphics.drawImage(plugin.getClockImage(), spriteBounds.x, spriteBounds.y, null);
	roleSprite.setHidden(true);
}
 
Example 19
Source File: GrandExchangePlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void highlightSearchMatches()
{
	if (!wasFuzzySearch)
	{
		return;
	}
	String input = client.getVar(VarClientStr.INPUT_TEXT);

	String underlineTag = "<u=" + ColorUtil.colorToHexCode(FUZZY_HIGHLIGHT_COLOR) + ">";

	Widget results = client.getWidget(WidgetInfo.CHATBOX_GE_SEARCH_RESULTS);
	Widget[] children = results.getDynamicChildren();
	int resultCount = children.length / 3;

	for (int i = 0; i < resultCount; i++)
	{
		Widget itemNameWidget = children[i * 3 + 1];
		String itemName = itemNameWidget.getText();

		List<Integer> indices;
		String otherName = itemName.replace('-', ' ');
		if (!itemName.contains("-") || FUZZY.fuzzyScore(itemName, input) >= FUZZY.fuzzyScore(otherName, input))
		{
			indices = findFuzzyIndices(itemName, input);
		}
		else
		{
			indices = findFuzzyIndices(otherName, input);
		}
		Collections.reverse(indices);

		StringBuilder newItemName = new StringBuilder(itemName);
		for (int index : indices)
		{
			if (wasFuzzySearch && (itemName.charAt(index) == ' ' || itemName.charAt(index) == '-'))
			{
				continue;
			}
			newItemName.insert(index + 1, "</u>");
			newItemName.insert(index, underlineTag);
		}

		itemNameWidget.setText(newItemName.toString());
	}
}
 
Example 20
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;
	}
}