chat click events: config option to toggle confirmations

This commit is contained in:
Bixilon 2022-02-17 12:53:41 +01:00
parent 0bef814b9b
commit 0a86f61e85
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
9 changed files with 87 additions and 14 deletions

View File

@ -19,6 +19,7 @@ import de.bixilon.minosoft.config.profile.profiles.Profile
import de.bixilon.minosoft.config.profile.profiles.gui.GUIProfileManager.delegate
import de.bixilon.minosoft.config.profile.profiles.gui.GUIProfileManager.latestVersion
import de.bixilon.minosoft.config.profile.profiles.gui.chat.ChatC
import de.bixilon.minosoft.config.profile.profiles.gui.confirmation.ConfirmationC
import de.bixilon.minosoft.config.profile.profiles.gui.hud.HudC
/**
@ -44,6 +45,7 @@ class GUIProfile(
val chat = ChatC()
val hud = HudC()
val confirmation = ConfirmationC()
override fun toString(): String {
return GUIProfileManager.getName(this)

View File

@ -0,0 +1,23 @@
/*
* Minosoft
* Copyright (C) 2022 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.config.profile.profiles.gui.confirmation
import de.bixilon.minosoft.config.profile.profiles.gui.GUIProfileManager.delegate
class ConfirmationC {
val copyToClipboard by delegate(true)
val openFile by delegate(true)
val openURL by delegate(true)
val sendMessage by delegate(true)
}

View File

@ -28,6 +28,10 @@ class CopyToClipboardClickEvent(
if (button != MouseButtons.LEFT || action != MouseActions.PRESS) {
return
}
if (guiRenderer.connection.profiles.gui.confirmation.copyToClipboard) {
guiRenderer.renderWindow.window.clipboardText = text
return
}
val dialog = CopyToClipboardDialog(guiRenderer, text)
dialog.open()
}

View File

@ -19,6 +19,7 @@ import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.confirmation.OpenFileConfirmationDialog
import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseActions
import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseButtons
import de.bixilon.minosoft.util.DesktopUtil
import glm_.vec2.Vec2i
import javafx.scene.text.Text
@ -34,6 +35,10 @@ class OpenFileClickEvent(
if (button != MouseButtons.LEFT || action != MouseActions.PRESS) {
return
}
if (guiRenderer.connection.profiles.gui.confirmation.openFile) {
DesktopUtil.openFile(path)
return
}
val dialog = OpenFileConfirmationDialog(guiRenderer, path)
dialog.open()
}

View File

@ -21,6 +21,7 @@ import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.confirmation.URLConfirmationDialog
import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseActions
import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseButtons
import de.bixilon.minosoft.util.DesktopUtil
import glm_.vec2.Vec2i
import javafx.scene.text.Text
import java.net.URL
@ -37,6 +38,10 @@ class OpenURLClickEvent(
if (button != MouseButtons.LEFT || action != MouseActions.PRESS) {
return
}
if (guiRenderer.connection.profiles.gui.confirmation.openURL) {
DesktopUtil.openURL(url)
return
}
val dialog = URLConfirmationDialog(guiRenderer, url)
dialog.open()
}

View File

@ -29,6 +29,10 @@ class SendMessageClickEvent(
if (button != MouseButtons.LEFT || action != MouseActions.PRESS) {
return
}
if (guiRenderer.connection.profiles.gui.confirmation.sendMessage) {
guiRenderer.connection.util.sendChatMessage(message)
return
}
val dialog = SendMessageDialog(guiRenderer, message)
dialog.open()
}

View File

@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.confirmation
import de.bixilon.minosoft.data.text.TextComponent
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
import de.bixilon.minosoft.gui.rendering.gui.elements.input.button.ButtonElement
import de.bixilon.minosoft.util.DesktopUtil
class OpenFileConfirmationDialog(
guiRenderer: GUIRenderer,
@ -28,7 +29,7 @@ class OpenFileConfirmationDialog(
override fun createButtons(): Array<ButtonElement> {
return arrayOf(
ButtonElement(guiRenderer, "Yes, open it!") {
println("ToDo: Can not open file: $path")
DesktopUtil.openFile(path)
close()
},
createCopyToClipboardButton(path)

View File

@ -14,13 +14,9 @@
package de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.confirmation
import de.bixilon.minosoft.data.text.TextComponent
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
import de.bixilon.minosoft.gui.rendering.gui.elements.input.button.ButtonElement
import de.bixilon.minosoft.terminal.RunConfiguration
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
import de.bixilon.minosoft.util.DesktopUtil
import java.net.URL
class URLConfirmationDialog(
@ -34,14 +30,7 @@ class URLConfirmationDialog(
override fun createButtons(): Array<ButtonElement> {
return arrayOf(
ButtonElement(guiRenderer, "Yes, open it!") {
if (RunConfiguration.DISABLE_EROS) {
return@ButtonElement Log.log(LogMessageType.GENERAL, LogLevels.INFO) { "Can not open url: $url" }
}
try {
JavaFXUtil.HOST_SERVICES.showDocument(url.toString())
} catch (exception: Throwable) {
exception.printStackTrace()
}
DesktopUtil.openURL(url)
close()
},
createCopyToClipboardButton(url.toString())

View File

@ -0,0 +1,40 @@
/*
* Minosoft
* Copyright (C) 2022 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.util
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
import de.bixilon.minosoft.terminal.RunConfiguration
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
import java.net.URL
object DesktopUtil {
fun openURL(url: URL) {
if (RunConfiguration.DISABLE_EROS) {
Log.log(LogMessageType.GENERAL, LogLevels.INFO) { "Can not open url: $url" }
return
}
try {
JavaFXUtil.HOST_SERVICES.showDocument(url.toString())
} catch (exception: Throwable) {
exception.printStackTrace()
}
}
fun openFile(path: String) {
println("ToDo: Can not open file: $path")
}
}