Beispiel #1
0
        public void FakeInstance_ValidArgumentsWithDLCs_ManagerHasValidInstance()
        {
            string      name      = "testname";
            GameVersion mhVersion = GameVersion.Parse("1.1.0");
            GameVersion bgVersion = GameVersion.Parse("1.0.0");
            string      tempdir   = TestData.NewTempDir();
            GameVersion version   = GameVersion.Parse("1.7.1");

            Dictionary <CKAN.DLC.IDlcDetector, GameVersion> dlcs = new Dictionary <CKAN.DLC.IDlcDetector, GameVersion>()
            {
                { new CKAN.DLC.MakingHistoryDlcDetector(), mhVersion },
                { new CKAN.DLC.BreakingGroundDlcDetector(), bgVersion }
            };

            manager.FakeInstance(new KerbalSpaceProgram(), name, tempdir, version, dlcs);
            CKAN.GameInstance newKSP = new CKAN.GameInstance(new KerbalSpaceProgram(), tempdir, name, new NullUser());
            CKAN.DLC.MakingHistoryDlcDetector  mhDetector = new CKAN.DLC.MakingHistoryDlcDetector();
            CKAN.DLC.BreakingGroundDlcDetector bgDetector = new CKAN.DLC.BreakingGroundDlcDetector();

            Assert.IsTrue(manager.HasInstance(name));
            Assert.IsTrue(mhDetector.IsInstalled(newKSP, out string _, out UnmanagedModuleVersion detectedMhVersion));
            Assert.IsTrue(bgDetector.IsInstalled(newKSP, out string _, out UnmanagedModuleVersion detectedBgVersion));
            Assert.IsTrue(detectedMhVersion == new UnmanagedModuleVersion(mhVersion.ToString()));
            Assert.IsTrue(detectedBgVersion == new UnmanagedModuleVersion(bgVersion.ToString()));

            // Tidy up.
            CKAN.RegistryManager.Instance(newKSP).ReleaseLock();
            System.IO.Directory.Delete(tempdir, true);
        }
        public void Save(string filePath)
        {
            XDocument doc = new XDocument();

            doc.Add(new XElement("contentpackage",
                                 new XAttribute("name", Name),
                                 new XAttribute("path", Path),
                                 new XAttribute("corepackage", CorePackage)));


            doc.Root.Add(new XAttribute("gameversion", GameVersion.ToString()));

            if (!string.IsNullOrEmpty(SteamWorkshopUrl))
            {
                doc.Root.Add(new XAttribute("steamworkshopurl", SteamWorkshopUrl));
            }

            if (InstallTime != null)
            {
                doc.Root.Add(new XAttribute("installtime", ToolBox.Epoch.FromDateTime(InstallTime.Value)));
            }

            foreach (ContentFile file in Files)
            {
                doc.Root.Add(new XElement(file.Type.ToString(), new XAttribute("file", file.Path)));
            }

            doc.Save(filePath);
        }
Beispiel #3
0
        public static string GetVersionName(GameVersion version)
        {
            var list  = (List <ComboItem>)VersionDataSource;
            var first = list.Find(z => z.Value == (int)version);

            return(first.Equals(default(ComboItem)) ? version.ToString() : first.Text);
        }
        private void UpdateJSON(string pluginPath)
        {
            if (File.Exists(pluginPath))
            {
                JObject jObject = JObject.Parse(File.ReadAllText(pluginPath));

                string modVersionText  = ModVersion.ToString();
                string gameVersionText = GameVersion.ToString();

                bool f0 = jObject["name"].ToString() != ModName;
                bool f1 = jObject["version"].ToString() != modVersionText;
                bool f2 = jObject["gameversion"].ToString() != gameVersionText;

                if (f0 || f1 || f2)
                {
                    if (f0)
                    {
                        jObject["name"] = ModName;
                    }
                    if (f1)
                    {
                        jObject["version"] = modVersionText;
                    }
                    if (f2)
                    {
                        jObject["gameversion"] = gameVersionText;
                    }

                    File.WriteAllText(pluginPath, jObject.ToString());
                }
            }
        }
        public void GameVersion(string versionStr)
        {
            // act
            GameVersion version = new GameVersion(versionStr);

            // assert
            Assert.AreEqual(versionStr, version.ToString(), "The game version did not round-trip to the same value.");
        }
Beispiel #6
0
 /// <summary>
 /// 获取游戏版本号
 /// </summary>
 public string GetGameVersion()
 {
     if (GameVersion == null)
     {
         return(string.Empty);
     }
     return(GameVersion.ToString());
 }
Beispiel #7
0
        public void GameVersion(string versionStr)
        {
            // act
            GameVersion version = new GameVersion(versionStr);

            // assert
            Assert.AreEqual(versionStr, version.ToString(), "The game version did not round-trip to the same value.");
            Assert.IsTrue(version.IsOlderThan(new SemanticVersion("1.2.30")), "The game version should be considered older than the later semantic versions.");
        }
Beispiel #8
0
 public static void AddHeader(StringBuilder sb, GameVersion Version, string name)
 {
     sb.AppendLine("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
     sb.AppendLine("<title>" + name + " - Tales of Vesperia (" + Version.ToString() + ")</title>");
     sb.AppendLine("<style>");
     sb.AppendLine(HyoutaTools.Properties.Resources.vesperia_website_general_css);
     sb.AppendLine(HyoutaTools.Properties.Resources.vesperia_website_scenario_css);
     sb.AppendLine("</style>");
     sb.AppendLine("</head>");
 }
 public static void AddHeader(StringBuilder sb, GameVersion Version, string name)
 {
     sb.AppendLine("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
     sb.AppendLine("<title>" + name + " - Tales of Vesperia (" + Version.ToString() + ")</title>");
     sb.AppendLine("<style>");
     sb.AppendLine(StyleCss);
     sb.AppendLine(ScenarioCss);
     sb.AppendLine("</style>");
     sb.AppendLine("</head>");
 }
Beispiel #10
0
        public static SKBitmap GetGameIcon(GameVersion game)
        {
            var img = LoadBitmapResource($"games.{(int)game}");

            if (img != null)
            {
                return(img);
            }
            return(LoadBitmapResource($"games.{game.ToString()}"));
        }
        /// <summary>
        /// Gets the description from a specific game version
        /// </summary>
        /// <param name="version">Game version</param>
        /// <returns>Description text, or null (if description for version is not found)</returns>
        public string GetDescription(GameVersion version)
        {
            switch (version)
            {
            case GameVersion.Any:
                return(this.Descriptions.FirstOrDefault()?.Description);

            default:
                return(this.Descriptions.FirstOrDefault(x => x.GameVersion.Equals(version.ToString(), StringComparison.InvariantCultureIgnoreCase))?.Description);
            }
        }
        public static PkNxGameVersion ToPkNxVersion(this GameVersion version)
        {
            var name = version.ToString();

            if (!Enum.TryParse <PkNxGameVersion>(name, ignoreCase: true, out var pknxVersion))
            {
                throw new InvalidOperationException($"Invalid PkNX game version: {name}");
            }

            return(pknxVersion);
        }
        /// <summary>
        /// 保存写入游戏版本数据
        /// </summary>
        public void SaveVersion()
        {
            string resVersion = gameVersion.ToString();

#if UNITY_IOS
            string resVersionPath = BuilderPreference.VERSION_PATH + "/version_ios.txt";
#else
            string resVersionPath = BuilderPreference.VERSION_PATH + "/version.txt";
#endif
            BuildUtil.SwapPathDirectory(resVersionPath);

            File.WriteAllText(resVersionPath, resVersion.ToString());
        }
Beispiel #14
0
        /// <summary>
        /// Returns a human readable string indicating the highest compatible
        /// version of KSP this module will run with. (Eg: 1.0.2,
        /// "All versions", etc).
        ///
        /// This is for *human consumption only*, as the strings may change in the
        /// future as we support additional locales.
        /// </summary>
        public string HighestCompatibleKSP()
        {
            GameVersion v = LatestCompatibleKSP();

            if (v.IsAny)
            {
                return("All versions");
            }
            else
            {
                return(v.ToString());
            }
        }
Beispiel #15
0
 static int ToString(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         GameVersion obj = (GameVersion)ToLua.CheckObject <GameVersion>(L, 1);
         string      o   = obj.ToString();
         LuaDLL.lua_pushstring(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #16
0
        /// <summary>
        /// If the installed game version is in the given range,
        /// return the given array without the given parameter,
        /// otherwise return the array as-is.
        /// </summary>
        /// <param name="args">Command line parameters to check</param>
        /// <param name="crashyKspRange">Game versions that should not use this parameter</param>
        /// <param name="parameter">The parameter to remove on version match</param>
        /// <returns>
        /// args or args minus parameter
        /// </returns>
        private string[] filterCmdLineArgs(string[] args, GameVersion installedVersion, GameVersionRange crashyKspRange, string parameter)
        {
            var installedRange = installedVersion.ToVersionRange();

            if (crashyKspRange.IntersectWith(installedRange) != null &&
                args.Contains(parameter))
            {
                log.DebugFormat(
                    "Parameter {0} found on incompatible KSP version {1}, pruning",
                    parameter,
                    installedVersion.ToString());
                return(args.Where(s => s != parameter).ToArray());
            }
            return(args);
        }
        public static string GetFullName(this GameVersion gameVersion)
        {
            switch (gameVersion)
            {
            case GameVersion.CallOfDuty2:
                return("Call of Duty 2");

            case GameVersion.CallOfDuty4:
                return("Call of Duty 4: Modern Warfare");

            case GameVersion.CallOfDuty5:
                return("Call of Duty: World at War");

            default:
                return(gameVersion.ToString());
            }
        }
Beispiel #18
0
        public void SingleParameterCtorWorksCorrectly()
        {
            // Act
            var result = new GameVersion(1);

            // Assert
            Assert.AreEqual(1, result.Major);
            Assert.AreEqual(-1, result.Minor);
            Assert.AreEqual(-1, result.Patch);
            Assert.AreEqual(-1, result.Build);

            Assert.IsTrue(result.IsMajorDefined);
            Assert.IsFalse(result.IsMinorDefined);
            Assert.IsFalse(result.IsPatchDefined);
            Assert.IsFalse(result.IsBuildDefined);

            Assert.IsFalse(result.IsFullyDefined);
            Assert.IsFalse(result.IsAny);

            Assert.AreEqual("1", result.ToString());
        }
Beispiel #19
0
        public void QuadrupleParameterCtorWorksCorrectly()
        {
            // Act
            var result = new GameVersion(1, 2, 3, 4);

            // Assert
            Assert.AreEqual(1, result.Major);
            Assert.AreEqual(2, result.Minor);
            Assert.AreEqual(3, result.Patch);
            Assert.AreEqual(4, result.Build);

            Assert.IsTrue(result.IsMajorDefined);
            Assert.IsTrue(result.IsMinorDefined);
            Assert.IsTrue(result.IsPatchDefined);
            Assert.IsTrue(result.IsBuildDefined);

            Assert.IsTrue(result.IsFullyDefined);
            Assert.IsFalse(result.IsAny);

            Assert.AreEqual("1.2.3.4", result.ToString());
        }
        public void Save(string filePath, bool reload = true)
        {
            var  packagesToDeselect = corePackages.Concat(regularPackages).Where(p => p.Path.CleanUpPath() == Path.CleanUpPath()).ToList();
            bool refreshFiles       = false;

            if (packagesToDeselect.Any())
            {
                foreach (var p in packagesToDeselect)
                {
                    if (p.IsCorePackage)
                    {
                        if (GameMain.Config.CurrentCorePackage == p)
                        {
                            refreshFiles = true;
                        }
                        corePackages.RemoveOnMainThread(p);
                    }
                    else
                    {
                        if (GameMain.Config.EnabledRegularPackages.Contains(p))
                        {
                            refreshFiles = true;
                        }
                        regularPackages.RemoveOnMainThread(p);
                    }
                }
                if (IsCorePackage)
                {
                    corePackages.AddOnMainThread(this);
                }
                else
                {
                    regularPackages.AddOnMainThread(this);
                }

                if (refreshFiles)
                {
                    GameMain.Config.DisableContentPackageItems(filesToRemove);
                    GameMain.Config.EnableContentPackageItems(filesToAdd);
                    GameMain.Config.RefreshContentPackageItems(filesToRemove.Concat(filesToAdd).Distinct());
                }
            }
            files.RemoveAll(f => filesToRemove.Contains(f));
            files.AddRange(filesToAdd);
            filesToRemove.Clear(); filesToAdd.Clear();

            XDocument doc = new XDocument();

            doc.Add(new XElement("contentpackage",
                                 new XAttribute("name", Name),
                                 new XAttribute("path", Path.CleanUpPathCrossPlatform(correctFilenameCase: false)),
                                 new XAttribute("corepackage", IsCorePackage)));

            doc.Root.Add(new XAttribute("gameversion", GameVersion.ToString()));

            if (SteamWorkshopId != 0)
            {
                doc.Root.Add(new XAttribute("steamworkshopid", SteamWorkshopId.ToString()));
            }

            if (InstallTime != null)
            {
                doc.Root.Add(new XAttribute("installtime", ToolBox.Epoch.FromDateTime(InstallTime.Value)));
            }

            foreach (ContentFile file in Files)
            {
                doc.Root.Add(new XElement(file.Type.ToString(), new XAttribute("file", file.Path.CleanUpPathCrossPlatform())));
            }

            doc.SaveSafe(filePath);
        }
Beispiel #21
0
    public void Handle_connection(IAsyncResult result)        //the parameter is a delegate, used to communicate between threads
    {
        Accept_connection();                                  //once again, checking for any other incoming connections
        TcpClient client = server.EndAcceptTcpClient(result); //creates the TcpClient

        NetworkStream ns = client.GetStream();

        while (client.Connected)  //while the client is connected, we look for incoming messages
        {
            try
            {
                if (type != "bot_info")
                {
                    string version = "";
                    if (type == "legal_fix")
                    {
                        byte[] versionBytes = Read_NS_Data(ns, 8);
                        version = Encoding.UTF8.GetString(versionBytes, 0, versionBytes.Length);
                        Console.WriteLine("Version sent over is: " + version);
                    }
                    var pk = GetPokemon(ns);
                    if (pk == null)
                    {
                        throw new System.ArgumentException("There was an issue reading the Pokemon data, is it not a Pokemon? (or maybe timeout?)");
                    }
                    if (type == "legality_check")
                    {
                        var lc = new LegalityAnalysis(pk);

                        byte[] report = Encoding.Default.GetBytes(lc.Report());
                        ns.Write(report, 0, report.Length);
                    }
                    else if (type == "info_get")
                    {
                        var summary = new GPSSSummary(pk, GameInfo.Strings);
                        var pkmn    = summary.CreatePKMN();
                        if (pkmn == null)
                        {
                            throw new System.ArgumentException("There was an issue reading the Pokemon data, is it not a Pokemon? (or maybe timeout?)");
                        }
                        var ser = new DataContractJsonSerializer(typeof(Pokemon));
                        ser.WriteObject(ns, pkmn);
                    }
                    else if (type == "legal_fix")
                    {
                        var alm = new AutoLegality(pk, version);
                        ns.Write(alm.GetLegalPKM().DecryptedBoxData, 0, alm.GetLegalPKM().DecryptedBoxData.Length);
                    }
                }
                else
                {
                    byte[] request_string_size    = Read_NS_Data(ns, 10);
                    string request_string_sizeStr = Encoding.UTF8.GetString(request_string_size, 0, request_string_size.Length);

                    int.TryParse(request_string_sizeStr, out int dataSize);
                    byte[] request_type    = Read_NS_Data(ns, dataSize);
                    string request_typeStr = Encoding.UTF8.GetString(request_type, 0, request_type.Length);
                    switch (request_typeStr)
                    {
                    case "enc_base64_get":
                    {
                        var qr = GenQR(GetPokemon(ns));
                        if (qr == null || qr.Length == 0)
                        {
                            ns.Write(Encoding.UTF8.GetBytes("."), 0, Encoding.UTF8.GetBytes(".").Length);
                            //throw new System.ArgumentException("Tried to upload something that wasn't a pokemon or something else went wrong during qr generation!");
                        }
                        else
                        {
                            ns.Write(qr, 0, qr.Length);
                        }
                        break;
                    }

                    case "encounter":
                    {
                        var queryStr = GetQueryString(ns);

                        var queries = queryStr.Split('|');

                        if (!Enum.GetNames(typeof(Species)).Any(s => s.ToLower() == queries[0]))
                        {
                            throw new System.ArgumentException("Invalid pokemon name provided!");
                        }
                        var data = EncounterLearn.GetLearnSummary(queries[0], queries.Skip(1));
                        var e    = new Encounters
                        {
                            Gen1 = new List <GenLoc>(),
                            Gen2 = new List <GenLoc>(),
                            Gen3 = new List <GenLoc>(),
                            Gen4 = new List <GenLoc>(),
                            Gen5 = new List <GenLoc>(),
                            Gen6 = new List <GenLoc>(),
                            Gen7 = new List <GenLoc>(),
                            Gen8 = new List <GenLoc>(),
                        };
                        bool first = true;
                        var  enc   = "";
                        foreach (var line in data)
                        {
                            if (line.StartsWith("="))
                            {
                                if (!first)
                                {
                                }
                                enc   = line.Replace("=", "");
                                first = false;
                                continue;
                            }
                            var gen   = GetStringFromRegex(@"Gen[0-9]", line);
                            var loc   = GetStringFromRegex(@"(?<=.{8}).+?(?=:)", line);
                            var games = GetStringFromRegex(@"([\t ][A-Z |,]{1,100}$|Any)", line);
                            games = games.Replace(" ", "");
                            games = games.Trim(':');
                            games = games.Trim('\t');
                            string[] gamesArray = games.Split(',');
                            GenLoc   entry      = new GenLoc();
                            switch (gen)
                            {
                            case "Gen1":
                            {
                                entry = e.Gen1.FirstOrDefault(l => l.EncounterType == enc);
                                break;
                            }

                            case "Gen2":
                            {
                                entry = e.Gen2.FirstOrDefault(l => l.EncounterType == enc);
                                break;
                            }

                            case "Gen3":
                            {
                                entry = e.Gen3.FirstOrDefault(l => l.EncounterType == enc);
                                break;
                            }

                            case "Gen4":
                            {
                                entry = e.Gen4.FirstOrDefault(l => l.EncounterType == enc);
                                break;
                            }

                            case "Gen5":
                            {
                                entry = e.Gen5.FirstOrDefault(l => l.EncounterType == enc);
                                break;
                            }

                            case "Gen6":
                            {
                                entry = e.Gen6.FirstOrDefault(l => l.EncounterType == enc);
                                break;
                            }

                            case "Gen7":
                            {
                                entry = e.Gen7.FirstOrDefault(l => l.EncounterType == enc);
                                break;
                            }

                            case "Gen8":
                            {
                                entry = e.Gen8.FirstOrDefault(l => l.EncounterType == enc);
                                break;
                            }
                            }
                            if (entry != null)
                            {
                                if (entry.Locations == null)
                                {
                                    entry.Locations = new List <Locs>();
                                }
                                var tmpGamesList = new List <string>();
                                foreach (var game in gamesArray)
                                {
                                    tmpGamesList.Add(game);
                                }
                                entry.Locations.Add(new Locs
                                    {
                                        Location = loc,
                                        Games    = tmpGamesList,
                                    });
                            }
                            else
                            {
                                var tmpGamesList = new List <string>();
                                foreach (var game in gamesArray)
                                {
                                    tmpGamesList.Add(game);
                                }
                                var tmpLocations = new List <Locs>
                                {
                                    new Locs
                                    {
                                        Location = loc,
                                        Games    = tmpGamesList,
                                    }
                                };
                                var tmpGenLoc = new GenLoc
                                {
                                    EncounterType = enc,
                                    Locations     = tmpLocations,
                                };
                                switch (gen)
                                {
                                case "Gen1":
                                {
                                    e.Gen1.Add(tmpGenLoc);
                                    break;
                                }

                                case "Gen2":
                                {
                                    e.Gen2.Add(tmpGenLoc);
                                    break;
                                }

                                case "Gen3":
                                {
                                    e.Gen3.Add(tmpGenLoc);
                                    break;
                                }

                                case "Gen4":
                                {
                                    e.Gen4.Add(tmpGenLoc);
                                    break;
                                }

                                case "Gen5":
                                {
                                    e.Gen5.Add(tmpGenLoc);
                                    break;
                                }

                                case "Gen6":
                                {
                                    e.Gen6.Add(tmpGenLoc);
                                    break;
                                }

                                case "Gen7":
                                {
                                    e.Gen7.Add(tmpGenLoc);
                                    break;
                                }

                                case "Gen8":
                                {
                                    e.Gen8.Add(tmpGenLoc);
                                    break;
                                }
                                }
                            }
                        }
                        var json = JsonConvert.SerializeObject(e);
                        ns.Write(Encoding.UTF8.GetBytes(json), 0, Encoding.UTF8.GetBytes(json).Length);
                        break;
                    }

                    case "move_learn":
                    {
                        var queryStr = GetQueryString(ns);
                        var queries  = queryStr.Split('|');
                        if (!Enum.GetNames(typeof(Species)).Any(s => s.ToLower() == queries[0]))
                        {
                            throw new System.ArgumentException("Invalid pokemon name provided!");
                        }
                        var i     = 1;
                        var moves = new List <LearnableMove>();
                        foreach (var move in queries.Skip(1))
                        {
                            if (i > 4)
                            {
                                break;
                            }
                            var workaround = move.Split(',');
                            var tmpMove    = new LearnableMove
                            {
                                MoveName = move,
                            };
                            if (!ConsoleIndex.moveNames.Any(m => m.ToLower().Contains(move.ToLower())))
                            {
                                tmpMove.Learnable = false;
                            }
                            else
                            {
                                tmpMove.Learnable = bool.Parse(EncounterLearn.CanLearn(queries[0], workaround).ToString());
                            }
                            moves.Add(tmpMove);
                            i++;
                        }
                        var json = JsonConvert.SerializeObject(moves);
                        ns.Write(Encoding.UTF8.GetBytes(json), 0, Encoding.UTF8.GetBytes(json).Length);
                        break;
                    }

                    case "poke_info":
                    {
                        var summary = new GPSSSummary(GetPokemon(ns), GameInfo.Strings);
                        var pkmn    = summary.CreatePKMN();
                        if (pkmn == null)
                        {
                            throw new System.ArgumentException("There was an issue reading the Pokemon data, is it not a Pokemon? (or maybe timeout?)");
                        }
                        var ser = new DataContractJsonSerializer(typeof(Pokemon));
                        ser.WriteObject(ns, pkmn);
                        break;
                    }

                    case "auto_legality":
                    {
                        byte[] size        = Read_NS_Data(ns, 8);
                        string dataSizeStr = Encoding.UTF8.GetString(size, 0, size.Length);
                        int.TryParse(dataSizeStr, out int dSize);
                        byte[]      version    = Read_NS_Data(ns, dSize);
                        string      versionStr = Encoding.UTF8.GetString(version, 0, version.Length);
                        GameVersion versionInt = 0;

                        var pkmn = GetPokemon(ns);
                        if (pkmn == null)
                        {
                            throw new System.ArgumentException("There was an issue reading the Pokemon data, is it not a Pokemon? (or maybe timeout?)");
                        }
                        if (versionStr == "?")
                        {
                            versionInt = GetPlaceholderVersion(pkmn);
                        }
                        else
                        {
                            int.TryParse(versionStr, out int vInt);
                            versionInt = (GameVersion)vInt;
                        }

                        var lc     = new LegalityAnalysis(pkmn);
                        var report = lc.Report().Split('\n');
                        var data   = new LegalityReturn
                        {
                            ran     = false,
                            success = true
                        };
                        if (!lc.Valid)
                        {
                            var alm = new AutoLegality(pkmn, versionInt.ToString());
                            Console.WriteLine(pkmn.Version);
                            var legalPK = alm.Legalize(pkmn, versionInt);
                            var qr      = System.Convert.ToBase64String(GenQR(legalPK));
                            if (qr == null || qr.Length == 0)
                            {
                                throw new ArgumentException("bad pokemon!");
                            }
                            data.qr      = System.Convert.ToBase64String(GenQR(legalPK));
                            data.pokemon = System.Convert.ToBase64String(legalPK.DecryptedBoxData);
                            data.ran     = true;
                            data.species = new GPSSSummary(legalPK, GameInfo.Strings).Species;
                            data.success = new LegalityAnalysis(legalPK).Valid;
                        }
                        if (data.ran && data.success)
                        {
                            data.report = report;
                        }
                        var json = JsonConvert.SerializeObject(data);
                        ns.Write(Encoding.UTF8.GetBytes(json), 0, Encoding.UTF8.GetBytes(json).Length);
                        break;
                    }

                    /*           case "index_lookup":
                     *             {
                     *                 var queryStr = GetQueryString(ns);
                     *                 break;
                     *             }*/
                    default: {
                        ns.Write(Encoding.UTF8.GetBytes("I don't know how to handle this query type yet!"), 0, Encoding.UTF8.GetBytes("I don't know how to handle this query type yet!").Length);
                        break;
                    }
                    }
                }
            } catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                byte[] err = Encoding.Default.GetBytes("Not a Pokemon!");
                ns.Write(err, 0, err.Length);
            } finally
            {
                ns.Flush();
                ns.Dispose();
                client.Dispose();
            }
        }
    }
Beispiel #22
0
        public void CreateSpecsWindow(GUIListBox parent, ScalableFont font, bool includeTitle = true, bool includeClass = true, bool includeDescription = false)
        {
            float  leftPanelWidth  = 0.6f;
            float  rightPanelWidth = 0.4f;
            string className       = !HasTag(SubmarineTag.Shuttle) ? TextManager.Get($"submarineclass.{SubmarineClass}") : TextManager.Get("shuttle");

            int classHeight       = (int)GUI.SubHeadingFont.MeasureString(className).Y;
            int leftPanelWidthInt = (int)(parent.Rect.Width * leftPanelWidth);

            GUITextBlock submarineNameText  = null;
            GUITextBlock submarineClassText = null;

            if (includeTitle)
            {
                int nameHeight = (int)GUI.LargeFont.MeasureString(DisplayName, true).Y;
                submarineNameText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, nameHeight + HUDLayoutSettings.Padding / 2), parent.Content.RectTransform), DisplayName, textAlignment: Alignment.CenterLeft, font: GUI.LargeFont)
                {
                    CanBeFocused = false
                };
                submarineNameText.RectTransform.MinSize = new Point(0, (int)submarineNameText.TextSize.Y);
            }
            if (includeClass)
            {
                submarineClassText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, classHeight), parent.Content.RectTransform), className, textAlignment: Alignment.CenterLeft, font: GUI.SubHeadingFont)
                {
                    CanBeFocused = false
                };
                submarineClassText.RectTransform.MinSize = new Point(0, (int)submarineClassText.TextSize.Y);
            }
            Vector2 realWorldDimensions = Dimensions * Physics.DisplayToRealWorldRatio;

            if (realWorldDimensions != Vector2.Zero)
            {
                string dimensionsStr = TextManager.GetWithVariables("DimensionsFormat", new string[2] {
                    "[width]", "[height]"
                }, new string[2] {
                    ((int)realWorldDimensions.X).ToString(), ((int)realWorldDimensions.Y).ToString()
                });
                var dimensionsText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                      TextManager.Get("Dimensions"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), dimensionsText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 dimensionsStr, textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                dimensionsText.RectTransform.MinSize = new Point(0, dimensionsText.Children.First().Rect.Height);
            }

            string cargoCapacityStr = CargoCapacity < 0 ? TextManager.Get("unknown") : TextManager.GetWithVariables("cargocapacityformat", new string[1] {
                "[cratecount]"
            }, new string[1] {
                CargoCapacity.ToString()
            });
            var cargoCapacityText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                     TextManager.Get("cargocapacity"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
            {
                CanBeFocused = false
            };

            new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), cargoCapacityText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                             cargoCapacityStr, textAlignment: Alignment.TopLeft, font: font, wrap: true)
            {
                CanBeFocused = false
            };
            cargoCapacityText.RectTransform.MinSize = new Point(0, cargoCapacityText.Children.First().Rect.Height);

            if (RecommendedCrewSizeMax > 0)
            {
                var crewSizeText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                    TextManager.Get("RecommendedCrewSize"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), crewSizeText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 RecommendedCrewSizeMin + " - " + RecommendedCrewSizeMax, textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                crewSizeText.RectTransform.MinSize = new Point(0, crewSizeText.Children.First().Rect.Height);
            }

            if (!string.IsNullOrEmpty(RecommendedCrewExperience))
            {
                var crewExperienceText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                          TextManager.Get("RecommendedCrewExperience"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), crewExperienceText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 TextManager.Get(RecommendedCrewExperience), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                crewExperienceText.RectTransform.MinSize = new Point(0, crewExperienceText.Children.First().Rect.Height);
            }

            if (RequiredContentPackages.Any())
            {
                var contentPackagesText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                           TextManager.Get("RequiredContentPackages"), textAlignment: Alignment.TopLeft, font: font)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), contentPackagesText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 string.Join(", ", RequiredContentPackages), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                contentPackagesText.RectTransform.MinSize = new Point(0, contentPackagesText.Children.First().Rect.Height);
            }

            // show what game version the submarine was created on
            if (!IsVanillaSubmarine() && GameVersion != null)
            {
                var versionText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                   TextManager.Get("serverlistversion"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), versionText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 GameVersion.ToString(), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };

                versionText.RectTransform.MinSize = new Point(0, versionText.Children.First().Rect.Height);
            }

            if (submarineNameText != null)
            {
                submarineNameText.AutoScaleHorizontal = true;
            }

            GUITextBlock descBlock = null;

            if (includeDescription)
            {
                //space
                new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), parent.Content.RectTransform), style: null);

                if (!string.IsNullOrEmpty(Description))
                {
                    var wsItemDesc = new GUITextBlock(new RectTransform(new Vector2(1, 0), parent.Content.RectTransform),
                                                      TextManager.Get("SaveSubDialogDescription", fallBackTag: "WorkshopItemDescription"), font: GUI.Font, wrap: true)
                    {
                        CanBeFocused = false, ForceUpperCase = true
                    };

                    descBlock = new GUITextBlock(new RectTransform(new Vector2(1, 0), parent.Content.RectTransform), Description, font: font, wrap: true)
                    {
                        CanBeFocused = false
                    };
                }
            }
            GUITextBlock.AutoScaleAndNormalize(parent.Content.GetAllChildren <GUITextBlock>().Where(c => c != submarineNameText && c != descBlock));
        }
        /// <summary>
        /// Create a new fake KSP instance
        /// </summary>
        /// <param name="game">The game of the new instance.</param>
        /// <param name="newName">The name for the new instance.</param>
        /// <param name="newPath">The location of the new instance.</param>
        /// <param name="version">The version of the new instance. Should have a build number.</param>
        /// <param name="dlcs">The IDlcDetector implementations for the DLCs that should be faked and the requested dlc version as a dictionary.</param>
        /// <exception cref="InstanceNameTakenKraken">Thrown if the instance name is already in use.</exception>
        /// <exception cref="NotKSPDirKraken">Thrown by AddInstance() if created instance is not valid, e.g. if a write operation didn't complete for whatever reason.</exception>
        public void FakeInstance(IGame game, string newName, string newPath, GameVersion version, Dictionary <DLC.IDlcDetector, GameVersion> dlcs = null)
        {
            TxFileManager fileMgr = new TxFileManager();

            using (TransactionScope transaction = CkanTransaction.CreateTransactionScope())
            {
                if (HasInstance(newName))
                {
                    throw new InstanceNameTakenKraken(newName);
                }


                if (!version.InBuildMap(game))
                {
                    throw new BadGameVersionKraken(String.Format("The specified KSP version is not a known version: {0}", version.ToString()));
                }
                if (Directory.Exists(newPath) && (Directory.GetFiles(newPath).Length != 0 || Directory.GetDirectories(newPath).Length != 0))
                {
                    throw new BadInstallLocationKraken("The specified folder already exists and is not empty.");
                }

                log.DebugFormat("Creating folder structure and text files at {0} for KSP version {1}", Path.GetFullPath(newPath), version.ToString());

                // Create a KSP root directory, containing a GameData folder, a buildID.txt/buildID64.txt and a readme.txt
                fileMgr.CreateDirectory(newPath);
                fileMgr.CreateDirectory(Path.Combine(newPath, "GameData"));
                fileMgr.CreateDirectory(Path.Combine(newPath, "Ships"));
                fileMgr.CreateDirectory(Path.Combine(newPath, "Ships", "VAB"));
                fileMgr.CreateDirectory(Path.Combine(newPath, "Ships", "SPH"));
                fileMgr.CreateDirectory(Path.Combine(newPath, "Ships", "@thumbs"));
                fileMgr.CreateDirectory(Path.Combine(newPath, "Ships", "@thumbs", "VAB"));
                fileMgr.CreateDirectory(Path.Combine(newPath, "Ships", "@thumbs", "SPH"));
                fileMgr.CreateDirectory(Path.Combine(newPath, "saves"));
                fileMgr.CreateDirectory(Path.Combine(newPath, "saves", "scenarios"));
                fileMgr.CreateDirectory(Path.Combine(newPath, "saves", "training"));

                // Don't write the buildID.txts if we have no build, otherwise it would be -1.
                if (version.IsBuildDefined)
                {
                    fileMgr.WriteAllText(Path.Combine(newPath, "buildID.txt"), String.Format("build id = {0}", version.Build));
                    fileMgr.WriteAllText(Path.Combine(newPath, "buildID64.txt"), String.Format("build id = {0}", version.Build));
                }

                // Create the readme.txt WITHOUT build number.
                fileMgr.WriteAllText(Path.Combine(newPath, "readme.txt"), String.Format("Version {0}", new GameVersion(version.Major, version.Minor, version.Patch).ToString()));

                // Create the needed folder structure and the readme.txt for DLCs that should be simulated.
                if (dlcs != null)
                {
                    foreach (KeyValuePair <DLC.IDlcDetector, GameVersion> dlc in dlcs)
                    {
                        DLC.IDlcDetector dlcDetector = dlc.Key;
                        GameVersion      dlcVersion  = dlc.Value;

                        if (!dlcDetector.AllowedOnBaseVersion(version))
                        {
                            throw new WrongGameVersionKraken(
                                      version,
                                      String.Format("KSP version {0} or above is needed for {1} DLC.",
                                                    dlcDetector.ReleaseGameVersion,
                                                    dlcDetector.IdentifierBaseName
                                                    ));
                        }

                        string dlcDir = Path.Combine(newPath, dlcDetector.InstallPath());
                        fileMgr.CreateDirectory(dlcDir);
                        fileMgr.WriteAllText(
                            Path.Combine(dlcDir, "readme.txt"),
                            String.Format("Version {0}", dlcVersion));
                    }
                }

                // Add the new instance to the config
                GameInstance new_instance = new GameInstance(game, newPath, newName, User, false);
                AddInstance(new_instance);
                transaction.Complete();
            }
        }
Beispiel #24
0
        public void CreatePreviewWindow(GUIComponent parent)
        {
            var content = new GUIFrame(new RectTransform(Vector2.One, parent.RectTransform), style: null);

            if (PreviewImage == null)
            {
                new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), content.RectTransform), TextManager.Get(SavedSubmarines.Contains(this) ? "SubPreviewImageNotFound" : "SubNotDownloaded"));
            }
            else
            {
                var submarinePreviewBackground = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.5f), content.RectTransform), style: null)
                {
                    Color = Color.Black
                };
                new GUIImage(new RectTransform(new Vector2(0.98f), submarinePreviewBackground.RectTransform, Anchor.Center), PreviewImage, scaleToFit: true);
                new GUIFrame(new RectTransform(Vector2.One, submarinePreviewBackground.RectTransform), "InnerGlow", color: Color.Black);
            }
            var descriptionBox = new GUIListBox(new RectTransform(new Vector2(1, 0.5f), content.RectTransform, Anchor.BottomCenter))
            {
                UserData         = "descriptionbox",
                ScrollBarVisible = true,
                Spacing          = 5
            };

            //space
            new GUIFrame(new RectTransform(new Vector2(1.0f, 0.03f), descriptionBox.Content.RectTransform), style: null);

            new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), TextManager.Get("submarine.name." + Name, true) ?? Name, font: GUI.LargeFont, wrap: true)
            {
                ForceUpperCase = true, CanBeFocused = false
            };

            float leftPanelWidth  = 0.6f;
            float rightPanelWidth = 0.4f / leftPanelWidth;

            ScalableFont font = descriptionBox.Rect.Width < 350 ? GUI.SmallFont : GUI.Font;

            Vector2 realWorldDimensions = Dimensions * Physics.DisplayToRealWorldRatio;

            if (realWorldDimensions != Vector2.Zero)
            {
                string dimensionsStr = TextManager.GetWithVariables("DimensionsFormat", new string[2] {
                    "[width]", "[height]"
                }, new string[2] {
                    ((int)realWorldDimensions.X).ToString(), ((int)realWorldDimensions.Y).ToString()
                });

                var dimensionsText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), descriptionBox.Content.RectTransform),
                                                      TextManager.Get("Dimensions"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), dimensionsText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 dimensionsStr, textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                dimensionsText.RectTransform.MinSize = new Point(0, dimensionsText.Children.First().Rect.Height);
            }

            if (RecommendedCrewSizeMax > 0)
            {
                var crewSizeText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), descriptionBox.Content.RectTransform),
                                                    TextManager.Get("RecommendedCrewSize"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), crewSizeText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 RecommendedCrewSizeMin + " - " + RecommendedCrewSizeMax, textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                crewSizeText.RectTransform.MinSize = new Point(0, crewSizeText.Children.First().Rect.Height);
            }

            if (!string.IsNullOrEmpty(RecommendedCrewExperience))
            {
                var crewExperienceText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), descriptionBox.Content.RectTransform),
                                                          TextManager.Get("RecommendedCrewExperience"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), crewExperienceText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 TextManager.Get(RecommendedCrewExperience), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                crewExperienceText.RectTransform.MinSize = new Point(0, crewExperienceText.Children.First().Rect.Height);
            }

            if (RequiredContentPackages.Any())
            {
                var contentPackagesText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), descriptionBox.Content.RectTransform),
                                                           TextManager.Get("RequiredContentPackages"), textAlignment: Alignment.TopLeft, font: font)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), contentPackagesText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 string.Join(", ", RequiredContentPackages), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                contentPackagesText.RectTransform.MinSize = new Point(0, contentPackagesText.Children.First().Rect.Height);
            }

            // show what game version the submarine was created on
            if (!IsVanillaSubmarine() && GameVersion != null)
            {
                var versionText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), descriptionBox.Content.RectTransform),
                                                   TextManager.Get("serverlistversion"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), versionText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 GameVersion.ToString(), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };

                versionText.RectTransform.MinSize = new Point(0, versionText.Children.First().Rect.Height);
            }

            GUITextBlock.AutoScaleAndNormalize(descriptionBox.Content.Children.Where(c => c is GUITextBlock).Cast <GUITextBlock>());

            //space
            new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), descriptionBox.Content.RectTransform), style: null);

            if (!string.IsNullOrEmpty(Description))
            {
                new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform),
                                 TextManager.Get("SaveSubDialogDescription", fallBackTag: "WorkshopItemDescription"), font: GUI.Font, wrap: true)
                {
                    CanBeFocused = false, ForceUpperCase = true
                };
            }

            new GUITextBlock(new RectTransform(new Vector2(1, 0), descriptionBox.Content.RectTransform), Description, font: font, wrap: true)
            {
                CanBeFocused = false
            };
        }
 public static string GetUrl( WebsiteSection section, GameVersion version, bool phpLink, int? id = null, int? category = null, int? icon = null, string extra = null )
 {
     if ( phpLink ) {
         string v = GetPhpUrlGameVersion( version );
         switch ( section ) {
             case WebsiteSection.Enemy: return "?version=" + v + "&section=enemies&category=" + category + ( id != null ? "#enemy" + id : "" );
             case WebsiteSection.Item: return "?version=" + v + "&section=items&icon=" + icon + ( id != null ? "#item" + id : "" );
             case WebsiteSection.Recipe: return "?version=" + v + "&section=recipes" + ( id != null ? "#recipe" + id : "" );
             case WebsiteSection.Skill: return "?version=" + v + "&section=skills" + ( id != null ? "#skill" + id : "" );
             case WebsiteSection.Location: return "?version=" + v + "&section=locations" + ( id != null ? "#location" + id : "" );
             case WebsiteSection.Shop: return "?version=" + v + "&section=shops" + ( id != null ? "#shop" + id : "" );
             case WebsiteSection.Skit: return "?version=" + v + "&section=skit" + ( extra != null ? "&name=" + extra : "" );
             case WebsiteSection.Scenario: return "?version=" + v + "&section=scenario" + ( extra != null ? "&name=" + extra : "" );
             default: throw new Exception( "Unsupported PHP URL requested." );
         }
     } else {
         StringBuilder sb = new StringBuilder();
         sb.Append( version.ToString() );
         sb.Append( "-" );
         sb.Append( section.ToString() );
         if ( category != null ) {
             sb.Append( "-c" );
             sb.Append( category );
         }
         if ( icon != null ) {
             sb.Append( "-i" );
             sb.Append( icon );
         }
         if ( extra != null ) {
             sb.Append( "-" );
             sb.Append( extra );
         }
         sb.Append( ".html" );
         if ( id != null ) {
             sb.Append( "#" );
             sb.Append( section.ToString().ToLowerInvariant() );
             sb.Append( id );
         }
         return sb.ToString();
     }
 }
Beispiel #26
0
        public void Save(string filePath)
        {
            XDocument doc = new XDocument();

            doc.Add(new XElement("contentpackage",
                                 new XAttribute("name", Name),
                                 new XAttribute("path", Path.CleanUpPathCrossPlatform(correctFilenameCase: false)),
                                 new XAttribute("corepackage", CorePackage)));

            doc.Root.Add(new XAttribute("gameversion", GameVersion.ToString()));

            if (!string.IsNullOrEmpty(SteamWorkshopUrl))
            {
                doc.Root.Add(new XAttribute("steamworkshopurl", SteamWorkshopUrl));
            }

            if (InstallTime != null)
            {
                doc.Root.Add(new XAttribute("installtime", ToolBox.Epoch.FromDateTime(InstallTime.Value)));
            }

            foreach (ContentFile file in Files)
            {
                doc.Root.Add(new XElement(file.Type.ToString(), new XAttribute("file", file.Path.CleanUpPathCrossPlatform())));
            }

            doc.SaveSafe(filePath);

            var  packagesToDeselect = List.Where(p => p.Path.CleanUpPath() == Path.CleanUpPath()).ToList();
            bool reselectPackage    = false;

            if (packagesToDeselect.Any())
            {
                foreach (var p in packagesToDeselect)
                {
                    if (GameMain.Config.SelectedContentPackages.Contains(p))
                    {
                        reselectPackage = true;
                        if (p.CorePackage)
                        {
                            GameMain.Config.AutoSelectCorePackage(packagesToDeselect);
                        }
                        else
                        {
                            GameMain.Config.DeselectContentPackage(p);
                        }
                    }
                    List.Remove(p);
                }
                List.Add(this);
                if (reselectPackage)
                {
                    if (CorePackage)
                    {
                        GameMain.Config.SelectCorePackage(this);
                    }
                    else
                    {
                        GameMain.Config.SelectContentPackage(this);
                    }
                }
            }
        }
        public static StringBuilder ReplaceIconsWithHtml(StringBuilder sb, Dictionary <uint, TSS.TSSEntry> inGameIdDict, GameVersion Version, bool japaneseStyle)
        {
            sb.Replace("\x06(ST1)", "<img src=\"text-icons/icon-status-01.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(ST2)", "<img src=\"text-icons/icon-status-02.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(ST3)", "<img src=\"text-icons/icon-status-03.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(ST4)", "<img src=\"text-icons/icon-status-04.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(ST5)", "<img src=\"text-icons/icon-status-05.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(ST6)", "<img src=\"text-icons/icon-status-06.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(ST7)", "<img src=\"text-icons/icon-status-07.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(SC1)", "<img src=\"text-icons/icon-status-08.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(SC2)", "<img src=\"text-icons/icon-status-09.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(SC3)", "<img src=\"text-icons/icon-status-10.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(SC4)", "<img src=\"text-icons/icon-status-11.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(SC5)", "<img src=\"text-icons/icon-status-17.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(SC6)", "<img src=\"text-icons/icon-status-13.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(SC7)", "<img src=\"text-icons/icon-status-18.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(EL1)", "<img src=\"text-icons/icon-element-02.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(EL2)", "<img src=\"text-icons/icon-element-04.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(EL3)", "<img src=\"text-icons/icon-element-01.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(EL4)", "<img src=\"text-icons/icon-element-05.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(EL5)", "<img src=\"text-icons/icon-element-03.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(EL6)", "<img src=\"text-icons/icon-element-06.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(EL7)", "<img src=\"text-icons/icon-element-07.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(FS1)", "<img src=\"text-icons/icon-fs-01.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(FS2)", "<img src=\"text-icons/icon-fs-02.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(FS3)", "<img src=\"text-icons/icon-fs-03.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(MC1)", "<img src=\"text-icons/icon-monster-01.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(MC2)", "<img src=\"text-icons/icon-monster-02.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(MC3)", "<img src=\"text-icons/icon-monster-03.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(MC4)", "<img src=\"text-icons/icon-monster-04.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(MC5)", "<img src=\"text-icons/icon-monster-05.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(MC6)", "<img src=\"text-icons/icon-monster-06.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(MC7)", "<img src=\"text-icons/icon-monster-07.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(MC8)", "<img src=\"text-icons/icon-monster-08.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(MC9)", "<img src=\"text-icons/icon-monster-09.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(COS)", "<img src=\"text-icons/icon-costume.png\" height=\"16\" width=\"16\">");
            sb.Replace("\x06(STA)", "<img src=\"text-icons/" + Version.ToString() + "/button-Start.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.Start) + "\">");
            sb.Replace("\x06(SEL)", "<img src=\"text-icons/" + Version.ToString() + "/button-Select.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.Select) + "\">");
            sb.Replace("\x06(L3)", "<img src=\"text-icons/" + Version.ToString() + "/ls-push.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.L3) + "\">");
            sb.Replace("\x06(R3)", "<img src=\"text-icons/" + Version.ToString() + "/rs-push.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.R3) + "\">");
            sb.Replace("\x06(MVN)", "<img src=\"text-icons/" + Version.ToString() + "/ls.png\" height=\"16\" title=\"Character Movement\">");
            sb.Replace("\x06(MVR)", "<img src=\"text-icons/" + Version.ToString() + "/ls-right.png\" height=\"16\" title=\"Character Movement Right\">");
            sb.Replace("\x06(MVL)", "<img src=\"text-icons/" + Version.ToString() + "/ls-left.png\" height=\"16\" title=\"Character Movement Left\">");
            sb.Replace("\x06(MVU)", "<img src=\"text-icons/" + Version.ToString() + "/ls-up.png\" height=\"16\" title=\"Character Movement Up\">");
            sb.Replace("\x06(MVD)", "<img src=\"text-icons/" + Version.ToString() + "/ls-down.png\" height=\"16\" title=\"Character Movement Down\">");
            sb.Replace("\x06(MVH)", "<img src=\"text-icons/" + Version.ToString() + "/ls-side.png\" height=\"16\" title=\"Character Movement Side\">");
            sb.Replace("\x06(LTN)", "<img src=\"text-icons/" + Version.ToString() + "/ls.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.LeftStick) + "\">");
            sb.Replace("\x06(LTR)", "<img src=\"text-icons/" + Version.ToString() + "/ls-right.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.LeftStick) + " Right\">");
            sb.Replace("\x06(LTL)", "<img src=\"text-icons/" + Version.ToString() + "/ls-left.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.LeftStick) + " Left\">");
            sb.Replace("\x06(LTU)", "<img src=\"text-icons/" + Version.ToString() + "/ls-up.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.LeftStick) + " Up\">");
            sb.Replace("\x06(LTD)", "<img src=\"text-icons/" + Version.ToString() + "/ls-down.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.LeftStick) + " Down\">");
            sb.Replace("\x06(LTH)", "<img src=\"text-icons/" + Version.ToString() + "/ls-side.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.LeftStick) + " Side\">");
            sb.Replace("\x06(RTN)", "<img src=\"text-icons/" + Version.ToString() + "/rs.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.RightStick) + "\">");
            sb.Replace("\x06(RTR)", "<img src=\"text-icons/" + Version.ToString() + "/rs-right.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.RightStick) + " Right\">");
            sb.Replace("\x06(RTL)", "<img src=\"text-icons/" + Version.ToString() + "/rs-left.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.RightStick) + " Left\">");
            sb.Replace("\x06(RTU)", "<img src=\"text-icons/" + Version.ToString() + "/rs-up.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.RightStick) + " Up\">");
            sb.Replace("\x06(RTD)", "<img src=\"text-icons/" + Version.ToString() + "/rs-down.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.RightStick) + " Down\">");
            sb.Replace("\x06(RTH)", "<img src=\"text-icons/" + Version.ToString() + "/rs-side.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.RightStick) + " Side\">");
            sb.Replace("\x06(LBN)", "<img src=\"text-icons/" + Version.ToString() + "/dpad.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.DPad) + "\">");
            sb.Replace("\x06(LBR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-right.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.DPad) + " Right\">");
            sb.Replace("\x06(LBL)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-left.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.DPad) + " Left\">");
            sb.Replace("\x06(LBU)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-up.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.DPad) + " Up\">");
            sb.Replace("\x06(LBD)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-down.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.DPad) + " Down\">");
            sb.Replace("\x06(LBH)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-side.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.DPad) + " Side\">");
            sb.Replace("\x06(MVNR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad.png\" height=\"16\" title=\"Non-Character Movement\">");
            sb.Replace("\x06(MVRR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-right.png\" height=\"16\" title=\"Non-Character Movement Right\">");
            sb.Replace("\x06(MVLR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-left.png\" height=\"16\" title=\"Non-Character Movement Left\">");
            sb.Replace("\x06(MVUR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-up.png\" height=\"16\" title=\"Non-Character Movement Up\">");
            sb.Replace("\x06(MVDR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-down.png\" height=\"16\" title=\"Non-Character Movement Down\">");
            sb.Replace("\x06(MVHR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-side.png\" height=\"16\" title=\"Non-Character Movement Side\">");
            sb.Replace("\x06(RBL)", "<img src=\"text-icons/" + Version.ToString() + "/button-action.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.LeftButton) + "\">");
            sb.Replace("\x06(RBU)", "<img src=\"text-icons/" + Version.ToString() + "/button-menu.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.UpperButton) + "\">");
            sb.Replace("\x06(RBR)", "<img src=\"text-icons/" + Version.ToString() + "/button-cancel.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.RightButton) + "\">");
            sb.Replace("\x06(RBD)", "<img src=\"text-icons/" + Version.ToString() + "/button-confirm.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.LowerButton) + "\">");

            if (japaneseStyle && Version.SwapsConfirmAndCancelDependingOnRegion())
            {
                // in JP PS3 version, swap circle/cross for confirm/cancel
                sb.Replace("\x06(CCL)", "<img src=\"text-icons/" + Version.ToString() + "/button-confirm.png\" height=\"16\" title=\"Cancel\">");
                sb.Replace("\x06(ETR)", "<img src=\"text-icons/" + Version.ToString() + "/button-cancel.png\" height=\"16\" title=\"Confirm\">");
            }
            else
            {
                sb.Replace("\x06(CCL)", "<img src=\"text-icons/" + Version.ToString() + "/button-cancel.png\" height=\"16\" title=\"Cancel\">");
                sb.Replace("\x06(ETR)", "<img src=\"text-icons/" + Version.ToString() + "/button-confirm.png\" height=\"16\" title=\"Confirm\">");
            }

            sb.Replace("\x06(ATK)", "<img src=\"text-icons/" + Version.ToString() + "/button-cancel.png\" height=\"16\" title=\"Attack\">");
            sb.Replace("\x06(ART)", "<img src=\"text-icons/" + Version.ToString() + "/button-confirm.png\" height=\"16\" title=\"Arte\">");
            sb.Replace("\x06(GUD)", "<img src=\"text-icons/" + Version.ToString() + "/button-action.png\" height=\"16\" title=\"Guard\">");
            sb.Replace("\x06(MEN)", "<img src=\"text-icons/" + Version.ToString() + "/button-menu.png\" height=\"16\" title=\"Menu\">");
            sb.Replace("\x06(CBR1)", "<img src=\"text-icons/" + Version.ToString() + "/button-R1.png\" height=\"16\" title=\"Enemy Target Switch\">");
            sb.Replace("\x06(CBR2)", "<img src=\"text-icons/" + Version.ToString() + "/button-R2.png\" height=\"16\" title=\"Fatal Strike\">");
            sb.Replace("\x06(CBL1)", "<img src=\"text-icons/" + Version.ToString() + "/button-L1.png\" height=\"16\" title=\"Alternate Attack\">");
            sb.Replace("\x06(CBL2)", "<img src=\"text-icons/" + Version.ToString() + "/button-L2.png\" height=\"16\" title=\"Free Run\">");
            sb.Replace("\x06(R1)", "<img src=\"text-icons/" + Version.ToString() + "/button-R1.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.R1) + "\">");
            sb.Replace("\x06(R2)", "<img src=\"text-icons/" + Version.ToString() + "/button-R2.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.R2) + "\">");
            sb.Replace("\x06(L1)", "<img src=\"text-icons/" + Version.ToString() + "/button-L1.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.L1) + "\">");
            sb.Replace("\x06(L2)", "<img src=\"text-icons/" + Version.ToString() + "/button-L2.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName(Version, ControllerButton.L2) + "\">");
            sb.Replace('∀', '♥');
            sb.Replace('‡', 'é');
            sb.Replace('†', 'í');
            return(sb);
        }
        public static string GetUrl(WebsiteSection section, GameVersion version, string versionPostfix, GameLocale locale, WebsiteLanguage websiteLanguage, bool phpLink, int?id = null, int?category = null, int?icon = null, string extra = null)
        {
            if (phpLink)
            {
                string v     = GetPhpUrlGameVersion(version);
                string l     = GetPhpUrlGameLocale(locale);
                string w     = GetPhpUrlWebsiteLanguage(websiteLanguage);
                string begin = "?version=" + v + versionPostfix + "&locale=" + l + "&compare=" + w;
                switch (section)
                {
                case WebsiteSection.Arte: return(begin + "&section=artes" + (id != null ? "&id=" + id : ""));

                case WebsiteSection.Enemy: return(begin + "&section=enemies&category=" + category + (id != null ? "&id=" + id : ""));

                case WebsiteSection.Item: return(begin + "&section=items&icon=" + icon + (id != null ? "&id=" + id : ""));

                case WebsiteSection.Recipe: return(begin + "&section=recipes" + (id != null ? "&id=" + id : ""));

                case WebsiteSection.Skill: return(begin + "&section=skills" + (id != null ? "&id=" + id : ""));

                case WebsiteSection.Location: return(begin + "&section=locations" + (id != null ? "&id=" + id : ""));

                case WebsiteSection.Shop: return(begin + "&section=shops" + (id != null ? "&id=" + id : ""));

                case WebsiteSection.SearchPoint: return(begin + "&section=searchpoint" + (id != null ? "#searchpoint" + id : ""));

                case WebsiteSection.Skit: return(begin + "&section=skit" + (extra != null ? "&name=" + extra : ""));

                case WebsiteSection.Scenario: return(begin + "&section=scenario" + (extra != null ? "&name=" + extra : ""));

                case WebsiteSection.NecropolisMap: return(begin + "&section=necropolis" + (extra != null ? "&map=" + extra : ""));

                default: throw new Exception("Unsupported PHP URL requested.");
                }
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(version.ToString());
                sb.Append("-");
                sb.Append(section.ToString());
                if (category != null)
                {
                    sb.Append("-c");
                    sb.Append(category);
                }
                if (icon != null)
                {
                    sb.Append("-i");
                    sb.Append(icon);
                }
                if (extra != null)
                {
                    sb.Append("-");
                    sb.Append(extra);
                }
                sb.Append(".html");
                if (id != null)
                {
                    sb.Append("#");
                    sb.Append(section.ToString().ToLowerInvariant());
                    sb.Append(id);
                }
                return(sb.ToString());
            }
        }
        public static StringBuilder ReplaceIconsWithHtml( StringBuilder sb, GameVersion Version, bool japaneseStyle )
        {
            sb.Replace( "\x06(ST1)", "<img src=\"text-icons/icon-status-01.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(ST2)", "<img src=\"text-icons/icon-status-02.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(ST3)", "<img src=\"text-icons/icon-status-03.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(ST4)", "<img src=\"text-icons/icon-status-04.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(ST5)", "<img src=\"text-icons/icon-status-05.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(ST6)", "<img src=\"text-icons/icon-status-06.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(ST7)", "<img src=\"text-icons/icon-status-07.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(SC1)", "<img src=\"text-icons/icon-status-08.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(SC2)", "<img src=\"text-icons/icon-status-09.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(SC3)", "<img src=\"text-icons/icon-status-10.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(SC4)", "<img src=\"text-icons/icon-status-11.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(SC5)", "<img src=\"text-icons/icon-status-17.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(SC6)", "<img src=\"text-icons/icon-status-13.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(SC7)", "<img src=\"text-icons/icon-status-18.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(EL1)", "<img src=\"text-icons/icon-element-02.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(EL2)", "<img src=\"text-icons/icon-element-04.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(EL3)", "<img src=\"text-icons/icon-element-01.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(EL4)", "<img src=\"text-icons/icon-element-05.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(EL5)", "<img src=\"text-icons/icon-element-03.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(EL6)", "<img src=\"text-icons/icon-element-06.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(EL7)", "<img src=\"text-icons/icon-element-07.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(FS1)", "<img src=\"text-icons/icon-fs-01.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(FS2)", "<img src=\"text-icons/icon-fs-02.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(FS3)", "<img src=\"text-icons/icon-fs-03.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(MC1)", "<img src=\"text-icons/icon-monster-01.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(MC2)", "<img src=\"text-icons/icon-monster-02.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(MC3)", "<img src=\"text-icons/icon-monster-03.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(MC4)", "<img src=\"text-icons/icon-monster-04.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(MC5)", "<img src=\"text-icons/icon-monster-05.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(MC6)", "<img src=\"text-icons/icon-monster-06.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(MC7)", "<img src=\"text-icons/icon-monster-07.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(MC8)", "<img src=\"text-icons/icon-monster-08.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(MC9)", "<img src=\"text-icons/icon-monster-09.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(COS)", "<img src=\"text-icons/icon-costume.png\" height=\"16\" width=\"16\">" );
            sb.Replace( "\x06(STA)", "<img src=\"text-icons/" + Version.ToString() + "/button-Start.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.Start ) + "\">" );
            sb.Replace( "\x06(SEL)", "<img src=\"text-icons/" + Version.ToString() + "/button-Select.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.Select ) + "\">" );
            sb.Replace( "\x06(L3)", "<img src=\"text-icons/" + Version.ToString() + "/ls-push.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.L3 ) + "\">" );
            sb.Replace( "\x06(R3)", "<img src=\"text-icons/" + Version.ToString() + "/rs-push.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.R3 ) + "\">" );
            sb.Replace( "\x06(MVN)", "<img src=\"text-icons/" + Version.ToString() + "/ls.png\" height=\"16\" title=\"Character Movement\">" );
            sb.Replace( "\x06(MVR)", "<img src=\"text-icons/" + Version.ToString() + "/ls-right.png\" height=\"16\" title=\"Character Movement Right\">" );
            sb.Replace( "\x06(MVL)", "<img src=\"text-icons/" + Version.ToString() + "/ls-left.png\" height=\"16\" title=\"Character Movement Left\">" );
            sb.Replace( "\x06(MVU)", "<img src=\"text-icons/" + Version.ToString() + "/ls-up.png\" height=\"16\" title=\"Character Movement Up\">" );
            sb.Replace( "\x06(MVD)", "<img src=\"text-icons/" + Version.ToString() + "/ls-down.png\" height=\"16\" title=\"Character Movement Down\">" );
            sb.Replace( "\x06(MVH)", "<img src=\"text-icons/" + Version.ToString() + "/ls-side.png\" height=\"16\" title=\"Character Movement Side\">" );
            sb.Replace( "\x06(LTN)", "<img src=\"text-icons/" + Version.ToString() + "/ls.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.LeftStick ) + "\">" );
            sb.Replace( "\x06(LTR)", "<img src=\"text-icons/" + Version.ToString() + "/ls-right.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.LeftStick ) + " Right\">" );
            sb.Replace( "\x06(LTL)", "<img src=\"text-icons/" + Version.ToString() + "/ls-left.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.LeftStick ) + " Left\">" );
            sb.Replace( "\x06(LTU)", "<img src=\"text-icons/" + Version.ToString() + "/ls-up.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.LeftStick ) + " Up\">" );
            sb.Replace( "\x06(LTD)", "<img src=\"text-icons/" + Version.ToString() + "/ls-down.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.LeftStick ) + " Down\">" );
            sb.Replace( "\x06(LTH)", "<img src=\"text-icons/" + Version.ToString() + "/ls-side.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.LeftStick ) + " Side\">" );
            sb.Replace( "\x06(RTN)", "<img src=\"text-icons/" + Version.ToString() + "/rs.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.RightStick ) + "\">" );
            sb.Replace( "\x06(RTR)", "<img src=\"text-icons/" + Version.ToString() + "/rs-right.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.RightStick ) + " Right\">" );
            sb.Replace( "\x06(RTL)", "<img src=\"text-icons/" + Version.ToString() + "/rs-left.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.RightStick ) + " Left\">" );
            sb.Replace( "\x06(RTU)", "<img src=\"text-icons/" + Version.ToString() + "/rs-up.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.RightStick ) + " Up\">" );
            sb.Replace( "\x06(RTD)", "<img src=\"text-icons/" + Version.ToString() + "/rs-down.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.RightStick ) + " Down\">" );
            sb.Replace( "\x06(RTH)", "<img src=\"text-icons/" + Version.ToString() + "/rs-side.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.RightStick ) + " Side\">" );
            sb.Replace( "\x06(LBN)", "<img src=\"text-icons/" + Version.ToString() + "/dpad.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.DPad ) + "\">" );
            sb.Replace( "\x06(LBR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-right.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.DPad ) + " Right\">" );
            sb.Replace( "\x06(LBL)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-left.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.DPad ) + " Left\">" );
            sb.Replace( "\x06(LBU)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-up.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.DPad ) + " Up\">" );
            sb.Replace( "\x06(LBD)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-down.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.DPad ) + " Down\">" );
            sb.Replace( "\x06(LBH)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-side.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.DPad ) + " Side\">" );
            sb.Replace( "\x06(MVNR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad.png\" height=\"16\" title=\"Non-Character Movement\">" );
            sb.Replace( "\x06(MVRR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-right.png\" height=\"16\" title=\"Non-Character Movement Right\">" );
            sb.Replace( "\x06(MVLR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-left.png\" height=\"16\" title=\"Non-Character Movement Left\">" );
            sb.Replace( "\x06(MVUR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-up.png\" height=\"16\" title=\"Non-Character Movement Up\">" );
            sb.Replace( "\x06(MVDR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-down.png\" height=\"16\" title=\"Non-Character Movement Down\">" );
            sb.Replace( "\x06(MVHR)", "<img src=\"text-icons/" + Version.ToString() + "/dpad-side.png\" height=\"16\" title=\"Non-Character Movement Side\">" );
            sb.Replace( "\x06(RBL)", "<img src=\"text-icons/" + Version.ToString() + "/button-action.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.LeftButton ) + "\">" );
            sb.Replace( "\x06(RBU)", "<img src=\"text-icons/" + Version.ToString() + "/button-menu.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.UpperButton ) + "\">" );
            sb.Replace( "\x06(RBR)", "<img src=\"text-icons/" + Version.ToString() + "/button-cancel.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.RightButton ) + "\">" );
            sb.Replace( "\x06(RBD)", "<img src=\"text-icons/" + Version.ToString() + "/button-confirm.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.LowerButton ) + "\">" );

            if ( japaneseStyle && Version == GameVersion.PS3 ) {
                // in JP PS3 version, swap circle/cross for confirm/cancel
                sb.Replace( "\x06(CCL)", "<img src=\"text-icons/" + Version.ToString() + "/button-confirm.png\" height=\"16\" title=\"Cancel\">" );
                sb.Replace( "\x06(ETR)", "<img src=\"text-icons/" + Version.ToString() + "/button-cancel.png\" height=\"16\" title=\"Confirm\">" );
            } else {
                sb.Replace( "\x06(CCL)", "<img src=\"text-icons/" + Version.ToString() + "/button-cancel.png\" height=\"16\" title=\"Cancel\">" );
                sb.Replace( "\x06(ETR)", "<img src=\"text-icons/" + Version.ToString() + "/button-confirm.png\" height=\"16\" title=\"Confirm\">" );
            }

            sb.Replace( "\x06(ATK)", "<img src=\"text-icons/" + Version.ToString() + "/button-cancel.png\" height=\"16\" title=\"Attack\">" );
            sb.Replace( "\x06(ART)", "<img src=\"text-icons/" + Version.ToString() + "/button-confirm.png\" height=\"16\" title=\"Arte\">" );
            sb.Replace( "\x06(GUD)", "<img src=\"text-icons/" + Version.ToString() + "/button-action.png\" height=\"16\" title=\"Guard\">" );
            sb.Replace( "\x06(MEN)", "<img src=\"text-icons/" + Version.ToString() + "/button-menu.png\" height=\"16\" title=\"Menu\">" );
            sb.Replace( "\x06(CBR1)", "<img src=\"text-icons/" + Version.ToString() + "/button-R1.png\" height=\"16\" title=\"Enemy Target Switch\">" );
            sb.Replace( "\x06(CBR2)", "<img src=\"text-icons/" + Version.ToString() + "/button-R2.png\" height=\"16\" title=\"Fatal Strike\">" );
            sb.Replace( "\x06(CBL1)", "<img src=\"text-icons/" + Version.ToString() + "/button-L1.png\" height=\"16\" title=\"Alternate Attack\">" );
            sb.Replace( "\x06(CBL2)", "<img src=\"text-icons/" + Version.ToString() + "/button-L2.png\" height=\"16\" title=\"Free Run\">" );
            sb.Replace( "\x06(R1)", "<img src=\"text-icons/" + Version.ToString() + "/button-R1.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.R1 ) + "\">" );
            sb.Replace( "\x06(R2)", "<img src=\"text-icons/" + Version.ToString() + "/button-R2.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.R2 ) + "\">" );
            sb.Replace( "\x06(L1)", "<img src=\"text-icons/" + Version.ToString() + "/button-L1.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.L1 ) + "\">" );
            sb.Replace( "\x06(L2)", "<img src=\"text-icons/" + Version.ToString() + "/button-L2.png\" height=\"16\" title=\"" + VesperiaUtil.GetButtonName( Version, ControllerButton.L2 ) + "\">" );
            sb.Replace( '∀', '♥' );
            sb.Replace( '‡', 'é' );
            sb.Replace( '†', 'í' );
            return sb;
        }
Beispiel #30
0
        public void CreateSpecsWindow(GUIListBox parent, ScalableFont font)
        {
            float  leftPanelWidth  = 0.6f;
            float  rightPanelWidth = 0.4f / leftPanelWidth;
            string className       = !HasTag(SubmarineTag.Shuttle) ? TextManager.Get($"submarineclass.{SubmarineClass}") : TextManager.Get("shuttle");

            int nameHeight        = (int)GUI.LargeFont.MeasureString(DisplayName, true).Y;
            int classHeight       = (int)GUI.SubHeadingFont.MeasureString(className).Y;
            int leftPanelWidthInt = (int)(parent.Rect.Width * leftPanelWidth);

            var submarineNameText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, nameHeight + HUDLayoutSettings.Padding / 2), parent.Content.RectTransform), DisplayName, textAlignment: Alignment.CenterLeft, font: GUI.LargeFont)
            {
                CanBeFocused = false
            };

            submarineNameText.RectTransform.MinSize = new Point(0, (int)submarineNameText.TextSize.Y);
            var submarineClassText = new GUITextBlock(new RectTransform(new Point(leftPanelWidthInt, classHeight), parent.Content.RectTransform), className, textAlignment: Alignment.CenterLeft, font: GUI.SubHeadingFont)
            {
                CanBeFocused = false
            };

            submarineClassText.RectTransform.MinSize = new Point(0, (int)submarineClassText.TextSize.Y);

            Vector2 realWorldDimensions = Dimensions * Physics.DisplayToRealWorldRatio;

            if (realWorldDimensions != Vector2.Zero)
            {
                string dimensionsStr = TextManager.GetWithVariables("DimensionsFormat", new string[2] {
                    "[width]", "[height]"
                }, new string[2] {
                    ((int)realWorldDimensions.X).ToString(), ((int)realWorldDimensions.Y).ToString()
                });

                var dimensionsText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                      TextManager.Get("Dimensions"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), dimensionsText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 dimensionsStr, textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                dimensionsText.RectTransform.MinSize = new Point(0, dimensionsText.Children.First().Rect.Height);
            }

            if (RecommendedCrewSizeMax > 0)
            {
                var crewSizeText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                    TextManager.Get("RecommendedCrewSize"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), crewSizeText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 RecommendedCrewSizeMin + " - " + RecommendedCrewSizeMax, textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                crewSizeText.RectTransform.MinSize = new Point(0, crewSizeText.Children.First().Rect.Height);
            }

            if (!string.IsNullOrEmpty(RecommendedCrewExperience))
            {
                var crewExperienceText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                          TextManager.Get("RecommendedCrewExperience"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), crewExperienceText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 TextManager.Get(RecommendedCrewExperience), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                crewExperienceText.RectTransform.MinSize = new Point(0, crewExperienceText.Children.First().Rect.Height);
            }

            if (RequiredContentPackages.Any())
            {
                var contentPackagesText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                           TextManager.Get("RequiredContentPackages"), textAlignment: Alignment.TopLeft, font: font)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), contentPackagesText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 string.Join(", ", RequiredContentPackages), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                contentPackagesText.RectTransform.MinSize = new Point(0, contentPackagesText.Children.First().Rect.Height);
            }

            // show what game version the submarine was created on
            if (!IsVanillaSubmarine() && GameVersion != null)
            {
                var versionText = new GUITextBlock(new RectTransform(new Vector2(leftPanelWidth, 0), parent.Content.RectTransform),
                                                   TextManager.Get("serverlistversion"), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };
                new GUITextBlock(new RectTransform(new Vector2(rightPanelWidth, 0.0f), versionText.RectTransform, Anchor.TopRight, Pivot.TopLeft),
                                 GameVersion.ToString(), textAlignment: Alignment.TopLeft, font: font, wrap: true)
                {
                    CanBeFocused = false
                };

                versionText.RectTransform.MinSize = new Point(0, versionText.Children.First().Rect.Height);
            }

            submarineNameText.AutoScaleHorizontal = true;
            GUITextBlock.AutoScaleAndNormalize(parent.Content.Children.Where(c => c is GUITextBlock && c != submarineNameText).Cast <GUITextBlock>());
        }
Beispiel #31
0
        public string GetVariable(VariableType type)
        {
            string result;

            switch (type)
            {
            case VariableType.EditorDirectory:
                result = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                break;

            case VariableType.ScriptDirectory:
                result = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Dir + "Script";
                break;

            case VariableType.LevelDirectory:
                if (!string.IsNullOrEmpty(LevelFilePath))
                {
                    result = Path.GetDirectoryName(LevelFilePath);
                }
                else
                {
                    result = GetVariable(VariableType.EditorDirectory);
                }
                break;

            case VariableType.GameDirectory:
                result = MakeAbsolute(GameDirectory ?? VariableCreate(VariableType.LevelDirectory), VariableType.GameDirectory);
                break;

            case VariableType.LevelName:
                if (!string.IsNullOrEmpty(LevelFilePath))
                {
                    result = PathC.GetFileNameWithoutExtensionTry(LevelFilePath);
                }
                else if (Wads.Count > 0 && !string.IsNullOrEmpty(Wads[0].Path))
                {
                    result = PathC.GetFileNameWithoutExtensionTry(Wads[0].Path);
                }
                else
                {
                    result = "Default";
                }
                break;

            case VariableType.EngineVersion:
                result = GameVersion.ToString();
                break;

            case VariableType.SoundEngineVersion:
                result = (GameVersion.Native()).ToString();
                break;

            default:
                throw new ArgumentException();
            }
            if (result == null)
            {
                result = "";
            }
            return(result);
        }
Beispiel #32
0
        private Metadata TransformOne(JObject json, CurseMod curseMod, CurseFile latestVersion)
        {
            Log.InfoFormat("Found Curse mod: {0} {1}", curseMod.GetName(), latestVersion.GetFileVersion());

            // Only pre-fill version info if there's none already. GH #199
            if (json["ksp_version_min"] == null && json["ksp_version_max"] == null && json["ksp_version"] == null)
            {
                GameVersion minVer = latestVersion.versions.Min();
                GameVersion maxVer = latestVersion.versions.Max();
                if (minVer == maxVer)
                {
                    Log.DebugFormat("Writing ksp_version from Curse: {0}", latestVersion.version);
                    json["ksp_version"] = latestVersion.version.ToString();
                }
                else
                {
                    Log.DebugFormat("Writing ksp_version_min,_max from Curse: {0}, {1}", minVer, maxVer);
                    json["ksp_version_min"] = minVer.ToString();
                    json["ksp_version_max"] = maxVer.ToString();
                }
            }

            var useDownloadNameVersion = false;
            var useFilenameVersion     = false;
            var useCurseIdVersion      = false;

            var curseMetadata = (JObject)json["x_netkan_curse"];

            if (curseMetadata != null)
            {
                var useDownloadNameVersionMetadata = (bool?)curseMetadata["use_download_name_version"];
                if (useDownloadNameVersionMetadata != null)
                {
                    useDownloadNameVersion = useDownloadNameVersionMetadata.Value;
                }

                var useFilenameVersionMetadata = (bool?)curseMetadata["use_filename_version"];
                if (useFilenameVersionMetadata != null)
                {
                    useFilenameVersion = useFilenameVersionMetadata.Value;
                }

                var useCurseIdVersionMetadata = (bool?)curseMetadata["use_curse_id_version"];
                if (useCurseIdVersionMetadata != null)
                {
                    useCurseIdVersion = useCurseIdVersionMetadata.Value;
                }

                if ((useDownloadNameVersion ? 1 : 0) + (useFilenameVersion ? 1 : 0) + (useCurseIdVersion ? 1 : 0) > 1)
                {
                    throw new Kraken("Conflicting version options set in x_netkan_curse");
                }
            }

            json.SafeAdd("name", curseMod.GetName());
            json.SafeAdd("abstract", curseMod.description);

            if (useDownloadNameVersion)
            {
                json.SafeAdd("version", latestVersion.name);
            }
            else if (useFilenameVersion)
            {
                json.SafeAdd("version", latestVersion.GetFilename());
            }
            else if (useCurseIdVersion)
            {
                json.SafeAdd("version", latestVersion.GetCurseIdVersion());
            }
            else
            {
                json.SafeAdd("version", latestVersion.GetFileVersion());
            }

            json.SafeAdd("author", () => JToken.FromObject(curseMod.authors));
            json.Remove("$kref");
            json.SafeAdd("download", Regex.Replace(latestVersion.GetDownloadUrl(), " ", "%20"));

            // Curse provides users with the following default selection of licenses. Let's convert them to CKAN
            // compatible license strings if possible.
            //
            // "Academic Free License v3.0"                               - Becomes "AFL-3.0"
            // "Ace3 Style BSD"                                           - Becomes "restricted"
            // "All Rights Reserved"                                      - Becomes "restricted"
            // "Apache License version 2.0"                               - Becomes "Apache-2.0"
            // "Apple Public Source License version 2.0 (APSL)"           - Becomes "APSL-2.0"
            // "BSD License"                                              - Becomes "BSD-3-clause"
            // "Common Development and Distribution License (CDDL) "      - Becomes "CDDL"
            // "GNU Affero General Public License version 3 (AGPLv3)"     - Becomes "AGPL-3.0"
            // "GNU General Public License version 2 (GPLv2)"             - Becomes "GPL-2.0"
            // "GNU General Public License version 3 (GPLv3)"             - Becomes "GPL-3.0"
            // "GNU Lesser General Public License version 2.1 (LGPLv2.1)" - Becomes "LGPL-2.1"
            // "GNU Lesser General Public License version 3 (LGPLv3)"     - Becomes "LGPL-3.0"
            // "ISC License (ISCL)"                                       - Becomes "ISC"
            // "Microsoft Public License (Ms-PL)"                         - Becomes "Ms-PL"
            // "Microsoft Reciprocal License (Ms-RL)"                     - Becomes "Ms-RL"
            // "MIT License"                                              - Becomes "MIT"
            // "Mozilla Public License 1.0 (MPL)"                         - Becomes "MPL-1.0"
            // "Mozilla Public License 1.1 (MPL 1.1)"                     - Becomes "MPL-1.1"
            // "Public Domain"                                            - Becomes "public-domain"
            // "WTFPL"                                                    - Becomes "WTFPL"
            // "zlib/libpng License"                                      - Becomes "Zlib"
            // "Custom License"                                           - Becomes "unknown"

            var curseLicense = curseMod.license.Trim();

            switch (curseLicense)
            {
            case "Academic Free License v3.0":
                json.SafeAdd("license", "AFL-3.0");
                break;

            case "Ace3 Style BSD":
                json.SafeAdd("license", "restricted");
                break;

            case "All Rights Reserved":
                json.SafeAdd("license", "restricted");
                break;

            case "Apache License version 2.0":
                json.SafeAdd("license", "Apache-2.0");
                break;

            case "Apple Public Source License version 2.0 (APSL)":
                json.SafeAdd("license", "APSL-2.0");
                break;

            case "BSD License":
                json.SafeAdd("license", "BSD-3-clause");
                break;

            case "Common Development and Distribution License (CDDL) ":
                json.SafeAdd("license", "CDDL");
                break;

            case "GNU Affero General Public License version 3 (AGPLv3)":
                json.SafeAdd("license", "AGPL-3.0");
                break;

            case "GNU General Public License version 2 (GPLv2)":
                json.SafeAdd("license", "GPL-2.0");
                break;

            case "GNU General Public License version 3 (GPLv3)":
                json.SafeAdd("license", "GPL-3.0");
                break;

            case "GNU Lesser General Public License version 2.1 (LGPLv2.1)":
                json.SafeAdd("license", "LGPL-2.1");
                break;

            case "GNU Lesser General Public License version 3 (LGPLv3)":
                json.SafeAdd("license", "LGPL-3.0");
                break;

            case "ISC License (ISCL)":
                json.SafeAdd("license", "ISC");
                break;

            case "Microsoft Public License (Ms-PL)":
                json.SafeAdd("license", "Ms-PL");
                break;

            case "Microsoft Reciprocal License (Ms-RL)":
                json.SafeAdd("license", "Ms-RL");
                break;

            case "MIT License":
                json.SafeAdd("license", "MIT");
                break;

            case "Mozilla Public License 1.0 (MPL)":
                json.SafeAdd("license", "MPL-1.0");
                break;

            case "Mozilla Public License 1.1 (MPL 1.1)":
                json.SafeAdd("license", "MPL-1.1");
                break;

            case "Public Domain":
                json.SafeAdd("license", "public-domain");
                break;

            case "WTFPL":
                json.SafeAdd("license", "WTFPL");
                break;

            case "zlib/libpng License":
                json.SafeAdd("license", "Zlib");
                break;

            default:
                json.SafeAdd("license", "unknown");
                break;
            }

            // Make sure resources exist.
            if (json["resources"] == null)
            {
                json["resources"] = new JObject();
            }

            var resourcesJson = (JObject)json["resources"];

            //resourcesJson.SafeAdd("homepage", Normalize(curseMod.website));
            //resourcesJson.SafeAdd("repository", Normalize(curseMod.source_code));
            resourcesJson.SafeAdd("curse", curseMod.GetProjectUrl());

            if (curseMod.thumbnail != null)
            {
                resourcesJson.SafeAdd("x_screenshot", Normalize(new Uri(curseMod.thumbnail)));
            }

            Log.DebugFormat("Transformed metadata:{0}{1}", Environment.NewLine, json);

            return(new Metadata(json));
        }