It is currently April 27th, 2024, 7:46 am

Trying to create a settings saving system

Get help with creating, editing & fixing problems with skins
User avatar
MazinLabib10
Posts: 14
Joined: January 21st, 2023, 3:47 pm

Trying to create a settings saving system

Post by MazinLabib10 »

Hello fellow Rainmeter enthusiasts! :welcome:

I'm working on a skin that shows the previous and next game for your favourite football/soccer team. It's been over a year since I began work on this project as I've had to put it aside for extended periods as university work piled up. However, now I can say the finish line is in sight and I'm hoping to release it in the coming weeks. Thanks to anyone here that helped me when I've faced issues with this before!

Now then, I need a bit of help with what should be the last feature to add to the settings of my skin. I'm looking to create a system for users to save their settings (layout, colours, fonts, etc.) in different files and be able to load them whenever they choose. My initial thought process was to somehow have the settings skin save the currently loaded variables to a new variables file and to then have a way to load such save files from within the settings itself. I've looked it up online but can't come up with how this can be done. So, I'm hoping to get an insight from folks here about whether this is possible and, if so, how I could do it. Thanks in advance! :D
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to create a settings saving system

Post by Yincognito »

MazinLabib10 wrote: February 10th, 2024, 8:10 pm Hello fellow Rainmeter enthusiasts! :welcome:

I'm working on a skin that shows the previous and next game for your favourite football/soccer team. It's been over a year since I began work on this project as I've had to put it aside for extended periods as university work piled up. However, now I can say the finish line is in sight and I'm hoping to release it in the coming weeks. Thanks to anyone here that helped me when I've faced issues with this before!

Now then, I need a bit of help with what should be the last feature to add to the settings of my skin. I'm looking to create a system for users to save their settings (layout, colours, fonts, etc.) in different files and be able to load them whenever they choose. My initial thought process was to somehow have the settings skin save the currently loaded variables to a new variables file and to then have a way to load such save files from within the settings itself. I've looked it up online but can't come up with how this can be done. So, I'm hoping to get an insight from folks here about whether this is possible and, if so, how I could do it. Thanks in advance! :D
If it's just about saving the current settings and having them persist the next time you load or refresh the skin, you'd use !WriteKeyValue to save values in your .inc files:
https://docs.rainmeter.net/manual/bangs/#Options
and have those .inc files @included in your skin:
https://docs.rainmeter.net/manual/skins/include-option/

However, if you're thinking of having multiple "sets" of settings that you can switch to at will, then things will become slightly more complicated since you'll probably have to design a small Explorer-like system where you can "choose" the desired settings / .inc file to use, either directly or via some additional "button":
https://docs.rainmeter.net/manual/plugins/fileview/
then !WriteKeyValue the corresponding @include options to the skin's .ini file before finally refreshing the skin to "load" the new settings / .inc file. Obviously, having single .inc files each containing a "set" of said settings / variable values would avoid complicating this system even further.

P.S. An alternative to using FileView would be to enter the desired .inc name manually, in an InputText measure:
https://docs.rainmeter.net/manual/plugins/inputtext/

P.S.S. The above describes only the "choosing" part of it, and assumes those settings / .inc files already exist. When it comes to actually creating such files before using !WriteKeyValue on them as usual, either a Lua function (you'd have to add the BOM characters from the script if you need a UTF-16 LE BOM file encoding, there's a thread by jsmorley on the forum about that) or some PowerShell command (preferable, as you can set the desired encoding) ran from a RunCommand measure will do the trick:
https://docs.rainmeter.net/manual/plugins/runcommand/
Didn't test it, but it might also be possible via a plain command line in the RunCommand measure (not sure about encoding in this case though).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
MazinLabib10
Posts: 14
Joined: January 21st, 2023, 3:47 pm

Re: Trying to create a settings saving system

Post by MazinLabib10 »

Yincognito wrote: February 11th, 2024, 12:14 pm However, if you're thinking of having multiple "sets" of settings that you can switch to at will, then things will become slightly more complicated since you'll probably have to design a small Explorer-like system where you can "choose" the desired settings / .inc file to use, either directly or via some additional "button":
https://docs.rainmeter.net/manual/plugins/fileview/
then !WriteKeyValue the corresponding @include options to the skin's .ini file before finally refreshing the skin to "load" the new settings / .inc file. Obviously, having single .inc files each containing a "set" of said settings / variable values would avoid complicating this system even further.
This is actually what I was thinking of doing. I just discovered the FileView plugin few hours ago but I'm not exactly sure how that works but I'm trying to figure it out now. Seems like it might have most potential for what I want to do though. Think I might have to create an Explorer window for both saving and loading variable files.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to create a settings saving system

Post by Yincognito »

MazinLabib10 wrote: February 11th, 2024, 1:10 pm This is actually what I was thinking of doing. I just discovered the FileView plugin few hours ago but I'm not exactly sure how that works but I'm trying to figure it out now. Seems like it might have most potential for what I want to do though. Think I might have to create an Explorer window for both saving and loading variable files.
Yeah, just start simple and you'll get the idea. Technically it won't be an Explorer window, as the plugin only provides the data / means to replicate such a window yourself. The saving part doesn't absolutely need FileView if you restrict saving to a single folder (unless you want stuff to be fancy and provide the best experience for the user), an InputText that triggers a RunCommand containing a simple file creation command (and then using !WriteKeyValue normally, to write the desired stuff into the newly created file) would probably be enough.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
MazinLabib10
Posts: 14
Joined: January 21st, 2023, 3:47 pm

Re: Trying to create a settings saving system

Post by MazinLabib10 »

Yincognito wrote: February 11th, 2024, 1:21 pm Yeah, just start simple and you'll get the idea. Technically it won't be an Explorer window, as the plugin only provides the data / means to replicate such a window yourself. The saving part doesn't absolutely need FileView if you restrict saving to a single folder (unless you want stuff to be fancy and provide the best experience for the user), an InputText that triggers a RunCommand containing a simple file creation command (and then using !WriteKeyValue normally, to write the desired stuff into the newly created file) would probably be enough.
Yeah I did get that it would be a replica of an Explorer window. Seen something similar in the NXT-OS suite. Those are some really good ideas you've given me though so big thanks for that!
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to create a settings saving system

Post by Yincognito »

MazinLabib10 wrote: February 11th, 2024, 2:38 pm Yeah I did get that it would be a replica of an Explorer window. Seen something similar in the NXT-OS suite. Those are some really good ideas you've given me though so big thanks for that!
You're welcome - good luck with the implementation, looking forward to see the final result when it will be done! Don't hesitate to come back and ask if you have any questions on that or you encounter difficulties that you can't handle on your own. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth