Launcher now has selectable profiles for live, testing, and local

This commit is contained in:
ceikry 2022-03-24 22:55:47 -05:00
parent 6ea4c51ad2
commit b5e4dc3d23
2 changed files with 30 additions and 0 deletions

View file

@ -48,6 +48,16 @@ object Json {
launcher["closeOnClientLaunch"] = SettingsWindow.closeLauncherOnLaunch.isToggled
launcher["notifyUpdates"] = Settings.CHECK_FOR_UPDATES
val ip = when(SettingsWindow.profileMode.selectedIndex)
{
0 -> "play.2009scape.org"
1 -> "ryannathans.net"
else -> "localhost"
}
data["ip_management"] = ip
data["ip_address"] = ip
FileWriter(CONF).use { writer ->
writer.write(data.toJSONString())
writer.flush()
@ -106,6 +116,13 @@ object Json {
SettingsWindow.closeLauncherOnLaunch.isToggled = launcher.getOrDefault("closeOnClientLaunch", true) as Boolean
Settings.CHECK_FOR_UPDATES = launcher.getOrDefault("notifyUpdates", true) as Boolean
SettingsWindow.profileMode.selectedIndex = when(data["ip_management"])
{
"play.2009scape.org" -> 0
"ryannathans.net" -> 1
else -> 2
}
} catch (e: Exception) {
println("error parsing settings, replacing with defaults...")
e.printStackTrace()

View file

@ -18,6 +18,7 @@ object SettingsWindow : JFrame("Client Settings") {
val xpDropModeOptions = arrayOf("instant","incremental")
val xpTrackModeOptions = arrayOf("total xp","recent skill")
val profileOptions = arrayOf("Live","Testing","Local")
var tabs = ArrayList<JPanel>()
var buttons = ArrayList<ImgButton>()
@ -47,6 +48,7 @@ object SettingsWindow : JFrame("Client Settings") {
val closeLauncherOnLaunch = Checkbox()
val checkForLauncherUpdates = Checkbox()
var RCMPreviewInitialized = false
val profileMode = JComboBox(profileOptions)
init {
isUndecorated = true
@ -283,6 +285,8 @@ object SettingsWindow : JFrame("Client Settings") {
val closeLauncherOnLaunchLabel = getLabel("Close launcher when client starts")
val checkForUpdatePanel = getThemedPanel(BorderLayout())
val checkForUpdateLabel = getLabel("Notify me of launcher updates")
val profilePanel = getThemedPanel(BorderLayout())
val profileLabel = getLabel("Profile")
checkForLauncherUpdates.onClick {
checkForLauncherUpdates.isToggled = !checkForLauncherUpdates.isToggled
@ -297,6 +301,15 @@ object SettingsWindow : JFrame("Client Settings") {
checkForUpdatePanel.add(checkForUpdateLabel, BorderLayout.WEST)
checkForUpdatePanel.add(checkForLauncherUpdates, BorderLayout.EAST)
pane.add(checkForUpdatePanel)
pane.add(getSeparator())
profileMode.size = Dimension(200,10)
profileMode.minimumSize = Dimension(200,10)
profileMode.maximumSize = Dimension(200,10)
profileMode.preferredSize = Dimension(200,10)
profilePanel.add(profileLabel, BorderLayout.WEST)
profilePanel.add(profileMode, BorderLayout.EAST)
pane.add(profilePanel)
addTab(pane, button, getLabel("Launcher Settings"))
}