ResposePopup -> ToastPopup rename

This commit is contained in:
Yair Morgenstern 2020-10-24 22:03:25 +03:00
parent 8dde23aa38
commit b867e829a4
7 changed files with 19 additions and 21 deletions

View File

@ -6,7 +6,6 @@ import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.actions.Actions import com.badlogic.gdx.scenes.scene2d.actions.Actions
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.logic.GameInfo import com.unciv.logic.GameInfo
import com.unciv.logic.GameSaver import com.unciv.logic.GameSaver
import com.unciv.logic.GameStarter import com.unciv.logic.GameStarter
@ -165,16 +164,16 @@ class MainMenuScreen: CameraStageBaseScreen() {
private fun autoLoadGame() { private fun autoLoadGame() {
ResponsePopup("Loading...", this) ToastPopup("Loading...", this)
thread { // Load game from file to class on separate thread to avoid ANR... thread { // Load game from file to class on separate thread to avoid ANR...
val savedGame: GameInfo val savedGame: GameInfo
try { try {
savedGame = GameSaver.loadGameByName(autosave) savedGame = GameSaver.loadGameByName(autosave)
} catch (outOfMemory: OutOfMemoryError) { } catch (outOfMemory: OutOfMemoryError) {
ResponsePopup("Not enough memory on phone to load game!", this) ToastPopup("Not enough memory on phone to load game!", this)
return@thread return@thread
} catch (ex: Exception) { // silent fail if we can't read the autosave for any reason } catch (ex: Exception) { // silent fail if we can't read the autosave for any reason
ResponsePopup("Cannot resume game!", this) ToastPopup("Cannot resume game!", this)
return@thread return@thread
} }
@ -183,7 +182,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
game.loadGame(savedGame) game.loadGame(savedGame)
dispose() dispose()
} catch (outOfMemory: OutOfMemoryError) { } catch (outOfMemory: OutOfMemoryError) {
ResponsePopup("Not enough memory on phone to load game!", this) ToastPopup("Not enough memory on phone to load game!", this)
} }
} }

View File

@ -82,13 +82,13 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
//rightTable Setup //rightTable Setup
copyUserIdButton.onClick { copyUserIdButton.onClick {
Gdx.app.clipboard.contents = game.settings.userId Gdx.app.clipboard.contents = game.settings.userId
ResponsePopup("UserID copied to clipboard".tr(), this) ToastPopup("UserID copied to clipboard".tr(), this)
} }
rightSideTable.add(copyUserIdButton).padBottom(30f).row() rightSideTable.add(copyUserIdButton).padBottom(30f).row()
copyGameIdButton.onClick { copyGameIdButton.onClick {
Gdx.app.clipboard.contents = selectedGame.gameId Gdx.app.clipboard.contents = selectedGame.gameId
ResponsePopup("GameID copied to clipboard".tr(), this) ToastPopup("GameID copied to clipboard".tr(), this)
} }
rightSideTable.add(copyGameIdButton).row() rightSideTable.add(copyGameIdButton).row()
@ -132,7 +132,7 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
} }
if (gameIsAlreadySavedAsMultiplayer(gameId)) { if (gameIsAlreadySavedAsMultiplayer(gameId)) {
ResponsePopup("Game is already added".tr(), this) ToastPopup("Game is already added".tr(), this)
return return
} }
@ -235,7 +235,7 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
leftSubTable.add(gameTable).row() leftSubTable.add(gameTable).row()
} catch (ex: Exception) { } catch (ex: Exception) {
//skipping one save is not fatal //skipping one save is not fatal
ResponsePopup("Could not refresh!".tr(), this) ToastPopup("Could not refresh!".tr(), this)
continue continue
} }
} }
@ -260,7 +260,7 @@ class MultiplayerScreen(previousScreen: CameraStageBaseScreen) : PickerScreen()
//skipping one is not fatal //skipping one is not fatal
//Trying to use as many prev. used strings as possible //Trying to use as many prev. used strings as possible
Gdx.app.postRunnable { Gdx.app.postRunnable {
ResponsePopup("Could not download game!".tr() + " ${multiplayerGameList.getValue(gameId)}", this) ToastPopup("Could not download game!".tr() + " ${multiplayerGameList.getValue(gameId)}", this)
} }
continue continue
} }
@ -344,7 +344,7 @@ class EditMultiplayerGameInfoScreen(game: GameInfo, gameName: String, backScreen
backScreen.reloadGameListUI() backScreen.reloadGameListUI()
}catch (ex: Exception) { }catch (ex: Exception) {
askPopup.close() askPopup.close()
ResponsePopup("Could not delete game!".tr(), this) ToastPopup("Could not delete game!".tr(), this)
} }
} }
askPopup.addButton("No"){ askPopup.addButton("No"){
@ -415,7 +415,7 @@ class AddMultiplayerGameScreen(backScreen: MultiplayerScreen) : PickerScreen(){
try { try {
UUID.fromString(IdChecker.checkAndReturnGameUuid(gameIDTextField.text)) UUID.fromString(IdChecker.checkAndReturnGameUuid(gameIDTextField.text))
}catch (ex: Exception){ }catch (ex: Exception){
ResponsePopup("Invalid game ID!".tr(), this) ToastPopup("Invalid game ID!".tr(), this)
return@onClick return@onClick
} }

View File

@ -95,7 +95,7 @@ class MapEditorMenuPopup(var mapEditorScreen: MapEditorScreen): Popup(mapEditorS
} }
close() close()
Gdx.app.postRunnable { Gdx.app.postRunnable {
ResponsePopup("Map saved", mapEditorScreen) // todo - add this text to translations ToastPopup("Map saved", mapEditorScreen) // todo - add this text to translations
} }
} catch (ex: Exception) { } catch (ex: Exception) {
ex.printStackTrace() ex.printStackTrace()

View File

@ -137,7 +137,7 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe
// Save gameId to clipboard because you have to do it anyway. // Save gameId to clipboard because you have to do it anyway.
Gdx.app.clipboard.contents = newGame!!.gameId Gdx.app.clipboard.contents = newGame!!.gameId
// Popup to notify the User that the gameID got copied to the clipboard // Popup to notify the User that the gameID got copied to the clipboard
Gdx.app.postRunnable { ResponsePopup("gameID copied to clipboard".tr(), UncivGame.Current.worldScreen, 2500) } Gdx.app.postRunnable { ToastPopup("gameID copied to clipboard".tr(), UncivGame.Current.worldScreen, 2500) }
} catch (ex: Exception) { } catch (ex: Exception) {
Gdx.app.postRunnable { Gdx.app.postRunnable {
val cantUploadNewGamePopup = Popup(this) val cantUploadNewGamePopup = Popup(this)

View File

@ -33,7 +33,7 @@ class ModManagementScreen: PickerScreen() {
} catch (ex: Exception) { } catch (ex: Exception) {
Gdx.app.postRunnable { Gdx.app.postRunnable {
ResponsePopup("Could not download mod list", this) ToastPopup("Could not download mod list", this)
} }
return@thread return@thread
} }
@ -88,13 +88,13 @@ class ModManagementScreen: PickerScreen() {
Github.downloadAndExtract("$gitRepoUrl/archive/master.zip", Github.downloadAndExtract("$gitRepoUrl/archive/master.zip",
Gdx.files.local("mods")) Gdx.files.local("mods"))
Gdx.app.postRunnable { Gdx.app.postRunnable {
ResponsePopup("Downloaded!", this) ToastPopup("Downloaded!", this)
RulesetCache.loadRulesets() RulesetCache.loadRulesets()
refresh() refresh()
} }
} catch (ex:Exception){ } catch (ex:Exception){
Gdx.app.postRunnable { Gdx.app.postRunnable {
ResponsePopup("Could not download mod", this) ToastPopup("Could not download mod", this)
} }
} }
finally { finally {

View File

@ -8,7 +8,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.PopupAlert
import com.unciv.logic.civilization.TechManager import com.unciv.logic.civilization.TechManager
import com.unciv.models.UncivSound import com.unciv.models.UncivSound
import com.unciv.models.ruleset.tech.Technology import com.unciv.models.ruleset.tech.Technology
@ -175,13 +174,13 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
for (tech in civInfo.gameInfo.ruleSet.technologies.values) { for (tech in civInfo.gameInfo.ruleSet.technologies.values) {
if (!techNameToButton.containsKey(tech.name)) { if (!techNameToButton.containsKey(tech.name)) {
ResponsePopup("Tech ${tech.name} appears to be missing - perhaps two techs have the same row & column", this) ToastPopup("Tech ${tech.name} appears to be missing - perhaps two techs have the same row & column", this)
continue continue
} }
val techButton = techNameToButton[tech.name]!! val techButton = techNameToButton[tech.name]!!
for (prerequisite in tech.prerequisites) { for (prerequisite in tech.prerequisites) {
if (!techNameToButton.containsKey(prerequisite)) { if (!techNameToButton.containsKey(prerequisite)) {
ResponsePopup("Tech $prerequisite. prerequisite of ${tech.name}, appears to be missing - perhaps two techs have the same row & column", this) ToastPopup("Tech $prerequisite. prerequisite of ${tech.name}, appears to be missing - perhaps two techs have the same row & column", this)
continue continue
} }
val prerequisiteButton = techNameToButton[prerequisite]!! val prerequisiteButton = techNameToButton[prerequisite]!!

View File

@ -4,7 +4,7 @@ import kotlin.concurrent.thread
//Its a popUp which will close itself after a given amount of time //Its a popUp which will close itself after a given amount of time
//Standard time is one second (in milliseconds) //Standard time is one second (in milliseconds)
class ResponsePopup (message: String, screen: CameraStageBaseScreen, time: Long = 1000) : Popup(screen){ class ToastPopup (message: String, screen: CameraStageBaseScreen, time: Long = 1000) : Popup(screen){
private val visibilityTime = time private val visibilityTime = time
init { init {
addGoodSizedLabel(message) addGoodSizedLabel(message)