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

Add a method of saving settings back to a file #1349

Closed
SrGesus opened this issue Oct 18, 2024 · 6 comments · Fixed by #1362
Closed

Add a method of saving settings back to a file #1349

SrGesus opened this issue Oct 18, 2024 · 6 comments · Fixed by #1362
Assignees
Milestone

Comments

@SrGesus
Copy link
Contributor

SrGesus commented Oct 18, 2024

Problem

Currently you can read settings from file but not write back to it.

Solution

Add a method to the settings class (I kind of don't like this because everything I/O related to settings is in the plugin instead of the class)

Alternatives

Perhaps a system that runs periodically? Not a big fan

Store back to file on every change? Would be doable when #456 is implemented

@SrGesus SrGesus added A-Engine B-Settings S-Triage Issues whose priority still has to be figured out labels Oct 18, 2024
@RiscadoA
Copy link
Member

Thanks for creating the issue! One other alternative would be to have some sort of SaveSettingsEvent which the settings plugin detects. This way you could keep the Settings class clean

@SrGesus
Copy link
Contributor Author

SrGesus commented Oct 18, 2024

Yes, sounds like #456 right?
Will be looking into it

@RiscadoA
Copy link
Member

RiscadoA commented Oct 18, 2024

Yes, sounds like #456 right? Will be looking into it

Yeah you can couple it with that one, but I don't know if it's a good idea to always save the settings when they are changed 🤔 I guess that behavior should be configurable with its own setting 👀

@RiscadoA RiscadoA added this to the 0.5 milestone Nov 5, 2024
@RiscadoA RiscadoA removed the S-Triage Issues whose priority still has to be figured out label Nov 5, 2024
@SrGesus
Copy link
Contributor Author

SrGesus commented Nov 8, 2024

Since mValues is private it is just be easier to do the serializing as a Settings class method but a question remains:

If there is a field, e.g - "assets.path" = "/assets/"

What should the settings.json look like?

{
  "assets.path": "/assets/"
}
{
  "assets": {
    "path": "/assets/"
  }
}

I'm leaning 1 because it's:

  • Much more trivial to implement
  • More efficient in both serialization and deserialization

@RiscadoA
Copy link
Member

RiscadoA commented Nov 8, 2024

Since mValues is private it is just be easier to do the serializing as a Settings class method but a question remains:

If there is a field, e.g - "assets.path" = "/assets/"

What should the settings.json look like?

{
  "assets.path": "/assets/"
}
{
  "assets": {
    "path": "/assets/"
  }
}

I'm leaning 1 because it's:

* Much more trivial to implement

* More efficient in both serialization and deserialization

Yeah I would say go for the first one. The problem is that then whenever the user opts for the second way the engine replaces it by the first one.
Maybe we should remove the logic for handling 'scopes' entirely, and just have everything inline as you suggested. What do you think?

@SrGesus
Copy link
Contributor Author

SrGesus commented Nov 8, 2024

Maybe we should remove the logic for handling 'scopes' entirely, and just have everything inline as you suggested. What do you think?

I think we should keep it since it's valid JSON and the performance impact on deserialisation is minimal since it should not run more than a couple times (if not just once on startup) and it might be easier for a user to write.

@SrGesus SrGesus linked a pull request Nov 8, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants