示例#1
0
文件: Util.cs 项目: hamtol2/D2EEditor
        public static void CompileToXML(ProjectFormat projectFormat, List <GraphItem> locatedItemList, IComparer <GraphItem> comparer)
        {
            locatedItemList.Sort(comparer);

            XMLProject project = new XMLProject();

            foreach (GraphItem node in locatedItemList)
            {
                if (node.GetNodeType == NodeType.SWITCH)
                {
                    SwitchBranchItem switchNode = node as SwitchBranchItem;
                    project.AddNode(switchNode.GetXMLSwitchData());
                }
                else if (node.GetNodeType == NodeType.VARIABLE)
                {
                    VariableItem variableNode = node as VariableItem;
                    project.AddNode(variableNode.GetXMLVariableData());
                }
                else if (node.GetNodeType == NodeType.IF)
                {
                    IFBranchItem ifNode = node as IFBranchItem;
                    project.AddNode(ifNode.GetXMLIFData());
                }
                else
                {
                    project.AddNode(node.GetXMLNormalData());
                }
            }

            XMLSerialize <XMLProject>(project, Application.dataPath + "/Data/TestProject.xml");
        }
示例#2
0
        public void SaveToFile(ProjectFormat format)
        {
            if (!Directory.Exists(Application.dataPath + "/Data"))
            {
                Directory.CreateDirectory(Application.dataPath + "/Data");
            }

            string projectPath = SetProjectPath(format.projectName);
            string jsonString  = JsonUtility.ToJson(format);

            File.WriteAllText(projectPath, jsonString);
        }
示例#3
0
        public void SaveState()
        {
            if (!IsValid)
            {
                //Debug.Log("SaveState null");
                return;
            }

            ProjectFormat format = WorkspaceManager.Instance.GetSaveFormat(GetProjectData.GetProjectFormat.projectName);

            //GetProjectData.UpdateProjectState(WorkspaceManager.Instance.GetSaveFormat(GetProjectData.GetProjectFormat.projectName));
            GetProjectData.UpdateProjectState(format);
        }
示例#4
0
        public void SaveProject(string projectName)
        {
            if (selectedTabIndex == -1)
            {
                return;
            }

            projectName = string.IsNullOrEmpty(projectName) ? currentTabs[selectedTabIndex].GetTabUI.GetTabName : projectName;
            ProjectFormat projectSaveFormatData = WorkspaceManager.Instance.GetSaveFormat(projectName);

            currentTabs[selectedTabIndex].GetTabData.SaveProject(projectSaveFormatData);

            WorkspaceManager.Instance.CompileToXML(projectSaveFormatData);
        }
示例#5
0
 public void SaveProject(ProjectFormat format)
 {
     project.SaveProject(format);
 }
示例#6
0
 public void CompileToXML(ProjectFormat projectFormat)
 {
     Util.CompileToXML(projectFormat, locatedItemList, this);
 }
示例#7
0
 public void LoadFromProjectFormat(ProjectFormat project)
 {
     CreateBlocks(project.blockArray);
     CreateLines(project.lineArray);
 }
示例#8
0
 public void UpdateProjectState(ProjectFormat format)
 {
     project = format;
 }
示例#9
0
 //public void LoadFromFile()
 public void LoadFromFile(string fileName)
 {
     // Load json text and convert to project format.
     project = LoadProjectDataFromJson(fileName);
 }
示例#10
0
 public void SaveProject(ProjectFormat format)
 {
     projectData.SaveToFile(format);
 }
示例#11
0
文件: Util.cs 项目: hamtol2/D2EEditor
        public static ProjectFormat GetSaveFormat(List <GraphItem> locatedItemList, List <GraphLine> locatedLineList, string projectName = "")
        {
            ProjectFormat project = new ProjectFormat();

            project.projectName = projectName;

            project.blockArray = new NodeBlockArray();
            for (int ix = 0; ix < locatedItemList.Count; ++ix)
            {
                NodeBlock block = new NodeBlock();
                block.nodeType = locatedItemList[ix].GetNodeType;
                block.id       = locatedItemList[ix].BlockID;
                block.title    = locatedItemList[ix].GetBlockTitle;
                block.value    = locatedItemList[ix].GetItemData() as string;
                block.position = locatedItemList[ix].GetComponent <RectTransform>().position;

                NodeType nodeType = locatedItemList[ix].GetNodeType;

                if (nodeType == NodeType.SWITCH)
                {
                    SwitchBranchItem switchNode = locatedItemList[ix] as SwitchBranchItem;
                    block.switchBlockCount = switchNode.GetBlockCount;
                    block.switchBranchType = switchNode.GetSwitchType;
                    block.name             = switchNode.GetSwitchName;
                    for (int jx = 0; jx < switchNode.GetBlockCount; ++jx)
                    {
                        ExecuteCasePoint casePoint = switchNode.executePoints[jx + 1] as ExecuteCasePoint;
                        block.switchBlockValues.Add(casePoint.CaseValue);
                    }
                }

                else if (nodeType == NodeType.VARIABLE)
                {
                    VariableItem variableNode = locatedItemList[ix] as VariableItem;
                    block.variableOperator = variableNode.GetOperatorType.ToString();
                    block.name             = variableNode.GetBlockName;
                }

                else if (nodeType == NodeType.IF)
                {
                    IFBranchItem    ifNode = locatedItemList[ix] as IFBranchItem;
                    BranchCondition data   = ifNode.GetIFBranchData();
                    block.name             = data.nameField;
                    block.value            = data.rParameter;
                    block.ifBranchType     = data.lParamType;
                    block.variableOperator = ifNode.GetStringFromOpType(data.opParameter);
                }

                project.BlockAdd(block);
            }

            project.lineArray = new LineBlockArray();
            for (int ix = 0; ix < locatedLineList.Count; ++ix)
            {
                int leftBlockID        = locatedLineList[ix].GetLeftExecutePointInfo.blockID;
                int leftExecutePointID = locatedLineList[ix].GetLeftExecutePointInfo.executePointID;
                int rightBlockID       = locatedLineList[ix].GetRightExecutePointInfo.blockID;

                LineBlock line = new LineBlock(leftBlockID, leftExecutePointID, rightBlockID);
                project.LineAdd(line);
            }

            return(project);
        }