net.runelite.api.events.BeforeRender Java Examples

The following examples show how to use net.runelite.api.events.BeforeRender. 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: MusicPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onBeforeRender(final BeforeRender event)
{
	// Tooltips are auto-cleared before each render frame; create a new updated one for this frame
	if (hoveredSlider != null)
	{
		final int value = hoveredSlider.getValue(musicConfig, client);
		final int percent = (int) Math.round((value * 100.0 / hoveredSlider.getMax()));

		tooltipManager.add(new Tooltip(hoveredSlider.getName() + ": " + percent + "%"));
		hoveredSlider = null;
	}
}
 
Example #2
Source File: OpponentInfoPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void updateMenuSubs()
{
	if (showAttackers || showAttacking || showHitpoints)
	{
		eventBus.subscribe(BeforeRender.class, MENU, this::onBeforeRender);
		eventBus.subscribe(MenuOpened.class, MENU, this::onMenuOpened);
	}
	else
	{
		eventBus.unregister(MENU);
	}
}
 
Example #3
Source File: AgilityPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void onBeforeRender(BeforeRender event)
{
	if (client.isMenuOpen() || client.getMenuOptionCount() <= 0)
	{
		return;
	}

	final MenuEntry entry = client.getLeftClickMenuEntry();
	if (checkAndModify(entry))
	{
		client.setLeftClickMenuEntry(entry);
	}
}
 
Example #4
Source File: MusicPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onBeforeRender(final BeforeRender event)
{
	// Tooltips are auto-cleared before each render frame; create a new updated one for this frame
	if (hoveredSlider != null)
	{
		final int value = hoveredSlider.getValue(musicConfig, client);
		final int percent = (int) Math.round((value * 100.0 / hoveredSlider.getMax()));

		tooltipManager.add(new Tooltip(hoveredSlider.getName() + ": " + percent + "%"));
		hoveredSlider = null;
	}
}
 
Example #5
Source File: InterfaceStylesPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onBeforeRender(BeforeRender event)
{
	adjustWidgetDimensions();
}
 
Example #6
Source File: SkyboxPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onBeforeRender(BeforeRender r)
{
	if (skybox == null || client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	Player player = client.getLocalPlayer();
	if (player == null)
	{
		return;
	}

	if
	(
		config.overrideMode() == SkyOverrideMode.ALL ||
		(config.overrideMode() == SkyOverrideMode.OVERWORLD && client.getLocalPlayer().getWorldLocation().getY() < 4200)
	)
	{
		client.setSkyboxColor(config.customColor().getRGB());
		return;
	}


	int px, py;
	if (client.getOculusOrbState() == 1)
	{
		px = client.getOculusOrbFocalPointX();
		py = client.getOculusOrbFocalPointY();
	}
	else
	{
		LocalPoint p = client.getLocalPlayer().getLocalLocation();
		px = p.getX();
		py = p.getY();
	}

	// Inverse of camera location / 2
	int spx = -((client.getCameraX() - px) >> 1);
	int spy = -((client.getCameraY() - py) >> 1);

	int baseX = client.getBaseX();
	int baseY = client.getBaseY();

	client.setSkyboxColor(skybox.getColorForPoint(
		baseX + ((px + spx) / 128.f),
		baseY + ((py + spy) / 128.f),
		baseX + (px / 128),
		baseY + (py / 128),
		client.getPlane(),
		client.getTextureProvider().getBrightness(),
		client.isInInstancedRegion() ? this::mapChunk : null
	));
}
 
Example #7
Source File: AgilityPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void addMenuSubscriptions()
{
	eventBus.subscribe(BeforeRender.class, MENU_SUBS, this::onBeforeRender);
	eventBus.subscribe(MenuOpened.class, MENU_SUBS, this::onMenuOpened);
}
 
Example #8
Source File: Anonymizer.java    From ExternalPlugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onBeforeRender(BeforeRender event)
{
	if (!config.hideRsn() || client == null || client.getGameState() != GameState.LOGGED_IN || name.isBlank() || name.isEmpty())
	{
		return;
	}

	RSClient rsClient = (RSClient) client;

	if (rsClient == null || rsClient.getWidgets() == null)
	{
		return;
	}

	for (RSWidget[] parent : rsClient.getWidgets())
	{
		if (parent == null)
		{
			continue;
		}

		for (RSWidget widget : parent)
		{
			parseWidget(widget);

			if (widget.getDynamicChildren() != null && widget.getDynamicChildren().length > 0)
			{
				Widget[] dynamicChildren = widget.getDynamicChildren();
				for (int i = 0; i < dynamicChildren.length; i++)
				{
					Widget dynamicChild = dynamicChildren[i];

					if (dynamicChild.getId() == 10616890 && dynamicChild.getText().contains(name))
					{
						parseWidget(dynamicChild);
						try
						{
							Widget text = dynamicChildren[i + 1];
							text.setOriginalX(80);
							text.revalidate();
						}
						catch (Exception ignored)
						{
						}
					}
				}
			}

			if (widget.getStaticChildren() != null && widget.getStaticChildren().length > 0)
			{
				for (Widget staticChild : widget.getStaticChildren())
				{
					parseWidget(staticChild);
				}
			}

			if (widget.getNestedChildren() != null && widget.getNestedChildren().length > 0)
			{
				for (Widget nestedChild : widget.getNestedChildren())
				{
					parseWidget(nestedChild);
				}
			}
		}
	}
}
 
Example #9
Source File: OverlayRenderer.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onBeforeRender(BeforeRender event)
{
	menuEntries = null;
}
 
Example #10
Source File: InterfaceStylesPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onBeforeRender(BeforeRender event)
{
	adjustWidgetDimensions();
}
 
Example #11
Source File: SkyboxPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onBeforeRender(BeforeRender r)
{
	if (skybox == null || client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	Player player = client.getLocalPlayer();
	if (player == null)
	{
		return;
	}

	int px, py;
	if (client.getOculusOrbState() == 1)
	{
		px = client.getOculusOrbFocalPointX();
		py = client.getOculusOrbFocalPointY();
	}
	else
	{
		LocalPoint p = client.getLocalPlayer().getLocalLocation();
		px = p.getX();
		py = p.getY();
	}

	// Inverse of camera location / 2
	int spx = -((client.getCameraX() - px) >> 1);
	int spy = -((client.getCameraY() - py) >> 1);

	int baseX = client.getBaseX();
	int baseY = client.getBaseY();

	client.setSkyboxColor(skybox.getColorForPoint(
		baseX + ((px + spx) / 128.f),
		baseY + ((py + spy) / 128.f),
		baseX + (px / 128),
		baseY + (py / 128),
		client.getPlane(),
		client.getTextureProvider().getBrightness(),
		client.isInInstancedRegion() ? this::mapChunk : null
	));
}