Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
Added About dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Sep 18, 2016
1 parent a155248 commit d4109c7
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 37 deletions.
5 changes: 4 additions & 1 deletion resources/com/soywiz/vitaorganizer/Texts.properties
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ UNSAFE_NOT_ACCEPTED=Not accepted installing game with extended permissions
WARNING_UNSAFE=Game %id% requires extended permissions.\nAre you sure you want to install it. It could damage your device?
VITASHELL_INSTALL=Now use VitaShell to install\n%vpkPath%\n\nAfter that active ftp again and use this program to Send Data to PSVita
METHOD1_INFO=Old method: 2 steps - Compatible with all ftp and VitaShell 0.9.1 and lower
METHOD2_INFO=New method: 1 single step - Requires VitaShell 0.9.5 and up
METHOD2_INFO=New method: 1 single step - Requires VitaShell 0.9.5 and up
ABOUT_TITLE=About
ABOUT_PROGRAMMING=Programming:
ABOUT_TRANSLATIONS=Translations:
3 changes: 3 additions & 0 deletions resources/com/soywiz/vitaorganizer/Texts_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ WARNING_UNSAFE=Game %id% requires extended permissions.\nAre you sure you want t
VITASHELL_INSTALL=Now use VitaShell to install\n%vpkPath%\n\nAfter that active ftp again and use this program to Send Data to PSVita
METHOD1_INFO=Old method: 2 steps - Compatible with all ftp and VitaShell 0.9.1 and lower
METHOD2_INFO=New method: 1 single step - Requires VitaShell 0.9.5 and up
ABOUT_TITLE=About
ABOUT_PROGRAMMING=Programming:
ABOUT_TRANSLATIONS=Translations:
3 changes: 3 additions & 0 deletions resources/com/soywiz/vitaorganizer/Texts_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ WARNING_UNSAFE=El juego %id% requiere permisos extendidos.\n
VITASHELL_INSTALL=Ahora usa VitaShell para instalar:\n%vpkPath%\n\nTras eso activa nuevo el FTP y usa este mismo programa con la opción: Mandar datos a la psvita
METHOD1_INFO=Método antigüo: 2 pasos - Compatible con todos los ftp y con VitaShell 0.9.1 o inferior
METHOD2_INFO=Método nuevo: 1 solo paso - Requiere VitaShell 0.9.5 o posterior
ABOUT_TITLE=About
ABOUT_PROGRAMMING=Programming:
ABOUT_TRANSLATIONS=Translations:
3 changes: 3 additions & 0 deletions resources/com/soywiz/vitaorganizer/Texts_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ WARNING_UNSAFE=Game %id% requires extended permissions.\nAre you sure you want t
VITASHELL_INSTALL=Now use VitaShell to install\n%vpkPath%\n\nAfter that active ftp again and use this program to Send Data to PSVita
METHOD1_INFO=Old method: 2 steps - Compatible with all ftp and VitaShell 0.9.1 and lower
METHOD2_INFO=New method: 1 single step - Requires VitaShell 0.9.5 and up
ABOUT_TITLE=About
ABOUT_PROGRAMMING=Programming:
ABOUT_TRANSLATIONS=Translations:
3 changes: 3 additions & 0 deletions resources/com/soywiz/vitaorganizer/Texts_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ WARNING_UNSAFE=Game %id% requires extended permissions.\nAre you sure you want t
VITASHELL_INSTALL=Now use VitaShell to install\n%vpkPath%\n\nAfter that active ftp again and use this program to Send Data to PSVita
METHOD1_INFO=Old method: 2 steps - Compatible with all ftp and VitaShell 0.9.1 and lower
METHOD2_INFO=New method: 1 single step - Requires VitaShell 0.9.5 and up
ABOUT_TITLE=About
ABOUT_PROGRAMMING=Programming:
ABOUT_TRANSLATIONS=Translations:
3 changes: 3 additions & 0 deletions resources/com/soywiz/vitaorganizer/Texts_nb.properties
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ WARNING_UNSAFE=Game %id% requires extended permissions.\nAre you sure you want t
VITASHELL_INSTALL=Now use VitaShell to install\n%vpkPath%\n\nAfter that active ftp again and use this program to Send Data to PSVita
METHOD1_INFO=Old method: 2 steps - Compatible with all ftp and VitaShell 0.9.1 and lower
METHOD2_INFO=New method: 1 single step - Requires VitaShell 0.9.5 and up
ABOUT_TITLE=About
ABOUT_PROGRAMMING=Programming:
ABOUT_TRANSLATIONS=Translations:
3 changes: 3 additions & 0 deletions resources/com/soywiz/vitaorganizer/Texts_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ WARNING_UNSAFE=Game %id% wymaga rozszerszonych uprawnień.\nCzy na pewno chcesz
VITASHELL_INSTALL=Użyj VitaShell aby zainstalować\n%vpkPath%\n\nPóźniej włącz znów FTP i użyj tego programu by przesłać dane gry.
METHOD1_INFO=Old method: 2 steps - Compatible with all ftp and VitaShell 0.9.1 and lower
METHOD2_INFO=New method: 1 single step - Requires VitaShell 0.9.5 and up
ABOUT_TITLE=About
ABOUT_PROGRAMMING=Programming:
ABOUT_TRANSLATIONS=Translations:
5 changes: 4 additions & 1 deletion resources/com/soywiz/vitaorganizer/Texts_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ UNSAFE_NOT_ACCEPTED=Not accepted installing game with extended permissions
WARNING_UNSAFE=Game %id% requires extended permissions.\nAre you sure you want to install it. It could damage your device?
VITASHELL_INSTALL=Now use VitaShell to install\n%vpkPath%\n\nAfter that active ftp again and use this program to Send Data to PSVita
METHOD1_INFO=Old method: 2 steps - Compatible with all ftp and VitaShell 0.9.1 and lower
METHOD2_INFO=New method: 1 single step - Requires VitaShell 0.9.5 and up
METHOD2_INFO=New method: 1 single step - Requires VitaShell 0.9.5 and up
ABOUT_TITLE=About
ABOUT_PROGRAMMING=Programming:
ABOUT_TRANSLATIONS=Translations:
3 changes: 3 additions & 0 deletions resources/com/soywiz/vitaorganizer/Texts_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ WARNING_UNSAFE=Game %id% requires extended permissions.\nAre you sure you want t
VITASHELL_INSTALL=Now use VitaShell to install\n%vpkPath%\n\nAfter that active ftp again and use this program to Send Data to PSVita
METHOD1_INFO=Old method: 2 steps - Compatible with all ftp and VitaShell 0.9.1 and lower
METHOD2_INFO=New method: 1 single step - Requires VitaShell 0.9.5 and up
ABOUT_TITLE=About
ABOUT_PROGRAMMING=Programming:
ABOUT_TRANSLATIONS=Translations:
31 changes: 3 additions & 28 deletions src/com/soywiz/vitaorganizer/VitaOrganizer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ package com.soywiz.vitaorganizer

import com.soywiz.util.OS
import com.soywiz.util.open2
import com.soywiz.vitaorganizer.ext.action
import com.soywiz.vitaorganizer.ext.getResourceString
import com.soywiz.vitaorganizer.ext.getResourceURL
import com.soywiz.vitaorganizer.ext.showDialog
import com.soywiz.vitaorganizer.ext.*
import com.soywiz.vitaorganizer.popups.AboutFrame
import com.soywiz.vitaorganizer.popups.KeyValueViewerFrame
import com.soywiz.vitaorganizer.tasks.*
import java.awt.*
import java.awt.event.*
import java.io.File
import java.net.URI
import java.net.URISyntaxException
import java.net.URL
import java.util.*
import javax.imageio.ImageIO
Expand Down Expand Up @@ -305,7 +301,6 @@ object VitaOrganizer : JPanel(BorderLayout()), StatusUpdater {
}



val connectButton = object : JButton(connectText) {
val button = this

Expand Down Expand Up @@ -445,28 +440,8 @@ object VitaOrganizer : JPanel(BorderLayout()), StatusUpdater {
//frame.focusOwner = filterTextField
}

fun openWebpage(uri: URI) {
val desktop = if (Desktop.isDesktopSupported()) Desktop.getDesktop() else null
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(uri)
} catch (e: Exception) {
e.printStackTrace()
}

}
}

fun openWebpage(url: URL) {
try {
openWebpage(url.toURI())
} catch (e: URISyntaxException) {
e.printStackTrace()
}
}

fun openAbout() {

frame.showDialog(AboutFrame())
}

fun checkForUpdates() {
Expand Down
11 changes: 5 additions & 6 deletions src/com/soywiz/vitaorganizer/ext/ComponentExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ package com.soywiz.vitaorganizer.ext

import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
import javax.swing.JButton
import javax.swing.JDialog
import javax.swing.JFrame
import javax.swing.JMenuItem
import javax.swing.*

fun JFrame.showDialog(modal: JFrame) {

val dialog = JDialog(this, modal.title, true)
dialog.contentPane.add(modal.components.first())
dialog.pack()
dialog.setLocationRelativeTo(this)
dialog.isResizable = modal.isResizable
dialog.isVisible = true
//frame.isEnabled = false

Expand All @@ -27,11 +24,13 @@ fun JMenuItem.action(callback: () -> Unit): JMenuItem {
return this
}

fun JButton.action(callback: () -> Unit): JButton {
fun <T: JComponent> T.onClick(callback: () -> Unit): T {
addMouseListener(object: MouseAdapter() {
override fun mouseClicked(e: MouseEvent?) {
callback()
}
})
return this
}

fun JButton.action(callback: () -> Unit): JButton = onClick(callback)
23 changes: 23 additions & 0 deletions src/com/soywiz/vitaorganizer/ext/openWebpage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.soywiz.vitaorganizer.ext

import java.awt.Desktop
import java.net.URI
import java.net.URISyntaxException
import java.net.URL

fun openWebpage(uri: URI) {
val desktop = if (Desktop.isDesktopSupported()) Desktop.getDesktop() else null
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(uri)
} catch (e: Exception) {
e.printStackTrace()
}

}
}

fun openWebpage(url: URL) = openWebpage(url.toURI())

fun openWebpage(url: String) = openWebpage(URL(url).toURI())

54 changes: 54 additions & 0 deletions src/com/soywiz/vitaorganizer/popups/AboutFrame.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.soywiz.vitaorganizer.popups

import com.soywiz.vitaorganizer.Texts
import com.soywiz.vitaorganizer.VitaOrganizer
import com.soywiz.vitaorganizer.ext.onClick
import com.soywiz.vitaorganizer.ext.openWebpage
import java.awt.*
import javax.swing.*

class AboutFrame() : JFrame(Texts.format("ABOUT_TITLE")) {
fun JLinkLabel(text: String, link: String, extra: String = ""): JLabel {
return JLabel("""<html><a href="$link">$text</a>$extra</html>""").apply {
cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
}.onClick {
openWebpage(link)
}
}

fun Contibutor(text: String, link: String, role: String = ""): JComponent {
return JLinkLabel(text, link, if (role.isNotEmpty()) " - $role" else "")
}

init {
isResizable = false
add(JPanel(BorderLayout()).apply {
add(JLabel("VitaOrganizer ${VitaOrganizer.currentVersion}", SwingConstants.CENTER).apply {
font = Font("Arial", Font.BOLD, 24)
}, BorderLayout.NORTH)
add(object : JPanel() {
override fun getInsets(): Insets {
return Insets(10, 10, 10, 10)
}

init {
layout = BoxLayout(this, BoxLayout.Y_AXIS)

add(JLabel(Texts.format("ABOUT_PROGRAMMING")))
add(Contibutor("soywiz", "http://soywiz.com/"))
add(Contibutor("luckylucks", "https://github.com/luckylucks/"))
add(JLabel(Texts.format("ABOUT_TRANSLATIONS")))
add(Contibutor("paweloszu", "https://github.com/paweloszu", "Polish"))
add(Contibutor("RijjiResa", "https://github.com/RijjiResa", "Norwegian"))
add(Contibutor("pvc1", "https://github.com/pvc1", "Russian"))
add(Contibutor("Mdslino", "https://github.com/Mdslino", "Brazilian"))
add(Contibutor("gordon0001", "https://github.com/gordon0001", "German"))
add(Contibutor("charlyzard", "https://github.com/charlyzard", "Spanish"))
add(Contibutor("anthologist", "https://github.com/anthologist", "Italian"))
add(Contibutor("adeldk", "https://github.com/adeldk", "French"))
}
})
preferredSize = Dimension(500, 400)
})
}
}
3 changes: 2 additions & 1 deletion src/com/soywiz/vitaorganizer/tasks/CheckForUpdatesTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.soywiz.vitaorganizer.tasks

import com.soywiz.vitaorganizer.Texts
import com.soywiz.vitaorganizer.VitaOrganizer
import com.soywiz.vitaorganizer.ext.openWebpage
import java.net.URL
import javax.swing.JOptionPane

Expand All @@ -26,7 +27,7 @@ class CheckForUpdatesTask : VitaTask() {
JOptionPane.YES_NO_OPTION
);
if (result == JOptionPane.OK_OPTION) {
VitaOrganizer.openWebpage(URL(lastVersionUrl))
openWebpage(URL(lastVersionUrl))
}
}
println(parts)
Expand Down

0 comments on commit d4109c7

Please sign in to comment.