NevolutionX
NevolutionX copied to clipboard
(DRAFT) Add theme support
Hello!
Theme support has been listed in the README to-do list for a while, but has never been implemented. As an exercise, I decided to make this a reality myself.
I decided to start out with just the basic code for the menu item instead of the entire thing as I predict there will be lots of things to implement and just wanted to open a PR to let people know that this is "under construction".
Currently, here's what the code does:
It can now create a "theme" type menu (like scan and settings are different types) that once launched will look at the given path for .nevoxtheme files. Unfortunately this is all for now, however I've tried to figure out the .nevoxtheme file format.
At first, I thought it'd just be a special JSON file that has a few key/value pairs:
- 3 background image pairs, pointing to the path of a background image for 480p, 720p and 1080i.
- A font pair, pointing to the path of a font
- A font color pair, with a hexadecimal RGB value representing the font color.
The name could be taken from the theme file name or from a new key/value pair.
However, I decided that due to complications with paths on Xbox like D: being automounted as the XBE path and the rest not being always mounted, we can do better.
This is what I came up with:
- An 8 bit unsigned integer holding the theme name length
- As many chars as the integer holds containing the theme name
- A 32 bit unsigned integer holding the size for a 480p image in bytes (This can be avoided if the file size is in the image header but I'm not sure every format has it)
- For that number of bytes there will be the image data
- Repeat for 720p and 1080i images
- A 32 bit unsigned integer holding the font size in bytes (Like images, this can be avoided given the size is in the header)
- Font data for that many bytes
- A 32 bit unsigned integer holding the hexadecimal RGB value representing the font color
Another reason I thought of that format is ease of use. Using the first file format, that'd need us to copy 5 files to have a complete, working theme. With this format, we only need 1 big file.
A couple of disadvantages I've thought of for the 2nd format are:
- The code to implement it will not be trivial, however it should be possible using the SDL_RWops API.
- Accessibility to creation tools. This will need a separate tool to create themes. We can implement one in the NevoX themes menu and also create a standalone program that can do the work.
I'm ready to hear your thoughts on both the code and the themes format. Cheers!
I'd very much prefer 5 files (3 images, 1 font, one config-file in JSON format) over one big blob. Once XGU/pbkit/whatever renderer comes one image should become enough. We don't want to have to change the format of the themes when that day comes.
+1 to JSON over a custom blob format that will require a tool to create. Also +1 to having one image size and scaling it in hardware.
I believe you can count on the "A:" containing whatever is in the NevolutionX directory (see mountHomeDir
) so you won't have an issue w/ the "D:" (which will be remounted to point at the DVD drive). That said, I think you could get by with something pretty trivial if we just assume that the files will always be together in one directory:
e.g. a skin.json
file:
{
"name": "Friendly name of the skin, so we can implement a skin chooser menu.",
"images": {
"background": {
"480": "480.png",
...
},
"launch": {
"480": "480Launch.png",
}
}
"menu": {
"font": "vegur.ttf",
"color": FFFFFF
}
}
Then we can just have a convention that these will live in subdirectories under a "Skins" directory, e.g.:
Skins\NevolutionXDefault\...
which would allow the dashboard to just look for skin.json
in each subdir under "Skins".
Man, been a while...
I'll go with JSON then. Having some more experience now I see why it's better. I'll also get to fixing/improving based on the code reviews.
On to work then...
#112 has an example of what I was thinking back when I saw this draft, btw. Probably good to discuss with @dracc to see if theming is desired and to make sure the approach is agreed on before you do too much work on it.