paul
April 3, 2022, 3:55pm
1
Hi,
I’m trying to declare my styles before Preset preset = [...]
to reuse them inside the preset
and to avoid copy-pasting the same style in half of the presets. This would also dramatically increase readability of our configs.
What I think I need is to now how to actually do it - that is to know what type to give to the style.
I took StyleAllocator
from struct Preset
definition but I’m not sure this is the way to go
StyleAllocator bladeStyleRed = StylePtr<Layers<ColorSelect<IntAr... ; //omit fn call "()" and call inside preset
StyleAllocator bladeStyleBlue= StylePtr<Layers<ColorSelect<IntAr... ;
StyleAllocator pixelStyleOrangeBlinkingBatt = StylePtr<Layers<RgbArg...;
Preset presets[] = {
{"Maul", "tracks/fates.wav", bladeStyleRed(), pixelStyleOrangeBlinkingBatt(), "red"},
{"Ani", "tracks/tusken.wav", bladeStyleBlue(), pixelStyleOrangeBlinkingBatt(), "blue"},
//...
}
Any advice how to do it properly is most welcome
As part of my Phase 4 update (coming soon) I will be adding a new feature as suggested by profezzorn. This thread is being created now so I can point users to the usage instructions.
The ProffieOS6 Style Library “using” functions allow you to simplify your config files by only needing to have the style code appear once and then reference that style by a “using” function in all of your presets. With the introduction of Edit Mode and Style Options in OS6, you no longer need to make unique copies of the same style code for each preset to change the color, effects or transitions. Instead you can use the same style code in multiple presets with unique colors and options thereby saving memory on the board.
The new “using” functions allow you to further simplify your presets by simply referencing the “using” function name within the preset. You will only need to add each unique style once above the Preset presets[] array and then refer to it within the StylePtr<>().
So instead of pasting the same Style code in each preset you’ll paste the “using” code once and then refer to it in each preset you want to use it by the using name like below.
Example:
#ifdef CONFIG_PROP
#include "../props/saber_fett263_buttons.h"
#endif
#ifdef CONFIG_PRESETS
/*--------------------------------- MainFallenOrderCalKestisRed -------------------------
copyright Fett263 FallenOrder (Primary Blade) OS6 Style
https://fett263.com/fett263-proffieOS6-style-library.html#FallenOrder
OS6.6 v4.0
Single Style
Base Style: Fallen Order Cal Kestis
--Effects Included--
Ignition Effect: Standard Ignition
Retraction Effect: Standard Retraction
Lockup Effect: Intensity Lockup V1, Begin Effect: Real Clash, End Effect: Full Blade Absorb
LightningBlock Effect: Responsive Lightning Block
Drag Effect: Intensity Sparking Drag
Melt Effect: Intensity Melt
Blast Effect: Blast Wave (Random)
Clash Effect: Real Clash V1
*/
using MainFallenOrderCalKestisRed = Layers<...>;
/*
Add to preset as StylePtr<MainFallenOrderCalKestisRed>()
--------------------------------------------------------------------------*/
Preset presets[] = {
{ "Anakin;common", "Anakin/tracks/intro.wav",
StylePtr<MainFallenOrderCalKestisRed>(), "Preset1"
},
{ "Luke;common", "Luke/tracks/intro.wav",
StylePtr<MainFallenOrderCalKestisRed>(), "Preset2"
},
...
In the above example the library produced the copyright, style info and a using function (the name will need to be unique for each style).
The line
using MainFallenOrderCalKestisRed…
Try setting up as “using”, I’ll be adding this ability, suggested by profezzorn, in the next update to the library.