mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-09 16:45:46 -07:00
Correct offsets
This commit is contained in:
parent
c24df5ab46
commit
f2d4c17569
2 changed files with 41 additions and 25 deletions
|
|
@ -4,7 +4,6 @@ import KondoKit.Helpers.addMouseListenerToAll
|
||||||
import KondoKit.Helpers.formatHtmlLabelText
|
import KondoKit.Helpers.formatHtmlLabelText
|
||||||
import KondoKit.SpriteToBufferedImage.getBufferedImageFromSprite
|
import KondoKit.SpriteToBufferedImage.getBufferedImageFromSprite
|
||||||
import KondoKit.XPTrackerView.wrappedWidget
|
import KondoKit.XPTrackerView.wrappedWidget
|
||||||
import KondoKit.plugin.Companion.IMAGE_SIZE
|
|
||||||
import KondoKit.plugin.Companion.POPUP_BACKGROUND
|
import KondoKit.plugin.Companion.POPUP_BACKGROUND
|
||||||
import KondoKit.plugin.Companion.POPUP_FOREGROUND
|
import KondoKit.plugin.Companion.POPUP_FOREGROUND
|
||||||
import KondoKit.plugin.Companion.TITLE_BAR_COLOR
|
import KondoKit.plugin.Companion.TITLE_BAR_COLOR
|
||||||
|
|
@ -351,6 +350,7 @@ object LootTrackerView {
|
||||||
?.apply {
|
?.apply {
|
||||||
val newValue = (getClientProperty("val") as? Int ?: 0) + valueOfNewDrops.toInt()
|
val newValue = (getClientProperty("val") as? Int ?: 0) + valueOfNewDrops.toInt()
|
||||||
text = "${formatValue(newValue)} gp"
|
text = "${formatValue(newValue)} gp"
|
||||||
|
foreground = primaryColor
|
||||||
putClientProperty("val", newValue)
|
putClientProperty("val", newValue)
|
||||||
revalidate()
|
revalidate()
|
||||||
if(focusedView == VIEW_NAME)
|
if(focusedView == VIEW_NAME)
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class plugin : Plugin() {
|
||||||
var uiOffset = 0
|
var uiOffset = 0
|
||||||
|
|
||||||
@Exposed("Stretched/Scaled Fixed Mode Support")
|
@Exposed("Stretched/Scaled Fixed Mode Support")
|
||||||
var useAltCanvas = false
|
var useScaledFixed = false
|
||||||
|
|
||||||
const val FIXED_WIDTH = 765
|
const val FIXED_WIDTH = 765
|
||||||
const val FIXED_HEIGHT = 503
|
const val FIXED_HEIGHT = 503
|
||||||
|
|
@ -162,7 +162,7 @@ class plugin : Plugin() {
|
||||||
System.setProperty("swing.aatext", "false")
|
System.setProperty("swing.aatext", "false")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun InitAltCanvas(){
|
private fun initAltCanvas(){
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
altCanvas = AltCanvas().apply {
|
altCanvas = AltCanvas().apply {
|
||||||
preferredSize = Dimension(FIXED_WIDTH, FIXED_HEIGHT)
|
preferredSize = Dimension(FIXED_WIDTH, FIXED_HEIGHT)
|
||||||
|
|
@ -178,27 +178,36 @@ class plugin : Plugin() {
|
||||||
val mode = GetWindowMode()
|
val mode = GetWindowMode()
|
||||||
val currentScrollPaneWidth = if (mainContentPanel.isVisible) NAVBAR_WIDTH + MAIN_CONTENT_WIDTH else NAVBAR_WIDTH
|
val currentScrollPaneWidth = if (mainContentPanel.isVisible) NAVBAR_WIDTH + MAIN_CONTENT_WIDTH else NAVBAR_WIDTH
|
||||||
lastUIOffset = uiOffset
|
lastUIOffset = uiOffset
|
||||||
|
|
||||||
when (mode) {
|
when (mode) {
|
||||||
WindowMode.FIXED -> {
|
WindowMode.FIXED -> {
|
||||||
if (frame.width < FIXED_WIDTH + currentScrollPaneWidth + uiOffset) {
|
if (frame.width < FIXED_WIDTH + currentScrollPaneWidth + uiOffset) {
|
||||||
frame.setSize(FIXED_WIDTH + currentScrollPaneWidth + uiOffset, frame.height)
|
frame.setSize(FIXED_WIDTH + currentScrollPaneWidth + uiOffset, frame.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
val difference = frame.width - (uiOffset + currentScrollPaneWidth)
|
val difference = frame.width - (uiOffset + currentScrollPaneWidth)
|
||||||
if(useAltCanvas){
|
|
||||||
|
if (useScaledFixed) {
|
||||||
GameShell.leftMargin = 0
|
GameShell.leftMargin = 0
|
||||||
canvas.setLocation(0,canvas.y)
|
val canvasWidth = difference + uiOffset / 2
|
||||||
altCanvas?.size = Dimension(difference + uiOffset/2, frame.height - canvas.y)
|
val canvasHeight = frame.height - canvas.y // Restricting height to frame height
|
||||||
|
|
||||||
|
altCanvas?.size = Dimension(canvasWidth, canvasHeight)
|
||||||
|
altCanvas?.setLocation(0, canvas.y)
|
||||||
|
canvas.setLocation(0, canvas.y)
|
||||||
} else {
|
} else {
|
||||||
GameShell.leftMargin = (difference + uiOffset) / 2
|
GameShell.leftMargin = (difference + uiOffset) / 2
|
||||||
canvas.setLocation(GameShell.leftMargin - (FIXED_WIDTH/2), canvas.y)
|
canvas.setLocation(GameShell.leftMargin - (FIXED_WIDTH / 2), canvas.y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowMode.RESIZABLE -> {
|
WindowMode.RESIZABLE -> {
|
||||||
GameShell.canvasWidth = frame.width - (currentScrollPaneWidth + uiOffset)
|
GameShell.canvasWidth = frame.width - (currentScrollPaneWidth + uiOffset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rightPanelWrapper?.preferredSize = Dimension(currentScrollPaneWidth, frame.height)
|
rightPanelWrapper?.preferredSize = Dimension(currentScrollPaneWidth, frame.height)
|
||||||
rightPanelWrapper?.let { it.isDoubleBuffered = true }
|
rightPanelWrapper?.isDoubleBuffered = true
|
||||||
rightPanelWrapper?.revalidate()
|
rightPanelWrapper?.revalidate()
|
||||||
rightPanelWrapper?.repaint()
|
rightPanelWrapper?.repaint()
|
||||||
}
|
}
|
||||||
|
|
@ -217,13 +226,11 @@ class plugin : Plugin() {
|
||||||
LootTrackerView.gePriceMap = LootTrackerView.loadGEPrices()
|
LootTrackerView.gePriceMap = LootTrackerView.loadGEPrices()
|
||||||
StoreData("kondoLaunchMinimized", launchMinimized)
|
StoreData("kondoLaunchMinimized", launchMinimized)
|
||||||
StoreData("kondoUIOffset", uiOffset)
|
StoreData("kondoUIOffset", uiOffset)
|
||||||
StoreData("kondoScaleFixed", useAltCanvas)
|
StoreData("kondoScaledFixed", useScaledFixed)
|
||||||
if(altCanvas == null && useAltCanvas){
|
if(altCanvas == null && useScaledFixed){
|
||||||
InitAltCanvas()
|
initAltCanvas()
|
||||||
} else if(altCanvas != null && !useAltCanvas){
|
} else if(altCanvas != null && !useScaledFixed){
|
||||||
frame.remove(altCanvas)
|
destroyAltCanvas()
|
||||||
altCanvas = null
|
|
||||||
UpdateDisplaySettings()
|
|
||||||
}
|
}
|
||||||
if(lastUIOffset != uiOffset){
|
if(lastUIOffset != uiOffset){
|
||||||
UpdateDisplaySettings()
|
UpdateDisplaySettings()
|
||||||
|
|
@ -231,6 +238,13 @@ class plugin : Plugin() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun destroyAltCanvas(){
|
||||||
|
moveCanvasToFront()
|
||||||
|
frame.remove(altCanvas)
|
||||||
|
altCanvas = null
|
||||||
|
UpdateDisplaySettings()
|
||||||
|
}
|
||||||
|
|
||||||
override fun OnMiniMenuCreate(currentEntries: Array<out MiniMenuEntry>?) {
|
override fun OnMiniMenuCreate(currentEntries: Array<out MiniMenuEntry>?) {
|
||||||
if (currentEntries != null) {
|
if (currentEntries != null) {
|
||||||
for ((index, entry) in currentEntries.withIndex()) {
|
for ((index, entry) in currentEntries.withIndex()) {
|
||||||
|
|
@ -350,8 +364,8 @@ class plugin : Plugin() {
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(!useAltCanvas) return
|
if(!useScaledFixed) return
|
||||||
if(GetWindowMode() == WindowMode.RESIZABLE){
|
if(GetWindowMode() == WindowMode.FIXED){
|
||||||
moveAltCanvasToFront()
|
moveAltCanvasToFront()
|
||||||
} else {
|
} else {
|
||||||
moveCanvasToFront()
|
moveCanvasToFront()
|
||||||
|
|
@ -364,8 +378,10 @@ class plugin : Plugin() {
|
||||||
println("WARNING: altcanvas is null")
|
println("WARNING: altcanvas is null")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
frame.setComponentZOrder(canvas, 2)
|
||||||
frame.setComponentZOrder(altCanvas, 1)
|
frame.setComponentZOrder(altCanvas, 1)
|
||||||
frame.setComponentZOrder(canvas, 0)
|
frame.setComponentZOrder(rightPanelWrapper, 0)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun moveCanvasToFront(){
|
private fun moveCanvasToFront(){
|
||||||
|
|
@ -373,8 +389,9 @@ class plugin : Plugin() {
|
||||||
println("WARNING: altcanvas is null")
|
println("WARNING: altcanvas is null")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
frame.setComponentZOrder(altCanvas, 0)
|
frame.setComponentZOrder(altCanvas, 2)
|
||||||
frame.setComponentZOrder(canvas, 1)
|
frame.setComponentZOrder(canvas, 1)
|
||||||
|
frame.setComponentZOrder(rightPanelWrapper, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun restoreSettings(){
|
private fun restoreSettings(){
|
||||||
|
|
@ -384,12 +401,12 @@ class plugin : Plugin() {
|
||||||
val osName = System.getProperty("os.name").toLowerCase()
|
val osName = System.getProperty("os.name").toLowerCase()
|
||||||
uiOffset = (GetData("kondoUIOffset") as? Int) ?: if (osName.contains("win")) 16 else 0
|
uiOffset = (GetData("kondoUIOffset") as? Int) ?: if (osName.contains("win")) 16 else 0
|
||||||
launchMinimized = (GetData("kondoLaunchMinimized") as? Boolean) ?: false
|
launchMinimized = (GetData("kondoLaunchMinimized") as? Boolean) ?: false
|
||||||
useAltCanvas = (GetData("kondoScaleFixed") as? Boolean) ?: false
|
useScaledFixed = (GetData("kondoScaleFixed") as? Boolean) ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initKondoUI(){
|
private fun initKondoUI(){
|
||||||
DrawText(FontType.LARGE, fromColor(Color(16777215)), TextModifier.CENTER, "KondoKit Loading Sprites...", GameShell.canvasWidth/2, GameShell.canvasHeight/2)
|
DrawText(FontType.LARGE, fromColor(Color(16777215)), TextModifier.CENTER, "KondoKit Loading Sprites...", GameShell.canvasWidth/2, GameShell.canvasHeight/2)
|
||||||
if(!allSpritesLoaded()) return;
|
if(!allSpritesLoaded()) return
|
||||||
val frame: Frame? = GameShell.frame
|
val frame: Frame? = GameShell.frame
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
restoreSettings()
|
restoreSettings()
|
||||||
|
|
@ -451,8 +468,8 @@ class plugin : Plugin() {
|
||||||
} else {
|
} else {
|
||||||
setActiveView(XPTrackerView.VIEW_NAME)
|
setActiveView(XPTrackerView.VIEW_NAME)
|
||||||
}
|
}
|
||||||
if(useAltCanvas) {
|
if(useScaledFixed) {
|
||||||
InitAltCanvas()
|
initAltCanvas()
|
||||||
}
|
}
|
||||||
initialized = true
|
initialized = true
|
||||||
pluginsReloaded = true
|
pluginsReloaded = true
|
||||||
|
|
@ -558,7 +575,7 @@ class plugin : Plugin() {
|
||||||
maximumSize = buttonSize
|
maximumSize = buttonSize
|
||||||
minimumSize = buttonSize
|
minimumSize = buttonSize
|
||||||
background = WIDGET_COLOR
|
background = WIDGET_COLOR
|
||||||
isOpaque = true // Ensure background is painted
|
isOpaque = true
|
||||||
|
|
||||||
val gbc = GridBagConstraints().apply {
|
val gbc = GridBagConstraints().apply {
|
||||||
anchor = GridBagConstraints.CENTER
|
anchor = GridBagConstraints.CENTER
|
||||||
|
|
@ -657,7 +674,6 @@ class plugin : Plugin() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun loadFont(): Font? {
|
fun loadFont(): Font? {
|
||||||
val fontStream = plugin::class.java.getResourceAsStream("res/runescape_small.ttf")
|
val fontStream = plugin::class.java.getResourceAsStream("res/runescape_small.ttf")
|
||||||
return if (fontStream != null) {
|
return if (fontStream != null) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue