mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-13 01:51:39 -07:00
Edge snap fix
This commit is contained in:
parent
5240963743
commit
0c1e445a95
2 changed files with 64 additions and 39 deletions
BIN
plugin-playground/src/main/kotlin/KondoKit/.DS_Store
vendored
BIN
plugin-playground/src/main/kotlin/KondoKit/.DS_Store
vendored
Binary file not shown.
|
|
@ -320,52 +320,77 @@ class plugin : Plugin() {
|
|||
}
|
||||
|
||||
private fun updateDisplaySettings() {
|
||||
val mode = GetWindowMode()
|
||||
val currentScrollPaneWidth = if (mainContentPanel.isVisible) NAVBAR_WIDTH + MAIN_CONTENT_WIDTH else NAVBAR_WIDTH
|
||||
lastUIOffset = uiOffset
|
||||
val applyDisplaySettings = {
|
||||
val mode = GetWindowMode()
|
||||
val currentScrollPaneWidth = if (mainContentPanel.isVisible) NAVBAR_WIDTH + MAIN_CONTENT_WIDTH else NAVBAR_WIDTH
|
||||
lastUIOffset = uiOffset
|
||||
|
||||
if(mode != WindowMode.FIXED) {
|
||||
destroyAltCanvas()
|
||||
} else if (useScaledFixed && altCanvas == null) {
|
||||
initAltCanvas()
|
||||
} else if (!useScaledFixed && altCanvas != null) {
|
||||
// Was using scaled fixed but toggled the setting
|
||||
// restore the original canvas
|
||||
moveCanvasToFront()
|
||||
destroyAltCanvas()
|
||||
}
|
||||
|
||||
when (mode) {
|
||||
WindowMode.FIXED -> {
|
||||
if (frame.width < FIXED_WIDTH + currentScrollPaneWidth + uiOffset) {
|
||||
frame.setSize(FIXED_WIDTH + currentScrollPaneWidth + uiOffset, frame.height)
|
||||
}
|
||||
|
||||
val difference = frame.width - (uiOffset + currentScrollPaneWidth)
|
||||
|
||||
if (useScaledFixed) {
|
||||
GameShell.leftMargin = 0
|
||||
val canvasWidth = difference + uiOffset / 2
|
||||
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 {
|
||||
val difference = frame.width - (FIXED_WIDTH + uiOffset + currentScrollPaneWidth)
|
||||
GameShell.leftMargin = difference / 2
|
||||
// Ensure the scroll wrapper stays attached on the EAST edge even if the game resets the layout
|
||||
rightPanelWrapper?.let { wrapper ->
|
||||
val needsLayoutReset = frame.layout !is BorderLayout
|
||||
val needsAttach = wrapper.parent != frame
|
||||
if (needsLayoutReset || needsAttach) {
|
||||
wrapper.parent?.remove(wrapper)
|
||||
frame.layout = BorderLayout()
|
||||
frame.add(wrapper, BorderLayout.EAST)
|
||||
if (altCanvas != null) {
|
||||
moveAltCanvasToFront()
|
||||
} else {
|
||||
moveCanvasToFront()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WindowMode.RESIZABLE -> {
|
||||
GameShell.canvasWidth = frame.width - (currentScrollPaneWidth + uiOffset)
|
||||
if(mode != WindowMode.FIXED) {
|
||||
destroyAltCanvas()
|
||||
} else if (useScaledFixed && altCanvas == null) {
|
||||
initAltCanvas()
|
||||
} else if (!useScaledFixed && altCanvas != null) {
|
||||
// Was using scaled fixed but toggled the setting
|
||||
// restore the original canvas
|
||||
moveCanvasToFront()
|
||||
destroyAltCanvas()
|
||||
}
|
||||
|
||||
when (mode) {
|
||||
WindowMode.FIXED -> {
|
||||
if (frame.width < FIXED_WIDTH + currentScrollPaneWidth + uiOffset) {
|
||||
frame.setSize(FIXED_WIDTH + currentScrollPaneWidth + uiOffset, frame.height)
|
||||
}
|
||||
|
||||
val difference = frame.width - (uiOffset + currentScrollPaneWidth)
|
||||
|
||||
if (useScaledFixed) {
|
||||
GameShell.leftMargin = 0
|
||||
val canvasWidth = difference + uiOffset / 2
|
||||
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 {
|
||||
val difference = frame.width - (FIXED_WIDTH + uiOffset + currentScrollPaneWidth)
|
||||
GameShell.leftMargin = difference / 2
|
||||
}
|
||||
}
|
||||
|
||||
WindowMode.RESIZABLE -> {
|
||||
GameShell.canvasWidth = frame.width - (currentScrollPaneWidth + uiOffset)
|
||||
}
|
||||
}
|
||||
|
||||
rightPanelWrapper?.preferredSize = Dimension(currentScrollPaneWidth, frame.height)
|
||||
rightPanelWrapper?.isDoubleBuffered = true
|
||||
rightPanelWrapper?.revalidate()
|
||||
rightPanelWrapper?.repaint()
|
||||
frame.validate()
|
||||
}
|
||||
|
||||
rightPanelWrapper?.preferredSize = Dimension(currentScrollPaneWidth, frame.height)
|
||||
rightPanelWrapper?.isDoubleBuffered = true
|
||||
rightPanelWrapper?.revalidate()
|
||||
rightPanelWrapper?.repaint()
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
applyDisplaySettings()
|
||||
} else {
|
||||
SwingUtilities.invokeLater { applyDisplaySettings() }
|
||||
}
|
||||
}
|
||||
|
||||
fun OnKondoValueUpdated(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue