コード例 #1
0
        protected override string GetParameterTitle()
        {
            // Set the first part of the output
            string output;

            if (!string.IsNullOrEmpty(title))
            {
                output = title;
            }
            else
            {
                // Set the vessel name
                if ((waiting || state == ParameterState.Complete) && trackedVessel != null)
                {
                    output = Localizer.Format("#cc.param.VesselParameterGroup.default", trackedVessel.vesselName);
                }
                else if (!string.IsNullOrEmpty(define))
                {
                    output = Localizer.Format("#cc.param.VesselParameterGroup.newVessel", define);
                }
                else if (vesselList.Any())
                {
                    output = Localizer.Format("#cc.param.VesselParameterGroup.default",
                                              LocalizationUtil.LocalizeList <string>(LocalizationUtil.Conjunction.OR, vesselList.AsEnumerable(), vesselName =>
                    {
                        if (ContractVesselTracker.Instance != null)
                        {
                            return(ContractVesselTracker.GetDisplayName(vesselName));
                        }
                        else
                        {
                            LoggingUtil.LogWarning(this, "Unable to get vessel display name for '{0}' - ContractVesselTracker is null.  This is likely caused by another ScenarioModule crashing, preventing others from loading.", vesselName);
                            return(vesselName);
                        }
                    }
                                                                                     ));
                }
                else
                {
                    output = Localizer.GetStringByTag("#cc.param.VesselParameterGroup.anyVessel");
                }

                // If we're complete and a custom title hasn't been provided, try to get a better title
                if (state == ParameterState.Complete && ParameterCount == 1 && trackedVessel != null)
                {
                    output = Localizer.Format("#cc.param.VesselParameterGroup.complete", trackedVessel.vesselName, GetParameter(0).Title);
                }
            }

            return(output);
        }
コード例 #2
0
        protected override string GetParameterTitle()
        {
            string output = "";

            if (string.IsNullOrEmpty(title))
            {
                if (vessels.Count == 1)
                {
                    output = Localizer.Format("#cc.param.VesselNotDestroyed", ContractVesselTracker.GetDisplayName(vessels[0]));
                }
                else if (vessels.Count != 0)
                {
                    output = Localizer.Format("#cc.param.VesselNotDestroyed", LocalizationUtil.LocalizeList <string>(LocalizationUtil.Conjunction.OR, vessels, v => ContractVesselTracker.GetDisplayName(v)));
                }
                else if (Parent is VesselParameterGroup && ((VesselParameterGroup)Parent).VesselList.Any())
                {
                    IEnumerable <string> vesselList = ((VesselParameterGroup)Parent).VesselList;
                    if (vesselList.Count() == 1)
                    {
                        output = Localizer.Format("#cc.param.VesselNotDestroyed", ContractVesselTracker.GetDisplayName(vesselList.First()));
                    }
                    else
                    {
                        output = Localizer.Format("#cc.param.VesselNotDestroyed", LocalizationUtil.LocalizeList <string>(LocalizationUtil.Conjunction.OR, vesselList, v => ContractVesselTracker.GetDisplayName(v)));
                    }
                }
                else
                {
                    output = Localizer.GetStringByTag("#cc.param.VesselNotDestroyed.any");
                }
            }
            else
            {
                output = title;
            }
            return(output);
        }
コード例 #3
0
        protected override string GetParameterTitle()
        {
            string output = null;

            if (string.IsNullOrEmpty(title))
            {
                // "Complete any ONE of the following"
                if (state == ParameterState.Complete)
                {
                    output = StringBuilderCache.Format("{0}: {1}", Localizer.GetStringByTag("#cc.param.Any"),
                                                       LocalizationUtil.LocalizeList <ContractParameter>(LocalizationUtil.Conjunction.AND, this.GetChildren().Where(x => x.State == ParameterState.Complete), x => x.Title));
                }
                else
                {
                    output = Localizer.GetStringByTag("#cc.param.Any");
                }
            }
            else
            {
                output = title;
            }

            return(output);
        }
コード例 #4
0
        protected override string GetParameterTitle()
        {
            string output = null;

            if (string.IsNullOrEmpty(title))
            {
                // "Allow no more than <<1>> of the following"
                if (state == ParameterState.Complete)
                {
                    output = StringBuilderCache.Format("{0}: {1}", Localizer.Format("#cc.param.AtMost", count),
                                                       LocalizationUtil.LocalizeList <ContractParameter>(LocalizationUtil.Conjunction.OR, this.GetChildren().Where(x => x.State == ParameterState.Complete), x => x.Title));
                }
                else
                {
                    output = Localizer.Format("#cc.param.AtMost", count);
                }
            }
            else
            {
                output = title;
            }

            return(output);
        }
コード例 #5
0
        protected void CreateDelegates()
        {
            foreach (Filter filter in filters)
            {
                if (filter.type == ParameterDelegateMatchType.VALIDATE)
                {
                    foreach (AvailablePart part in filter.parts)
                    {
                        AddParameter(new CountParameterDelegate <Part>(filter.minCount, filter.maxCount, p => p.partInfo.name == part.name,
                                                                       part.title, false));
                    }

                    // Filter by part modules
                    foreach (string partModule in filter.partModules)
                    {
                        AddParameter(new CountParameterDelegate <Part>(filter.minCount, filter.maxCount, p => PartHasModule(p, partModule),
                                                                       Localizer.Format("#cc.param.PartValidation.withModule", ModuleName(partModule)), false));
                    }

                    // Filter by part module types
                    foreach (string partModuleType in filter.partModuleTypes)
                    {
                        AddParameter(new CountParameterDelegate <Part>(filter.minCount, filter.maxCount, p => PartHasObjective(p, partModuleType),
                                                                       Localizer.Format("#cc.param.PartValidation.withModuleType", ModuleTypeName(partModuleType)), false));
                    }
                }
                else
                {
                    // Filter by part
                    if (filter.parts.Any())
                    {
                        AddParameter(new ParameterDelegate <Part>(
                                         Localizer.Format("#cc.param.PartValidation.type", filter.type.Prefix(), LocalizationUtil.LocalizeList <AvailablePart>(LocalizationUtil.Conjunction.OR, filter.parts, p => p.title)),
                                         p => filter.parts.Any(pp => p.partInfo.name == pp.name), filter.type));
                    }

                    // Filter by part modules
                    foreach (string partModule in filter.partModules)
                    {
                        AddParameter(new ParameterDelegate <Part>(Localizer.Format("#cc.param.PartValidation.module", filter.type.Prefix(), ModuleName(partModule)), p => PartHasModule(p, partModule), filter.type));
                    }

                    // Filter by part modules
                    foreach (string partModuleType in filter.partModuleTypes)
                    {
                        AddParameter(new ParameterDelegate <Part>(Localizer.Format("#cc.param.PartValidation.moduleType", filter.type.Prefix(), ModuleTypeName(partModuleType)), p => PartHasObjective(p, partModuleType), filter.type));
                    }

                    // Filter by part modules - extended mode
                    foreach (List <Tuple <string, string, string> > list in filter.partModuleExtended)
                    {
                        ContractParameter wrapperParam = AddParameter(new AllParameterDelegate <Part>(Localizer.Format("#cc.param.PartValidation.moduleShort", filter.type.Prefix()), filter.type));

                        foreach (Tuple <string, string, string> v in list)
                        {
                            string name = v.Item1;
                            string label;
                            if (string.IsNullOrEmpty(v.Item2))
                            {
                                label = Regex.Replace(name, @"([A-Z]+?(?=[A-Z][^A-Z])|\B[A-Z]+?(?=[^A-Z]))", " $1");
                                label = label.Substring(0, 1).ToUpper() + label.Substring(1);
                            }
                            else
                            {
                                label = v.Item2;
                            }
                            string value = name == "name" ? ModuleName(v.Item3) : v.Item3;

                            ParameterDelegateMatchType childFilter = ParameterDelegateMatchType.FILTER;
                            wrapperParam.AddParameter(new ParameterDelegate <Part>(Localizer.Format("#cc.param.PartValidation.generic", childFilter.Prefix(), label, value), p => PartModuleCheck(p, v), childFilter));
                        }
                    }

                    // Filter by category
                    if (filter.category != null)
                    {
                        AddParameter(new ParameterDelegate <Part>(Localizer.Format("#cc.param.PartValidation.category", filter.type.Prefix(), filter.category),
                                                                  p => p.partInfo.category == filter.category.Value, filter.type));
                    }

                    // Filter by manufacturer
                    if (filter.manufacturer != null)
                    {
                        AddParameter(new ParameterDelegate <Part>(Localizer.Format("#cc.param.PartValidation.manufacturer", filter.type.Prefix(), filter.manufacturer),
                                                                  p => p.partInfo.manufacturer == filter.manufacturer, filter.type));
                    }
                }
            }

            // Validate count
            if (minCount != 0 || maxCount != int.MaxValue && !(minCount == maxCount && maxCount == 0))
            {
                AddParameter(new CountParameterDelegate <Part>(minCount, maxCount));
            }
        }
コード例 #6
0
 public string BodyList()
 {
     return(LocalizationUtil.LocalizeList <CelestialBody>(LocalizationUtil.Conjunction.OR, targetBodies, cb => cb.displayName));
 }
コード例 #7
0
 public string SituationList()
 {
     return(LocalizationUtil.LocalizeList <Vessel.Situations>(LocalizationUtil.Conjunction.OR, situation, sit => ReachSituation.GetTitleStringShort(sit)));
 }