Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2060 from Lucwousin/hd-minimaps
Browse files Browse the repository at this point in the history
Client: add hd minimaps
  • Loading branch information
Lucwousin authored Jan 2, 2020
2 parents f93ed47 + 318e365 commit d1b4e2e
Show file tree
Hide file tree
Showing 10 changed files with 629 additions and 75 deletions.
4 changes: 4 additions & 0 deletions runelite-api/src/main/java/net/runelite/api/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,10 @@ public interface Client extends GameShell
*/
void setInventoryDragDelay(int delay);

boolean isHdMinimapEnabled();

void setHdMinimapEnabled(boolean enabled);

/**
* Gets a set of current world types that apply to the logged in world.
*
Expand Down
32 changes: 32 additions & 0 deletions runelite-api/src/main/java/net/runelite/api/TileModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,36 @@ public interface TileModel

int getBufferLen();
void setBufferLen(int bufferLen);

int getUnderlaySwColor();

void setUnderlaySwColor(int color);

int getUnderlaySeColor();

void setUnderlaySeColor(int color);

int getUnderlayNeColor();

void setUnderlayNeColor(int color);

int getUnderlayNwColor();

void setUnderlayNwColor(int color);

int getOverlaySwColor();

void setOverlaySwColor(int color);

int getOverlaySeColor();

void setOverlaySeColor(int color);

int getOverlayNeColor();

void setOverlayNeColor(int color);

int getOverlayNwColor();

void setOverlayNwColor(int color);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@
@ConfigGroup("minimap")
public interface MinimapConfig extends Config
{
@ConfigItem(
keyName = "hdMinimapEnabled",
name = "HD minimap",
description = "Configures whether to show the minimap in higher detail (relog to see changes)",
position = 1
)
default boolean hdMinimapEnabled()
{
return false;
}

@ConfigItem(
keyName = "item",
name = "Item color",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.awt.Color;
import java.util.Arrays;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Sprite;
Expand All @@ -45,28 +44,18 @@
@PluginDescriptor(
name = "Minimap",
description = "Customize the color of minimap dots",
tags = {"items", "npcs", "players"}
tags = {"items", "npcs", "players", "hd"}
)
@Singleton
public class MinimapPlugin extends Plugin
{
private static final int NUM_MAPDOTS = 6;

@Inject
private Client client;

@Inject
private MinimapConfig config;

private Sprite[] originalDotSprites;

private Color itemColor;
private Color npcColor;
private Color playerColor;
private Color friendColor;
private Color teamColor;
private Color clanColor;
private boolean hideMinimap;
private Color[] colors;

@Provides
private MinimapConfig provideConfig(ConfigManager configManager)
Expand All @@ -77,18 +66,20 @@ private MinimapConfig provideConfig(ConfigManager configManager)
@Override
protected void startUp()
{
updateConfig();

updateMinimapWidgetVisibility(this.hideMinimap);
updateMinimapWidgetVisibility(config.hideMinimap());
storeOriginalDots();
replaceMapDots();

client.setHdMinimapEnabled(config.hdMinimapEnabled());
}

@Override
protected void shutDown()
{
updateMinimapWidgetVisibility(false);
restoreOriginalDots();

client.setHdMinimapEnabled(false);
}

@Subscribe
Expand All @@ -109,21 +100,30 @@ private void onConfigChanged(ConfigChanged event)
return;
}

updateConfig();
if (event.getKey().equals("hdMinimapEnabled"))
{
client.setHdMinimapEnabled(config.hdMinimapEnabled());
return;
}

if (event.getKey().equals("hideMinimap"))
{
updateMinimapWidgetVisibility(this.hideMinimap);
updateMinimapWidgetVisibility(config.hideMinimap());
return;
}

if (event.getKey().endsWith("Color"))
{
colors = null;
}

replaceMapDots();
}

@Subscribe
private void onWidgetHiddenChanged(WidgetHiddenChanged event)
{
updateMinimapWidgetVisibility(this.hideMinimap);
updateMinimapWidgetVisibility(config.hideMinimap());
}

private void updateMinimapWidgetVisibility(boolean enable)
Expand Down Expand Up @@ -168,14 +168,18 @@ private void replaceMapDots()

private Color[] getColors()
{
Color[] colors = new Color[NUM_MAPDOTS];
colors[0] = this.itemColor;
colors[1] = this.npcColor;
colors[2] = this.playerColor;
colors[3] = this.friendColor;
colors[4] = this.teamColor;
colors[5] = this.clanColor;

if (colors == null)
{
colors = new Color[]
{
config.itemColor(),
config.npcColor(),
config.playerColor(),
config.friendColor(),
config.teamColor(),
config.clanColor()
};
}
return colors;
}

Expand All @@ -202,15 +206,4 @@ private void restoreOriginalDots()

System.arraycopy(originalDotSprites, 0, mapDots, 0, mapDots.length);
}

private void updateConfig()
{
this.itemColor = config.itemColor();
this.npcColor = config.npcColor();
this.playerColor = config.playerColor();
this.friendColor = config.friendColor();
this.teamColor = config.teamColor();
this.clanColor = config.clanColor();
this.hideMinimap = config.hideMinimap();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,9 @@
import net.runelite.api.InventoryID;
import net.runelite.api.MenuEntry;
import net.runelite.api.MenuOpcode;
import static net.runelite.api.MenuOpcode.PLAYER_EIGTH_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_FIFTH_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_FIRST_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_FOURTH_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_SECOND_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_SEVENTH_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_SIXTH_OPTION;
import static net.runelite.api.MenuOpcode.PLAYER_THIRD_OPTION;
import net.runelite.api.MessageNode;
import net.runelite.api.NPC;
import net.runelite.api.Node;
import static net.runelite.api.Perspective.LOCAL_TILE_SIZE;
import net.runelite.api.Player;
import net.runelite.api.Point;
import net.runelite.api.Prayer;
Expand Down Expand Up @@ -135,6 +126,8 @@
import net.runelite.rs.api.RSUsername;
import net.runelite.rs.api.RSWidget;
import org.slf4j.Logger;
import static net.runelite.api.MenuOpcode.*;
import static net.runelite.api.Perspective.LOCAL_TILE_SIZE;

@Mixin(RSClient.class)
public abstract class RSClientMixin implements RSClient
Expand Down Expand Up @@ -283,6 +276,9 @@ public RSClientMixin()
{
}

@Inject
private static boolean hdMinimapEnabled;

@Inject
@Override
public Callbacks getCallbacks()
Expand Down Expand Up @@ -374,6 +370,20 @@ public void setInventoryDragDelay(int delay)
inventoryDragDelay = delay;
}

@Inject
@Override
public boolean isHdMinimapEnabled()
{
return hdMinimapEnabled;
}

@Inject
@Override
public void setHdMinimapEnabled(boolean enabled)
{
hdMinimapEnabled = enabled;
}

@Inject
@Override
public AccountType getAccountType()
Expand Down
Loading

0 comments on commit d1b4e2e

Please sign in to comment.