runelite-client: add instance world map plugin
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.api;
|
||||
|
||||
public interface SceneTilePaint
|
||||
{
|
||||
int getRBG();
|
||||
}
|
||||
@@ -40,4 +40,6 @@ public interface Tile
|
||||
GroundObject getGroundObject();
|
||||
|
||||
WallObject getWallObject();
|
||||
|
||||
SceneTilePaint getSceneTilePaint();
|
||||
}
|
||||
|
||||
@@ -47,6 +47,12 @@ class WidgetID
|
||||
static final int SLAYER_REWARDS_GROUP_ID = 426;
|
||||
static final int PRIVATE_CHAT = 163;
|
||||
static final int CHATBOX_GROUP_ID = 162;
|
||||
static final int WORLD_MAP_MENU_GROUP_ID = 160;
|
||||
|
||||
static class WorldMap
|
||||
{
|
||||
static final int OPTION = 29;
|
||||
}
|
||||
|
||||
static class SlayerRewards
|
||||
{
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.instancemap;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup(
|
||||
keyName = "instancemap",
|
||||
name = "Instance Map",
|
||||
description = "Displays a map of the current instance"
|
||||
)
|
||||
public interface InstanceMapConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
keyName = "enabled",
|
||||
name = "Enabled",
|
||||
description = "Enables or disables the overlay"
|
||||
)
|
||||
default boolean enabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.instancemap;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
|
||||
class InstanceMapOverlay extends Overlay
|
||||
{
|
||||
/**
|
||||
* Size of the drawn tile in the instance map.
|
||||
*/
|
||||
private static final int tileSize = 3;
|
||||
|
||||
private final Client client;
|
||||
private final InstanceMapConfig config;
|
||||
|
||||
private boolean showMap = false;
|
||||
|
||||
@Inject
|
||||
InstanceMapOverlay(@Nullable Client client,
|
||||
InstanceMapConfig config)
|
||||
{
|
||||
super(OverlayPosition.DYNAMIC);
|
||||
this.client = client;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public boolean isMapShown()
|
||||
{
|
||||
return showMap;
|
||||
}
|
||||
|
||||
public void setShowMap(boolean show)
|
||||
{
|
||||
showMap = show;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (client.getGameState() != GameState.LOGGED_IN || !config.enabled() || !showMap)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return drawInstanceMap(graphics);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws all the tiles on the current plane of client.reigion to the
|
||||
* screen. This will show instances unlike the world map.
|
||||
*
|
||||
* @param graphics graphics to draw to
|
||||
* @return The dimensions of the map
|
||||
*/
|
||||
private Dimension drawInstanceMap(Graphics2D graphics)
|
||||
{
|
||||
Tile[][][] regionTiles = client.getRegion().getTiles();
|
||||
|
||||
int plane = client.getPlane();
|
||||
Tile[][] tiles = regionTiles[plane];
|
||||
|
||||
Dimension mapOverlaySize = new Dimension(tiles.length * tileSize, tiles[0].length * tileSize);
|
||||
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.fillRect(0, 0, mapOverlaySize.width, mapOverlaySize.height);
|
||||
|
||||
for (int x = 0; x < tiles.length; x++)
|
||||
{
|
||||
for (int y = 0; y < tiles[x].length; y++)
|
||||
{
|
||||
Tile curTile = tiles[x][(tiles[x].length - 1) - y]; // flip the y value
|
||||
if (curTile != null && curTile.getSceneTilePaint() != null)
|
||||
{
|
||||
graphics.setColor(new Color(curTile.getSceneTilePaint().getRBG()));
|
||||
graphics.fillRect(x * tileSize, y * tileSize, tileSize, tileSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mapOverlaySize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.instancemap;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.events.WidgetMenuOptionClicked;
|
||||
import net.runelite.client.menus.WidgetMenuOption;
|
||||
import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Instance Map"
|
||||
)
|
||||
public class IntanceMapPlugin extends Plugin
|
||||
{
|
||||
private final WidgetMenuOption openMapOption = new WidgetMenuOption("Show", "Instance Map", WidgetInfo.WORLD_MAP);
|
||||
|
||||
@Inject
|
||||
InstanceMapConfig config;
|
||||
|
||||
@Inject
|
||||
InstanceMapOverlay overlay;
|
||||
|
||||
@Inject
|
||||
MenuManager menuManager;
|
||||
|
||||
@Override
|
||||
public void configure(Binder binder)
|
||||
{
|
||||
binder.bind(InstanceMapOverlay.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
InstanceMapConfig getConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(InstanceMapConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
if (config.enabled())
|
||||
{
|
||||
menuManager.addManagedCustomMenu(openMapOption);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
if (config.enabled())
|
||||
{
|
||||
menuManager.addManagedCustomMenu(openMapOption);
|
||||
}
|
||||
else
|
||||
{
|
||||
menuManager.removeManagedCustomMenu(openMapOption);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onWidgetMenuOptionClicked(WidgetMenuOptionClicked event)
|
||||
{
|
||||
if (!config.enabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getMenuOption().equals(openMapOption.getMenuOption())
|
||||
&& event.getMenuTarget().equals(openMapOption.getMenuTarget())
|
||||
&& event.getWidget() == WidgetInfo.WORLD_MAP)
|
||||
{
|
||||
overlay.setShowMap(!overlay.isMapShown());
|
||||
if (overlay.isMapShown())
|
||||
{
|
||||
openMapOption.setMenuOption("Hide");
|
||||
}
|
||||
else
|
||||
{
|
||||
openMapOption.setMenuOption("Show");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Overlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.rs.api;
|
||||
|
||||
import net.runelite.api.SceneTilePaint;
|
||||
import net.runelite.mapping.Import;
|
||||
|
||||
public interface RSSceneTilePaint extends SceneTilePaint
|
||||
{
|
||||
@Import("rgb")
|
||||
@Override
|
||||
int getRBG();
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import net.runelite.api.DecorativeObject;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.GroundObject;
|
||||
import net.runelite.api.ItemLayer;
|
||||
import net.runelite.api.SceneTilePaint;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.api.WallObject;
|
||||
import net.runelite.mapping.Import;
|
||||
@@ -54,6 +55,10 @@ public interface RSTile extends Tile
|
||||
@Override
|
||||
WallObject getWallObject();
|
||||
|
||||
@Import("paint")
|
||||
@Override
|
||||
SceneTilePaint getSceneTilePaint();
|
||||
|
||||
@Import("x")
|
||||
int getX();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user