mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
add offline accounts
This commit is contained in:
parent
89a00b17eb
commit
2451e4a5da
@ -22,6 +22,7 @@ import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.gui.eros.controller.EmbeddedJavaFXController
|
||||
import de.bixilon.minosoft.gui.eros.dialogs.SimpleErosConfirmationDialog
|
||||
import de.bixilon.minosoft.gui.eros.main.account.add.OfflineAddController
|
||||
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||
import de.bixilon.minosoft.util.task.pool.DefaultThreadPool
|
||||
import javafx.application.Platform
|
||||
@ -187,7 +188,7 @@ class AccountController : EmbeddedJavaFXController<Pane>() {
|
||||
resourceLocation = OfflineAccount.RESOURCE_LOCATION,
|
||||
translationKey = "minosoft:main.account.type.offline".asResourceLocation(),
|
||||
icon = FontAwesomeSolid.MAP,
|
||||
addHandler = { TODO() }
|
||||
addHandler = { OfflineAddController(it).show() }
|
||||
),
|
||||
ErosAccountType<MicrosoftAccount>(
|
||||
resourceLocation = MicrosoftAccount.RESOURCE_LOCATION,
|
||||
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.main.account.add
|
||||
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.data.accounts.types.OfflineAccount
|
||||
import de.bixilon.minosoft.gui.eros.controller.JavaFXWindowController
|
||||
import de.bixilon.minosoft.gui.eros.main.account.AccountController
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.ctext
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.placeholder
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.text
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||
import javafx.application.Platform
|
||||
import javafx.fxml.FXML
|
||||
import javafx.scene.control.Button
|
||||
import javafx.scene.control.TextField
|
||||
import javafx.scene.text.TextFlow
|
||||
import javafx.stage.Modality
|
||||
|
||||
class OfflineAddController(
|
||||
private val accountController: AccountController,
|
||||
) : JavaFXWindowController() {
|
||||
@FXML private lateinit var headerFX: TextFlow
|
||||
@FXML private lateinit var descriptionFX: TextFlow
|
||||
|
||||
@FXML private lateinit var usernameLabelFX: TextFlow
|
||||
@FXML private lateinit var usernameFX: TextField
|
||||
|
||||
@FXML private lateinit var addButtonFX: Button
|
||||
@FXML private lateinit var cancelButtonFX: Button
|
||||
|
||||
|
||||
fun show() {
|
||||
Platform.runLater {
|
||||
JavaFXUtil.openModal(TITLE, LAYOUT, this, modality = Modality.APPLICATION_MODAL)
|
||||
stage.show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
super.init()
|
||||
|
||||
|
||||
headerFX.text = HEADER
|
||||
descriptionFX.text = DESCRIPTION
|
||||
usernameLabelFX.text = USERNAME_LABEL
|
||||
usernameFX.placeholder = USERNAME_PLACEHOLDER
|
||||
addButtonFX.ctext = ADD_BUTTON
|
||||
cancelButtonFX.ctext = CANCEL_BUTTON
|
||||
|
||||
usernameFX.textProperty().addListener { _, _, new ->
|
||||
addButtonFX.isDisable = !ProtocolDefinition.MINECRAFT_NAME_VALIDATOR.matcher(new).matches()
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
fun add() {
|
||||
val account = OfflineAccount(usernameFX.text)
|
||||
Minosoft.config.config.account.entries[account.id] = account
|
||||
Minosoft.config.saveToFile()
|
||||
|
||||
accountController.refreshList()
|
||||
stage.hide()
|
||||
}
|
||||
|
||||
@FXML
|
||||
fun cancel() {
|
||||
stage.hide()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LAYOUT = "minosoft:eros/main/account/add/offline.fxml".asResourceLocation()
|
||||
|
||||
private val TITLE = "minosoft:main.account.add.offline.title".asResourceLocation()
|
||||
private val HEADER = "minosoft:main.account.add.offline.header".asResourceLocation()
|
||||
private val DESCRIPTION = "minosoft:main.account.add.offline.description".asResourceLocation()
|
||||
private val USERNAME_LABEL = "minosoft:main.account.add.offline.username.label".asResourceLocation()
|
||||
private val USERNAME_PLACEHOLDER = "minosoft:main.account.add.offline.username.placeholder".asResourceLocation()
|
||||
private val ADD_BUTTON = "minosoft:main.account.add.offline.add_button".asResourceLocation()
|
||||
private val CANCEL_BUTTON = "minosoft:main.account.add.offline.cancel_button".asResourceLocation()
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<HBox xmlns:fx="http://javafx.com/fxml/1" fx:id="root" prefHeight="200.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/16"> <!--fx:controller="de.bixilon.minosoft.gui.eros.main.account.add.OfflineAddController" -->
|
||||
<GridPane HBox.hgrow="ALWAYS">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="ALWAYS"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints vgrow="NEVER"/>
|
||||
<RowConstraints vgrow="NEVER"/>
|
||||
<RowConstraints vgrow="NEVER"/>
|
||||
<RowConstraints vgrow="ALWAYS"/>
|
||||
<RowConstraints vgrow="NEVER"/>
|
||||
</rowConstraints>
|
||||
<TextFlow fx:id="headerFX">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="10.0" left="5.0" right="5.0" top="10.0"/>
|
||||
</GridPane.margin>
|
||||
<Text text="Add offline account"/>
|
||||
</TextFlow>
|
||||
<TextFlow fx:id="descriptionFX" GridPane.rowIndex="1">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</padding>
|
||||
<GridPane.margin>
|
||||
<Insets bottom="15.0" right="5.0" top="5.0"/>
|
||||
</GridPane.margin>
|
||||
<Text text="Please enter the username for your account"/>
|
||||
</TextFlow>
|
||||
<GridPane GridPane.rowIndex="2">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="NEVER"/>
|
||||
<ColumnConstraints hgrow="ALWAYS"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints valignment="CENTER" vgrow="NEVER"/>
|
||||
</rowConstraints>
|
||||
<TextFlow fx:id="usernameLabelFX">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="30.0" top="5.0"/>
|
||||
</GridPane.margin>
|
||||
<Text text="Username"/>
|
||||
</TextFlow>
|
||||
<TextField fx:id="usernameFX" promptText="Username" GridPane.columnIndex="1">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</GridPane.margin>
|
||||
</TextField>
|
||||
</GridPane>
|
||||
<GridPane GridPane.rowIndex="4">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="ALWAYS"/>
|
||||
<ColumnConstraints hgrow="NEVER"/>
|
||||
<ColumnConstraints hgrow="NEVER"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints vgrow="NEVER"/>
|
||||
</rowConstraints>
|
||||
<Button fx:id="cancelButtonFX" onAction="#cancel" text="Cancel" GridPane.columnIndex="1">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</GridPane.margin>
|
||||
</Button>
|
||||
<Button disable="true" onAction="#add" fx:id="addButtonFX" text="Add" GridPane.columnIndex="2">
|
||||
<GridPane.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</GridPane.margin>
|
||||
</Button>
|
||||
</GridPane>
|
||||
</GridPane>
|
||||
</HBox>
|
@ -65,3 +65,11 @@ minosoft:main.account.type.offline=Offline
|
||||
|
||||
|
||||
minosoft:main.account.card.connection_count=%1$s connections
|
||||
|
||||
minosoft:main.account.add.offline.title=Add offline account
|
||||
minosoft:main.account.add.offline.header=Add offline account
|
||||
minosoft:main.account.add.offline.description=Please enter the username of the account you want to add.
|
||||
minosoft:main.account.add.offline.username.label=Username
|
||||
minosoft:main.account.add.offline.username.placeholder=Username
|
||||
minosoft:main.account.add.offline.add_button=Add
|
||||
minosoft:main.account.add.offline.cancel_button=Cancel
|
||||
|
Loading…
x
Reference in New Issue
Block a user