Variable Support in Themes in EmulationStation
-
@jdrassa aww, thats sad. i thought i could get rid of files and folders. If i would use your method i had to make multiple system/theme.xml for every theme that has special colors.
Welp, guess i can stop working on my template then. There's nothing more i can think of to improve it because of the restrictions. No offense because it was a great experience. -
@jdrassa
Hi, do you mind me asking why you decided against that - sounds like it would be a really useful feature to streamline themes further (was just trying to figure out the best way to achieve system specific colours myself).Would an alternative option be to have a way to load external variables in from a text file?
You could have a text file that contains the variable and nothing else - in this case a colour, and give the text file the same name as the system:
arcade.txt
ffffff
You could then load in the variable something like this:
<loadVariables> <systemColor>./${system.theme}.txt</systemColor> </loadVariables>
Loving the variable support by the way, I'm planning to use it extensively in my next theme.
-
@ruckage your suggestion i kinda the same like the one @jdrassa suggested besides that you could dump all txt files into one location. In the end you still have to create, open and edit over 60 files if you want to do it for each system.
It's seems easier to me to create different colored tiles, save them acording to the system.name und then implement them with the system.name variable as background image. Of course this only works if you want to use it as background or something similar. -
@ectoone
Not really, it still negates the need to have a separate folder for each system and it would allow you to colour any element in the theme using the loaded variable.
What ever you do you're still going to have files for each system if you want system specific elements, your suggestions doesn't change that and limits it to backgrounds only. -
@ruckage The negation of separate folders was what i meant by "dumping all txt files into one location". :)
And i never said my idea was a good one, just an alternative with flaws.
I would prefer to use the method i mentioned up top and be able to mix variables into other variables. -
@ruckage said in Variable Support in Themes in EmulationStation:
Hi, do you mind me asking why you decided against that
I was worried it would overly complicate things. If a lot of variables were defined that way, then it would be more difficult to get an overall view of what is different about a specific system. Where as maintaining system specific theming in the system specific theme file centralizes it.
@ruckage said in Variable Support in Themes in EmulationStation:
Would an alternative option be to have a way to load external variables in from a text file?
You could have a text file that contains the variable and nothing else - in this case a colour, and give the text file the same name as the system:I think the problem with this approach is that once you start introducing multiple variables, the number of files you are creating will grow quickly.
-
@jdrassa said in Variable Support in Themes in EmulationStation:
@ruckage said in Variable Support in Themes in EmulationStation:
Hi, do you mind me asking why you decided against that
I was worried it would overly complicate things. If a lot of variables were defined that way, then it would be more difficult to get an overall view of what is different about a specific system. Where as maintaining system specific theming in the system specific theme file centralizes it.
I always refrained to create an dynamic theme because of the one system per folder setup. I rather use threaded variables than maintaining multiple files. That allows me to save variants of code blocks for several elements.
It also is just a problem that themers would have to deal with, not the users.
If you would add that, it wouldn't break the option to still use the system/theme.xml method, am I right? So why not have both ways.And to be honest, I was more confused by the fact that some complex code works, and some simple stuff didn't. Plus, that I had times, where - for whatever reason - the same code worked in one moment and then suddenly stopped working.
-
Heya, would it be possible to get a
game.name
variable? I mean one likesystem.name
that could be used within an text element to display the currently selected game.
I was thinking about that after I accidentally turned the carousel from a navigation element into a design element when I was working on my Metroid theme.
Since the available elements for detailed view are limited, I always have a hard time to create something I like. And I thought what I could do if I could hide the gamelist and have just one game name on screen (now that I think of it, I probably just could make the gamelist very small to display one game... Welp, back to the drawing board.).
But still, I can see more options where I could use that variable. I'm thinking of ways to display more images based on a game without having extra tags in the gamelist. Although I'm not sure how ES handles images and that might be to resource heavy. -
@ectoone Unfortunately that is not possible due to how the themes are loaded and when the variables are resolved.
-
@jdrassa Yeah i thought so.
But if i remember correctly, I've seen something likemd_gamename
when i was looking at the github discussion for grid view. Maybe that will be available in other views. But i'm so tired that i could be totally wrong about that. -
@ectoone You are correct. Something like that was proposed with grid view. It would make sense to support it in all views.
-
I'm using the single theme.xml principle for my snes mini theme but I've hit a bit a snag.
I'm using the ${system.name} variable extensively to load system specific backgrounds and logos etc. which works really well and is far better than having a folder for each system.
However there is a downside - for unsupported systems and custom collections you lose the ability to have a default system as for example ${system.name}.png will always look for a png with the current system name and if it doesn't exist will load nothing.Would it be possible if no file exists for ES to then assume that ${system.name}=default and then look for that file instead?
Eg. Assume that nes has no assets.
In the theme we have: <path>./${system.name}.png</path>
This will look for nes.pngThis doesn't exist so as a backup ES will then look for: default.png
(basically it would replace the system name with the word default or another word of your choice)I hope that makes sense, I love not needing a folder for every system - it makes changes so much easier and this seems to be the only real downside.
-
@ruckage What I did for the default background was to use a default image as background and have the system backgrounds load on top of that using zindex. But I agree that some default value would be useful, it would allow us to have a default logo on the carousel instead of plain text as well.
-
-
@ruckage I will need to think some about the best way to approach this. The way variables are processed, they are are resolved well before the values are passed to the actual gui components (i.e. ImageComponent, TextComponent, ...). As such, the components are unaware of variables.
I am leaning towards adding something like the following:
<image> <path>./${system.name}.png</path> <defaultPath>./default.png</defaultPath> </image>
This would make the behavior very specific and deliberate.
-
@ruckage Also just to note. I see you are using
${system.name}
. I would recommend using${system.theme}
instead. -
@jdrassa
Thanks for the reply. Having a default path sounds perfect to me.Regarding the use of ${system.name} I'll change that to ${system.theme}.
What's the difference between them as ${system.name} seems to work perfectly and the only systems I noticed which didn't work as expected were all/favorites/recent. -
@ruckage The values are derived from es_systems.cfg.
<system> <name>nes</name> <!-- ${system.name} --> <fullname>Nintendo Entertainment System</fullname> <!-- ${system.fullName} --> <path>/home/pi/RetroPie/roms/nes</path> <extension>.nes .zip .NES .ZIP</extension> <command>/opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ nes %ROM%</command> <platform>nes</platform> <theme>nes</theme> <!-- ${system.theme} --> </system>
While generally, name and theme are the same, there are some cases where they are not. It also helps for systems like megadrive/genesis and pce/tg16 where the user may have changed the theme.
-
@jdrassa
Thanks, obvious really if I'd thought about it.
I've changed all instances of ${system.name} to ${system.theme}. Thanks for the advise. -
@ruckage I have implemented default image support. I ended up naming the new field
default
since that was what video was already using.<image> <path>./${system.name}.png</path> <default>./default.png</default> </image>
It also occurred to me that this could work well for the missing.png you use. You could set it as the default for
md_image
and then it would only show if the selected game does not have an image.Windows build available here:
https://ci.appveyor.com/project/jrassa/emulationstation/build/2.6.4-201746011746/artifacts
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.