feat: Add /firm search command
This commit is contained in:
@@ -6,6 +6,6 @@ import moe.nea.firmament.gui.config.AllConfigsGui
|
|||||||
|
|
||||||
class FirmamentModMenuPlugin : ModMenuApi {
|
class FirmamentModMenuPlugin : ModMenuApi {
|
||||||
override fun getModConfigScreenFactory(): ConfigScreenFactory<*> {
|
override fun getModConfigScreenFactory(): ConfigScreenFactory<*> {
|
||||||
return ConfigScreenFactory { AllConfigsGui.makeScreen(it) }
|
return ConfigScreenFactory { AllConfigsGui.makeScreen(parent = it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider {
|
|||||||
val mappedSetter = setter.xmap(fromT, toT)
|
val mappedSetter = setter.xmap(fromT, toT)
|
||||||
|
|
||||||
private val delegateI by lazy {
|
private val delegateI by lazy {
|
||||||
wrapComponent(RowComponent(
|
wrapComponent(
|
||||||
|
RowComponent(
|
||||||
AlignComponent(
|
AlignComponent(
|
||||||
TextComponent(
|
TextComponent(
|
||||||
IMinecraft.instance.defaultFontRenderer,
|
IMinecraft.instance.defaultFontRenderer,
|
||||||
@@ -114,7 +115,8 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider {
|
|||||||
minStep,
|
minStep,
|
||||||
40
|
40
|
||||||
)
|
)
|
||||||
))
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +304,6 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun open(parent: Screen?): Screen {
|
|
||||||
val configObject = object : Config() {
|
val configObject = object : Config() {
|
||||||
override fun saveNow() {
|
override fun saveNow() {
|
||||||
ManagedConfig.allManagedConfigs.getAll().forEach { it.save() }
|
ManagedConfig.allManagedConfigs.getAll().forEach { it.save() }
|
||||||
@@ -341,12 +342,18 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val socials = listOf<Social>(
|
private val socials = listOf<Social>(
|
||||||
mkSocial("Discord", Firmament.identifier("textures/socials/discord.png"),
|
mkSocial(
|
||||||
Firmament.modContainer.metadata.contact.get("discord").get()),
|
"Discord", Firmament.identifier("textures/socials/discord.png"),
|
||||||
mkSocial("Source Code", Firmament.identifier("textures/socials/git.png"),
|
Firmament.modContainer.metadata.contact.get("discord").get()
|
||||||
Firmament.modContainer.metadata.contact.get("sources").get()),
|
),
|
||||||
mkSocial("Modrinth", Firmament.identifier("textures/socials/modrinth.png"),
|
mkSocial(
|
||||||
Firmament.modContainer.metadata.contact.get("modrinth").get()),
|
"Source Code", Firmament.identifier("textures/socials/git.png"),
|
||||||
|
Firmament.modContainer.metadata.contact.get("sources").get()
|
||||||
|
),
|
||||||
|
mkSocial(
|
||||||
|
"Modrinth", Firmament.identifier("textures/socials/modrinth.png"),
|
||||||
|
Firmament.modContainer.metadata.contact.get("modrinth").get()
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun getSocials(): List<Social> {
|
override fun getSocials(): List<Social> {
|
||||||
@@ -395,7 +402,11 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider {
|
|||||||
|
|
||||||
return@map ProcessedCategoryFirm(it, options)
|
return@map ProcessedCategoryFirm(it, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun open(search: String?, parent: Screen?): Screen {
|
||||||
val editor = MoulConfigEditor(ProcessedCategory.collect(categories), configObject)
|
val editor = MoulConfigEditor(ProcessedCategory.collect(categories), configObject)
|
||||||
|
if (search != null)
|
||||||
|
editor.search(search)
|
||||||
return GuiElementWrapper(editor) // TODO : add parent support
|
return GuiElementWrapper(editor) // TODO : add parent support
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class YaclIntegration : FirmamentConfigScreenProvider {
|
|||||||
override val key: String
|
override val key: String
|
||||||
get() = "yacl"
|
get() = "yacl"
|
||||||
|
|
||||||
override fun open(parent: Screen?): Screen {
|
override fun open(search: String?, parent: Screen?): Screen {
|
||||||
return object : YACLScreen(buildConfig(), parent) {
|
return object : YACLScreen(buildConfig(), parent) {
|
||||||
override fun setFocused(focused: Element?) {
|
override fun setFocused(focused: Element?) {
|
||||||
if (this.focused is KeybindingWidget &&
|
if (this.focused is KeybindingWidget &&
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ import io.github.notenoughupdates.moulconfig.observer.ObservableList
|
|||||||
import io.github.notenoughupdates.moulconfig.xml.Bind
|
import io.github.notenoughupdates.moulconfig.xml.Bind
|
||||||
import net.minecraft.client.gui.screen.Screen
|
import net.minecraft.client.gui.screen.Screen
|
||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
|
import moe.nea.firmament.annotations.Subscribe
|
||||||
|
import moe.nea.firmament.commands.RestArgumentType
|
||||||
|
import moe.nea.firmament.commands.get
|
||||||
|
import moe.nea.firmament.commands.thenArgument
|
||||||
|
import moe.nea.firmament.commands.thenExecute
|
||||||
|
import moe.nea.firmament.events.CommandEvent
|
||||||
import moe.nea.firmament.util.MC
|
import moe.nea.firmament.util.MC
|
||||||
import moe.nea.firmament.util.MoulConfigUtils
|
import moe.nea.firmament.util.MoulConfigUtils
|
||||||
import moe.nea.firmament.util.ScreenUtil.setScreenLater
|
import moe.nea.firmament.util.ScreenUtil.setScreenLater
|
||||||
@@ -66,7 +72,7 @@ object AllConfigsGui {
|
|||||||
return MoulConfigUtils.loadScreen("config/main", CategoryView(), parent)
|
return MoulConfigUtils.loadScreen("config/main", CategoryView(), parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun makeScreen(parent: Screen? = null): Screen {
|
fun makeScreen(search: String? = null, parent: Screen? = null): Screen {
|
||||||
val wantedKey = when {
|
val wantedKey = when {
|
||||||
ConfigConfig.enableMoulConfig -> "moulconfig"
|
ConfigConfig.enableMoulConfig -> "moulconfig"
|
||||||
ConfigConfig.enableYacl -> "yacl"
|
ConfigConfig.enableYacl -> "yacl"
|
||||||
@@ -74,10 +80,23 @@ object AllConfigsGui {
|
|||||||
}
|
}
|
||||||
val provider = FirmamentConfigScreenProvider.providers.find { it.key == wantedKey }
|
val provider = FirmamentConfigScreenProvider.providers.find { it.key == wantedKey }
|
||||||
?: FirmamentConfigScreenProvider.providers.first()
|
?: FirmamentConfigScreenProvider.providers.first()
|
||||||
return provider.open(parent)
|
return provider.open(search, parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showAllGuis() {
|
fun showAllGuis() {
|
||||||
setScreenLater(makeScreen())
|
setScreenLater(makeScreen())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
fun registerCommands(event: CommandEvent.SubCommand) {
|
||||||
|
event.subcommand("search") {
|
||||||
|
thenArgument("search", RestArgumentType) { search ->
|
||||||
|
thenExecute {
|
||||||
|
val search = this[search]
|
||||||
|
setScreenLater(makeScreen(search = search))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class BuiltInConfigScreenProvider : FirmamentConfigScreenProvider {
|
|||||||
override val key: String
|
override val key: String
|
||||||
get() = "builtin"
|
get() = "builtin"
|
||||||
|
|
||||||
override fun open(parent: Screen?): Screen {
|
override fun open(search: String?, parent: Screen?): Screen {
|
||||||
return AllConfigsGui.makeBuiltInScreen(parent)
|
return AllConfigsGui.makeBuiltInScreen(parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ interface FirmamentConfigScreenProvider {
|
|||||||
val key: String
|
val key: String
|
||||||
val isEnabled: Boolean get() = true
|
val isEnabled: Boolean get() = true
|
||||||
|
|
||||||
fun open(parent: Screen?): Screen
|
fun open(search: String?, parent: Screen?): Screen
|
||||||
|
|
||||||
companion object : CompatLoader<FirmamentConfigScreenProvider>(FirmamentConfigScreenProvider::class) {
|
companion object : CompatLoader<FirmamentConfigScreenProvider>(FirmamentConfigScreenProvider::class) {
|
||||||
val providers by lazy {
|
val providers by lazy {
|
||||||
|
|||||||
Reference in New Issue
Block a user