mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-10 10:20:44 -07:00
Manually adjust globe skill sprite positioning
This commit is contained in:
parent
d730ff65c4
commit
e8bed52163
3 changed files with 50 additions and 7 deletions
|
|
@ -2,6 +2,7 @@ package XPGlobesPlugin
|
|||
|
||||
import java.awt.Color
|
||||
|
||||
|
||||
object Constants {
|
||||
const val SKILL_COUNT = 24
|
||||
const val MAX_LEVEL = 99
|
||||
|
|
|
|||
|
|
@ -3,11 +3,51 @@ package XPGlobesPlugin
|
|||
import plugin.api.API
|
||||
import rt4.Sprite
|
||||
|
||||
|
||||
object XPSprites {
|
||||
|
||||
private val spriteOffsets: Array<Pair<Int, Int>> = arrayOf(
|
||||
Pair(1,-1), // attack
|
||||
Pair(0,0), // defense
|
||||
Pair(0,0), // strength
|
||||
Pair(0,1), // health
|
||||
Pair(0,0), // ranged
|
||||
Pair(0,0), // prayer
|
||||
Pair(0,-1), // magic
|
||||
Pair(0,-1), // cooking
|
||||
Pair(0,0), // woodcutting
|
||||
Pair(1,0), // fletching
|
||||
Pair(3,0), // fishing
|
||||
Pair(0,-1), // fire-making
|
||||
Pair(1,0), // crafting
|
||||
Pair(1,0), // smithing
|
||||
Pair(2,-1), // mining
|
||||
Pair(0,1), // herblore
|
||||
Pair(2,0), // agility
|
||||
Pair(0,0), // thieving
|
||||
Pair(-1,0), // slayer
|
||||
Pair(0,0), // farming
|
||||
Pair(0,0), // runecrafting
|
||||
Pair(0,0), // hunter
|
||||
Pair(1,-1), // construction
|
||||
Pair(2,-1), // summoning
|
||||
)
|
||||
|
||||
|
||||
fun getSpriteForSkill(skillId: Int) : Sprite? {
|
||||
return API.GetSprite(getSpriteId(skillId))
|
||||
}
|
||||
|
||||
|
||||
fun getSpriteOffsetForSkill(skillId: Int) : Pair<Int, Int> {
|
||||
if (skillId < 0 || skillId >= Constants.SKILL_COUNT) {
|
||||
return Pair(0,0)
|
||||
}
|
||||
|
||||
return spriteOffsets[skillId];
|
||||
}
|
||||
|
||||
|
||||
private fun getSpriteId(skillId: Int) : Int {
|
||||
return when (skillId) {
|
||||
0 -> 197
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import java.awt.image.BufferedImage
|
|||
|
||||
|
||||
class plugin : Plugin() {
|
||||
private var xpGlobes = Array(Constants.SKILL_COUNT) { skillId -> XPGlobe(skillId, Constants.INVALID_XP, Constants.INVALID_XP, 0L, null) }
|
||||
private var xpGlobes = Array(Constants.SKILL_COUNT) { skillId -> XPGlobe(skillId, Constants.INVALID_XP, 0L, null) }
|
||||
private var lastGain = 0L
|
||||
private var backgroundSprite: Sprite? = null
|
||||
private var borderSprite: Sprite? = null
|
||||
|
|
@ -49,6 +49,7 @@ class plugin : Plugin() {
|
|||
activeGlobes.add(xpGlobe) // alive
|
||||
}
|
||||
}
|
||||
|
||||
val maxGlobes = if (API.GetWindowMode() == WindowMode.FIXED) Constants.MAX_GLOBES_SD else Constants.MAX_GLOBES
|
||||
val globeCount = if (activeGlobes.size > maxGlobes) maxGlobes else activeGlobes.size
|
||||
val (backgroundSize, globeBorder, xpBorder) = getGlobeDimensions()
|
||||
|
|
@ -67,7 +68,6 @@ class plugin : Plugin() {
|
|||
override fun OnXPUpdate(skillId: Int, xp: Int) {
|
||||
if (xpGlobes[skillId].xp == Constants.INVALID_XP) {
|
||||
xpGlobes[skillId].xp = xp
|
||||
xpGlobes[skillId].prevXp = xp
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -77,14 +77,12 @@ class plugin : Plugin() {
|
|||
|
||||
val prevXp = xpGlobes[skillId].xp
|
||||
xpGlobes[skillId].xp = xp
|
||||
xpGlobes[skillId].prevXp = prevXp
|
||||
xpGlobes[skillId].timestamp = 0L
|
||||
val (prevLevel, _) = XPTable.getLevelForXp(prevXp)
|
||||
val (level, gainedXp) = XPTable.getLevelForXp(xp)
|
||||
|
||||
// we do not draw XP globes for level >= MAX_LEVEL
|
||||
if (level != Constants.INVALID_LEVEL && level < Constants.MAX_LEVEL) {
|
||||
|
||||
var arcWeight = 1.0
|
||||
var arcColor = Constants.GLOBE_XP_ARC_LEVEL_UP_COLOR
|
||||
|
||||
|
|
@ -114,11 +112,11 @@ class plugin : Plugin() {
|
|||
|
||||
override fun OnLogout() {
|
||||
lastGain = 0L
|
||||
xpGlobes = Array(Constants.SKILL_COUNT) { skillId -> XPGlobe(skillId, Constants.INVALID_XP, Constants.INVALID_XP, 0L, null) }
|
||||
xpGlobes = Array(Constants.SKILL_COUNT) { skillId -> XPGlobe(skillId, Constants.INVALID_XP, 0L, null) }
|
||||
}
|
||||
|
||||
|
||||
data class XPGlobe(val skillId: Int, var prevXp: Int, var xp: Int, var timestamp: Long, var arcSprite: Sprite?)
|
||||
data class XPGlobe(val skillId: Int, var xp: Int, var timestamp: Long, var arcSprite: Sprite?)
|
||||
|
||||
|
||||
private fun getGlobeDimensions() : Triple<Int, Int, Int> {
|
||||
|
|
@ -150,7 +148,11 @@ class plugin : Plugin() {
|
|||
val drawX = posX + totalBorder + xOffset
|
||||
val drawY = posY + totalBorder + yOffset
|
||||
|
||||
skillSprite?.render(drawX, drawY)
|
||||
// even if the centering logic is correct, the sprite seems not to be well-centered inside the
|
||||
// graphic resource. Manually adjust...
|
||||
val (spriteXOffset, spriteYOffset) = XPSprites.getSpriteOffsetForSkill(globe.skillId)
|
||||
|
||||
skillSprite?.render(drawX + spriteXOffset, drawY + spriteYOffset)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue