-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor menu notification, added TCTT message
- Loading branch information
1 parent
ade4f5e
commit 0cdfc73
Showing
2 changed files
with
60 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
core/src/main/kotlin/com/bombbird/terminalcontrol2/ui/MenuNotificationManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.bombbird.terminalcontrol2.ui | ||
|
||
import com.badlogic.gdx.Gdx | ||
import com.badlogic.gdx.scenes.scene2d.Stage | ||
import com.badlogic.gdx.utils.Align | ||
import com.bombbird.terminalcontrol2.global.PREFS_FILE_NAME | ||
import ktx.collections.GdxArray | ||
|
||
class MenuNotificationManager(private val stage: Stage) { | ||
private class MenuNotification(val prefKey: String, val title: String, val message: String, val height: Int, val width: Int) | ||
|
||
/** | ||
* Notification array, added in order of highest to lowest priority (i.e. if a notification is shown, all | ||
* notifications added after will not be shown even if it has not been shown ever before to the user | ||
*/ | ||
private val notifications = GdxArray<MenuNotification>().apply { | ||
add( | ||
MenuNotification("beta-welcome-msg-shown", "Welcome to the beta!", "Thank you for" + | ||
" joining the beta! This is a very early version of the game, so there are likely to be bugs and" + | ||
" issues. Please report them by emailing bombbirddev@gmail.com, or by clicking the \"Report Bug\"" + | ||
" button in the Pause screen or info menu. Please include as much information as possible," + | ||
" including the build version (in info menu), expected behaviour and steps to reproduce the bug." + | ||
" Screenshots and video recordings are very helpful too.\n\nCurrently, there are 3 default airports" + | ||
" for testing, and more will be added as testing goes on. We hope you will enjoy the new" + | ||
" multiplayer functionality, have fun!", 800, 1800) | ||
) | ||
add( | ||
MenuNotification("tctt-added", "New airport available!", "TCTT has been added to the" + | ||
" game. Custom datatag layouts have also been enabled: Settings => Datatag => Datatag style. As" + | ||
" always, please report bugs encountered by clicking the \"Report Bug\" button in the Pause" + | ||
" screen, or from the info menu. We hope you will enjoy the new map, have fun!", 600, 1400) | ||
) | ||
} | ||
|
||
/** Shows the message that has not been shown before with the highest priority */ | ||
fun showMessages() { | ||
val prefs = Gdx.app.getPreferences(PREFS_FILE_NAME) | ||
|
||
for (i in 0 until notifications.size) { | ||
val notif = notifications[i] | ||
if (!prefs.getBoolean(notif.prefKey, false)) { | ||
// Show welcome message | ||
CustomDialog(notif.title, notif.message, "", "Ok!", height = notif.height, | ||
width = notif.width, fontAlign = Align.left).show(stage) | ||
break | ||
} | ||
} | ||
|
||
// All messages are marked as shown | ||
for (i in 0 until notifications.size) { | ||
prefs.putBoolean(notifications[i].prefKey, true) | ||
} | ||
prefs.flush() | ||
} | ||
} |