-
Notifications
You must be signed in to change notification settings - Fork 631
Add Blood Color options to Cosmetics Editor #6007
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
base: develop
Are you sure you want to change the base?
Changes from all commits
3a31dc3
76e45ee
aaf0db6
8aaa9ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,8 @@ u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey); | |
| } | ||
|
|
||
| static WidgetInfo goronNeck; | ||
| static void RegisterBlueBloodHook(); | ||
| static void RegisterGreenBloodHook(); | ||
|
|
||
| namespace SohGui { | ||
| extern std::shared_ptr<SohMenu> mSohMenu; | ||
|
|
@@ -97,6 +99,7 @@ std::map<CosmeticGroup, const char*> groupLabels = { | |
| { COSMETICS_GROUP_NAVI, "Navi" }, | ||
| { COSMETICS_GROUP_IVAN, "Ivan" }, | ||
| { COSMETICS_GROUP_MESSAGE, "Message" }, | ||
| { COSMETICS_GROUP_BLOOD, "Blood" }, | ||
| }; | ||
|
|
||
| static const std::unordered_map<int32_t, const char*> cosmeticsRandomizerModes = { | ||
|
|
@@ -420,6 +423,23 @@ static std::map<std::string, CosmeticOption> cosmeticOptions = { | |
| COSMETIC_OPTION("SpinAttack.Level2Primary", "Level 2 Primary", COSMETICS_GROUP_SPIN_ATTACK, ColorRGBA8(255, 255, 170, 255), false, true, true), | ||
| COSMETIC_OPTION("SpinAttack.Level2Secondary", "Level 2 Secondary", COSMETICS_GROUP_SPIN_ATTACK, ColorRGBA8(255, 100, 0, 255), false, true, false), | ||
|
|
||
| COSMETIC_OPTION("Blood.Blue0Begin", "Blue 0 Begin", COSMETICS_GROUP_BLOOD, ColorRGBA8( 10, 10, 200, 255), true, true, false), | ||
| COSMETIC_OPTION("Blood.Blue0End", "Blue 0 End", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 0, 32, 0), true, true, false), | ||
| COSMETIC_OPTION("Blood.Blue1Begin", "Blue 1 Begin", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 0, 128, 255), true, true, false), | ||
| COSMETIC_OPTION("Blood.Blue1End", "Blue 1 End", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 0, 32, 0), true, true, false), | ||
| COSMETIC_OPTION("Blood.Blue2Begin", "Blue 2 Begin", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 0, 128, 255), true, true, false), | ||
| COSMETIC_OPTION("Blood.Blue2End", "Blue 2 End", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 0, 64, 0), true, true, false), | ||
| COSMETIC_OPTION("Blood.Blue3Begin", "Blue 3 Begin", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 0, 128, 255), true, true, false), | ||
| COSMETIC_OPTION("Blood.Blue3End", "Blue 3 End", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 0, 64, 0), true, true, false), | ||
| COSMETIC_OPTION("Blood.Green0Begin", "Green 0 Begin", COSMETICS_GROUP_BLOOD, ColorRGBA8( 10, 200, 10, 255), true, true, false), | ||
| COSMETIC_OPTION("Blood.Green0End", "Green 0 End", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 32, 0, 0), true, true, false), | ||
| COSMETIC_OPTION("Blood.Green1Begin", "Green 1 Begin", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 128, 0, 255), true, true, false), | ||
| COSMETIC_OPTION("Blood.Green1End", "Green 1 End", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 32, 0, 0), true, true, false), | ||
| COSMETIC_OPTION("Blood.Green2Begin", "Green 2 Begin", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 128, 0, 255), true, true, false), | ||
| COSMETIC_OPTION("Blood.Green2End", "Green 2 End", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 64, 0, 0), true, true, false), | ||
| COSMETIC_OPTION("Blood.Green3Begin", "Green 3 Begin", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 128, 0, 255), true, true, false), | ||
| COSMETIC_OPTION("Blood.Green3End", "Green 3 End", COSMETICS_GROUP_BLOOD, ColorRGBA8( 0, 64, 0, 0), true, true, false), | ||
|
|
||
| COSMETIC_OPTION("Trails.Bombchu", "Bombchu", COSMETICS_GROUP_TRAILS, ColorRGBA8(250, 0, 0, 255), false, true, true), | ||
| COSMETIC_OPTION("Trails.Boomerang", "Boomerang", COSMETICS_GROUP_TRAILS, ColorRGBA8(255, 255, 100, 255), false, true, true), | ||
| COSMETIC_OPTION("Trails.KokiriSword", "Kokiri Sword", COSMETICS_GROUP_TRAILS, ColorRGBA8(255, 255, 255, 255), false, true, false), | ||
|
|
@@ -1509,6 +1529,12 @@ void ApplyOrResetCustomGfxPatches(bool manualChange) { | |
| player->actor.scale.z = scale; | ||
| } | ||
| } | ||
|
|
||
| // (Un)register Hooks | ||
| if (manualChange) { | ||
| RegisterBlueBloodHook(); | ||
| RegisterGreenBloodHook(); | ||
| } | ||
| } | ||
|
|
||
| extern "C" Color_RGBA8 CosmeticsEditor_GetDefaultValue(const char* id) { | ||
|
|
@@ -2528,6 +2554,7 @@ void CosmeticsEditorWindow::DrawElement() { | |
| DrawCosmeticGroup(COSMETICS_GROUP_MAGIC); | ||
| DrawCosmeticGroup(COSMETICS_GROUP_ARROWS); | ||
| DrawCosmeticGroup(COSMETICS_GROUP_SPIN_ATTACK); | ||
| DrawCosmeticGroup(COSMETICS_GROUP_BLOOD); | ||
| DrawCosmeticGroup(COSMETICS_GROUP_TRAILS); | ||
| if (UIWidgets::CVarSliderInt("Trails Duration: %d", CVAR_COSMETIC("Trails.Duration.Value"), | ||
| UIWidgets::IntSliderOptions() | ||
|
|
@@ -2678,6 +2705,95 @@ void CosmeticsEditor_ResetGroup(CosmeticGroup group) { | |
| ApplyOrResetCustomGfxPatches(); | ||
| } | ||
|
|
||
| static void SetBlueBloodColor(EffectSparkInit* effectSparkInit) { | ||
| Color_RGBA8 blue0begin = { 10, 10, 200, 255 }; | ||
| effectSparkInit->colorStart[0] = CVarGetColor(CVAR_COSMETIC("Blood.Blue0Begin.Value"), blue0begin); | ||
| Color_RGBA8 blue0end = { 0, 0, 32, 0 }; | ||
| effectSparkInit->colorEnd[0] = CVarGetColor(CVAR_COSMETIC("Blood.Blue0End.Value"), blue0end); | ||
|
|
||
| Color_RGBA8 blue1begin = { 0, 0, 128, 255 }; | ||
| effectSparkInit->colorStart[1] = CVarGetColor(CVAR_COSMETIC("Blood.Blue1Begin.Value"), blue1begin); | ||
| Color_RGBA8 blue1end = { 0, 0, 32, 0 }; | ||
| effectSparkInit->colorEnd[1] = CVarGetColor(CVAR_COSMETIC("Blood.Blue1End.Value"), blue1end); | ||
|
|
||
| Color_RGBA8 blue2begin = { 0, 0, 128, 255 }; | ||
| effectSparkInit->colorStart[2] = CVarGetColor(CVAR_COSMETIC("Blood.Blue2Begin.Value"), blue2begin); | ||
| Color_RGBA8 blue2end = { 0, 0, 64, 0 }; | ||
| effectSparkInit->colorEnd[2] = CVarGetColor(CVAR_COSMETIC("Blood.Blue2End.Value"), blue2end); | ||
|
|
||
| Color_RGBA8 blue3begin = { 0, 0, 128, 255 }; | ||
| effectSparkInit->colorStart[3] = CVarGetColor(CVAR_COSMETIC("Blood.Blue3Begin.Value"), blue3begin); | ||
| Color_RGBA8 blue3end = { 0, 0, 64, 0 }; | ||
| effectSparkInit->colorEnd[3] = CVarGetColor(CVAR_COSMETIC("Blood.Blue3End.Value"), blue3end); | ||
| } | ||
|
|
||
| static void SetGreenBloodColor(EffectSparkInit* effectSparkInit) { | ||
| Color_RGBA8 green0begin = { 10, 200, 10, 255 }; | ||
| effectSparkInit->colorStart[0] = CVarGetColor(CVAR_COSMETIC("Blood.Green0Begin.Value"), green0begin); | ||
| Color_RGBA8 green0end = { 0, 32, 0, 0 }; | ||
| effectSparkInit->colorEnd[0] = CVarGetColor(CVAR_COSMETIC("Blood.Green0End.Value"), green0end); | ||
|
|
||
| Color_RGBA8 green1begin = { 0, 128, 0, 255 }; | ||
| effectSparkInit->colorStart[1] = CVarGetColor(CVAR_COSMETIC("Blood.Green1Begin.Value"), green1begin); | ||
| Color_RGBA8 green1end = { 0, 32, 0, 0 }; | ||
| effectSparkInit->colorEnd[1] = CVarGetColor(CVAR_COSMETIC("Blood.Green1End.Value"), green1end); | ||
|
|
||
| Color_RGBA8 green2begin = { 0, 128, 0, 255 }; | ||
| effectSparkInit->colorStart[2] = CVarGetColor(CVAR_COSMETIC("Blood.Green2Begin.Value"), green2begin); | ||
| Color_RGBA8 green2end = { 0, 64, 0, 0 }; | ||
| effectSparkInit->colorEnd[2] = CVarGetColor(CVAR_COSMETIC("Blood.Green2End.Value"), green2end); | ||
|
|
||
| Color_RGBA8 green3begin = { 0, 128, 0, 255 }; | ||
| effectSparkInit->colorStart[3] = CVarGetColor(CVAR_COSMETIC("Blood.Green3Begin.Value"), green3begin); | ||
| Color_RGBA8 green3end = { 0, 64, 0, 0 }; | ||
| effectSparkInit->colorEnd[3] = CVarGetColor(CVAR_COSMETIC("Blood.Green3End.Value"), green3end); | ||
| } | ||
|
|
||
| static void RegisterBlueBloodHook() { | ||
| static bool previousHookState = false; // Previous hook enabled state (we don't re-register if unchanged) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. COND_VB_SHOULD handles this, can remove this variable. Same for green blood
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the register functions are automatically called by shipinit then this isn't needed. As of now, the register functions aren't called automatically by shipinit for some reason. |
||
| bool hookEnabled = CVarGetInteger(CVAR_COSMETIC("Blood.Blue0Begin.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Blue0End.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Blue1Begin.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Blue1End.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Blue2Begin.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Blue2End.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Blue3Begin.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Blue3End.Changed"), 0); | ||
|
|
||
| if (previousHookState != hookEnabled) { | ||
| previousHookState = hookEnabled; | ||
|
|
||
| COND_VB_SHOULD(VB_BLOOD_SET_COLOR_BLUE, hookEnabled, { | ||
| EffectSparkInit* effectSparkInit = va_arg(args, EffectSparkInit*); | ||
| *should = false; // Don't run vanilla color set code | ||
| // Call a separate color set function (Inlining code here breaks COND_VB_SHOULD macro for some reason) | ||
| SetBlueBloodColor(effectSparkInit); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| static void RegisterGreenBloodHook() { | ||
| static bool previousHookState = false; | ||
| bool hookEnabled = CVarGetInteger(CVAR_COSMETIC("Blood.Green0Begin.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Green0End.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Green1Begin.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Green1End.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Green2Begin.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Green2End.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Green3Begin.Changed"), 0) || | ||
| CVarGetInteger(CVAR_COSMETIC("Blood.Green3End.Changed"), 0); | ||
|
|
||
| if (previousHookState != hookEnabled) { | ||
| previousHookState = hookEnabled; | ||
|
|
||
| COND_VB_SHOULD(VB_BLOOD_SET_COLOR_GREEN, hookEnabled, { | ||
| EffectSparkInit* effectSparkInit = va_arg(args, EffectSparkInit*); | ||
| *should = false; | ||
| SetGreenBloodColor(effectSparkInit); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| void RegisterCosmeticHooks() { | ||
| COND_HOOK(OnGenerationCompletion, | ||
| CVarGetInteger(CVAR_COSMETIC("RandomizeCosmeticsGenModes"), RANDOMIZE_OFF) == RANDOMIZE_ON_RANDO_GEN_ONLY, | ||
|
|
@@ -2716,7 +2832,31 @@ void RegisterCosmeticWidgets() { | |
| SohGui::mSohMenu->AddSearchWidget({ goronNeck, "Enhancements", "Cosmetics Editor", "Silly" }); | ||
| } | ||
|
|
||
| static RegisterShipInitFunc initFunc(RegisterCosmeticHooks, { | ||
| CVAR_COSMETIC("RandomizeCosmeticsGenModes"), | ||
| }); | ||
| static RegisterShipInitFunc initFunc_BlueBlood(RegisterBlueBloodHook, { | ||
| CVAR_COSMETIC("Blood.Blue0Begin.Changed"), | ||
| CVAR_COSMETIC("Blood.Blue0End.Changed"), | ||
| CVAR_COSMETIC("Blood.Blue1Begin.Changed"), | ||
| CVAR_COSMETIC("Blood.Blue1End.Changed"), | ||
| CVAR_COSMETIC("Blood.Blue2Begin.Changed"), | ||
| CVAR_COSMETIC("Blood.Blue2End.Changed"), | ||
| CVAR_COSMETIC("Blood.Blue3Begin.Changed"), | ||
| CVAR_COSMETIC("Blood.Blue3End.Changed"), | ||
| }); | ||
|
|
||
| static RegisterShipInitFunc initFunc_GreenBlood(RegisterGreenBloodHook, { | ||
| CVAR_COSMETIC("Blood.Green0Begin.Changed"), | ||
| CVAR_COSMETIC("Blood.Green0End.Changed"), | ||
| CVAR_COSMETIC("Blood.Green1Begin.Changed"), | ||
| CVAR_COSMETIC("Blood.Green1End.Changed"), | ||
| CVAR_COSMETIC("Blood.Green2Begin.Changed"), | ||
| CVAR_COSMETIC("Blood.Green2End.Changed"), | ||
| CVAR_COSMETIC("Blood.Green3Begin.Changed"), | ||
| CVAR_COSMETIC("Blood.Green3End.Changed"), | ||
| }); | ||
|
|
||
| static RegisterShipInitFunc initFunc_CosmeticHooks(RegisterCosmeticHooks, | ||
| { | ||
| CVAR_COSMETIC("RandomizeCosmeticsGenModes"), | ||
| }); | ||
|
|
||
| static RegisterMenuInitFunc menuInitFunc(RegisterCosmeticWidgets); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be necessary with shipinit hooks
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally not necessary due to automatic register/unregister calls by shipinit, but in my case it doesn't work. Despite all relevant CVar names (CVAR_COSMETIC("Blood.Blue0Begin.Changed") etc) are listed to be watched by RegisterShipInitFunc, the RegisterBlue/GreenBloodHook functions never gets called automatically when blood colors are changed from the default.