eros: show message if no account selected

This commit is contained in:
Bixilon 2021-07-28 23:19:24 +02:00
parent 5bd0c9b7c2
commit 1588f135e6
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
5 changed files with 43 additions and 4 deletions

View File

@ -20,7 +20,9 @@ import de.bixilon.minosoft.data.accounts.Account
import de.bixilon.minosoft.gui.eros.controller.JavaFXWindowController
import de.bixilon.minosoft.gui.eros.main.play.PlayMainController
import de.bixilon.minosoft.gui.eros.modding.invoker.JavaFXEventInvoker
import de.bixilon.minosoft.gui.eros.util.JavaFXAccountUtil.avatar
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.ctext
import de.bixilon.minosoft.modding.event.events.account.AccountSelectEvent
import de.bixilon.minosoft.modding.event.master.GlobalEventMaster
import de.bixilon.minosoft.util.GitInfo
@ -87,8 +89,8 @@ class MainErosController : JavaFXWindowController() {
GlobalEventMaster.registerEvent(JavaFXEventInvoker.of<AccountSelectEvent> {
accountImageFX.image = JavaFXUtil.MINOSOFT_LOGO // ToDo
accountNameFX.text = it.account?.username
accountImageFX.image = it.account?.avatar
accountNameFX.ctext = it.account?.username ?: NO_ACCOUNT_SELECTED
})
}
@ -117,4 +119,8 @@ class MainErosController : JavaFXWindowController() {
onSuccess(account)
}
}
companion object {
private val NO_ACCOUNT_SELECTED = "minosoft:main.account.no_account_selected".asResourceLocation()
}
}

View File

@ -25,7 +25,7 @@ import org.kordamp.ikonli.fontawesome5.FontAwesomeSolid
enum class ServerTypes(
val icon: Ikon,
private val countGetter: () -> Int,
private val countSupplier: () -> Int,
) : Translatable {
CUSTOM(FontAwesomeSolid.SERVER, { Minosoft.config.config.server.entries.size }),
LAN(FontAwesomeSolid.NETWORK_WIRED, { LANServerListener.SERVERS.size }),
@ -34,7 +34,7 @@ enum class ServerTypes(
override val translationKey: ResourceLocation = "minosoft:server_type.${name.lowercase()}".asResourceLocation()
val count: Int
get() = countGetter()
get() = countSupplier()
companion object : ValuesEnum<ServerTypes> {
override val VALUES: Array<ServerTypes> = values()

View File

@ -0,0 +1,23 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.eros.util
import de.bixilon.minosoft.data.accounts.Account
import javafx.scene.image.Image
object JavaFXAccountUtil {
val Account.avatar: Image?
get() = null // ToDo
}

View File

@ -27,6 +27,7 @@ import javafx.scene.control.Labeled
import javafx.scene.control.TextField
import javafx.scene.image.Image
import javafx.scene.layout.Pane
import javafx.scene.text.Text
import javafx.scene.text.TextFlow
import javafx.stage.Modality
import javafx.stage.Stage
@ -85,4 +86,10 @@ object JavaFXUtil {
set(value) {
this.text = Minosoft.LANGUAGE_MANAGER.translate(value).message
}
var Text.ctext: Any?
get() = this.text
set(value) {
this.text = Minosoft.LANGUAGE_MANAGER.translate(value).message
}
}

View File

@ -54,3 +54,6 @@ minosoft:update_server.edit.update_button=Save server
minosoft:server_list.refresh.header=Refresh
minosoft:server_list.refresh.text1=Get the latest
minosoft:server_list.refresh.text2=information
minosoft:main.account.no_account_selected=No account selected