aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewerLibrary.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-07-01 03:42:51 +0200
committerLinnea Gräf <nea@nea.moe>2024-07-03 21:05:51 +0200
commit5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e (patch)
treea5b0a6fbc8878ae62bb2c3a01dbb255388353fda /src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewerLibrary.kt
parentdff1f9c0e2b728dba902d72816104abccc61f511 (diff)
downloadfirmament-5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e.tar.gz
firmament-5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e.tar.bz2
firmament-5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e.zip
[WIP] Remove LibGUI
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewerLibrary.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewerLibrary.kt71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewerLibrary.kt b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewerLibrary.kt
deleted file mode 100644
index 0c99f67..0000000
--- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/ProfileViewerLibrary.kt
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
- * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- */
-
-package moe.nea.firmament.gui.profileviewer
-
-import com.mojang.brigadier.StringReader
-import io.github.cottonmc.cotton.gui.client.CottonClientScreen
-import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription
-import io.github.cottonmc.cotton.gui.widget.WGridPanel
-import io.github.cottonmc.cotton.gui.widget.WText
-import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment
-import moe.nea.lisp.LispData
-import moe.nea.lisp.LispExecutionContext
-import moe.nea.lisp.LispParser
-import moe.nea.lisp.bind.AutoBinder
-import moe.nea.lisp.bind.LispBinding
-import moe.nea.lisp.bind.UnmapForeignObject
-import net.minecraft.command.argument.ItemStringReader
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
-import moe.nea.firmament.gui.WTitledItem
-import moe.nea.firmament.util.MC
-import moe.nea.firmament.util.ScreenUtil
-import moe.nea.firmament.util.item.setCustomName
-import moe.nea.firmament.util.modifyLore
-
-class ProfileViewerLibrary {
-
- @LispBinding("mk-item")
- fun makeItem(itemType: String, title: String, vararg lore: String): LispData.ForeignObject<ItemStack> {
- val item = ItemStringReader(MC.defaultRegistries).consume(StringReader(itemType))
- val itemStack = ItemStack(item.item.value())
- itemStack.applyComponentsFrom(item.components)
- itemStack.modifyLore { lore.map { Text.literal(it) } }
- itemStack.setCustomName(Text.literal(title))
- return LispData.ForeignObject(itemStack)
- }
-
- @LispBinding("def-page")
- fun defPage(name: String, @UnmapForeignObject icon: ItemStack) {
- pages.add(Pair(name, icon))
- }
-
- val pages = mutableListOf<Pair<String, ItemStack>>()
- val coreEnvironment = LispExecutionContext()
-
- fun run() {
- val t = coreEnvironment.genBindings()
- val ab = AutoBinder()
- ab.bindTo(this, t)
- val prog = LispParser.parse(
- "testfile.lisp", """
- (def-page "Test" (mk-item "minecraft:tnt" "§aThis is a test page" "§aMore text"))
- (def-page "Skills" (mk-item "minecraft:diamond_sword" "§aThis is a test page" "§aMore text"))
- """.trimIndent()
- )
- coreEnvironment.executeProgram(t, prog)
- val light = LightweightGuiDescription()
- val root = light.rootPanel as WGridPanel
- root.setGaps(8, 8)
- pages.forEachIndexed { i, (name, item) ->
- root.add(WTitledItem(item), 0, i)
- root.add(WText(Text.literal(name)).also { it.verticalAlignment = VerticalAlignment.CENTER }, 1, i, 6, 1)
- }
- ScreenUtil.setScreenLater(CottonClientScreen(light))
- }
-}