Exemplo n.º 1
0
        public void Init(ViewConfig elementConfig)
        {
            if (elementConfig is ElementConfig)
            {
                this.elementConfig = elementConfig as ElementConfig;
                name = elementConfig.Name;

                foreach (var attribute in BeforeInitAttribute(this.elementConfig.Attributes))
                {
                    MB2CustomEditorView view;
                    if (!ElementViewManager.GetView(attribute.Type, out view))
                    {
                        view = new NotSupportView();
                    }
                    view.Init(attribute);

                    attributeViews.Add(attribute.Name, view);
                }
                AfterInitAttribute(attributeViews);

                foreach (var element in BeforeInitNestedElement(this.elementConfig.NestedElements))
                {
                    MB2CustomEditorView view;
                    if (!ElementViewManager.GetView(element.Name, out view))
                    {
                        view = new ElementView();
                    }
                    view.Init(element);
                    nestedElementExpanded.Add(element.Name, true);
                    nestedElementViews.Add(element.Name, view);
                }
                AfterInitNestedElement(nestedElementViews);
            }
        }
Exemplo n.º 2
0
        // Call this function when editor start up
        static StartUp()
        {
            InitLayout();

            ElementViewManager.RegisterAssemby(typeof(StringInput).Assembly);
            //TODO: TEST Only, for NPCCharacter
            XmlDocument doc = new XmlDocument();

            doc.Load(Application.dataPath + @"/MB2Editor/Resources/XSD/NPCCharacters.xsd");
            ConfigManager.RegisterFromXsd(doc);

            UpdateSupportFileType();
        }
Exemplo n.º 3
0
        static void SimpleBuild()
        {
            string outputPath;

            if ((outputPath = EditorUtility.SaveFolderPanel("Save output to", "", "")) != "")
            {
                float ratio = 0;
                float step  = 0;
                if (Directory.EnumerateFileSystemEntries(outputPath).Any())
                {
                    if (!EditorUtility.DisplayDialog("Target not Empty", "The target folder isn't empty, Overwrite?", "Yes", "Cancel"))
                    {
                        return;
                    }
                }

                EditorUtility.DisplayProgressBar("Building Project", "", ratio);

                // Step 1: Create Folder
                EditorUtility.DisplayProgressBar("Building Project", "Create project structure", (ratio += 0.1f));
                string moduleDataFolder = Path.Combine(outputPath, "ModuleData");
                Directory.CreateDirectory(moduleDataFolder);

                // Step 2: Create DataSet
                ElementConfig[] configs = ConfigManager.Datasets;
                step = 0.7f / configs.Length;
                foreach (var config in configs)
                {
                    EditorUtility.DisplayProgressBar("Building Project", "Create Dataset " + config.Name, (ratio += step));

                    MB2CustomEditorView view;
                    if (!ElementViewManager.GetView(config.Name, out view))
                    {
                        view = new DataSetView();
                    }
                    view.Init(config);

                    File.WriteAllText(moduleDataFolder + "/" + config.Name + ".xml", view.GetData());
                }

                // Step 3: Create SubModule.xml
                EditorUtility.DisplayProgressBar("Building Project", "Create SubModule.xml", (ratio = 0.8f));
                CreateSubModule(outputPath + "SubModule.xml");

                EditorUtility.ClearProgressBar();
                EditorUtility.DisplayDialog("Built finished", "Built successfully!", "Ok");
                EditorUtility.RevealInFinder(moduleDataFolder);
            }
        }
Exemplo n.º 4
0
        void OnModelSelected(BaseModel target)
        {
            model = target;
            if (model == null || model.NameSpace.Equals("MB2Editor") || model.element.Equals("Unassigned"))
            {
                notSupport = EditorNotSupport.Unassigned;
            }
            else
            {
                DataSetConfig config;
                if (ConfigManager.GetConfig(model.NameSpace, out config))
                {
                    //TODO: need cache view here for perfermance
                    var supportDataSet = config.Datasets.Where((element) => element.NestedElements.Any((nestedElement) => nestedElement.Name.Equals(model.element)));
                    datasetViews = supportDataSet.Select((dataset) =>
                    {
                        MB2CustomEditorView view;
                        if (!ElementViewManager.GetView(dataset.Name, out view))
                        {
                            view = new DataSetView();
                        }
                        view.Init(dataset);
                        return(view);
                    }).ToArray();


                    if (datasetViews.Length > 0)
                    {
                        notSupport = EditorNotSupport.Support;
                    }
                    else
                    {
                        notSupport = EditorNotSupport.NoView;
                    }
                }
                else
                {
                    notSupport = EditorNotSupport.NoView;
                }
            }

            Repaint();
        }