mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-09 16:45:46 -07:00
Keep the canvas in the frame but change the Z order
This commit is contained in:
parent
8180e20281
commit
1f1718d917
3 changed files with 20 additions and 53 deletions
|
|
@ -70,7 +70,7 @@ public class PluginRepository {
|
||||||
File pluginsDirectory = new File(GlobalJsonConfig.instance.pluginsFolder);
|
File pluginsDirectory = new File(GlobalJsonConfig.instance.pluginsFolder);
|
||||||
|
|
||||||
if (!pluginsDirectory.exists()) {
|
if (!pluginsDirectory.exists()) {
|
||||||
System.out.println("Skipping plugin initialization - " + pluginsDirectory.getAbsolutePath() + " does not exist.");
|
//System.out.println("Skipping plugin initialization - " + pluginsDirectory.getAbsolutePath() + " does not exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ public class PluginRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadedPlugins.containsKey(info)) {
|
if (loadedPlugins.containsKey(info)) {
|
||||||
System.out.println("Skipping reloading of plugin " + file.getName() + " as it already exists and has OnPluginsReloaded.");
|
//System.out.println("Skipping reloading of plugin " + file.getName() + " as it already exists and has OnPluginsReloaded.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,7 +143,7 @@ public class PluginRepository {
|
||||||
loader.loadClass(file.getName() + "." + f.getName().replace(".class",""));
|
loader.loadClass(file.getName() + "." + f.getName().replace(".class",""));
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Successfully loaded plugin " + file.getName() + ", version " + info.version);
|
//System.out.println("Successfully loaded plugin " + file.getName() + ", version " + info.version);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Unexpected exception during plugin initialization:");
|
System.err.println("Unexpected exception during plugin initialization:");
|
||||||
|
|
|
||||||
|
|
@ -205,8 +205,8 @@ public final class GlRenderer {
|
||||||
@OriginalMember(owner = "client!tf", name = "d", descriptor = "()V")
|
@OriginalMember(owner = "client!tf", name = "d", descriptor = "()V")
|
||||||
public static void swapBuffers() {
|
public static void swapBuffers() {
|
||||||
try {
|
try {
|
||||||
readPixels();
|
|
||||||
drawable.swapBuffers();
|
drawable.swapBuffers();
|
||||||
|
readPixels();
|
||||||
} catch (@Pc(3) Exception local3) {
|
} catch (@Pc(3) Exception local3) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ import rt4.GameShell.frame
|
||||||
import rt4.client.js5Archive8
|
import rt4.client.js5Archive8
|
||||||
import rt4.client.mainLoadState
|
import rt4.client.mainLoadState
|
||||||
import java.awt.*
|
import java.awt.*
|
||||||
import java.awt.Component
|
|
||||||
import java.awt.Font
|
import java.awt.Font
|
||||||
import java.awt.event.*
|
import java.awt.event.*
|
||||||
import java.awt.image.BufferedImage
|
import java.awt.image.BufferedImage
|
||||||
|
|
@ -113,7 +112,6 @@ class plugin : Plugin() {
|
||||||
private var lastUIOffset = 0
|
private var lastUIOffset = 0
|
||||||
private const val HIDDEN_VIEW = "HIDDEN"
|
private const val HIDDEN_VIEW = "HIDDEN"
|
||||||
private val drawActions = mutableListOf<() -> Unit>()
|
private val drawActions = mutableListOf<() -> Unit>()
|
||||||
private var hiddenFrame: JFrame? = null
|
|
||||||
|
|
||||||
fun registerDrawAction(action: () -> Unit) {
|
fun registerDrawAction(action: () -> Unit) {
|
||||||
synchronized(drawActions) {
|
synchronized(drawActions) {
|
||||||
|
|
@ -390,13 +388,13 @@ class plugin : Plugin() {
|
||||||
System.setProperty("swing.aatext", "false")
|
System.setProperty("swing.aatext", "false")
|
||||||
val frame: Frame? = GameShell.frame
|
val frame: Frame? = GameShell.frame
|
||||||
if (frame != null) {
|
if (frame != null) {
|
||||||
|
frame.layout = BorderLayout()
|
||||||
// Create the AltCanvas and add it to the main frame
|
// Create the AltCanvas and add it to the main frame
|
||||||
altCanvas = createAltCanvas()
|
altCanvas = createAltCanvas()
|
||||||
|
altCanvas?.let { frame.add(it) }
|
||||||
// Use BorderLayout for better layout control
|
// Use BorderLayout for better layout control
|
||||||
frame.layout = BorderLayout()
|
frame.setComponentZOrder(altCanvas, 0)
|
||||||
|
frame.setComponentZOrder(canvas, 1)
|
||||||
// Add the AltCanvas in the center to ensure it scales properly with the window size
|
|
||||||
altCanvas?.let { frame.add(it, BorderLayout.NORTH) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -409,6 +407,7 @@ class plugin : Plugin() {
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
canvas.setLocation(0,0)
|
||||||
val difference = frame.width - (uiOffset + currentScrollPaneWidth)
|
val difference = frame.width - (uiOffset + currentScrollPaneWidth)
|
||||||
altCanvas?.size = Dimension(difference, frame.height - 30)
|
altCanvas?.size = Dimension(difference, frame.height - 30)
|
||||||
}
|
}
|
||||||
|
|
@ -486,17 +485,16 @@ class plugin : Plugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun OnXPUpdate(skillId: Int, xp: Int) {
|
override fun OnXPUpdate(skillId: Int, xp: Int) {
|
||||||
SwingUtilities.invokeLater{
|
|
||||||
if (!initialXP.containsKey(skillId)) {
|
if (!initialXP.containsKey(skillId)) {
|
||||||
initialXP[skillId] = xp
|
initialXP[skillId] = xp
|
||||||
return@invokeLater
|
return
|
||||||
}
|
}
|
||||||
var xpWidget = xpWidgets[skillId]
|
var xpWidget = xpWidgets[skillId]
|
||||||
if (xpWidget != null) {
|
if (xpWidget != null) {
|
||||||
updateWidget(xpWidget, xp)
|
updateWidget(xpWidget, xp)
|
||||||
} else {
|
} else {
|
||||||
val previousXp = initialXP[skillId] ?: xp
|
val previousXp = initialXP[skillId] ?: xp
|
||||||
if (xp == initialXP[skillId]) return@invokeLater
|
if (xp == initialXP[skillId]) return
|
||||||
|
|
||||||
xpWidget = createXPWidget(skillId, previousXp)
|
xpWidget = createXPWidget(skillId, previousXp)
|
||||||
xpWidgets[skillId] = xpWidget
|
xpWidgets[skillId] = xpWidget
|
||||||
|
|
@ -512,7 +510,6 @@ class plugin : Plugin() {
|
||||||
updateWidget(xpWidget, xp)
|
updateWidget(xpWidget, xp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun Draw(timeDelta: Long) {
|
override fun Draw(timeDelta: Long) {
|
||||||
if (GlRenderer.enabled && GlRenderer.canvasWidth != GameShell.canvasWidth) {
|
if (GlRenderer.enabled && GlRenderer.canvasWidth != GameShell.canvasWidth) {
|
||||||
|
|
@ -555,49 +552,16 @@ class plugin : Plugin() {
|
||||||
|
|
||||||
override fun LateDraw(timeDelta: Long) {
|
override fun LateDraw(timeDelta: Long) {
|
||||||
if (!initialized) return
|
if (!initialized) return
|
||||||
if (GetWindowMode() == WindowMode.FIXED) {
|
if(GetWindowMode() == WindowMode.RESIZABLE){
|
||||||
if (canvas.parent != hiddenFrame?.contentPane) {
|
frame.setComponentZOrder(altCanvas, 1)
|
||||||
if (altCanvas?.parent != frame) {
|
frame.setComponentZOrder(canvas, 0)
|
||||||
frame.add(altCanvas)
|
|
||||||
}
|
|
||||||
initializeHiddenFrame()
|
|
||||||
hiddenFrame?.let { transferComponent(canvas, frame, it) }
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (altCanvas?.parent == frame) {
|
frame.setComponentZOrder(altCanvas, 0)
|
||||||
frame.remove(altCanvas)
|
frame.setComponentZOrder(canvas, 1)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
altCanvas?.updateGameImage() // Update the game image as needed
|
altCanvas?.updateGameImage() // Update the game image as needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun transferComponent(component: Component, fromFrame: Frame, toFrame: Frame) {
|
|
||||||
println("Transferring component")
|
|
||||||
fromFrame.remove(component)
|
|
||||||
toFrame.add(component)
|
|
||||||
toFrame.pack()
|
|
||||||
fromFrame.revalidate()
|
|
||||||
toFrame.revalidate()
|
|
||||||
fromFrame.repaint()
|
|
||||||
toFrame.repaint()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun initializeHiddenFrame(debugMode: Boolean = true) {
|
|
||||||
if (hiddenFrame == null) {
|
|
||||||
hiddenFrame = JFrame().apply {
|
|
||||||
isUndecorated = !debugMode
|
|
||||||
isFocusable = false
|
|
||||||
isVisible = debugMode // Show frame if debugMode is true
|
|
||||||
setSize(
|
|
||||||
if(debugMode) FIXED_WIDTH else 1,
|
|
||||||
if(debugMode) FIXED_HEIGHT else 1
|
|
||||||
)
|
|
||||||
defaultCloseOperation = JFrame.DO_NOTHING_ON_CLOSE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
@ -720,7 +684,10 @@ class plugin : Plugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.layout = BorderLayout()
|
frame.layout = BorderLayout()
|
||||||
rightPanelWrapper?.let { frame.add(it, BorderLayout.EAST) }
|
rightPanelWrapper?.let {
|
||||||
|
frame.add(it, BorderLayout.EAST)
|
||||||
|
frame.setComponentZOrder(it, 2)
|
||||||
|
}
|
||||||
|
|
||||||
if(!launchMinimized){
|
if(!launchMinimized){
|
||||||
setActiveView(XPTrackerView.VIEW_NAME)
|
setActiveView(XPTrackerView.VIEW_NAME)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue