Esempio n. 1
0
        private void CreateUIPanelCode(GameObject uiPrefab, string uiPrefabPath)
        {
            if (null == uiPrefab)
            {
                return;
            }

            var behaviourName = uiPrefab.name;

            var strFilePath = CodeGenUtil.GenSourceFilePathFromPrefabPath(uiPrefabPath, behaviourName);

            if (File.Exists(strFilePath) == false)
            {
                RegisteredTemplateGeneratorsFactory.RegisterTemplate <PanelCodeData, UIPanelDataTemplate>();
                RegisteredTemplateGeneratorsFactory.RegisterTemplate <PanelCodeData, UIPanelTemplate>();

                var factory = new RegisteredTemplateGeneratorsFactory();

                var generators = factory.CreateGenerators(new UIGraph(), UIMarkCollector.mPanelCodeData);

                CompilingSystem.GenerateFile(new FileInfo(strFilePath), new CodeFileGenerator(UIKitSettingData.GetProjectNamespace())
                {
                    Generators = generators.ToArray()
                });

                RegisteredTemplateGeneratorsFactory.UnRegisterTemplate <PanelCodeData>();
            }

            CreateUIPanelDesignerCode(behaviourName, strFilePath);
            Debug.Log(">>>>>>>Success Create UIPrefab Code: " + behaviourName);
        }
Esempio n. 2
0
        private void CreateUIPanelDesignerCode(string behaviourName, string uiUIPanelfilePath)
        {
            var dir = uiUIPanelfilePath.Replace(behaviourName + ".cs", "");
            var generateFilePath = dir + behaviourName + ".Designer.cs";

            RegisteredTemplateGeneratorsFactory.RegisterTemplate <PanelCodeData, UIPanelDesignerTemplate>();

            var factory = new RegisteredTemplateGeneratorsFactory();

            var generators = factory.CreateGenerators(new UIGraph(), UIMarkCollector.mPanelCodeData);

            CompilingSystem.GenerateFile(new FileInfo(generateFilePath), new CodeFileGenerator(UIKitSettingData.GetProjectNamespace())
            {
                Generators = generators.ToArray()
            });

            RegisteredTemplateGeneratorsFactory.UnRegisterTemplate <PanelCodeData>();

            foreach (var elementCodeData in UIMarkCollector.mPanelCodeData.ElementCodeDatas)
            {
                var elementDir = string.Empty;
                elementDir = elementCodeData.MarkedObjInfo.MarkObj.GetUIMarkType() == UIMarkType.Element
                                        ? (dir + behaviourName + "/").CreateDirIfNotExists()
                                        : (Application.dataPath + "/" + UIKitSettingData.GetScriptsPath() + "/Components/").CreateDirIfNotExists();
                CreateUIElementCode(elementDir, elementCodeData);
            }
        }
Esempio n. 3
0
        public override void Initialize(UFrameContainer container)
        {
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <SystemNode, SystemTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <SystemNode, SystemPartialTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <ComponentNode, ComponentTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <ComponentNode, ComponentEditableTemplate>();
            //            RegisteredTemplateGeneratorsFactory.RegisterTemplate<ComponentGroupNode,ComponentGroupTemplate>();
            //          RegisteredTemplateGeneratorsFactory.RegisterTemplate<ComponentGroupNode,ComponentGroupManagerTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <EventNode, EventTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <GroupNode, GroupTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <GroupNode, GroupItemTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <HandlerNode, HandlerTemplate>();
            //RegisteredTemplateGeneratorsFactory.RegisterTemplate<HandlerNode, EditableHandlerTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <uFrameDatabaseConfig, DbLoaderTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <uFrameDatabaseConfig, EcsEditorExtensionTemplate>();
            //RegisteredTemplateGeneratorsFactory.RegisterTemplate<PropertyChangedNode, PropertyHandlerTemplate>();
            //            RegisteredTemplateGeneratorsFactory.RegisterTemplate<EntityNode, EntityTemplate>();

            RegisteredTemplateGeneratorsFactory.RegisterTemplate <CustomActionNode, CustomActionEditableTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <CustomActionNode, CustomActionDesignerTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <CustomActionNode, CustomActionSequenceTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <CodeActionNode, CodeActionEditableTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <CodeActionNode, CodeActionDesignerTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <SystemNode, LoaderTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <ModuleNode, ComponentExtensionsTemplate>();

            RegisteredTemplateGeneratorsFactory.RegisterTemplate <DescriptorNode, DescriptorInterfaceTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <DescriptorNode, DescriptorAttributeTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <DescriptorNode, DescriptorGroupTemplate>();
        }
Esempio n. 4
0
        public override void Initialize(UFrameContainer container)
        {
            // Grab a reference to the main framework graphs plugin
            var framework = container.Resolve <uFrameMVVM>();

            //Framework.ElementsGraphRoot.AddCodeTemplate<BackupData>();
            // Register the code template
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <PropertiesChildItem, SetPropertyActionsTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <PropertiesChildItem, GetPropertyActionsTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <PropertiesChildItem, GetCurrentStateActionsTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <PropertiesChildItem, CheckPropertyActionsTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <PropertiesChildItem, CheckStateActionsTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <CommandsChildItem, ExecuteCommandsActionsTemplate>();

            framework.ComputedProperty.AddCodeTemplate <ComputedPropertyActionsTemplate>();
            framework.ComputedProperty.AddCodeTemplate <CheckComputedPropertyActionsTemplate>();
        }
        private void CreateUIPanelDesignerCode(string behaviourName, string uiUIPanelfilePath, PanelCodeInfo panelCodeInfo)
        {
            var dir = uiUIPanelfilePath.Replace(behaviourName + ".cs", "");
            var generateFilePath = dir + behaviourName + ".Designer.cs";

            if (mScriptKitInfo.IsNotNull())
            {
                if (mScriptKitInfo.Templates.IsNotNull() && mScriptKitInfo.Templates[1].IsNotNull())
                {
                    mScriptKitInfo.Templates[1].Generate(generateFilePath, behaviourName, UIKitSettingData.GetProjectNamespace(), panelCodeInfo);
                }
                mScriptKitInfo.HotScriptFilePath.CreateDirIfNotExists();
                mScriptKitInfo.HotScriptFilePath = mScriptKitInfo.HotScriptFilePath + "/" + behaviourName + mScriptKitInfo.HotScriptSuffix;
                if (File.Exists(mScriptKitInfo.HotScriptFilePath) == false && mScriptKitInfo.Templates.IsNotNull() && mScriptKitInfo.Templates[2].IsNotNull())
                {
                    mScriptKitInfo.Templates[2].Generate(mScriptKitInfo.HotScriptFilePath, behaviourName, UIKitSettingData.GetProjectNamespace(), panelCodeInfo);
                }
            }
            else
            {
                RegisteredTemplateGeneratorsFactory.RegisterTemplate <PanelCodeInfo, UIPanelDesignerTemplate>();

                var factory = new RegisteredTemplateGeneratorsFactory();

                var generators = factory.CreateGenerators(new UIGraph(), panelCodeInfo);

                CompilingSystem.GenerateFile(new FileInfo(generateFilePath), new CodeFileGenerator(UIKitSettingData.GetProjectNamespace())
                {
                    Generators = generators.ToArray()
                });

                RegisteredTemplateGeneratorsFactory.UnRegisterTemplate <PanelCodeInfo>();
            }

            foreach (var elementCodeData in panelCodeInfo.ElementCodeDatas)
            {
                var elementDir = string.Empty;
                elementDir = elementCodeData.BindInfo.BindScript.GetBindType() == BindType.Element
                                        ? (dir + behaviourName + "/").CreateDirIfNotExists()
                                        : (Application.dataPath + "/" + UIKitSettingData.GetScriptsPath() + "/Components/").CreateDirIfNotExists();
                CreateUIElementCode(elementDir, elementCodeData);
            }
        }
Esempio n. 6
0
        public override void Initialize(UFrameContainer container)
        {
            base.Initialize(container);
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <SubSystemNode, SystemLoaderTemplate>();
            //RegisteredTemplateGeneratorsFactory.RegisterTemplate<SubSystemNode, SystemLoaderPartialTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <SceneTypeNode, SceneTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <SceneTypeNode, SceneLoaderTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <SceneTypeNode, SceneSettingsTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <ServiceNode, ServiceTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <SimpleClassNode, SimpleClassTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <ElementNode, ViewModelTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <ElementNode, ViewModelConstructorTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <ElementNode, ControllerTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <CommandsChildItem, ViewModelCommandClassTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <CommandNode, CommandTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <ViewNode, ViewTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <StateMachineNode, StateMachineTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <StateNode, StateTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <ViewComponentNode, ViewComponentTemplate>();

            // Register bindable methods
            AddBindingMethods(container);
            AddBindingMethods_UGUIExtenstions(container);
        }
Esempio n. 7
0
    public override void Initialize(UFrameContainer container)
    {
#if DEBUG && UNITY_EDITOR
        //container.RegisterInstance<IToolbarCommand>(new PrintPlugins(), "Json");
#endif
        //container.RegisterInstance<IDiagramNodeCommand>(new SelectColorCommand(), "SelectColor");
        var pluginConfig = container
                           .AddItem <ShellNodeSectionsSlot>()
                           .AddItem <ShellNodeInputsSlot>()
                           .AddItem <ShellNodeOutputsSlot>()
                           .AddItem <TemplatePropertyReference>()
                           .AddItem <TemplateMethodReference>()
                           .AddItem <TemplateFieldReference>()
                           .AddItem <TemplateEventReference>()
                           .AddItem <ShellAcceptableReferenceType>()
                           .AddItem <ShellConnectableReferenceType>()
                           .AddTypeItem <ShellPropertySelectorItem>()
                           .AddGraph <PluginGraphData, ShellPluginNode>("Shell Plugin")
                           .Color(NodeColor.Green)

                           .HasSubNode <IShellNode>()
                           .HasSubNode <TypeReferenceNode>()
                           .HasSubNode <ShellNodeConfig>()
                           .HasSubNode <ScreenshotNode>()
#if UNITY_EDITOR
                           // .AddCodeTemplate<DocumentationTemplate>()
#endif
        ;
        // container.AddNode<ScreenshotNode, ScreenshotNodeViewModel, ScreenshotNodeDrawer>("Screenshot");
        container.AddWorkspaceConfig <ArchitectWorkspace>("Architect", "Create a uFrame Architect workspace for creating plugin graphs.")
        .WithGraph <PluginGraphData>("Plugin", "Creates a new plugin graph for creating node configurations.");
        var shellConfigurationNode =
            container.AddNode <ShellNodeConfig, ShellNodeConfigViewModel, ShellNodeConfigDrawer>("Node Config")
            .HasSubNode <ShellNodeConfig>()
            .HasSubNode <ScreenshotNode>()
            .HasSubNode <ShellTemplateConfigNode>()
        ;
        // shellConfigurationNode.AddFlag("Graph Type");

        container.AddNode <ShellTemplateConfigNode>("Code Template")
        .Color(NodeColor.Purple);


        RegisteredTemplateGeneratorsFactory.RegisterTemplate <ShellNodeConfig, ShellNodeConfigTemplate>();
        RegisteredTemplateGeneratorsFactory.RegisterTemplate <ShellNodeConfigSection, ShellNodeConfigReferenceSectionTemplate>();
        RegisteredTemplateGeneratorsFactory.RegisterTemplate <ShellNodeConfigSection, ShellNodeConfigChildItemTemplate>();
        RegisteredTemplateGeneratorsFactory.RegisterTemplate <ShellNodeConfig, ShellNodeAsGraphTemplate>();
        RegisteredTemplateGeneratorsFactory.RegisterTemplate <ShellPluginNode, ShellConfigPluginTemplate>();
        RegisteredTemplateGeneratorsFactory.RegisterTemplate <ShellNodeConfig, ShellNodeConfigViewModelTemplate>();
        RegisteredTemplateGeneratorsFactory.RegisterTemplate <ShellNodeConfig, ShellNodeConfigDrawerTemplate>();
        RegisteredTemplateGeneratorsFactory.RegisterTemplate <ShellTemplateConfigNode, ShellNodeConfigTemplateTemplate>();
        RegisteredTemplateGeneratorsFactory.RegisterTemplate <IShellSlotType, ShellSlotItemTemplate>();
#if UNITY_EDITOR
        if (GenerateDocumentation)
        {
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <ShellPluginNode, DocumentationTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <IDocumentable, DocumentationPageTemplate>();
        }
#endif


        container.Connectable <ShellNodeConfigSection, ShellNodeConfig>();
        container.Connectable <ShellNodeConfigSection, ShellNodeConfigSection>();
        container.Connectable <IShellNodeConfigItem, IShellNodeConfigItem>();
        container.Connectable <ShellNodeConfigOutput, ShellNodeConfigInput>();
        container.Connectable <ShellNodeConfigOutput, ShellNodeConfig>();
        container.Connectable <ShellNodeConfigOutput, ShellNodeConfigSection>();
        container.Connectable <ShellNodeConfig, ShellNodeConfigInput>();
        container.Connectable <ShellNodeConfig, ShellNodeConfigSection>();
        container.Connectable <IShellNodeConfigItem, ShellTemplateConfigNode>();

        container.Connectable <ShellNodeConfigSection, ShellNodeConfigInput>();

        container.Connectable <ShellNodeConfigSection, ShellNodeConfigSection>();
    }
        public override void Initialize(UFrameContainer container)
        {
            // Grab a reference to the main framework graphs plugin
            Framework = container.Resolve <uFrameMVVM>();
            //Framework.ElementsGraphRoot.AddCodeTemplate<BackupData>();
            // Register the code template
            Framework.Service.AddCodeTemplate <ServiceTemplate>();
            Framework.SimpleClass.AddCodeTemplate <SimpleClassTemplate>();
            Framework.Element.AddCodeTemplate <ControllerTemplate>();
            Framework.Element.AddCodeTemplate <ViewModelTemplate>();
            Framework.Element.AddCodeTemplate <ViewModelConstructorTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <CommandsChildItem, ViewModelCommandClassTemplate>();
            RegisteredTemplateGeneratorsFactory.RegisterTemplate <CommandNode, CommandClassTemplate>();
            //Framework.SceneManager.AddCodeTemplate<SceneManagerTemplate>();
            //Framework.SceneManager.AddCodeTemplate<SceneManagerSettingsTemplate>();
            Framework.SceneType.AddCodeTemplate <SceneTemplate>();
            Framework.SceneType.AddCodeTemplate <SceneSettingsTemplate>();
            Framework.Subsystem.AddCodeTemplate <SystemLoaderTemplate>();
            Framework.SceneType.AddCodeTemplate <SceneLoaderTemplate>();
            Framework.View.AddCodeTemplate <ViewTemplate>();
            Framework.ViewComponent.AddCodeTemplate <ViewComponentTemplate>();
            Framework.State.AddCodeTemplate <StateTemplate>();
            Framework.StateMachine.AddCodeTemplate <StateMachineTemplate>();

            // Register our bindable methods
            container.AddBindingMethod(typeof(ViewBindings), "BindProperty",
                                       _ => _ is PropertiesChildItem || _ is ComputedPropertyNode)
            .SetNameFormat("{0} Changed")
            .ImplementWith(args =>
            {
                var sourceItem = args.SourceItem as ITypedItem;

                if (sourceItem.RelatedNode() is StateMachineNode)
                {
                    args.Method.Parameters.Clear();
                    args.Method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(State), "State"));
                }
            })
            ;

            container.AddBindingMethod(typeof(ViewBindings), "BindStateProperty",
                                       _ => _ is PropertiesChildItem && _.RelatedNode() is StateMachineNode)
            .SetNameFormat("{0} State Changed")
            .SetDescription(
                "Binding to a state property creates methods for each state, and in the designer code will property call the each state's method when it changes.")
            .ImplementWith(args =>
            {
                args.Method.Parameters[0].Type = typeof(State).ToCodeReference();
                var sourceItem   = args.SourceItem as ITypedItem;
                var stateMachine = sourceItem.RelatedNode() as StateMachineNode;
                if (args.IsDesignerFile)
                {
                    foreach (var state in stateMachine.States)
                    {
                        var method = new CodeMemberMethod()
                        {
                            Name       = "On" + state.Name,
                            Attributes = MemberAttributes.Public
                        };
                        var conditionStatement =
                            new CodeConditionStatement(
                                new CodeSnippetExpression(string.Format("arg1 is {0}", state.Name)));
                        conditionStatement.TrueStatements.Add(
                            new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), method.Name));

                        args.Method.Statements.Add(conditionStatement);
                        args.Decleration.Members.Add(method);
                    }
                }

                args.Method.Parameters[0].Type = "Invert.StateMachine.State".ToCodeReference();
            });

            container.AddBindingMethod(typeof(ViewBindings), "BindCollection", _ => _ is CollectionsChildItem)
            .SetNameFormat("{0} Collection Changed")
            .SetDescription(
                "Collection bindings bind to a collection giving you two methods, {CollectionName}Added, and {CollectionName}Removed, override these methods to execute something when the collection is modified.")
            ;

            container.AddBindingMethod(typeof(ViewBindings), "BindToViewCollection", _ => _ is CollectionsChildItem)
            .SetNameFormat("{0} View Collection Changed")
            .SetDescription(
                "The view collection changed binding automatically creates views for each element's viewmodel when created.")
            .ImplementWith(args =>
            {
                if (args.Method.Name.EndsWith("CreateView"))
                {
                    args.Method.Parameters[0].Name = "viewModel";
                    args.Method._("return InstantiateView(viewModel)");
                }
                else
                {
                    args.Method.Parameters[0].Name = "view";
                }
            })
            ;

            container.AddBindingMethod(typeof(ViewBindings), "BindCommandExecuted", _ => _ is CommandsChildItem)
            .SetNameFormat("{0} Executed")
            .SetDescription(
                "The executed binding is for listening to when a command is invoked on a view.  It will provide you with a method in the format {CommandName}Executed({CommandClass} data)")

            .ImplementWith(args =>
            {
                args.Method.Parameters[0].Name = "command";
                var commandItem = args.SourceItem as CommandsChildItem;
                args.Method.Parameters[0].Type = commandItem.ClassName.ToCodeReference();
            })
            ;

            container.AddBindingMethod(typeof(UGUIExtensions), "BindInputFieldToProperty",                        // Registration
                                       _ => _ is PropertiesChildItem && _.RelatedTypeName == typeof(string).Name) // Validation
            .SetDescription(
                "Binds a string property to an uGUI input field.  A field will be created on the view for specifying the uGUI field.")
            .SetNameFormat("{0} To Input Field")     // Configuration
            ;

            container.AddBindingMethod(typeof(UGUIExtensions), "BindButtonToCommand", _ => _ is CommandsChildItem)
            .SetDescription(
                "The ButtonToCommand binding will create a reference to a uGUI button on the view and automatically wire the click event to invoke the command.")
            .SetNameFormat("{0} To Button");
            container.AddBindingMethod(typeof(UGUIExtensions), "BindToggleToProperty",
                                       _ => _ is PropertiesChildItem && _.RelatedTypeName == typeof(bool).Name)
            .SetDescription("Bind toggle to property will bind a boolean property directly to a uGUI toggle box.")
            .SetNameFormat("{0} To Toggle");
            container.AddBindingMethod(typeof(UGUIExtensions), "BindTextToProperty",
                                       _ => _ is PropertiesChildItem && _.RelatedTypeName == typeof(string).Name)
            .SetDescription("Binds a string property to a uGUI text label.")
            .SetNameFormat("{0} To Text");

            container.AddBindingMethod(typeof(UGUIExtensions), "BindSliderToProperty",
                                       _ => _ is PropertiesChildItem && _.RelatedTypeName == typeof(float).Name)
            .SetDescription("Binds a slider to a float value.")
            .SetNameFormat("{0} To Slider");
        }