コード例 #1
0
        private void CreateButtonContainerComponent()
        {
            ButtonContainer          = new ComponentSave();
            ButtonContainer.Name     = "ButtonContainer";
            ButtonContainer.BaseType = "Container";
            ButtonContainer.Initialize(StandardElementsManager.Self.GetDefaultStateFor("Container"));

            InstanceSave buttonInContainer = new InstanceSave();

            buttonInContainer.Name     = "ButtonInstance";
            buttonInContainer.BaseType = "Button";
            ButtonContainer.Instances.Add(buttonInContainer);
        }
コード例 #2
0
        private void CreateButtonComponent()
        {
            Button          = new ComponentSave();
            Button.Name     = "VariableTestButton";
            Button.BaseType = "Sprite";
            Button.Initialize(StandardElementsManager.Self.GetDefaultStateFor("Sprite"));


            InstanceSave instance = new InstanceSave();

            instance.Name     = "TextInstance";
            instance.BaseType = "Text";
            Button.Instances.Add(instance);

            // Set the varlue for the Text's Text property
            Button.DefaultState.SetValue(instance.Name + "." + "Text", "Hello");
            VariableSave variableSave = Button.DefaultState.GetVariableSave(instance.Name + "." + "Text");

            variableSave.ExposedAsName = "ButtonText";
        }
コード例 #3
0
        private GeneralResponse GetReferencesInProjectOrDisk(string fileName, TopLevelOrRecursive topLevelOrRecursive, List <string> listToFill, ProjectOrDisk projectOrDisk)
        {
            GeneralResponse generalResponse = GeneralResponse.SuccessfulResponse;

            if (CanTrackDependenciesOn(fileName))
            {
                string extension = FileManager.GetExtension(fileName);

                string oldRelative = FileManager.RelativeDirectory;

                string gumxFile = null;


                FileManager.RelativeDirectory = GetGumxDirectory(fileName);
                LoadGumxIfNecessaryFromDirectory(FileManager.RelativeDirectory);

                string absoluteFileName = fileName;
                if (FileManager.IsRelative(absoluteFileName))
                {
                    absoluteFileName = FileManager.RelativeDirectory + absoluteFileName;
                }

                string errors = null;
                if (System.IO.File.Exists(absoluteFileName))
                {
                    switch (extension)
                    {
                    case "gumx":
                    {
                        try
                        {
                            LoadGumxIfNecessaryFromDirectory(FileManager.RelativeDirectory, force: true);
                            GetFilesReferencedBy(Gum.Managers.ObjectFinder.Self.GumProjectSave, topLevelOrRecursive, listToFill, projectOrDisk);
                        }
                        catch (Exception e)
                        {
                            errors =
                                "Error tracking Gum references for " + absoluteFileName + "\n" + e.ToString();
                        }
                    }
                    break;

                    case "gucx":
                    {
                        ComponentSave gumComponentSave = null;
                        try
                        {
                            gumComponentSave          = FileManager.XmlDeserialize <ComponentSave>(absoluteFileName);
                            gumComponentSave.FileName = absoluteFileName;
                            // See an explanation for this in LoadGumxIfNecessaryFromDirectory
                            gumComponentSave.Initialize(gumComponentSave.DefaultState);
                            GetFilesReferencedBy(gumComponentSave, topLevelOrRecursive, listToFill, projectOrDisk);
                        }
                        catch (Exception e)
                        {
                            errors =
                                "Error tracking Gum references for " + absoluteFileName + "\n" + e.ToString();
                        }
                    }
                    break;

                    case "gusx":
                    {
                        ScreenSave gumScreenSave = null;
                        try
                        {
                            gumScreenSave          = FileManager.XmlDeserialize <ScreenSave>(absoluteFileName);
                            gumScreenSave.FileName = absoluteFileName;
                            // See an explanation for this in LoadGumxIfNecessaryFromDirectory
                            gumScreenSave.Initialize(gumScreenSave.DefaultState);

                            GetFilesReferencedBy(gumScreenSave, topLevelOrRecursive, listToFill, projectOrDisk);
                        }
                        catch (Exception e)
                        {
                            errors =
                                "Error tracking Gum references for " + absoluteFileName + "\n" + e.ToString();
                        }
                    }
                    break;

                    case "gutx":
                    {
                        StandardElementSave standardElementSave = null;
                        try
                        {
                            standardElementSave          = FileManager.XmlDeserialize <StandardElementSave>(absoluteFileName);
                            standardElementSave.FileName = absoluteFileName;
                            // See an explanation for this in LoadGumxIfNecessaryFromDirectory
                            standardElementSave.Initialize(standardElementSave.DefaultState);

                            GetFilesReferencedBy(standardElementSave, topLevelOrRecursive, listToFill, projectOrDisk);
                        }
                        catch (Exception e)
                        {
                            errors =
                                "Error tracking Gum references for " + absoluteFileName + "\n" + e.ToString();
                        }
                    }
                    break;
                    }
                }

                if (errors != null)
                {
                    generalResponse = new GeneralResponse
                    {
                        Succeeded = false,
                        Message   = errors
                    };
                }

                FileManager.RelativeDirectory = oldRelative;
            }

            return(generalResponse);
        }