diff --git a/src/main/java/de/bixilon/minosoft/data/text/events/click/ClickCallbackClickEvent.kt b/src/main/java/de/bixilon/minosoft/data/text/events/click/ClickCallbackClickEvent.kt
new file mode 100644
index 000000000..64957ac0f
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/text/events/click/ClickCallbackClickEvent.kt
@@ -0,0 +1,29 @@
+/*
+ * 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 .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.text.events.click
+
+import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
+import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseActions
+import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseButtons
+import glm_.vec2.Vec2i
+
+class ClickCallbackClickEvent(val callback: () -> Unit) : ClickEvent {
+
+ override fun onClick(guiRenderer: GUIRenderer, position: Vec2i, button: MouseButtons, action: MouseActions) {
+ if (button != MouseButtons.LEFT || action != MouseActions.PRESS) {
+ return
+ }
+ callback()
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/text/events/click/CopyToClipboardClickEvent.kt b/src/main/java/de/bixilon/minosoft/data/text/events/click/CopyToClipboardClickEvent.kt
index a4374d413..fbb766992 100644
--- a/src/main/java/de/bixilon/minosoft/data/text/events/click/CopyToClipboardClickEvent.kt
+++ b/src/main/java/de/bixilon/minosoft/data/text/events/click/CopyToClipboardClickEvent.kt
@@ -28,7 +28,7 @@ class CopyToClipboardClickEvent(
if (button != MouseButtons.LEFT || action != MouseActions.PRESS) {
return
}
- if (guiRenderer.connection.profiles.gui.confirmation.copyToClipboard) {
+ if (!guiRenderer.connection.profiles.gui.confirmation.copyToClipboard) {
guiRenderer.renderWindow.window.clipboardText = text
return
}
diff --git a/src/main/java/de/bixilon/minosoft/data/text/events/click/OpenFileClickEvent.kt b/src/main/java/de/bixilon/minosoft/data/text/events/click/OpenFileClickEvent.kt
index 2bfbc860a..b968c6ce4 100644
--- a/src/main/java/de/bixilon/minosoft/data/text/events/click/OpenFileClickEvent.kt
+++ b/src/main/java/de/bixilon/minosoft/data/text/events/click/OpenFileClickEvent.kt
@@ -35,7 +35,7 @@ class OpenFileClickEvent(
if (button != MouseButtons.LEFT || action != MouseActions.PRESS) {
return
}
- if (guiRenderer.connection.profiles.gui.confirmation.openFile) {
+ if (!guiRenderer.connection.profiles.gui.confirmation.openFile) {
DesktopUtil.openFile(path)
return
}
diff --git a/src/main/java/de/bixilon/minosoft/data/text/events/click/OpenURLClickEvent.kt b/src/main/java/de/bixilon/minosoft/data/text/events/click/OpenURLClickEvent.kt
index 25ecbe0ef..928e8a905 100644
--- a/src/main/java/de/bixilon/minosoft/data/text/events/click/OpenURLClickEvent.kt
+++ b/src/main/java/de/bixilon/minosoft/data/text/events/click/OpenURLClickEvent.kt
@@ -38,7 +38,7 @@ class OpenURLClickEvent(
if (button != MouseButtons.LEFT || action != MouseActions.PRESS) {
return
}
- if (guiRenderer.connection.profiles.gui.confirmation.openURL) {
+ if (!guiRenderer.connection.profiles.gui.confirmation.openURL) {
DesktopUtil.openURL(url)
return
}
diff --git a/src/main/java/de/bixilon/minosoft/data/text/events/click/SendMessageClickEvent.kt b/src/main/java/de/bixilon/minosoft/data/text/events/click/SendMessageClickEvent.kt
index 5a0b541ae..dfeb1bdba 100644
--- a/src/main/java/de/bixilon/minosoft/data/text/events/click/SendMessageClickEvent.kt
+++ b/src/main/java/de/bixilon/minosoft/data/text/events/click/SendMessageClickEvent.kt
@@ -29,7 +29,7 @@ class SendMessageClickEvent(
if (button != MouseButtons.LEFT || action != MouseActions.PRESS) {
return
}
- if (guiRenderer.connection.profiles.gui.confirmation.sendMessage) {
+ if (!guiRenderer.connection.profiles.gui.confirmation.sendMessage) {
guiRenderer.connection.util.sendChatMessage(message)
return
}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/input/button/ButtonElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/input/button/ButtonElement.kt
index 8948ba64e..9d5867069 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/input/button/ButtonElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/input/button/ButtonElement.kt
@@ -113,42 +113,48 @@ open class ButtonElement(
cacheUpToDate = false
}
- override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions) {
+ override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions): Boolean {
if (disabled) {
- return
+ return true
}
if (button != MouseButtons.LEFT) {
- return
+ return true
}
if (action != MouseActions.PRESS) {
- return
+ return true
}
submit()
+ return true
}
- override fun onKey(key: KeyCodes, type: KeyChangeTypes) {
+ override fun onKey(key: KeyCodes, type: KeyChangeTypes): Boolean {
if (!hovered) {
- return
+ return true
}
if (disabled) {
- return
+ return true
}
if (key != KeyCodes.KEY_ENTER) {
- return
+ return true
}
if (type != KeyChangeTypes.PRESS) {
- return
+ return true
}
submit()
+ return true
}
- override fun onMouseEnter(position: Vec2i) {
+ override fun onMouseEnter(position: Vec2i): Boolean {
hovered = true
+
+ return true
}
- override fun onMouseLeave() {
+ override fun onMouseLeave(): Boolean {
hovered = false
+
+ return true
}
open fun submit() {
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/TextElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/TextElement.kt
index bc20d714c..e3be43af6 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/TextElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/TextElement.kt
@@ -171,12 +171,13 @@ open class TextElement(
renderInfo.currentLineNumber = 0
}
- override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions) {
+ override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions): Boolean {
if (action != MouseActions.PRESS || button != MouseButtons.LEFT) {
- return
+ return true
}
- val text = getTextComponentAt(position) ?: return
+ val text = getTextComponentAt(position) ?: return false
text.clickEvent?.onClick(guiRenderer, position, button, action)
+ return true
}
private fun getTextComponentAt(position: Vec2i): TextComponent? {
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/TextFlowElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/TextFlowElement.kt
index c086513fe..083763dcf 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/TextFlowElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/TextFlowElement.kt
@@ -92,8 +92,9 @@ open class TextFlowElement(
}
}
- override fun onScroll(position: Vec2i, scrollOffset: Vec2d) {
+ override fun onScroll(position: Vec2i, scrollOffset: Vec2d): Boolean {
this.scrollOffset += scrollOffset.y.toInt()
+ return true
}
@Synchronized
@@ -180,9 +181,10 @@ open class TextFlowElement(
}
}
- override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions) {
- val pair = getAt(position) ?: return
+ override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions): Boolean {
+ val pair = getAt(position) ?: return false
pair.first.textElement.onMouseAction(pair.second, button, action)
+ return true
}
private fun getAt(position: Vec2i): Pair? {
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/mark/MarkTextElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/mark/MarkTextElement.kt
index abd112e25..f6b28ff83 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/mark/MarkTextElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/elements/text/mark/MarkTextElement.kt
@@ -96,7 +96,7 @@ class MarkTextElement(
super.forceRender(offset, consumer, options)
}
- override fun onKey(key: KeyCodes, type: KeyChangeTypes) {
+ override fun onKey(key: KeyCodes, type: KeyChangeTypes): Boolean {
super.onKey(key, type)
val controlDown = guiRenderer.isKeyDown(ModifierKeys.CONTROL)
@@ -104,7 +104,7 @@ class MarkTextElement(
when (key) {
KeyCodes.KEY_A -> {
if (!controlDown) {
- return
+ return true
}
mark(0, chatComponent.message.length)
}
@@ -114,8 +114,9 @@ class MarkTextElement(
}
}
KeyCodes.KEY_ESCAPE -> unmark()
- else -> return
+ else -> return true
}
+ return true
}
fun copy() {
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/elements/input/TextInputElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/elements/input/TextInputElement.kt
index 28122ef73..69604021a 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/elements/input/TextInputElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/elements/input/TextInputElement.kt
@@ -121,13 +121,14 @@ class TextInputElement(
onChange()
}
- override fun onCharPress(char: Int) {
+ override fun onCharPress(char: Int): Boolean {
if (_value.length >= maxLength || !editable) {
- return
+ return true
}
cursorTick = CURSOR_TICK_ON_ACTION
insert(char.toChar().toString())
forceApply()
+ return true
}
private fun mark(mark: Boolean, right: Boolean, modify: Int) {
@@ -168,9 +169,9 @@ class TextInputElement(
textElement.unmark()
}
- override fun onKey(key: KeyCodes, type: KeyChangeTypes) {
+ override fun onKey(key: KeyCodes, type: KeyChangeTypes): Boolean {
if (type == KeyChangeTypes.RELEASE) {
- return
+ return true
}
val controlDown = guiRenderer.isKeyDown(ModifierKeys.CONTROL)
val shiftDown = guiRenderer.isKeyDown(ModifierKeys.SHIFT)
@@ -189,12 +190,12 @@ class TextInputElement(
}
KeyCodes.KEY_BACKSPACE -> {
if (_value.isEmpty() || !editable) {
- return
+ return true
}
if (textElement.marked) {
insert("")
} else if (_pointer == 0) {
- return
+ return true
} else {
val delete = if (controlDown) calculateWordPointer(false) else -1
_value.delete(_pointer + delete, _pointer)
@@ -204,12 +205,12 @@ class TextInputElement(
}
KeyCodes.KEY_DELETE -> {
if (_value.isEmpty() || !editable) {
- return
+ return true
}
if (textElement.marked) {
insert("")
} else if (_pointer == _value.length) {
- return
+ return true
} else {
val delete = if (controlDown) calculateWordPointer(true) else 1
_value.delete(_pointer, _pointer + delete)
@@ -221,7 +222,7 @@ class TextInputElement(
if (!shiftDown) {
textElement.unmark()
}
- return
+ return true
}
val modify = if (controlDown) {
calculateWordPointer(false)
@@ -235,7 +236,7 @@ class TextInputElement(
if (!shiftDown && _pointer == _value.length) {
textElement.unmark()
}
- return
+ return true
}
val modify = if (controlDown) {
calculateWordPointer(true)
@@ -256,11 +257,13 @@ class TextInputElement(
else -> return textElement.onKey(key, type)
}
forceApply()
+
+ return true
}
- override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions) {
+ override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions): Boolean {
if (action != MouseActions.PRESS) {
- return
+ return true
}
val leftText = TextElement(guiRenderer, value, background = false)
leftText.prefMaxSize = Vec2i(position.x, size.y)
@@ -282,6 +285,7 @@ class TextInputElement(
}
this._pointer = pointer
forceSilentApply()
+ return true
}
override fun onChildChange(child: Element) {
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/screen/menu/Menu.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/screen/menu/Menu.kt
index aee39037c..38e896d72 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/screen/menu/Menu.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/screen/menu/Menu.kt
@@ -75,32 +75,36 @@ abstract class Menu(
}
}
- override fun onMouseLeave() {
+ override fun onMouseLeave(): Boolean {
activeElement?.onMouseLeave()
activeElement = null
+ return true
}
- override fun onMouseMove(position: Vec2i) {
+ override fun onMouseMove(position: Vec2i): Boolean {
val pair = getAt(position)
if (activeElement != pair?.first) {
activeElement?.onMouseLeave()
pair?.first?.onMouseEnter(pair.second)
activeElement = pair?.first
- return
+ return true
}
pair?.first?.onMouseMove(pair.second)
+ return true
}
- override fun onMouseEnter(position: Vec2i) {
+ override fun onMouseEnter(position: Vec2i): Boolean {
val pair = getAt(position)
pair?.first?.onMouseEnter(pair.second)
activeElement = pair?.first
+ return true
}
- override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions) {
- val (element, delta) = getAt(position) ?: return
+ override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions): Boolean {
+ val (element, delta) = getAt(position) ?: return true
element.onMouseAction(delta, button, action)
+ return true
}
override fun onChildChange(child: Element) {
@@ -155,8 +159,7 @@ abstract class Menu(
super.tick()
}
- override fun onKey(key: KeyCodes, type: KeyChangeTypes) {
- super.onKey(key, type)
+ override fun onKey(key: KeyCodes, type: KeyChangeTypes): Boolean {
if (type != KeyChangeTypes.RELEASE && key == KeyCodes.KEY_TAB) {
var element: Element?
var initialIndex = elements.indexOf(activeElement)
@@ -170,33 +173,36 @@ abstract class Menu(
index = 0
}
if (index == initialIndex) {
- return
+ return true
}
- element = elements.getOrNull(index) ?: return
+ element = elements.getOrNull(index) ?: return true
if (element.canFocus) {
break
}
}
if (element == null) {
- return
+ return true
}
activeElement?.onMouseLeave()
element.onMouseEnter(Vec2i.EMPTY)
activeElement = element
- return // no passthrough the key to current active element
+ return true // no passthrough the key to current active element
}
activeElement?.onKey(key, type)
+
+ return true
}
- override fun onCharPress(char: Int) {
- super.onCharPress(char)
+ override fun onCharPress(char: Int): Boolean {
activeElement?.onCharPress(char)
+ return true
}
- override fun onScroll(position: Vec2i, scrollOffset: Vec2d) {
- val (element, delta) = getAt(position) ?: return
+ override fun onScroll(position: Vec2i, scrollOffset: Vec2d): Boolean {
+ val (element, delta) = getAt(position) ?: return true
element.onScroll(delta, scrollOffset)
+ return true
}
private fun reset() {
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/screen/menu/confirmation/DeleteScreenshotDialog.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/screen/menu/confirmation/DeleteScreenshotDialog.kt
new file mode 100644
index 000000000..09bc831a6
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/gui/screen/menu/confirmation/DeleteScreenshotDialog.kt
@@ -0,0 +1,43 @@
+/*
+ * 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 .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.confirmation
+
+import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
+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 java.io.File
+
+class DeleteScreenshotDialog(
+ guiRenderer: GUIRenderer,
+ private val screenshot: File,
+) : AbstractConfirmationMenu(
+ guiRenderer,
+ "Do you want to delete this screenshot?",
+ TextComponent(screenshot.name, color = VALUE_COLOR),
+) {
+
+ override fun createButtons(): Array {
+ return arrayOf(
+ ButtonElement(guiRenderer, "§cSure, delete it") {
+ DefaultThreadPool += { screenshot.delete() }
+ close()
+ }
+ )
+ }
+
+ init {
+ initButtons()
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/LayoutedGUIElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/LayoutedGUIElement.kt
index b4f6e47ac..b3d9b0088 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/LayoutedGUIElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/LayoutedGUIElement.kt
@@ -118,31 +118,26 @@ class LayoutedGUIElement(
}
// move out
this.lastPosition = INVALID_MOUSE_POSITION
- elementLayout.onMouseLeave()
- return true
+ return elementLayout.onMouseLeave()
}
val delta = position - offset
this.lastPosition = delta
if (lastPosition.isOutside(offset, size)) {
- elementLayout.onMouseEnter(delta)
- return true
+ return elementLayout.onMouseEnter(delta)
}
- elementLayout.onMouseMove(delta)
- return true
+ return elementLayout.onMouseMove(delta)
}
override fun onCharPress(char: Int): Boolean {
- elementLayout.onCharPress(char)
- return true
+ return elementLayout.onCharPress(char)
}
override fun onKeyPress(type: KeyChangeTypes, key: KeyCodes): Boolean {
val mouseButton = MouseButtons[key]
if (mouseButton == null) {
- elementLayout.onKey(key, type)
- return true
+ return elementLayout.onKey(key, type)
}
val position = lastPosition
@@ -151,8 +146,7 @@ class LayoutedGUIElement(
}
val mouseAction = MouseActions[type] ?: return false
- elementLayout.onMouseAction(position, mouseButton, mouseAction)
- return true
+ return elementLayout.onMouseAction(position, mouseButton, mouseAction)
}
override fun onScroll(scrollOffset: Vec2d): Boolean {
@@ -160,8 +154,7 @@ class LayoutedGUIElement(
if (lastPosition == INVALID_MOUSE_POSITION) {
return false
}
- elementLayout.onScroll(position, scrollOffset)
- return true
+ return elementLayout.onScroll(position, scrollOffset)
}
override fun onClose() {
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/AbstractChatElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/AbstractChatElement.kt
index ce64a5e6e..901091336 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/AbstractChatElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/AbstractChatElement.kt
@@ -34,12 +34,13 @@ abstract class AbstractChatElement(guiRenderer: GUIRenderer) : Element(guiRender
}
- override fun onScroll(position: Vec2i, scrollOffset: Vec2d) {
+ override fun onScroll(position: Vec2i, scrollOffset: Vec2d): Boolean {
val size = messages.size
if (position.y > size.y || position.x > messages.size.x) {
- return
+ return false
}
messages.onScroll(position, scrollOffset)
+ return true
}
override fun tick() {
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/ChatElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/ChatElement.kt
index c2909affc..ca3c572b2 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/ChatElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/ChatElement.kt
@@ -133,11 +133,13 @@ class ChatElement(guiRenderer: GUIRenderer) : AbstractChatElement(guiRenderer) {
messages.onClose()
}
- override fun onCharPress(char: Int) {
+ override fun onCharPress(char: Int): Boolean {
if (char == '§'.code) {
- return input.onCharPress('&'.code)
+ input.onCharPress('&'.code)
+ } else {
+ input.onCharPress(char)
}
- input.onCharPress(char)
+ return true
}
private fun submit() {
@@ -154,23 +156,24 @@ class ChatElement(guiRenderer: GUIRenderer) : AbstractChatElement(guiRenderer) {
guiRenderer.gui.pop()
}
- override fun onKey(key: KeyCodes, type: KeyChangeTypes) {
+ override fun onKey(key: KeyCodes, type: KeyChangeTypes): Boolean {
if (type != KeyChangeTypes.RELEASE) {
when (key) {
KeyCodes.KEY_ENTER -> {
- return submit()
+ submit()
+ return true
}
KeyCodes.KEY_PAGE_UP -> {
messages.scrollOffset++
- return
+ return true
}
KeyCodes.KEY_PAGE_DOWN -> {
messages.scrollOffset--
- return
+ return true
}
KeyCodes.KEY_UP -> {
if (historyIndex <= 0) {
- return
+ return true
}
val size = history.size
if (historyIndex > size) {
@@ -183,11 +186,11 @@ class ChatElement(guiRenderer: GUIRenderer) : AbstractChatElement(guiRenderer) {
val size = history.size
historyIndex++
if (historyIndex > size) {
- return
+ return true
}
if (historyIndex == size) {
input.value = ""
- return
+ return true
}
input.value = history[historyIndex]
}
@@ -195,11 +198,14 @@ class ChatElement(guiRenderer: GUIRenderer) : AbstractChatElement(guiRenderer) {
}
}
input.onKey(key, type)
+
+ return true
}
- override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions) {
- val pair = getAt(position) ?: return
+ override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions): Boolean {
+ val pair = getAt(position) ?: return false
pair.first.onMouseAction(pair.second, button, action)
+ return true
}
private fun getAt(position: Vec2i): Pair? {
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/InternalChatElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/InternalChatElement.kt
index 5e9064a71..c2290de97 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/InternalChatElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/chat/InternalChatElement.kt
@@ -82,9 +82,10 @@ class InternalChatElement(guiRenderer: GUIRenderer) : AbstractChatElement(guiRen
guiRenderer.gui.pop() // pop normal chat
}
- override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions) {
- val pair = getAt(position) ?: return
+ override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions): Boolean {
+ val pair = getAt(position) ?: return false
pair.first.onMouseAction(pair.second, button, action)
+ return true
}
private fun getAt(position: Vec2i): Pair? {
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/input/InputElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/input/InputElement.kt
index 2c7754a22..3b2f9cef4 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/input/InputElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/input/InputElement.kt
@@ -22,14 +22,14 @@ import glm_.vec2.Vec2i
interface InputElement {
- fun onMouseMove(position: Vec2i) {}
- fun onMouseEnter(position: Vec2i) {}
- fun onMouseLeave() {}
- fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions) {}
- fun onScroll(position: Vec2i, scrollOffset: Vec2d) {}
+ fun onMouseMove(position: Vec2i) = false
+ fun onMouseEnter(position: Vec2i) = false
+ fun onMouseLeave() = false
+ fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions) = false
+ fun onScroll(position: Vec2i, scrollOffset: Vec2d) = false
- fun onKey(key: KeyCodes, type: KeyChangeTypes) {}
- fun onCharPress(char: Int) {}
+ fun onKey(key: KeyCodes, type: KeyChangeTypes) = false
+ fun onCharPress(char: Int) = false
// ToDo: drag
}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/util/ScreenshotTaker.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/util/ScreenshotTaker.kt
index 2ae2df72d..99ada7a31 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/util/ScreenshotTaker.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/util/ScreenshotTaker.kt
@@ -22,9 +22,12 @@ import de.bixilon.kutil.time.TimeUtil
import de.bixilon.minosoft.data.text.BaseComponent
import de.bixilon.minosoft.data.text.ChatColors
import de.bixilon.minosoft.data.text.TextComponent
+import de.bixilon.minosoft.data.text.events.click.ClickCallbackClickEvent
import de.bixilon.minosoft.data.text.events.click.OpenFileClickEvent
import de.bixilon.minosoft.data.text.events.hover.TextHoverEvent
import de.bixilon.minosoft.gui.rendering.RenderWindow
+import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
+import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.confirmation.DeleteScreenshotDialog
import de.bixilon.minosoft.gui.rendering.system.base.PixelTypes
import de.bixilon.minosoft.terminal.RunConfiguration
import glm_.vec2.Vec2i
@@ -73,22 +76,20 @@ class ScreenshotTaker(
ImageIO.write(bufferedImage, "png", file)
renderWindow.connection.util.sendDebugMessage(BaseComponent(
- "§aScreenshot saved to ",
+ "§aScreenshot saved: ",
TextComponent(file.name).apply {
color = ChatColors.WHITE
underline()
clickEvent = OpenFileClickEvent(file.slashPath)
hoverEvent = TextHoverEvent("Click to open")
},
- // "\n",
- // TextComponent("[DELETE]").apply {
- // color = ChatColors.RED
- // bold()
- // clickEvent = ClickEvent(ClickEvent.ClickEventActions.OPEN_CONFIRMATION, {
- // TODO()
- // })
- // hoverEvent = ClickEvent(ClickEvent.HoverEventActions.SHOW_TEXT, "Click to delete screenshot")
- // },
+ " ",
+ TextComponent("[DELETE]").apply {
+ color = ChatColors.RED
+ bold()
+ clickEvent = ClickCallbackClickEvent { DeleteScreenshotDialog(renderWindow.renderer[GUIRenderer] ?: return@ClickCallbackClickEvent, file).open() }
+ hoverEvent = TextHoverEvent("Click to delete screenshot")
+ },
))
} catch (exception: Exception) {
exception.fail()