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

The following examples show how to use net.runelite.api.widgets.Widget#setHidden() . 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 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 2
Source File: MinimapPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void updateMinimapWidgetVisibility(boolean enable)
{
	final Widget resizableStonesWidget = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_STONES_WIDGET);

	if (resizableStonesWidget != null)
	{
		resizableStonesWidget.setHidden(enable);
	}

	final Widget resizableNormalWidget = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_WIDGET);

	if (resizableNormalWidget != null && !resizableNormalWidget.isSelfHidden())
	{
		for (Widget widget : resizableNormalWidget.getStaticChildren())
		{
			if (widget.getId() != WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_LOGOUT_BUTTON.getId() &&
				widget.getId() != WidgetInfo.RESIZABLE_MINIMAP_LOGOUT_BUTTON.getId())
			{
				widget.setHidden(enable);
			}
		}
	}
}
 
Example 3
Source File: BarrowsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void shutDown()
{
	overlayManager.remove(barrowsOverlay);
	overlayManager.remove(brotherOverlay);
	puzzleAnswer = null;
	wasInCrypt = false;
	stopPrayerDrainTimer();

	// Restore widgets
	final Widget potential = client.getWidget(WidgetInfo.BARROWS_POTENTIAL);
	if (potential != null)
	{
		potential.setHidden(false);
	}

	final Widget barrowsBrothers = client.getWidget(WidgetInfo.BARROWS_BROTHERS);
	if (barrowsBrothers != null)
	{
		barrowsBrothers.setHidden(false);
	}
}
 
Example 4
Source File: BlastMineOreCountOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	final Widget blastMineWidget = client.getWidget(WidgetInfo.BLAST_MINE);

	if (blastMineWidget == null)
	{
		return null;
	}

	if (config.showOreOverlay())
	{
		blastMineWidget.setHidden(true);
		panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.COAL, client.getVar(Varbits.BLAST_MINE_COAL))));
		panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.GOLD_ORE, client.getVar(Varbits.BLAST_MINE_GOLD))));
		panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.MITHRIL_ORE, client.getVar(Varbits.BLAST_MINE_MITHRIL))));
		panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.ADAMANTITE_ORE, client.getVar(Varbits.BLAST_MINE_ADAMANTITE))));
		panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.RUNITE_ORE, client.getVar(Varbits.BLAST_MINE_RUNITE))));
	}
	else
	{
		blastMineWidget.setHidden(false);
	}

	return super.render(graphics);
}
 
Example 5
Source File: WikiPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void removeWidgets()
{

	Widget minimapOrbs = client.getWidget(WidgetInfo.MINIMAP_ORBS);
	if (minimapOrbs == null)
	{
		return;
	}
	Widget[] children = minimapOrbs.getChildren();
	if (children == null || children.length < 1)
	{
		return;
	}
	children[0] = null;

	Widget vanilla = client.getWidget(WidgetInfo.MINIMAP_WIKI_BANNER);
	if (vanilla != null)
	{
		vanilla.setHidden(false);
	}

	onDeselect();
	client.setSpellSelected(false);
}
 
Example 6
Source File: RaidsPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void shutDown()
{
	chatCommandManager.unregisterCommand(LAYOUT_COMMAND);
	overlayManager.remove(overlay);
	overlayManager.remove(pointsOverlay);
	clientToolbar.removeNavigation(navButton);
	if (config.partyDisplay())
	{
		overlayManager.remove(partyOverlay);
	}
	infoBoxManager.removeInfoBox(timer);
	final Widget widget = client.getWidget(WidgetInfo.RAIDS_POINTS_INFOBOX);
	if (widget != null)
	{
		widget.setHidden(false);
	}
	reset();
}
 
Example 7
Source File: BlastFurnaceCofferOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	if (plugin.getConveyorBelt() == null)
	{
		return null;
	}

	Widget sack = client.getWidget(WidgetInfo.BLAST_FURNACE_COFFER);

	if (sack != null)
	{
		final int coffer = client.getVar(BLAST_FURNACE_COFFER);

		sack.setHidden(true);

		panelComponent.getChildren().add(LineComponent.builder()
			.left("Coffer:")
			.right(QuantityFormatter.quantityToStackSize(coffer) + " gp")
			.build());

		if (config.showCofferTime())
		{
			final long millis = (long) (coffer / COST_PER_HOUR * 60 * 60 * 1000);

			panelComponent.getChildren().add(LineComponent.builder()
				.left("Time:")
				.right(formatDuration(millis, "H'h' m'm' s's'", true))
				.build());
		}
	}

	return super.render(graphics);
}
 
Example 8
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 9
Source File: NightmareZonePlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void shutDown()
{
	overlayManager.remove(overlay);
	overlay.removeAbsorptionCounter();

	Widget nmzWidget = client.getWidget(WidgetInfo.NIGHTMARE_ZONE);

	if (nmzWidget != null)
	{
		nmzWidget.setHidden(false);
	}

	resetPointsPerHour();
}
 
Example 10
Source File: BarrowsBrotherSlainOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	// Do not display overlay if potential is null/hidden
	final Widget potential = client.getWidget(WidgetInfo.BARROWS_POTENTIAL);
	if (potential == null || potential.isHidden())
	{
		return null;
	}

	// Hide original overlay
	final Widget barrowsBrothers = client.getWidget(WidgetInfo.BARROWS_BROTHERS);
	if (barrowsBrothers != null)
	{
		barrowsBrothers.setHidden(true);
		potential.setHidden(true);
	}

	TableComponent tableComponent = new TableComponent();
	tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);

	for (BarrowsBrothers brother : BarrowsBrothers.values())
	{
		final boolean brotherSlain = client.getVar(brother.getKilledVarbit()) > 0;
		String slain = brotherSlain ? "\u2713" : "\u2717";
		tableComponent.addRow(brother.getName(), ColorUtil.prependColorTag(slain, brotherSlain ? Color.GREEN : Color.RED));
	}

	float rewardPercent = client.getVar(Varbits.BARROWS_REWARD_POTENTIAL) / 10.0f;
	tableComponent.addRow("Potential", ColorUtil.prependColorTag(rewardPercent != 0 ? rewardPercent + "%" : "0%", rewardPercent >= 73.0f && rewardPercent <= 88.0f ? Color.GREEN : rewardPercent < 65.6f ? Color.WHITE : Color.YELLOW));

	panelComponent.getChildren().add(tableComponent);

	return super.render(graphics);
}
 
Example 11
Source File: RaidsPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onWidgetHiddenChanged(WidgetHiddenChanged event)
{
	if (!inRaidChambers || event.isHidden())
	{
		return;
	}

	Widget widget = event.getWidget();

	if (widget == client.getWidget(WidgetInfo.RAIDS_POINTS_INFOBOX))
	{
		widget.setHidden(true);
	}
}
 
Example 12
Source File: MotherlodeSackOverlay.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	if (!plugin.isInMlm())
	{
		return null;
	}

	Widget sack = client.getWidget(WidgetInfo.MOTHERLODE_MINE);

	panelComponent.getChildren().clear();
	panelComponent.setBackgroundColor(ComponentConstants.STANDARD_BACKGROUND_COLOR);

	TableComponent tableComponent = new TableComponent();
	tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);

	if (sack != null)
	{
		sack.setHidden(true);

		if (config.showSack())
		{
			if (plugin.getCurSackSize() >= plugin.getMaxSackSize())
			{
				panelComponent.setBackgroundColor(DANGER);
			}

			tableComponent.addRow("Pay-dirt in sack:", String.valueOf(client.getVar(Varbits.SACK_NUMBER)));
		}

		if (config.showDepositsLeft())
		{
			final Integer depositsLeft = plugin.getDepositsLeft();
			Color color = Color.WHITE;

			if (depositsLeft != null)
			{
				if (depositsLeft == 0)
				{
					panelComponent.setBackgroundColor(DANGER);
				}
				else if (depositsLeft == 1)
				{
					color = Color.RED;
				}
			}

			tableComponent.addRow(ColorUtil.prependColorTag("Deposits left:", color), ColorUtil.prependColorTag(depositsLeft == null ? "N/A" : String.valueOf(depositsLeft), color));
		}
	}

	panelComponent.getChildren().add(tableComponent);

	return panelComponent.render(graphics);
}
 
Example 13
Source File: MusicPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void updateList(Widget musicList, String filter)
{
	if (tracks == null)
	{
		tracks = Arrays.stream(musicList.getDynamicChildren())
			.sorted(Comparator.comparing(Widget::getRelativeY))
			.collect(Collectors.toList());
	}

	tracks.forEach(w -> w.setHidden(true));

	Collection<Widget> relevantTracks = tracks.stream()
		.filter(w -> w.getText().toLowerCase().contains(filter))
		.filter(w -> currentMusicFilter == MusicState.ALL || w.getTextColor() == currentMusicFilter.getColor())
		.collect(Collectors.toList());

	// Original music track list has a little offset
	int y = 3;

	for (Widget track : relevantTracks)
	{
		track.setHidden(false);
		track.setOriginalY(y);
		track.revalidate();

		y += track.getHeight();
	}

	y += 3;

	int newHeight = 0;

	if (musicList.getScrollHeight() > 0)
	{
		newHeight = (musicList.getScrollY() * y) / musicList.getScrollHeight();
	}

	musicList.setScrollHeight(y);
	musicList.revalidateScroll();

	client.runScript(
		ScriptID.UPDATE_SCROLLBAR,
		WidgetInfo.MUSIC_TRACK_SCROLLBAR.getId(),
		WidgetInfo.MUSIC_TRACK_LIST.getId(),
		newHeight
	);
}
 
Example 14
Source File: QuestListPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void updateList(QuestContainer questContainer, String filter)
{
	Widget list = client.getWidget(questContainer.widgetInfo);
	if (list == null)
	{
		return;
	}

	Collection<QuestWidget> quests = questSet.get(questContainer);

	if (quests != null &&
		// Check to make sure the list hasn't been rebuild since we were last her
		// Do this by making sure the list's dynamic children are the same as when we last saw them
		quests.stream().noneMatch(w ->
		{
			Widget codeWidget = w.getQuest();
			if (codeWidget == null)
			{
				return false;
			}
			return list.getChild(codeWidget.getIndex()) == codeWidget;
		}))
	{
		quests = null;
	}

	if (quests == null)
	{
		// Find all of the widgets that we care about, sorting by their Y value
		quests = Arrays.stream(list.getDynamicChildren())
			.sorted(Comparator.comparing(Widget::getRelativeY))
			.filter(w -> !QUEST_HEADERS.contains(w.getText()))
			.map(w -> new QuestWidget(w, Text.removeTags(w.getText()).toLowerCase()))
			.collect(Collectors.toList());
		questSet.put(questContainer, quests);
	}

	// offset because of header
	int y = 20;
	for (QuestWidget questInfo : quests)
	{
		Widget quest = questInfo.getQuest();
		QuestState questState = QuestState.getByColor(quest.getTextColor());

		boolean hidden;
		if (!filter.isEmpty())
		{
			// If searching, show result regardless of filtered state
			hidden = !questInfo.getTitle().contains(filter);
		}
		else
		{
			// Otherwise hide if it doesn't match the filter state
			if (currentFilterState == QuestState.NOT_COMPLETED)
			{
				hidden = questState == QuestState.COMPLETE;
			}
			else
			{
				hidden = currentFilterState != QuestState.ALL && questState != currentFilterState;
			}
		}

		quest.setHidden(hidden);
		quest.setOriginalY(y);
		quest.revalidate();

		if (!hidden)
		{
			y += quest.getHeight();
		}
	}

	long hiddenCount = quests.stream()
		.filter(q -> q.getQuest().isHidden())
		.count();
	list.setOriginalHeight(hiddenCount == quests.size() ? 0 : y);
}
 
Example 15
Source File: TabInterface.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void updateWidget(Widget t, int y)
{
	t.setOriginalY(y);
	t.setHidden(y < (bounds.y + BUTTON_HEIGHT + MARGIN) || y > (bounds.y + bounds.height - TAB_HEIGHT - MARGIN - BUTTON_HEIGHT));
	t.revalidate();
}
 
Example 16
Source File: CorpDamageOverlay.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	Widget damageWidget = client.getWidget(WidgetID.CORP_DAMAGE, 0);
	if (damageWidget != null)
	{
		damageWidget.setHidden(true);
	}

	NPC corp = corpPlugin.getCorp();
	if (corp == null)
	{
		return null;
	}

	int myDamage = client.getVar(Varbits.CORP_DAMAGE);
	int totalDamage = corpPlugin.getTotalDamage();
	int players = corpPlugin.getPlayers().size();

	// estimate how much damage is required for kill based on number of players
	int damageForKill = players != 0 ? totalDamage / players : 0;

	TableComponent tableComponent = new TableComponent();
	tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);

	NPC core = corpPlugin.getCore();
	if (core != null)
	{
		WorldPoint corePoint = core.getWorldLocation();
		WorldPoint myPoint = client.getLocalPlayer().getWorldLocation();

		String text = null;

		if (core.getInteracting() == client.getLocalPlayer())
		{
			text = "The core is targeting you!";
		}
		else if (corePoint.distanceTo(myPoint) <= 1)
		{
			text = "Stay away from the core!";
		}

		if (text != null)
		{
			final FontMetrics fontMetrics = graphics.getFontMetrics();
			int textWidth = Math.max(ComponentConstants.STANDARD_WIDTH, fontMetrics.stringWidth(text));

			panelComponent.setPreferredSize(new Dimension(textWidth, 0));
			tableComponent.addRow(ColorUtil.prependColorTag(text, Color.RED), "");
		}
	}

	if (config.showDamage())
	{
		tableComponent.addRow("Your damage", ColorUtil.prependColorTag(Integer.toString(myDamage), damageForKill > 0 && myDamage >= damageForKill ? Color.GREEN : Color.RED));
		tableComponent.addRow("Total damage:", Integer.toString(totalDamage));
	}

	panelComponent.getChildren().add(tableComponent);
	return super.render(graphics);
}
 
Example 17
Source File: WikiPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void addWidgets()
{
	Widget minimapOrbs = client.getWidget(WidgetInfo.MINIMAP_ORBS);
	if (minimapOrbs == null)
	{
		return;
	}

	Widget vanilla = client.getWidget(WidgetInfo.MINIMAP_WIKI_BANNER);
	if (vanilla != null)
	{
		vanilla.setHidden(true);
	}

	icon = minimapOrbs.createChild(0, WidgetType.GRAPHIC);
	icon.setSpriteId(SpriteID.WIKI_DESELECTED);
	icon.setOriginalX(0);
	icon.setOriginalY(0);
	icon.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
	icon.setYPositionMode(WidgetPositionMode.ABSOLUTE_BOTTOM);
	icon.setOriginalWidth(40);
	icon.setOriginalHeight(14);
	icon.setTargetVerb("Lookup");
	icon.setName("Wiki");
	icon.setClickMask(WidgetConfig.USE_GROUND_ITEM | WidgetConfig.USE_ITEM | WidgetConfig.USE_NPC
		| WidgetConfig.USE_OBJECT | WidgetConfig.USE_WIDGET);
	icon.setNoClickThrough(true);
	icon.setOnTargetEnterListener((JavaScriptCallback) ev ->
	{
		wikiSelected = true;
		icon.setSpriteId(SpriteID.WIKI_SELECTED);
		client.setAllWidgetsAreOpTargetable(true);
	});

	final int searchIndex = config.leftClickSearch() ? 4 : 5;
	icon.setAction(searchIndex, "Search");
	icon.setOnOpListener((JavaScriptCallback) ev ->
	{
		if (ev.getOp() == searchIndex + 1)
		{
			openSearchInput();
		}
	});

	// This doesn't always run because we cancel the menuop
	icon.setOnTargetLeaveListener((JavaScriptCallback) ev -> onDeselect());
	icon.revalidate();
}
 
Example 18
Source File: TabInterface.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void updateWidget(Widget t, int y)
{
	t.setOriginalY(y);
	t.setHidden(y < (bounds.y + BUTTON_HEIGHT + MARGIN) || y > (bounds.y + bounds.height - TAB_HEIGHT - MARGIN - BUTTON_HEIGHT));
	t.revalidate();
}
 
Example 19
Source File: TabInterface.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void loadTab(String tag)
{
	TagTab tagTab = tabManager.load(tag);

	if (tagTab.getBackground() == null)
	{
		Widget btn = createGraphic(ColorUtil.wrapWithColorTag(tagTab.getTag(), HILIGHT_COLOR), TabSprites.TAB_BACKGROUND.getSpriteId(), -1, TAB_WIDTH, TAB_HEIGHT, bounds.x, 1, true);
		addTabActions(btn);
		tagTab.setBackground(btn);
	}

	if (tagTab.getIcon() == null)
	{
		Widget icon = createGraphic(
			ColorUtil.wrapWithColorTag(tagTab.getTag(), HILIGHT_COLOR),
			-1,
			tagTab.getIconItemId(),
			Constants.ITEM_SPRITE_WIDTH, Constants.ITEM_SPRITE_HEIGHT,
			bounds.x + 3, 1,
			false);
		addTabOptions(icon);
		tagTab.setIcon(icon);
	}
	
	if (tagTab.getMenu() == null)
	{
		Widget menu = createGraphic(
			client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER),
			ColorUtil.wrapWithColorTag(tagTab.getTag(), HILIGHT_COLOR),
			-1,
			tagTab.getIconItemId(),
			BANK_ITEM_WIDTH, BANK_ITEM_HEIGHT,
			BANK_ITEM_START_X, BANK_ITEM_START_Y,
			true);
		addTabActions(menu);
		addTabOptions(menu);
		if (activeTab != null && activeTab.getTag().equals(TAB_MENU_KEY))
		{
			menu.setHidden(false);
		}
		else
		{
			menu.setHidden(true);
		}
		tagTab.setMenu(menu);
	}

	tabManager.add(tagTab);
}
 
Example 20
Source File: WikiPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void addWidgets()
{
	Widget minimapOrbs = client.getWidget(WidgetInfo.MINIMAP_ORBS);
	if (minimapOrbs == null)
	{
		return;
	}

	Widget vanilla = client.getWidget(WidgetInfo.MINIMAP_WIKI_BANNER);
	if (vanilla != null)
	{
		vanilla.setHidden(true);
	}

	icon = minimapOrbs.createChild(0, WidgetType.GRAPHIC);
	icon.setSpriteId(SpriteID.WIKI_DESELECTED);
	icon.setOriginalX(0);
	icon.setOriginalY(0);
	icon.setXPositionMode(WidgetPositionMode.ABSOLUTE_RIGHT);
	icon.setYPositionMode(WidgetPositionMode.ABSOLUTE_BOTTOM);
	icon.setOriginalWidth(40);
	icon.setOriginalHeight(14);
	icon.setTargetVerb("Lookup");
	icon.setName("Wiki");
	icon.setClickMask(WidgetConfig.USE_GROUND_ITEM | WidgetConfig.USE_ITEM | WidgetConfig.USE_NPC
		| WidgetConfig.USE_OBJECT | WidgetConfig.USE_WIDGET);
	icon.setNoClickThrough(true);
	icon.setOnTargetEnterListener((JavaScriptCallback) ev ->
	{
		wikiSelected = true;
		icon.setSpriteId(SpriteID.WIKI_SELECTED);
		client.setAllWidgetsAreOpTargetable(true);
	});

	final int searchIndex = config.leftClickSearch() ? 4 : 5;
	icon.setAction(searchIndex, "Search");
	icon.setOnOpListener((JavaScriptCallback) ev ->
	{
		if (ev.getOp() == searchIndex + 1)
		{
			openSearchInput();
		}
	});

	// This doesn't always run because we cancel the menuop
	icon.setOnTargetLeaveListener((JavaScriptCallback) ev -> onDeselect());
	icon.revalidate();
}