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); }
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); }
private void Button_Click(object sender, RoutedEventArgs e) { TGINI config; try { config = GINI.ReadFromFile(Dirry.C("$AppSupport$/TeddyBaseConfig.GINI")); } catch (Exception err) { Afgekeurd($"Failed to load the configuration file\n{err.Message}"); return; } switch (config.C("PLATFORM")) { case "Windows": Dirry.InitAltDrives(AltDrivePlaforms.Windows); break; case "Linux": Dirry.InitAltDrives(AltDrivePlaforms.Linux, config.C("LINUX_MEDIA")); break; default: Afgekeurd($"Platform {config.C("PLATFORM")} unknown"); return; } var workspace = config.C("WORKSPACE"); if (workspace == "") { Afgekeurd("Workspace not configured. Please run the launcher first!"); return; } TGINI project = new TGINI(); var prjallowregex = new Regex(@"^[a-zA-Z0-9_ ]+$"); ProjectName.Text = ProjectName.Text.Trim(); var projectdir = $"{workspace}/{ProjectName.Text}"; if (ProjectName.Text == "") { Afgekeurd("No project name given!"); return; } if (!prjallowregex.IsMatch(ProjectName.Text)) { Afgekeurd("Only numbers letters underscores and spaces allowed in project name"); return; } if (Directory.Exists(projectdir)) { Afgekeurd("That project already exists!"); return; } var mapw = qstr.ToInt(MapW.Text); var maph = qstr.ToInt(MapH.Text); if (mapw <= 0 || maph <= 0) { Afgekeurd("The map format has incorrect values"); return; } if (mapw * maph > 50000) { var r = MessageBox.Show($"These settings will be very very costly on your RAM. {mapw * maph} bytes per layer at least, and then the object layer not counted. Are you SURE, you wanna do this?", "Are you crazy?", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (r == MessageBoxResult.No) { return; } } var layers = Layers.Text.Split(';'); if (layers.Length < 1) { Afgekeurd("A TeddyBear project MUST have at least 1 layer"); } // Not really needed as the editor will never use it, but I guess it's just good practise project.D("PROJECTNAME", ProjectName.Text); // Create Project try { Directory.CreateDirectory(Dirry.AD(projectdir)); } catch (Exception err) { Afgekeurd($"Project creation folder failed!\n\nDir: {Dirry.AD(projectdir)}\n\n{err.Message}"); return; } // Grid should when you are not an advanced user always be 32x32, and if you are an advanced user, why are you using this wizard? project.D("GRIDX", "32"); project.D("GRIDY", "32"); // Sizes project.D("SIZEX", $"{mapw}"); project.D("SIZEY", $"{maph}"); project.D("ResizeTextures", "FALSE"); // Layers foreach (string layer in Layers.Text.Split(';')) { if (layer != "") { project.Add("LAYERS", layer); if (!qstr.Prefixed(layer, "Zone_")) { project.D($"HOT.{layer}", "BC"); } } } // Map dir var mapdir = MapFileFolder.Text; if (mapdir == "*InProject*") { mapdir = $"{projectdir}/Maps"; } project.D("LevelDir", mapdir); try { Directory.CreateDirectory(Dirry.AD(mapdir)); } catch (Exception err) { Afgekeurd($"Creation/access of map folder failed! -- Please note that a (project dir is now already created, you may need to destroy it for another go)\n\n{err.Message}"); return; } // Texture dirs var texdir = TextureFolder.Text; if (texdir == "*InProject*") { texdir = $"{projectdir}/Textures"; } var texdirs = texdir.Split(';'); foreach (string td in texdirs) { project.Add("textures", td); try { Directory.CreateDirectory(Dirry.AD(td)); } catch (Exception err) { Afgekeurd($"Creation/access of texture folder {td} failed! -- Please note that a (project dir is now already created, you may need to destroy it for another go)\n\n{err.Message}"); return; } } // Meta data var metas = MetaData.Text.Split(';'); foreach (string meta in metas) { project.Add("Data", meta.Trim()); } // Create project file try { project.SaveSource(Dirry.AD($"{projectdir}/{ProjectName.Text}.Project.GINI")); } catch (Exception err) { Afgekeurd($"I could not create project file '{projectdir}/{ProjectName.Text}.Project.GINI'\n\n{err.Message}"); return; } MessageBox.Show("Project succesfully created", ProjectName.Text); }