runelite-client: some work on widget overlays
can't figure out how to only render whats on screen and some positions are off, when others aren't
This commit is contained in:
@@ -176,6 +176,15 @@ public class Client
|
||||
return client.getBaseY();
|
||||
}
|
||||
|
||||
public Widget[][] getWidgets()
|
||||
{
|
||||
return Arrays.stream(client.getWidgets())
|
||||
.map(parent -> parent != null ? Arrays.stream(parent)
|
||||
.map(child -> child != null ? new Widget(this, child) : null)
|
||||
.toArray(Widget[]::new) : null
|
||||
).toArray(Widget[][]::new);
|
||||
}
|
||||
|
||||
public Widget getWidget(int groupId, int childId)
|
||||
{
|
||||
net.runelite.rs.api.Widget[][] widgets = client.getWidgets();
|
||||
@@ -204,6 +213,11 @@ public class Client
|
||||
return client.getWidgetPositionsY();
|
||||
}
|
||||
|
||||
public boolean[] getValidInterfaces()
|
||||
{
|
||||
return client.getValidInterfaces();
|
||||
}
|
||||
|
||||
public String[] getPlayerOptions()
|
||||
{
|
||||
return client.getPlayerOptions();
|
||||
|
||||
@@ -43,9 +43,8 @@ public class Region
|
||||
.map(tile1 -> Arrays.stream(tile1)
|
||||
.map(tile2 -> Arrays.stream(tile2)
|
||||
.map(tile3 -> new Tile(client, tile3))
|
||||
.toArray(i -> new Tile[i])
|
||||
)
|
||||
.toArray(i -> new Tile[i][])
|
||||
).toArray(i -> new Tile[i][][]);
|
||||
.toArray(Tile[]::new)
|
||||
).toArray(Tile[][]::new)
|
||||
).toArray(Tile[][][]::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,16 @@ public class Widget
|
||||
this.widget = widget;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return widget.getId();
|
||||
}
|
||||
|
||||
public int getType()
|
||||
{
|
||||
return widget.getType();
|
||||
}
|
||||
|
||||
public Widget getParent()
|
||||
{
|
||||
net.runelite.rs.api.Widget parent = widget.getParent();
|
||||
@@ -67,22 +77,45 @@ public class Widget
|
||||
return widget.getRelativeY();
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return widget.getText();
|
||||
}
|
||||
|
||||
public boolean isHidden()
|
||||
{
|
||||
return widget.isHidden();
|
||||
}
|
||||
|
||||
public Point getCanvasLocation()
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
Widget cur;
|
||||
|
||||
int boundsIndex = widget.getBoundsIndex();
|
||||
if (boundsIndex != -1)
|
||||
for (cur = this; cur.getParent() != null; cur = cur.getParent())
|
||||
{
|
||||
int[] widgetBoundsWidth = client.getWidgetPositionsX();
|
||||
int[] widgetBoundsHeight = client.getWidgetPositionsY();
|
||||
|
||||
x += widgetBoundsWidth[boundsIndex];
|
||||
y += widgetBoundsHeight[boundsIndex];
|
||||
x += cur.getRelativeX();
|
||||
y += cur.getRelativeY();
|
||||
}
|
||||
|
||||
for (Widget cur = this; cur != null; cur = cur.getParent())
|
||||
// cur is now the root
|
||||
int[] widgetBoundsWidth = client.getWidgetPositionsX();
|
||||
int[] widgetBoundsHeight = client.getWidgetPositionsY();
|
||||
|
||||
int boundsIndex = cur.widget.getBoundsIndex();
|
||||
if (boundsIndex != -1)
|
||||
{
|
||||
x += widgetBoundsWidth[boundsIndex];
|
||||
y += widgetBoundsHeight[boundsIndex];
|
||||
|
||||
if (cur.getType() > 0)
|
||||
{
|
||||
x += cur.getRelativeX();
|
||||
y += cur.getRelativeY();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x += cur.getRelativeX();
|
||||
y += cur.getRelativeY();
|
||||
@@ -101,6 +134,12 @@ public class Widget
|
||||
return widget.getHeight();
|
||||
}
|
||||
|
||||
public Rectangle getBounds()
|
||||
{
|
||||
Point canvasLocation = getCanvasLocation();
|
||||
return new Rectangle(canvasLocation.getX(), canvasLocation.getY(), getWidth(), getHeight());
|
||||
}
|
||||
|
||||
public Collection<WidgetItem> getWidgetItems()
|
||||
{
|
||||
int[] itemIds = widget.getItemIds();
|
||||
|
||||
Reference in New Issue
Block a user