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(); }
static void Annoy(string arg) => QuickGTK.Info(arg); // This is just a test ;)
static void OnQIConfirm(object sender, EventArgs e) { var input = QI_Input.Text; var name = input.ToUpper(); MenuBoxInput.Hide(); if (!QIValidName(name)) { QuickGTK.Error("Invalid record name!\n\nRecord names may only contain letters, numbers and underscores!"); return; } if (MyDataBase.Record.ContainsKey(name)) { if (!QuickGTK.Confirm($"A record named {name} already exists!\n\nIf you continue the old record will be destroyed and replaced by the new one!\n\nAre you sure?")) { return; } } switch (want) { case "NEW": var newrec = new MyRecord(); MyDataBase.Record[name] = newrec; foreach (string k in MyDataBase.fields.Keys) { var uk = k.ToUpper(); newrec.value[k] = ""; switch (MyDataBase.fields[k]) { case "int": case "double": newrec.value[k] = "0"; break; case "bool": newrec.value[k] = "FALSE"; break; case "date": newrec.value[k] = "19/6/1975"; break; case "time": newrec.value[k] = "00:00:00"; break; } if (MyDataBase.defaults.ContainsKey(uk)) { newrec.value[k] = MyDataBase.defaults[uk]; } Console.WriteLine($"Field: {MyDataBase.fields[k]} {k} = {newrec.value[k]}"); } newrec.MODIFIED = true; MyDataBase.UpdateRecView(); // TODO: New record should add default values if set. QuickGTK.Info($"Record {name} has been created!"); break; case "DUPE": var rec = MyDataBase.Record[sc_rec]; newrec = new MyRecord(); MyDataBase.Record[name] = newrec; foreach (string k in MyDataBase.fields.Keys) { newrec.value[k] = rec.value[k]; } newrec.MODIFIED = true; MyDataBase.UpdateRecView(); QuickGTK.Info($"Record {sc_rec} has been duplicated into {name}"); break; case "RENAME": var crec = MyDataBase.Record[sc_rec]; MyDataBase.Record.Remove(sc_rec); MyDataBase.Record[name] = crec; crec.MODIFIED = true; MyDataBase.UpdateRecView(); QuickGTK.Info($"Record {sc_rec} has been renamed to {name}\n\nWARNING!\nIf you've set MyData to record-by-record export files with the old name will remain!"); break; default: QuickGTK.Error($"Internal error!\n\n\nInvalid input request --> {want}!"); break; } }