From 3dc7fac22a44bcb68726c380b36afefb93ea53b0 Mon Sep 17 00:00:00 2001 From: Victor Chelaru Date: Tue, 21 Nov 2023 05:05:00 -0700 Subject: [PATCH] Added support for SetByDerived on static variables --- .../PreviewProject/bin/Debug/AESettings.json | 2 +- .../CustomVariableSaveSetPropertyLogic.cs | 19 ++++++++++++++----- .../ElementInheritanceTypeCodeGenerator.cs | 5 ++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/FRBDK/AnimationEditor/PreviewProject/bin/Debug/AESettings.json b/FRBDK/AnimationEditor/PreviewProject/bin/Debug/AESettings.json index 7517c923b..11226e48d 100644 --- a/FRBDK/AnimationEditor/PreviewProject/bin/Debug/AESettings.json +++ b/FRBDK/AnimationEditor/PreviewProject/bin/Debug/AESettings.json @@ -1 +1 @@ -{"RecentFiles":["C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/Migo.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/Evilvine.achx","C:/Users/vchel/Documents/GitHub/FlatRedBall/FRBDK/Glue/OfficialPlugins/Wizard/EmbeddedContent/Platformer/PlatformerAnimations.achx","C:/Users/vchel/Documents/FlatRedBallProjects/WallJumpTutorial/WallJumpTutorial/Content/Entities/Player/PlatformerAnimations.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Bullet/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/masteroid/Masteroid/Content/GlobalContent/Asteroids.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/StaticDestroyableObject/AnimationChainListFile.achx","C:/Users/vchel/Documents/FlatRedBallProjects/Beefball3/Beefball3/Content/Screens/GameScreen/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Ui/Emoticons/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Prop/PropAnimations.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Player/PlayerBodyAnimations1.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/HomeBase/HomeBaseAnimations.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Player/FlashlightAnimations.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/EyeballThing.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/BoomBabyShoggoth.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyBullet/PoisonCloudAnimation.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyDeathEffect/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyBullet/BlackHoleShotAnimation.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyBullet/ParasiteShotAnimation.achx","C:/Users/vchel/Documents/FlatRedBallProjects/LiveEditTest/LiveEditTest/Content/Entities/AnimatedEntity/AnimationChainListFile.achx"]} \ No newline at end of file +{"RecentFiles":["C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/UiAnimationChains.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/Migo.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/Evilvine.achx","C:/Users/vchel/Documents/GitHub/FlatRedBall/FRBDK/Glue/OfficialPlugins/Wizard/EmbeddedContent/Platformer/PlatformerAnimations.achx","C:/Users/vchel/Documents/FlatRedBallProjects/WallJumpTutorial/WallJumpTutorial/Content/Entities/Player/PlatformerAnimations.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Bullet/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/masteroid/Masteroid/Content/GlobalContent/Asteroids.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/StaticDestroyableObject/AnimationChainListFile.achx","C:/Users/vchel/Documents/FlatRedBallProjects/Beefball3/Beefball3/Content/Screens/GameScreen/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Ui/Emoticons/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Prop/PropAnimations.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Player/PlayerBodyAnimations1.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/HomeBase/HomeBaseAnimations.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Player/FlashlightAnimations.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/EyeballThing.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/BoomBabyShoggoth.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyBullet/PoisonCloudAnimation.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyDeathEffect/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyBullet/BlackHoleShotAnimation.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyBullet/ParasiteShotAnimation.achx"]} \ No newline at end of file diff --git a/FRBDK/Glue/Glue/SetProperty/CustomVariableSaveSetPropertyLogic.cs b/FRBDK/Glue/Glue/SetProperty/CustomVariableSaveSetPropertyLogic.cs index 92e84234f..3750a4ae5 100644 --- a/FRBDK/Glue/Glue/SetProperty/CustomVariableSaveSetPropertyLogic.cs +++ b/FRBDK/Glue/Glue/SetProperty/CustomVariableSaveSetPropertyLogic.cs @@ -334,11 +334,20 @@ private static void HandleSetByDerivedChanged(CustomVariable customVariable, obj { bool didErrorOccur = false; - if (customVariable.SetByDerived && customVariable.IsShared) - { - GlueCommands.Self.DialogCommands.ShowMessageBox("Variables that are IsShared cannot be SetByDerived"); - didErrorOccur = true; - } + // November 20, 2023 + // This was a limitation + // for a long time, but we + // want to have the ability + // to define variables in the + // base class, and have those overridden + // in the derived. For example, an Enemy's + // display name should be defined in base, but + // set on derived like "Skeleton" or "Goblin". + //if (customVariable.SetByDerived && customVariable.IsShared) + //{ + //GlueCommands.Self.DialogCommands.ShowMessageBox("Variables that are IsShared cannot be SetByDerived"); + //didErrorOccur = true; + //} if (didErrorOccur) { diff --git a/FRBDK/Glue/OfficialPlugins/ElementInheritanceTypePlugin/CodeGenerators/ElementInheritanceTypeCodeGenerator.cs b/FRBDK/Glue/OfficialPlugins/ElementInheritanceTypePlugin/CodeGenerators/ElementInheritanceTypeCodeGenerator.cs index 602ff2d43..bb42701b4 100644 --- a/FRBDK/Glue/OfficialPlugins/ElementInheritanceTypePlugin/CodeGenerators/ElementInheritanceTypeCodeGenerator.cs +++ b/FRBDK/Glue/OfficialPlugins/ElementInheritanceTypePlugin/CodeGenerators/ElementInheritanceTypeCodeGenerator.cs @@ -62,7 +62,10 @@ public override void GenerateAdditionalClasses(ICodeBlock codeBlock, IElement el block.Line($"GetFile = {QualifiedTypeName(derivedElement)}.GetFile,"); block.Line($"LoadStaticContent = {QualifiedTypeName(derivedElement)}.LoadStaticContent,"); - foreach (var variable in element.CustomVariables.Where(item => item.SetByDerived && !item.IsShared)) + foreach (var variable in element.CustomVariables.Where(item => item.SetByDerived + // Why don't we generate is shared? Now that we can inherit shared variables, let's do it so that the user can specify variables for the type, like a Display Name + //&& !item.IsShared + )) { if (!ShouldSkip(variable)) {