コード例 #1
0
ファイル: Program.cs プロジェクト: TrickyGameTools/Kthura
        void Run()
        {
            Console.WriteLine("Kthura Convert - Coded by Jeroen P. Broks");
            Console.WriteLine($"Project: {Project}");
            Print("Loading Global Config");
            GlobConfig = GINIE.FromFile(GlobConfigFile);
            Print("Workspace: ", WorkSpace);
            Print("Loading old project: ", OldFile);
            Old = GINI.ReadFromFile(OldFile);
            Print("Data for new project creation");
            Nieuw = GINIE.FromSource($"[CONVERT]\nConvertData={DateTime.Now}");
            Nieuw.AutoSaveSource = OldFile.Replace(".GINI", ".ini");
            Print("- Meta data");
            Nieuw["Meta", "CREATED"] = $"{DateTime.Now} -- By conversion of an old project";
            Nieuw["Meta", "PROJECT"] = Old["Project"];
            Print("- Meta data tags for map");
            foreach (var k in Old.List("GeneralData"))
            {
                Nieuw.List("Map", "GeneralData").Add(k);
            }
            Print("- Tex convert");
            Nieuw["PATHS.WINDOWS", "MAPS"] = Old["Maps"];
            foreach (var i in Old.List("TEXTURESGRABFOLDERSMERGE"))
            {
                Nieuw.List("Paths.Windows", "TexMaps").Add(i);
            }
            Nieuw["PATHS.WINDOWS", "TEXMERGE"] = "YES";
            //TexDir = E:/ Projects / Maps / Kthura / cpp_kthproject / Textures
            Print("- Custom stuff");
            foreach (var c in Old.List("CSpots"))
            {
                Nieuw.List("Map", "Special").Add(c);
            }
            Print();
            foreach (var mp in FileList.GetTree(Old["Maps"]))
            {
                KthuraCheck(mp);
            }

            // Last
            Nieuw["Meta", "CONVERTFINISH"] = $"{DateTime.Now}";
        }
コード例 #2
0
        private void CreateProject_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <bool, string> TexField = new Dictionary <bool, string>();

            TexField[false] = "Textures";
            TexField[true]  = "TexturesGrabFoldersMerge";
            var prjallowregex = new Regex(@"^[a-zA-Z0-9_ ]+$");
            var prjname       = CrPrjName.Text;

            if (prjname.Trim() == "")
            {
                Afgekeurd("No Project Title"); return;
            }
            if (!prjallowregex.IsMatch(prjname))
            {
                Afgekeurd("Illegal characters in Project Title"); return;
            }
            var prjdir      = $"{MainConfig.WorkSpace}/{prjname}";
            var prjfile     = $"{prjdir}/{prjname}.Project.GINI";
            var prjmeta     = CrPrjMeta.Text.Split(';');
            var prjtexmerge = qstr.Prefixed(CrPrjTextureFolders.Text, "@MERGE@");
            var prjtex      = CrPrjTextureFolders.Text.Split(';');

            if (prjtexmerge)
            {
                prjtex = qstr.RemPrefix(CrPrjTextureFolders.Text, "@MERGE@").Split(';');
            }
            if (CrPrjTextureFolders.Text == "*InProject*")
            {
                prjtex = new string[] { $"{prjdir}/Textures/" };
            }
#if GINIE_Project
            var   Paths  = $"Paths.{MainConfig.Platform}";
            GINIE OutPrj = GINIE.FromSource($"[meta]\nCreated={DateTime.Now}\n");
            prjfile = $"{prjdir}/{prjname}.Project.INI";
            if (File.Exists(prjdir))
            {
                Afgekeurd($"Hey!\nThere is a file named {prjdir}!\n\nRemove it first please (files do not belong in the workspace root)!");
                return;
            }
            if (Directory.Exists(prjdir))
            {
                Afgekeurd("There already appears to be a project directory with that name.\nEither remove or rename that project, or pick a different name for this project!");
                return;
            }
            Directory.CreateDirectory(prjdir);
            OutPrj.AutoSaveSource = prjfile;
            try {
                OutPrj["Meta", "Project"] = prjname;
                OutPrj.List("Map", "Special");
                if (CrPrjMapFolder.Text == "*InProject*")
                {
                    var td = $"{prjdir}/Maps";
                    Directory.CreateDirectory(td);
                    OutPrj[Paths, "Maps"] = td;
                }
                else
                {
                    OutPrj[Paths, "Maps"] = CrPrjMapFolder.Text.Replace("\\", "/");
                }
                OutPrj.List("Map", "GeneralData");
                foreach (string m in prjmeta)
                {
                    OutPrj.List("Map", "GeneralData").Add(m.Trim());
                }
                if (prjtexmerge)
                {
                    OutPrj[Paths, "TexMerge"] = "YES";
                }
                else
                {
                    OutPrj[Paths, "TexMerge"] = "NO";
                }
                if (CrPrjTextureFolders.Text == "*InProject*")
                {
                    Directory.CreateDirectory($"{prjdir}/Textures/");
                    OutPrj.List(Paths, "Textures").Add($"{prjdir}/Textures");
                }
                else
                {
                    foreach (string f in prjtex)
                    {
                        OutPrj.List(Paths, "Textures").Add(f.Trim());
                    }
                }
            } catch (Exception E) {
                Afgekeurd($"Creating a new project failed!\n\n{E.Message}");
            }
#else
            TGINI Project = new TGINI();
            Project.D("Project", prjname);
            Project.D("Maps", CrPrjMapFolder.Text);
            Project.CL("GeneralData");
            foreach (string m in prjmeta)
            {
                Project.List("GeneralData").Add(m.Trim());
            }
            Project.CL(TexField[prjtexmerge]);
            foreach (string f in prjtex)
            {
                Project.List(TexField[prjtexmerge]).Add(f.Trim());
            }
            if (File.Exists(prjdir))
            {
                Afgekeurd($"Hey!\nThere is a file named {prjdir}!\n\nRemove it first please (files do not belong in the workspace root)!");
                return;
            }
            if (Directory.Exists(prjdir))
            {
                Afgekeurd("There already appears to be a project directory with that name.\nEither remove or rename that project, or pick a different name for this project!");
                return;
            }
            try {
                Directory.CreateDirectory(prjdir);
                if (CrPrjTextureFolders.Text == "*InProject*")
                {
                    Directory.CreateDirectory($"{prjdir}/Textures/");
                }
                if (CrPrjMapFolder.Text == "*InProject*")
                {
                    var td = $"{prjdir}/Maps";
                    Directory.CreateDirectory(td);
                    Project.D("Maps", td.Replace("\\", "/"));
                }
                Project.SaveSource(prjfile);
                MessageBox.Show("A new project has been created!");
                Scan4Projects();
            } catch (Exception E) {
                Afgekeurd($"Creating a new project failed!\n\n{E.Message}");
            }
#endif
        }