コード例 #1
0
ファイル: ProgramList.cs プロジェクト: Alko-li/Decontainment
        private bool RenameProgram(Program program, int index, string name)
        {
            // Check that we don't override an existing file
            foreach (Program p in programs)
            {
                if ((p != program && p.name == name) || name == "")
                {
                    PromptSystem.Instance.PromptInvalidProgramName(name);
                    return(false);
                }
            }

            // Remove old file
            File.Delete(ProgramDirectory.ProgramPath(program.name));

            // Update back end
            programs.RemoveAt(index);
            program.name = name;
            int newIndex = programs.InsertAlphabetically(program);

            // Update front end
            transform.GetChild(index).SetSiblingIndex(newIndex);

            // Create new file
            SaveProgram(program);
            return(true);
        }
コード例 #2
0
ファイル: ProgramList.cs プロジェクト: Alko-li/Decontainment
        private void SaveProgram(Program program)
        {
            string       programText = Disassembler.Disassemble(program);
            StreamWriter programFile = File.CreateText(ProgramDirectory.ProgramPath(program.name));

            programFile.Write(programText);
            programFile.Close();
        }
コード例 #3
0
ファイル: Files.cs プロジェクト: Amit-B/ginger-bread
        public static string GetPath(ProgramDirectory dir)
        {
            string ret = string.Empty, main = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "/GingerBread";

            switch (dir)
            {
            case ProgramDirectory.Main: ret = main; break;

            case ProgramDirectory.Sounds: ret = main + "/Sound Files"; break;
            }
            return(ret);
        }
コード例 #4
0
        protected override void RenameItem(Program program, string name)
        {
            string fromPath = ProgramDirectory.ProgramPath(program.name);
            string toPath   = ProgramDirectory.ProgramPath(name);

            #if UNITY_EDITOR && !BUILD_MODE
            AssetDatabase.RenameAsset(fromPath, name);
            #else
            File.Move(fromPath, toPath);
            #endif
            program.name = name;
        }
コード例 #5
0
        public Program AssembleProgram()
        {
            string programText = null;

            if (builtInProgram != null)
            {
                programText = builtInProgram.text;
            }
            else if (customProgramName != null)
            {
                try {
                    programText = File.ReadAllText(ProgramDirectory.ProgramPath(customProgramName));
                } catch {
                    Debug.LogWarning("Error opening program " + customProgramName + ". Using fallback program.");
                }
            }

            if (programText == null)
            {
                Debug.LogWarning("No program provided. Using fallback program.");
                PromptSystem.Instance.PromptOtherAction("No program provided. Using fallback program.");
                return(FALLBACK_PROGRAM);
            }
            else
            {
                Program program = Assembler.Assemble(customProgramName, programText);
                if (program == null)
                {
                    Debug.LogWarning("Assembly failed. Using fallback program.");
                    return(FALLBACK_PROGRAM);
                }
                else
                {
                    return(program);
                }
            }
        }
コード例 #6
0
 protected override void DeleteItem(Program program)
 {
     File.Delete(ProgramDirectory.ProgramPath(program.name));
     codeList.Program = null;
 }