mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-24 10:01:39 +07:00
EventHub removal - Removed 'MultiplayerGameDeleted' event
This commit is contained in:
parent
d07815242f
commit
7e7f8fc267
@ -112,7 +112,7 @@ class OnlineMultiplayer {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun updateSavesFromFiles() {
|
||||
private fun updateSavesFromFiles() {
|
||||
val saves = files.getMultiplayerSaves()
|
||||
|
||||
val removedSaves = savedGames.keys - saves.toSet()
|
||||
@ -152,12 +152,12 @@ class OnlineMultiplayer {
|
||||
addGame(gamePreview, saveFileName)
|
||||
}
|
||||
|
||||
private suspend fun addGame(newGame: GameInfo) {
|
||||
private fun addGame(newGame: GameInfo) {
|
||||
val newGamePreview = newGame.asPreview()
|
||||
addGame(newGamePreview, newGamePreview.gameId)
|
||||
}
|
||||
|
||||
private suspend fun addGame(preview: GameInfoPreview, saveFileName: String) {
|
||||
private fun addGame(preview: GameInfoPreview, saveFileName: String) {
|
||||
val fileHandle = files.saveGame(preview, saveFileName)
|
||||
return addGame(fileHandle, preview)
|
||||
}
|
||||
@ -271,8 +271,6 @@ class OnlineMultiplayer {
|
||||
|
||||
/**
|
||||
* Deletes the game from disk, does not delete it remotely.
|
||||
*
|
||||
* Fires [MultiplayerGameDeleted]
|
||||
*/
|
||||
fun deleteGame(multiplayerGame: OnlineMultiplayerGame) {
|
||||
deleteGame(multiplayerGame.fileHandle)
|
||||
@ -285,7 +283,6 @@ class OnlineMultiplayer {
|
||||
|
||||
debug("Deleting game %s with id %s", fileHandle.name(), game.preview?.gameId)
|
||||
savedGames.remove(game.fileHandle)
|
||||
Concurrency.runOnGLThread { EventBus.send(MultiplayerGameDeleted(game.name)) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,10 +49,3 @@ class MultiplayerGameNameChanged(
|
||||
override val name: String,
|
||||
val newName: String
|
||||
) : Event, HasMultiplayerGameName
|
||||
|
||||
/**
|
||||
* Gets sent when a game is deleted
|
||||
*/
|
||||
class MultiplayerGameDeleted(
|
||||
override val name: String
|
||||
) : Event, HasMultiplayerGameName
|
||||
|
@ -41,7 +41,7 @@ class EditMultiplayerGameInfoScreen(val multiplayerGame: OnlineMultiplayerGame)
|
||||
) {
|
||||
try {
|
||||
game.onlineMultiplayer.deleteGame(multiplayerGame)
|
||||
game.popScreen()
|
||||
(game.popScreen() as? MultiplayerScreen)?.onGameDeleted(multiplayerGame.name)
|
||||
} catch (ex: Exception) {
|
||||
Log.error("Could not delete game!", ex)
|
||||
ToastPopup("Could not delete game!", this)
|
||||
|
@ -10,7 +10,6 @@ import com.unciv.UncivGame
|
||||
import com.unciv.logic.GameInfoPreview
|
||||
import com.unciv.logic.event.EventBus
|
||||
import com.unciv.logic.multiplayer.HasMultiplayerGameName
|
||||
import com.unciv.logic.multiplayer.MultiplayerGameDeleted
|
||||
import com.unciv.logic.multiplayer.MultiplayerGameNameChanged
|
||||
import com.unciv.logic.multiplayer.MultiplayerGameUpdateEnded
|
||||
import com.unciv.logic.multiplayer.MultiplayerGameUpdateFailed
|
||||
@ -38,9 +37,6 @@ class GameList(
|
||||
events.receive(MultiplayerGameNameChanged::class) {
|
||||
update()
|
||||
}
|
||||
events.receive(MultiplayerGameDeleted::class) {
|
||||
update()
|
||||
}
|
||||
|
||||
update()
|
||||
}
|
||||
@ -101,11 +97,6 @@ private class GameDisplay(
|
||||
}
|
||||
}
|
||||
|
||||
fun changeName(newName: String) {
|
||||
gameName = newName
|
||||
gameButton.setText(newName)
|
||||
}
|
||||
|
||||
private fun updateTurnIndicator() {
|
||||
if (isPlayersTurn()) statusIndicators.addActor(turnIndicator)
|
||||
else turnIndicator.remove()
|
||||
|
@ -3,8 +3,6 @@ package com.unciv.ui.screens.multiplayerscreens
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.logic.event.EventBus
|
||||
import com.unciv.logic.multiplayer.MultiplayerGameDeleted
|
||||
import com.unciv.logic.multiplayer.OnlineMultiplayerGame
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.screens.pickerscreens.PickerScreen
|
||||
@ -40,8 +38,6 @@ class MultiplayerScreen : PickerScreen() {
|
||||
private val rightSideTable = createRightSideTable()
|
||||
val gameList = GameList(::selectGame)
|
||||
|
||||
private val events = EventBus.EventReceiver()
|
||||
|
||||
init {
|
||||
setDefaultCloseAction()
|
||||
|
||||
@ -53,16 +49,17 @@ class MultiplayerScreen : PickerScreen() {
|
||||
|
||||
setupRightSideButton()
|
||||
|
||||
events.receive(MultiplayerGameDeleted::class, { it.name == selectedGame?.name }) {
|
||||
unselectGame()
|
||||
}
|
||||
|
||||
game.onlineMultiplayer.requestUpdate()
|
||||
|
||||
pickerPane.bottomTable.background = skinStrings.getUiBackground("MultiplayerScreen/BottomTable", tintColor = skinStrings.skinConfig.clearColor)
|
||||
pickerPane.topTable.background = skinStrings.getUiBackground("MultiplayerScreen/TopTable", tintColor = skinStrings.skinConfig.clearColor)
|
||||
}
|
||||
|
||||
fun onGameDeleted(gameName:String){
|
||||
if (selectedGame?.name == gameName) unselectGame()
|
||||
gameList.update()
|
||||
}
|
||||
|
||||
private fun setupRightSideButton() {
|
||||
rightSideButton.setText("Join game".tr())
|
||||
rightSideButton.onClick { MultiplayerHelpers.loadMultiplayerGame(this, selectedGame!!) }
|
||||
|
Loading…
Reference in New Issue
Block a user