aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2023-11-12 04:29:53 +0100
committerLinnea Gräf <nea@nea.moe>2023-11-12 04:29:53 +0100
commitf5515b455d607ddda5b215a8c4c1df9ff03e4117 (patch)
tree4e0db3f0ae019f63abc8d0c0feb91195d9b6d760 /src/main/kotlin/moe/nea
parent15a20ef60a397e46021fdbcfc58a3f89214c500e (diff)
downloadFirmament-f5515b455d607ddda5b215a8c4c1df9ff03e4117.tar.gz
Firmament-f5515b455d607ddda5b215a8c4c1df9ff03e4117.tar.bz2
Firmament-f5515b455d607ddda5b215a8c4c1df9ff03e4117.zip
Add saving and loading to inventory button
Diffstat (limited to 'src/main/kotlin/moe/nea')
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/inventory/buttons/InventoryButtonEditor.kt28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/buttons/InventoryButtonEditor.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/buttons/InventoryButtonEditor.kt
index 982bf31..f269242 100644
--- a/src/main/kotlin/moe/nea/firmament/features/inventory/buttons/InventoryButtonEditor.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/inventory/buttons/InventoryButtonEditor.kt
@@ -1,22 +1,38 @@
package moe.nea.firmament.features.inventory.buttons
+import io.github.moulberry.moulconfig.common.IItemStack
import io.github.moulberry.moulconfig.xml.Bind
+import io.github.notenoughupdates.moulconfig.platform.ModernItemStack
import me.shedaniel.math.Dimension
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
import org.lwjgl.glfw.GLFW
import net.minecraft.client.gui.DrawContext
+import moe.nea.firmament.repo.ItemCache.asItemStack
+import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.MoulConfigUtils
+import moe.nea.firmament.util.SkyblockId
class InventoryButtonEditor(
val lastGuiRect: Rectangle,
) : FragmentGuiScreen() {
- class Editor {
+ class Editor(val originalButton: Button) {
@field:Bind
- var command: String = ""
+ var command: String = originalButton.command ?: ""
@field:Bind
- var icon: String = ""
+ var icon: String = originalButton.icon ?: ""
+
+ @Bind
+ fun getItemIcon(): IItemStack {
+ save()
+ return ModernItemStack.of(RepoManager.getNEUItem(SkyblockId(icon)).asItemStack(idHint = SkyblockId(icon)))
+ }
+
+ fun save() {
+ originalButton.icon = icon
+ originalButton.command = command
+ }
}
data class Button(
@@ -24,8 +40,8 @@ class InventoryButtonEditor(
val y: Int,
val anchorRight: Boolean,
val anchorBottom: Boolean,
- val icon: String?,
- val command: String?,
+ var icon: String?,
+ var command: String?,
) {
fun isValid() = !icon.isNullOrBlank() && !command.isNullOrBlank()
@@ -70,7 +86,7 @@ class InventoryButtonEditor(
if (super.mouseClicked(mouseX, mouseY, button)) return true
val clickedButton = buttons.firstOrNull { it.getBounds(lastGuiRect).contains(Point(mouseX, mouseY)) }
if (clickedButton != null) {
- createPopup(MoulConfigUtils.loadGui("button_editor_fragment", Editor()), Point(mouseX, mouseY))
+ createPopup(MoulConfigUtils.loadGui("button_editor_fragment", Editor(clickedButton)), Point(mouseX, mouseY))
return true
}
if (lastGuiRect.contains(mouseX, mouseY) || lastGuiRect.contains(Point(mouseX + 18, mouseY + 18))) return true