Example #1
0
        private void InitializeBuildPage()
        {
            m_buildPage      = new BuildPageControl();
            m_buildPage.Dock = DockStyle.Fill;
            m_mainPanel.Controls.Add(m_buildPage);

            AddTabPage(m_buildPage, TAB_NAME_BUILD);

            m_buildPage.RefreshContent();
            if (m_projectManagerPanel != null)
            {
                m_projectManagerPanel.RebuildList();
            }
        }
Example #2
0
        private void OnAction(Action action)
        {
            if (action == null)
            {
                return;
            }

            if (action.Id == "CbpChanged")
            {
                Console.WriteLine("CBP project file changed!");
                if (ProjectModel != null)
                {
                    ProjectModel.UpdateFromCbp();
                    MetaComponentsManager.Instance.UnregisterAllMetaComponents();
                    Parallel.Invoke(
                        () => LoadSdkMetaFiles(),
                        () => GenerateProjectMetaFiles()
                        );
                    if (m_buildPage != null)
                    {
                        m_buildPage.RefreshContent();
                    }
                    if (m_projectManagerPanel != null)
                    {
                        m_projectManagerPanel.RebuildList();
                    }
                }
            }
            else if (action.Id == "EditorCbpChanged")
            {
                Console.WriteLine("Editor CBP project file changed!");
                if (m_buildPage != null && !m_buildPage.IsBatchProcessRunning && ProjectModel != null && !string.IsNullOrEmpty(ProjectModel.EditorCbpPath))
                {
                    if (m_scenePage != null)
                    {
                        m_scenePage.SaveSceneBackup();
                    }
                    SceneViewPlugin.Unload();
                    m_buildPage.BatchOperationProject(
                        BuildPageControl.BatchOperationMode.Rebuild,
                        null,
                        ProjectModel.WorkingDirectory + @"\" + ProjectModel.EditorCbpPath
                        );
                }
            }
            else if (action.Id == "SceneViewPluginChanged")
            {
                Console.WriteLine("Editor components plugin changed!");
                if (ProjectModel != null && !string.IsNullOrEmpty(ProjectModel.EditorPluginPath))
                {
                    string pluginPath = ProjectModel.WorkingDirectory + @"\" + ProjectModel.EditorPluginPath;
                    SceneViewPlugin.Unload();
                    if (SceneViewPlugin.Load(pluginPath))
                    {
                        if (m_scenePage != null)
                        {
                            m_scenePage.ReinitializeRenderer();
                        }
                        List <string> clist = SceneViewPlugin.ListComponents();
                        if (clist != null && clist.Count > 0)
                        {
                            foreach (string c in clist)
                            {
                                Console.WriteLine("Registered component: " + c);
                            }
                        }
                        if (m_scenePage != null)
                        {
                            m_scenePage.OpenSceneBackup();
                        }
                    }
                }
            }
            else if (action.Id == "LoadMetaComponent" && action.Params != null && action.Params.Length > 0)
            {
                string path = action.Params[0] as string;
                if (!String.IsNullOrEmpty(path) && ProjectModel != null)
                {
                    Console.WriteLine("Load meta-component for: \"{0}\"", path);
                    string metaPath = path + ".meta";
                    if (File.Exists(metaPath))
                    {
                        string        json = File.ReadAllText(metaPath);
                        MetaComponent meta = Newtonsoft.Json.JsonConvert.DeserializeObject <MetaComponent>(json);
                        MetaComponentsManager.Instance.UnregisterMetaComponent(meta);
                        ProjectModel.MetaComponentPaths.Remove(path);
                        if (meta != null)
                        {
                            MetaComponentsManager.Instance.RegisterMetaComponent(meta);
                            ProjectModel.MetaComponentPaths.Add(path, meta);
                            if (meta.Properties != null && meta.Properties.Count > 0)
                            {
                                foreach (MetaProperty prop in meta.Properties)
                                {
                                    if (PropertyEditorsManager.Instance.FindPropertyEditor(prop.ValueType) == null)
                                    {
                                        Console.WriteLine("Property editor for type: \"{0}\" (component: \"{1}\", property: \"{2}\") not found!", prop.ValueType, meta.Name, prop.Name);
                                    }
                                }
                            }
                        }
                    }
                    if (m_projectManagerPanel != null)
                    {
                        m_projectManagerPanel.UpdateFile(path);
                    }
                    GenerateProjectCodeFiles();
                }
            }
            else if (action.Id == "RemoveMetaComponent" && action.Params != null && action.Params.Length > 0)
            {
                string path = action.Params[0] as string;
                if (!String.IsNullOrEmpty(path) && ProjectModel != null && ProjectModel.MetaComponentPaths.ContainsKey(path))
                {
                    Console.WriteLine("Remove meta-component for: \"{0}\"", path);
                    MetaComponentsManager.Instance.UnregisterMetaComponent(ProjectModel.MetaComponentPaths[path]);
                    ProjectModel.MetaComponentPaths.Remove(path);
                    if (m_projectManagerPanel != null)
                    {
                        m_projectManagerPanel.UpdateFile(path);
                    }
                    GenerateProjectCodeFiles();
                }
            }
            else if (action.Id == "LoadMetaAsset" && action.Params != null && action.Params.Length > 0)
            {
                string path = action.Params[0] as string;
                if (!String.IsNullOrEmpty(path) && ProjectModel != null)
                {
                    Console.WriteLine("Load meta-asset for: \"{0}\"", path);
                    string metaPath = path + ".meta";
                    if (File.Exists(metaPath))
                    {
                        string    json = File.ReadAllText(metaPath);
                        MetaAsset meta = Newtonsoft.Json.JsonConvert.DeserializeObject <MetaAsset>(json);
                        MetaAssetsManager.Instance.UnregisterMetaAsset(meta);
                        ProjectModel.MetaAssetsPaths.Remove(path);
                        if (meta != null)
                        {
                            MetaAssetsManager.Instance.RegisterMetaAsset(meta);
                            ProjectModel.MetaAssetsPaths.Add(path, meta);
                        }
                    }
                    if (m_projectManagerPanel != null)
                    {
                        m_projectManagerPanel.UpdateFile(path);
                    }
                    GenerateProjectCodeFiles();
                }
            }
            else if (action.Id == "RemoveMetaAsset" && action.Params != null && action.Params.Length > 0)
            {
                string path = action.Params[0] as string;
                if (!String.IsNullOrEmpty(path) && ProjectModel != null && ProjectModel.MetaAssetsPaths.ContainsKey(path))
                {
                    Console.WriteLine("Remove meta-asset for: \"{0}\"", path);
                    MetaAssetsManager.Instance.UnregisterMetaAsset(ProjectModel.MetaAssetsPaths[path]);
                    ProjectModel.MetaAssetsPaths.Remove(path);
                    if (m_projectManagerPanel != null)
                    {
                        m_projectManagerPanel.UpdateFile(path);
                    }
                    GenerateProjectCodeFiles();
                }
            }
            else if (action.Id == "GameObjectIdChanged" && action.Params != null && action.Params.Length > 0)
            {
                if (m_scenePage != null)
                {
                    m_scenePage.SceneTreeChangeGameObjectId((int)action.Params[0]);
                }
            }
        }