@@ -8,6 +8,7 @@ import com.github.ilovegamecoding.intellijcodexp.models.CodeXPConfiguration
8
8
import com.github.ilovegamecoding.intellijcodexp.models.CodeXPDialog
9
9
import com.github.ilovegamecoding.intellijcodexp.models.CodeXPLevel
10
10
import com.github.ilovegamecoding.intellijcodexp.services.CodeXPService
11
+ import com.github.ilovegamecoding.intellijcodexp.utils.StringUtil
11
12
import com.intellij.openapi.actionSystem.CommonDataKeys
12
13
import com.intellij.openapi.actionSystem.DataContext
13
14
import com.intellij.openapi.application.ApplicationManager
@@ -19,7 +20,6 @@ import java.awt.Color
19
20
import java.awt.Dimension
20
21
import java.awt.Font
21
22
import java.awt.Point
22
- import java.awt.event.ActionListener
23
23
import java.awt.event.MouseAdapter
24
24
import java.awt.event.MouseMotionAdapter
25
25
import javax.swing.*
@@ -43,19 +43,35 @@ object CodeXPUIManager : CodeXPEventListener, CodeXPListener {
43
43
private var currentXPGainValue: Int = 0
44
44
45
45
/* *
46
- * The message bus for the plugin
46
+ * The message bus for the plugin.
47
47
*/
48
48
private val messageBus = ApplicationManager .getApplication().messageBus
49
49
50
50
/* *
51
- * The connection to the message bus
51
+ * The connection to the message bus.
52
52
*/
53
53
private val connection = messageBus.connect()
54
54
55
+ /* *
56
+ * The IDE frame.
57
+ */
55
58
private lateinit var ide: JLayeredPane
59
+
60
+ /* *
61
+ * Dialog area for displaying dialogs in the IDE.
62
+ */
56
63
private lateinit var dialogArea: JPanel
64
+
65
+ /* *
66
+ * Timers for each dialog.
67
+ */
57
68
private val dialogTimers: MutableMap <CodeXPDialog , Timer > = mutableMapOf ()
58
69
70
+ /* *
71
+ * Dialog duration.
72
+ */
73
+ private val dialogDuration: Int = 4000
74
+
59
75
init {
60
76
connection.subscribe(CodeXPEventListener .CODEXP_EVENT , this )
61
77
connection.subscribe(CodeXPListener .CODEXP , this )
@@ -73,8 +89,8 @@ object CodeXPUIManager : CodeXPEventListener, CodeXPListener {
73
89
showDialog(
74
90
CodeXPDialog .createDialog(
75
91
" Level Up!" ,
76
- " Congratulations! You have reached level ${levelInfo.level} !" ,
77
- " XP to next level: ${levelInfo.totalXPForNextLevel} xp"
92
+ " Congratulations! You are now level ${StringUtil .numberToStringWithCommas( levelInfo.level.toLong()) } !" ,
93
+ " XP to next level: ${StringUtil .numberToStringWithCommas( levelInfo.totalXPForNextLevel)} xp"
78
94
)
79
95
)
80
96
}
@@ -87,8 +103,8 @@ object CodeXPUIManager : CodeXPEventListener, CodeXPListener {
87
103
showDialog(
88
104
CodeXPDialog .createDialog(
89
105
" Challenge Completed!" ,
90
- " Congratulations! You have completed ' ${challenge.name} ' !" ,
91
- " XP gained : ${challenge.rewardXP} xp"
106
+ " Congratulations! You have completed ${challenge.name.lowercase()} !" ,
107
+ " XP earned : ${StringUtil .numberToStringWithCommas( challenge.rewardXP)} xp"
92
108
)
93
109
)
94
110
}
@@ -247,7 +263,7 @@ object CodeXPUIManager : CodeXPEventListener, CodeXPListener {
247
263
* Show the progress window for 3 seconds.
248
264
*/
249
265
private fun showDialog (dialog : CodeXPDialog ) {
250
- dialogTimers[dialog] = Timer (3000 , ActionListener { hideDialog(dialog) })
266
+ dialogTimers[dialog] = Timer (dialogDuration) { hideDialog(dialog) }
251
267
dialogTimers[dialog]?.start()
252
268
dialog.show()
253
269
0 commit comments