ThemeService
Looking for a way to get the module?
Take the module from here
What is ThemeService?
- ThemeService allows plugin developers to apply themes to any GUI element. When a user changes the theme, the GUI will automatically be recolored to match the selected theme.
What is the purpose?
- Currently, plugin developers have to manually update their UI to be compatable with themes, however this is a lengthy proccess, especially for those new to plugin-making. ThemeService aims to remove the hurdle and allow more developers to introduce themes to their plugins.
How to use it?
--Adds an item to the registry
ThemeService:AddItem(GUI, property, guideEnum, modifierEnum)
-- Variables:
-- GUI - Object that you want automatically updated
-- Property - The property of the object you want automatically updated
-- GuideEnum - guide color reference (e.g. Enum.StudioStyleGuideColor.MainBackground)
-- ModifierEnum - Contextual reference (e.g. Enum.StudioStyleGuideModifier.Default)
--Adds multiple items to the registry
ThemeService:BulkAdd(Array, property, guideEnum, modifierEnum)
-- Variables:
-- Array - The objects that you want automatically updated
-- Property - The property of the object you want automatically updated
-- GuideEnum - guide color reference (e.g. Enum.StudioStyleGuideColor.MainBackground)
-- ModifierEnum - Contextual reference (e.g. Enum.StudioStyleGuideModifier.Default)
You shouldn’t use the :UpdateItem()
function unless you are debugging:
--Forcefully updates a GUI to match the theme
--Only works on GUI inserted into the :AddItem() method
--(Only use this method if you are updating the color of a UI manually)
ThemeService:UpdateItem(GUI, property)
-- Variables:
-- GUI - Object that you want to update
-- Property - property of the object you want to update
Here is an example of ThemeService in action, courtesy of @MrSprinkleToes
Further information:
- Require the module using
local ThemeService = require(PutModulePathHere.ThemeService)
-
ThemeService:AddItem()
can be called infinite times on the same object -
ThemeService:AddItem()
can be called infinite times on the same property - There are no memory leaks that I am aware of
- If an object is parented to nil, the UI will still update
- If an object is deleted, the UI reference will be removed and stop updating
- You no longer need to manually listen to the
settings().Studio.ThemeChanged
event
I originally created the plugin to help myself create plugins, but after seeing many plugin-makers struggle, I thought that it was important to share the module with others so that more high quality, theme compatible plugins can be created.
If you have any questions, feel free to ask, I’m open to suggestions if you have any.