mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-16 03:20:21 -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() {
|
private fun updateDisplaySettings() {
|
||||||
val mode = GetWindowMode()
|
val applyDisplaySettings = {
|
||||||
val currentScrollPaneWidth = if (mainContentPanel.isVisible) NAVBAR_WIDTH + MAIN_CONTENT_WIDTH else NAVBAR_WIDTH
|
val mode = GetWindowMode()
|
||||||
lastUIOffset = uiOffset
|
val currentScrollPaneWidth = if (mainContentPanel.isVisible) NAVBAR_WIDTH + MAIN_CONTENT_WIDTH else NAVBAR_WIDTH
|
||||||
|
lastUIOffset = uiOffset
|
||||||
|
|
||||||
if(mode != WindowMode.FIXED) {
|
// Ensure the scroll wrapper stays attached on the EAST edge even if the game resets the layout
|
||||||
destroyAltCanvas()
|
rightPanelWrapper?.let { wrapper ->
|
||||||
} else if (useScaledFixed && altCanvas == null) {
|
val needsLayoutReset = frame.layout !is BorderLayout
|
||||||
initAltCanvas()
|
val needsAttach = wrapper.parent != frame
|
||||||
} else if (!useScaledFixed && altCanvas != null) {
|
if (needsLayoutReset || needsAttach) {
|
||||||
// Was using scaled fixed but toggled the setting
|
wrapper.parent?.remove(wrapper)
|
||||||
// restore the original canvas
|
frame.layout = BorderLayout()
|
||||||
moveCanvasToFront()
|
frame.add(wrapper, BorderLayout.EAST)
|
||||||
destroyAltCanvas()
|
if (altCanvas != null) {
|
||||||
}
|
moveAltCanvasToFront()
|
||||||
|
} else {
|
||||||
when (mode) {
|
moveCanvasToFront()
|
||||||
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 -> {
|
if(mode != WindowMode.FIXED) {
|
||||||
GameShell.canvasWidth = frame.width - (currentScrollPaneWidth + uiOffset)
|
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)
|
if (SwingUtilities.isEventDispatchThread()) {
|
||||||
rightPanelWrapper?.isDoubleBuffered = true
|
applyDisplaySettings()
|
||||||
rightPanelWrapper?.revalidate()
|
} else {
|
||||||
rightPanelWrapper?.repaint()
|
SwingUtilities.invokeLater { applyDisplaySettings() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun OnKondoValueUpdated(){
|
fun OnKondoValueUpdated(){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue