bool GetGINI() { if (File.Exists(qstr.RemSuffix(GINIFile, ".gini") + ".ini")) { Console.Beep(); Console.WriteLine("Renaming old ini file to GINI!"); File.Move(qstr.RemSuffix(GINIFile, ".gini") + ".ini", GINIFile); } if (!File.Exists(GINIFile)) { for (int i = 0; i < 10; i++) { Console.Beep(2000, 1000); Console.Beep(1000, 1000); } Console.WriteLine("This directory has not been initized as a MKL based project!"); Console.Write("Do you want it to be a MKL based project ? <Y/N> "); if (Console.ReadLine().ToUpper() != "Y") { return(false); } QuickStream.SaveString(GINIFile, "[rem]\nVoid Dark(){ cprintf(\"Void the darkness\"); }\n"); } Data = GINI.ReadFromFile(GINIFile); Data.CL("KNOWN"); Data.CL("SKIPFILE"); Data.CL("SKIPDIR"); Ask("Project", dir, "Please name the project: "); return(true); }
static void Output(object senderwhichwedonotcareabout, EventArgs argswecouldntcareevenlessabout) { var output = new TGINI(); var odir = ""; var project = ""; var copy = ""; foreach (string k in Fields.Keys) { var puretxt = Fields[k].Buffer.Text; var txt = puretxt.Replace('\r', ' ').Replace('\n', ' '); // In most fields we do NOT allow 'enters' if (qstr.Left(k, 1) == "*") { switch (k) { case "*KTHURA": odir = txt; break; case "*Project": project = txt; break; case "*Copyright": copy = puretxt; break; case "*Meta": output.CL("GENERALDATA"); foreach (string e in puretxt.Split('\n')) { output.Add("GENERALDATA", e.Trim()); } break; case "*Textures": output.CL("TEXTURESGRABFOLDERSMERGE"); output.Add("TEXTURESGRABFOLDERSMERGE", txt); break; } } else { output.D(k, puretxt); } } // These two lists only have to exist. They are not being altered, because that is the more advance stuff (CSPOTS or Custom Spots most of all). output.CL("CSPOTS"); output.CL("LINES"); var outputscript = output.ToSource(); outputscript = $"[rem]\nThis script was Generated by the Quick Kthura Project Wizard\n\n{project}\n\n{copy}\n\n{outputscript}"; QOpen.SaveString($"Projects/{project}", outputscript); }
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 }