Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config schema proposal #28

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

puppy-girl
Copy link
Contributor

@puppy-girl puppy-girl commented Nov 14, 2024

my proposal for a config schema field in the mod manifest based on the layout of json schema. sorry for the c# side of things being lacking, im aware it could be better

each property in ConfigSchema will have the config property as the key and its data as the values. Title and Description can optionally be provided for config managers to show richer information (for example, Title can be used in place of the config key and Description can fill a tooltip to better explain what a property does)

properties will use the following types and the additional data associated with them:

  • string:
    • MinLength
    • MaxLength
    • Pattern: a regex pattern for use in C#. since godot's regex is based on PCRE, mod devs should define patterns separately in their gdscript code when required. hesitant with this one because of the catch
  • int/float:
    • Minimum
    • Maximum
    • MultipleOf
  • string/int/float:
    • Enum: a list of acceptable values
    • SuggestedEnum: a list of suggested values for hints/autocomplete in UIs, but any value is accepted
  • object:
    • Properties
  • array:
    • Items
    • MinItems
    • MaxItems
  • bool

would love discussion ty ૮ ˶′ ཅ ‵˶ ა

@Awesomerly
Copy link

I wonder if it would be a good idea to have an "id" field for a configuration parameter so you could have the title and the way it's referred to in code be different.

@puppy-girl
Copy link
Contributor Author

I wonder if it would be a good idea to have an "id" field for a configuration parameter so you could have the title and the way it's referred to in code be different.

the config schema property would be a dictionary where each key is the id of the config property, for example:

"ConfigSchema": {
    "EnableFeature": {
        "Type": "bool"
    },
    "FeatureMax": {
        "Type": "int",
        "Minimum": 1,
        "Maximum": 10
    }
}

@ai-kana
Copy link
Contributor

ai-kana commented Nov 18, 2024

Personal opinions but this kind of seems unnecessary there is already a way to make a config that is also bound to object aka more convenient to use.

Though that way of making a config has flaws being you it is written by the program and loses all formatting and comments if it wasn't json.

Using the Microsoft.Extensions.Configuration package is very nice for read-only configurations. But I think it's a little late for that change.

Also how do you even access this? Every thing is marked internal and ModManifest is never passed to the mod.

@puppy-girl
Copy link
Contributor Author

Personal opinions but this kind of seems unnecessary there is already a way to make a config that is also bound to object aka more convenient to use.

a schema allows config editors (in mod managers, mods, etc.) to give users more helpful information and restrictions beyond only being able to assume what type the property should be from what's already there. as well as that, lots of people are using configs with gdscript rather than exclusively in C# mods. it's primarily meant to make this information available outside of the mod and to consolidate it into the manifest rather than spread across multiple places

@puppy-girl puppy-girl marked this pull request as ready for review November 21, 2024 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants