示例#1
0
        public void DrawGeneral(Graphics g, LiveSplitState state, float width, float height)
        {
            Timer.DrawBackground(g, InternalComponent.TimerColor, Settings.BackgroundColor, Settings.BackgroundColor2, width, height, Settings.BackgroundGradient);

            InternalComponent.Settings.ShowGradient        = Settings.TimerShowGradient;
            InternalComponent.Settings.OverrideSplitColors = Settings.OverrideTimerColors;
            InternalComponent.Settings.TimerColor          = Settings.TimerColor;
            InternalComponent.Settings.DigitsFormat        = Settings.DigitsFormat;
            InternalComponent.Settings.Accuracy            = Settings.Accuracy;
            InternalComponent.Settings.DecimalsSize        = Settings.DecimalsSize;
            AlternateTimer.Settings.ShowGradient           = Settings.AlternateTimerShowGradient;
            AlternateTimer.Settings.OverrideSplitColors    = true;
            AlternateTimer.Settings.TimerColor             = Settings.AlternateTimerColor;
            AlternateTimer.Settings.DigitsFormat           = Settings.AlternateDigitsFormat;
            AlternateTimer.Settings.Accuracy     = Settings.AlternateAccuracy;
            AlternateTimer.Settings.DecimalsSize = Settings.AlternateTimerDecimalsSize;
        }
示例#2
0
        public void DrawGeneral(Graphics g, LiveSplitState state, float width, float height)
        {
            Timer.DrawBackground(g, InternalComponent.TimerColor, Settings.BackgroundColor, Settings.BackgroundColor2, width, height, Settings.BackgroundGradient);

            var lastSplitOffset = state.CurrentSplitIndex == state.Run.Count ? -1 : 0;

            var originalDrawSize = Math.Min(Settings.IconSize, width - 14);
            var icon             = state.CurrentSplitIndex >= 0 ? state.Run[state.CurrentSplitIndex + lastSplitOffset].Icon : null;

            if (Settings.DisplayIcon && icon != null)
            {
                if (OldImage != icon)
                {
                    ImageAnimator.Animate(icon, (s, o) => { });
                    OldImage = icon;
                }
                var drawWidth  = originalDrawSize;
                var drawHeight = originalDrawSize;
                if (icon.Width > icon.Height)
                {
                    var ratio = icon.Height / (float)icon.Width;
                    drawHeight *= ratio;
                }
                else
                {
                    var ratio = icon.Width / (float)icon.Height;
                    drawWidth *= ratio;
                }

                ImageAnimator.UpdateFrames(icon);

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

                IconWidth = (int)(originalDrawSize + 7.5f);
            }
            else
            {
                IconWidth = 0;
            }

            InternalComponent.Settings.ShowGradient        = Settings.TimerShowGradient;
            InternalComponent.Settings.OverrideSplitColors = Settings.OverrideTimerColors;
            InternalComponent.Settings.TimerColor          = Settings.TimerColor;
            InternalComponent.Settings.DigitsFormat        = Settings.DigitsFormat;
            InternalComponent.Settings.Accuracy            = Settings.Accuracy;
            InternalComponent.Settings.DecimalsSize        = Settings.DecimalsSize;
            SegmentTimer.Settings.ShowGradient             = Settings.SegmentTimerShowGradient;
            SegmentTimer.Settings.OverrideSplitColors      = true;
            SegmentTimer.Settings.TimerColor   = Settings.SegmentTimerColor;
            SegmentTimer.Settings.DigitsFormat = Settings.SegmentDigitsFormat;
            SegmentTimer.Settings.Accuracy     = Settings.SegmentAccuracy;
            SegmentTimer.Settings.DecimalsSize = Settings.SegmentTimerDecimalsSize;

            if (state.CurrentSplitIndex >= 0)
            {
                var labelsFont = new Font(Settings.SegmentLabelsFont.FontFamily, Settings.SegmentLabelsFont.Size, Settings.SegmentLabelsFont.Style);
                var timesFont  = new Font(Settings.SegmentTimesFont.FontFamily, Settings.SegmentTimesFont.Size, Settings.SegmentTimesFont.Style);
                LabelSegment.Font   = labelsFont;
                LabelSegment.X      = 5 + IconWidth;
                LabelSegment.Y      = height * ((100f - Settings.SegmentTimerSizeRatio) / 100f);
                LabelSegment.Width  = width - SegmentTimer.ActualWidth - 5 - IconWidth;
                LabelSegment.Height = height * (Settings.SegmentTimerSizeRatio / 200f) * (!HideComparison ? 1f : 2f);
                LabelSegment.HorizontalAlignment = StringAlignment.Near;
                LabelSegment.VerticalAlignment   = StringAlignment.Center;
                LabelSegment.ForeColor           = Settings.SegmentLabelsColor;
                LabelSegment.HasShadow           = state.LayoutSettings.DropShadows;
                LabelSegment.ShadowColor         = state.LayoutSettings.ShadowsColor;
                LabelSegment.OutlineColor        = state.LayoutSettings.TextOutlineColor;
                if (Comparison != "None")
                {
                    LabelSegment.Draw(g);
                }

                LabelBest.Font   = labelsFont;
                LabelBest.X      = 5 + IconWidth;
                LabelBest.Y      = height * ((100f - Settings.SegmentTimerSizeRatio / 2f) / 100f);
                LabelBest.Width  = width - SegmentTimer.ActualWidth - 5 - IconWidth;
                LabelBest.Height = height * (Settings.SegmentTimerSizeRatio / 200f);
                LabelBest.HorizontalAlignment = StringAlignment.Near;
                LabelBest.VerticalAlignment   = StringAlignment.Center;
                LabelBest.ForeColor           = Settings.SegmentLabelsColor;
                LabelBest.HasShadow           = state.LayoutSettings.DropShadows;
                LabelBest.ShadowColor         = state.LayoutSettings.ShadowsColor;
                LabelBest.OutlineColor        = state.LayoutSettings.TextOutlineColor;
                if (!HideComparison)
                {
                    LabelBest.Draw(g);
                }

                var offset = Math.Max(LabelSegment.ActualWidth, HideComparison ? 0 : LabelBest.ActualWidth) + 10;

                if (Comparison != "None")
                {
                    SegmentTime.Font   = timesFont;
                    SegmentTime.X      = offset + IconWidth;
                    SegmentTime.Y      = height * ((100f - Settings.SegmentTimerSizeRatio) / 100f);
                    SegmentTime.Width  = width - SegmentTimer.ActualWidth - offset - IconWidth;
                    SegmentTime.Height = height * (Settings.SegmentTimerSizeRatio / 200f) * (!HideComparison ? 1f : 2f);
                    SegmentTime.HorizontalAlignment = StringAlignment.Near;
                    SegmentTime.VerticalAlignment   = StringAlignment.Center;
                    SegmentTime.ForeColor           = Settings.SegmentTimesColor;
                    SegmentTime.HasShadow           = state.LayoutSettings.DropShadows;
                    SegmentTime.ShadowColor         = state.LayoutSettings.ShadowsColor;
                    SegmentTime.OutlineColor        = state.LayoutSettings.TextOutlineColor;
                    SegmentTime.IsMonospaced        = true;
                    SegmentTime.Draw(g);
                }

                if (!HideComparison)
                {
                    BestSegmentTime.Font   = timesFont;
                    BestSegmentTime.X      = offset + IconWidth;
                    BestSegmentTime.Y      = height * ((100f - Settings.SegmentTimerSizeRatio / 2f) / 100f);
                    BestSegmentTime.Width  = width - SegmentTimer.ActualWidth - offset - IconWidth;
                    BestSegmentTime.Height = height * (Settings.SegmentTimerSizeRatio / 200f);
                    BestSegmentTime.HorizontalAlignment = StringAlignment.Near;
                    BestSegmentTime.VerticalAlignment   = StringAlignment.Center;
                    BestSegmentTime.ForeColor           = Settings.SegmentTimesColor;
                    BestSegmentTime.HasShadow           = state.LayoutSettings.DropShadows;
                    BestSegmentTime.ShadowColor         = state.LayoutSettings.ShadowsColor;
                    BestSegmentTime.OutlineColor        = state.LayoutSettings.TextOutlineColor;
                    BestSegmentTime.IsMonospaced        = true;
                    BestSegmentTime.Draw(g);
                }
                SplitName.Font   = Settings.SplitNameFont;
                SplitName.X      = IconWidth + 5;
                SplitName.Y      = 0;
                SplitName.Width  = width - InternalComponent.ActualWidth - IconWidth - 5;
                SplitName.Height = height * ((100f - Settings.SegmentTimerSizeRatio) / 100f);
                SplitName.HorizontalAlignment = StringAlignment.Near;
                SplitName.VerticalAlignment   = StringAlignment.Center;
                SplitName.ForeColor           = Settings.SplitNameColor;
                SplitName.HasShadow           = state.LayoutSettings.DropShadows;
                SplitName.ShadowColor         = state.LayoutSettings.ShadowsColor;
                SplitName.OutlineColor        = state.LayoutSettings.TextOutlineColor;
                if (Settings.ShowSplitName)
                {
                    SplitName.Draw(g);
                }
            }
        }