static void OnGoForIt(object sender, EventArgs e) { var outdir = Data["Project"].Text; var prj = System.IO.Path.GetFileName(outdir); var langs = Languages.Buffer.Text.Split('\n'); var gini = new TGINI(); gini.D("Author", Data["Author"].Text); gini.D("Copyright", Data["Author"].Text); gini.D("Notes", Data["License"].Text); gini.D("License", Data["License"].Text); gini.D("lzma", "YES"); var outt = "[rem]\nEmpty now\n[tags]\n\n[scenario]\n\n"; var li = 0; if (langs.Length < 1) { QuickGTK.Error("At least one language is required to do the job!"); return; } foreach (string flang in langs) { li++; Console.WriteLine($"Creating language #{li}: {flang}"); var lang = flang.Trim(); gini.D($"Lang{li}.Name", lang); var outj = outdir + "/" + lang + ".jcr"; gini.D($"Lang{li}.File", outj); var jo = new TJCRCreate(outj, "lzma"); jo.AddString(outt, "BASICENTRY", "lzma", Data["Author"].Text, Data["License"].Text); jo.Close(); } Console.WriteLine("Creating project GINI"); gini.SaveSource(outdir + "/" + prj + ".scenlang.gini"); QuickGTK.Info("Project has been created.\nYou can now use the regular ScenLang tool and open project file:\n\n" + outdir + "/" + prj + ".scenlang.gini"); Application.Quit(); }
void Ask(string key, string defaultval, string q) { while (Data.C(key) == "") { Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(q); Console.ForegroundColor = ConsoleColor.Cyan; Data.D(key, Console.ReadLine().Trim()); if (Data.C(key) == "") { Data.D(key, defaultval); } Console.ForegroundColor = ConsoleColor.Gray; } Data.SaveSource(GINIFile); }
public MainWindow() { InitializeComponent(); if (!File.Exists(GINIFILE)) { QuickStream.SaveString(GINIFILE, "[rem]\nTeddybear knows nothing yet! Boring, huh?\n"); } config = GINI.ReadFromFile(GINIFILE); if (config.C("Platform") == "") { var p = new string[] { "Windows", "Linux", "***" }; foreach (string pl in p) { if (pl == "***") { MessageBox.Show("Then I'm afraid you are on a non-supported system, sorry!"); Environment.Exit(1); } var r = MessageBox.Show($"Are you on {pl}?", "The current version of .NET has no PROPER platform detection, so I have to ask you:", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (r == MessageBoxResult.Yes) { config.D("Platform", pl); config.SaveSource(GINIFILE); break; } } } switch (config.C("Platform")) { case "Windows": System.Diagnostics.Debug.WriteLine("Init Alt Drive: Windows"); Dirry.InitAltDrives(AltDrivePlaforms.Windows); break; case "Linux": if (config.C("LINUX_MEDIA") == "") { MessageBox.Show($"I cannot find out myself where to find the folder in which Linux automatically mounts drives to. You can help me by editing {GINIFILE} and add the line LINUX_MEDIA=<your folder here> under the [vars] section."); Environment.Exit(2); } Dirry.InitAltDrives(AltDrivePlaforms.Linux, config.C("LINUX_MEDIA")); break; default: MessageBox.Show("Unknown or unsupported platform!"); Environment.Exit(3); break; // Not needed, but the C# compiler is not smart enough to notice, so it won't compile if not present.... DUH! :P } WorkSpace.Text = config.C("WORKSPACE"); wpchanged = false; ScanProjects(); AutoEnable(); }
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); }
void Ask(string Tag, string Uitleg, string Vraag) { if (Config.C(Tag) != "") { return; } QCol.Green($"{Uitleg}\n"); var Antwoord = ""; do { QCol.Yellow($"{Vraag}: "); Antwoord = Console.ReadLine().Replace("\\", "/").Trim(); } while (Antwoord == ""); Config.D(Tag, Antwoord); Config.SaveSource(ShowConfig); }
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 }
private void WorkSpace_TextChanged(object sender, TextChangedEventArgs e) { wpchanged = true; config.D("WORKSPACE", WorkSpace.Text); AutoEnable(); }
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); }
public void DefData(string f, string v) { Data.D(f, v); SaveMe(); }