public override IColoredTextList MakeInstance(GuiHudLineKeys key, float currentSpeed = -1F) {
     if (!ValidateKeyAgainstIntelLevel(key)) {
         return _emptyIColoredTextList;
     }
     FleetData data = _data as FleetData;
     switch (key) {
         case GuiHudLineKeys.Speed:
             return new ColoredTextList_Speed(currentSpeed, data.MaxSpeed);  // fleet will always display speed, even if zero
         case GuiHudLineKeys.Owner:
             return new ColoredTextList_Owner(data.Owner);
         case GuiHudLineKeys.Health:
             return new ColoredTextList_Health(data.Health, data.MaxHitPoints);
         case GuiHudLineKeys.CombatStrength:
             return new ColoredTextList<float>(Constants.FormatFloat_0Dp, data.Strength.Combined);
         case GuiHudLineKeys.CombatStrengthDetails:
             return new ColoredTextList_Combat(data.Strength);
         case GuiHudLineKeys.Composition:
             return new ColoredTextList_Composition(data.Composition);
         case GuiHudLineKeys.CompositionDetails:
             //TODO
             return new ColoredTextList_Composition(data.Composition);
         default:
             return base.MakeInstance(key);
     }
 }
 public override IColoredTextList MakeInstance(GuiHudLineKeys key, float currentSpeed = -1F) {
     if (!ValidateKeyAgainstIntelLevel(key)) {
         return _emptyIColoredTextList;
     }
     SystemData data = _data as SystemData;
     switch (key) {
         case GuiHudLineKeys.Speed:
             return currentSpeed > Constants.ZeroF ? new ColoredTextList_Speed(currentSpeed) : _emptyIColoredTextList;
         case GuiHudLineKeys.Owner:
             return (data.Settlement != null) ? new ColoredTextList_Owner(data.Settlement.Owner) : _emptyIColoredTextList;
         case GuiHudLineKeys.Health:
             return (data.Settlement != null) ? new ColoredTextList_Health(data.Settlement.Health, data.Settlement.MaxHitPoints) : _emptyIColoredTextList;
         case GuiHudLineKeys.CombatStrength:
             return (data.Settlement != null) ? new ColoredTextList<float>(Constants.FormatFloat_0Dp, data.Settlement.Strength.Combined) : _emptyIColoredTextList;
         case GuiHudLineKeys.CombatStrengthDetails:
             return (data.Settlement != null) ? new ColoredTextList_Combat(data.Settlement.Strength) : _emptyIColoredTextList;
         case GuiHudLineKeys.Capacity:
             return new ColoredTextList<int>(Constants.FormatInt_2DMin, data.Capacity);
         case GuiHudLineKeys.Resources:
             return new ColoredTextList_Resources(data.Resources);
         case GuiHudLineKeys.Specials:
             return (data.SpecialResources != null) ? new ColoredTextList_Specials(data.SpecialResources) : _emptyIColoredTextList;
         case GuiHudLineKeys.SettlementSize:
             return (data.Settlement != null) ? new ColoredTextList_String(data.Settlement.SettlementSize.GetName()) : _emptyIColoredTextList;
         case GuiHudLineKeys.SettlementDetails:
             return (data.Settlement != null) ? new ColoredTextList_Settlement(data.Settlement) : _emptyIColoredTextList;
         default:
             return base.MakeInstance(key);
     }
 }
 public override IColoredTextList MakeInstance(GuiHudLineKeys key, float currentSpeed = -1F) {
     if (!ValidateKeyAgainstIntelLevel(key)) {
         return _emptyIColoredTextList;
     }
     ShipData data = _data as ShipData;
     switch (key) {
         case GuiHudLineKeys.Speed:
             return new ColoredTextList_Speed(currentSpeed, data.MaxSpeed);
         case GuiHudLineKeys.Owner:
             return new ColoredTextList_Owner(data.Owner);
         case GuiHudLineKeys.Health:
             return new ColoredTextList_Health(data.Health, data.MaxHitPoints);  // ship should always have MaxHitPoints, even if health is virtually zero
         case GuiHudLineKeys.CombatStrength:
             return new ColoredTextList<float>(Constants.FormatFloat_0Dp, data.Strength.Combined);  // ship should always have CombatStrength even if health is virtually zero
         case GuiHudLineKeys.CombatStrengthDetails:
             return new ColoredTextList_Combat(data.Strength);  // ship should always have CombatStrength even if health is virtually zero
         case GuiHudLineKeys.ShipSize:
             return new ColoredTextList_String(data.Hull.GetDescription());
         case GuiHudLineKeys.ShipDetails:
             return new ColoredTextList_Ship(data);
         default:
             return base.MakeInstance(key);
     }
 }
 protected bool ValidateKeyAgainstIntelLevel(GuiHudLineKeys key) {
     return _hudLineKeyLookup[IntelLevel].Contains<GuiHudLineKeys>(key);
 }
        /// <summary>
        /// Makes an instance of IColoredTextList for the provided key from the data contained within the factory.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="currentSpeed">Optional current speed of the game object.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public virtual IColoredTextList MakeInstance(GuiHudLineKeys key, float currentSpeed = -1F) {
            switch (key) {
                case GuiHudLineKeys.ParentName:
                    return new ColoredTextList_String(_data.OptionalParentName);
                case GuiHudLineKeys.Distance:
                    return new ColoredTextList_Distance(_data.Position);    // returns empty if nothing is selected thereby making distance n/a
                case GuiHudLineKeys.IntelState:
                    return (_data.LastHumanPlayerIntelDate != null) ? new ColoredTextList_Intel(_data.LastHumanPlayerIntelDate, IntelLevel) : _emptyIColoredTextList;

                // The following is a fall through catcher for line keys that aren't processed in derived factories. An empty ColoredTextList will be returned which will be ignored by GuiCursorHudText
                case GuiHudLineKeys.Owner:
                case GuiHudLineKeys.Health:
                case GuiHudLineKeys.CombatStrength:
                case GuiHudLineKeys.CombatStrengthDetails:
                case GuiHudLineKeys.Capacity:
                case GuiHudLineKeys.Resources:
                case GuiHudLineKeys.Specials:
                case GuiHudLineKeys.Composition:
                case GuiHudLineKeys.CompositionDetails:
                case GuiHudLineKeys.SettlementSize:
                case GuiHudLineKeys.SettlementDetails:
                case GuiHudLineKeys.ShipSize:
                case GuiHudLineKeys.ShipDetails:
                    return _emptyIColoredTextList;

                //Speed should be processed by all derived factories
                case GuiHudLineKeys.Speed:
                case GuiHudLineKeys.None:
                default:
                    throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(key));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Constructs and returns a line of text by taking the base content (determined by the lineKey) and inserting colored elements of text.
        /// </summary>
        /// <param name="lineKey">The line key.</param>
        /// <param name="coloredTextList">The colored text elements.</param>
        /// <returns></returns>
        private string ConstructTextLine(GuiHudLineKeys lineKey, IColoredTextList coloredTextList) {
            IList<string> textElements = new List<string>();
            foreach (var ct in coloredTextList.List) {
                textElements.Add(ct.TextWithEmbeddedColor);
                //D.Log("ConstructTextLine called. ColoredTextElement = {0}".Inject(ct.TextWithEmbeddedColor));
            }

            string baseText;
            if (_baseDisplayLineContent.TryGetValue(lineKey, out baseText)) {
                //D.Log("BaseText = {0}", baseText);
                //D.Log("Text Elements = {0}", textElements.Concatenate<string>(Constants.Comma));
                string colorEmbeddedLineText = baseText.Inject(textElements.ToArray<string>());
                return colorEmbeddedLineText;
            }

            string warn = "No LineKey {0} found.".Inject(lineKey.GetName());
            D.Warn(warn);
            return warn;
        }
Exemplo n.º 7
0
 /// <summary>
 /// Replaces any existing list of text elements for this lineKey with the provided list. If no such list already
 /// exists, the new textElements list is simply added.
 /// </summary>
 /// <param name="lineKey">The line key.</param>
 /// <param name="textList">The text elements.</param>
 public void Replace(GuiHudLineKeys lineKey, IColoredTextList textList) {
     if (_textLine.ContainsKey(lineKey)) {
         _textLine.Remove(lineKey);
     }
     Add(lineKey, textList);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Adds the specified key and text list to this GuiCursorHudText.
 /// </summary>
 /// <param name="lineKey">The line key.</param>
 /// <param name="textList">The text list.</param>
 /// <exception cref="ArgumentException" >Attempting to add a line key that is already present.</exception>
 public void Add(GuiHudLineKeys lineKey, IColoredTextList textList) {
     _textLine.Add(lineKey, textList);
     //_data[lineKey] = textList;
     IsDirty = true;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Adds or replaces any existing list of text elements for this lineKey with the provided list. 
 /// If the existing list and the provided list are identical, this method does nothing.
 /// </summary>
 /// <param name="lineKey">The line key.</param>
 /// <param name="textList">The list of text elements.</param>
 public void Add(GuiHudLineKeys lineKey, IColoredTextList textList) {
     if (_textLineLookup.ContainsKey(lineKey)) {
         IColoredTextList existingList = _textLineLookup[lineKey];
         if (IsEqual(textList, existingList)) {
             //D.Warn("{0} key {1} has identical content [{2}].", GetType().Name, lineKey.GetName(), textList.List.Concatenate());
             return;
         }
         _textLineLookup.Remove(lineKey);
         D.Log("Removing {0} HUD line [{1}].", lineKey.GetValueName(), existingList.List.Concatenate());
     }
     D.Log("Adding {0} HUD line [{1}].", lineKey.GetValueName(), textList.List.Concatenate());
     _textLineLookup.Add(lineKey, textList);
     //_data[lineKey] = textList;
     IsDirty = true;
 }