api: remove getViewportWidget()

The returned widget isn't actually the viewport widget, but is a layer within the viewport, and only needs to be used within the overlay renderer to position the snapcorners
This commit is contained in:
Adam
2020-12-14 20:42:32 -05:00
parent 78e0cf5392
commit 38b3d3a904
5 changed files with 23 additions and 22 deletions

View File

@@ -879,16 +879,6 @@ public interface Client extends GameEngine
*/
IterableHashTable<MessageNode> getMessages();
/**
* Gets the viewport widget.
* <p>
* The viewport is the area of the game above the chatbox
* and to the left of the mini-map.
*
* @return the viewport widget
*/
Widget getViewportWidget();
/**
* Gets the object composition corresponding to an objects ID.
*

View File

@@ -42,7 +42,6 @@ import net.runelite.api.Point;
import net.runelite.api.Tile;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.widgets.Widget;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
@@ -91,12 +90,10 @@ public class BlastMineRockOverlay extends Overlay
}
final Tile[][][] tiles = client.getScene().getTiles();
final Widget viewport = client.getViewportWidget();
for (final BlastMineRock rock : rocks.values())
{
if (viewport == null ||
rock.getGameObject().getCanvasLocation() == null ||
if (rock.getGameObject().getCanvasLocation() == null ||
rock.getGameObject().getWorldLocation().distanceTo(client.getLocalPlayer().getWorldLocation()) > MAX_DISTANCE)
{
continue;

View File

@@ -111,7 +111,7 @@ public class GroundItemsOverlay extends Overlay
final FontMetrics fm = graphics.getFontMetrics();
final Player player = client.getLocalPlayer();
if (player == null || client.getViewportWidget() == null)
if (player == null)
{
return null;
}

View File

@@ -34,7 +34,6 @@ import net.runelite.api.Client;
import net.runelite.api.Perspective;
import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.widgets.Widget;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
@@ -85,8 +84,6 @@ public class TitheFarmPlantOverlay extends Overlay
@Override
public Dimension render(Graphics2D graphics)
{
final Widget viewport = client.getViewportWidget();
for (TitheFarmPlant plant : plugin.getPlants())
{
if (plant.getState() == TitheFarmPlantState.DEAD)
@@ -103,7 +100,7 @@ public class TitheFarmPlantOverlay extends Overlay
final Point canvasLocation = Perspective.localToCanvas(client, localLocation, client.getPlane());
if (viewport != null && canvasLocation != null)
if (canvasLocation != null)
{
final ProgressPieComponent progressPieComponent = new ProgressPieComponent();
progressPieComponent.setPosition(canvasLocation);

View File

@@ -48,6 +48,7 @@ import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.KeyCode;
import net.runelite.api.MenuEntry;
import net.runelite.api.Varbits;
import net.runelite.api.events.BeforeRender;
import net.runelite.api.events.ClientTick;
import net.runelite.api.events.FocusChanged;
@@ -184,7 +185,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
|| overlays.isEmpty()
|| client.getGameState() != GameState.LOGGED_IN
|| client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null
|| client.getViewportWidget() == null)
|| getViewportLayer() == null)
{
return;
}
@@ -795,11 +796,11 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
changed = true;
}
final boolean viewportChanged = !client.getViewportWidget().getBounds().equals(viewportBounds);
final boolean viewportChanged = !getViewportLayer().getBounds().equals(viewportBounds);
if (viewportChanged)
{
viewportBounds = client.getViewportWidget().getBounds();
viewportBounds = getViewportLayer().getBounds();
changed = true;
}
@@ -814,6 +815,22 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
return changed;
}
private Widget getViewportLayer()
{
if (client.isResized())
{
if (client.getVar(Varbits.SIDE_PANELS) == 1)
{
return client.getWidget(WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE);
}
else
{
return client.getWidget(WidgetInfo.RESIZABLE_VIEWPORT_OLD_SCHOOL_BOX);
}
}
return client.getWidget(WidgetInfo.FIXED_VIEWPORT);
}
private OverlayBounds buildSnapCorners()
{
final Point topLeftPoint = new Point(