Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
59b250f
Initial work on quilt support
anonymous123-code Mar 27, 2023
fcdc9d6
Gradle template fixes
anonymous123-code Mar 27, 2023
a6ebe7b
Properly add Quilt to Facet editor
anonymous123-code Mar 27, 2023
f52bf80
Add Templates to template editor
anonymous123-code Mar 27, 2023
4f48c2f
Fix generated qmj
anonymous123-code Mar 27, 2023
5810f9a
Dont generate client Entry Point on Server-Only mods
anonymous123-code Mar 27, 2023
d8e7fd2
Fix environment information in QMJ
anonymous123-code Mar 27, 2023
3fa28cf
Fix entrypoint name detected as name listener
anonymous123-code Mar 27, 2023
be2ecc5
QMJ template fix: use artifact id in mod icon path
anonymous123-code Mar 28, 2023
76f9ac1
Temp fix: remove gradle wrapper step to avoid sync and wrapper runnin…
anonymous123-code Mar 28, 2023
2a958a3
Fix: metadata is now properly filled
anonymous123-code Mar 28, 2023
76a1ad2
Fix formatting
anonymous123-code Mar 28, 2023
66953fe
Forgot some licenses
anonymous123-code Mar 28, 2023
93dde67
Some more formatting
anonymous123-code Mar 28, 2023
cf06e2f
Merge branch 'minecraft-dev:dev' into quilt
anonymous123-code Apr 13, 2023
bf81f89
Fix for https://github.com/QuiltMC/update-quilt-meta/issues/9
anonymous123-code Apr 13, 2023
9765754
Readd gradle wrapper step as it seems to be fixed since the merge
anonymous123-code Apr 18, 2023
df4142f
Revert "Fix for https://github.com/QuiltMC/update-quilt-meta/issues/9…
anonymous123-code Apr 18, 2023
e0b69e4
Merge remote-tracking branch 'super/dev' into quilt
anonymous123-code Apr 18, 2023
62651ed
Add Standard Library selector
anonymous123-code Apr 19, 2023
f4c1bab
Properly store changes to the authors input
anonymous123-code Apr 19, 2023
fe0a0a6
Refactor: Move row init inside init blocks
anonymous123-code Apr 19, 2023
00ef5a9
Refactor: Move row init inside init blocks
anonymous123-code Apr 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Standard Library selector
uses a segmented button, allows for QSL selection, but warns that it isnt supported and disables version selection
  • Loading branch information
anonymous123-code committed Apr 19, 2023
commit 62651ed87d2c6aed16e39aa831934edd112c040b
7 changes: 6 additions & 1 deletion src/main/kotlin/platform/quilt/creator/asset-steps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class QuiltSmartModeFilesStep(parent: NewProjectWizardStep) : AbstractLongRunnin
val mcVersion = data.getUserData(QuiltVersionChainStep.MC_VERSION_KEY) ?: return
val javaVersion = findStep<JdkProjectSetupFinalizer>().preferredJdk.ordinal
val license = data.getUserData(LicenseStep.KEY) ?: return
val apiVersion = data.getUserData(QuiltVersionChainStep.API_VERSION_KEY)
val apiVersion = data.getUserData(QuiltStandardLibrariesStep.API_VERSION_KEY)
val apiName = data.getUserData(QuiltStandardLibrariesStep.API_NAME_KEY)
val useMixins = data.getUserData(UseMixinsStep.KEY) ?: false

val packageName = "${buildSystemProps.groupId.toPackageName()}.${buildSystemProps.artifactId.toPackageName()}"
Expand Down Expand Up @@ -144,6 +145,10 @@ class QuiltSmartModeFilesStep(parent: NewProjectWizardStep) : AbstractLongRunnin
assets.addTemplateProperties("API_VERSION" to apiVersion)
}

if (apiName != null) {
assets.addTemplateProperties("API_NAME" to apiName)
}

if (useMixins) {
assets.addTemplateProperties("MIXINS" to "true")
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/kotlin/platform/quilt/creator/gradle-steps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class QuiltGradleFilesStep(parent: NewProjectWizardStep) : AbstractLongRunningAs
val loaderVersion = data.getUserData(QuiltVersionChainStep.LOADER_VERSION_KEY) ?: return
val loomVersion = "1.1.+" // TODO
val javaVersion = findStep<JdkProjectSetupFinalizer>().preferredJdk.ordinal
val apiVersion = data.getUserData(QuiltVersionChainStep.API_VERSION_KEY)
val apiVersion = data.getUserData(QuiltStandardLibrariesStep.API_VERSION_KEY)
val apiName = data.getUserData(QuiltStandardLibrariesStep.API_NAME_KEY)
val officialMappings = data.getUserData(QuiltVersionChainStep.OFFICIAL_MAPPINGS_KEY) ?: false

assets.addTemplateProperties(
Expand All @@ -69,6 +70,10 @@ class QuiltGradleFilesStep(parent: NewProjectWizardStep) : AbstractLongRunningAs
assets.addTemplateProperties("API_VERSION" to apiVersion)
}

if (apiName != null) {
assets.addTemplateProperties("API_NAME" to apiName)
}

if (officialMappings) {
assets.addTemplateProperties("OFFICIAL_MAPPINGS" to "true")
}
Expand Down
117 changes: 81 additions & 36 deletions src/main/kotlin/platform/quilt/creator/ui-steps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import com.demonwav.mcdev.util.bindEnabled
import com.intellij.ide.users.LocalUserSettings
import com.intellij.ide.wizard.AbstractNewProjectWizardStep
import com.intellij.ide.wizard.NewProjectWizardStep
import com.intellij.openapi.observable.properties.GraphProperty
import com.intellij.openapi.observable.properties.ObservableMutableProperty
import com.intellij.openapi.observable.properties.transform
import com.intellij.openapi.observable.util.bind
import com.intellij.openapi.observable.util.bindBooleanStorage
import com.intellij.openapi.observable.util.bindStorage
import com.intellij.openapi.observable.util.not
Expand Down Expand Up @@ -64,7 +68,8 @@ class QuiltPlatformStep(

override fun createStep(data: Pair<QuiltVersions, QuiltStandardLibrariesVersions>): NewProjectWizardStep {
val (quiltVersions, apiVersions) = data
return QuiltVersionChainStep(this, quiltVersions, apiVersions)
return QuiltVersionChainStep(this, quiltVersions)
.nextStep { QuiltStandardLibrariesStep(this, apiVersions) }
.nextStep(::QuiltEnvironmentStep)
.nextStep(::UseMixinsStep)
.nextStep(::ModNameStep)
Expand All @@ -85,29 +90,24 @@ class QuiltPlatformStep(

class QuiltVersionChainStep(
parent: NewProjectWizardStep,
private val quiltVersions: QuiltVersions,
private val apiVersions: QuiltStandardLibrariesVersions,
) : AbstractMcVersionChainStep(parent, "Loader Version:", "Quilt Mappings Version:", "QFAPI/QSL Version:") {
private val quiltVersions: QuiltVersions
) : AbstractMcVersionChainStep(parent, "Loader Version:", "Quilt Mappings Version:") {
companion object {
private const val LOADER_VERSION = 1
private const val QUILT_MAPPINGS_VERSION = 2
private const val QFAPI_VERSION = 3

val MC_VERSION_KEY = Key.create<String>("${QuiltVersionChainStep::class.java.name}.mcVersion")
val LOADER_VERSION_KEY = Key.create<SemanticVersion>("${QuiltVersionChainStep::class.java.name}.loaderVersion")
val QUILT_MAPPINGS_VERSION_KEY = Key.create<String>("${QuiltVersionChainStep::class.java.name}.quiltVersion")
val API_VERSION_KEY = Key.create<SemanticVersion>("${QuiltVersionChainStep::class.java.name}.qfapiVersion")
val OFFICIAL_MAPPINGS_KEY = Key.create<Boolean>("${QuiltVersionChainStep::class.java.name}.officialMappings")

lateinit var MC_VERSION_PROPERTY: ObservableMutableProperty<Comparable<*>>
}

private val showSnapshotsProperty = propertyGraph.property(false)
.bindBooleanStorage("${javaClass.name}.showSnapshots")
private var showSnapshots by showSnapshotsProperty

private val useApiProperty = propertyGraph.property(true)
.bindBooleanStorage("${javaClass.name}.useApi")
private var useApi by useApiProperty

private val useOfficialMappingsProperty = propertyGraph.property(false)
.bindBooleanStorage("${javaClass.name}.useOfficialMappings")
private var useOfficialMappings by useOfficialMappingsProperty
Expand Down Expand Up @@ -145,22 +145,6 @@ class QuiltVersionChainStep(
).bindEnabled(useOfficialMappingsProperty.not()).component.foreground = JBColor.YELLOW
comboBox
}
QFAPI_VERSION -> {
val comboBox = super.createComboBox(row, index, items).bindEnabled(useApiProperty)
row.checkBox("Use Quilted Fabric API").bindSelected(useApiProperty)
row.label(EMPTY_LABEL).bindText(
getVersionProperty(MINECRAFT_VERSION).transform { mcVersion ->
mcVersion as QuiltMcVersion
val matched = apiVersions.versions.any { mcVersion.version in it.gameVersions }
if (matched) {
EMPTY_LABEL
} else {
"Unable to match QFAPI/QSL versions to Minecraft version"
}
},
).bindEnabled(useApiProperty).component.foreground = JBColor.YELLOW
comboBox
}
else -> super.createComboBox(row, index, items)
}
}
Expand All @@ -176,13 +160,6 @@ class QuiltVersionChainStep(
}
filteredVersions.ifEmpty { quiltVersions.mappings.map { it.version } }
}
QFAPI_VERSION -> {
val mcVersion = versionsAbove[MINECRAFT_VERSION] as QuiltMcVersion
val filteredVersions = apiVersions.versions.mapNotNull { api ->
api.version.takeIf { mcVersion.version in api.gameVersions }
}
filteredVersions.ifEmpty { apiVersions.versions.map { it.version } }
}
else -> throw IncorrectOperationException()
}
}
Expand All @@ -192,6 +169,7 @@ class QuiltVersionChainStep(
if (!showSnapshots) {
updateVersionBox()
}
MC_VERSION_PROPERTY = getVersionProperty(MINECRAFT_VERSION)
}

private fun updateVersionBox() {
Expand All @@ -209,9 +187,6 @@ class QuiltVersionChainStep(
QUILT_MAPPINGS_VERSION_KEY,
(getVersion(QUILT_MAPPINGS_VERSION) as QuiltVersions.QuiltMappingsVersion).name
)
if (useApi) {
data.putUserData(API_VERSION_KEY, getVersion(QFAPI_VERSION) as SemanticVersion)
}
data.putUserData(OFFICIAL_MAPPINGS_KEY, useOfficialMappings)
}
}
Expand Down Expand Up @@ -255,6 +230,76 @@ class QuiltEnvironmentStep(parent: NewProjectWizardStep) : AbstractNewProjectWiz
}
}

class QuiltStandardLibrariesStep(
parent: NewProjectWizardStep,
private val apiVersions: QuiltStandardLibrariesVersions
) : AbstractNewProjectWizardStep(parent) {
companion object {
val API_NAME_KEY = Key.create<String>("${QuiltVersionChainStep::class.java.name}.QuiltApiName")
val API_VERSION_KEY = Key.create<SemanticVersion>("${QuiltVersionChainStep::class.java.name}.quiltApiVersion")
}

private val apiNameProperty = propertyGraph.property("QFAPI")
.bindStorage("${javaClass.name}.apiName")
private var apiName by apiNameProperty

private val apiVersionProperty: GraphProperty<Comparable<*>> = propertyGraph
.property(apiVersions.versions.first().version)
private var apiVersion by apiVersionProperty
override fun setupUI(builder: Panel) {
with(builder) {
row("Standard Library:") {
segmentedButton(listOf("QSL", "QFAPI", "QFAPI/deprecated FAPI", "None")) { it }
.bind(apiNameProperty)
}.label("QSL is not yet supported").let { cell ->
cell.visible(apiNameProperty.transform { apiName == "QSL" }.get())
apiNameProperty.transform { apiName == "QSL" }.afterChange { cell.visible(it) }
cell.component.foreground = JBColor.YELLOW
}

row("Library Version: ") {
val comboBox = cell(
VersionChainComboBox(getVersionsList(QuiltVersionChainStep.MC_VERSION_PROPERTY.get()))
.bind(apiVersionProperty)
)
QuiltVersionChainStep.MC_VERSION_PROPERTY.afterChange {
comboBox.component.setSelectableItems(getVersionsList(it))
}
comboBox.enabled(apiNameProperty.transform { apiName != "QSL" && apiName != "None" }.get())
apiNameProperty.transform { apiName != "QSL" && apiName != "None" }.afterChange { comboBox.enabled(it) }
}.let { row ->
row.label(EMPTY_LABEL).bindText(
QuiltVersionChainStep.MC_VERSION_PROPERTY.transform { mcVersion ->
mcVersion as QuiltMcVersion
val matched = apiVersions.versions.any { mcVersion.version in it.gameVersions }
if (matched) {
EMPTY_LABEL
} else {
"Unable to match QFAPI/QSL versions to Minecraft version"
}
},
).component.foreground = JBColor.YELLOW
}
}
}

private fun getVersionsList(mcVersion: Comparable<*>): List<SemanticVersion> {
val mcVersion = mcVersion as QuiltMcVersion
val filteredVersions = apiVersions.versions.mapNotNull { api ->
api.version.takeIf { mcVersion.version in api.gameVersions }
}
return filteredVersions.ifEmpty { apiVersions.versions.map { it.version } }
}

override fun setupProject(project: Project) {
super.setupProject(project)
if (apiName != "None") {
data.putUserData(API_VERSION_KEY, apiVersion as SemanticVersion)
}
data.putUserData(API_NAME_KEY, apiName)
}
}

class QuiltOptionalSettingsStep(parent: NewProjectWizardStep) : AbstractCollapsibleStep(parent) {
override val title = "Optional Settings"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ dependencies {
modImplementation libs.quilt.loader

#if (${API_VERSION})
#if(${API_NAME}=="QFAPI")
// QSL is not a complete API; You will need Quilted Fabric API to fill in the gaps.
// Quilted Fabric API will automatically pull in the correct QSL version.
modImplementation libs.quilted.fabric.api
#elseif(${API_NAME}=="QFAPI/deprecated FAPI")
// QSL is not a complete API; You will need Quilted Fabric API to fill in the gaps.
// Quilted Fabric API will automatically pull in the correct QSL version. The bundle also includes deprecated FAPI libraries
modImplementation libs.bundles.quilted.fabric.api
#end
#end
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loade

#if (${API_VERSION})
quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "quilted_fabric_api" }
#if(${API_NAME}=="QFAPI/deprecated FAPI")
quilted_fabric_api_deprecated = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api-deprecated", version.ref = "quilted_fabric_api" }
#end
#end

# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example".
[bundles]
#if (${API_VERSION})
#if(${API_NAME}=="QFAPI/deprecated FAPI")
quilted_fabric_api = ["quilted_fabric_api", "quilted_fabric_api_deprecated"]
#end
#end

[plugins]
quilt_loom = { id = "org.quiltmc.loom", version = "${LOOM_VERSION}" }