Ejemplo n.º 1
0
        public GradedLabelsComponent(GradedSplitsSettings settings, IEnumerable <GradedColumnData> columns)
        {
            Settings      = settings;
            MinimumHeight = 31;

            MeasureTimeLabel   = new SimpleLabel();
            MeasureDeltaLabel  = new SimpleLabel();
            TimeFormatter      = new GradedRegularSplitTimeFormatter(Settings.SplitTimesAccuracy);
            DeltaTimeFormatter = new GradedDeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals);

            Cache       = new GraphicsCache();
            LabelsList  = new List <SimpleLabel>();
            ColumnsList = columns;
        }
Ejemplo n.º 2
0
        public GradedSplitComponent(GradedSplitsSettings settings, IEnumerable <GradedColumnData> columnsList)
        {
            NameLabel = new SimpleLabel()
            {
                HorizontalAlignment = StringAlignment.Near,
                X = 8,
            };
            MeasureTimeLabel   = new SimpleLabel();
            MeasureDeltaLabel  = new SimpleLabel();
            Settings           = settings;
            ColumnsList        = columnsList;
            TimeFormatter      = new GradedRegularSplitTimeFormatter(Settings.SplitTimesAccuracy);
            DeltaTimeFormatter = new GradedDeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals);
            MinimumHeight      = 25;
            VerticalHeight     = 31;

            NeedUpdateAll = true;
            IsActive      = false;

            Cache      = new GraphicsCache();
            LabelsList = new List <SimpleLabel>();
        }
Ejemplo n.º 3
0
        private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            if (Settings.BackgroundGradient == GradedExtendedGradientType.Alternating)
            {
                g.FillRectangle(new SolidBrush(
                                    Settings.BackgroundColor
                                    ), 0, 0, width, height);
            }

            MeasureTimeLabel.Text  = TimeFormatter.Format(new TimeSpan(24, 0, 0));
            MeasureDeltaLabel.Text = DeltaTimeFormatter.Format(new TimeSpan(0, 9, 0, 0));

            MeasureTimeLabel.Font          = state.LayoutSettings.TimesFont;
            MeasureTimeLabel.IsMonospaced  = true;
            MeasureDeltaLabel.Font         = state.LayoutSettings.TimesFont;
            MeasureDeltaLabel.IsMonospaced = true;

            MeasureTimeLabel.SetActualWidth(g);
            MeasureDeltaLabel.SetActualWidth(g);

            if (Settings.SplitTimesAccuracy != CurrentAccuracy)
            {
                TimeFormatter   = new GradedRegularSplitTimeFormatter(Settings.SplitTimesAccuracy);
                CurrentAccuracy = Settings.SplitTimesAccuracy;
            }
            if (Settings.DeltasAccuracy != CurrentDeltaAccuracy || Settings.DropDecimals != CurrentDropDecimals)
            {
                DeltaTimeFormatter   = new GradedDeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals);
                CurrentDeltaAccuracy = Settings.DeltasAccuracy;
                CurrentDropDecimals  = Settings.DropDecimals;
            }

            foreach (var label in LabelsList)
            {
                label.ShadowColor  = state.LayoutSettings.ShadowsColor;
                label.OutlineColor = state.LayoutSettings.TextOutlineColor;
                label.Y            = 0;
                label.Height       = height;
            }
            MinimumWidth = 10f;

            if (ColumnsList.Count() == LabelsList.Count)
            {
                var curX = width - 7;
                foreach (var label in LabelsList.Reverse())
                {
                    var column = ColumnsList.ElementAt(LabelsList.IndexOf(label));

                    var labelWidth = 0f;
                    if (column.Type == GradedColumnType.DeltaorSplitTime || column.Type == GradedColumnType.SegmentDeltaorSegmentTime)
                    {
                        labelWidth = Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth);
                    }
                    else if (column.Type == GradedColumnType.Delta || column.Type == GradedColumnType.SegmentDelta)
                    {
                        labelWidth = MeasureDeltaLabel.ActualWidth;
                    }
                    else
                    {
                        labelWidth = MeasureTimeLabel.ActualWidth;
                    }
                    curX       -= labelWidth + 5;
                    label.Width = labelWidth;
                    label.X     = curX + 5;

                    label.Font      = state.LayoutSettings.TextFont;
                    label.HasShadow = state.LayoutSettings.DropShadows;
                    label.Draw(g);
                }
            }
        }
Ejemplo n.º 4
0
        private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            if (NeedUpdateAll)
            {
                UpdateAll(state);
            }

            var splitIndex = state.Run.IndexOf(Split);

            if (Settings.BackgroundGradient == GradedExtendedGradientType.Alternating)
            {
                g.FillRectangle(new SolidBrush(
                                    splitIndex % 2 + (Settings.ShowColumnLabels ? 1 : 0) == 1
                    ? Settings.BackgroundColor2
                    : Settings.BackgroundColor
                                    ), 0, 0, width, height);
            }

            MeasureTimeLabel.Text  = TimeFormatter.Format(new TimeSpan(24, 0, 0));
            MeasureDeltaLabel.Text = DeltaTimeFormatter.Format(new TimeSpan(0, 9, 0, 0));

            MeasureTimeLabel.Font          = state.LayoutSettings.TimesFont;
            MeasureTimeLabel.IsMonospaced  = true;
            MeasureDeltaLabel.Font         = state.LayoutSettings.TimesFont;
            MeasureDeltaLabel.IsMonospaced = true;

            MeasureTimeLabel.SetActualWidth(g);
            MeasureDeltaLabel.SetActualWidth(g);

            NameLabel.ShadowColor  = state.LayoutSettings.ShadowsColor;
            NameLabel.OutlineColor = state.LayoutSettings.TextOutlineColor;
            foreach (var label in LabelsList)
            {
                label.ShadowColor  = state.LayoutSettings.ShadowsColor;
                label.OutlineColor = state.LayoutSettings.TextOutlineColor;
            }

            if (Settings.SplitTimesAccuracy != CurrentAccuracy)
            {
                TimeFormatter   = new GradedRegularSplitTimeFormatter(Settings.SplitTimesAccuracy);
                CurrentAccuracy = Settings.SplitTimesAccuracy;
            }
            if (Settings.DeltasAccuracy != CurrentDeltaAccuracy || Settings.DropDecimals != CurrentDropDecimals)
            {
                DeltaTimeFormatter   = new GradedDeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals);
                CurrentDeltaAccuracy = Settings.DeltasAccuracy;
                CurrentDropDecimals  = Settings.DropDecimals;
            }

            if (Split != null)
            {
                if (mode == LayoutMode.Vertical)
                {
                    NameLabel.VerticalAlignment = StringAlignment.Center;
                    NameLabel.Y      = 0;
                    NameLabel.Height = height;
                    foreach (var label in LabelsList)
                    {
                        label.VerticalAlignment = StringAlignment.Center;
                        label.Y      = 0;
                        label.Height = height;
                    }
                }
                else
                {
                    NameLabel.VerticalAlignment = StringAlignment.Near;
                    NameLabel.Y      = 0;
                    NameLabel.Height = 50;
                    foreach (var label in LabelsList)
                    {
                        label.VerticalAlignment = StringAlignment.Far;
                        label.Y      = height - 50;
                        label.Height = 50;
                    }
                }

                if (IsActive)
                {
                    var currentSplitBrush = new LinearGradientBrush(
                        new PointF(0, 0),
                        Settings.CurrentSplitGradient == GradientType.Horizontal
                        ? new PointF(width, 0)
                        : new PointF(0, height),
                        Settings.CurrentSplitTopColor,
                        Settings.CurrentSplitGradient == GradientType.Plain
                        ? Settings.CurrentSplitTopColor
                        : Settings.CurrentSplitBottomColor);
                    g.FillRectangle(currentSplitBrush, 0, 0, width, height);
                }

                bool customizedImage;
                var  icon = GetIcon(state, splitIndex, out customizedImage);

                if (DisplayIcon && icon != null)
                {
                    Image shadow;
                    if (customizedImage)
                    {
                        if (!CustomShadowImages.TryGetValue(icon, out shadow))
                        {
                            shadow = IconShadow.Generate(icon, state.LayoutSettings.ShadowsColor);
                            CustomShadowImages.Add(icon, shadow);
                        }
                    }
                    else
                    {
                        shadow = ShadowImage;
                    }

                    if (OldImage != icon)
                    {
                        ImageAnimator.Animate(icon, (s, o) => { });
                        ImageAnimator.Animate(shadow, (s, o) => { });
                        OldImage = icon;
                    }

                    var drawWidth    = Settings.IconSize;
                    var drawHeight   = Settings.IconSize;
                    var shadowWidth  = Settings.IconSize * (5 / 4f);
                    var shadowHeight = Settings.IconSize * (5 / 4f);
                    if (icon.Width > icon.Height)
                    {
                        var ratio = icon.Height / (float)icon.Width;
                        drawHeight   *= ratio;
                        shadowHeight *= ratio;
                    }
                    else
                    {
                        var ratio = icon.Width / (float)icon.Height;
                        drawWidth   *= ratio;
                        shadowWidth *= ratio;
                    }

                    ImageAnimator.UpdateFrames(shadow);
                    if (Settings.IconShadows && shadow != null)
                    {
                        g.DrawImage(
                            shadow,
                            7 + (Settings.IconSize * (5 / 4f) - shadowWidth) / 2 - 0.7f,
                            (height - Settings.IconSize) / 2.0f + (Settings.IconSize * (5 / 4f) - shadowHeight) / 2 - 0.7f,
                            shadowWidth,
                            shadowHeight);
                    }

                    ImageAnimator.UpdateFrames(icon);

                    g.DrawImage(
                        icon,
                        7 + (Settings.IconSize - drawWidth) / 2,
                        (height - Settings.IconSize) / 2.0f + (Settings.IconSize - drawHeight) / 2,
                        drawWidth,
                        drawHeight);
                }

                NameLabel.Font      = state.LayoutSettings.TextFont;
                NameLabel.X         = 5 + IconWidth;
                NameLabel.HasShadow = state.LayoutSettings.DropShadows;

                if (ColumnsList.Count() == LabelsList.Count)
                {
                    var curX  = width - 7;
                    var nameX = width - 7;
                    foreach (var label in LabelsList.Reverse())
                    {
                        var column = ColumnsList.ElementAt(LabelsList.IndexOf(label));

                        var labelWidth = 0f;
                        if (column.Type == GradedColumnType.DeltaorSplitTime || column.Type == GradedColumnType.SegmentDeltaorSegmentTime)
                        {
                            labelWidth = Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth);
                        }
                        else if (column.Type == GradedColumnType.Delta || column.Type == GradedColumnType.SegmentDelta)
                        {
                            labelWidth = MeasureDeltaLabel.ActualWidth;
                        }
                        else
                        {
                            labelWidth = MeasureTimeLabel.ActualWidth;
                        }
                        label.Width = labelWidth + 20;
                        curX       -= labelWidth + 5;
                        label.X     = curX - 15;

                        label.Font         = state.LayoutSettings.TimesFont;
                        label.HasShadow    = state.LayoutSettings.DropShadows;
                        label.IsMonospaced = true;
                        label.Draw(g);

                        if (!string.IsNullOrEmpty(label.Text))
                        {
                            nameX = curX + labelWidth + 5 - label.ActualWidth;
                        }
                    }
                    NameLabel.Width = (mode == LayoutMode.Horizontal ? width - 10 : nameX) - IconWidth;
                    NameLabel.Draw(g);
                }
            }
            else
            {
                DisplayIcon = Settings.DisplayIcons;
            }
        }