Added a right click menu preview to the right click settings window

This commit is contained in:
ceikry 2021-08-17 12:03:06 -05:00
parent 37cc71e42d
commit 702984bd69
2 changed files with 123 additions and 0 deletions

View file

@ -0,0 +1,98 @@
package settingseditor
import java.awt.BorderLayout
import java.awt.Color
import java.lang.Exception
import javax.swing.*
object RCMPreview : JFrame("RCM Preview") {
val chooseLabel = JLabel("Choose Option")
val mainPanel = JPanel(BorderLayout())
val choosePanel = JPanel(BorderLayout())
val optionsPanel = JPanel()
val abyssalWhipLabel = JLabel(" Abyssal whip")
val abyssalWhipLabel2 = JLabel(" Abyssal whip")
val takePanel = JPanel(BorderLayout())
val examinePanel = JPanel(BorderLayout())
val walkPanel = JPanel(BorderLayout())
val cancelPanel = JPanel(BorderLayout())
var border = BorderFactory.createLineBorder(Color(255,255,255))
init {
isUndecorated = true
isResizable = false
layout = BorderLayout()
setLocation(SettingsWindow.location.x + SettingsWindow.width + 10, SettingsWindow.location.y)
isVisible = false
updateComponents()
choosePanel.add(chooseLabel, BorderLayout.WEST)
mainPanel.add(choosePanel, BorderLayout.NORTH)
optionsPanel.layout = BoxLayout(optionsPanel, BoxLayout.PAGE_AXIS)
takePanel.add(getLabel("Take"), BorderLayout.WEST)
takePanel.add(abyssalWhipLabel, BorderLayout.EAST)
optionsPanel.add(takePanel)
examinePanel.add(getLabel("Examine"), BorderLayout.WEST)
examinePanel.add(abyssalWhipLabel2, BorderLayout.EAST)
walkPanel.add(getLabel("Walk here"), BorderLayout.WEST)
cancelPanel.add(getLabel("Cancel"), BorderLayout.WEST)
optionsPanel.add(walkPanel)
optionsPanel.add(examinePanel)
optionsPanel.add(cancelPanel)
mainPanel.add(optionsPanel, BorderLayout.SOUTH)
add(mainPanel, BorderLayout.CENTER)
background = Color(0,0,0,0)
mainPanel.background = Color(0,0,0,0)
pack()
SettingsWindow.RCMPreviewInitialized = true
}
private fun updateComponents(){
val bgColor = Color.decode(SettingsWindow.bgColorField.text)
val titleColor = Color.decode(SettingsWindow.titleColorField.text)
val fontColor = Color.decode(SettingsWindow.titleFontColor.text)
val borderColor = Color.decode(SettingsWindow.borderColor.text)
val bgOpacity = SettingsWindow.bgOpacityField.text.toInt()
val titleOpacity = SettingsWindow.titleOpacityField.text.toInt()
val borderOpacity = SettingsWindow.borderOpacity.text.toInt()
chooseLabel.foreground = Color(fontColor.red, fontColor.green, fontColor.blue)
choosePanel.background = Color(titleColor.red, titleColor.green, titleColor.blue, titleOpacity)
optionsPanel.background = Color(bgColor.red, bgColor.green, bgColor.blue, bgOpacity)
abyssalWhipLabel.foreground = Color(174,98,47)
abyssalWhipLabel2.foreground = Color(174,98,47)
takePanel.background = Color(bgColor.red, bgColor.green, bgColor.blue, bgOpacity)
examinePanel.background = Color(bgColor.red, bgColor.green, bgColor.blue, bgOpacity)
walkPanel.background = Color(bgColor.red, bgColor.green, bgColor.blue, bgOpacity)
cancelPanel.background = Color(bgColor.red, bgColor.green, bgColor.blue, bgOpacity)
border = BorderFactory.createLineBorder(Color(borderColor.red, borderColor.green, borderColor.blue, borderOpacity))
if(SettingsWindow.rs3Border.isToggled){
mainPanel.border = border
optionsPanel.border = null
} else {
mainPanel.border = null
optionsPanel.border = border
}
}
fun getLabel(text: String): JLabel {
val l = JLabel(text)
l.foreground = Color(203,203,203)
return l
}
fun redraw(){
try {
updateComponents()
revalidate()
repaint()
} catch (ignored: Exception){}
}
}

View file

@ -11,6 +11,8 @@ import java.awt.Dimension
import java.awt.LayoutManager
import javax.imageio.ImageIO
import javax.swing.*
import javax.swing.event.DocumentEvent
import javax.swing.event.DocumentListener
object SettingsWindow : JFrame("Client Settings") {
@ -42,6 +44,7 @@ object SettingsWindow : JFrame("Client Settings") {
val slayerEnabled = Checkbox()
val closeLauncherOnLaunch = Checkbox()
val checkForLauncherUpdates = Checkbox()
var RCMPreviewInitialized = false
init {
isUndecorated = true
@ -63,6 +66,7 @@ object SettingsWindow : JFrame("Client Settings") {
val saveButton = ImgButton("/save_hi.png","/save_lo.png")
saveButton.onClick {
Json.save()
RCMPreview.isVisible = false
isVisible = false
}
saveButton.placeAt(width - 30, height - 30, 30, 30)
@ -71,6 +75,7 @@ object SettingsWindow : JFrame("Client Settings") {
val closeButton = ImgButton("/close_hi.png", "/close_dark.png")
closeButton.onClick {
isVisible = false
RCMPreview.isVisible = false
Json.parse()
}
closeButton.placeAt(width - 25, 5, 20, 20)
@ -194,6 +199,20 @@ object SettingsWindow : JFrame("Client Settings") {
field.minimumSize = Dimension(100,10)
field.maximumSize = Dimension(100,10)
field.preferredSize = Dimension(100,10)
field.document.addDocumentListener(object : DocumentListener {
override fun insertUpdate(p0: DocumentEvent?) {
if(RCMPreviewInitialized)
RCMPreview.redraw()
}
override fun removeUpdate(p0: DocumentEvent?) {
if(RCMPreviewInitialized)
RCMPreview.redraw()
}
override fun changedUpdate(p0: DocumentEvent?) {
if(RCMPreviewInitialized)
RCMPreview.redraw()
}
})
}
rs3BorderPanel.add(rs3BorderLabel, BorderLayout.WEST)
@ -231,6 +250,11 @@ object SettingsWindow : JFrame("Client Settings") {
borderOpacityPanel.add(borderOpacity, BorderLayout.EAST)
pane.add(borderOpacityPanel)
rs3Border.onClick {
rs3Border.isToggled = !rs3Border.isToggled
RCMPreview.redraw()
}
addTab(pane, button, getLabel("Rightclick Settings"))
}
@ -295,6 +319,7 @@ object SettingsWindow : JFrame("Client Settings") {
else {
tabs[i].isVisible = true
tabNotes[i].isVisible = true
RCMPreview.isVisible = i == 1
}
}
repaint()