Example #1
0
        public override void Run(FlagParse fp)
        {
            if (fp.Args.Length < 2)
            {
                QCol.Green("This feature allows you to show the content of a certain file.\n");
                QCol.Green("In order to do this, some additional configuration will be needed, as well as knowledge of the file system you are using.\n");
                QCol.Green("Don't worry about having to set up this file, manually. You will be prompted whenever NJCR requires more information.\n");
                QCol.Green($"The configuration can lateron be edited with your favority text editor (as long as it supports Unix LF line ends), as it will be saved as {ShowConfig}");
                return;
            }
            QCol.Doing("Reading JCR", fp.Args[1].Replace("\\", "/"));
            var jcr = JCR6.Dir(fp.Args[1]);

            if (jcr == null)
            {
                QCol.QuickError(JCR6.JERROR); return;
            }
            if (!File.Exists(ShowConfig))
            {
                QuickStream.SaveString(ShowConfig, "[rem]\nNothint to see here yet\n");
            }
            Config = GINI.ReadFromFile(ShowConfig);
            Ask("Temp.Dir", "I am in need of a temp-directory.\nYou can pick any directory you want for this, and the system will try to create the desired directory if it doesn't yet exist.\nThe files to show will be temporarily stored here, and IT'S VERY IMPORTANT THAT THIS DIRECTORY IS ONLY USED FOR THIS PURPOSE!!!", "Temp Folder");
            QCol.Doing("Temp dir", TempFolder);
            Directory.CreateDirectory(TempFolder);
            for (int i = 2; i < fp.Args.Length; i++)
            {
                Show(jcr, fp.Args[i]);
            }
        }
Example #2
0
 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);
 }
Example #3
0
        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();
        }
Example #4
0
        void ScanMaps()
        {
            string SelPrj = (string)PrjSelect.SelectedValue;

            PrjMapSelect.Items.Clear();
            if (SelPrj == "" || SelPrj[0] == '*')
            {
                return;
            }
            PrjMapSelect.Items.Add("**NEW MAP**");
            //System.Diagnostics.Debug.WriteLine($"Alt Drives {Dirry.ADrives()}"); // Debug

            var   pfile    = Dirry.AD($"{DirWorkSpace}/{SelPrj}/{SelPrj}.Project.GINI");
            TGINI TProject = GINI.ReadFromFile(pfile);

            if (TProject == null)
            {
                MessageBox.Show($"Failed to load the project file!\n{pfile}");
            }
            else
            {
                var ls = FileList.GetDir(Dirry.AD(TProject.C("LEVELDIR")));
                foreach (string f in ls)
                {
                    PrjMapSelect.Items.Add(f);
                }
            }
        }
        }     //End Function

        static public TGINI ReadFromLines(string[] lines)
        {
            var ret = new TGINI();

            //ret.init1st()
            ret.ParseLines(lines);
            return(ret);
        }
        static TGINI ReadFromBytes(byte[] thebytes)
        {
            var ret = new TGINI();

            //ret.init1st()
            ret.ReadFromBytes(thebytes);
            return(ret);
        }
Example #7
0
        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();
        }
Example #8
0
 void Init(string[] args)
 {
     Kthura.automap = false;
     if (args.Length == 0)
     {
         Uitleg();
         OriCol();
         Environment.Exit(0);
     }
     InitJCR6.Go();
     ExportBasis.Init();
     Dirry.InitAltDrives(AltDrivePlaforms.Windows); // TODO: I may need to expand this later for Linux and Mac.
     cli_Settings = new FlagParse(args);
     cli_Settings.CrString("target");
     cli_Settings.CrString("project");
     cli_Settings.CrString("map");
     cli_Settings.CrString("xpto");
     if (!cli_Settings.Parse())
     {
         Uitleg();
         Error("Parsing command line input failed!");
     }
     Project = cli_Settings.GetString("project");
     Map     = cli_Settings.GetString("map");
     XPTo    = cli_Settings.GetString("xpto");
     Target  = cli_Settings.GetString("target");
     Assert(File.Exists(GlobalConfigFile), $"I cannot find {GlobalConfigFile}");
     GlobalConfig = GINI.ReadFromFile(GlobalConfigFile);
     Assert(GlobalConfig != null, "Global config could nt be properly loaded");
     Assert(Project, "Hey! I don't have a project!");
     Assert(WorkSpace, "I can't find out what the workspace is. Is Kthura properly configured?");
     Assert(File.Exists(ProjectConfigFile), $"I could not access {ProjectConfigFile}. It appears it doesn't exist!");
     Doing("Reading project", ProjectConfigFile);
     ProjectConfig = GINI.ReadFromFile(ProjectConfigFile);
     Assert(ProjectConfig, "Project could not be properly read.");
     Target = cli_Settings.GetString("target");
     if (Target == "")
     {
         Target = ProjectConfig.C("EXPORT.TARGET");
     }
     Assert(Target, "No target");
     Doing("Exporting to", Target);
     Assert(ExportBasis.HaveDriver(Target), $"Driver to export to {Target} has not been found!");
     XPTo = cli_Settings.GetString("xpto");
     if (XPTo == "")
     {
         XPTo = ProjectConfig.C("EXPORT.XPTO");
     }
     Assert(XPTo, "No export-to folder.");
     Map = cli_Settings.GetString("map");
 }
Example #9
0
        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);
        }
        /// <summary>
        /// This function can read a GINI file.
        /// Either being a 'text' file or 'compiled' file doesn't matter
        /// this routine can autodetect that.
        /// </summary>
        /// <param name="file"></param>
        /// <param name="AcceptNonExistance"></param>
        /// <returns></returns>
        static public TGINI ReadFromFile(string file, bool AcceptNonExistance = false)
        {
            if (!File.Exists(file))
            {
                if (AcceptNonExistance)
                {
                    return(new TGINI());
                }
                Console.WriteLine($"GINI file {file} doesn't exist");
                return(null);
            }
            var ret = new TGINI();
            var b   = QuickStream.GetFile(file);

            return(ParseBytes(b));
        }
Example #11
0
        void LoadMainConfig()
        {
            if (!File.Exists(GINIFILE))
            {
                Crash($"I need configuration first!\nLoading the launcher will do that for you!");
            }
            dwriteln($"Reading: {GINIFILE}");
            MainConfig = GINI.ReadFromFile(GINIFILE);
            switch (MainConfig.C("Platform").ToUpper())
            {
            case "WINDOWS": Dirry.InitAltDrives(AltDrivePlaforms.Windows); break;

            case "LINUX": Dirry.InitAltDrives(AltDrivePlaforms.Linux); break;

            default:
                Crash($"Unknown platform setting in project file: {MainConfig.C("Platform")}");
                break;
            }
        }
Example #12
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}";
        }
Example #13
0
 void Scan4Maps()
 {
     if (LstProjects.SelectedItem == null)
     {
         return;                                   // Crash prevention
     }
     try {
         var prj = LstProjects.SelectedItem.ToString();
         Debug.WriteLine($"Scanning project: {prj}");
         var      projectfile = $"{MainConfig.WorkSpace}/{prj}/{prj}.Project.ini";
         var      prjfile     = $"{MainConfig.WorkSpace}/{prj}/{prj}.Project.GINI";
         string[] maps        = null;
         if (File.Exists(projectfile))
         {
             GINIE PRJ = GINIE.FromFile(projectfile);
             maps = FileList.GetDir(PRJ[$"Paths.{MainConfig.Platform}", "Maps"]);
             StartTheEditor.IsEnabled = true;
             NieuwSysteem             = true;
         }
         else if (File.Exists(prjfile))
         {
             TGINI Project = GINI.ReadFromFile(prjfile);
             if (Project == null)
             {
                 MessageBox.Show($"Reading {prjfile} failed!", "Project scanning error", MessageBoxButton.OK, MessageBoxImage.Error); return;
             }
             maps = FileList.GetDir(Project.C("Maps"));
             StartTheEditor.IsEnabled = false;
             NieuwSysteem             = false;
         }
         LstMaps.Items.Clear();
         LstMaps.Items.Add("** New Map **");
         foreach (string m in maps)
         {
             LstMaps.Items.Add(m);
         }
     } catch (Exception E) {
         MessageBox.Show(E.Message, "Project scanning errorr", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #14
0
 private static void InitArgs()
 {
     JCR6_lzma.Init();
     MyArgs.CrBool("version", false);
     MyArgs.CrBool("help", false);
     MyArgs.CrBool("h", false);
     if (!MyArgs.Parse(true))
     {
         throw new Exception("Invalid input");
     }
     if (MyArgs.GetBool("version"))
     {
         Head();
         Console.WriteLine(MKL.All(true));
         Environment.Exit(0);
     }
     if (MyArgs.GetBool("h") || MyArgs.GetBool("help"))
     {
         Head();
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.Write("MKL_Update ");
         Console.ForegroundColor = ConsoleColor.Yellow;
         Console.WriteLine("[<dir1> [<dir2> [<dir3>....]]]");
         Console.ForegroundColor = ConsoleColor.Gray;
         Console.WriteLine("\tUpdates the MKL data and license blocks in given directories. If none given, the current directory will be done");
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.Write("MKL_Update ");
         Console.ForegroundColor = ConsoleColor.Magenta;
         Console.WriteLine("-h");
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.Write("MKL_Update ");
         Console.ForegroundColor = ConsoleColor.Magenta;
         Console.WriteLine("-help");
         Console.ForegroundColor = ConsoleColor.Gray;
         Console.WriteLine("\tShows this help text");
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.Write("MKL_Update ");
         Console.ForegroundColor = ConsoleColor.Magenta;
         Console.WriteLine("-version");
         Console.ForegroundColor = ConsoleColor.Gray;
         Console.WriteLine("\tShows detailed version information");
         Console.WriteLine("\n\n\nThe next programming languages are supported by MKL_Update");
         foreach (string k in JCR.Entries.Keys)
         {
             if (qstr.Prefixed(k, "EXT/"))
             {
                 TGINI T = GINI.ReadFromLines(JCR.ReadLines(k));
                 // Console.WriteLine($"{k} => {qstr.Prefixed(k, "EXT/")}"); // debug line
                 Console.ForegroundColor = ConsoleColor.Yellow;
                 Console.BackgroundColor = ConsoleColor.Blue;
                 Console.Write(k.ToLower());
                 for (int i = k.Length; i < 30; i++)
                 {
                     Console.Write(" ");
                 }
                 Console.BackgroundColor = ConsoleColor.Black;
                 Console.ForegroundColor = ConsoleColor.Magenta;
                 Console.WriteLine($" {T.C("LANGUAGE")}");
             }
         }
         Console.ResetColor();
         Environment.Exit(0);
     }
 }
Example #15
0
        void SetupProject(string[] args)
        {
            dwriteln("Project setup started");
            FlagParse fp = new FlagParse(args);

            fp.CrString("Target", "");
            fp.CrString("To", "");
            fp.CrString("Project", "");
            if (!fp.Parse(
#if DEBUG
                    true
#endif
                    ))
            {
                Crash("Flag parsing failed!");
            }
            XProject = fp.GetString("Project");
            XTarget  = fp.GetString("Target");
            XTo      = fp.GetString("To");
            if (XProject == "" && XTarget == "" && XTo == "")
            {
                cwrite(ConsoleColor.Cyan, "Usage: ");
                cwrite(ConsoleColor.DarkGreen, $"{qstr.RemSuffix(qstr.StripDir(System.Reflection.Assembly.GetEntryAssembly().Location),".exe")} ");
                cwrite(ConsoleColor.DarkMagenta, "-<flag> <value>\n\n");
                cwrite(ConsoleColor.Red, string.Format("{0,15}", "-Project ")); cwriteln(ConsoleColor.Green, "Define the project");
                cwrite(ConsoleColor.Red, string.Format("{0,15}", "-Target ")); cwriteln(ConsoleColor.Green, "Define the target language");
                cwrite(ConsoleColor.Red, string.Format("{0,15}", "-To ")); cwriteln(ConsoleColor.Green, "Define the folder where the translations should go to");
                Console.WriteLine("");
                cwriteln(ConsoleColor.Yellow, "Supported target languages:");
                foreach (string drv in XPort_Base.Drivers.Keys)
                {
                    cwrite(ConsoleColor.Red, "= ");
                    cwriteln(ConsoleColor.DarkYellow, drv);
                }
                Console.WriteLine("");
                cwriteln(ConsoleColor.White, "Please note that \"To\" and \"Target\" can also be defined in the project file, so you don't have to name them here.\nWhen using them here on the cli even if set in the project file, the value set in the cli will take priority!");
                Halt(0);
            }
            if (XProject == "")
            {
                Crash("No Project!");
            }
            ProjectFile = Dirry.AD($"{MainConfig.C("WorkSpace")}/{XProject}/{XProject}.project.GINI");
            dwriteln($"Reading: {ProjectFile}");
            ProjectConfig = GINI.ReadFromFile(ProjectFile);
            cwrite(ConsoleColor.Yellow, "Reading Project: ");
            cwriteln(ConsoleColor.Cyan, XProject);
            if (ProjectConfig == null)
            {
                Crash($"Reading {ProjectFile} failed!");
            }
            if (XTarget == "")
            {
                XTarget = ProjectConfig.C("XPORT.TARGET");
            }
            if (XTarget == "")
            {
                Crash("And to what language do you want to translate this to? Without the -Target flag, I don't know!");
            }
            if (XTo == "")
            {
                XTo = ProjectConfig.C("XPORT.TO");
            }
            if (XTo == "")
            {
                Crash("And where do you want the translations to be put? Without the -To flag, I don't know!");
            }
            XTarget = XTarget.ToLower();
            if (!XPort_Base.Drivers.ContainsKey(XTarget))
            {
                Crash($"I cannot export to {XTarget}");
            }
        }
Example #16
0
 void Assert(TGINI ok, string e) => Assert(ok != null, e);
Example #17
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
        }
        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);
        }