diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/features/inventory/buttons/InventoryButtonEditor.kt | 28 |
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 |