Exemplo n.º 1
0
 protected override string RequirementText()
 {
     return(Localizer.Format(invertRequirement ? "#cc.req.PartUnlocked.x" : "#cc.req.PartUnlocked",
                             LocalizationUtil.LocalizeList <AvailablePart>(invertRequirement ? LocalizationUtil.Conjunction.OR : LocalizationUtil.Conjunction.AND, parts,
                                                                           x => StringBuilderCache.Format("<color=#{0}>{1}</color>", MissionControlUI.RequirementHighlightColor, x.title)),
                             parts.Count));
 }
Exemplo n.º 2
0
 protected override string RequirementText()
 {
     return(Localizer.Format(invertRequirement ? "#cc.req.PartModuleTypeUnlocked.x" : "#cc.req.PartModuleTypeUnlocked",
                             LocalizationUtil.LocalizeList <string>(invertRequirement ? LocalizationUtil.Conjunction.AND : LocalizationUtil.Conjunction.OR, partModuleTypes,
                                                                    x => StringBuilderCache.Format("<color=#{0}>{1}</color>", MissionControlUI.RequirementHighlightColor, Parameters.PartValidation.ModuleTypeName(x))),
                             partModuleTypes.Count));
 }
Exemplo n.º 3
0
        protected override string RequirementText()
        {
            // Techs
            if (techs.Count > 0)
            {
                return(Localizer.Format(invertRequirement ? "#cc.req.TechResearched.tech.x" : "#cc.req.TechResearched.tech",
                                        LocalizationUtil.LocalizeList <string>(invertRequirement ? LocalizationUtil.Conjunction.AND : LocalizationUtil.Conjunction.OR, techs, x => { Tech t = Tech.GetTech(x); return t != null ? t.title : x; })));
            }

            // Part module
            if (partModules.Count > 0)
            {
                return(Localizer.Format(invertRequirement ? "#cc.req.TechResearched.part.x" : "#cc.req.TechResearched.part",
                                        LocalizationUtil.LocalizeList <string>(invertRequirement ? LocalizationUtil.Conjunction.AND : LocalizationUtil.Conjunction.OR, partModules, x => Parameters.PartValidation.ModuleName(x))));
            }

            // Part module type
            return(Localizer.Format(invertRequirement ? "#cc.req.TechResearched.part.x" : "#cc.req.TechResearched.part",
                                    LocalizationUtil.LocalizeList <string>(invertRequirement ? LocalizationUtil.Conjunction.AND : LocalizationUtil.Conjunction.OR, partModuleTypes, x => Parameters.PartValidation.ModuleTypeName(x))));
        }
        void Update()
        {
            // Detect if there are any new messages
            if (MessageSystem.Instance != null)
            {
                // Derive the internal message list
                if (messageList == null)
                {
                    messageList = (List <MessageSystemButton>)messageListField.GetValue(MessageSystem.Instance);
                }

                // Go through new messages
                if (messageList.Count > lastMessageCount)
                {
                    for (int i = (messageList.Count - lastMessageCount); i-- > 0;)
                    {
                        LoggingUtil.LogVerbose(this, "Message list count = {0}, message {3} = {1} + {2}", messageList.Count, messageList[i].message.message, messageList[i].message.messageTitle, i);
                        if (LocalizationUtil.IsLocalizedString(messageList[i].message.message, deployedScienceTag))
                        {
                            // Pull out the parameters
                            IList <string> parameters = LocalizationUtil.UnLocalizeString(messageList[i].message.message, deployedScienceTag);

                            // Identify the subject
                            ScienceSubject subject = null;
                            foreach (ScienceSubject sub in recentScience)
                            {
                                if (sub.title == parameters[0])
                                {
                                    subject = sub;
                                    break;
                                }
                            }

                            // Subject identified
                            if (subject != null)
                            {
                                LoggingUtil.LogVerbose(this, "Subject identified as {0}", subject.id);

                                // Delete the old message
                                MessageSystem.Instance.DiscardMessage(messageList[i].message.button);

                                // Check for an existing summary level message
                                MessageSystem.Message message = MessageSystem.Instance.FindMessages(m => m.messageTitle == deployedScienceMessageTitle).FirstOrDefault();
                                if (message != null)
                                {
                                    message.IsRead = false;
                                    trackedSubjects.Clear();
                                }
                                trackedSubjects.Add(subject);
                                trackedSubjects.Sort((ss1, ss2) => string.Compare(ss1.title, ss2.title));

                                StringBuilder sb = StringBuilderCache.Acquire();
                                sb.Append(string.Format("<b>{0}</b>:\n", deployedScienceMessageTitle));

                                foreach (ScienceSubject s in trackedSubjects)
                                {
                                    sb.Append(string.Format("    {0}: <color=#6DCFF6><sprite=\"CurrencySpriteAsset\" name=\"Science\" tint=1> {1}</color> / <color=#6DCFF6><sprite=\"CurrencySpriteAsset\" name=\"Science\" tint=1> {2}</color>\n",
                                                            s.title, s.science.ToString("F1"), s.scienceCap.ToString("F1")));
                                }

                                if (message != null)
                                {
                                    message.message = sb.ToStringAndRelease();
                                }
                                else
                                {
                                    MessageSystem.Instance.AddMessage(new MessageSystem.Message(deployedScienceMessageTitle, sb.ToStringAndRelease(),
                                                                                                MessageSystemButton.MessageButtonColor.BLUE, MessageSystemButton.ButtonIcons.ALERT));
                                }
                            }
                            else
                            {
                                LoggingUtil.LogWarning(this, "Couldn't identify subject for deployed experiment with title '{0}'", parameters[0]);
                            }
                        }
                    }

                    recentScience.Clear();
                }
                lastMessageCount = messageList.Count;

                // Check for active screen messages
                screenMessagesToRemove.Clear();
                foreach (ScreenMessage message in ScreenMessages.Instance.ActiveMessages)
                {
                    if (LocalizationUtil.IsLocalizedString(message.message, deployedScienceTag))
                    {
                        screenMessagesToRemove.Add(message);
                    }
                }

                // Remove the messages
                foreach (ScreenMessage message in screenMessagesToRemove)
                {
                    ScreenMessages.RemoveMessage(message);
                }
            }
        }
        protected override string RequirementText()
        {
            string techStr = LocalizationUtil.LocalizeList <string>(invertRequirement ? LocalizationUtil.Conjunction.OR : LocalizationUtil.Conjunction.AND, techs, t => Tech.GetTech(t).title);

            return(Localizer.Format(invertRequirement ? "#cc.req.CanResearchTech.x" : "#cc.req.CanResearchTech", techStr));
        }