diff options
author | inglettronald <inglettronald@gmail.com> | 2023-06-30 03:55:49 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-06-30 03:55:49 -0500 |
commit | cd7b08b4799b5ee08f1dca6ff92a28e74d9db102 (patch) | |
tree | 86691df35e72dc3d4e15891f049e1edbc8a2bc3a /src/main/kotlin | |
parent | f01846879e226b932d81fa842e4eee4567f0a28c (diff) | |
download | DulkirMod-Fabric-cd7b08b4799b5ee08f1dca6ff92a28e74d9db102.tar.gz DulkirMod-Fabric-cd7b08b4799b5ee08f1dca6ff92a28e74d9db102.tar.bz2 DulkirMod-Fabric-cd7b08b4799b5ee08f1dca6ff92a28e74d9db102.zip |
Added Alias Code And Implemented Dynamic Key
Diffstat (limited to 'src/main/kotlin')
3 files changed, 65 insertions, 9 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt index da9f2d8..4fb42a8 100644 --- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt +++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt @@ -17,6 +17,7 @@ import com.dulkirfabric.DulkirModFabric.mc import com.dulkirfabric.config.ConfigHelper.mkKeyField import com.dulkirfabric.config.ConfigHelper.mkStringField import com.dulkirfabric.config.ConfigHelper.mkToggle +import com.dulkirfabric.features.InventoryScale import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers import kotlinx.serialization.decodeFromString @@ -57,7 +58,19 @@ class DulkirConfig { general.addEntry( entryBuilder.startFloatField(Text.literal("Inventory Scale"), configOptions.inventoryScale) .setTooltip(Text.literal("Size of GUI whenever you're in an inventory screen")) - .setSaveConsumer { newValue -> configOptions.inventoryScale = newValue } + .setSaveConsumer { newValue -> + configOptions.inventoryScale = newValue + InventoryScale.scaleBuffer = newValue + InventoryScale.prevTickScale = newValue + InventoryScale.tickScale = newValue + InventoryScale.frameScale = newValue + } + .build() + ) + general.addEntry( + entryBuilder.startFloatField(Text.literal("Tooltip Scale"), configOptions.tooltipScale) + .setTooltip(Text.literal("Default Value for Scaling a particular tooltip without scroll input")) + .setSaveConsumer { newValue -> configOptions.tooltipScale = newValue } .build() ) general.addEntry( @@ -102,6 +115,22 @@ class DulkirConfig { ) ) + val aliases = builder.getOrCreateCategory(Text.literal("Shortcuts")) + aliases.addEntry( + ConfigHelper.mkConfigList( + Text.literal("Aliases (do not include '/')"), + configOptions::aliasList, + { Alias("", "") }, + Text.literal("Alias"), + { value -> + listOf( + entryBuilder.mkStringField(Text.literal("Command"), value::command), + entryBuilder.mkStringField(Text.literal("Alias"), value::alias) + ) + } + ) + ) + builder.transparentBackground() screen = builder.build() } @@ -111,13 +140,15 @@ class DulkirConfig { var invScaleBool: Boolean = false, var inventoryScale: Float = 1f, var macrosList: List<Macro> = listOf(Macro(UNKNOWN_KEY, "")), + var aliasList: List<Alias> = listOf(Alias("", "")), var ignoreReverseThirdPerson: Boolean = false, var dynamicKey: InputUtil.Key = UNKNOWN_KEY, var customBlockOutlines: Boolean = false, var blockOutlineThickness: Int = 3, var blockOutlineColor: Int = 0xFFFFFF, var abiPhoneDND: Boolean = false, - var abiPhoneCallerID: Boolean = false + var abiPhoneCallerID: Boolean = false, + var tooltipScale: Float = 1f ) @Serializable @@ -126,6 +157,12 @@ class DulkirConfig { var command: String, ) + @Serializable + data class Alias( + var alias: String, + var command: String + ) + /** * Object for storing all the actual config values that will be used in doing useful stuff with the config */ diff --git a/src/main/kotlin/com/dulkirfabric/features/AliasImpl.kt b/src/main/kotlin/com/dulkirfabric/features/AliasImpl.kt new file mode 100644 index 0000000..2e552e7 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/features/AliasImpl.kt @@ -0,0 +1,16 @@ +package com.dulkirfabric.features + +import com.dulkirfabric.config.DulkirConfig +import com.dulkirfabric.events.chat.ModifyCommandEvent +import meteordevelopment.orbit.EventHandler + +object AliasImpl { + @EventHandler + fun onCommand(event: ModifyCommandEvent) { + DulkirConfig.configOptions.aliasList.forEach { + if (it.alias == event.command) { + event.command = it.command + } + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt b/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt index fdca658..8e2112a 100644 --- a/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt +++ b/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt @@ -1,5 +1,6 @@ package com.dulkirfabric.features +import com.dulkirfabric.commands.DynamicKeyCommand import com.dulkirfabric.config.DulkirConfig import com.dulkirfabric.events.WorldKeyPressEvent import com.dulkirfabric.util.TextUtils @@ -20,14 +21,16 @@ object KeyShortCutImpl { lastCommandHandle = System.currentTimeMillis() prevCode = event.key - // This conditional allows for these shortcuts to work for commands or normal messages - // You have to do it this way because the messages are handled differently on the client - // side in modern versions of Minecraft. - if (it.command.startsWith("/")) - TextUtils.sendCommand(it.command.substring(1)) - else - TextUtils.sendMessage(it.command) + TextUtils.sendCommand(it.command.trimStart('/')) } } + + if (DulkirConfig.configOptions.dynamicKey.code == event.key) { + if (event.key == prevCode && System.currentTimeMillis() - lastCommandHandle < 1000) + return + lastCommandHandle = System.currentTimeMillis() + prevCode = event.key + TextUtils.sendCommand(DynamicKeyCommand.command.trimStart('/')) + } } }
\ No newline at end of file |