net.runelite.api.VarClientInt Java Examples

The following examples show how to use net.runelite.api.VarClientInt. 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: VarInspector.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void onVarClientIntChanged(VarClientIntChanged e)
{
	int idx = e.getIndex();
	int neew = (Integer) client.getVarcMap().getOrDefault(idx, 0);
	int old = (Integer) varcs.getOrDefault(idx, 0);
	varcs.put(idx, neew);

	if (old != neew)
	{
		String name = String.format("%d", idx);
		for (VarClientInt varc : VarClientInt.values())
		{
			if (varc.getIndex() == idx)
			{
				name = String.format("%s(%d)", varc.name(), idx);
				break;
			}
		}
		addVarLog(VarType.VARCINT, name, old, neew);
	}
}
 
Example #2
Source File: CameraOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Dimension render(final Graphics2D graphics)
{
	final Widget slider = client.getWidget(WidgetInfo.OPTIONS_CAMERA_ZOOM_SLIDER_HANDLE);
	final Point mousePos = client.getMouseCanvasPosition();

	if (slider == null || slider.isHidden() || !slider.getBounds().contains(mousePos.getX(), mousePos.getY()))
	{
		return null;
	}

	final int value = client.getVar(VarClientInt.CAMERA_ZOOM_RESIZABLE_VIEWPORT);
	final int max = config.innerLimit() ? config.INNER_ZOOM_LIMIT : CameraPlugin.DEFAULT_INNER_ZOOM_LIMIT;

	tooltipManager.add(new Tooltip("Camera Zoom: " + value + " / " + max));
	return null;
}
 
Example #3
Source File: CameraOverlay.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public Dimension render(final Graphics2D graphics)
{
	final Widget slider = client.getWidget(WidgetInfo.OPTIONS_CAMERA_ZOOM_SLIDER_HANDLE);
	final Point mousePos = client.getMouseCanvasPosition();

	if (slider == null || slider.isHidden() || !slider.getBounds().contains(mousePos.getX(), mousePos.getY()))
	{
		return null;
	}

	final int value = client.getVar(VarClientInt.CAMERA_ZOOM_RESIZABLE_VIEWPORT);
	final int max = config.innerLimit() ? config.INNER_ZOOM_LIMIT : CameraPlugin.DEFAULT_INNER_ZOOM_LIMIT;

	tooltipManager.add(new Tooltip("Camera Zoom: " + value + " / " + max));
	return null;
}
 
Example #4
Source File: VarInspector.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onVarClientIntChanged(VarClientIntChanged e)
{
	int idx = e.getIndex();
	int neew = (Integer) client.getVarcMap().getOrDefault(idx, 0);
	int old = (Integer) varcs.getOrDefault(idx, 0);
	varcs.put(idx, neew);

	if (old != neew)
	{
		String name = String.format("%d", idx);
		for (VarClientInt varc : VarClientInt.values())
		{
			if (varc.getIndex() == idx)
			{
				name = String.format("%s(%d)", varc.name(), idx);
				break;
			}
		}
		addVarLog(VarType.VARCINT, name, old, neew);
	}
}
 
Example #5
Source File: ChatHistoryPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e)
{
	if (e.getKeyCode() != CYCLE_HOTKEY || !config.pmTargetCycling())
	{
		return;
	}

	if (client.getVar(VarClientInt.INPUT_TYPE) != InputType.PRIVATE_MESSAGE.getType())
	{
		return;
	}

	clientThread.invoke(() ->
	{
		final String target = findPreviousFriend();
		if (target == null)
		{
			return;
		}

		final String currentMessage = client.getVar(VarClientStr.INPUT_TEXT);

		client.runScript(ScriptID.OPEN_PRIVATE_MESSAGE_INTERFACE, target);

		client.setVar(VarClientStr.INPUT_TEXT, currentMessage);
		client.runScript(ScriptID.CHAT_TEXT_INPUT_REBUILD, "");
	});
}
 
Example #6
Source File: QuestListPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onVarClientIntChanged(VarClientIntChanged varClientIntChanged)
{
	if (varClientIntChanged.getIndex() == VarClientInt.INVENTORY_TAB.getIndex())
	{
		if (isChatboxOpen() && !isOnQuestTab())
		{
			chatboxPanelManager.close();
		}
	}
}
 
Example #7
Source File: KeyRemappingPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
boolean chatboxFocused()
{
	Widget chatboxParent = client.getWidget(WidgetInfo.CHATBOX_PARENT);
	if (chatboxParent == null || chatboxParent.getOnKeyListener() == null)
	{
		return false;
	}

	// the search box on the world map can be focused, and chat input goes there, even
	// though the chatbox still has its key listener.
	Widget worldMapSearch = client.getWidget(WidgetInfo.WORLD_MAP_SEARCH);
	return worldMapSearch == null || client.getVar(VarClientInt.WORLD_MAP_SEARCH_FOCUSED) != 1;
}
 
Example #8
Source File: ChatboxPanelManager.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void unsafeOpenInput(ChatboxInput input)
{
	client.runScript(ScriptID.MESSAGE_LAYER_OPEN, 0);

	eventBus.register(input);
	if (input instanceof KeyListener)
	{
		keyManager.registerKeyListener((KeyListener) input);
	}
	if (input instanceof MouseListener)
	{
		mouseManager.registerMouseListener((MouseListener) input);
	}
	if (input instanceof MouseWheelListener)
	{
		mouseManager.registerMouseWheelListener((MouseWheelListener) input);
	}

	if (currentInput != null)
	{
		killCurrentPanel();
	}

	currentInput = input;
	client.setVar(VarClientInt.INPUT_TYPE, InputType.RUNELITE_CHATBOX_PANEL.getType());
	client.getWidget(WidgetInfo.CHATBOX_TITLE).setHidden(true);
	client.getWidget(WidgetInfo.CHATBOX_FULL_INPUT).setHidden(true);

	Widget c = getContainerWidget();
	c.deleteAllChildren();
	c.setOnDialogAbortListener((JavaScriptCallback) ev -> this.unsafeCloseInput());
	input.open();
}
 
Example #9
Source File: ChatHistoryPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e)
{
	if (e.getKeyCode() != CYCLE_HOTKEY || !config.pmTargetCycling())
	{
		return;
	}

	if (client.getVar(VarClientInt.INPUT_TYPE) != InputType.PRIVATE_MESSAGE.getType())
	{
		return;
	}

	clientThread.invoke(() ->
	{
		final String target = findPreviousFriend();
		if (target == null)
		{
			return;
		}

		final String currentMessage = client.getVar(VarClientStr.INPUT_TEXT);

		client.runScript(ScriptID.OPEN_PRIVATE_MESSAGE_INTERFACE, target);

		client.setVar(VarClientStr.INPUT_TEXT, currentMessage);
		client.runScript(ScriptID.CHAT_TEXT_INPUT_REBUILD, "");
	});
}
 
Example #10
Source File: QuestListPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onVarClientIntChanged(VarClientIntChanged varClientIntChanged)
{
	if (varClientIntChanged.getIndex() == VarClientInt.INTERFACE_TAB.getIndex() && isChatboxOpen() && isNotOnQuestTab())
	{
		chatboxPanelManager.close();
	}
}
 
Example #11
Source File: KeyRemappingPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
boolean chatboxFocused()
{
	Widget chatboxParent = client.getWidget(WidgetInfo.CHATBOX_PARENT);
	if (chatboxParent == null || chatboxParent.getOnKeyListener() == null)
	{
		return false;
	}

	// the search box on the world map can be focused, and chat input goes there, even
	// though the chatbox still has its key listener.
	Widget worldMapSearch = client.getWidget(WidgetInfo.WORLD_MAP_SEARCH);
	return worldMapSearch == null || client.getVar(VarClientInt.WORLD_MAP_SEARCH_FOCUSED) != 1;
}
 
Example #12
Source File: DailyTasksPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onGameTick(GameTick event)
{
	long currentTime = System.currentTimeMillis();
	boolean dailyReset = !loggingIn && currentTime - lastReset > ONE_DAY;

	if ((dailyReset || loggingIn)
		&& client.getVar(VarClientInt.MEMBERSHIP_STATUS) == 1)
	{
		// Round down to the nearest day
		lastReset = (long) Math.floor(currentTime / ONE_DAY) * ONE_DAY;
		loggingIn = false;

		if (config.showHerbBoxes())
		{
			checkHerbBoxes(dailyReset);
		}

		if (config.showStaves())
		{
			checkStaves(dailyReset);
		}

		if (config.showEssence())
		{
			checkEssence(dailyReset);
		}

		if (config.showRunes())
		{
			checkRunes(dailyReset);
		}

		if (config.showSand())
		{
			checkSand(dailyReset);
		}

		if (config.showFlax())
		{
			checkFlax(dailyReset);
		}

		if (config.showBonemeal())
		{
			checkBonemeal(dailyReset);
		}

		if (config.showDynamite())
		{
			checkDynamite(dailyReset);
		}

		if (config.showArrows())
		{
			checkArrows(dailyReset);
		}
	}
}
 
Example #13
Source File: MusicPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private boolean isOnMusicTab()
{
	return client.getVar(VarClientInt.INTERFACE_TAB) == 13;
}
 
Example #14
Source File: QuestListPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private boolean isOnQuestTab()
{
	return client.getVar(Varbits.QUEST_TAB) == 0 && client.getVar(VarClientInt.INVENTORY_TAB) == 2;
}
 
Example #15
Source File: DailyTasksPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onGameTick(GameTick event)
{
	long currentTime = System.currentTimeMillis();
	boolean dailyReset = !loggingIn && currentTime - lastReset > ONE_DAY;

	if ((dailyReset || loggingIn)
		&& client.getVar(VarClientInt.MEMBERSHIP_STATUS) == 1)
	{
		// Round down to the nearest day
		lastReset = (long) Math.floor(currentTime / ONE_DAY) * ONE_DAY;
		loggingIn = false;

		if (config.showHerbBoxes())
		{
			checkHerbBoxes(dailyReset);
		}

		if (config.showStaves())
		{
			checkStaves(dailyReset);
		}

		if (config.showEssence())
		{
			checkEssence(dailyReset);
		}

		if (config.showRunes())
		{
			checkRunes(dailyReset);
		}

		if (config.showSand())
		{
			checkSand(dailyReset);
		}

		if (config.showFlax())
		{
			checkFlax(dailyReset);
		}

		if (config.showBonemeal())
		{
			checkBonemeal(dailyReset);
		}

		if (config.showArrows())
		{
			checkArrows(dailyReset);
		}

		if (config.showDynamite())
		{
			checkDynamite(dailyReset);
		}
	}
}
 
Example #16
Source File: MouseHighlightOverlay.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	if (client.isMenuOpen())
	{
		return null;
	}

	MenuEntry[] menuEntries = client.getMenuEntries();
	int last = menuEntries.length - 1;

	if (last < 0)
	{
		return null;
	}

	MenuEntry menuEntry = menuEntries[last];
	String target = menuEntry.getTarget();
	String option = menuEntry.getOption();
	int type = menuEntry.getType();

	if (type == MenuAction.RUNELITE_OVERLAY.getId() || type == MenuAction.CC_OP_LOW_PRIORITY.getId())
	{
		// These are always right click only
		return null;
	}

	if (Strings.isNullOrEmpty(option))
	{
		return null;
	}

	// Trivial options that don't need to be highlighted, add more as they appear.
	switch (option)
	{
		case "Walk here":
		case "Cancel":
		case "Continue":
			return null;
		case "Move":
			// Hide overlay on sliding puzzle boxes
			if (target.contains("Sliding piece"))
			{
				return null;
			}
	}

	final int widgetId = menuEntry.getParam1();
	final int groupId = WidgetInfo.TO_GROUP(widgetId);
	final int childId = WidgetInfo.TO_CHILD(widgetId);
	final Widget widget = client.getWidget(groupId, childId);

	if (!config.uiTooltip() && widget != null)
	{
		return null;
	}

	if (!config.chatboxTooltip() && groupId == WidgetInfo.CHATBOX.getGroupId())
	{
		return null;
	}

	if (config.disableSpellbooktooltip() && groupId == WidgetID.SPELLBOOK_GROUP_ID)
	{
		return null;
	}

	if (widget != null)
	{
		// If this varc is set, some CS is showing tooltip
		int tooltipTimeout = client.getVar(VarClientInt.TOOLTIP_TIMEOUT);
		if (tooltipTimeout > client.getGameCycle())
		{
			return null;
		}
	}

	// If this varc is set, a tooltip is already being displayed
	int tooltipDisplayed = client.getVar(VarClientInt.TOOLTIP_VISIBLE);
	if (tooltipDisplayed == 1)
	{
		return null;
	}

	tooltipManager.addFront(new Tooltip(option + (Strings.isNullOrEmpty(target) ? "" : " " + target)));
	return null;
}
 
Example #17
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 #18
Source File: BankTagsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onMenuOptionClicked(MenuOptionClicked event)
{
	if (event.getWidgetId() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
		&& event.getMenuAction() == MenuAction.RUNELITE
		&& event.getMenuOption().startsWith(EDIT_TAGS_MENU_OPTION))
	{
		event.consume();
		int inventoryIndex = event.getActionParam();
		ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
		if (bankContainer == null)
		{
			return;
		}
		Item[] items = bankContainer.getItems();
		if (inventoryIndex < 0 || inventoryIndex >= items.length)
		{
			return;
		}
		Item item = bankContainer.getItems()[inventoryIndex];
		if (item == null)
		{
			return;
		}

		int itemId = item.getId();
		ItemComposition itemComposition = itemManager.getItemComposition(itemId);
		String name = itemComposition.getName();

		// Get both tags and vartags and append * to end of vartags name
		Collection<String> tags = tagManager.getTags(itemId, false);
		tagManager.getTags(itemId, true).stream()
			.map(i -> i + "*")
			.forEach(tags::add);

		boolean isSearchOpen = client.getVar(VarClientInt.INPUT_TYPE) == InputType.SEARCH.getType();
		String searchText = client.getVar(VarClientStr.INPUT_TEXT);
		String initialValue = Text.toCSV(tags);

		chatboxPanelManager.openTextInput(name + " tags:<br>(append " + VAR_TAG_SUFFIX + " for variation tag)")
			.addCharValidator(FILTERED_CHARS)
			.value(initialValue)
			.onDone((Consumer<String>) (newValue) ->
				clientThread.invoke(() ->
				{
					// Split inputted tags to vartags (ending with *) and regular tags
					final Collection<String> newTags = new ArrayList<>(Text.fromCSV(newValue.toLowerCase()));
					final Collection<String> newVarTags = new ArrayList<>(newTags).stream().filter(s -> s.endsWith(VAR_TAG_SUFFIX)).map(s ->
					{
						newTags.remove(s);
						return s.substring(0, s.length() - VAR_TAG_SUFFIX.length());
					}).collect(Collectors.toList());

					// And save them
					tagManager.setTagString(itemId, Text.toCSV(newTags), false);
					tagManager.setTagString(itemId, Text.toCSV(newVarTags), true);

					// Check both previous and current tags in case the tag got removed in new tags or in case
					// the tag got added in new tags
					tabInterface.updateTabIfActive(Text.fromCSV(initialValue.toLowerCase().replaceAll(Pattern.quote(VAR_TAG_SUFFIX), "")));
					tabInterface.updateTabIfActive(Text.fromCSV(newValue.toLowerCase().replaceAll(Pattern.quote(VAR_TAG_SUFFIX), "")));
				}))
			.build();

		if (isSearchOpen)
		{
			bankSearch.reset(false);
			bankSearch.search(InputType.SEARCH, searchText, false);
		}
	}
	else
	{
		tabInterface.handleClick(event);
	}
}
 
Example #19
Source File: TabInterface.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void handleClick(MenuOptionClicked event)
{
	if (isHidden())
	{
		return;
	}

	if (chatboxPanelManager.getCurrentInput() != null
		&& event.getMenuAction() != MenuAction.CANCEL
		&& !event.getMenuOption().equals(SCROLL_UP)
		&& !event.getMenuOption().equals(SCROLL_DOWN))
	{
		chatboxPanelManager.close();
	}

	if ((event.getWidgetId() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
			|| event.getWidgetId() == WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER.getId())
		&& event.getMenuAction() == MenuAction.CC_OP_LOW_PRIORITY
		&& (event.getMenuOption().equalsIgnoreCase("withdraw-x")
			|| event.getMenuOption().equalsIgnoreCase("deposit-x")))
	{
		waitSearchTick = true;
		rememberedSearch = client.getVar(VarClientStr.INPUT_TEXT);
		bankSearch.search(InputType.NONE, rememberedSearch, true);
	}

	if (activeTab != null
		&& event.getMenuOption().equals("Search")
		&& client.getWidget(WidgetInfo.BANK_SEARCH_BUTTON_BACKGROUND).getSpriteId() != SpriteID.EQUIPMENT_SLOT_SELECTED)
	{
		activateTab(null);
		// This ensures that when clicking Search when tab is selected, the search input is opened rather
		// than client trying to close it first
		client.setVar(VarClientStr.INPUT_TEXT, "");
		client.setVar(VarClientInt.INPUT_TYPE, 0);
	}
	else if (activeTab != null
		&& event.getMenuOption().startsWith("View tab"))
	{
		activateTab(null);
	}
	else if (activeTab != null
		&& event.getWidgetId() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
		&& event.getMenuAction() == MenuAction.RUNELITE
		&& event.getMenuOption().startsWith(REMOVE_TAG))
	{
		// Add "remove" menu entry to all items in bank while tab is selected
		event.consume();
		final ItemComposition item = getItem(event.getActionParam());
		final int itemId = item.getId();
		tagManager.removeTag(itemId, activeTab.getTag());
		bankSearch.search(InputType.SEARCH, TAG_SEARCH + activeTab.getTag(), true);
	}
	else if (event.getMenuAction() == MenuAction.RUNELITE
		&& ((event.getWidgetId() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId() && event.getMenuOption().equals(TAG_INVENTORY))
		|| (event.getWidgetId() == WidgetInfo.BANK_DEPOSIT_EQUIPMENT.getId() && event.getMenuOption().equals(TAG_GEAR))))
	{
		handleDeposit(event, event.getWidgetId() == WidgetInfo.BANK_DEPOSIT_INVENTORY.getId());
	}
	else if (activeTab != null && ((event.getWidgetId() == WidgetInfo.BANK_EQUIPMENT_BUTTON.getId() && event.getMenuOption().equals(SHOW_WORN))
		|| (event.getWidgetId() == WidgetInfo.BANK_SETTINGS_BUTTON.getId() && event.getMenuOption().equals(SHOW_SETTINGS))
		|| (event.getWidgetId() == WidgetInfo.BANK_TUTORIAL_BUTTON.getId() && event.getMenuOption().equals(SHOW_TUTORIAL))))
	{
		saveTab();
		rememberedSearch = TAG_SEARCH + activeTab.getTag();
	}
	else if (!Strings.isNullOrEmpty(rememberedSearch) && ((event.getWidgetId() == WidgetInfo.BANK_EQUIPMENT_BUTTON.getId() && event.getMenuOption().equals(HIDE_WORN))
			|| (event.getWidgetId() == WidgetInfo.BANK_SETTINGS_BUTTON.getId() && event.getMenuOption().equals(HIDE_SETTINGS))))
	{
		bankSearch.reset(true);
		bankSearch.search(InputType.NONE, rememberedSearch, true);
		rememberedSearch = "";
	}
}
 
Example #20
Source File: TabInterface.java    From runelite with BSD 2-Clause "Simplified" License 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 #21
Source File: MouseHighlightOverlay.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	if (client.isMenuOpen())
	{
		return null;
	}

	MenuEntry[] menuEntries = client.getMenuEntries();
	int last = menuEntries.length - 1;

	if (last < 0)
	{
		return null;
	}

	MenuEntry menuEntry = menuEntries[last];
	String target = menuEntry.getTarget();
	String option = menuEntry.getOption();
	int type = menuEntry.getOpcode();

	if (shouldNotRenderMenuAction(type))
	{
		return null;
	}

	if (Strings.isNullOrEmpty(option))
	{
		return null;
	}

	// Trivial options that don't need to be highlighted, add more as they appear.
	switch (option)
	{
		case "Walk here":
		case "Cancel":
		case "Continue":
			return null;
		case "Move":
			// Hide overlay on sliding puzzle boxes
			if (target.contains("Sliding piece"))
			{
				return null;
			}
	}

	final int widgetId = menuEntry.getParam1();
	final int groupId = WidgetInfo.TO_GROUP(widgetId);
	final int childId = WidgetInfo.TO_CHILD(widgetId);
	final Widget widget = client.getWidget(groupId, childId);

	if (!config.uiTooltip() && widget != null)
	{
		return null;
	}

	if (!config.chatboxTooltip() && groupId == WidgetInfo.CHATBOX.getGroupId())
	{
		return null;
	}

	if (widget != null)
	{
		// If this varc is set, some CS is showing tooltip
		int tooltipTimeout = client.getVar(VarClientInt.TOOLTIP_TIMEOUT);
		if (tooltipTimeout > client.getGameCycle())
		{
			return null;
		}
	}

	if (widget == null && !config.mainTooltip())
	{
		return null;
	}

	// If this varc is set, a tooltip is already being displayed
	int tooltipDisplayed = client.getVar(VarClientInt.TOOLTIP_VISIBLE);
	if (tooltipDisplayed == 1)
	{
		return null;
	}

	tooltipManager.addFront(new Tooltip(option + (Strings.isNullOrEmpty(target) ? "" : " " + target)));
	return null;
}
 
Example #22
Source File: BankTagsPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private boolean isSearching()
{
	return client.getVar(VarClientInt.INPUT_TYPE) == InputType.SEARCH.getType()
		|| (client.getVar(VarClientInt.INPUT_TYPE) <= 0
		&& client.getVar(VarClientStr.INPUT_TEXT) != null && client.getVar(VarClientStr.INPUT_TEXT).length() > 0);
}
 
Example #23
Source File: BankTagsPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onMenuOptionClicked(MenuOptionClicked event)
{
	if (event.getParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
		&& event.getMenuOpcode() == MenuOpcode.RUNELITE
		&& event.getOption().startsWith(EDIT_TAGS_MENU_OPTION))
	{
		event.consume();
		int inventoryIndex = event.getParam0();
		ItemContainer bankContainer = client.getItemContainer(InventoryID.BANK);
		if (bankContainer == null)
		{
			return;
		}
		Item[] items = bankContainer.getItems();
		if (inventoryIndex < 0 || inventoryIndex >= items.length)
		{
			return;
		}
		Item item = bankContainer.getItems()[inventoryIndex];
		if (item == null)
		{
			return;
		}

		int itemId = item.getId();
		ItemDefinition itemDefinition = itemManager.getItemDefinition(itemId);
		String name = itemDefinition.getName();

		// Get both tags and vartags and append * to end of vartags name
		Collection<String> tags = tagManager.getTags(itemId, false);
		tagManager.getTags(itemId, true).stream()
			.map(i -> i + "*")
			.forEach(tags::add);

		boolean isSearchOpen = client.getVar(VarClientInt.INPUT_TYPE) == InputType.SEARCH.getType();
		String searchText = client.getVar(VarClientStr.INPUT_TEXT);
		String initialValue = Text.toCSV(tags);

		chatboxPanelManager.openTextInput(name + " tags:<br>(append " + VAR_TAG_SUFFIX + " for variation tag)")
			.addCharValidator(FILTERED_CHARS)
			.value(initialValue)
			.onDone((Consumer<String>) (newValue) ->
				clientThread.invoke(() ->
				{
					// Split inputted tags to vartags (ending with *) and regular tags
					final Collection<String> newTags = new ArrayList<>(Text.fromCSV(newValue.toLowerCase()));
					final Collection<String> newVarTags = new ArrayList<>(newTags).stream().filter(s -> s.endsWith(VAR_TAG_SUFFIX)).map(s ->
					{
						newTags.remove(s);
						return s.substring(0, s.length() - VAR_TAG_SUFFIX.length());
					}).collect(Collectors.toList());

					// And save them
					tagManager.setTagString(itemId, Text.toCSV(newTags), false);
					tagManager.setTagString(itemId, Text.toCSV(newVarTags), true);

					// Check both previous and current tags in case the tag got removed in new tags or in case
					// the tag got added in new tags
					tabInterface.updateTabIfActive(Text.fromCSV(initialValue.toLowerCase().replaceAll(Pattern.quote(VAR_TAG_SUFFIX), "")));
					tabInterface.updateTabIfActive(Text.fromCSV(newValue.toLowerCase().replaceAll(Pattern.quote(VAR_TAG_SUFFIX), "")));
				}))
			.build();

		if (isSearchOpen)
		{
			bankSearch.reset(false);
			bankSearch.search(InputType.SEARCH, searchText, false);
		}
	}
	else
	{
		tabInterface.handleClick(event);
	}
}
 
Example #24
Source File: MusicPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private boolean isOnMusicTab()
{
	return client.getVar(VarClientInt.INVENTORY_TAB) == 13;
}
 
Example #25
Source File: CustomSwapper.java    From ExternalPlugins with GNU General Public License v3.0 4 votes vote down vote up
private void executePair(Pair<Tab, Rectangle> pair)
{
	switch (pair.getLeft())
	{
		case COMBAT:
			if (client.getVar(VarClientInt.INTERFACE_TAB) != InterfaceTab.COMBAT.getId())
			{
				robot.delay((int) getMillis());
				robot.keyPress(utils.getTabHotkey(pair.getLeft()));
				robot.delay((int) getMillis());
			}
			utils.click(pair.getRight());
			break;
		case EQUIPMENT:
			if (client.getVar(VarClientInt.INTERFACE_TAB) != InterfaceTab.EQUIPMENT.getId())
			{
				robot.delay((int) getMillis());
				robot.keyPress(utils.getTabHotkey(pair.getLeft()));
				robot.delay((int) getMillis());
			}
			utils.click(pair.getRight());
			break;
		case INVENTORY:
			if (client.getVar(VarClientInt.INTERFACE_TAB) != InterfaceTab.INVENTORY.getId())
			{
				robot.delay((int) getMillis());
				robot.keyPress(utils.getTabHotkey(pair.getLeft()));
				robot.delay((int) getMillis());
			}
			utils.click(pair.getRight());
			break;
		case PRAYER:
			if (client.getVar(VarClientInt.INTERFACE_TAB) != InterfaceTab.PRAYER.getId())
			{
				robot.delay((int) getMillis());
				robot.keyPress(utils.getTabHotkey(pair.getLeft()));
				robot.delay((int) getMillis());
			}
			utils.click(pair.getRight());
			break;
		case SPELLBOOK:
			if (client.getVar(VarClientInt.INTERFACE_TAB) != InterfaceTab.SPELLBOOK.getId())
			{
				robot.delay((int) getMillis());
				robot.keyPress(utils.getTabHotkey(pair.getLeft()));
				robot.delay((int) getMillis());
			}
			utils.click(pair.getRight());
			break;
	}
}
 
Example #26
Source File: XpDropPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void calculateDamageDealt(int diff)
{
	double damageDealt = diff / HITPOINT_RATIO;

	// DeadMan mode Tournament has an XP modifier of 10x in safezone, 15x outside.
	if (client.getWorldType().contains(WorldType.DEADMAN_TOURNAMENT))
	{
		if (client.getVar(VarClientInt.DMM_SAFEZONE) == 0)
		{
			DMM_MULTIPLIER_RATIO = 15;
		}
		if (client.getVar(VarClientInt.DMM_SAFEZONE) == 1)
		{
			DMM_MULTIPLIER_RATIO = 10;
		}
		damageDealt = damageDealt / DMM_MULTIPLIER_RATIO;
	}
	// DeadMan mode W45 has an XP modifier of 10x
	else if (!client.getWorldType().contains(WorldType.DEADMAN_TOURNAMENT)
		&& client.getWorldType().contains(WorldType.DEADMAN))
	{
		DMM_MULTIPLIER_RATIO = 10;
		damageDealt = damageDealt / DMM_MULTIPLIER_RATIO;
	}

	// Some NPCs have an XP modifier, account for it here.
	Actor a = client.getLocalPlayer().getInteracting();
	if (!(a instanceof NPC) && !(a instanceof Player))
	{
		// If we are interacting with nothing we may have clicked away at the perfect time fall back
		// to last tick
		if (!(lastOpponent instanceof NPC) && !(lastOpponent instanceof Player))
		{
			damage = (int) Math.rint(damageDealt);
			tickShow = 3;
			return;
		}

		a = lastOpponent;
	}

	if (a instanceof Player)
	{
		damage = (int) Math.rint(damageDealt);
		tickShow = 3;
		return;
	}

	NPC target = (NPC) a;
	damage = (int) Math.rint(damageDealt / npcManager.getXpModifier(target.getId()));
	tickShow = 3;
}
 
Example #27
Source File: QuestListPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private boolean isNotOnQuestTab()
{
	return client.getVar(Varbits.QUEST_TAB) != 0 || client.getVar(VarClientInt.INTERFACE_TAB) != InterfaceTab.QUEST.getId();
}