Example #1
0
 private void ExportCanvasCallback(string formatID)
 {
     IOFormat = ImportExportManager.ParseFormat(formatID);
     if (IOFormat.RequiresLocationGUI)
     {
         ExportLocationGUI = IOFormat.ExportLocationArgsGUI;
         modalPanelContent = ExportCanvasGUI;
         showModalPanel    = true;
     }
     else if (IOFormat.ExportLocationArgsSelection(canvasCache.nodeCanvas.saveName, out IOLocationArgs))
     {
         ImportExportManager.ExportCanvas(canvasCache.nodeCanvas, IOFormat, IOLocationArgs);
     }
 }
Example #2
0
        public void DrawToolbarGUI(Rect rect)
        {
            rect.height = toolbarHeight;
            rect.width  = 280f;
            if (!showModalPanel)
            {
                GUILayout.BeginArea(rect, NodeEditorGUI.toolbar);
                GUILayout.BeginHorizontal();
                //float curToolbarHeight = 0;
                if (GUILayout.Button("New", NodeEditorGUI.toolbarButton, GUILayout.Width(50)))
                {
                    AutoSave();
                    switch (NodeEditorGUI.state)
                    {
                    case NodeEditorGUI.NodeEditorState.Mission:
                        NewNodeCanvas(typeof(QuestCanvas));
                        break;

                    case NodeEditorGUI.NodeEditorState.Dialogue:
                        NewNodeCanvas(typeof(DialogueCanvas));
                        break;

                    case NodeEditorGUI.NodeEditorState.Sector:
                        NewNodeCanvas(typeof(SectorCanvas));
                        break;
                    }
                    IOLocationArgs = null;
                }
                if (GUILayout.Button("Import", NodeEditorGUI.toolbarButton, GUILayout.Width(50)))
                {
                    IOFormat = ImportExportManager.ParseFormat("XML");
                    if (IOFormat.RequiresLocationGUI)
                    {
                        // Try to auto save
                        AutoSave();

                        ImportLocationGUI = IOFormat.ImportLocationArgsGUI;
                        modalPanelContent = ImportCanvasGUI;
                        showModalPanel    = true;
                    }
                    else if (IOFormat.ImportLocationArgsSelection(out IOLocationArgs))
                    {
                        canvasCache.SetCanvas(ImportExportManager.ImportCanvas(IOFormat, IOLocationArgs));
                    }
                }
                if (GUILayout.Button("Export", NodeEditorGUI.toolbarButton, GUILayout.Width(50)))
                {
                    IOFormat = ImportExportManager.ParseFormat("XML");
                    if (IOFormat.RequiresLocationGUI)
                    {
                        ExportLocationGUI = IOFormat.ExportLocationArgsGUI;
                        modalPanelContent = ExportCanvasGUI;
                        showModalPanel    = true;
                    }
                    else if (IOFormat.ExportLocationArgsSelection(canvasCache.nodeCanvas.saveName, out IOLocationArgs))
                    {
                        ImportExportManager.ExportCanvas(canvasCache.nodeCanvas, IOFormat, IOLocationArgs);
                    }
                }
                string buttonText = "Mission";
                switch (NodeEditorGUI.state)
                {
                case NodeEditorGUI.NodeEditorState.Mission:
                    buttonText = "Mission";
                    break;

                case NodeEditorGUI.NodeEditorState.Dialogue:
                    buttonText = "Dialogue";
                    break;

                case NodeEditorGUI.NodeEditorState.Sector:
                    buttonText = "Sector";
                    break;

                default:
                    break;
                }

                if (GUILayout.Button(buttonText, NodeEditorGUI.toolbarButton, GUILayout.Width(50)))
                {
                    NodeEditorGUI.state = (NodeEditorGUI.NodeEditorState)(((int)NodeEditorGUI.state + 1) % 3);

                    switch (NodeEditorGUI.state)
                    {
                    case NodeEditorGUI.NodeEditorState.Mission:
                        NewNodeCanvas(typeof(QuestCanvas));
                        break;

                    case NodeEditorGUI.NodeEditorState.Dialogue:
                        NewNodeCanvas(typeof(DialogueCanvas));
                        break;

                    case NodeEditorGUI.NodeEditorState.Sector:
                        NewNodeCanvas(typeof(SectorCanvas));
                        break;

                    default:
                        break;
                    }
                    NodeEditorGUI.Init();
                }

                bool autoSave = GUILayout.Toggle(autoSaveEnabled, "Auto Save");
                if (autoSave != autoSaveEnabled)
                {
                    autoSaveEnabled = autoSave;
                    PlayerPrefs.SetInt("NEAutoSave", autoSave ? 1 : 0);
                    PlayerPrefs.Save();
                }

                GUI.backgroundColor = Color.white;
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
                if (Event.current.type == EventType.Repaint)
                {
                    toolbarHeight = 20;
                }
            }
        }