minimap: add clan chat dot color configuration

This commit is contained in:
Adam
2021-05-19 22:49:24 -04:00
parent 4efd609e40
commit 94ad05fa0f
3 changed files with 90 additions and 83 deletions

View File

@@ -28,69 +28,19 @@ import java.awt.Color;
import net.runelite.client.config.Config; import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem; import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.ConfigSection;
@ConfigGroup("minimap") @ConfigGroup(MinimapConfig.GROUP)
public interface MinimapConfig extends Config public interface MinimapConfig extends Config
{ {
@ConfigItem( String GROUP = "minimap";
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( @ConfigSection(
keyName = "npc", name = "Minimap dot colors",
name = "NPC color", description = "The colors of dots on the minimap.",
description = "Set the minimap color NPCs are drawn in" position = 0
) )
default Color npcColor() //mapdot 1 String minimapDotSection = "minimapDotSection";
{
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 = "Friends Chat color",
description = "Set the minimap color your friends chat members are drawn in"
)
default Color friendsChatColor() //mapdot 5
{
return new Color(170, 0, 190);
}
@ConfigItem( @ConfigItem(
keyName = "hideMinimap", keyName = "hideMinimap",
@@ -101,4 +51,60 @@ public interface MinimapConfig extends Config
{ {
return false; return false;
} }
@ConfigItem(
keyName = "item",
name = "Item color",
description = "Set the minimap color items are drawn in",
section = minimapDotSection
)
Color itemColor();
@ConfigItem(
keyName = "npc",
name = "NPC color",
description = "Set the minimap color NPCs are drawn in",
section = minimapDotSection
)
Color npcColor();
@ConfigItem(
keyName = "player",
name = "Player color",
description = "Set the minimap Color players are drawn in",
section = minimapDotSection
)
Color playerColor();
@ConfigItem(
keyName = "friend",
name = "Friends color",
description = "Set the minimap color your friends are drawn in",
section = minimapDotSection
)
Color friendColor();
@ConfigItem(
keyName = "team",
name = "Team color",
description = "Set the minimap color your team is drawn in",
section = minimapDotSection
)
Color teamColor();
@ConfigItem(
keyName = "clan", // old name from prior to clans
name = "Friends Chat color",
description = "Set the minimap color your friends chat members are drawn in",
section = minimapDotSection
)
Color friendsChatColor();
@ConfigItem(
keyName = "clanchat",
name = "Clan Chat color",
description = "Set the minimap color your clan chat members are drawn in",
section = minimapDotSection
)
Color clanChatColor();
} }

View File

@@ -28,7 +28,7 @@ import java.awt.Color;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.SpritePixels; import net.runelite.api.SpritePixels;
public class MinimapDot class MinimapDot
{ {
private static final int MAP_DOT_WIDTH = 4; private static final int MAP_DOT_WIDTH = 4;
private static final int MAP_DOT_HEIGHT = 5; private static final int MAP_DOT_HEIGHT = 5;
@@ -67,12 +67,9 @@ public class MinimapDot
return pixels; return pixels;
} }
public static SpritePixels create(Client client, Color color) static SpritePixels create(Client client, Color color)
{ {
int[] pixels = createPixels(color); int[] pixels = createPixels(color);
return client.createSpritePixels(pixels, MAP_DOT_WIDTH, MAP_DOT_HEIGHT);
SpritePixels dotSprite = client.createSpritePixels(pixels, MAP_DOT_WIDTH, MAP_DOT_HEIGHT);
return dotSprite;
} }
} }

View File

@@ -44,12 +44,18 @@ import net.runelite.client.plugins.PluginDescriptor;
@PluginDescriptor( @PluginDescriptor(
name = "Minimap", name = "Minimap",
description = "Customize the color of minimap dots", description = "Customize the color of minimap dots, and hide the minimap",
tags = {"items", "npcs", "players"} tags = {"items", "npcs", "players"}
) )
public class MinimapPlugin extends Plugin public class MinimapPlugin extends Plugin
{ {
private static final int NUM_MAPDOTS = 6; private static final int DOT_ITEM = 0;
private static final int DOT_NPC = 1;
private static final int DOT_PLAYER = 2;
private static final int DOT_FRIEND = 3;
private static final int DOT_TEAM = 4;
private static final int DOT_FRIENDSCHAT = 5;
private static final int DOT_CLAN = 6;
@Inject @Inject
private Client client; private Client client;
@@ -66,7 +72,7 @@ public class MinimapPlugin extends Plugin
} }
@Override @Override
protected void startUp() throws Exception protected void startUp()
{ {
updateMinimapWidgetVisibility(config.hideMinimap()); updateMinimapWidgetVisibility(config.hideMinimap());
storeOriginalDots(); storeOriginalDots();
@@ -74,7 +80,7 @@ public class MinimapPlugin extends Plugin
} }
@Override @Override
protected void shutDown() throws Exception protected void shutDown()
{ {
updateMinimapWidgetVisibility(false); updateMinimapWidgetVisibility(false);
restoreOriginalDots(); restoreOriginalDots();
@@ -93,7 +99,7 @@ public class MinimapPlugin extends Plugin
@Subscribe @Subscribe
public void onConfigChanged(ConfigChanged event) public void onConfigChanged(ConfigChanged event)
{ {
if (!event.getGroup().equals("minimap")) if (!event.getGroup().equals(MinimapConfig.GROUP))
{ {
return; return;
} }
@@ -149,23 +155,21 @@ public class MinimapPlugin extends Plugin
return; return;
} }
Color[] minimapDotColors = getColors(); applyDot(mapDots, DOT_ITEM, config.itemColor());
for (int i = 0; i < mapDots.length && i < minimapDotColors.length; ++i) applyDot(mapDots, DOT_NPC, config.npcColor());
{ applyDot(mapDots, DOT_PLAYER, config.playerColor());
mapDots[i] = MinimapDot.create(this.client, minimapDotColors[i]); applyDot(mapDots, DOT_FRIEND, config.friendColor());
} applyDot(mapDots, DOT_TEAM, config.teamColor());
applyDot(mapDots, DOT_FRIENDSCHAT, config.friendsChatColor());
applyDot(mapDots, DOT_CLAN, config.clanChatColor());
} }
private Color[] getColors() private void applyDot(SpritePixels[] mapDots, int id, Color color)
{ {
Color[] colors = new Color[NUM_MAPDOTS]; if (id < mapDots.length && color != null)
colors[0] = config.itemColor(); {
colors[1] = config.npcColor(); mapDots[id] = MinimapDot.create(client, color);
colors[2] = config.playerColor(); }
colors[3] = config.friendColor();
colors[4] = config.teamColor();
colors[5] = config.friendsChatColor();
return colors;
} }
private void storeOriginalDots() private void storeOriginalDots()