mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-09 16:45:46 -07:00
ResizableSD 1.1
This commit is contained in:
parent
8b42b58b87
commit
8076568083
2 changed files with 42 additions and 36 deletions
|
|
@ -1,84 +1,90 @@
|
||||||
package ToggleResizableSD
|
package ToggleResizableSD
|
||||||
|
|
||||||
|
import KondoKit.Exposed
|
||||||
import plugin.Plugin
|
import plugin.Plugin
|
||||||
import plugin.annotations.PluginMeta
|
|
||||||
import plugin.api.API
|
import plugin.api.API
|
||||||
import rt4.*
|
import plugin.api.API.StoreData
|
||||||
|
import rt4.DisplayMode
|
||||||
|
import rt4.GameShell
|
||||||
|
import rt4.InterfaceList
|
||||||
|
import rt4.client
|
||||||
import java.awt.event.KeyAdapter
|
import java.awt.event.KeyAdapter
|
||||||
import java.awt.event.KeyEvent
|
import java.awt.event.KeyEvent
|
||||||
|
|
||||||
class plugin : Plugin() {
|
class plugin : Plugin() {
|
||||||
var toggleResize = false
|
|
||||||
var wantHd = false //Setting wantHd to true hides the black screen on logout (when resize SD is enabled), by enabling HD on logout
|
@Exposed("Use Resizable SD")
|
||||||
|
var useResizable = false
|
||||||
|
|
||||||
|
@Exposed("Setting wantHd to true hides the black screen on logout (when resize SD is enabled), by enabling HD on logout ")
|
||||||
|
var wantHd = false
|
||||||
|
|
||||||
override fun Init() {
|
override fun Init() {
|
||||||
API.AddKeyboardListener(object : KeyAdapter() {
|
API.AddKeyboardListener(object : KeyAdapter() {
|
||||||
override fun keyPressed(e: KeyEvent) {
|
override fun keyPressed(e: KeyEvent) {
|
||||||
if (e.keyCode == KeyEvent.VK_F12) {
|
if (e.keyCode == KeyEvent.VK_F12) {
|
||||||
toggleResize = true
|
toggleResizableSd()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (!DisplayMode.resizableSD && API.GetData("use-resizable-sd") == true) {
|
|
||||||
toggleResize = true
|
useResizable = DisplayMode.resizableSD
|
||||||
|
if (API.GetData("use-resizable-sd") == true) {
|
||||||
|
useResizable = true
|
||||||
}
|
}
|
||||||
var osNameLowerCase: String = ""
|
|
||||||
var osName: String
|
var osNameLowerCase: String = System.getProperty("os.name").toLowerCase()
|
||||||
|
|
||||||
try {
|
|
||||||
osName = System.getProperty("os.name")
|
|
||||||
} catch (e: Exception) {
|
|
||||||
osName = "Unknown"
|
|
||||||
}
|
|
||||||
|
|
||||||
osNameLowerCase = osName.toLowerCase()
|
|
||||||
if (!osNameLowerCase.startsWith("mac")) {
|
if (!osNameLowerCase.startsWith("mac")) {
|
||||||
wantHd = true
|
wantHd = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (API.GetData("want-hd") == false) {
|
if (API.GetData("want-hd") == false) {
|
||||||
wantHd = false
|
wantHd = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun ProcessCommand(commandStr: String, args: Array<out String>?) {
|
override fun ProcessCommand(commandStr: String, args: Array<out String>?) {
|
||||||
when(commandStr.toLowerCase()) {
|
when (commandStr.toLowerCase()) {
|
||||||
"::toggleresizablesd", "::resizablesd", "::togglersd", "::rsd" -> {
|
"::toggleresizablesd", "::resizablesd", "::togglersd", "::rsd" -> {
|
||||||
toggleResize = true //We could call toggleResizableSd() directly here, but it's not necessary.
|
toggleResizableSd()
|
||||||
}
|
}
|
||||||
"::toggleresizablesdhd", "::resizablesdhd", "::togglersdhd", "::rsdhd", -> {
|
"::toggleresizablesdhd", "::resizablesdhd", "::togglersdhd", "::rsdhd" -> {
|
||||||
wantHd = !wantHd
|
wantHd = !wantHd
|
||||||
API.StoreData("want-hd", wantHd)
|
StoreData("want-hd", wantHd)
|
||||||
API.SendMessage("You have turned login screen HD " + (if (wantHd) "on" else "off"))
|
API.SendMessage("You have turned login screen HD " + (if (wantHd) "on" else "off"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleResizableSd() {
|
fun toggleResizableSd() {
|
||||||
//We only want to toggle resizable SD when we are logged in and the lobby/welcome interface is not open.
|
|
||||||
if (InterfaceList.aClass13_26 == null || client.gameState != 30) {
|
if (InterfaceList.aClass13_26 == null || client.gameState != 30) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
toggleResize = false
|
|
||||||
DisplayMode.resizableSD = !DisplayMode.resizableSD;
|
DisplayMode.resizableSD = !DisplayMode.resizableSD
|
||||||
if(!DisplayMode.resizableSD){
|
useResizable = DisplayMode.resizableSD
|
||||||
//Revert to fixed
|
StoreData("use-resizable-sd", useResizable)
|
||||||
API.StoreData("use-resizable-sd", false) //Note: It is important to call StoreData before setWindowMode because setWindowMode causes all plugins to reload.
|
|
||||||
|
if (!DisplayMode.resizableSD) {
|
||||||
DisplayMode.setWindowMode(true, 0, -1, -1)
|
DisplayMode.setWindowMode(true, 0, -1, -1)
|
||||||
} else {
|
} else {
|
||||||
//Use resizable
|
|
||||||
API.StoreData("use-resizable-sd", true) //Note: It is important to call StoreData before setWindowMode because setWindowMode causes all plugins to reload.
|
|
||||||
DisplayMode.setWindowMode(true, 0, GameShell.frameWidth, GameShell.frameHeight)
|
DisplayMode.setWindowMode(true, 0, GameShell.frameWidth, GameShell.frameHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun Draw(timeDelta: Long) {
|
override fun Draw(timeDelta: Long) {
|
||||||
if (toggleResize) {
|
if (useResizable != DisplayMode.resizableSD) {
|
||||||
toggleResizableSd()
|
toggleResizableSd()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun OnKondoValueUpdated() {
|
||||||
|
StoreData("want-hd", wantHd)
|
||||||
|
StoreData("use-resizable-sd", useResizable)
|
||||||
|
}
|
||||||
|
|
||||||
override fun OnLogout() {
|
override fun OnLogout() {
|
||||||
if (DisplayMode.resizableSD && wantHd) {
|
if (DisplayMode.resizableSD && wantHd) {
|
||||||
//Because resizable SD always uses the "HD" size canvas/window mode (check the in-game Graphics Options with resizeable SD enabled if you don't believe me!), useHD becomes true when logging out, so logging out with resizeSD enabled means "HD" will always be enabled on the login screen after logging out, so we might as well fix the HD flyover by setting resizableSD to false first, and then calling setWindowMode to replace the canvas and set newMode to 2.
|
|
||||||
DisplayMode.resizableSD = false
|
DisplayMode.resizableSD = false
|
||||||
DisplayMode.setWindowMode(true, 2, GameShell.frameWidth, GameShell.frameHeight)
|
DisplayMode.setWindowMode(true, 2, GameShell.frameWidth, GameShell.frameHeight)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
AUTHOR='ipkpjersi'
|
AUTHOR='ipkpjersi'
|
||||||
DESCRIPTION='Allows you to use F12 to toggle resizable SD.'
|
DESCRIPTION='Allows you to use F12 to toggle resizable SD.'
|
||||||
VERSION=1.0
|
VERSION=1.1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue