public static OrbNonCompiledLanguage GenerateNewLanguageStructure()
        {
            string rootpath = Application.dataPath + "/Ouroboros/LanguageFiles";

            //Check to see if the root folder exists, create it if it doesnt
            if (System.IO.Directory.Exists(rootpath))
            {
                System.IO.Directory.CreateDirectory(rootpath);
            }

            //Search the root folder for a new language number that doesnt exist yet
            int num = 0;

            while (System.IO.Directory.Exists(rootpath + "/NewLanguage" + num))
            {
                num++;
            }
            string langPath = rootpath + "/NewLanguage" + num;

            //Make the new directory
            System.IO.Directory.CreateDirectory(langPath);

            System.IO.Directory.CreateDirectory(langPath + "/Terminals");
            System.IO.Directory.CreateDirectory(langPath + "/NonTerminals");

            //Create enviroment file
            System.IO.File.Create(langPath + "/enviroment.chunk");
            //Create Using File
            System.IO.File.Create(langPath + "/using.chunk");
            //Create Preexecution File
            System.IO.File.Create(langPath + "/preexecution.chunk");

            OrbNonCompiledLanguage lang = new OrbNonCompiledLanguage();

            lang.name = "NewLanguage" + num;

            //Save the new language to

            //Refresh the asset database to allow for the Project panel to display our new folder
            UnityEditor.AssetDatabase.Refresh();
            return(lang);
        }
Beispiel #2
0
        private void DrawDefaultMenu()
        {
            if (windowSettings == null)
            {
                windowSettings = OrbWindowSettings.Load();
                //Check to see if we had a language we were working on
                if (windowSettings.languageName != "")
                {
                    //Attempt to load it
                }
            }



            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Load"))
                {
                    //Attempt to load.
                }
                if (windowSettings.language != null && GUILayout.Button("Save"))
                {
                    //Save the file.
                }
                if (GUILayout.Button("New"))
                {
                    windowSettings.language = OrbNonCompiledLanguage.GenerateNewLanguageStructure();
                    //Look for non colliding name for language
                    //Create file strucuture
                }
                if (GUILayout.Button("Close"))
                {
                    windowSettings.language = null;
                    //Look for non colliding name for language
                    //Create file strucuture
                }
            }
            EditorGUILayout.EndHorizontal();

            //File loading options
            //File saving options
            //New language button

            if (windowSettings.language != null)
            {
                //Name
                EditorGUILayout.BeginHorizontal();
                {
                    windowSettings.language.name = EditorGUILayout.TextField("Name:", windowSettings.language.name);
                }
                EditorGUILayout.EndHorizontal();

                //Package Manager
                HorizontalLine(Color.grey);
                if (windowSettings.m_PackageManager = EditorGUILayout.Foldout(windowSettings.m_PackageManager, "Package manager"))
                {
                    DrawPackageManger();
                }

                //Using Segment
                HorizontalLine(Color.grey);
                if (windowSettings.m_UsingDirectives = EditorGUILayout.Foldout(windowSettings.m_UsingDirectives, "Using Directives"))
                {
                    DrawUsingSegment();
                }

                //Static data segment
                HorizontalLine(Color.grey);
                if (windowSettings.m_Enviroment = EditorGUILayout.Foldout(windowSettings.m_Enviroment, "Global Enviroment"))
                {
                    DrawEnviromentManager();
                }

                //Pre execution code
                HorizontalLine(Color.grey);
                if (windowSettings.m_Preexecution = EditorGUILayout.Foldout(windowSettings.m_Preexecution, "Pre-execution"))
                {
                    DrawPreExecution();
                }

                //Terminal Tokens and Regex
                HorizontalLine(Color.grey);
                if (windowSettings.m_Terminals = EditorGUILayout.Foldout(windowSettings.m_Terminals, "Terminal Tokens"))
                {
                    DrawTerminalTokens();
                }

                //Non terminal Tokens and RHS
                HorizontalLine(Color.grey);
                if (windowSettings.m_Nonterminals = EditorGUILayout.Foldout(windowSettings.m_Nonterminals, "Nonterminal Tokens"))
                {
                    DrawNonerminalTokens();
                    //Display a dropdown of all other tokens
                }
            }

            OrbWindowSettings.Save(windowSettings);
        }
        public static void Save(OrbNonCompiledLanguage file)
        {
            string filePath = Application.dataPath + "/Assets/Ouroboros/LanguageFiles/" + file.name + "/" + file.name + ".json";

            File.WriteAllText(filePath, JsonUtility.ToJson(file, true));
        }