Ejemplo n.º 1
0
        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}";
        }
Ejemplo n.º 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
        }
Ejemplo n.º 3
0
        bool Act(string f)
        {
            string d = qstr.ExtractDir(f);
            string e = qstr.ExtractExt(f);

            if (Data.List("KNOWN").Contains(f))
            {
                return(Changed(f));
            }
            if (Data.List("SKIPFILE").Contains(f))
            {
                return(false);
            }
            if (Data.List("SKIPDIR").Contains(d))
            {
                return(false);
            }
            Console.Beep();
            do
            {
                Console.Clear();
                Console.BackgroundColor = ConsoleColor.DarkRed;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine($"**** {f} ****");
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.BackgroundColor = ConsoleColor.Black;
                string remblock = "";
                var    BT       = QuickStream.ReadFile(f);
                var    L        = BT.ReadLine();
                if (L == Extension.Get(e).C("START"))
                {
                    remblock = L + "\n";
                    do
                    {
                        L = BT.ReadLine();
                        if (L == Extension.Get(e).C("END"))
                        {
                            break;
                        }
                        if (BT.EOF)
                        {
                            Error("Unclosed license block!");
                            return(false);
                        }
                        remblock += L + "\n";
                    } while (true);
                }
                BT.Close();
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("");
                Console.WriteLine("1 = Replace original block and add this file to the auto-updateble files");
                Console.WriteLine("2 = Add license block and add this file to the auto-updatable files");
                Console.WriteLine("3 = Skip this file for now");
                Console.WriteLine("4 = Skip this file forever");
                if (d != "")
                {
                    Console.WriteLine("5 = Skip this entire directory forever");
                }
                Console.Write("Please tell me what to do: ");
                var c = Console.ReadKey();
                Console.WriteLine("\n"); // Yes, two lines :P
                switch (c.Key)
                {
                case ConsoleKey.D1:
                    Data.Add("KNOWN", f);
                    Data.SaveSource(GINIFile);
                    if (!ReplaceBlock(f))
                    {
                        Error("Block replacement failed!");
                    }
                    return(false);    // Always false, or the system will do this again for no reason!

                case ConsoleKey.D2:
                    Data.Add("KNOWN", f);
                    Data.SaveSource(GINIFile);
                    if (!AddBlock(f))
                    {
                        Error("Block addition failed!");
                    }
                    return(false);    // Always false, or the system will do this again for no reason!

                case ConsoleKey.D3:
                    return(false);

                case ConsoleKey.D4:
                    Data.Add("SKIPFILE", f);
                    Data.SaveSource(GINIFile);
                    return(false);

                case ConsoleKey.D5:
                    if (d == "")
                    {
                        break;
                    }
                    Data.Add("SKIPDIR", d);
                    Data.SaveSource(GINIFile);
                    return(false);
                }
            } while (true);
        }