Пример #1
0
        public static void AddModifiersToNode(ILocalisationApiHelper localisation, VisNode node,
                                              IDictionary <string, string> modifiers,
                                              Entity source,
                                              bool localiseKeys = true)
        {
            foreach (var modifierNodeKeyValue in modifiers)
            {
                string key    = localiseKeys ? GetPotentialLocalisationKeys(localisation, modifierNodeKeyValue.Key) : modifierNodeKeyValue.Key;
                string prefix = "";
                string suffix = "";
                string value  = modifierNodeKeyValue.Value;
                try {
                    if (modifierNodeKeyValue.Key.ToUpperInvariant().EndsWith("ADD"))
                    {
                        double intValue = value.ToDouble();
                        prefix = intValue >= 0 ? "+" : "";
                    }

                    if (modifierNodeKeyValue.Key.ToUpperInvariant().EndsWith("MULT"))
                    {
                        int percentageValue = (int)(value.ToDouble() * 100);
                        prefix = percentageValue >= 0 ? "+" : "";
                        suffix = "%";
                        value  = percentageValue.ToString(CultureInfo.InvariantCulture);
                    }
                }
                catch (FormatException e) {
                    Log.Logger.Error(e, "Error parsing {nodeId} from {filePath}", node.id, source.FilePath);
                }

                node.title = $"{node.title}<br/><b>{key}:</b> {prefix}{value}{suffix}";
            }
        }
 protected EntityCreator(ILocalisationApiHelper localisationApiHelper, ICWParserHelper cwParserHelper)
 {
     LocalisationApiHelper = localisationApiHelper;
     CWParserHelper        = cwParserHelper;
     ParseFileMask         = StellarisDirectoryHelper.TextMask;
     AbortOnFailure        = false;
 }
Пример #3
0
 public TechTreeGraphCreator(ILocalisationApiHelper localisationApiHelper, ICWParserHelper cwParserHelper,
                             StellarisDirectoryHelper stellarisDirectoryHelper, IEnumerable <StellarisDirectoryHelper> modDirectoryHelpers) : base(localisationApiHelper, cwParserHelper)
 {
     this.stellarisDirectoryHelper = stellarisDirectoryHelper;
     this.modDirectoryHelpers      = modDirectoryHelpers;
     IgnoreFiles = new List <string>();
     IgnoreFiles.AddRange(new [] { "00_tier.txt", "00_category.txt", "eac_category.txt" });
 }
Пример #4
0
 public DependantsGraphCreator(ILocalisationApiHelper localisationApiHelper, ICWParserHelper cwParserHelper,
                               StellarisDirectoryHelper stellarisDirectoryHelper, IEnumerable <StellarisDirectoryHelper> modDirectoryHelpers,
                               ModEntityData <Tech> techsAndDependencies)
 {
     this.localisationApiHelper    = localisationApiHelper;
     this.cwParserHelper           = cwParserHelper;
     this.stellarisDirectoryHelper = stellarisDirectoryHelper;
     this.modDirectoryHelpers      = modDirectoryHelpers;
     this.techsAndDependencies     = techsAndDependencies;
 }
Пример #5
0
        // f*****g capitalisation
        private static string GetPotentialLocalisationKeys(ILocalisationApiHelper localisation, string rootKey)
        {
            var result = new List <string>();

            result.Add(rootKey);
            result.Add(rootKey.ToUpperInvariant());
            result.Add("mod_" + rootKey);
            result.Add("MOD_" + rootKey.ToUpperInvariant());

            foreach (var key in result)
            {
                if (localisation.HasValueForKey(key))
                {
                    return(localisation.GetName(key));
                }
            }

            return(rootKey);
        }
Пример #6
0
        public static string CreateCostString <T>(ILocalisationApiHelper localisation, string resourceType, IDictionary <string, T> costs)
        {
            if (costs.Any())
            {
                string costString = $"<br/><b>{resourceType}:</b>";
                foreach (var(key, value) in costs)
                {
                    costString = $"{costString} {value} {localisation.GetName(key)},";
                }

                return(costString.Remove(costString.Length - 1));

                ;
            }
            else
            {
                return("");
            }
        }
Пример #7
0
 public BuildingGraphCreator(ILocalisationApiHelper localisationApiHelper, ICWParserHelper cwParserHelper) : base(localisationApiHelper, cwParserHelper)
 {
 }
Пример #8
0
 public DecisionGraphCreator(ILocalisationApiHelper localisationApiHelper, ICWParserHelper cwParserHelper) : base(localisationApiHelper, cwParserHelper)
 {
 }
 public ShipComponentSetGraphCreator(ILocalisationApiHelper localisationApiHelper, ICWParserHelper cwParserHelper) : base(localisationApiHelper, cwParserHelper)
 {
 }
 public ShipComponentGraphCreator(ILocalisationApiHelper localisationApiHelper, ICWParserHelper cwParserHelper) : base(localisationApiHelper, cwParserHelper)
 {
     excludes.Add("STARBASE_COMBAT_COMPUTER_1");
     excludes.Add("STARBASE_COMBAT_COMPUTER_2");
     excludes.Add("STARBASE_COMBAT_COMPUTER_3");
 }
 public VisDataMarshaler(ILocalisationApiHelper localisationApi, OutputDirectoryHelper outputDirectoryHelper)
 {
     this.localisationApi       = localisationApi;
     this.outputDirectoryHelper = outputDirectoryHelper;
     techsVisMarshaler          = new TechsVisMarshaler(localisationApi, outputDirectoryHelper);
 }
Пример #12
0
 public TechsVisMarshaler(ILocalisationApiHelper localisationApi, OutputDirectoryHelper outputDirectoryHelper)
 {
     this.localisationApi       = localisationApi;
     this.outputDirectoryHelper = outputDirectoryHelper;
 }