net.runelite.client.util.ColorUtil Java Examples

The following examples show how to use net.runelite.client.util.ColorUtil. 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: SlayerTaskPanel.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private static String htmlLabel(String key, long timeMillis)
{
	if (timeMillis == Long.MAX_VALUE)
	{
		String valueStr = "N/A";
		return String.format(HTML_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR),
			key, valueStr);
	}
	else
	{
		long seconds = timeMillis / MILLIS_PER_SECOND;
		long minutes = seconds / SECONDS_PER_MINUTE;
		seconds %= 60;
		long hours = minutes / MINUTES_PER_HOUR;
		minutes %= 60;
		return String.format(HTML_TIME_LABEL_TEMPLATE, ColorUtil.toHexColor(ColorScheme.LIGHT_GRAY_COLOR),
			key, (int) hours, (int) minutes, (int) seconds);
	}
}
 
Example #2
Source File: OpponentInfoPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private String getHpString(Actor actor, boolean withColorTag)
{
	int maxHp = getMaxHp(actor);
	int health = actor.getHealthScale();
	int ratio = actor.getHealthRatio();

	final String result;
	if (maxHp != -1)
	{
		final int exactHealth = OpponentInfoOverlay.getExactHp(ratio, health, maxHp);
		result = "(" + exactHealth + "/" + maxHp + ")";
	}
	else
	{
		result = "(" + (100 * ratio) / health + "%)";
	}

	return withColorTag ? ColorUtil.colorStartTag(0xff0000) + result : result;
}
 
Example #3
Source File: AgilityPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkAndModify(MenuEntry old)
{
	//Guarding against non-first option because agility shortcuts are always that type of event.
	if (old.getOpcode() != MenuOpcode.GAME_OBJECT_FIRST_OPTION.getId())
	{
		return false;
	}

	for (Obstacle nearbyObstacle : getObstacles().values())
	{
		AgilityShortcut shortcut = nearbyObstacle.getShortcut();
		if (shortcut != null && Ints.contains(shortcut.getObstacleIds(), old.getIdentifier()))
		{
			final int reqLevel = shortcut.getLevel();
			final String requirementText = ColorUtil.getLevelColorString(reqLevel, getAgilityLevel()) + "  (level-" + reqLevel + ")";

			old.setTarget(old.getTarget() + requirementText);
			return true;
		}
	}

	return false;
}
 
Example #4
Source File: PoisonPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
String createTooltip()
{
	Duration timeLeft;
	if (nextPoisonTick.isBefore(Instant.now()) && !envenomed)
	{
		timeLeft = Duration.of(POISON_TICK_MILLIS * (lastValue - 1), ChronoUnit.MILLIS);
	}
	else
	{
		timeLeft = Duration.between(Instant.now(), nextPoisonTick).plusMillis(POISON_TICK_MILLIS * (lastValue - 1));
	}

	String line1 = MessageFormat.format("Next {0} damage: {1}</br>Time until damage: {2}",
		envenomed ? "venom" : "poison", ColorUtil.wrapWithColorTag(String.valueOf(lastDamage), Color.RED),
		getFormattedTime(Duration.between(Instant.now(), nextPoisonTick)));
	String line2 = envenomed ? "" : MessageFormat.format("</br>Time until cure: {0}", getFormattedTime(timeLeft));

	return line1 + line2;
}
 
Example #5
Source File: OverlayRenderer.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private MenuEntry[] createRightClickMenuEntries(Overlay overlay)
{
	List<OverlayMenuEntry> menuEntries = overlay.getMenuEntries();
	if (menuEntries.isEmpty())
	{
		return null;
	}

	final MenuEntry[] entries = new MenuEntry[menuEntries.size()];

	// Add in reverse order so they display correctly in the right-click menu
	for (int i = menuEntries.size() - 1; i >= 0; --i)
	{
		OverlayMenuEntry overlayMenuEntry = menuEntries.get(i);

		final MenuEntry entry = new MenuEntry();
		entry.setOption(overlayMenuEntry.getOption());
		entry.setTarget(ColorUtil.wrapWithColorTag(overlayMenuEntry.getTarget(), JagexColors.MENU_TARGET));
		entry.setType(overlayMenuEntry.getMenuAction().getId());
		entry.setIdentifier(overlayManager.getOverlays().indexOf(overlay)); // overlay id

		entries[i] = entry;
	}

	return entries;
}
 
Example #6
Source File: RuneliteColorPicker.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Parses the hex input, updating the color with the new values.
 */
private void updateHex()
{
	String hex = hexInput.getText();
	if (Strings.isNullOrEmpty(hex))
	{
		hex = BLANK_HEX;
	}

	Color color = ColorUtil.fromHex(hex);
	if (color == null)
	{
		return;
	}

	if (!alphaHidden && ColorUtil.isAlphaHex(hex))
	{
		alphaSlider.update(color.getAlpha());
	}

	colorChange(color);
	updatePanels();
}
 
Example #7
Source File: RecentColors.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private static JPanel createBox(final Color color, final Consumer<Color> consumer, final boolean alphaHidden)
{
	final JPanel box = new JPanel();
	String hex = alphaHidden ? ColorUtil.colorToHexCode(color) : ColorUtil.colorToAlphaHexCode(color);

	box.setBackground(color);
	box.setOpaque(true);
	box.setPreferredSize(new Dimension(BOX_SIZE, BOX_SIZE));
	box.setToolTipText("#" + hex.toUpperCase());
	box.addMouseListener(new MouseAdapter()
	{
		@Override
		public void mouseClicked(MouseEvent e)
		{
			consumer.accept(color);
		}
	});

	return box;
}
 
Example #8
Source File: PlayerIndicatorsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private String decorateTarget(String oldTarget, Decorations decorations)
{
	String newTarget = oldTarget;

	if (decorations.getColor() != null && config.colorPlayerMenu())
	{
		// strip out existing <col...
		int idx = oldTarget.indexOf('>');
		if (idx != -1)
		{
			newTarget = oldTarget.substring(idx + 1);
		}

		newTarget = ColorUtil.prependColorTag(newTarget, decorations.getColor());
	}

	if (decorations.getImage() != -1 && config.showFriendsChatRanks())
	{
		newTarget = "<img=" + decorations.getImage() + ">" + newTarget;
	}

	return newTarget;
}
 
Example #9
Source File: KingdomCounter.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private String bestResources()
{
	Kingdom maxKingdom = plugin.getMaxKingdom();

	if (maxKingdom.resourceProfit == null)
	{
		return ColorUtil.wrapWithColorTag("Calculating resource profits...", Color.ORANGE);
	}

	StringBuilder maxRewards = new StringBuilder(ColorUtil.wrapWithColorTag("Resource Yields </br>", Color.YELLOW));

	for (Map.Entry<ResourceType, Integer> entry : maxKingdom.resourceProfit.entrySet())
	{
		maxRewards.append(entry.getKey().getType()).append(": ").append(QuantityFormatter.formatNumber(entry.getValue())).append("</br>");
	}
	return maxRewards.toString();
}
 
Example #10
Source File: KingdomCounter.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private String rewardInfo()
{
	Kingdom personalKingdom = plugin.getPersonalKingdom();

	if (personalKingdom.resourceProfit == null)
	{
		return ColorUtil.wrapWithColorTag("Calculating reward info...", Color.ORANGE);
	}

	StringBuilder currentRewardSettings = new StringBuilder(ColorUtil.wrapWithColorTag("Current Rewards: ", Color.YELLOW)
		+ QuantityFormatter.formatNumber(personalKingdom.grossProfit) + "</br>");

	for (Map.Entry<Reward, Integer> entry : personalKingdom.rewardQuantity.entrySet())
	{
		currentRewardSettings.append(entry.getKey().getName()).append(" x ").append(QuantityFormatter.formatNumber(entry.getValue())).append("</br>");
	}
	return currentRewardSettings.toString();
}
 
Example #11
Source File: CustomSwapper.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
private void dispatchError(String error)
{
	String str = ColorUtil.wrapWithColorTag("Custom Swapper", Color.MAGENTA)
		+ " has encountered an "
		+ ColorUtil.wrapWithColorTag("error", Color.RED)
		+ ": "
		+ error;

	client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", str, null);
}
 
Example #12
Source File: WidgetInspector.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void onMenuEntryAdded(MenuEntryAdded event)
{
	if (!pickerSelected)
	{
		return;
	}

	MenuEntry[] menuEntries = client.getMenuEntries();

	for (int i = 0; i < menuEntries.length; i++)
	{
		MenuEntry entry = menuEntries[i];
		if (entry.getOpcode() != MenuOpcode.ITEM_USE_ON_WIDGET.getId()
			&& entry.getOpcode() != MenuOpcode.SPELL_CAST_ON_WIDGET.getId())
		{
			continue;
		}
		String name = WidgetInfo.TO_GROUP(entry.getParam1()) + "." + WidgetInfo.TO_CHILD(entry.getParam1());

		if (entry.getParam0() != -1)
		{
			name += " [" + entry.getParam0() + "]";
		}

		Color color = colorForWidget(i, menuEntries.length);

		entry.setTarget(ColorUtil.wrapWithColorTag(name, color));
	}

	client.setMenuEntries(menuEntries);
}
 
Example #13
Source File: KeyRemappingPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
void unlockChat()
{
	Widget chatboxInput = client.getWidget(WidgetInfo.CHATBOX_INPUT);
	if (chatboxInput != null && client.getGameState() == GameState.LOGGED_IN)
	{
		final boolean isChatboxTransparent = client.isResized() && client.getVar(Varbits.TRANSPARENT_CHATBOX) == 1;
		final Color textColor = isChatboxTransparent ? JagexColors.CHAT_TYPED_TEXT_TRANSPARENT_BACKGROUND : JagexColors.CHAT_TYPED_TEXT_OPAQUE_BACKGROUND;
		setChatboxWidgetInput(chatboxInput, ColorUtil.wrapWithColorTag(client.getVar(VarClientStr.CHATBOX_TYPED_TEXT) + "*", textColor));
	}
}
 
Example #14
Source File: OpponentInfoPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void startUp()
{
	this.attackingColTag = ColorUtil.colorTag(config.attackingColor());
	this.showAttackers = config.showAttackersMenu();
	this.showAttacking = config.showAttackingMenu();
	this.showHitpoints = config.showHitpointsMenu();

	updateMenuSubs();

	overlayManager.add(opponentInfoOverlay);
	overlayManager.add(playerComparisonOverlay);
}
 
Example #15
Source File: PartyPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Nullable
PartyData getPartyData(final UUID uuid)
{
	final PartyMember memberById = party.getMemberById(uuid);

	if (memberById == null)
	{
		// This happens when you are not in party but you still receive message.
		// Can happen if you just left party and you received message before message went through
		// in ws service
		return null;
	}

	return partyDataMap.computeIfAbsent(uuid, (u) ->
	{
		final String name = memberById.getName();
		final WorldMapPoint worldMapPoint = new PartyWorldMapPoint(new WorldPoint(0, 0, 0), memberById);
		worldMapPoint.setTooltip(name);

		// When first joining a party, other members can join before getting a join for self
		PartyMember partyMember = party.getLocalMember();
		if (partyMember == null || !u.equals(partyMember.getMemberId()))
		{
			worldMapManager.add(worldMapPoint);
		}

		return new PartyData(u, name, worldMapPoint, ColorUtil.fromObject(name));
	});
}
 
Example #16
Source File: SlayerPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void addCounter()
{
	if (!config.showInfobox() || counter != null || currentTask == null || Strings.isNullOrEmpty(currentTask.getTaskName()))
	{
		return;
	}

	Task task = Task.getTask(currentTask.getTaskName());
	AsyncBufferedImage taskImg = getImageForTask(task);
	String taskTooltip = ColorUtil.wrapWithColorTag("%s", new Color(255, 119, 0)) + "</br>";

	if (currentTask.getTaskLocation() != null && !currentTask.getTaskLocation().isEmpty())
	{
		taskTooltip += currentTask.getTaskLocation() + "</br>";
	}

	taskTooltip += ColorUtil.wrapWithColorTag("Pts:", Color.YELLOW)
		+ " %s</br>"
		+ ColorUtil.wrapWithColorTag("Streak:", Color.YELLOW)
		+ " %s";

	if (currentTask.getInitialAmount() > 0)
	{
		taskTooltip += "</br>"
			+ ColorUtil.wrapWithColorTag("Start:", Color.YELLOW)
			+ " " + currentTask.getInitialAmount();
	}

	counter = new TaskCounter(taskImg, this, currentTask.getAmount());
	counter.setTooltip(String.format(taskTooltip, capsString(currentTask.getTaskName()), points, streak));

	infoBoxManager.addInfoBox(counter);
}
 
Example #17
Source File: PoisonPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
String createTooltip()
{
	String line1 = MessageFormat.format("Next {0} damage: {1}</br>Time until damage: {2}",
		envenomed ? "venom" : "poison", ColorUtil.wrapWithColorTag(String.valueOf(lastDamage), Color.RED), getFormattedTime(nextPoisonTick));
	String line2 = envenomed ? "" : MessageFormat.format("</br>Time until cure: {0}", getFormattedTime(poisonNaturalCure));

	return line1 + line2;
}
 
Example #18
Source File: ItemStatOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private String getChangeString(
	final double value,
	final boolean inverse,
	final boolean showPercent)
{
	final Color plus = Positivity.getColor(config, Positivity.BETTER_UNCAPPED);
	final Color minus = Positivity.getColor(config, Positivity.WORSE);

	if (value == 0)
	{
		return "";
	}

	final Color color;

	if (inverse)
	{
		color = value > 0 ? minus : plus;
	}
	else
	{
		color = value > 0 ? plus : minus;
	}

	final String prefix = value > 0 ? "+" : "";
	final String suffix = showPercent ? "%" : "";
	final String valueString = QuantityFormatter.formatNumber(value);
	return ColorUtil.wrapWithColorTag(prefix + valueString + suffix, color);
}
 
Example #19
Source File: WintertodtOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	if (!plugin.isInWintertodt() || !wintertodtConfig.showOverlay())
	{
		return null;
	}

	panelComponent.getChildren().add(TitleComponent.builder()
		.text("Points in inventory")
		.color(Color.WHITE)
		.build());

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

	tableComponent.addRow(ColorUtil.prependColorTag("Status:", Color.WHITE), ColorUtil.prependColorTag(plugin.getCurrentActivity().getActionString(), plugin.getCurrentActivity() == WintertodtActivity.IDLE ? Color.RED : Color.GREEN));

	int firemakingLvl = client.getRealSkillLevel(Skill.FIREMAKING);

	int rootsScore = plugin.getNumRoots() * WINTERTODT_ROOTS_MULTIPLIER;
	int rootsXp = plugin.getNumRoots() * Math.round(2 + (3 * firemakingLvl));

	tableComponent.addRow(ColorUtil.prependColorTag("Roots:", Color.WHITE), ColorUtil.prependColorTag(rootsScore + " pts (" + rootsXp + " xp)", plugin.getNumRoots() > 0 ? Color.GREEN : Color.RED));

	int kindlingScore = plugin.getNumKindling() * WINTERTODT_KINDLING_MULTIPLIER;
	long kindlingXp = plugin.getNumKindling() * Math.round(3.8 * firemakingLvl);

	tableComponent.addRow(ColorUtil.prependColorTag("Kindling:", Color.WHITE), ColorUtil.prependColorTag(kindlingScore + " pts (" + kindlingXp + " xp)", plugin.getNumKindling() > 0 ? Color.GREEN : Color.RED));
	tableComponent.addRow(ColorUtil.prependColorTag("Total:", Color.WHITE), ColorUtil.prependColorTag((rootsScore + kindlingScore) + " pts (" + (rootsXp + kindlingXp) + " xp)", (rootsScore + kindlingScore > 0) ? Color.GREEN : Color.RED));

	panelComponent.getChildren().add(tableComponent);

	return super.render(graphics);
}
 
Example #20
Source File: PlayerInfoCustomIndicator.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Color getTextColor()
{
	float currLvl = 0;
	switch (type)
	{
		case HEALTH:
			currLvl = client.getBoostedSkillLevel(Skill.HITPOINTS) / (float) client.getRealSkillLevel(Skill.HITPOINTS);
			break;
		case PRAYER:
			currLvl = client.getBoostedSkillLevel(Skill.PRAYER) / (float) client.getRealSkillLevel(Skill.PRAYER);
			break;
		case ENERGY:
			currLvl = client.getEnergy() / 100.0F;
			break;
		case SPECIAL:
			currLvl = client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT) / 1000.0F;
			break;
		case WORLD:
			currLvl = 1000; // hacky
	}

	if (currLvl > 1.0)
	{
		return config.colorHigh();
	}
	else if (currLvl > 0.5)
	{
		return ColorUtil.colorLerp(config.colorMed(), config.colorHigh(), (currLvl * 2) - 1.0F);
	}
	else
	{
		return ColorUtil.colorLerp(config.colorLow(), config.colorMed(), (currLvl * 2));
	}
}
 
Example #21
Source File: ChatHistoryPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded entry)
{
	final ChatboxTab tab = ChatboxTab.of(entry.getParam1());

	if (tab == null || !config.clearHistory() || !Text.removeTags(entry.getOption()).equals(tab.getAfter()))
	{
		return;
	}

	final MenuEntry clearEntry = new MenuEntry();
	clearEntry.setTarget("");
	clearEntry.setOpcode(MenuOpcode.RUNELITE.getId());
	clearEntry.setParam0(entry.getParam0());
	clearEntry.setParam1(entry.getParam1());

	if (tab == ChatboxTab.GAME)
	{
		// keep type as the original CC_OP to correctly group "Game: Clear history" with
		// other tab "Game: *" options.
		clearEntry.setOpcode(entry.getOpcode());
	}

	final StringBuilder messageBuilder = new StringBuilder();

	if (tab != ChatboxTab.ALL)
	{
		messageBuilder.append(ColorUtil.wrapWithColorTag(tab.getName() + ": ", Color.YELLOW));
	}

	messageBuilder.append(CLEAR_HISTORY);
	clearEntry.setOption(messageBuilder.toString());

	final MenuEntry[] menuEntries = client.getMenuEntries();
	client.setMenuEntries(ArrayUtils.insert(menuEntries.length - 1, menuEntries, clearEntry));
}
 
Example #22
Source File: DevToolsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
	if (!examine.isActive())
	{
		return;
	}

	MenuAction action = MenuAction.of(event.getType());

	if (EXAMINE_MENU_ACTIONS.contains(action))
	{
		MenuEntry[] entries = client.getMenuEntries();
		MenuEntry entry = entries[entries.length - 1];

		final int identifier = event.getIdentifier();
		String info = "ID: ";

		if (action == MenuAction.EXAMINE_NPC)
		{
			NPC npc = client.getCachedNPCs()[identifier];
			info += npc.getId();
		}
		else
		{
			info += identifier;

			if (action == MenuAction.EXAMINE_OBJECT)
			{
				WorldPoint point = WorldPoint.fromScene(client, entry.getParam0(), entry.getParam1(), client.getPlane());
				info += " X: " + point.getX() + " Y: " + point.getY();
			}
		}

		entry.setTarget(entry.getTarget() + " " + ColorUtil.prependColorTag("(" + info + ")", JagexColors.MENU_TARGET));
		client.setMenuEntries(entries);
	}
}
 
Example #23
Source File: TimestampPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onScriptCallbackEvent(ScriptCallbackEvent event)
{
	if (!event.getEventName().equals("addTimestamp"))
	{
		return;
	}

	int[] intStack = client.getIntStack();
	int intStackSize = client.getIntStackSize();

	String[] stringStack = client.getStringStack();
	int stringStackSize = client.getStringStackSize();

	int messageId = intStack[intStackSize - 1];

	MessageNode messageNode = client.getMessages().get(messageId);

	String timestamp = generateTimestamp(messageNode.getTimestamp(), ZoneId.systemDefault()) + " ";

	Color timestampColour = getTimestampColour();
	if (timestampColour != null)
	{
		timestamp = ColorUtil.wrapWithColorTag(timestamp, timestampColour);
	}

	stringStack[stringStackSize - 1] = timestamp;
}
 
Example #24
Source File: ItemStatOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private String getChangeString(
	final double value,
	final boolean inverse,
	final boolean showPercent)
{
	final Color plus = Positivity.getColor(config, Positivity.BETTER_UNCAPPED);
	final Color minus = Positivity.getColor(config, Positivity.WORSE);

	if (value == 0)
	{
		return "";
	}

	final Color color;

	if (inverse)
	{
		color = value > 0 ? minus : plus;
	}
	else
	{
		color = value > 0 ? plus : minus;
	}

	final String prefix = value > 0 ? "+" : "";
	final String suffix = showPercent ? "%" : "";
	final String valueString = QuantityFormatter.formatNumber(value);
	return ColorUtil.wrapWithColorTag(prefix + valueString + suffix, color);
}
 
Example #25
Source File: RecentColors.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
JPanel build(final Consumer<Color> consumer, final boolean alphaHidden)
{
	load();

	JPanel container = new JPanel(new GridBagLayout());

	GridBagConstraints cx = new GridBagConstraints();
	cx.insets = new Insets(0, 1, 4, 2);
	cx.gridy = 0;
	cx.gridx = 0;
	cx.anchor = GridBagConstraints.WEST;

	for (String s : recentColors)
	{
		if (cx.gridx == MAX / 2)
		{
			cx.gridy++;
			cx.gridx = 0;
		}

		// Make sure the last element stays in line with all of the others
		if (container.getComponentCount() == recentColors.size() - 1)
		{
			cx.weightx = 1;
			cx.gridwidth = MAX / 2 - cx.gridx;
		}

		container.add(createBox(ColorUtil.fromString(s), consumer, alphaHidden), cx);
		cx.gridx++;
	}

	return container;
}
 
Example #26
Source File: ColorValueSlider.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void moveTarget(int x, boolean shouldUpdate)
{
	value = Ints.constrainToRange(x, ColorUtil.MIN_RGB_VALUE + KNOB_WIDTH, ColorUtil.MAX_RGB_VALUE + KNOB_WIDTH);
	paintImmediately(0, 0, this.getWidth(), this.getHeight());

	if (shouldUpdate && onValueChanged != null)
	{
		onValueChanged.accept(getValue());
	}
}
 
Example #27
Source File: ColorValuePanel.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void update(int value)
{
	value = ColorUtil.constrainValue(value);

	slider.setValue(value);
	input.setText(value + "");
}
 
Example #28
Source File: ChatMessageManager.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onScriptCallbackEvent(ScriptCallbackEvent scriptCallbackEvent)
{
	final String eventName = scriptCallbackEvent.getEventName();

	switch (eventName)
	{
		case "privateChatFrom":
		case "privateChatTo":
		case "privateChatSplitFrom":
		case "privateChatSplitTo":
			break;
		default:
			return;
	}

	boolean isChatboxTransparent = client.isResized() && client.getVar(Varbits.TRANSPARENT_CHATBOX) == 1;
	Color usernameColor = isChatboxTransparent ? chatColorConfig.transparentPrivateUsernames() : chatColorConfig.opaquePrivateUsernames();
	if (usernameColor == null)
	{
		return;
	}

	final String[] stringStack = client.getStringStack();
	final int stringStackSize = client.getStringStackSize();

	// Stack is: To/From playername :
	String toFrom = stringStack[stringStackSize - 3];
	stringStack[stringStackSize - 3] = ColorUtil.prependColorTag(toFrom, usernameColor);
}
 
Example #29
Source File: ChatMessageManager.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private String recolorMessage(boolean transparent, String message, ChatMessageType messageType)
{
	final Collection<ChatColor> chatColors = colorCache.get(messageType);
	final AtomicReference<String> resultMessage = new AtomicReference<>(message);

	// Replace custom formatting with actual colors
	chatColors.stream()
		.filter(chatColor -> chatColor.isTransparent() == transparent)
		.forEach(chatColor ->
			resultMessage.getAndUpdate(oldMessage -> oldMessage.replaceAll(
				"<col" + chatColor.getType().name() + ">",
				ColorUtil.colorTag(chatColor.getColor()))));

	return resultMessage.get();
}
 
Example #30
Source File: SlayerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addCounter()
{
	if (!config.showInfobox() || counter != null || Strings.isNullOrEmpty(taskName))
	{
		return;
	}

	Task task = Task.getTask(taskName);
	int itemSpriteId = ItemID.ENCHANTED_GEM;
	if (task != null)
	{
		itemSpriteId = task.getItemSpriteId();
	}

	BufferedImage taskImg = itemManager.getImage(itemSpriteId);
	String taskTooltip = ColorUtil.wrapWithColorTag("%s", new Color(255, 119, 0)) + "</br>";

	if (taskLocation != null && !taskLocation.isEmpty())
	{
		taskTooltip += taskLocation + "</br>";
	}

	taskTooltip += ColorUtil.wrapWithColorTag("Pts:", Color.YELLOW)
		+ " %s</br>"
		+ ColorUtil.wrapWithColorTag("Streak:", Color.YELLOW)
		+ " %s";

	if (initialAmount > 0)
	{
		taskTooltip += "</br>"
			+ ColorUtil.wrapWithColorTag("Start:", Color.YELLOW)
			+ " " + initialAmount;
	}

	counter = new TaskCounter(taskImg, this, amount);
	counter.setTooltip(String.format(taskTooltip, capsString(taskName), config.points(), config.streak()));

	infoBoxManager.addInfoBox(counter);
}