runelite-client: add minimap dot plugin
This commit is contained in:
@@ -155,6 +155,8 @@ public interface Client extends GameEngine
|
||||
Area[] getMapAreas();
|
||||
|
||||
IndexedSprite[] getMapScene();
|
||||
|
||||
SpritePixels[] getMapDots();
|
||||
|
||||
int getGameCycle();
|
||||
|
||||
@@ -166,6 +168,8 @@ public interface Client extends GameEngine
|
||||
|
||||
IndexedSprite createIndexedSprite();
|
||||
|
||||
SpritePixels createSpritePixels(int[] pixels, int width, int height);
|
||||
|
||||
Point getSceneDestinationLocation();
|
||||
|
||||
List<Projectile> getProjectiles();
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Dreyri <https://github.com/Dreyri>
|
||||
* 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.minimap;
|
||||
|
||||
import java.awt.Color;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup(
|
||||
keyName = "minimap",
|
||||
name = "Minimap",
|
||||
description = "Configuration for the minimap")
|
||||
public interface MinimapConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
keyName = "item",
|
||||
name = "Item color",
|
||||
description = "Set the minimap color items are drawn in"
|
||||
)
|
||||
default Color itemColor() //mapdot 0
|
||||
{
|
||||
return new Color(255, 0, 0);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "npc",
|
||||
name = "NPC color",
|
||||
description = "Set the minimap color NPCs are drawn in"
|
||||
)
|
||||
default Color npcColor() //mapdot 1
|
||||
{
|
||||
return new Color(255, 255, 0);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "player",
|
||||
name = "Player color",
|
||||
description = "Set the minimap Color players are drawn in"
|
||||
)
|
||||
default Color playerColor() //mapdot 2
|
||||
{
|
||||
return new Color(255, 255, 255);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "friend",
|
||||
name = "Friends color",
|
||||
description = "Set the minimap color your friends are drawn in"
|
||||
)
|
||||
default Color friendColor() //mapdot 3
|
||||
{
|
||||
return new Color(0, 255, 0);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "team",
|
||||
name = "Team color",
|
||||
description = "Set the minimap color your team is drawn in"
|
||||
)
|
||||
default Color teamColor() //mapdot 4
|
||||
{
|
||||
return new Color(19, 110, 247);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "clan",
|
||||
name = "Clan color",
|
||||
description = "Set the minimap color your clan is drawn in"
|
||||
)
|
||||
default Color clanColor() //mapdot 5
|
||||
{
|
||||
return new Color(170, 0, 190);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Dreyri <https://github.com/Dreyri>
|
||||
* 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.minimap;
|
||||
|
||||
import java.awt.Color;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.SpritePixels;
|
||||
|
||||
public class MinimapDot
|
||||
{
|
||||
private static final int MAP_DOT_WIDTH = 4;
|
||||
private static final int MAP_DOT_HEIGHT = 5;
|
||||
|
||||
private static int[] createPixels(Color color)
|
||||
{
|
||||
int rgb = color.getRGB();
|
||||
|
||||
int[] pixels = new int[MAP_DOT_HEIGHT * MAP_DOT_WIDTH];
|
||||
|
||||
pixels[0] = 0;
|
||||
pixels[1] = rgb;
|
||||
pixels[2] = rgb;
|
||||
pixels[3] = 0;
|
||||
|
||||
pixels[4] = rgb;
|
||||
pixels[5] = rgb;
|
||||
pixels[6] = rgb;
|
||||
pixels[7] = rgb;
|
||||
|
||||
pixels[8] = rgb;
|
||||
pixels[9] = rgb;
|
||||
pixels[10] = rgb;
|
||||
pixels[11] = rgb;
|
||||
|
||||
pixels[12] = 1;
|
||||
pixels[13] = rgb;
|
||||
pixels[14] = rgb;
|
||||
pixels[15] = 1;
|
||||
|
||||
pixels[16] = 0;
|
||||
pixels[17] = 1;
|
||||
pixels[18] = 1;
|
||||
pixels[19] = 0;
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
public static SpritePixels create(Client client, Color color)
|
||||
{
|
||||
int[] pixels = createPixels(color);
|
||||
|
||||
SpritePixels dotSprite = client.createSpritePixels(pixels, MAP_DOT_WIDTH, MAP_DOT_HEIGHT);
|
||||
|
||||
return dotSprite;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Dreyri <https://github.com/Dreyri>
|
||||
* 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.minimap;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.SpritePixels;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Minimap"
|
||||
)
|
||||
public class MinimapPlugin extends Plugin
|
||||
{
|
||||
private static final int NUM_MAPDOTS = 6;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private MinimapConfig config;
|
||||
|
||||
private SpritePixels[] originalDotSprites;
|
||||
|
||||
@Provides
|
||||
private MinimapConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(MinimapConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
storeOriginalDots();
|
||||
replaceMapDots();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
restoreOriginalDots();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameStateChange(GameStateChanged event)
|
||||
{
|
||||
if (event.getGameState() == GameState.LOGIN_SCREEN && originalDotSprites == null)
|
||||
{
|
||||
storeOriginalDots();
|
||||
replaceMapDots();
|
||||
}
|
||||
}
|
||||
|
||||
private Color[] getColors()
|
||||
{
|
||||
Color[] colors = new Color[NUM_MAPDOTS];
|
||||
colors[0] = config.itemColor();
|
||||
colors[1] = config.npcColor();
|
||||
colors[2] = config.playerColor();
|
||||
colors[3] = config.friendColor();
|
||||
colors[4] = config.teamColor();
|
||||
colors[5] = config.clanColor();
|
||||
return colors;
|
||||
}
|
||||
|
||||
private void storeOriginalDots()
|
||||
{
|
||||
SpritePixels[] originalDots = client.getMapDots();
|
||||
|
||||
if (originalDots == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
originalDotSprites = Arrays.copyOf(originalDots, originalDots.length);
|
||||
}
|
||||
|
||||
public void restoreOriginalDots()
|
||||
{
|
||||
SpritePixels[] mapDots = client.getMapDots();
|
||||
System.arraycopy(originalDotSprites, 0, mapDots, 0, mapDots.length);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void configChanged(ConfigChanged event)
|
||||
{
|
||||
if (!event.getGroup().equals("minimap"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
replaceMapDots();
|
||||
}
|
||||
|
||||
private void replaceMapDots()
|
||||
{
|
||||
SpritePixels[] mapDots = client.getMapDots();
|
||||
|
||||
if (mapDots == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Color[] minimapDotColors = getColors();
|
||||
for (int i = 0; i < mapDots.length && i < minimapDotColors.length; ++i)
|
||||
{
|
||||
mapDots[i] = MinimapDot.create(this.client, minimapDotColors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -315,6 +315,9 @@ public interface RSClient extends RSGameEngine, Client
|
||||
@Override
|
||||
RSSpritePixels[] getMapIcons();
|
||||
|
||||
@Import("mapDots")
|
||||
RSSpritePixels[] getMapDots();
|
||||
|
||||
@Import("modIcons")
|
||||
@Override
|
||||
RSIndexedSprite[] getModIcons();
|
||||
@@ -326,6 +329,10 @@ public interface RSClient extends RSGameEngine, Client
|
||||
@Override
|
||||
RSIndexedSprite createIndexedSprite();
|
||||
|
||||
@Construct
|
||||
@Override
|
||||
RSSpritePixels createSpritePixels(int[] pixels, int width, int height);
|
||||
|
||||
@Import("destinationX")
|
||||
int getDestinationX();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user