コード例 #1
0
        private static void ApplyLanguage(Control control, ILocalizedLanguage lang, ToolTip toolTip = null)
        {
            var  tag    = control.Tag?.ToString();
            bool hasTag = tag?.StartsWith("iatag_") ?? false;

            if (hasTag)
            {
                // Some controls like TextBox will only have a _tooltip tag, don't insert the text into them.
                if (!tag.EndsWith("_tooltip"))
                {
                    var localizedTag = lang.GetTag(tag);
                    if (!string.IsNullOrEmpty(localizedTag))
                    {
                        control.Text = localizedTag;
                    }
                    else if (lang.WarnIfMissing)
                    {
                        Logger.WarnFormat("Could not find tag {0} in localization, defaulting to {0}={1}", tag, control.Text);
                    }
                }

                // Most controls only has a regular tag, but may contain a _tooltip tag too.
                if (toolTip != null && !string.IsNullOrEmpty(toolTip.GetToolTip(control)))
                {
                    var tooltipTagName = (tag + "_tooltip").Replace("_tooltip_tooltip", "_tooltip");

                    var localizedTooltipTag = lang.GetTag(tooltipTagName);
                    if (!string.IsNullOrEmpty(localizedTooltipTag))
                    {
                        toolTip.SetToolTip(control, localizedTooltipTag);
                    }
                    else if (lang.WarnIfMissing)
                    {
                        Logger.WarnFormat("Could not find tag {0} in localization, defaulting to {0}={1}", tooltipTagName, toolTip.GetToolTip(control));
                    }
                }
            }
            else
            {
                // Listview column headers
                ListView lv = control as ListView;
                if (lv != null)
                {
                    foreach (ColumnHeader header in lv.Columns)
                    {
                        ApplyLanguage(header, lang);
                    }
                }
            }
        }
コード例 #2
0
        private static void ApplyLanguage(Control control, ILocalizedLanguage lang)
        {
            var  tag    = control.Tag?.ToString();
            bool hasTag = tag?.StartsWith("iatag_") ?? false;

            if (hasTag)
            {
                var localizedTag = lang.GetTag(tag);
                if (!string.IsNullOrEmpty(localizedTag))
                {
                    control.Text = localizedTag;
                }
                else if (lang.WarnIfMissing)
                {
                    Logger.WarnFormat("Could not find tag {0} in localization, defaulting to {0}={1}", tag,
                                      control.Text);
                }
            }
            else
            {
                // Listview column headers
                ListView lv = control as ListView;
                if (lv != null)
                {
                    foreach (ColumnHeader header in lv.Columns)
                    {
                        ApplyLanguage(header, lang);
                    }
                }
            }
        }
コード例 #3
0
        public static string TranslateFaction(ILocalizedLanguage language, string faction)
        {
            switch (faction)
            {
            case "Survivors":
                return(language.GetTag("tagFactionSurvivors"));

            case "User0":
                return(language.GetTag("tagFactionUser0"));

            case "User2":
                return(language.GetTag("tagFactionUser2"));

            case "User4":
                return(language.GetTag("tagFactionUser4"));

            case "User5":
                return(language.GetTag("tagFactionUser5"));

            case "User7":
                return(language.GetTag("tagFactionUser7"));

            case "User8":
                return(language.GetTag("tagFactionUser8"));

            case "User9":
                return(language.GetTag("tagFactionUser9_ia"));

            case "User10":
                return(language.GetTag("tagFactionUser10_ia"));

            case "User11":
                return(language.GetTag("tagFactionUser11_ia"));

            default:
                return(faction);
            }
        }
コード例 #4
0
        private static void ApplyLanguage(ColumnHeader control, ILocalizedLanguage lang)
        {
            var  tag    = control.Tag?.ToString();
            bool hasTag = tag?.StartsWith("iatag_") ?? false;

            if (hasTag)
            {
                var localizedTag = lang.GetTag(tag);
                if (!string.IsNullOrEmpty(localizedTag))
                {
                    control.Text = localizedTag;
                }
                else if (lang.WarnIfMissing)
                {
                    Logger.WarnFormat("Could not find tag {0} in localization, defaulting to {0}={1}", tag,
                                      control.Text);
                }
            }
        }
コード例 #5
0
        private void ProcessConversionDamage(ISet <IItemStat> stats, List <TranslatedStat> result)
        {
            var conversionPercentage = stats.FirstOrDefault(m => m.Stat == "conversionPercentage");
            var conversionOutType    = stats.FirstOrDefault(m => m.Stat == "conversionOutType");
            var conversionInType     = stats.FirstOrDefault(m => m.Stat == "conversionInType");

            if (conversionPercentage != null && conversionOutType != null && conversionInType != null)
            {
                result.Add(new TranslatedStat
                {
                    Text   = _language.GetTag("customtag_damage_conversion"),
                    Param0 = conversionPercentage.Value,
                    Param3 = DamageTypeTranslation(conversionInType.TextValue),
                    Param5 = DamageTypeTranslation(conversionOutType.TextValue),
                    Type   = TranslatedStatType.BODY
                });
            }
        }
コード例 #6
0
ファイル: SlotTranslator.cs プロジェクト: molybedenum/iagd
        public static string Translate(ILocalizedLanguage language, string stat)
        {
            if (SlotMap == null)
            {
                SlotMap = new Dictionary <string, string>
                {
                    ["ArmorProtective_Head"]      = language.GetTag("iatag_slot_head"),
                    ["ArmorProtective_Hands"]     = language.GetTag("iatag_slot_hands"),
                    ["ArmorProtective_Feet"]      = language.GetTag("iatag_slot_feet"),
                    ["ArmorProtective_Legs"]      = language.GetTag("iatag_slot_legs"),
                    ["ArmorProtective_Chest"]     = language.GetTag("iatag_slot_chest"),
                    ["ArmorProtective_Waist"]     = language.GetTag("iatag_slot_belt"),
                    ["ArmorJewelry_Medal"]        = language.GetTag("iatag_slot_medal"),
                    ["ArmorJewelry_Ring"]         = language.GetTag("iatag_slot_ring"),
                    ["ArmorProtective_Shoulders"] = language.GetTag("iatag_slot_shoulder"),
                    ["ArmorJewelry_Amulet"]       = language.GetTag("iatag_slot_neck"),
                    ["WeaponMelee_Dagger"]        = language.GetTag("iatag_slot_dagger1h"),
                    ["WeaponMelee_Mace"]          = language.GetTag("iatag_slot_mace1h"),
                    ["WeaponMelee_Axe"]           = language.GetTag("iatag_slot_axe1h"),
                    ["WeaponMelee_Scepter"]       = language.GetTag("iatag_slot_scepter1h"),
                    ["WeaponMelee_Sword"]         = language.GetTag("iatag_slot_sword1h"),
                    ["WeaponMelee_Sword2h"]       = language.GetTag("iatag_slot_sword2h"),
                    ["WeaponMelee_Mace2h"]        = language.GetTag("iatag_slot_mace2h"),
                    ["WeaponMelee_Axe2h"]         = language.GetTag("iatag_slot_axe2h"),
                    ["WeaponHunting_Ranged1h"]    = language.GetTag("iatag_slot_ranged1h"),
                    ["WeaponHunting_Ranged2h"]    = language.GetTag("iatag_slot_ranged2h"),
                    ["WeaponArmor_Offhand"]       = language.GetTag("iatag_slot_offhand"),
                    ["WeaponArmor_Shield"]        = language.GetTag("iatag_slot_shield"),
                    ["ItemRelic"]          = language.GetTag("iatag_slot_component"),
                    ["ItemArtifact"]       = language.GetTag("iatag_slot_relic"),
                    ["ItemFactionBooster"] = language.GetTag("iatag_slot_scroll"),
                    ["ItemEnchantment"]    = language.GetTag("iatag_slot_augmentation")
                };
            }

            if (!string.IsNullOrEmpty(stat) && SlotMap.ContainsKey(stat))
            {
                return(SlotMap[stat]);
            }

            return(stat);
        }
コード例 #7
0
 private void ProcessConversionDamage(ISet <IItemStat> stats, List <TranslatedStat> result)
 {
     {
         var conversionPercentage = stats.FirstOrDefault(m => m.Stat == "conversionPercentage");
         var conversionOutType    = stats.FirstOrDefault(m => m.Stat == "conversionOutType");
         var conversionInType     = stats.FirstOrDefault(m => m.Stat == "conversionInType");
         if (conversionPercentage != null && conversionOutType != null && conversionInType != null)
         {
             result.Add(new TranslatedStat {
                 Text   = _language.GetTag("customtag_damage_conversion"),
                 Param0 = conversionPercentage.Value,
                 Param3 = DamageTypeTranslation(conversionInType.TextValue),
                 Param5 = DamageTypeTranslation(conversionOutType.TextValue),
                 Type   = TranslatedStatType.BODY
             });
         }
     }
     { // A bit of a lame way of doing this.. maybe look into a better way? stats has a "pet" prefix from earlier preprocessing when loading the database
         var conversionPercentage = stats.FirstOrDefault(m => m.Stat == "petconversionPercentage");
         var conversionOutType    = stats.FirstOrDefault(m => m.Stat == "petconversionOutType");
         var conversionInType     = stats.FirstOrDefault(m => m.Stat == "petconversionInType");
         if (conversionPercentage != null && conversionOutType != null && conversionInType != null)
         {
             result.Add(new TranslatedStat {
                 Text   = _language.GetTag("customtag_damage_conversion"),
                 Param0 = conversionPercentage.Value,
                 Param3 = DamageTypeTranslation(conversionInType.TextValue),
                 Param5 = DamageTypeTranslation(conversionOutType.TextValue),
                 Type   = TranslatedStatType.BODY
             });
         }
     }
 }