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

The following examples show how to use net.runelite.api.widgets.Widget#isHidden() . 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: WorldMapOverlay.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Gets a clip area which excludes the area of widgets which overlay the world map.
 *
 * @param baseRectangle The base area to clip from
 * @return              An {@link Area} representing <code>baseRectangle</code>, with the area
 *                      of visible widgets overlaying the world map clipped from it.
 */
private Area getWorldMapClipArea(Rectangle baseRectangle)
{
	final Widget overview = client.getWidget(WidgetInfo.WORLD_MAP_OVERVIEW_MAP);
	final Widget surfaceSelector = client.getWidget(WidgetInfo.WORLD_MAP_SURFACE_SELECTOR);

	Area clipArea = new Area(baseRectangle);

	if (overview != null && !overview.isHidden())
	{
		clipArea.subtract(new Area(overview.getBounds()));
	}

	if (surfaceSelector != null && !surfaceSelector.isHidden())
	{
		clipArea.subtract(new Area(surfaceSelector.getBounds()));
	}

	return clipArea;
}
 
Example 2
Source File: BankSearch.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void layoutBank()
{
	Widget bankContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
	if (bankContainer == null || bankContainer.isHidden())
	{
		return;
	}

	Object[] scriptArgs = bankContainer.getOnInvTransmitListener();
	if (scriptArgs == null)
	{
		return;
	}

	client.runScript(scriptArgs);
}
 
Example 3
Source File: BarrowsOverlay.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	Widget puzzleAnswer = plugin.getPuzzleAnswer();

	if (config.showBrotherLoc())
	{
		renderBarrowsBrothers(graphics);
	}

	if (puzzleAnswer != null && config.showPuzzleAnswer() && !puzzleAnswer.isHidden())
	{
		Rectangle answerRect = puzzleAnswer.getBounds();
		graphics.setColor(Color.GREEN);
		graphics.draw(answerRect);
	}

	return null;
}
 
Example 4
Source File: CombatLevelOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	Widget combatLevelWidget = client.getWidget(WidgetInfo.COMBAT_LEVEL);
	if (!config.showLevelsUntil()
		|| client.getLocalPlayer().getCombatLevel() == Experience.MAX_COMBAT_LEVEL
		|| combatLevelWidget == null || combatLevelWidget.isHidden())
	{
		return null;
	}

	Rectangle combatCanvas = combatLevelWidget.getBounds();

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

	if (combatCanvas.contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY()))
	{
		tooltipManager.add(new Tooltip(getLevelsUntilTooltip()));
	}

	return null;
}
 
Example 5
Source File: Anonymizer.java    From ExternalPlugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onGameTick(GameTick event)
{
	Player p = client.getLocalPlayer();

	if (p == null)
	{
		return;
	}

	name = p.getName();

	if (config.hideXp())
	{
		Widget xp = client.getWidget(122, 9);

		if (xp != null && xp.getText() != null && !xp.isHidden())
		{
			xp.setText("123,456,789");
			xp.revalidate();
		}
	}
}
 
Example 6
Source File: CombatLevelOverlay.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	Widget combatLevelWidget = client.getWidget(WidgetInfo.COMBAT_LEVEL);
	if (!config.showLevelsUntil()
		|| client.getLocalPlayer().getCombatLevel() == Experience.MAX_COMBAT_LEVEL
		|| combatLevelWidget == null || combatLevelWidget.isHidden())
	{
		return null;
	}

	Rectangle combatCanvas = combatLevelWidget.getBounds();

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

	if (combatCanvas.contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY()))
	{
		tooltipManager.add(new Tooltip(getLevelsUntilTooltip()));
	}

	return null;
}
 
Example 7
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 8
Source File: WorldHopperPingOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	if (!worldHopperConfig.displayPing())
	{
		return null;
	}

	final int ping = worldHopperPlugin.getCurrentPing();
	if (ping < 0)
	{
		return null;
	}

	final String text = ping + " ms";
	final int textWidth = graphics.getFontMetrics().stringWidth(text);
	final int textHeight = graphics.getFontMetrics().getAscent() - graphics.getFontMetrics().getDescent();

	// Adjust ping offset for logout button
	Widget logoutButton = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_LOGOUT_BUTTON);
	int xOffset = X_OFFSET;
	if (logoutButton != null && !logoutButton.isHidden())
	{
		xOffset += logoutButton.getWidth();
	}

	final int width = (int) client.getRealDimensions().getWidth();
	final Point point = new Point(width - textWidth - xOffset, textHeight + Y_OFFSET);
	OverlayUtil.renderTextLocation(graphics, point, text, Color.YELLOW);

	return null;
}
 
Example 9
Source File: FpsOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	if (!config.drawFps())
	{
		return null;
	}

	// On resizable bottom line mode the logout button is at the top right, so offset the overlay
	// to account for it
	Widget logoutButton = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_LOGOUT_BUTTON);
	int xOffset = X_OFFSET;
	if (logoutButton != null && !logoutButton.isHidden())
	{
		xOffset += logoutButton.getWidth();
	}
	
	final String text = client.getFPS() + FPS_STRING;
	final int textWidth = graphics.getFontMetrics().stringWidth(text);
	final int textHeight = graphics.getFontMetrics().getAscent() - graphics.getFontMetrics().getDescent();

	final int width = (int) client.getRealDimensions().getWidth();
	final Point point = new Point(width - textWidth - xOffset, textHeight + Y_OFFSET);
	OverlayUtil.renderTextLocation(graphics, point, text, getFpsValueColor());

	return null;
}
 
Example 10
Source File: FpsOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	if (!config.drawFps())
	{
		return null;
	}

	// On resizable bottom line mode the logout button is at the top right, so offset the overlay
	// to account for it
	Widget logoutButton = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_LOGOUT_BUTTON);
	int xOffset = X_OFFSET;
	if (logoutButton != null && !logoutButton.isHidden())
	{
		xOffset += logoutButton.getWidth();
	}

	final String text = client.getFPS() + FPS_STRING;
	final int textWidth = graphics.getFontMetrics().stringWidth(text);
	final int textHeight = graphics.getFontMetrics().getAscent() - graphics.getFontMetrics().getDescent();

	final int width = (int) client.getRealDimensions().getWidth();
	final Point point = new Point(width - textWidth - xOffset, textHeight + Y_OFFSET);
	OverlayUtil.renderTextLocation(graphics, point, text, getFpsValueColor());

	return null;
}
 
Example 11
Source File: RegenMeterOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void renderRegen(Graphics2D g, WidgetInfo widgetInfo, double percent, Color color)
{
	Widget widget = client.getWidget(widgetInfo);
	if (widget == null || widget.isHidden())
	{
		return;
	}
	Rectangle bounds = widget.getBounds();

	Arc2D.Double arc = new Arc2D.Double(bounds.x + OFFSET, bounds.y + (bounds.height / 2 - DIAMETER / 2), DIAMETER, DIAMETER, 90.d, -360.d * percent, Arc2D.OPEN);
	final Stroke STROKE = new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
	g.setStroke(STROKE);
	g.setColor(color);
	g.draw(arc);
}
 
Example 12
Source File: TabInterface.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
public void update()
{
	if (isHidden())
	{
		parent = null;
		waitSearchTick = false;
		rememberedSearch = "";

		saveTab();
		return;
	}

	// Don't continue ticking if equipment menu or bank menu is open
	if (parent.isSelfHidden())
	{
		return;
	}

	if (activeTab != null && client.getVar(VarClientInt.INPUT_TYPE) == InputType.RUNELITE.getType())
	{
		// don't reset active tab if we are editing tags
		updateBounds();
		scrollTab(0);
		return;
	}

	String str = client.getVar(VarClientStr.INPUT_TEXT);

	if (Strings.isNullOrEmpty(str))
	{
		str = "";
	}

	Widget bankTitle = client.getWidget(WidgetInfo.BANK_TITLE_BAR);
	if (bankTitle != null && !bankTitle.isHidden() && !str.startsWith(TAG_SEARCH))
	{
		str = bankTitle.getText().replaceFirst("Showing items: ", "");

		if (str.startsWith("Tab "))
		{
			str = "";
		}
	}

	str = Text.standardize(str);

	if (str.startsWith(BankTagsPlugin.TAG_SEARCH))
	{
		activateTab(tabManager.find(str.substring(TAG_SEARCH.length())));
	}
	else
	{
		activateTab(null);
	}

	if (!waitSearchTick
		&& activeTab == null
		&& !Strings.isNullOrEmpty(rememberedSearch)
		&& client.getVar(VarClientInt.INPUT_TYPE) == InputType.NONE.getType())
	{
		bankSearch.reset(true);
		bankSearch.search(InputType.NONE, rememberedSearch, true);
		rememberedSearch = "";
	}
	else if (waitSearchTick)
	{
		waitSearchTick = false;
	}

	updateBounds();
	scrollTab(0);
}
 
Example 13
Source File: TabInterface.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void updateBounds()
{
	Widget itemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
	if (itemContainer == null)
	{
		return;
	}

	int height = itemContainer.getHeight();

	// If player isn't using normal bank tabs
	if (itemContainer.getRelativeY() == 0)
	{
		height -= (TAB_HEIGHT + MARGIN);
	}

	bounds.setSize(TAB_WIDTH + MARGIN * 2, height);
	bounds.setLocation(MARGIN, TAB_HEIGHT + MARGIN);

	Widget incinerator = client.getWidget(WidgetInfo.BANK_INCINERATOR);

	if (incinerator != null && !incinerator.isHidden())
	{
		incinerator.setOriginalHeight(INCINERATOR_HEIGHT);
		incinerator.setOriginalWidth(INCINERATOR_WIDTH);
		incinerator.setOriginalY(INCINERATOR_HEIGHT);

		Widget child = incinerator.getDynamicChildren()[0];
		child.setOriginalHeight(INCINERATOR_HEIGHT);
		child.setOriginalWidth(INCINERATOR_WIDTH);
		child.setWidthMode(WidgetSizeMode.ABSOLUTE);
		child.setHeightMode(WidgetSizeMode.ABSOLUTE);
		child.setType(WidgetType.GRAPHIC);
		child.setSpriteId(TabSprites.INCINERATOR.getSpriteId());
		incinerator.revalidate();

		bounds.setSize(TAB_WIDTH + MARGIN * 2, height - incinerator.getHeight());
	}

	if (upButton != null)
	{
		Point p = upButton.getCanvasLocation();
		canvasBounds.setBounds(p.getX(), p.getY() + BUTTON_HEIGHT, bounds.width, maxTabs * TAB_HEIGHT + maxTabs * MARGIN);
	}
}
 
Example 14
Source File: PrayerDoseOverlay.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	final Widget xpOrb = client.getWidget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
	if (xpOrb == null || xpOrb.isHidden())
	{
		return null;
	}

	final Rectangle bounds = xpOrb.getBounds();
	if (bounds.getX() <= 0)
	{
		return null;
	}

	final Point mousePosition = client.getMouseCanvasPosition();

	if (config.showPrayerStatistics() && bounds.contains(mousePosition.getX(), mousePosition.getY()))
	{
		final StringBuilder sb = new StringBuilder();

		if (config.replaceOrbText())
		{
			sb.append("Prayer points remaining: ").append(client.getBoostedSkillLevel(Skill.PRAYER));
		}
		else
		{
			sb.append("Time Remaining: ").append(plugin.getEstimatedTimeRemaining(false));
		}

		sb.append("</br>").append("Prayer Bonus: ").append(plugin.getPrayerBonus());
		tooltipManager.add(new Tooltip(sb.toString()));
	}

	if (!config.showPrayerDoseIndicator() || !hasPrayerRestore)
	{
		return null;
	}

	final int currentPrayer = client.getBoostedSkillLevel(Skill.PRAYER);
	final int maxPrayer = client.getRealSkillLevel(Skill.PRAYER);

	final int prayerPointsMissing = maxPrayer - currentPrayer;
	if (prayerPointsMissing <= 0)
	{
		return null;
	}

	final double dosePercentage = hasHolyWrench ? .27 : .25;
	final int basePointsRestored = (int) Math.floor(maxPrayer * dosePercentage);

	final int pointsRestored = basePointsRestored + 7 + bonusPrayer;

	if (prayerPointsMissing < pointsRestored)
	{
		return null;
	}

	// Purposefully using height twice here as the bounds of the prayer orb includes the number sticking out the side
	final int orbInnerSize = (int) bounds.getHeight();

	final int orbInnerX = (int) (bounds.getX() + 24); // x pos of the inside of the prayer orb
	final int orbInnerY = (int) (bounds.getY() - 1); // y pos of the inside of the prayer orb

	final long timeSinceLastTick = Duration.between(startOfLastTick, Instant.now()).toMillis();

	final float tickProgress = Math.min(timeSinceLastTick / PULSE_TIME, 1); // Cap between 0 and 1
	final double t = tickProgress * Math.PI; // Convert to 0 - pi

	graphics.setColor(ColorUtil.colorLerp(START_COLOR, END_COLOR, Math.sin(t)));
	graphics.setStroke(new BasicStroke(2));
	graphics.drawOval(orbInnerX, orbInnerY, orbInnerSize, orbInnerSize);

	return new Dimension((int) bounds.getWidth(), (int) bounds.getHeight());
}
 
Example 15
Source File: TabInterface.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private boolean isHidden()
{
	Widget widget = client.getWidget(WidgetInfo.BANK_CONTAINER);
	return !config.tabs() || widget == null || widget.isHidden();
}
 
Example 16
Source File: StatusBarsOverlay.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Dimension render(Graphics2D g)
{
	final Widget widgetBankTitleBar = client.getWidget(WidgetInfo.BANK_TITLE_BAR);
	if (widgetBankTitleBar != null && !widgetBankTitleBar.isHidden())
	{
		return null;
	}

	Viewport curViewport = null;
	Widget curWidget = null;

	for (Viewport viewport : Viewport.values())
	{
		final Widget viewportWidget = client.getWidget(viewport.getViewport());
		if (viewportWidget != null && !viewportWidget.isHidden())
		{
			curViewport = viewport;
			curWidget = viewportWidget;
			break;
		}
	}

	if (curViewport == null)
	{
		return null;
	}
	else
	{
		curWidget.isHidden();
	}

	final Point offsetLeft = curViewport.getOffsetLeft();
	final Point offsetRight = curViewport.getOffsetRight();
	final Point location = curWidget.getCanvasLocation();
	final int height, offsetLeftBarX, offsetLeftBarY, offsetRightBarX, offsetRightBarY;

	if (curViewport == Viewport.RESIZED_BOTTOM)
	{
		height = RESIZED_BOTTOM_HEIGHT;
		offsetLeftBarX = (location.getX() + RESIZED_BOTTOM_OFFSET_X - offsetLeft.getX());
		offsetLeftBarY = (location.getY() - RESIZED_BOTTOM_OFFSET_Y - offsetRight.getY());
		offsetRightBarX = (location.getX() + RESIZED_BOTTOM_OFFSET_X - offsetRight.getX());
		offsetRightBarY = (location.getY() - RESIZED_BOTTOM_OFFSET_Y - offsetRight.getY());
	}
	else
	{
		height = HEIGHT;
		offsetLeftBarX = (location.getX() - offsetLeft.getX());
		offsetLeftBarY = (location.getY() - offsetLeft.getY());
		offsetRightBarX = (location.getX() - offsetRight.getX()) + curWidget.getWidth();
		offsetRightBarY = (location.getY() - offsetRight.getY());
	}

	BarRenderer left = plugin.getBarRenderers().get(config.leftBarMode());
	BarRenderer right = plugin.getBarRenderers().get(config.rightBarMode());

	if (left != null)
	{
		left.draw(client, this, g, offsetLeftBarX, offsetLeftBarY, height);
	}

	if (right != null)
	{
		right.draw(client, this, g, offsetRightBarX, offsetRightBarY, height);
	}

	return null;
}
 
Example 17
Source File: ClueScrollEmoteOverlay.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	ClueScroll clue = plugin.getClue();

	if (!(clue instanceof EmoteClue))
	{
		hasScrolled = false;
		return null;
	}

	EmoteClue emoteClue = (EmoteClue) clue;

	if (!emoteClue.getFirstEmote().hasSprite())
	{
		return null;
	}

	Widget emoteContainer = client.getWidget(WidgetInfo.EMOTE_CONTAINER);

	if (emoteContainer == null || emoteContainer.isHidden())
	{
		return null;
	}

	Widget emoteWindow = client.getWidget(WidgetInfo.EMOTE_WINDOW);

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

	Widget firstEmoteWidget = null;
	Widget secondEmoteWidget = null;

	for (Widget emoteWidget : emoteContainer.getDynamicChildren())
	{
		if (emoteWidget.getSpriteId() == emoteClue.getFirstEmote().getSpriteId())
		{
			firstEmoteWidget = emoteWidget;
			plugin.highlightWidget(graphics, emoteWidget, emoteWindow, null,
				emoteClue.getSecondEmote() != null ? "1st" : null);
		}
		else if (emoteClue.getSecondEmote() != null
			&& emoteWidget.getSpriteId() == emoteClue.getSecondEmote().getSpriteId())
		{
			secondEmoteWidget = emoteWidget;
			plugin.highlightWidget(graphics, emoteWidget, emoteWindow, null, "2nd");
		}
	}
	if (!hasScrolled)
	{
		hasScrolled = true;
		plugin.scrollToWidget(WidgetInfo.EMOTE_CONTAINER, WidgetInfo.EMOTE_SCROLLBAR, firstEmoteWidget, secondEmoteWidget);
	}

	return null;
}
 
Example 18
Source File: Perspective.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Translates two-dimensional ground coordinates within the 3D world to
 * their corresponding coordinates on the Minimap.
 *
 * @param client the game client
 * @param point ground coordinate
 * @param distance max distance from local player to minimap point
 * @return a {@link Point} on screen corresponding to the position in
 * 3D-space
 */
@Nullable
public static Point localToMinimap(@Nonnull Client client, @Nonnull LocalPoint point, int distance)
{
	LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
	int x = point.getX() / 32 - localLocation.getX() / 32;
	int y = point.getY() / 32 - localLocation.getY() / 32;

	int dist = x * x + y * y;
	if (dist < distance)
	{
		Widget minimapDrawWidget;
		if (client.isResized())
		{
			if (client.getVar(Varbits.SIDE_PANELS) == 1)
			{
				minimapDrawWidget = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_DRAW_AREA);
			}
			else
			{
				minimapDrawWidget = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_STONES_DRAW_AREA);
			}
		}
		else
		{
			minimapDrawWidget = client.getWidget(WidgetInfo.FIXED_VIEWPORT_MINIMAP_DRAW_AREA);
		}

		if (minimapDrawWidget == null || minimapDrawWidget.isHidden())
		{
			return null;
		}

		final int angle = client.getMapAngle() & 0x7FF;

		final int sin = SINE[angle];
		final int cos = COSINE[angle];

		final int xx = y * sin + cos * x >> 16;
		final int yy = sin * x - y * cos >> 16;

		Point loc = minimapDrawWidget.getCanvasLocation();
		int miniMapX = loc.getX() + xx + minimapDrawWidget.getWidth() / 2;
		int miniMapY = minimapDrawWidget.getHeight() / 2 + loc.getY() + yy;
		return new Point(miniMapX, miniMapY);
	}

	return null;
}
 
Example 19
Source File: PrayerDoseOverlay.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	final Widget xpOrb = client.getWidget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
	if (xpOrb == null || xpOrb.isHidden())
	{
		return null;
	}

	final Rectangle bounds = xpOrb.getBounds();
	if (bounds.getX() <= 0)
	{
		return null;
	}

	final Point mousePosition = client.getMouseCanvasPosition();

	if (config.showPrayerStatistics() && bounds.contains(mousePosition.getX(), mousePosition.getY()))
	{
		final StringBuilder sb = new StringBuilder();

		if (config.replaceOrbText())
		{
			sb.append("Prayer points remaining: ").append(client.getBoostedSkillLevel(Skill.PRAYER));
		}
		else
		{
			sb.append("Time Remaining: ").append(plugin.getEstimatedTimeRemaining(false));
		}

		sb.append("</br>").append("Prayer Bonus: ").append(plugin.getPrayerBonus());
		tooltipManager.add(new Tooltip(sb.toString()));
	}

	if (!config.showPrayerDoseIndicator() || !hasPrayerRestore)
	{
		return null;
	}

	final int currentPrayer = client.getBoostedSkillLevel(Skill.PRAYER);
	final int maxPrayer = client.getRealSkillLevel(Skill.PRAYER);

	final int prayerPointsMissing = maxPrayer - currentPrayer;
	if (prayerPointsMissing <= 0)
	{
		return null;
	}

	final double dosePercentage = hasHolyWrench ? .27 : .25;
	final int basePointsRestored = (int) Math.floor(maxPrayer * dosePercentage);

	final int pointsRestored = basePointsRestored + 7 + bonusPrayer;

	if (prayerPointsMissing < pointsRestored)
	{
		return null;
	}

	// Purposefully using height twice here as the bounds of the prayer orb includes the number sticking out the side
	final int orbInnerSize = (int) bounds.getHeight();

	final int orbInnerX = (int) (bounds.getX() + 24); // x pos of the inside of the prayer orb
	final int orbInnerY = (int) (bounds.getY() - 1); // y pos of the inside of the prayer orb

	final long timeSinceLastTick = Duration.between(startOfLastTick, Instant.now()).toMillis();

	final float tickProgress = Math.min(timeSinceLastTick / PULSE_TIME, 1); // Cap between 0 and 1
	final double t = tickProgress * Math.PI; // Convert to 0 - pi

	graphics.setColor(ColorUtil.colorLerp(START_COLOR, END_COLOR, Math.sin(t)));
	graphics.setStroke(new BasicStroke(2));
	graphics.drawOval(orbInnerX, orbInnerY, orbInnerSize, orbInnerSize);

	return new Dimension((int) bounds.getWidth(), (int) bounds.getHeight());
}
 
Example 20
Source File: ClueScrollMusicOverlay.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	ClueScroll clue = plugin.getClue();

	if (!(clue instanceof MusicClue))
	{
		hasScrolled = false;
		return null;
	}

	MusicClue musicClue = (MusicClue) clue;

	Widget musicContainer = client.getWidget(WidgetInfo.MUSIC_WINDOW);

	if (musicContainer == null || musicContainer.isHidden())
	{
		return null;
	}

	Widget trackList = client.getWidget(WidgetInfo.MUSIC_TRACK_LIST);
	String trackToFind = musicClue.getSong();
	Widget found = null;

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

	for (Widget track : trackList.getDynamicChildren())
	{
		if (track.getText().equals(trackToFind))
		{
			found = track;
			break;
		}
	}

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

	if (!hasScrolled)
	{
		hasScrolled = true;
		plugin.scrollToWidget(WidgetInfo.MUSIC_TRACK_LIST, WidgetInfo.MUSIC_TRACK_SCROLLBAR, found);
	}
	plugin.highlightWidget(graphics, found, trackList, PADDING, null);

	return null;
}