mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 01:16:46 -04:00
replace invoke functions with postfix functions
This commit is contained in:
parent
f94adbd3de
commit
c804ba9acb
@ -46,7 +46,7 @@ class MultiAssetsManager(
|
|||||||
|
|
||||||
for (assetManager in assetsManagers) {
|
for (assetManager in assetsManagers) {
|
||||||
try {
|
try {
|
||||||
return runnable.invoke(assetManager)
|
return runnable(assetManager)
|
||||||
} catch (ignored: FileNotFoundException) {
|
} catch (ignored: FileNotFoundException) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ abstract class Entity(
|
|||||||
if (values.containsKey(resourceLocation)) {
|
if (values.containsKey(resourceLocation)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val methodRetValue = method.invoke(this) ?: continue
|
val methodRetValue = method(this) ?: continue
|
||||||
values[resourceLocation] = methodRetValue
|
values[resourceLocation] = methodRetValue
|
||||||
} catch (e: IllegalAccessException) {
|
} catch (e: IllegalAccessException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
@ -109,7 +109,7 @@ class VersionMapping {
|
|||||||
field = value
|
field = value
|
||||||
|
|
||||||
for (parentableField in PARENTABLE_FIELDS) {
|
for (parentableField in PARENTABLE_FIELDS) {
|
||||||
PARENTABLE_SET_PARENT_METHOD.invoke(parentableField.get(this), value?.let { parentableField.get(it) })
|
PARENTABLE_SET_PARENT_METHOD(parentableField.get(this), value?.let { parentableField.get(it) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ class VersionMapping {
|
|||||||
if (!field.type.isAssignableFrom(Clearable::class.java)) {
|
if (!field.type.isAssignableFrom(Clearable::class.java)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
field.javaClass.getMethod("clear").invoke(this)
|
field.javaClass.getMethod("clear")(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class RenderWindowInputHandler(
|
|||||||
|
|
||||||
var currentKeyConsumer: KeyConsumer? = null
|
var currentKeyConsumer: KeyConsumer? = null
|
||||||
|
|
||||||
fun invoke(windowId: Long, key: Int, char: Int, action: Int, modifierKey: Int) {
|
fun keyInput(windowId: Long, key: Int, char: Int, action: Int, modifierKey: Int) {
|
||||||
if (windowId != renderWindow.windowId) {
|
if (windowId != renderWindow.windowId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ class RenderWindowInputHandler(
|
|||||||
// Log.debug("Changing $resourceLocation because of $keyCode -> $thisKeyBindingDown")
|
// Log.debug("Changing $resourceLocation because of $keyCode -> $thisKeyBindingDown")
|
||||||
pair.lastChange = System.currentTimeMillis()
|
pair.lastChange = System.currentTimeMillis()
|
||||||
for (callback in pair.callback) {
|
for (callback in pair.callback) {
|
||||||
callback.invoke(thisKeyBindingDown)
|
callback(thisKeyBindingDown)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thisKeyBindingDown) {
|
if (thisKeyBindingDown) {
|
||||||
@ -204,7 +204,7 @@ class RenderWindowInputHandler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun invoke(windowId: Long, char: Int) {
|
fun charInput(windowId: Long, char: Int) {
|
||||||
if (windowId != renderWindow.windowId) {
|
if (windowId != renderWindow.windowId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ class RenderWindowInputHandler(
|
|||||||
currentKeyConsumer?.charInput(char.toChar())
|
currentKeyConsumer?.charInput(char.toChar())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun invoke(windowId: Long, xPos: Double, yPos: Double) {
|
fun mouseMove(windowId: Long, xPos: Double, yPos: Double) {
|
||||||
if (windowId != renderWindow.windowId) {
|
if (windowId != renderWindow.windowId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -232,7 +232,7 @@ class RenderWindowInputHandler(
|
|||||||
if (currentKeyConsumer != null) {
|
if (currentKeyConsumer != null) {
|
||||||
return@add
|
return@add
|
||||||
}
|
}
|
||||||
callback.invoke(it)
|
callback(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,10 +253,10 @@ class RenderWindow(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
glfwSetKeyCallback(this.windowId, inputHandler::invoke)
|
glfwSetKeyCallback(this.windowId, inputHandler::keyInput)
|
||||||
|
|
||||||
glfwSetCharCallback(windowId, inputHandler::invoke)
|
glfwSetCharCallback(windowId, inputHandler::charInput)
|
||||||
glfwSetCursorPosCallback(windowId, inputHandler::invoke)
|
glfwSetCursorPosCallback(windowId, inputHandler::mouseMove)
|
||||||
|
|
||||||
|
|
||||||
registerGlobalKeyCombinations()
|
registerGlobalKeyCombinations()
|
||||||
|
@ -114,7 +114,7 @@ class TintColorCalculator(val world: World) {
|
|||||||
if (color == RenderConstants.WHITE_COLOR) {
|
if (color == RenderConstants.WHITE_COLOR) {
|
||||||
color = RenderConstants.GRASS_FAILOVER_COLOR
|
color = RenderConstants.GRASS_FAILOVER_COLOR
|
||||||
}
|
}
|
||||||
biome.grassColorModifier.modifier.invoke(color)
|
biome.grassColorModifier.modifier(color)
|
||||||
}
|
}
|
||||||
TINTS[GRASS_TINT_RESOURCE_LOCATION] = grassTintCalculator
|
TINTS[GRASS_TINT_RESOURCE_LOCATION] = grassTintCalculator
|
||||||
TINTS[SUGAR_CANE_TINT_RESOURCE_LOCATION] = grassTintCalculator
|
TINTS[SUGAR_CANE_TINT_RESOURCE_LOCATION] = grassTintCalculator
|
||||||
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.rendering.hud.elements.input
|
|||||||
import de.bixilon.minosoft.config.key.KeyCodes
|
import de.bixilon.minosoft.config.key.KeyCodes
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||||
|
import de.bixilon.minosoft.gui.rendering.font.text.TextSetProperties
|
||||||
import de.bixilon.minosoft.gui.rendering.hud.nodes.layout.AbsoluteLayout
|
import de.bixilon.minosoft.gui.rendering.hud.nodes.layout.AbsoluteLayout
|
||||||
import de.bixilon.minosoft.gui.rendering.hud.nodes.primitive.LabelNode
|
import de.bixilon.minosoft.gui.rendering.hud.nodes.primitive.LabelNode
|
||||||
import de.bixilon.minosoft.util.MMath
|
import de.bixilon.minosoft.util.MMath
|
||||||
@ -27,7 +28,7 @@ open class TextField(
|
|||||||
val properties: TextFieldProperties,
|
val properties: TextFieldProperties,
|
||||||
) : AbsoluteLayout(renderWindow), KeyConsumer, MouseConsumer {
|
) : AbsoluteLayout(renderWindow), KeyConsumer, MouseConsumer {
|
||||||
private var textBuilder: StringBuilder = StringBuilder(properties.defaultText)
|
private var textBuilder: StringBuilder = StringBuilder(properties.defaultText)
|
||||||
val textElement = LabelNode(renderWindow, sizing = sizing, text = ChatComponent.of(text), background = false)
|
val textElement = LabelNode(renderWindow, sizing = sizing.copy(), setProperties = TextSetProperties(hardWrap = 100), text = ChatComponent.of(text), background = false)
|
||||||
private var position = text.length
|
private var position = text.length
|
||||||
|
|
||||||
var text: String
|
var text: String
|
||||||
|
@ -82,12 +82,9 @@ open class AbsoluteLayout(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun recalculateSize() {
|
private fun recalculateSize() {
|
||||||
if (children.isEmpty()) {
|
sizing.currentSize = Vec2i(sizing.minSize)
|
||||||
sizing.currentSize = Vec2i(sizing.minSize)
|
for ((childNode, start) in children) {
|
||||||
} else {
|
checkSize(childNode, start)
|
||||||
for ((childNode, start) in children) {
|
|
||||||
checkSize(childNode, start)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ class LabelNode(
|
|||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
prepare()
|
prepare()
|
||||||
apply()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var sText: String
|
var sText: String
|
||||||
|
@ -21,8 +21,8 @@ class CallbackEventInvoker<E : Event> private constructor(
|
|||||||
override val eventType: Class<out Event>,
|
override val eventType: Class<out Event>,
|
||||||
) : EventInvoker(ignoreCancelled, Priorities.NORMAL, null) {
|
) : EventInvoker(ignoreCancelled, Priorities.NORMAL, null) {
|
||||||
|
|
||||||
override fun invoke(event: Event) {
|
override operator fun invoke(event: Event) {
|
||||||
callback.invoke(event as E)
|
callback(event as E)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -28,14 +28,14 @@ class EventInvokerMethod(
|
|||||||
|
|
||||||
constructor(annotation: EventHandler, listener: EventListener, method: Method) : this(annotation.ignoreCancelled, annotation.priority, listener, method)
|
constructor(annotation: EventHandler, listener: EventListener, method: Method) : this(annotation.ignoreCancelled, annotation.priority, listener, method)
|
||||||
|
|
||||||
override fun invoke(event: Event) {
|
override operator fun invoke(event: Event) {
|
||||||
if (!method.parameters[0].type.isAssignableFrom(event.javaClass)) {
|
if (!method.parameters[0].type.isAssignableFrom(event.javaClass)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.isIgnoreCancelled && event is CancelableEvent && event.isCancelled) {
|
if (!this.isIgnoreCancelled && event is CancelableEvent && event.isCancelled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
method.invoke(listener, event)
|
method(listener, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ abstract class Connection {
|
|||||||
fun fireEvent(connectionEvent: ConnectionEvent): Boolean {
|
fun fireEvent(connectionEvent: ConnectionEvent): Boolean {
|
||||||
for (eventManager in Minosoft.EVENT_MANAGERS) {
|
for (eventManager in Minosoft.EVENT_MANAGERS) {
|
||||||
for (eventListener in eventManager.globalEventListeners) {
|
for (eventListener in eventManager.globalEventListeners) {
|
||||||
eventListener.invoke(connectionEvent)
|
eventListener(connectionEvent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ abstract class Connection {
|
|||||||
if (!eventInvoker.eventType.isAssignableFrom(connectionEvent::class.java)) {
|
if (!eventInvoker.eventType.isAssignableFrom(connectionEvent::class.java)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
eventInvoker.invoke(connectionEvent)
|
eventInvoker(connectionEvent)
|
||||||
}
|
}
|
||||||
if (connectionEvent is CancelableEvent) {
|
if (connectionEvent is CancelableEvent) {
|
||||||
return connectionEvent.isCancelled
|
return connectionEvent.isCancelled
|
||||||
|
@ -149,9 +149,9 @@ class StatusConnection(
|
|||||||
val wasPingDone = wasPingDone()
|
val wasPingDone = wasPingDone()
|
||||||
if (method.eventType.isAssignableFrom(ServerListStatusArriveEvent::class.java) && wasPingDone) {
|
if (method.eventType.isAssignableFrom(ServerListStatusArriveEvent::class.java) && wasPingDone) {
|
||||||
// ping done
|
// ping done
|
||||||
method.invoke(ServerListStatusArriveEvent(this, this.lastPing))
|
method(ServerListStatusArriveEvent(this, this.lastPing))
|
||||||
} else if (method.eventType.isAssignableFrom(ServerListPongEvent::class.java) && wasPingDone && this.pong != null) {
|
} else if (method.eventType.isAssignableFrom(ServerListPongEvent::class.java) && wasPingDone && this.pong != null) {
|
||||||
method.invoke(this.pong!!)
|
method(this.pong!!)
|
||||||
} else {
|
} else {
|
||||||
super.registerEvent(method)
|
super.registerEvent(method)
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ open class InByteBuffer {
|
|||||||
check(length <= size) { "Trying to allocate to much memory!" }
|
check(length <= size) { "Trying to allocate to much memory!" }
|
||||||
val array: MutableList<T> = mutableListOf()
|
val array: MutableList<T> = mutableListOf()
|
||||||
for (i in 0 until length) {
|
for (i in 0 until length) {
|
||||||
array.add(i, reader.invoke())
|
array.add(i, reader())
|
||||||
}
|
}
|
||||||
return array.toTypedArray()
|
return array.toTypedArray()
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ object Log {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log(logMessageType, level, additionalPrefix, messageBuilder.invoke())
|
log(logMessageType, level, additionalPrefix, messageBuilder())
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user