Ejemplo n.º 1
0
        private HudElement(string elementType, string defName, HudTarget targets)
        {
            _elementType = elementType;
            DefName      = defName;
            Targets      = targets;

            HudTimings.Add(this);
        }
Ejemplo n.º 2
0
        public override bool Draw(HudComponent component, Rect rect)
        {
            HudTimings.Update(component)?.Start();

            var result = DoDraw(rect);

            HudTimings.Update(component)?.Finish(rect);

            return(result);
        }
Ejemplo n.º 3
0
        private HudLayout(XElement xe) : base(xe, true)
        {
            HudTimings.Add(this);

            bool docked;

            if (xe.Name == DockedElementName)
            {
                docked = true;
            }
            else if (xe.Name == FloatingElementName)
            {
                docked = false;
            }
            else
            {
                return;
            }

            var height = xe.Attribute(HeightAttributeName)?.Value.ToInt() ?? -1;
            var width  = xe.Attribute(WidthAttributeName)?.Value.ToInt() ?? -1;
            var tabs   = xe.Attribute(TabsAttributeName)?.Value.ToInt() ?? -1;

            if (height > 0)
            {
                if (docked)
                {
                    Theme.InspectPaneHeight.Value = height;
                }
                else
                {
                    Theme.HudHeight.Value = height;
                }
            }
            if (width > 0)
            {
                if (docked)
                {
                    Theme.InspectPaneTabWidth.Value = width;
                }
                else
                {
                    Theme.HudWidth.Value = width;
                }
            }
            if (docked && tabs > 0)
            {
                Theme.InspectPaneMinTabs.Value = tabs;
            }
        }
Ejemplo n.º 4
0
        public void Draw(Rect rect, PawnModel model)
        {
            HudTimings.Update(this)?.Start();

            try
            {
                if (model == null)
                {
                    return;
                }

                if (model.Base != _lastPawn || _lastRefresh == default || (DateTime.Now - _lastRefresh).TotalMilliseconds > Theme.RefreshRate.Value * 100)
                {
                    Prepare(model);
                    _lastPawn    = model.Base;
                    _lastRefresh = DateTime.Now;
                }

                Draw(rect);
            }
            catch (Exception exception) { Mod.HandleError(exception); }

            HudTimings.Update(this)?.Finish(rect, true);
        }