Extracts code files from an assembly and saves them to disk, relative to the current project.
Esempio n. 1
0
        public override void StartUp()
        {
            // Do anything your plugin needs to do when it first starts up
            mCoreItemAdder = new CodeBuildItemAdder();
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.AfterThatDecision.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.DecisionAndList.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.DecisionOrList.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.DelegateDecision.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.GeneralAction.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.GeneralDecision.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.IDecisionList.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.IDoScriptEngine.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.IIfScriptEngine.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.IScriptAction.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.IScriptDecision.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.Script.cs");
            mCoreItemAdder.Add("GameScriptingPlugin.EmbeddedCodeFiles.ScriptEngine.cs");

            mCoreItemAdder.OutputFolderInProject = "GameScriptingCore";
            //this.ReactToLoadedGlux += HandleOpenProject;

            this.AddMenuItemTo("Add Game Script Core Classes", HandleAddGameScript, "Plugins");

            mDebuggingItemAdder = new CodeBuildItemAdder();
            mDebuggingItemAdder.Add(
                "GameScriptingPlugin/EmbeddedCodeFilesDebugging/ScriptDebuggingForm.cs");
            mDebuggingItemAdder.Add(
                "GameScriptingPlugin/EmbeddedCodeFilesDebugging/ScriptDebuggingForm.Designer.cs");

            mDebuggingItemAdder.OutputFolderInProject = "GameScriptingDebugging";

            this.AddMenuItemTo("Add Game Script Debugging Classes", HandleAddGameScriptDebugging, "Plugins");
        }
        public override void StartUp()
        {
            CanFileReferenceContent += absoluteFileName => !string.IsNullOrEmpty(absoluteFileName) &&
                                               FileManager.GetExtension(absoluteFileName).ToLowerInvariant() ==
                                               "scml";
            GetFilesReferencedBy += GetFilesReferencedByFunc;

            AvailableAssetTypes.Self.AddAssetType(new AssetTypeInfo
            {
                FriendlyName = "SpriterObjectCollection (.scml)",
                CanBeObject = true,
                QualifiedRuntimeTypeName = new PlatformSpecificType{ Platform = "All", QualifiedType = "FlatRedBall_Spriter.SpriterObjectCollection"},
                QualifiedSaveTypeName = "FlatRedBall_Spriter.SpriterObjectSave",
                Extension = "scml",
                AddToManagersMethod = new List<string>{ "this.AddToManagers()" },
                LayeredAddToManagersMethod = new List<string>{ "this.AddToManagers(mLayer)" },
                CustomLoadMethod = "{THIS} = FlatRedBall_Spriter.SpriterObjectSave.FromFile(\"{FILE_NAME}\").ToRuntime();",
                DestroyMethod = "this.Destroy()",
                ShouldAttach = true,
                MustBeAddedToContentPipeline = false,
                CanBeCloned = true,
                HasCursorIsOn = false,
                HasVisibleProperty = false,
                CanIgnorePausing = false,
                ExtraVariablesPattern = "float RelativeScaleX; float RelativeScaleY; bool ParentScaleChangesPosition; bool RenderBones; bool RenderPoints; bool RenderCollisionBoxes; bool FlipHorizontal; float AnimationSpeed"
            });

            AvailableAssetTypes.Self.AddAssetType(new AssetTypeInfo
            {
                FriendlyName = "SpriterObject",
                CanBeObject = true,
                QualifiedRuntimeTypeName = new PlatformSpecificType { Platform = "All", QualifiedType = "FlatRedBall_Spriter.SpriterObject" },
                QualifiedSaveTypeName = "FlatRedBall_Spriter.SpriterObjectSave",
                AddToManagersMethod = new List<string> { "this.AddToManagers()" },
                LayeredAddToManagersMethod = new List<string> { "this.AddToManagers(mLayer)" },
                FindByNameSyntax = "FindByName(\"OBJECTNAME\")",
                DestroyMethod = "this.Destroy()",
                ShouldAttach = true,
                MustBeAddedToContentPipeline = false,
                CanBeCloned = true,
                HasCursorIsOn = false,
                HasVisibleProperty = false,
                CanIgnorePausing = false,
                ExtraVariablesPattern = "float RelativeScaleX; float RelativeScaleY; bool ParentScaleChangesPosition; bool RenderBones; bool RenderPoints; bool RenderCollisionBoxes; bool FlipHorizontal; float AnimationSpeed"
            });

            _itemAdder = new CodeBuildItemAdder();

            _itemAdder.Add("SpriterPlugin.FlatRedBallTextureLoader.cs");
            _itemAdder.Add("SpriterPlugin.ITextureLoader.cs");
            _itemAdder.Add("SpriterPlugin.KeyFrame.cs");
            _itemAdder.Add("SpriterPlugin.KeyFrameValues.cs");
            _itemAdder.Add("SpriterPlugin.SpriterObject.cs");
            _itemAdder.Add("SpriterPlugin.SpriterObjectAnimation.cs");
            _itemAdder.Add("SpriterPlugin.SpriterObjectSave.conversion.cs");
            _itemAdder.Add("SpriterPlugin.SpriterObjectSave.serialization.cs");
            _itemAdder.Add("SpriterPlugin.IRelativeScalable.cs");
            _itemAdder.Add("SpriterPlugin.ScaledPositionedObject.cs");
            _itemAdder.Add("SpriterPlugin.ScaledPositionedObjectExtensions.cs");
            _itemAdder.Add("SpriterPlugin.ScaledSprite.cs");
            _itemAdder.Add("SpriterPlugin.SpriterPoint.cs");
            _itemAdder.Add("SpriterPlugin.ScaledPolygon.cs");
            _itemAdder.Add("SpriterPlugin.SpriterBone.cs");
            _itemAdder.Add("SpriterPlugin.SpriterObjectCollection.cs");

            _itemAdder.OutputFolderInProject = "SpriterPlugin";

            // Add the following code to your StartUp method:
            ReactToLoadedGlux += HandleGluxLoad;

            TryAddContainedObjects += OnTryAddContainedObjects;

            var assembly = Assembly.GetExecutingAssembly();
            string whatToSave = "SpriterPlugin.Content.SpriterTemplate.scml";

            string destination = FileManager.UserApplicationData + @"Glue\FilesForAddNewFile\SpriterTemplate.scml";

            try
            {
                FileManager.SaveEmbeddedResource(assembly, whatToSave, destination);
            }
            catch (Exception e)
            {
                PluginManager.ReceiveError("Error trying to save spriter template: [" + e.ToString() + "]");
            }
        }