mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
gui: draggable (wip)
This commit is contained in:
parent
a9ff815e76
commit
c545dca618
@ -16,7 +16,7 @@ package de.bixilon.minosoft.data.text.events.hover
|
||||
import de.bixilon.kutil.json.JsonObject
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.popper.text.TextPopper
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.popper.text.TextPopper
|
||||
import glm_.vec2.Vec2i
|
||||
import javafx.scene.text.Text
|
||||
|
||||
|
@ -14,9 +14,10 @@
|
||||
package de.bixilon.minosoft.gui.rendering.gui
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.DraggableHandler
|
||||
import de.bixilon.minosoft.gui.rendering.input.InputHandler
|
||||
|
||||
interface GUIElement : InputHandler {
|
||||
interface GUIElement : InputHandler, DraggableHandler {
|
||||
val guiRenderer: GUIRenderer
|
||||
val renderWindow: RenderWindow
|
||||
var enabled: Boolean
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.gui
|
||||
|
||||
import de.bixilon.kutil.time.TimeUtil
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.Drawable
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
|
||||
|
@ -14,14 +14,16 @@
|
||||
package de.bixilon.minosoft.gui.rendering.gui
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.watcher.DataWatcher.Companion.watched
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegateWatcher.Companion.profileWatchRendering
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasManager
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.GUIManager
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.DraggedManager
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.popper.PopperManager
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDManager
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.ModifierKeys
|
||||
import de.bixilon.minosoft.gui.rendering.gui.popper.PopperManager
|
||||
import de.bixilon.minosoft.gui.rendering.input.InputHandler
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.Renderer
|
||||
@ -31,6 +33,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.PolygonModes
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.buffer.frame.Framebuffer
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.phases.OtherDrawable
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -45,10 +48,11 @@ class GUIRenderer(
|
||||
) : Renderer, InputHandler, OtherDrawable {
|
||||
private val profile = connection.profiles.gui
|
||||
override val renderSystem = renderWindow.renderSystem
|
||||
var scaledSize: Vec2i = renderWindow.window.size
|
||||
var scaledSize: Vec2i by watched(renderWindow.window.size)
|
||||
val gui = GUIManager(this)
|
||||
val hud = HUDManager(this)
|
||||
val popper = PopperManager(this)
|
||||
val dragged = DraggedManager(this)
|
||||
var matrix: Mat4 = Mat4()
|
||||
private set
|
||||
var matrixChange = true
|
||||
@ -59,14 +63,15 @@ class GUIRenderer(
|
||||
val shader = renderWindow.renderSystem.createShader("minosoft:hud".toResourceLocation())
|
||||
val atlasManager = AtlasManager(renderWindow)
|
||||
|
||||
val currentCursorPosition: Vec2i
|
||||
get() = Vec2i(renderWindow.inputHandler.currentMousePosition).scale()
|
||||
var currentCursorPosition: Vec2i by watched(Vec2i.EMPTY)
|
||||
private set
|
||||
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
atlasManager.init()
|
||||
gui.init()
|
||||
hud.init()
|
||||
popper.init()
|
||||
dragged.init()
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
@ -81,6 +86,7 @@ class GUIRenderer(
|
||||
gui.postInit()
|
||||
hud.postInit()
|
||||
popper.postInit()
|
||||
dragged.postInit()
|
||||
}
|
||||
|
||||
private fun recalculateMatrices(windowSize: Vec2i = renderWindow.window.size, scale: Float = profile.scale) {
|
||||
@ -91,6 +97,7 @@ class GUIRenderer(
|
||||
gui.onMatrixChange()
|
||||
hud.onMatrixChange()
|
||||
popper.onMatrixChange()
|
||||
dragged.onMatrixChange()
|
||||
}
|
||||
|
||||
fun setup() {
|
||||
@ -106,18 +113,32 @@ class GUIRenderer(
|
||||
}
|
||||
|
||||
override fun onMouseMove(position: Vec2i): Boolean {
|
||||
return gui.onMouseMove(position.scale())
|
||||
val scaledPosition = position.scale()
|
||||
currentCursorPosition = scaledPosition
|
||||
if (dragged.onMouseMove(scaledPosition)) {
|
||||
return true
|
||||
}
|
||||
return gui.onMouseMove(scaledPosition)
|
||||
}
|
||||
|
||||
override fun onCharPress(char: Int): Boolean {
|
||||
if (dragged.onCharPress(char)) {
|
||||
return true
|
||||
}
|
||||
return gui.onCharPress(char)
|
||||
}
|
||||
|
||||
override fun onKeyPress(type: KeyChangeTypes, key: KeyCodes): Boolean {
|
||||
if (dragged.onKeyPress(type, key)) {
|
||||
return true
|
||||
}
|
||||
return gui.onKeyPress(type, key)
|
||||
}
|
||||
|
||||
override fun onScroll(scrollOffset: Vec2d): Boolean {
|
||||
if (dragged.onScroll(scrollOffset)) {
|
||||
return true
|
||||
}
|
||||
return gui.onScroll(scrollOffset)
|
||||
}
|
||||
|
||||
@ -125,6 +146,7 @@ class GUIRenderer(
|
||||
hud.draw()
|
||||
gui.draw()
|
||||
popper.draw()
|
||||
dragged.draw()
|
||||
if (this.matrixChange) {
|
||||
this.matrixChange = false
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.gui.elements
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.DraggableElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.InputElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMesh
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMeshCache
|
||||
@ -31,7 +32,7 @@ import de.bixilon.minosoft.util.collections.floats.DirectArrayFloatList
|
||||
import glm_.vec2.Vec2i
|
||||
import glm_.vec4.Vec4i
|
||||
|
||||
abstract class Element(val guiRenderer: GUIRenderer, var initialCacheSize: Int = 1000) : InputElement {
|
||||
abstract class Element(val guiRenderer: GUIRenderer, var initialCacheSize: Int = 1000) : InputElement, DraggableElement {
|
||||
var ignoreDisplaySize = false
|
||||
val renderWindow = guiRenderer.renderWindow
|
||||
open val activeWhenHidden = false
|
||||
|
@ -21,6 +21,10 @@ import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.Vec2iBinding
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.AbstractLayout
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.Dragged
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.elements.item.FloatingItem
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseActions
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseButtons
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
@ -35,7 +39,9 @@ class ContainerItemsElement(
|
||||
val slots: Int2ObjectOpenHashMap<Vec2iBinding>, // ToDo: Use an array?
|
||||
) : Element(guiRenderer), AbstractLayout<ItemElement> {
|
||||
private val itemElements: MutableMap<Int, ItemElementData> = synchronizedMapOf()
|
||||
private var floatingItem: FloatingItem? = null
|
||||
override var activeElement: ItemElement? = null
|
||||
override var activeDragElement: ItemElement? = null
|
||||
private var update = true
|
||||
|
||||
init {
|
||||
@ -121,6 +127,29 @@ class ContainerItemsElement(
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions): Boolean {
|
||||
val consumed = super<AbstractLayout>.onMouseAction(position, button, action)
|
||||
if (action != MouseActions.PRESS) {
|
||||
return consumed
|
||||
}
|
||||
|
||||
val activeElement = activeElement
|
||||
val stack = activeElement?.stack
|
||||
var floatingItem = this.floatingItem
|
||||
if ((floatingItem != null && !floatingItem.visible) || stack?._valid != true) {
|
||||
return consumed
|
||||
}
|
||||
floatingItem = FloatingItem(guiRenderer, activeElement.slotId, stack)
|
||||
this.floatingItem = floatingItem
|
||||
floatingItem.show()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onDragMove(position: Vec2i, absolute: Vec2i, draggable: Dragged): Element? {
|
||||
println("Drag: ($draggable) at $position")
|
||||
return this
|
||||
}
|
||||
|
||||
private data class ItemElementData(
|
||||
val element: ItemElement,
|
||||
|
@ -31,10 +31,10 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.VerticalAlignments.Compani
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ColorElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ImageElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.popper.item.ItemInfoPopper
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.ModifierKeys
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.gui.popper.item.ItemInfoPopper
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.CursorShapes
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.EMPTY
|
||||
@ -182,9 +182,11 @@ class ItemElement(
|
||||
return stack.toString()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
companion object {
|
||||
private val NEGATIVE_INFINITE_TEXT = TextComponent("-∞").color(ChatColors.RED)
|
||||
private val INFINITE_TEXT = TextComponent("∞").color(ChatColors.RED)
|
||||
private val ZERO_TEXT = TextComponent("0").color(ChatColors.YELLOW)
|
||||
|
||||
val DEFAULT_SIZE = Vec2i(17, 17) // 16x16 for the item and 1px for the count offset
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ open class TextFlowElement(
|
||||
private val messages: MutableList<TextFlowTextElement> = synchronizedListOf() // all messages **from newest to oldest**
|
||||
private var visibleLines: List<TextFlowLineElement> = listOf() // all visible lines **from bottom to top**
|
||||
override var activeElement: TextElement? = null
|
||||
override var activeDragElement: TextElement? = null
|
||||
|
||||
private val background = ColorElement(guiRenderer, size, RenderConstants.TEXT_BACKGROUND_COLOR)
|
||||
|
||||
|
@ -15,6 +15,8 @@ package de.bixilon.minosoft.gui.rendering.gui.gui
|
||||
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.Dragged
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.DraggableElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.InputElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseActions
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseButtons
|
||||
@ -22,8 +24,9 @@ import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import glm_.vec2.Vec2d
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
interface AbstractLayout<T : Element> : InputElement {
|
||||
interface AbstractLayout<T : Element> : InputElement, DraggableElement {
|
||||
var activeElement: T?
|
||||
var activeDragElement: T?
|
||||
|
||||
fun getAt(position: Vec2i): Pair<T, Vec2i>?
|
||||
|
||||
@ -55,8 +58,8 @@ interface AbstractLayout<T : Element> : InputElement {
|
||||
}
|
||||
|
||||
override fun onMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions): Boolean {
|
||||
val pair = getAt(position) ?: return false
|
||||
return pair.first.onMouseAction(pair.second, button, action)
|
||||
val (element, offset) = getAt(position) ?: return false
|
||||
return element.onMouseAction(offset, button, action)
|
||||
}
|
||||
|
||||
override fun onKey(key: KeyCodes, type: KeyChangeTypes): Boolean {
|
||||
@ -68,7 +71,40 @@ interface AbstractLayout<T : Element> : InputElement {
|
||||
}
|
||||
|
||||
override fun onScroll(position: Vec2i, scrollOffset: Vec2d): Boolean {
|
||||
val pair = getAt(position) ?: return false
|
||||
return pair.first.onScroll(pair.second, scrollOffset)
|
||||
val (element, offset) = getAt(position) ?: return false
|
||||
return element.onScroll(offset, scrollOffset)
|
||||
}
|
||||
|
||||
override fun onDragEnter(position: Vec2i, absolute: Vec2i, draggable: Dragged): Element? {
|
||||
val pair = getAt(position)
|
||||
this.activeDragElement = pair?.first
|
||||
return pair?.first?.onDragEnter(pair.second, absolute, draggable)
|
||||
}
|
||||
|
||||
override fun onDragMove(position: Vec2i, absolute: Vec2i, draggable: Dragged): Element? {
|
||||
val pair = getAt(position)
|
||||
|
||||
if (activeDragElement != pair?.first) {
|
||||
val activeDragElement = activeDragElement
|
||||
this.activeDragElement = pair?.first
|
||||
|
||||
// Don't put this in the return line, compiler optimizations break it.
|
||||
val leaveElement = activeDragElement?.onDragLeave(draggable)
|
||||
val enterElement = pair?.first?.onDragEnter(pair.second, absolute, draggable)
|
||||
return enterElement ?: leaveElement
|
||||
}
|
||||
return pair?.first?.onDragMove(pair.second, absolute, draggable)
|
||||
}
|
||||
|
||||
override fun onDragLeave(draggable: Dragged): Element? {
|
||||
val activeDragElement = this.activeDragElement
|
||||
this.activeDragElement = null
|
||||
return activeDragElement?.onDragLeave(draggable)
|
||||
}
|
||||
|
||||
override fun onDragSuccess(draggable: Dragged): Element? {
|
||||
val activeDragElement = this.activeDragElement
|
||||
this.activeDragElement = null
|
||||
return activeDragElement?.onDragSuccess(draggable)
|
||||
}
|
||||
}
|
||||
|
@ -21,13 +21,15 @@ import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIElementDrawer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.Dragged
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.container.inventory.LocalInventoryScreen
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.pause.PauseMenu
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.DraggableHandler
|
||||
import de.bixilon.minosoft.gui.rendering.input.InputHandler
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.Drawable
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
@ -38,7 +40,7 @@ import glm_.vec2.Vec2i
|
||||
|
||||
class GUIManager(
|
||||
override val guiRenderer: GUIRenderer,
|
||||
) : Initializable, InputHandler, GUIElementDrawer {
|
||||
) : Initializable, InputHandler, GUIElementDrawer, DraggableHandler {
|
||||
private val elementCache: MutableMap<GUIBuilder<*>, GUIElement> = mutableMapOf()
|
||||
var elementOrder: MutableList<GUIElement> = mutableListOf()
|
||||
private val renderWindow = guiRenderer.renderWindow
|
||||
@ -78,7 +80,7 @@ class GUIManager(
|
||||
for (element in elementCache.values) {
|
||||
// ToDo: Just the current active one
|
||||
if (element is LayoutedGUIElement<*>) {
|
||||
element.elementLayout.forceSilentApply()
|
||||
element.element.forceSilentApply()
|
||||
}
|
||||
element.apply()
|
||||
}
|
||||
@ -140,52 +142,55 @@ class GUIManager(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCharPress(char: Int): Boolean {
|
||||
private fun runForEach(run: (element: GUIElement) -> Boolean): Boolean {
|
||||
for ((index, element) in elementOrder.toList().withIndex()) {
|
||||
if (index != 0 && !element.activeWhenHidden) {
|
||||
continue
|
||||
}
|
||||
if (element.onCharPress(char)) {
|
||||
if (run(element)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onCharPress(char: Int): Boolean {
|
||||
return runForEach { it.onCharPress(char) }
|
||||
}
|
||||
|
||||
override fun onMouseMove(position: Vec2i): Boolean {
|
||||
for ((index, element) in elementOrder.toList().withIndex()) {
|
||||
if (index != 0 && !element.activeWhenHidden) {
|
||||
continue
|
||||
}
|
||||
if (element.onMouseMove(position)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return runForEach { it.onMouseMove(position) }
|
||||
}
|
||||
|
||||
override fun onKeyPress(type: KeyChangeTypes, key: KeyCodes): Boolean {
|
||||
for ((index, element) in elementOrder.toList().withIndex()) {
|
||||
if (index != 0 && !element.activeWhenHidden) {
|
||||
continue
|
||||
}
|
||||
if (element.onKeyPress(type, key)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return runForEach { it.onKeyPress(type, key) }
|
||||
}
|
||||
|
||||
override fun onScroll(scrollOffset: Vec2d): Boolean {
|
||||
return runForEach { it.onScroll(scrollOffset) }
|
||||
}
|
||||
|
||||
private fun runForEachDrag(run: (element: GUIElement) -> Element?): Element? {
|
||||
for ((index, element) in elementOrder.toList().withIndex()) {
|
||||
if (index != 0 && !element.activeWhenHidden) {
|
||||
continue
|
||||
}
|
||||
if (element.onScroll(scrollOffset)) {
|
||||
return true
|
||||
}
|
||||
|
||||
run(element)?.let { return it }
|
||||
}
|
||||
return false
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onDragMove(position: Vec2i, draggable: Dragged): Element? {
|
||||
return runForEachDrag { it.onDragMove(position, draggable) }
|
||||
}
|
||||
|
||||
override fun onDragLeave(draggable: Dragged): Element? {
|
||||
return runForEachDrag { it.onDragLeave(draggable) }
|
||||
}
|
||||
|
||||
override fun onDragSuccess(draggable: Dragged): Element? {
|
||||
return runForEachDrag { it.onDragSuccess(draggable) }
|
||||
}
|
||||
|
||||
fun open(builder: GUIBuilder<*>) {
|
||||
@ -233,6 +238,7 @@ class GUIManager(
|
||||
if (elementOrder.isEmpty()) {
|
||||
renderWindow.inputHandler.inputHandler = null
|
||||
guiRenderer.popper.clear()
|
||||
guiRenderer.dragged.element = null
|
||||
}
|
||||
val now = elementOrder.firstOrNull() ?: return
|
||||
now.onOpen()
|
||||
@ -244,6 +250,7 @@ class GUIManager(
|
||||
}
|
||||
elementOrder.clear()
|
||||
guiRenderer.popper.clear()
|
||||
guiRenderer.dragged.element = null
|
||||
renderWindow.inputHandler.inputHandler = null
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -11,14 +11,13 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.hud.elements
|
||||
package de.bixilon.minosoft.gui.rendering.gui.gui
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.Dragged
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.input.mouse.MouseActions
|
||||
@ -27,22 +26,22 @@ import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMesh
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.Drawable
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.isOutside
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.util.collections.floats.DirectArrayFloatList
|
||||
import glm_.vec2.Vec2d
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class LayoutedGUIElement<T : LayoutedElement>(
|
||||
val layout: T,
|
||||
open class GUIMeshElement<T : Element>(
|
||||
val element: T,
|
||||
) : HUDElement, Drawable {
|
||||
val elementLayout = layout.unsafeCast<Element>()
|
||||
override val guiRenderer: GUIRenderer = elementLayout.guiRenderer
|
||||
override val guiRenderer: GUIRenderer = element.guiRenderer
|
||||
override val renderWindow: RenderWindow = guiRenderer.renderWindow
|
||||
var mesh: GUIMesh = GUIMesh(renderWindow, guiRenderer.matrix, DirectArrayFloatList(1000))
|
||||
private var lastRevision = 0L
|
||||
override val skipDraw: Boolean
|
||||
get() = if (layout is Drawable) layout.skipDraw else false
|
||||
private var lastPosition: Vec2i = Vec2i(-1, -1)
|
||||
get() = if (element is Drawable) element.skipDraw else false
|
||||
protected var lastRevision = 0L
|
||||
protected var lastPosition: Vec2i? = null
|
||||
protected var dragged = false
|
||||
override var enabled = true
|
||||
set(value) {
|
||||
if (field == value) {
|
||||
@ -50,33 +49,33 @@ class LayoutedGUIElement<T : LayoutedElement>(
|
||||
}
|
||||
field = value
|
||||
if (!value) {
|
||||
elementLayout.onClose()
|
||||
element.onClose()
|
||||
}
|
||||
}
|
||||
override val activeWhenHidden: Boolean
|
||||
get() = elementLayout.activeWhenHidden
|
||||
get() = element.activeWhenHidden
|
||||
|
||||
init {
|
||||
elementLayout.cache.data = mesh.data
|
||||
element.cache.data = mesh.data
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
elementLayout.tick()
|
||||
element.tick()
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
if (layout is Initializable) {
|
||||
layout.init()
|
||||
if (element is Initializable) {
|
||||
element.init()
|
||||
}
|
||||
}
|
||||
|
||||
override fun postInit() {
|
||||
if (layout is Initializable) {
|
||||
layout.postInit()
|
||||
if (element is Initializable) {
|
||||
element.postInit()
|
||||
}
|
||||
}
|
||||
|
||||
private fun createNewMesh() {
|
||||
protected fun createNewMesh() {
|
||||
val mesh = this.mesh
|
||||
if (mesh.state == Mesh.MeshStates.LOADED) {
|
||||
mesh.unload()
|
||||
@ -84,11 +83,10 @@ class LayoutedGUIElement<T : LayoutedElement>(
|
||||
this.mesh = GUIMesh(renderWindow, guiRenderer.matrix, mesh.data)
|
||||
}
|
||||
|
||||
fun prepare() {
|
||||
val layoutOffset = layout.layoutOffset
|
||||
elementLayout.render(layoutOffset, mesh, null)
|
||||
fun prepare(offset: Vec2i) {
|
||||
element.render(offset, mesh, null)
|
||||
|
||||
val revision = elementLayout.cache.revision
|
||||
val revision = element.cache.revision
|
||||
if (revision != lastRevision) {
|
||||
createNewMesh()
|
||||
this.mesh.load()
|
||||
@ -96,82 +94,73 @@ class LayoutedGUIElement<T : LayoutedElement>(
|
||||
}
|
||||
}
|
||||
|
||||
override fun draw() {
|
||||
if (layout is Drawable) {
|
||||
layout.draw()
|
||||
}
|
||||
open fun prepare() {
|
||||
prepare(Vec2i.EMPTY)
|
||||
}
|
||||
|
||||
override fun draw() {
|
||||
if (element is Drawable) {
|
||||
element.draw()
|
||||
}
|
||||
}
|
||||
|
||||
fun initMesh() {
|
||||
mesh.load()
|
||||
}
|
||||
|
||||
override fun onMouseMove(position: Vec2i): Boolean {
|
||||
val offset = layout.layoutOffset
|
||||
val size = elementLayout.size
|
||||
val lastPosition = lastPosition
|
||||
|
||||
if (position.isOutside(offset, offset + size)) {
|
||||
if (lastPosition == INVALID_MOUSE_POSITION) {
|
||||
return false
|
||||
}
|
||||
// move out
|
||||
this.lastPosition = INVALID_MOUSE_POSITION
|
||||
return elementLayout.onMouseLeave()
|
||||
}
|
||||
val delta = position - offset
|
||||
val previousOutside = lastPosition == INVALID_MOUSE_POSITION
|
||||
this.lastPosition = delta
|
||||
|
||||
if (previousOutside) {
|
||||
return elementLayout.onMouseEnter(delta, position)
|
||||
}
|
||||
|
||||
return elementLayout.onMouseMove(delta, position)
|
||||
override fun onCharPress(char: Int): Boolean {
|
||||
return element.onCharPress(char)
|
||||
}
|
||||
|
||||
override fun onCharPress(char: Int): Boolean {
|
||||
return elementLayout.onCharPress(char)
|
||||
override fun onMouseMove(position: Vec2i): Boolean {
|
||||
return element.onMouseMove(position, position)
|
||||
}
|
||||
|
||||
override fun onKeyPress(type: KeyChangeTypes, key: KeyCodes): Boolean {
|
||||
val mouseButton = MouseButtons[key] ?: return elementLayout.onKey(key, type)
|
||||
val mouseButton = MouseButtons[key] ?: return element.onKey(key, type)
|
||||
|
||||
val position = lastPosition
|
||||
if (position == INVALID_MOUSE_POSITION) {
|
||||
return false
|
||||
}
|
||||
val position = lastPosition ?: return false
|
||||
|
||||
val mouseAction = MouseActions[type] ?: return false
|
||||
return elementLayout.onMouseAction(position, mouseButton, mouseAction)
|
||||
return element.onMouseAction(position, mouseButton, mouseAction)
|
||||
}
|
||||
|
||||
override fun onScroll(scrollOffset: Vec2d): Boolean {
|
||||
val position = lastPosition
|
||||
if (lastPosition == INVALID_MOUSE_POSITION) {
|
||||
return false
|
||||
val position = lastPosition ?: return false
|
||||
return element.onScroll(position, scrollOffset)
|
||||
}
|
||||
|
||||
override fun onDragMove(position: Vec2i, draggable: Dragged): Element? {
|
||||
if (!dragged) {
|
||||
dragged = true
|
||||
element.onDragEnter(position, position, draggable)
|
||||
}
|
||||
return elementLayout.onScroll(position, scrollOffset)
|
||||
return element.onDragMove(position, position, draggable)
|
||||
}
|
||||
|
||||
override fun onDragLeave(draggable: Dragged): Element? {
|
||||
dragged = false
|
||||
return element.onDragLeave(draggable)
|
||||
}
|
||||
|
||||
override fun onDragSuccess(draggable: Dragged): Element? {
|
||||
dragged = false
|
||||
return element.onDragSuccess(draggable)
|
||||
}
|
||||
|
||||
override fun onClose() {
|
||||
elementLayout.onClose()
|
||||
elementLayout.onMouseLeave()
|
||||
lastPosition = INVALID_MOUSE_POSITION
|
||||
element.onClose()
|
||||
element.onMouseLeave()
|
||||
lastPosition = null
|
||||
}
|
||||
|
||||
override fun onOpen() {
|
||||
elementLayout.onOpen()
|
||||
element.onOpen()
|
||||
onMouseMove(guiRenderer.currentCursorPosition)
|
||||
}
|
||||
|
||||
override fun onHide() {
|
||||
elementLayout.onHide()
|
||||
elementLayout.onMouseLeave()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val INVALID_MOUSE_POSITION = Vec2i(-1, -1)
|
||||
element.onHide()
|
||||
element.onMouseLeave()
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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.gui.rendering.gui.gui
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.Dragged
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.isGreater
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.isSmaller
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class LayoutedGUIElement<T : LayoutedElement>(
|
||||
val layout: T,
|
||||
) : GUIMeshElement<Element>(layout.unsafeCast()) {
|
||||
protected var lastDragPosition: Vec2i? = null
|
||||
|
||||
override fun prepare() {
|
||||
prepare(layout.layoutOffset)
|
||||
}
|
||||
|
||||
private fun getOffset(position: Vec2i): Vec2i? {
|
||||
val layoutOffset = layout.layoutOffset
|
||||
val size = element.size
|
||||
if (position isSmaller layoutOffset) {
|
||||
return null
|
||||
}
|
||||
val offset = position - layoutOffset
|
||||
if (offset isGreater size) {
|
||||
return null
|
||||
}
|
||||
return offset
|
||||
}
|
||||
|
||||
override fun onMouseMove(position: Vec2i): Boolean {
|
||||
val lastPosition = lastPosition
|
||||
val offset = getOffset(position)
|
||||
if (offset == null) {
|
||||
if (lastPosition == null) {
|
||||
return false
|
||||
}
|
||||
// move out
|
||||
this.lastPosition = null
|
||||
return element.onMouseLeave()
|
||||
}
|
||||
|
||||
val previousOutside = lastPosition == null
|
||||
this.lastPosition = offset
|
||||
|
||||
if (previousOutside) {
|
||||
return element.onMouseEnter(offset, position)
|
||||
}
|
||||
|
||||
return element.onMouseMove(offset, position)
|
||||
}
|
||||
|
||||
override fun onDragMove(position: Vec2i, draggable: Dragged): Element? {
|
||||
val lastDragPosition = lastDragPosition
|
||||
val offset = getOffset(position)
|
||||
if (offset == null) {
|
||||
if (this.lastDragPosition == null) {
|
||||
return null
|
||||
}
|
||||
// move out
|
||||
this.lastDragPosition = null
|
||||
return element.onDragLeave(draggable)
|
||||
}
|
||||
|
||||
val previousOutside = lastDragPosition == null
|
||||
this.lastDragPosition = offset
|
||||
|
||||
if (previousOutside) {
|
||||
return element.onDragEnter(offset, position, draggable)
|
||||
}
|
||||
|
||||
return element.onDragMove(offset, position, draggable)
|
||||
}
|
||||
|
||||
override fun onDragLeave(draggable: Dragged): Element? {
|
||||
var element: Element? = null
|
||||
if (lastDragPosition != null) {
|
||||
element = this.element.onDragLeave(draggable)
|
||||
}
|
||||
lastDragPosition = null
|
||||
return element
|
||||
}
|
||||
|
||||
override fun onDragSuccess(draggable: Dragged): Element? {
|
||||
var element: Element? = null
|
||||
if (lastDragPosition != null) {
|
||||
element = this.element.onDragSuccess(draggable)
|
||||
}
|
||||
lastDragPosition = null
|
||||
return element
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.gui.dragged
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
abstract class Dragged(guiRenderer: GUIRenderer) : Element(guiRenderer) {
|
||||
val visible: Boolean
|
||||
get() = guiRenderer.dragged.element?.element === this
|
||||
|
||||
|
||||
open fun onDragStart(position: Vec2i, target: Element?) = Unit
|
||||
open fun onDragMove(position: Vec2i, target: Element?) = Unit
|
||||
open fun onDragEnd(position: Vec2i, target: Element?) = Unit
|
||||
open fun onDragSuccess(position: Vec2i, target: Element?) = Unit
|
||||
|
||||
fun show() {
|
||||
if (visible) {
|
||||
return
|
||||
}
|
||||
guiRenderer.dragged.element = DraggedGUIElement(this)
|
||||
}
|
||||
|
||||
fun close() {
|
||||
if (!visible) {
|
||||
return
|
||||
}
|
||||
guiRenderer.dragged.element = null
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.gui.rendering.gui.gui.dragged
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.GUIMeshElement
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class DraggedGUIElement<T : Dragged>(element: T) : GUIMeshElement<T>(element) {
|
||||
|
||||
override fun prepare() {
|
||||
prepare(guiRenderer.currentCursorPosition - (element.size / 2))
|
||||
}
|
||||
|
||||
override fun onMouseMove(position: Vec2i): Boolean {
|
||||
val element = guiRenderer.gui.onDragMove(position, element)
|
||||
this.element.onDragMove(position, element)
|
||||
return element != null
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-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.gui.rendering.gui.gui.dragged
|
||||
|
||||
import de.bixilon.kutil.time.TimeUtil
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIElementDrawer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.input.InputHandler
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.CursorModes
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class DraggedManager(
|
||||
override val guiRenderer: GUIRenderer,
|
||||
) : Initializable, InputHandler, GUIElementDrawer {
|
||||
var element: DraggedGUIElement<*>? = null
|
||||
set(value) {
|
||||
if (field == value || field?.element == value?.element) {
|
||||
return
|
||||
}
|
||||
val position = guiRenderer.currentCursorPosition
|
||||
field?.element?.onDragEnd(position, null) // ToDo
|
||||
field = value
|
||||
element?.element?.onDragStart(position, null) // ToDo
|
||||
applyCursor()
|
||||
}
|
||||
override var lastTickTime: Long = -1L
|
||||
|
||||
override fun init() {
|
||||
}
|
||||
|
||||
override fun postInit() {
|
||||
}
|
||||
|
||||
fun onMatrixChange() {
|
||||
element?.element?.forceSilentApply()
|
||||
}
|
||||
|
||||
private fun applyCursor() {
|
||||
val window = guiRenderer.renderWindow.window
|
||||
if (window.cursorMode == CursorModes.DISABLED) {
|
||||
return
|
||||
}
|
||||
window.cursorMode = if (element == null) CursorModes.NORMAL else CursorModes.HIDDEN
|
||||
}
|
||||
|
||||
fun draw() {
|
||||
val element = element ?: return
|
||||
val time = TimeUtil.time
|
||||
val tick = time - lastTickTime > ProtocolDefinition.TICK_TIME
|
||||
if (tick) {
|
||||
lastTickTime = time
|
||||
}
|
||||
if (!element.enabled) {
|
||||
return
|
||||
}
|
||||
if (tick) {
|
||||
element.tick()
|
||||
|
||||
lastTickTime = time
|
||||
}
|
||||
|
||||
if (!element.skipDraw) {
|
||||
element.draw()
|
||||
}
|
||||
element.prepare()
|
||||
|
||||
guiRenderer.setup()
|
||||
if (!element.enabled || element.mesh.data.isEmpty) {
|
||||
return
|
||||
}
|
||||
element.mesh.draw()
|
||||
}
|
||||
|
||||
override fun onCharPress(char: Int): Boolean {
|
||||
element?.onCharPress(char) ?: return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onMouseMove(position: Vec2i): Boolean {
|
||||
element?.onMouseMove(position) ?: return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onKeyPress(type: KeyChangeTypes, key: KeyCodes): Boolean {
|
||||
element?.onKeyPress(type, key) ?: return false
|
||||
return true
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.gui.rendering.gui.gui.dragged.elements.item
|
||||
|
||||
import de.bixilon.minosoft.data.inventory.stack.ItemStack
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.items.ItemElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.Dragged
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class FloatingItem(
|
||||
guiRenderer: GUIRenderer,
|
||||
val sourceId: Int,
|
||||
val stack: ItemStack,
|
||||
size: Vec2i = ItemElement.DEFAULT_SIZE,
|
||||
) : Dragged(guiRenderer) {
|
||||
private val itemElement = ItemElement(guiRenderer, size, stack, -1, null, this)
|
||||
|
||||
init {
|
||||
forceSilentApply()
|
||||
_size = size
|
||||
}
|
||||
|
||||
override fun forceRender(offset: Vec2i, consumer: GUIVertexConsumer, options: GUIVertexOptions?) {
|
||||
itemElement.render(offset, consumer, options)
|
||||
}
|
||||
|
||||
override fun forceSilentApply() {
|
||||
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.popper
|
||||
package de.bixilon.minosoft.gui.rendering.gui.gui.popper
|
||||
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
@ -27,8 +27,9 @@ import glm_.vec2.Vec2i
|
||||
abstract class Popper(
|
||||
guiRenderer: GUIRenderer,
|
||||
position: Vec2i,
|
||||
val background: Boolean = true,
|
||||
) : Element(guiRenderer), LayoutedElement {
|
||||
private val background = ColorElement(guiRenderer, Vec2i.EMPTY, color = RGBColor(10, 10, 20, 230))
|
||||
private val backgroundElement = ColorElement(guiRenderer, Vec2i.EMPTY, color = RGBColor(10, 10, 20, 230))
|
||||
open var dead = false
|
||||
override var layoutOffset: Vec2i = EMPTY
|
||||
protected set
|
||||
@ -42,12 +43,14 @@ abstract class Popper(
|
||||
}
|
||||
|
||||
override fun forceRender(offset: Vec2i, consumer: GUIVertexConsumer, options: GUIVertexOptions?) {
|
||||
background.render(offset, consumer, options)
|
||||
if (background) {
|
||||
backgroundElement.render(offset, consumer, options)
|
||||
}
|
||||
}
|
||||
|
||||
override fun forceSilentApply() {
|
||||
calculateLayoutOffset()
|
||||
background.size = size
|
||||
backgroundElement.size = size
|
||||
cacheUpToDate = false
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -11,14 +11,14 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.popper
|
||||
package de.bixilon.minosoft.gui.rendering.gui.gui.popper
|
||||
|
||||
import de.bixilon.kutil.time.TimeUtil
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIElementDrawer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.input.InputHandler
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
@ -11,7 +11,7 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.popper.item
|
||||
package de.bixilon.minosoft.gui.rendering.gui.gui.popper.item
|
||||
|
||||
import de.bixilon.minosoft.data.inventory.stack.ItemStack
|
||||
import de.bixilon.minosoft.data.text.BaseComponent
|
||||
@ -21,9 +21,9 @@ import de.bixilon.minosoft.data.text.TextComponent
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.popper.Popper
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.gui.popper.Popper
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class ItemInfoPopper(
|
@ -11,14 +11,14 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui.popper.text
|
||||
package de.bixilon.minosoft.gui.rendering.gui.gui.popper.text
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.popper.Popper
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.gui.popper.Popper
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
class TextPopper(
|
@ -39,6 +39,7 @@ abstract class ContainerScreen(
|
||||
private val containerBackground = AtlasImageElement(guiRenderer, background)
|
||||
protected val containerElement = ContainerItemsElement(guiRenderer, container, items).apply { parent = this@ContainerScreen }
|
||||
override var activeElement: Element? = null
|
||||
override var activeDragElement: Element? = null
|
||||
|
||||
override fun forceRender(offset: Vec2i, consumer: GUIVertexConsumer, options: GUIVertexOptions?) {
|
||||
super.forceRender(offset, consumer, options)
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.minosoft.config.key.KeyBinding
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.GUIBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
class LocalInventoryScreen(guiRenderer: GUIRenderer) : InventoryScreen(guiRenderer, guiRenderer.connection.player.inventory) {
|
||||
|
@ -37,6 +37,7 @@ abstract class Menu(
|
||||
private var totalHeight = -1
|
||||
|
||||
override var activeElement: Element? = null
|
||||
override var activeDragElement: Element? = null
|
||||
|
||||
override fun forceSilentApply() {
|
||||
val elementWidth = maxOf(minOf(preferredElementWidth, size.x / 3), 0)
|
||||
|
@ -20,8 +20,8 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.input.button.ButtonElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.spacer.SpacerElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.GUIBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.Menu
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||
import glm_.vec2.Vec2i
|
||||
import glm_.vec3.Vec3d
|
||||
|
@ -21,9 +21,9 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.input.button.NeutralizedBu
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.spacer.SpacerElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.GUIBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.Menu
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.debug.DebugMenu
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||
import de.bixilon.minosoft.util.ShutdownManager
|
||||
import glm_.vec2.Vec2i
|
||||
|
@ -22,8 +22,8 @@ import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIElementDrawer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.bossbar.BossbarLayout
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.chat.ChatElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.chat.InternalChatElement
|
||||
@ -76,7 +76,7 @@ class HUDManager(
|
||||
fun onMatrixChange() {
|
||||
for (element in hudElements.toSynchronizedMap().values) {
|
||||
if (element is LayoutedGUIElement<*>) {
|
||||
element.elementLayout.forceApply()
|
||||
element.element.forceApply()
|
||||
}
|
||||
element.apply()
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.layout.RowLayout
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.modding.event.events.bossbar.*
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
@ -30,6 +30,7 @@ abstract class AbstractChatElement(guiRenderer: GUIRenderer) : Element(guiRender
|
||||
protected val profile = connection.profiles.gui
|
||||
protected val messages = TextFlowElement(guiRenderer, 20000).apply { parent = this@AbstractChatElement }
|
||||
override var activeElement: Element? = null
|
||||
override var activeDragElement: Element? = null
|
||||
|
||||
override fun forceRender(offset: Vec2i, consumer: GUIVertexConsumer, options: GUIVertexOptions?) {
|
||||
messages.render(offset + Vec2i(ChatElement.CHAT_INPUT_MARGIN, 0), consumer, options)
|
||||
|
@ -24,9 +24,9 @@ import de.bixilon.minosoft.gui.rendering.font.Font
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.GUIBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.elements.input.TextInputElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
|
||||
|
@ -19,8 +19,8 @@ import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.GUIBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.modding.event.events.InternalMessageReceiveEvent
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
@ -25,9 +25,9 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments.Companion.getOffset
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.FadingTextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
|
@ -20,8 +20,8 @@ import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.Drawable
|
||||
|
@ -20,9 +20,9 @@ import de.bixilon.minosoft.gui.rendering.camera.target.targets.BlockTarget
|
||||
import de.bixilon.minosoft.gui.rendering.camera.target.targets.EntityTarget
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.CustomHUDElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMesh
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.BlendingFunctions
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
@ -35,9 +35,9 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.layout.grid.GridLayout
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.spacer.LineSpacerElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.AutoTextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
||||
|
@ -19,8 +19,8 @@ import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
|
@ -28,9 +28,9 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments.Compa
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ColorElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.Drawable
|
||||
|
@ -29,9 +29,9 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments.Compa
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.ColorElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.Drawable
|
||||
|
@ -20,9 +20,9 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments.Companion.getOffset
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.LayoutedElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.FadingTextElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.Initializable
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.HUDBuilder
|
||||
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.LayoutedGUIElement
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.gui.rendering.gui.input
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.Dragged
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
interface DraggableElement {
|
||||
|
||||
fun onDragEnter(position: Vec2i, absolute: Vec2i, draggable: Dragged): Element? = null
|
||||
fun onDragMove(position: Vec2i, absolute: Vec2i, draggable: Dragged): Element? = null
|
||||
fun onDragLeave(draggable: Dragged): Element? = null
|
||||
fun onDragSuccess(draggable: Dragged): Element? = null
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.gui.rendering.gui.input
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Element
|
||||
import de.bixilon.minosoft.gui.rendering.gui.gui.dragged.Dragged
|
||||
import glm_.vec2.Vec2i
|
||||
|
||||
interface DraggableHandler {
|
||||
|
||||
fun onDragMove(position: Vec2i, draggable: Dragged): Element? = null
|
||||
fun onDragLeave(draggable: Dragged): Element? = null
|
||||
fun onDragSuccess(draggable: Dragged): Element? = null
|
||||
}
|
@ -27,6 +27,4 @@ interface InputElement : MouseInputElement {
|
||||
|
||||
fun onKey(key: KeyCodes, type: KeyChangeTypes) = false
|
||||
fun onCharPress(char: Int) = false
|
||||
|
||||
// ToDo: drag
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user