mirror of
https://gitlab.com/2009scape/09launcher.git
synced 2025-12-09 16:45:54 -07:00
Initial push
This commit is contained in:
commit
dee36e793b
27 changed files with 554 additions and 0 deletions
153
src/main/kotlin/MainWindow.kt
Normal file
153
src/main/kotlin/MainWindow.kt
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
import java.awt.Desktop
|
||||
import java.awt.Dimension
|
||||
import java.awt.Image
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import javax.imageio.ImageIO
|
||||
import javax.swing.*
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
|
||||
object MainWindow : JFrame("2009scape Launcher") {
|
||||
|
||||
val loadingLabel = JLabel("Press Launch to play 2009scape!")
|
||||
val loadingBar = JLabel(ImageIcon(javaClass.getResource("/loadingBar.png")))
|
||||
val playButton = ImgButton("/playButton.png","/playButtonDisabled.png", false)
|
||||
|
||||
|
||||
init {
|
||||
defaultCloseOperation = EXIT_ON_CLOSE
|
||||
preferredSize = Dimension(1366,768)
|
||||
size = Dimension(800,500)
|
||||
val tileBG = BackgroundPanel(ImageIO.read(javaClass.getResource("/tile.png")))
|
||||
contentPane = tileBG
|
||||
layout = null
|
||||
|
||||
constructTopBar()
|
||||
val updatePane = LatestUpdatePane("https://2009scape.org/services/m=news/archives/2021-07-12.html")
|
||||
updatePane.placeAt(4, 45, MainWindow.width - 8, MainWindow.height - 85)
|
||||
add(updatePane)
|
||||
addPlayButton()
|
||||
|
||||
setLocationRelativeTo(null)
|
||||
isUndecorated = true
|
||||
isVisible = true
|
||||
}
|
||||
|
||||
private fun constructTopBar(){
|
||||
val panel = BackgroundPanel(ImageIO.read(javaClass.getResource("/topBar.png")))
|
||||
panel.placeAt(0,0,MainWindow.width, 40)
|
||||
addCloseButton(panel)
|
||||
addNewsButton(panel)
|
||||
addBugReportButton(panel)
|
||||
addHighscoreButton(panel)
|
||||
addDiscordButton(panel)
|
||||
addLogo(panel)
|
||||
add(panel)
|
||||
}
|
||||
|
||||
private fun addPlayButton(){
|
||||
val loadingFrame = JLabel(ImageIcon(javaClass.getResource("/loadingFrame.png")))
|
||||
playButton.isEnabled = true
|
||||
playButton.onClick {
|
||||
if(Updater.checkUpdate()) Updater.runUpdate()
|
||||
else Runtime.getRuntime().exec("java -jar " + Settings.SAVE_DIR + File.separator + Settings.SAVE_NAME, null, File(System.getProperty("user.home"))).also { exitProcess(0) }
|
||||
}
|
||||
loadingFrame.placeAt(96,MainWindow.height - 35, 704, 35)
|
||||
loadingBar.placeAt(103, MainWindow.height - 33, 695, 31)
|
||||
playButton.placeAt(0,MainWindow.height - 35,100,35)
|
||||
loadingLabel.placeAt(300, MainWindow.height - 24, 300, 15)
|
||||
add(loadingLabel)
|
||||
add(loadingBar)
|
||||
add(loadingFrame)
|
||||
add(playButton)
|
||||
}
|
||||
|
||||
private fun addNewsButton(panel: JPanel){
|
||||
val label = BackgroundLabel("/messageBox.png", "Latest<br/>Update")
|
||||
label.placeAt(0, 40, 90, 56)
|
||||
add(label)
|
||||
|
||||
val button = ImgButton("/news.png")
|
||||
button.onMouseEnter { label.isVisible = true }
|
||||
button.onMouseExit { label.isVisible = false }
|
||||
button.onClick {
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
Desktop.getDesktop().browse(URI("https://2009scape.org/services/m=news/archives/2021-07-12.html"));
|
||||
}
|
||||
}
|
||||
button.placeAt(5,4,35,35)
|
||||
panel.add(button)
|
||||
}
|
||||
|
||||
private fun addBugReportButton(panel: JPanel){
|
||||
val label = BackgroundLabel("/messageBox.png", "Report<br/>Bug")
|
||||
label.placeAt(25, 40, 90, 56)
|
||||
add(label)
|
||||
|
||||
val button = ImgButton("/reportBug.png")
|
||||
button.onMouseEnter { label.isVisible = true }
|
||||
button.onMouseExit { label.isVisible = false }
|
||||
button.onClick {
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
Desktop.getDesktop().browse(URI("https://gitlab.com/2009scape/2009scape/-/issues"));
|
||||
}
|
||||
}
|
||||
button.placeAt(50, 4, 35, 35)
|
||||
panel.add(button)
|
||||
}
|
||||
|
||||
private fun addHighscoreButton(panel: JPanel){
|
||||
val label = BackgroundLabel("/messageBox.png", "Leader<br/>Boards")
|
||||
label.placeAt(70, 40, 90, 56)
|
||||
add(label)
|
||||
|
||||
val button = ImgButton("/highScores.png")
|
||||
button.onMouseEnter { label.isVisible = true }
|
||||
button.onMouseExit { label.isVisible = false }
|
||||
button.onClick {
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
Desktop.getDesktop().browse(URI("https://2009scape.org/services/m=hiscore/hiscores.html?world=2"));
|
||||
}
|
||||
}
|
||||
button.placeAt(90, 2, 38, 38)
|
||||
panel.add(button)
|
||||
}
|
||||
|
||||
private fun addDiscordButton(panel: JPanel){
|
||||
val label = BackgroundLabel("/messageBox.png", "Join<br/>Discord")
|
||||
label.placeAt(110, 40, 90, 56)
|
||||
add(label)
|
||||
|
||||
val button = ImgButton("/joinDiscord.png")
|
||||
button.onMouseEnter { label.isVisible = true }
|
||||
button.onMouseExit { label.isVisible = false }
|
||||
button.onClick {
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
Desktop.getDesktop().browse(URI("https://discord.gg/YY7WSttN7H"));
|
||||
}
|
||||
}
|
||||
button.placeAt(135, 4, 35, 35)
|
||||
panel.add(button)
|
||||
}
|
||||
|
||||
private fun addCloseButton(panel: BackgroundPanel){
|
||||
val button = ImgButton("/close_hi.png","/close_dark.png")
|
||||
button.onClick { exitProcess(0) }
|
||||
button.placeAt(panel.width - 35, 7, 25, 25)
|
||||
button.isOpaque = false
|
||||
panel.add(button)
|
||||
}
|
||||
|
||||
private fun addLogo(panel: JPanel){
|
||||
val logo = JLabel(ImageIcon(javaClass.getResource("/logo.png")))
|
||||
logo.icon = ImageIcon((logo.icon as ImageIcon).image.getScaledInstance(179,40, Image.SCALE_SMOOTH))
|
||||
logo.placeAt(311, 0, 179, 40)
|
||||
panel.add(logo)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue