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

Rework and improve SaveSystem #5

Closed
Seeloewen opened this issue Mar 5, 2024 · 1 comment
Closed

Rework and improve SaveSystem #5

Seeloewen opened this issue Mar 5, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Seeloewen
Copy link
Owner

Seeloewen commented Mar 5, 2024

A working save system is a crucial part of every app that has some sort of settings or other user inputs that need to be stored. Most of my apps save some kind of files as well. Currently, practically every app I have uses a different save system, all of them being pretty outdated and flawed. That's why I've decided to make one universal save system that can be used in all of my apps that are written in C# and WPF.

SeeloewenLib v1.0.0 already comes with a basic implementation of a Save System, though it was mostly meant for test purposes and wasn't ready for actual use yet. As you may know, there haven't been any updates since the first release of the library. That's because since the release, I've been cooking up ideas for features and improvements. Now, it's finally time to add them and the Save System is the first since I think it's most important.

How am I going to implement it?
Pretty much everything is automated. One of the few manual things is the creation of settings entrys. When starting your app, you will need to create a new SaveSystem. To the saveEntries list of that SaveSystem you will have to add a SaveEntry for each entry you want to save. This entry includes the following parameters: string name, string content, bool isCategory, bool hasDefinedValues, string[] possibleValues, int index

When this is done, you can get all settings from your settings file and load the respective values from file into the entries. While doing this, it automatically checks for corruption or invalid values. After finding a corrupted value, you will be asked whether to continue loading it or correct it. When correcting the file, a backup will be created in case you need your old values back.

The entries can be accessed and customized using the provided methods, or simply by accessing the SaveEntries by your own methods.
GetEntry(name) => Returns the value of the given entry
SetEntry(name, value) => Sets entry to given value
ResetEntries() => Resets entries to their default value (1st in possibleValues array or "" if hasDefinedValues is false)

Saving the entries is also very easy. Simply run the Save() method and all of the entries will be written to a settings file. You are free to decide the header and also the filename and path of that settings file.

@Seeloewen Seeloewen added the enhancement New feature or request label Mar 5, 2024
@Seeloewen Seeloewen self-assigned this Mar 5, 2024
@Seeloewen
Copy link
Owner Author

The rework is now done and I'm happy with how it turned out. The corruption check however was not tested thoroughly and may throw up issues. Will take a look out when during the next few days, especially when I'm gonna implement it into the Random Item Giver Updater. For now it's released and available in Version 1.1.0 of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

1 participant