コード例 #1
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);
                }
            }
        }
コード例 #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);
 }
コード例 #3
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]);
            }
        }
コード例 #4
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();
        }
コード例 #5
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");
 }
コード例 #6
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;
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: TrickyGameTools/Kthura
        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}";
        }
コード例 #8
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);
     }
 }
コード例 #9
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}");
            }
        }
コード例 #10
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);
        }
コード例 #11
0
        static public dvProject Get(string prjname)
        {
            try {
                if (LoadedProjects.ContainsKey(prjname))
                {
                    return(LoadedProjects[prjname]);
                }
                GUI.WriteLn($"Loading project: {prjname}");
                var ret = new dvProject();
                ret.myname = prjname;
                ret.myfile = $"{MainClass.WorkSpace}/Projects/{ret.myname}";
                try {
                    ret.Data = GINI.ReadFromFile($"{ret.myfile}.prj");
                } catch {
                    GUI.WriteLn($"ERROR:\tI could not read {ret.myfile}.prj");
                    QuickGTK.Error($"!!ERROR!!\n\nI could not read {ret.myfile}.prj");
                    return(null);
                } finally {
                    GUI.WriteLn("Complete!");
                }
                if (ret.Data == null)
                {
                    GUI.WriteLn($"ERROR:\tI could not read {ret.myfile}.prj");
                    QuickGTK.Error($"!!ERROR!!\n\nI could not read {ret.myfile}.prj");
                    return(null);
                }
                // Load Indexes
                var     bix = QuickStream.ReadFile($"{ret.myfile}.Index");
                byte    tag;
                dvIndex Index;
                GUI.WriteLn($"Loading indexes for project: {prjname}");
                while (!bix.EOF)
                {
                    //if (bix.EOF) { Console.WriteLine($"ERROR! Record {want} not found"); goto closure; } // I hate the "goto" command but in this particular case it's the safest way to go! (No I do miss the "defer" keyword Go has!)
                    tag = bix.ReadByte();
                    if (tag != 0)
                    {
                        GUI.WriteLn($"ERROR! Unknown index command tag {tag}!"); ret = null; goto closure;
                    }
                    Index        = new dvIndex();
                    Index.id     = bix.ReadInt();
                    Index.size   = bix.ReadLong();
                    Index.offset = bix.ReadLong();
                    if (ret.Indexes.ContainsKey(Index.id))
                    {
                        GUI.WriteLn($"WARNING!!! Duplicate index #{Index.id}. One of them will overwrite another");
                    }
                    ret.Indexes[Index.id] = Index;
                    //einde = offset + size;
                }                 //while (id != want);//(id < 0 || id < min || id > max);
                LoadedProjects[prjname] = ret;
                GUI.WriteLn($"Records:        {ret.CountRecords}");
                GUI.WriteLn($"Highest number: {ret.HighestRecordNumber}");
                ret.Data.CL("CDPREFIX");
                dvPrefix pref = null;
                foreach (string iline in ret.Data.List("CDPREFIX"))
                {
                    var line = iline.Trim();
                    if (line != "")
                    {
                        var p = line.IndexOf(':');
                        if (p < 0)
                        {
                            GUI.WriteLn("Invalid Prefix definition!");
                        }
                        else
                        {
                            var key   = line.Substring(0, p).Trim().ToUpper();
                            var value = line.Substring(p + 1).Trim();
                            if (key == "NEW")
                            {
                                pref = new dvPrefix();
                                ret.Prefixes[value] = pref;
                                GUI.WriteLn($"Prefix added:   {value}");
                            }
                            else if (pref == null)
                            {
                                GUI.WriteLn("Definition without prefix! Please check your prefix settings!");
                            }
                            else
                            {
                                pref.RawSet(key, value);
                                Console.WriteLine($"Prefix[\"{key}\"]=\"{value}\";");
                            }
                        }
                    }
                }
closure:
                bix.Close();
                return(ret);
            } catch (Exception E) {
                QuickGTK.Error(E.Message);
                return(null);
            }
        }