use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class CombatLevelPlugin method updateCombatLevel.
@Subscribe
public void updateCombatLevel(GameTick event) {
if (client.getGameState() != GameState.LOGGED_IN) {
return;
}
Widget combatLevelWidget = client.getWidget(WidgetInfo.COMBAT_LEVEL);
if (combatLevelWidget == null) {
return;
}
double combatLevelPrecise = Experience.getCombatLevelPrecise(client.getRealSkillLevel(Skill.ATTACK), client.getRealSkillLevel(Skill.STRENGTH), client.getRealSkillLevel(Skill.DEFENCE), client.getRealSkillLevel(Skill.HITPOINTS), client.getRealSkillLevel(Skill.MAGIC), client.getRealSkillLevel(Skill.RANGED), client.getRealSkillLevel(Skill.PRAYER));
combatLevelWidget.setText("Combat Lvl: " + decimalFormat.format(combatLevelPrecise));
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class WidgetInspector method addWidget.
private DefaultMutableTreeNode addWidget(String type, Widget widget) {
if (widget == null || widget.isHidden()) {
return null;
}
DefaultMutableTreeNode node = new WidgetTreeNode(type, widget);
Widget[] childComponents = widget.getDynamicChildren();
if (childComponents != null) {
for (Widget component : childComponents) {
DefaultMutableTreeNode childNode = addWidget("D", component);
if (childNode != null) {
node.add(childNode);
}
}
}
childComponents = widget.getStaticChildren();
if (childComponents != null) {
for (Widget component : childComponents) {
DefaultMutableTreeNode childNode = addWidget("S", component);
if (childNode != null) {
node.add(childNode);
}
}
}
childComponents = widget.getNestedChildren();
if (childComponents != null) {
for (Widget component : childComponents) {
DefaultMutableTreeNode childNode = addWidget("N", component);
if (childNode != null) {
node.add(childNode);
}
}
}
Collection<WidgetItem> items = widget.getWidgetItems();
if (items != null) {
for (WidgetItem item : items) {
if (item == null) {
continue;
}
node.add(new WidgetItemNode(item));
}
}
return node;
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class ScreenshotPlugin method parseLevelUpWidget.
public String parseLevelUpWidget(WidgetInfo levelUpSkill, WidgetInfo levelUpLevel) {
Widget skillChild = client.getWidget(levelUpSkill);
Widget levelChild = client.getWidget(levelUpLevel);
if (skillChild == null || levelChild == null) {
return null;
}
// "Congratulations, you just advanced a Firemaking level."
String skillText = skillChild.getText();
// "Your Firemaking level is now 9."
String levelText = levelChild.getText();
String[] splitSkillName = skillText.split(" ");
String skillName = splitSkillName[splitSkillName.length - 2];
String skillLevel = levelText.substring(levelText.lastIndexOf(" ") + 1, levelText.length() - 1);
return skillName + "(" + skillLevel + ")";
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class ScreenshotPlugin method hideWidgets.
@Subscribe
public void hideWidgets(WidgetHiddenChanged event) {
Widget widget = event.getWidget();
if (widget.isHidden()) {
return;
}
switch(TO_GROUP(widget.getId())) {
case LEVEL_UP_GROUP_ID:
if (!config.screenshotLevels()) {
return;
}
break;
case QUEST_COMPLETED_GROUP_ID:
case CLUE_SCROLL_REWARD_GROUP_ID:
case BARROWS_REWARD_GROUP_ID:
case RAIDS_REWARD_GROUP_ID:
if (!config.screenshotRewards()) {
return;
}
break;
}
String fileName;
switch(TO_GROUP(widget.getId())) {
case LEVEL_UP_GROUP_ID:
{
fileName = parseLevelUpWidget(WidgetInfo.LEVEL_UP_SKILL, WidgetInfo.LEVEL_UP_LEVEL);
break;
}
case DIALOG_SPRITE_GROUP_ID:
{
fileName = parseLevelUpWidget(WidgetInfo.DIALOG_SPRITE_SPRITE, WidgetInfo.DIALOG_SPRITE_TEXT);
break;
}
case QUEST_COMPLETED_GROUP_ID:
{
Widget textChild = client.getWidget(WidgetInfo.QUEST_COMPLETED_NAME_TEXT);
if (textChild == null) {
return;
}
// "You have completed The Corsair Curse!"
String text = textChild.getText();
fileName = text.substring(19, text.length() - 1);
break;
}
case CLUE_SCROLL_REWARD_GROUP_ID:
{
if (clueType == null || clueNumber == null) {
return;
}
fileName = Character.toUpperCase(clueType.charAt(0)) + clueType.substring(1) + "(" + clueNumber + ")";
clueType = null;
clueNumber = null;
break;
}
case BARROWS_REWARD_GROUP_ID:
{
if (barrowsNumber == null) {
return;
}
fileName = "Barrows(" + barrowsNumber + ")";
barrowsNumber = null;
break;
}
case RAIDS_REWARD_GROUP_ID:
{
if (raidsNumber == null) {
return;
}
fileName = "Raids(" + raidsNumber + ")";
raidsNumber = null;
break;
}
default:
return;
}
if (fileName == null) {
return;
}
takeScreenshot(fileName, config.displayDate());
}
use of net.runelite.api.widgets.Widget in project runelite by runelite.
the class SlayerPlugin method scheduledChecks.
@Schedule(period = 600, unit = ChronoUnit.MILLIS)
public void scheduledChecks() {
Widget NPCDialog = client.getWidget(WidgetInfo.DIALOG_NPC_TEXT);
if (NPCDialog != null) {
// remove color and linebreaks
String NPCText = Text.removeTags(NPCDialog.getText());
// number, name
Matcher mAssign = NPC_ASSIGN_MESSAGE.matcher(NPCText);
// name, number
Matcher mCurrent = NPC_CURRENT_MESSAGE.matcher(NPCText);
boolean found1 = mAssign.find();
boolean found2 = mCurrent.find();
if (!found1 && !found2) {
return;
}
String taskName = found1 ? mAssign.group(2) : mCurrent.group(1);
int amount = Integer.parseInt(found1 ? mAssign.group(1) : mCurrent.group(2));
setTask(taskName, amount);
}
Widget rewardsBarWidget = client.getWidget(WidgetInfo.SLAYER_REWARDS_TOPBAR);
if (rewardsBarWidget != null) {
for (Widget w : rewardsBarWidget.getDynamicChildren()) {
Matcher mPoints = REWARD_POINTS.matcher(w.getText());
if (mPoints.find()) {
points = Integer.parseInt(mPoints.group(1));
break;
}
}
}
if (infoTimer != null) {
Duration timeSinceInfobox = Duration.between(infoTimer, Instant.now());
Duration statTimeout = Duration.ofMinutes(config.statTimeout());
if (timeSinceInfobox.compareTo(statTimeout) >= 0) {
removeCounter();
}
}
}
Aggregations