void DesignList_SimpleClass()
        {
            if (SelectedJsonElement == null || SelectedJsonElement.jo ["Common"] ["Desc"] == null)
            {
                return;
            }

            JObject jo_common = SelectedJsonElement.jo ["Common"] as JObject;

            if (GUILayout.Button("<<"))
            {
                SelectedJsonElement    = null;
                SimpleClassMembersList = null;
                NeedRefresh            = true;

                AutoSelected.SelectedJsonFileName = string.Empty;
                AutoSelected.Save();

                return;
            }

            GUILayout.Label(string.Format("Workspace:{0}, SimpleClass:{1}", SelectedJsonElement.Workspace, SelectedJsonElement.Name), EditorStyles.boldLabel);

            jo_common ["Desc"] = GUILayout.TextArea(jo_common ["Desc"].Value <string> (), GUIStyleTemplate.GreenDescStyle2());

            if (jo_common ["Type"] == null)
            {
                jo_common.Add("Type", "");
            }

            GUILayout.BeginHorizontal();
            jo_common ["Type"] = EditorGUILayout.TextField("Base", jo_common ["Type"].Value <string> ());
            GUILayout.EndHorizontal();

            DesignList_SimpleClass_Member();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Reset"))
            {
                SelectedJsonElement.Load();
                ResetSimpleClassMembersList();
            }
            if (GUILayout.Button("Save"))
            {
                SaveJson();
            }
            if (GUILayout.Button("Save&Generate"))
            {
                SaveJson();

                Generator.GenerateCode(SelectedJsonElement.jo);

                AssetDatabase.Refresh();

                NeedRefresh = true;

                this.Repaint();
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 2
0
        static void ClearEditorSettings()
        {
            if (Current != null)
            {
                Current.SelectedJsonElement = null;

                Current.WSJsonFilesList        = null;
                Current.ElementMembersList     = null;
                Current.SimpleClassMembersList = null;
                Current.EnumMembersList        = null;

                Current.SelectedWorkspace       = null;
                Current.SelectedWorkspaceCommon = null;

                Current.NeedRefresh = true;
            }

            AutoSelected.Reset();
        }
Exemplo n.º 3
0
        void DesignList_Element()
        {
            if (SelectedJsonElement == null || SelectedJsonElement.jo ["Common"] ["Desc"] == null)
            {
                return;
            }

            JObject jo_common = SelectedJsonElement.jo ["Common"] as JObject;

            if (GUILayout.Button("<<"))
            {
                SelectedJsonElement = null;
                ElementMembersList  = null;
                NeedRefresh         = true;

                AutoSelected.SelectedJsonFileName = string.Empty;
                AutoSelected.Save();

                return;
            }

            GUILayout.Label(string.Format("Workspace:{0}, Element:{1}", SelectedJsonElement.Workspace, SelectedJsonElement.Name), EditorStyles.boldLabel);

            jo_common ["Desc"] = GUILayout.TextArea(jo_common ["Desc"].Value <string> (), GUIStyleTemplate.GreenDescStyle2());

            if (jo_common ["Type"] == null)
            {
                jo_common.Add("Type", "");
            }

            GUILayout.BeginHorizontal();
            jo_common ["Type"] = EditorGUILayout.TextField("Base", jo_common ["Type"].Value <string> ());
            GUILayout.EndHorizontal();

            toolbar_index = GUILayout.Toolbar(toolbar_index, ToolbarHeaders, new GUILayoutOption[] { GUILayout.Height(25f) });

            switch (toolbar_index)
            {
            case 0:
                DesignList_Element_Member();
                break;

            case 1:
                DesignList_Element_View();
                break;

            default:
                break;
            }

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Reset"))
            {
                SelectedJsonElement.Load();
                ResetElementMembersList();
            }
            if (GUILayout.Button("Save"))
            {
                SaveJson();
            }
            if (GUILayout.Button("Save&Generate"))
            {
                SaveJson();

                Generator.GenerateCode(SelectedJsonElement.jo);

                AssetDatabase.Refresh();

                NeedRefresh = true;

                this.Repaint();
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 4
0
        void DesignList()
        {
            if (WorkspaceDirectoryInfos == null || CommonManager.CommonObjectDic == null)
            {
                NeedRefresh = true;
                return;
            }

//			string JsonRootFull = Path.Combine (Application.dataPath, JsonRoot);
            if (SelectedWorkspace == null)
            {
                GUILayout.Label("Root", EditorStyles.boldLabel);
                scrollViewPos = GUILayout.BeginScrollView(scrollViewPos);
                for (int i = 0; i < WorkspaceDirectoryInfos.Length; i++)
                {
                    DirectoryInfo wdi        = WorkspaceDirectoryInfos [i];
                    string        ws_name    = wdi.Name;
                    StringBuilder sb_content = new StringBuilder(wdi.Name);

                    if (CommonManager != null)
                    {
                        int file_count = CommonManager.CommonObjectDic [ws_name].ElementFiles.Count;
                        sb_content.AppendFormat(" ({0} file{1})", file_count, file_count > 1 ? "s" : "");
//					button_content += " (" + CommonManager.CommonObjectDic [ws_name].ElementFiles.Count + " file)";
                    }

                    GUIContent button_content = new GUIContent(sb_content.ToString(), pgf_workspace_icon);

                    if (GUILayout.Button(button_content, GUIStyleTemplate.ButtonStyleAlignmentLeft()))
                    {
                        AutoSelected.SelectedWorkspaceName = ws_name;
                        AutoSelected.Save();
                        SelectedWorkspace = wdi;
                        NeedRefresh       = true;
                    }
                }
                GUILayout.EndScrollView();
            }
            else
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("<<"))
                {
                    SelectedWorkspace       = null;
                    NeedRefresh             = true;
                    WSJsonFilesList         = null;
                    SelectedWorkspaceCommon = null;

                    AutoSelected.SelectedWorkspaceName = string.Empty;
                    AutoSelected.Save();

                    return;
                }
                if (GUILayout.Button("Save"))
                {
                    SaveCommonFile();
                }
                GUILayout.EndHorizontal();

                GUILayout.Label("Workspace:" + SelectedWorkspace.Name, EditorStyles.boldLabel);

                if (SelectedWorkspaceCommon != null)
                {
//				PRDebug.TagLog ("PGFrameWindow.Debug", Color.yellow, JsonConvert.SerializeObject (SelectedWorkspaceCommon));
                    if (WSJsonFilesList == null)
                    {
                        ResetReorderableList();
                    }

                    JsonFilesScrollPos = GUILayout.BeginScrollView(JsonFilesScrollPos);
                    WSJsonFilesList.DoLayoutList();

                    GUILayout.EndScrollView();

                    TryShowPopupWindowDoc();
                }
            }
        }
Exemplo n.º 5
0
        void ResetReorderableList()
        {
            JArray ja_elements = SelectedWorkspaceCommon.jo ["ElementFiles"] as JArray;

            WSJsonFilesList = new ReorderableList(ja_elements, typeof(JToken));
            WSJsonFilesList.drawHeaderCallback += (Rect rect) => {
                GUI.Label(rect, "ElementFiles");
            };
            float[] split = new float[] { 0f, 1f };
            WSJsonFilesList.drawElementCallback += (Rect rect, int index, bool isActive, bool isFocused) => {
                Rect r = new Rect(rect);
                r.y      -= 1;
                r.height -= 2;
                int split_idx = 0;
                r.x     = (rect.width - 25f) * split [split_idx] + 25f;
                r.width = (rect.width - 25f) * (split [split_idx + 1] - split [split_idx]);
                JObject jo_element = ja_elements [index] as JObject;

                string jo_element_filename = jo_element ["File"].Value <string> ();

                DocType   dt   = (DocType)Enum.Parse(typeof(DocType), jo_element ["DocType"].Value <string> ());
                Texture2D icon = null;
                switch (dt)
                {
                case DocType.Element:
                    icon = pgf_element_icon;
                    break;

                case DocType.SimpleClass:
                    icon = pgf_simple_class_icon;
                    break;

                case DocType.Enum:
                    icon = pgf_enum_icon;
                    break;

                case DocType.FSM:
                    icon = pgf_fsm_icon;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                GUIContent content = new GUIContent(jo_element_filename, icon);
                if (GUI.Button(r, content, GUIStyleTemplate.ButtonStyleAlignmentLeft()))
                {
                    if (Event.current.button == 1)
                    {
                        JSONElement jsonElement = jElements.Single(je => je.FileName == jo_element_filename);

                        PGFrameOpenFileTools.OpenContentMenu(jsonElement);
                    }
                    else
                    {
                        SelectedJsonElement = jElements.Single(je => je.FileName == jo_element_filename);

                        if (dt == DocType.FSM)
                        {
                            FSMWindow.Init();
                            FSMWindow.Current.jElement = SelectedJsonElement;
                        }

                        AutoSelected.SelectedJsonFileName = jo_element_filename;
                        AutoSelected.Save();
                    }
                }
            };

            WSJsonFilesList.onAddCallback += (ReorderableList list) => {
                GenericMenu menu = new GenericMenu();
                foreach (DocType dt in Enum.GetValues(typeof(DocType)))
                {
                    menu.AddItem(new GUIContent(dt.ToString()), false, (object userData) => {
                        NeedShowPopupWindowDocType = (DocType)userData;
                    }, dt);
                }
                menu.ShowAsContext();
            };

            WSJsonFilesList.onRemoveCallback += (ReorderableList list) => {
                JObject jo       = ja_elements [list.index] as JObject;
                string  jsonName = jo ["File"].Value <string> ();

                if (EditorUtility.DisplayDialog("警告!", string.Format("确定删除框架中的{0}文件?", jo ["File"].Value <string> ()), "Yes", "No"))
                {
                    ja_elements.RemoveAt(list.index);
                    SelectedWorkspaceCommon.jo ["ElementFiles"] = ja_elements;
                    SaveCommonFile();

                    DeleteElementJsonFile(jsonName, SelectedWorkspaceCommon.Workspace);
                    NeedRefresh = true;
                }
            };
        }