interface styles: update HD Health bar to work with new sprites
@@ -1564,6 +1564,25 @@ public final class SpriteID
|
||||
public static final int MOBILE_FUNCTION_MODE_DISABLED = 1624;
|
||||
public static final int MOBILE_YELLOW_TOUCH_ANIMATION_1 = 1625;
|
||||
public static final int MOBILE_YELLOW_TOUCH_ANIMATION_2 = 1626;
|
||||
/* Unmapped: 1627~1707 */
|
||||
public static final int TAB_MAGIC_SPELLBOOK_ARCEUUS_UNUSED = 1708;
|
||||
/* Unmapped: 1709, 1710 */
|
||||
public static final int TAB_MAGIC_SPELLBOOK_ARCEUUS = 1711;
|
||||
/* Unmapped: 1712~2175 */
|
||||
public static final int HEALTHBAR_DEFAULT_FRONT_30PX = 2176;
|
||||
public static final int HEALTHBAR_DEFAULT_BACK_30PX = 2177;
|
||||
public static final int HEALTHBAR_DEFAULT_FRONT_50PX = 2178;
|
||||
public static final int HEALTHBAR_DEFAULT_BACK_50PX = 2179;
|
||||
public static final int HEALTHBAR_DEFAULT_FRONT_60PX = 2180;
|
||||
public static final int HEALTHBAR_DEFAULT_BACK_60PX = 2181;
|
||||
public static final int HEALTHBAR_DEFAULT_FRONT_80PX = 2182;
|
||||
public static final int HEALTHBAR_DEFAULT_BACK_80PX = 2183;
|
||||
public static final int HEALTHBAR_DEFAULT_FRONT_100PX = 2184;
|
||||
public static final int HEALTHBAR_DEFAULT_BACK_100PX = 2185;
|
||||
public static final int HEALTHBAR_DEFAULT_FRONT_120PX = 2186;
|
||||
public static final int HEALTHBAR_DEFAULT_BACK_120PX = 2187;
|
||||
public static final int HEALTHBAR_DEFAULT_FRONT_140PX = 2188;
|
||||
public static final int HEALTHBAR_DEFAULT_BACK_140PX = 2189;
|
||||
public static final int HEALTHBAR_DEFAULT_FRONT_160PX = 2190;
|
||||
public static final int HEALTHBAR_DEFAULT_BACK_160PX = 2191;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Hydrox6 <ikada@protonmail.ch>
|
||||
* 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.interfacestyles;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import static net.runelite.api.SpriteID.*;
|
||||
import net.runelite.client.game.SpriteOverride;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
enum HealthbarOverride implements SpriteOverride
|
||||
{
|
||||
BACK_30PX(HEALTHBAR_DEFAULT_BACK_30PX, "back_30px.png"),
|
||||
BACK_50PX(HEALTHBAR_DEFAULT_BACK_50PX, "back_30px.png"),
|
||||
BACK_60PX(HEALTHBAR_DEFAULT_BACK_60PX, "back_30px.png"),
|
||||
BACK_80PX(HEALTHBAR_DEFAULT_BACK_80PX, "back_90px.png"),
|
||||
BACK_100PX(HEALTHBAR_DEFAULT_BACK_100PX, "back_90px.png"),
|
||||
BACK_120PX(HEALTHBAR_DEFAULT_BACK_120PX, "back_90px.png"),
|
||||
BACK_140PX(HEALTHBAR_DEFAULT_BACK_140PX, "back_90px.png"),
|
||||
BACK_160PX(HEALTHBAR_DEFAULT_BACK_160PX, "back_90px.png"),
|
||||
|
||||
FRONT_30PX(HEALTHBAR_DEFAULT_FRONT_30PX, "front_30px.png"),
|
||||
FRONT_50PX(HEALTHBAR_DEFAULT_FRONT_50PX, "front_30px.png"),
|
||||
FRONT_60PX(HEALTHBAR_DEFAULT_FRONT_60PX, "front_30px.png"),
|
||||
FRONT_80PX(HEALTHBAR_DEFAULT_FRONT_80PX, "front_90px.png"),
|
||||
FRONT_100PX(HEALTHBAR_DEFAULT_FRONT_100PX, "front_90px.png"),
|
||||
FRONT_120PX(HEALTHBAR_DEFAULT_FRONT_120PX, "front_90px.png"),
|
||||
FRONT_140PX(HEALTHBAR_DEFAULT_FRONT_140PX, "front_90px.png"),
|
||||
FRONT_160PX(HEALTHBAR_DEFAULT_FRONT_160PX, "front_90px.png");
|
||||
|
||||
@Getter
|
||||
private final int spriteId;
|
||||
|
||||
private final String fileName;
|
||||
|
||||
@Getter
|
||||
private int padding = 1;
|
||||
|
||||
private static final Map<Integer, HealthbarOverride> MAP;
|
||||
|
||||
static
|
||||
{
|
||||
ImmutableMap.Builder<Integer, HealthbarOverride> builder = new ImmutableMap.Builder<>();
|
||||
|
||||
for (HealthbarOverride override : values())
|
||||
{
|
||||
builder.put(override.spriteId, override);
|
||||
}
|
||||
|
||||
MAP = builder.build();
|
||||
}
|
||||
|
||||
static HealthbarOverride get(int spriteID)
|
||||
{
|
||||
return MAP.get(spriteID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileName()
|
||||
{
|
||||
return Skin.AROUND_2010.toString() + "/healthbar/" + this.fileName;
|
||||
}
|
||||
}
|
||||
@@ -69,8 +69,6 @@ public class InterfaceStylesPlugin extends Plugin
|
||||
@Inject
|
||||
private SpriteManager spriteManager;
|
||||
|
||||
private HealthBarOverride healthBarOverride;
|
||||
|
||||
@Provides
|
||||
InterfaceStylesConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
@@ -90,9 +88,7 @@ public class InterfaceStylesPlugin extends Plugin
|
||||
{
|
||||
restoreWidgetDimensions();
|
||||
removeGameframe();
|
||||
healthBarOverride = null;
|
||||
client.setHealthBarOverride(null);
|
||||
client.resetHealthBarCaches(); // invalidate healthbar cache so padding resets
|
||||
restoreHealthBars();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -114,19 +110,19 @@ public class InterfaceStylesPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onPostHealthBar(PostHealthBar postHealthBar)
|
||||
{
|
||||
if (healthBarOverride == null || !config.hdHealthBars())
|
||||
if (!config.hdHealthBars())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HealthBar healthBar = postHealthBar.getHealthBar();
|
||||
SpritePixels frontSprite = healthBar.getHealthBarFrontSprite();
|
||||
HealthbarOverride override = HealthbarOverride.get(healthBar.getHealthBarFrontSpriteId());
|
||||
|
||||
// Check if this is the health bar we are replacing
|
||||
if (frontSprite == healthBarOverride.getFrontSprite() || frontSprite == healthBarOverride.getFrontSpriteLarge())
|
||||
if (override != null)
|
||||
{
|
||||
// Increase padding to show some more green at very low hp percentages
|
||||
healthBar.setPadding(1);
|
||||
healthBar.setPadding(override.getPadding());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,30 +265,24 @@ public class InterfaceStylesPlugin extends Plugin
|
||||
|
||||
private void overrideHealthBars()
|
||||
{
|
||||
// Reset health bar cache to reset applied padding
|
||||
client.resetHealthBarCaches();
|
||||
|
||||
if (config.hdHealthBars())
|
||||
{
|
||||
String fileBase = Skin.AROUND_2010.toString() + "/healthbar/";
|
||||
|
||||
SpritePixels frontSprite = getFileSpritePixels(fileBase + "front.png");
|
||||
SpritePixels backSprite = getFileSpritePixels(fileBase + "back.png");
|
||||
|
||||
SpritePixels frontSpriteLarge = getFileSpritePixels(fileBase + "front_large.png");
|
||||
SpritePixels backSpriteLarge = getFileSpritePixels(fileBase + "back_large.png");
|
||||
|
||||
HealthBarOverride override = new HealthBarOverride(frontSprite, backSprite, frontSpriteLarge, backSpriteLarge);
|
||||
healthBarOverride = override;
|
||||
client.setHealthBarOverride(override);
|
||||
spriteManager.addSpriteOverrides(HealthbarOverride.values());
|
||||
// Reset health bar caches to apply the override
|
||||
clientThread.invokeLater(client::resetHealthBarCaches);
|
||||
}
|
||||
else
|
||||
{
|
||||
healthBarOverride = null;
|
||||
client.setHealthBarOverride(null);
|
||||
restoreHealthBars();
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreHealthBars()
|
||||
{
|
||||
spriteManager.removeSpriteOverrides(HealthbarOverride.values());
|
||||
clientThread.invokeLater(client::resetHealthBarCaches);
|
||||
}
|
||||
|
||||
private void restoreWidgetDimensions()
|
||||
{
|
||||
for (WidgetOffset widgetOffset : WidgetOffset.values())
|
||||
|
||||
|
Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 280 B |
|
Before Width: | Height: | Size: 305 B After Width: | Height: | Size: 305 B |
|
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
|
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 444 B |