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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ public class PluginRepository {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ public class PluginRepository {
|
|||
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) {
|
||||
System.err.println("Unexpected exception during plugin initialization:");
|
||||
|
|
|
|||
|
|
@ -205,8 +205,8 @@ public final class GlRenderer {
|
|||
@OriginalMember(owner = "client!tf", name = "d", descriptor = "()V")
|
||||
public static void swapBuffers() {
|
||||
try {
|
||||
readPixels();
|
||||
drawable.swapBuffers();
|
||||
readPixels();
|
||||
} catch (@Pc(3) Exception local3) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import rt4.GameShell.frame
|
|||
import rt4.client.js5Archive8
|
||||
import rt4.client.mainLoadState
|
||||
import java.awt.*
|
||||
import java.awt.Component
|
||||
import java.awt.Font
|
||||
import java.awt.event.*
|
||||
import java.awt.image.BufferedImage
|
||||
|
|
@ -113,7 +112,6 @@ class plugin : Plugin() {
|
|||
private var lastUIOffset = 0
|
||||
private const val HIDDEN_VIEW = "HIDDEN"
|
||||
private val drawActions = mutableListOf<() -> Unit>()
|
||||
private var hiddenFrame: JFrame? = null
|
||||
|
||||
fun registerDrawAction(action: () -> Unit) {
|
||||
synchronized(drawActions) {
|
||||
|
|
@ -390,13 +388,13 @@ class plugin : Plugin() {
|
|||
System.setProperty("swing.aatext", "false")
|
||||
val frame: Frame? = GameShell.frame
|
||||
if (frame != null) {
|
||||
frame.layout = BorderLayout()
|
||||
// Create the AltCanvas and add it to the main frame
|
||||
altCanvas = createAltCanvas()
|
||||
altCanvas?.let { frame.add(it) }
|
||||
// Use BorderLayout for better layout control
|
||||
frame.layout = BorderLayout()
|
||||
|
||||
// Add the AltCanvas in the center to ensure it scales properly with the window size
|
||||
altCanvas?.let { frame.add(it, BorderLayout.NORTH) }
|
||||
frame.setComponentZOrder(altCanvas, 0)
|
||||
frame.setComponentZOrder(canvas, 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -409,6 +407,7 @@ class plugin : Plugin() {
|
|||
if (frame.width < FIXED_WIDTH + currentScrollPaneWidth + uiOffset) {
|
||||
frame.setSize(FIXED_WIDTH + currentScrollPaneWidth + uiOffset, frame.height)
|
||||
}
|
||||
canvas.setLocation(0,0)
|
||||
val difference = frame.width - (uiOffset + currentScrollPaneWidth)
|
||||
altCanvas?.size = Dimension(difference, frame.height - 30)
|
||||
}
|
||||
|
|
@ -486,17 +485,16 @@ class plugin : Plugin() {
|
|||
}
|
||||
|
||||
override fun OnXPUpdate(skillId: Int, xp: Int) {
|
||||
SwingUtilities.invokeLater{
|
||||
if (!initialXP.containsKey(skillId)) {
|
||||
initialXP[skillId] = xp
|
||||
return@invokeLater
|
||||
return
|
||||
}
|
||||
var xpWidget = xpWidgets[skillId]
|
||||
if (xpWidget != null) {
|
||||
updateWidget(xpWidget, xp)
|
||||
} else {
|
||||
val previousXp = initialXP[skillId] ?: xp
|
||||
if (xp == initialXP[skillId]) return@invokeLater
|
||||
if (xp == initialXP[skillId]) return
|
||||
|
||||
xpWidget = createXPWidget(skillId, previousXp)
|
||||
xpWidgets[skillId] = xpWidget
|
||||
|
|
@ -512,7 +510,6 @@ class plugin : Plugin() {
|
|||
updateWidget(xpWidget, xp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun Draw(timeDelta: Long) {
|
||||
if (GlRenderer.enabled && GlRenderer.canvasWidth != GameShell.canvasWidth) {
|
||||
|
|
@ -555,49 +552,16 @@ class plugin : Plugin() {
|
|||
|
||||
override fun LateDraw(timeDelta: Long) {
|
||||
if (!initialized) return
|
||||
if (GetWindowMode() == WindowMode.FIXED) {
|
||||
if (canvas.parent != hiddenFrame?.contentPane) {
|
||||
if (altCanvas?.parent != frame) {
|
||||
frame.add(altCanvas)
|
||||
}
|
||||
initializeHiddenFrame()
|
||||
hiddenFrame?.let { transferComponent(canvas, frame, it) }
|
||||
}
|
||||
if(GetWindowMode() == WindowMode.RESIZABLE){
|
||||
frame.setComponentZOrder(altCanvas, 1)
|
||||
frame.setComponentZOrder(canvas, 0)
|
||||
} else {
|
||||
if (altCanvas?.parent == frame) {
|
||||
frame.remove(altCanvas)
|
||||
}
|
||||
frame.setComponentZOrder(altCanvas, 0)
|
||||
frame.setComponentZOrder(canvas, 1)
|
||||
}
|
||||
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(){
|
||||
DrawText(FontType.LARGE, fromColor(Color(16777215)), TextModifier.CENTER, "KondoKit Loading Sprites...", GameShell.canvasWidth/2, GameShell.canvasHeight/2)
|
||||
if(!allSpritesLoaded()) return;
|
||||
|
|
@ -720,7 +684,10 @@ class plugin : Plugin() {
|
|||
}
|
||||
|
||||
frame.layout = BorderLayout()
|
||||
rightPanelWrapper?.let { frame.add(it, BorderLayout.EAST) }
|
||||
rightPanelWrapper?.let {
|
||||
frame.add(it, BorderLayout.EAST)
|
||||
frame.setComponentZOrder(it, 2)
|
||||
}
|
||||
|
||||
if(!launchMinimized){
|
||||
setActiveView(XPTrackerView.VIEW_NAME)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue