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) {
|
||||
try {
|
||||
return runnable.invoke(assetManager)
|
||||
return runnable(assetManager)
|
||||
} catch (ignored: FileNotFoundException) {
|
||||
continue
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ abstract class Entity(
|
||||
if (values.containsKey(resourceLocation)) {
|
||||
continue
|
||||
}
|
||||
val methodRetValue = method.invoke(this) ?: continue
|
||||
val methodRetValue = method(this) ?: continue
|
||||
values[resourceLocation] = methodRetValue
|
||||
} catch (e: IllegalAccessException) {
|
||||
e.printStackTrace()
|
||||
|
@ -109,7 +109,7 @@ class VersionMapping {
|
||||
field = value
|
||||
|
||||
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)) {
|
||||
continue
|
||||
}
|
||||
field.javaClass.getMethod("clear").invoke(this)
|
||||
field.javaClass.getMethod("clear")(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class RenderWindowInputHandler(
|
||||
|
||||
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) {
|
||||
return
|
||||
}
|
||||
@ -186,7 +186,7 @@ class RenderWindowInputHandler(
|
||||
// Log.debug("Changing $resourceLocation because of $keyCode -> $thisKeyBindingDown")
|
||||
pair.lastChange = System.currentTimeMillis()
|
||||
for (callback in pair.callback) {
|
||||
callback.invoke(thisKeyBindingDown)
|
||||
callback(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) {
|
||||
return
|
||||
}
|
||||
@ -215,7 +215,7 @@ class RenderWindowInputHandler(
|
||||
currentKeyConsumer?.charInput(char.toChar())
|
||||
}
|
||||
|
||||
fun invoke(windowId: Long, xPos: Double, yPos: Double) {
|
||||
fun mouseMove(windowId: Long, xPos: Double, yPos: Double) {
|
||||
if (windowId != renderWindow.windowId) {
|
||||
return
|
||||
}
|
||||
@ -232,7 +232,7 @@ class RenderWindowInputHandler(
|
||||
if (currentKeyConsumer != null) {
|
||||
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)
|
||||
glfwSetCursorPosCallback(windowId, inputHandler::invoke)
|
||||
glfwSetCharCallback(windowId, inputHandler::charInput)
|
||||
glfwSetCursorPosCallback(windowId, inputHandler::mouseMove)
|
||||
|
||||
|
||||
registerGlobalKeyCombinations()
|
||||
|
@ -114,7 +114,7 @@ class TintColorCalculator(val world: World) {
|
||||
if (color == RenderConstants.WHITE_COLOR) {
|
||||
color = RenderConstants.GRASS_FAILOVER_COLOR
|
||||
}
|
||||
biome.grassColorModifier.modifier.invoke(color)
|
||||
biome.grassColorModifier.modifier(color)
|
||||
}
|
||||
TINTS[GRASS_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.data.text.ChatComponent
|
||||
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.primitive.LabelNode
|
||||
import de.bixilon.minosoft.util.MMath
|
||||
@ -27,7 +28,7 @@ open class TextField(
|
||||
val properties: TextFieldProperties,
|
||||
) : AbsoluteLayout(renderWindow), KeyConsumer, MouseConsumer {
|
||||
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
|
||||
|
||||
var text: String
|
||||
|
@ -82,12 +82,9 @@ open class AbsoluteLayout(
|
||||
}
|
||||
|
||||
private fun recalculateSize() {
|
||||
if (children.isEmpty()) {
|
||||
sizing.currentSize = Vec2i(sizing.minSize)
|
||||
} else {
|
||||
for ((childNode, start) in children) {
|
||||
checkSize(childNode, start)
|
||||
}
|
||||
sizing.currentSize = Vec2i(sizing.minSize)
|
||||
for ((childNode, start) in children) {
|
||||
checkSize(childNode, start)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,6 @@ class LabelNode(
|
||||
set(value) {
|
||||
field = value
|
||||
prepare()
|
||||
apply()
|
||||
}
|
||||
|
||||
var sText: String
|
||||
|
@ -21,8 +21,8 @@ class CallbackEventInvoker<E : Event> private constructor(
|
||||
override val eventType: Class<out Event>,
|
||||
) : EventInvoker(ignoreCancelled, Priorities.NORMAL, null) {
|
||||
|
||||
override fun invoke(event: Event) {
|
||||
callback.invoke(event as E)
|
||||
override operator fun invoke(event: Event) {
|
||||
callback(event as E)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -28,14 +28,14 @@ class EventInvokerMethod(
|
||||
|
||||
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)) {
|
||||
return
|
||||
}
|
||||
if (!this.isIgnoreCancelled && event is CancelableEvent && event.isCancelled) {
|
||||
return
|
||||
}
|
||||
method.invoke(listener, event)
|
||||
method(listener, event)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ abstract class Connection {
|
||||
fun fireEvent(connectionEvent: ConnectionEvent): Boolean {
|
||||
for (eventManager in Minosoft.EVENT_MANAGERS) {
|
||||
for (eventListener in eventManager.globalEventListeners) {
|
||||
eventListener.invoke(connectionEvent)
|
||||
eventListener(connectionEvent)
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ abstract class Connection {
|
||||
if (!eventInvoker.eventType.isAssignableFrom(connectionEvent::class.java)) {
|
||||
continue
|
||||
}
|
||||
eventInvoker.invoke(connectionEvent)
|
||||
eventInvoker(connectionEvent)
|
||||
}
|
||||
if (connectionEvent is CancelableEvent) {
|
||||
return connectionEvent.isCancelled
|
||||
|
@ -149,9 +149,9 @@ class StatusConnection(
|
||||
val wasPingDone = wasPingDone()
|
||||
if (method.eventType.isAssignableFrom(ServerListStatusArriveEvent::class.java) && wasPingDone) {
|
||||
// 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) {
|
||||
method.invoke(this.pong!!)
|
||||
method(this.pong!!)
|
||||
} else {
|
||||
super.registerEvent(method)
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ open class InByteBuffer {
|
||||
check(length <= size) { "Trying to allocate to much memory!" }
|
||||
val array: MutableList<T> = mutableListOf()
|
||||
for (i in 0 until length) {
|
||||
array.add(i, reader.invoke())
|
||||
array.add(i, reader())
|
||||
}
|
||||
return array.toTypedArray()
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ object Log {
|
||||
}
|
||||
}
|
||||
}
|
||||
log(logMessageType, level, additionalPrefix, messageBuilder.invoke())
|
||||
log(logMessageType, level, additionalPrefix, messageBuilder())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
Loading…
x
Reference in New Issue
Block a user