Exemplo n.º 1
0
        static bool ChooseTheFile(Window w, string[] a)
        {
            if (a.Length != 0 && System.IO.File.Exists(a[0]))
            {
                filename = a[0]; return(true);
            }
            var ops = Dirry.C("$AppSupport$/MyData/Startup");

            if (System.IO.File.Exists(ops))
            {
                var file = QOpen.LoadString(ops);
                System.IO.File.Delete(ops);
                if (System.IO.File.Exists(file))
                {
                    filename = file;
                    return(true);
                }
            }
            FileChooserDialog fcd = new FileChooserDialog("Choose database", w, FileChooserAction.Open, "Select", ResponseType.Accept, "Cancel", ResponseType.Close);

            fcd.SelectMultiple = false;
            var  r       = fcd.Run(); // This opens the window and waits for the response
            bool alright = false;

            if (r == (int)ResponseType.Accept)
            {
                filename = fcd.Filename;
                alright  = true;
            }
            fcd.Destroy(); // The dialog does not automatically close when clicking the buttons, so you have to manually close it with this
            return(alright);
        }
Exemplo n.º 2
0
 static void Load_JCR6()
 {
     Assets = JCR6.Dir(Dirry.C("$AppDir$/jcr/Kobud.jcr"));
     if (Assets == null)
     {
         QuickGTK.Error(JCR6.JERROR);
         throw new Exception(JCR6.JERROR);
     }
 }
Exemplo n.º 3
0
 static Core()
 {
     MKL.Lic("Stach - Core.cs", "GNU General Public License 3");
     MKL.Version("Stach - Core.cs", "21.03.09");
     FFS.Hello();
     Debug.WriteLine($"Running on {Platform}");
     Dirry.InitAltDrives();
     Config = GINIE.FromFile($"{Dirry.C("$AppSupport$/Stach.ini")}");
     Config.AutoSaveSource = $"{Dirry.C("$AppSupport$/Stach.ini")}";
     JCR6_lzma.Init();
     JCR6_jxsrcca.Init();
     JCR6_zlib.Init();
     new JCR_QuakePack();
     new JCR_a();
     new JCR_QuickLink();
     JCR_JCR5.Init();
     new JCR6_WAD();
     new JCR_WestwoodPAK();
 }
        public static void Main(string[] getargs)
        {
#if DEBUG
            string[] args = { "C", "Test" };
#else
            string[] args = getargs;
#endif
            Dirry.C("$AppSupport"); // Just forces MKL to be properly set :P
            QOpen.Hello();
            qstr.Chr(1);
            Compile.Hi();
            MKL.Lic("DevLog Compiler - DevLogCompiler.cs", "GNU General Public License 3");
            MKL.Version("DevLog Compiler - DevLogCompiler.cs", "18.11.17");
            Console.WriteLine($"DevLog - version {MKL.Newest}");
            Console.WriteLine($"(c) Jeroen P. Broks 2018-20{qstr.Left(MKL.Newest,2)}");
#if DEBUG
            Console.WriteLine("\n\nWARNING! This is the debug version!\nAs the name suggests this build should be used for debugging purposes ONLY!\n");
#endif
            if (args.Length == 0)
            {
                Console.WriteLine("\n\n");
                Console.WriteLine("DevLogCompiler c <project> - Compiles Project Into Binary form");
                //Console.WriteLine("DevLogCompiler d <project> - Decompiles Project From Binary form back to text form");
                Console.WriteLine("DevlogCompiler v           - Full version information");
                return;
            }
            switch (args[0].ToUpper())
            {
            case "C": if (args.Length != 2)
                {
                    Console.WriteLine("Invalid command line input!"); return;
                }
                Compile.Go($"{WorkSpace}/Projects/{args[1]}");
                break;

            case "V": Console.WriteLine($"\n{MKL.All()}"); break;

            default: Console.WriteLine("Unknown command switch"); break;
            }
        }
Exemplo n.º 5
0
        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);
        }