예제 #1
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();
        }
예제 #2
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");
 }
예제 #3
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);
                }
            }
        }
예제 #4
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;
            }
        }
예제 #5
0
        void TranslateMaps()
        {
            Doing("Analysing Maps for Project", XProject);
            var tdrv   = XPort_Base.Drivers[XTarget];
            var mapdir = Dirry.AD(ProjectConfig.C("LevelDir"));
            var fl     = FileList.GetDir(mapdir);

            foreach (string mapname in fl)
            {
                Doing("Translating", mapname);
                var map = TeddyBear.TeddyMap.Load($"{mapdir}/{mapname}");
                if (map == null)
                {
                    Crash($"Map Load Error\n{JCR6.JERROR}");
                }
                var translation = tdrv.Translate(map);
                QuickStream.SaveString(tdrv.TransFile($"{XTo}/{mapname}"), translation);
            }
        }
예제 #6
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);
     }
 }
예제 #7
0
        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);
        }
예제 #8
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}");
            }
        }
예제 #9
0
 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);
 }
예제 #10
0
 public string GetData(string f) => Data.C(f);
예제 #11
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);
     }
 }