11 August 2022, 01:14:32
Started by ingar, 12 April 2019, 09:17:55
12 April 2019, 09:17:55
I am very impressed of all the work you have done with TGUI. Out of interest: How many developers are working on the project?
Anyway, from the "widgets" test program, I was thinking of the following improvements:
1: Is it possible to add a Theme constructor that takes a theme from memory instead of from file?
Like the "LoadFromMemory" functions in SFML? In this way, we could prevent users to tamper with
2: Perhaps also make a constructor for predefined themes?
#define THEME_BLACK 1000
#define THEME_GRAY 1001
Small things, but anyway.
Re: Theme constructor
12 April 2019, 18:36:54
I'm the sole developer. Some people have contributed some pieces of code but most comes from just me.
we could prevent users to tamper with the theme
Personally I don't think we should prevent people from tampering with resources if they want to change things. But loading from memory can of course have its use cases other than preventing tampering so it might still a useful feature.
One problem with loading from memory is how to handle external resources. If you just want to load the theme file from memory and let the images still be loaded from files then it isn't difficult but you probably want textures to be loaded from memory as well. I'm not sure how that should be done.
Technically it is already possible with tgui to load themes without using filenames, but that is probably too much work to be useful. You could make a class that inherits from BaseThemeLoader (like the DefaultThemeLoader does) and call the static Theme::setThemeLoader function to change the loader. Then the THEME_BLACK could be defined as the string "1000" and the custom theme loader would implement a way to load the right theme based on that id.
But the way you load things from memory is probably too specific to your code to be used by others, otherwise someone would have to write it once and it could be shipped with TGUI as alternative to the DefaultThemeLoader.
Terms and Rules
Go Up ▲
SMF 2.1.2 © 2022