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

(DRAFT) Add theme support #73

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

kosmas12
Copy link
Contributor

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:

  1. 3 background image pairs, pointing to the path of a background image for 480p, 720p and 1080i.
  2. A font pair, pointing to the path of a font
  3. 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:

  1. An 8 bit unsigned integer holding the theme name length
  2. As many chars as the integer holds containing the theme name
  3. 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)
  4. For that number of bytes there will be the image data
  5. Repeat for 720p and 1080i images
  6. A 32 bit unsigned integer holding the font size in bytes (Like images, this can be avoided given the size is in the header)
  7. Font data for that many bytes
  8. 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:

  1. The code to implement it will not be trivial, however it should be possible using the SDL_RWops API.
  2. 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!

@kosmas12 kosmas12 marked this pull request as draft July 28, 2021 18:11
#include <windows.h>
#endif

void findThemes(std::string const& path, MenuThemes *list) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not as part of MenuThemes::?

Comment on lines +148 to +157
void MenuThemes::execute(Menu *menu) {
if (menu->getCurrentMenu() != this) {
menu->setCurrentMenu(this);
}
else {
if (childNodes.size() > selected) {
this->childNodes.at(selected)->execute(menu);
}
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do anything different from MenuNode, does it?
In that case, this can be removed.

I'd wager you want ThemeItem to perform the actual magic in the end anyways?

Comment on lines +57 to +65
class MenuThemes : public MenuNode {
public:
MenuThemes(MenuNode *parent, std::string const& label, std::string const& path);
~MenuThemes();
void execute(Menu *menu);
protected:
std::string path;
};

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worthy of its own file, no?

@dracc
Copy link
Owner

dracc commented Jul 30, 2021

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.

@abaire
Copy link
Contributor

abaire commented Sep 23, 2021

+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".

@kosmas12
Copy link
Contributor Author

kosmas12 commented Jan 9, 2022

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...

@abaire
Copy link
Contributor

abaire commented Jan 9, 2022

#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.

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