Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player outline prayers #71

Open
wants to merge 2 commits into
base: player-outline
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'java'
id 'checkstyle'
}

repositories {
Expand All @@ -11,7 +10,7 @@ repositories {
mavenCentral()
}

def runeLiteVersion = '1.7.25'
def runeLiteVersion = 'latest.release'

dependencies {
compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion
Expand All @@ -24,10 +23,10 @@ dependencies {
testImplementation group: 'net.runelite', name:'jshell', version: runeLiteVersion
}

group = 'com.playeroutline'
version = '1.0'
sourceCompatibility = '1.8'
group = 'com.example'
version = '1.0-SNAPSHOT'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
options.release.set(11)
}
101 changes: 96 additions & 5 deletions src/main/java/com/playeroutline/PlayerOutlineConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@
package com.playeroutline;

import java.awt.Color;
import net.runelite.client.config.Alpha;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range;

import net.runelite.client.config.*;

@ConfigGroup("playeroutline")
public interface PlayerOutlineConfig extends Config
{

@ConfigSection(
name = "Prayer Color Highlight",
description = "Changes color of your highlight based on overhead prayer.",
position = 3,
closedByDefault = true
)
String colorHighlightSection = "colorHighlight";
@Alpha
@ConfigItem(
keyName = "playerOutlineColor",
Expand Down Expand Up @@ -70,4 +75,90 @@ default int outlineFeather()
{
return 4;
}

@ConfigItem(
name = "Enable Overhead Changing",
description = "Changes color based on the overhead being prayed",
position = 0,
keyName = "prayerChanging",
section = colorHighlightSection
)
default boolean prayerChanging()
{
return false;
}
@Alpha
@ConfigItem(
keyName = "playerOutlineColorMage",
name = "Mage Protection Color",
description = "The color for the players outline when praying mage protection",
position = 1,
section = colorHighlightSection
)
default Color playerOutlineColorMage()
{
return new Color(0,0,255,90);
}
@Alpha
@ConfigItem(
keyName = "playerOutlineColorRange",
name = "Range Protection Color",
description = "The color for the players outline when praying range protection",
position = 2,
section = colorHighlightSection
)
default Color playerOutlineColorRange()
{
return new Color(0,255,0,90);
}
@Alpha
@ConfigItem(
keyName = "playerOutlineColorMelee",
name = "Melee Protection Color",
description = "The color for the players outline when praying melee protection",
position = 3,
section = colorHighlightSection
)
default Color playerOutlineMelee()
{
return new Color(255,0,0,90);
}
@Alpha
@ConfigItem(
keyName = "playerOutlineColorRedemption",
name = "Redemption Color",
description = "The color for the players outline when praying redemption",
position = 4,
section = colorHighlightSection
)
default Color playerOutlineColorRedemption()
{
return new Color(0x3D000000, true);
}

@Alpha
@ConfigItem(
keyName = "playerOutlineColorSmite",
name = "Smite Color",
description = "The color for the players outline when praying smite",
position = 5,
section = colorHighlightSection
)
default Color playerOutlineColorSmite()
{
return new Color(0x3D000000, true);
}
@Alpha
@ConfigItem(
keyName = "playerOutlineColorRet",
name = "Retribution Color",
description = "The color for the players outline when praying retribution",
position = 6,
section = colorHighlightSection
)
default Color playerOutlineColorRet()
{
return new Color(0x3D000000, true);
}

}
6 changes: 4 additions & 2 deletions src/main/java/com/playeroutline/PlayerOutlineOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ public class PlayerOutlineOverlay extends Overlay

private final Client client;
private final PlayerOutlineConfig config;
private final PlayerOutlinePlugin plugin;
private final ModelOutlineRenderer modelOutlineRenderer;

@Inject
public PlayerOutlineOverlay(Client client, PlayerOutlineConfig config, ModelOutlineRenderer modelOutlineRenderer)
public PlayerOutlineOverlay(Client client, PlayerOutlineConfig config, ModelOutlineRenderer modelOutlineRenderer, PlayerOutlinePlugin plugin)
{
this.client = client;
this.config = config;
this.plugin = plugin;
this.modelOutlineRenderer = modelOutlineRenderer;
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_SCENE);
Expand All @@ -55,7 +57,7 @@ public PlayerOutlineOverlay(Client client, PlayerOutlineConfig config, ModelOutl
@Override
public Dimension render(Graphics2D graphics)
{
modelOutlineRenderer.drawOutline(client.getLocalPlayer(), config.borderWidth(), config.playerOutlineColor(), config.outlineFeather());
modelOutlineRenderer.drawOutline(client.getLocalPlayer(), config.borderWidth(), plugin.getActiveColor(), config.outlineFeather());
return null;
}

Expand Down
68 changes: 62 additions & 6 deletions src/main/java/com/playeroutline/PlayerOutlinePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,95 @@
import com.google.inject.Provides;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.HeadIcon;
import net.runelite.api.Player;
import net.runelite.api.events.GameTick;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager;

import java.awt.*;

@Slf4j
@PluginDescriptor(
name = "Player Outline",
description = "A simple plugin that outlines the player allowing you to see the player behind objects.",
tags = "highlight, player, outline, color"
)
public class PlayerOutlinePlugin extends Plugin
{
public class PlayerOutlinePlugin extends Plugin {
@Inject
PlayerOutlineOverlay playerOutlineOverlay;
@Inject
private OverlayManager overlayManager;
@Inject
PlayerOutlineConfig config;
@Inject
Client client;
private Color activeColor;

@Override
protected void startUp()
{
protected void startUp() {
activeColor = config.playerOutlineColor();
overlayManager.add(playerOutlineOverlay);
}

@Override
protected void shutDown()
{
protected void shutDown() {
overlayManager.remove(playerOutlineOverlay);
}

@Subscribe
protected void onGameTick(GameTick tick)
{
if(config.prayerChanging())
updateColor();
}

public Color getActiveColor()
{
return activeColor;
}

@Provides
PlayerOutlineConfig provideConfig(ConfigManager configManager)
{
return configManager.getConfig(PlayerOutlineConfig.class);
}

void updateColor()
{
Player p = client.getLocalPlayer();
if(p==null)
return;
HeadIcon currentOverhead = p.getOverheadIcon();
if(currentOverhead == null)
{
activeColor = config.playerOutlineColor();
return;
}
switch(currentOverhead)
{
case MAGIC:
activeColor = config.playerOutlineColorMage();
break;
case MELEE:
activeColor = config.playerOutlineMelee();
break;
case RANGED:
activeColor = config.playerOutlineColorRange();
break;
case SMITE:
activeColor = config.playerOutlineColorSmite();
break;
case REDEMPTION:
activeColor = config.playerOutlineColorRedemption();
break;
case RETRIBUTION:
activeColor = config.playerOutlineColorRet();
break;
}
}
}