public RaceLabels(RaceComponent component, int index, RaceSettings settings, RaceSplit split) { Parent = component; RaceIndex = index; Split = split; Settings = settings; MinimumHeight = 10; VerticalHeight = 31; TimeFormatter = new RegularSplitTimeFormatter(Settings.Accuracy); DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.Accuracy, false); Cache = new GraphicsCache(); RacerName = new SimpleLabel() { HorizontalAlignment = StringAlignment.Near, VerticalAlignment = StringAlignment.Near }; RacerSplit = new SimpleLabel() { HorizontalAlignment = StringAlignment.Near, VerticalAlignment = StringAlignment.Far }; RacerTime = new SimpleLabel() { HorizontalAlignment = StringAlignment.Far, VerticalAlignment = StringAlignment.Far }; RacerDelta = new SimpleLabel() { HorizontalAlignment = StringAlignment.Far, VerticalAlignment = StringAlignment.Near }; }
private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode) { if (Settings.BackgroundGradient == ExtendedGradientType.Alternating) { g.FillRectangle(new SolidBrush((RaceIndex & 1) == 0 ? Settings.BackgroundColor2 : Settings.BackgroundColor), 0, 0, width, height); } if (Settings.Accuracy != CurrentAccuracy) { TimeFormatter = new RegularSplitTimeFormatter(Settings.Accuracy); DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.Accuracy, false); CurrentAccuracy = Settings.Accuracy; } VerticalHeight = 1.9f * g.MeasureString("A", RacerName.Font).Height; RacerName.SetActualWidth(g); RacerName.ShadowColor = state.LayoutSettings.ShadowsColor; RacerName.Y = 0; RacerName.X = 0; RacerName.Height = height; RacerName.Width = width; RacerName.Font = state.LayoutSettings.TextFont; RacerName.HasShadow = state.LayoutSettings.DropShadows; RacerName.Draw(g); RacerSplit.SetActualWidth(g); RacerSplit.ShadowColor = state.LayoutSettings.ShadowsColor; RacerSplit.Y = 0; RacerSplit.X = 0; RacerSplit.Height = height; RacerSplit.Width = width; RacerSplit.Font = state.LayoutSettings.TextFont; RacerSplit.HasShadow = state.LayoutSettings.DropShadows; RacerSplit.Draw(g); RacerTime.SetActualWidth(g); RacerTime.ShadowColor = state.LayoutSettings.ShadowsColor; RacerTime.Y = 0; RacerTime.X = 0; RacerTime.Height = height; RacerTime.Width = width; RacerTime.Font = state.LayoutSettings.TextFont; RacerTime.HasShadow = state.LayoutSettings.DropShadows; RacerTime.Draw(g); RacerDelta.SetActualWidth(g); RacerDelta.ShadowColor = state.LayoutSettings.ShadowsColor; RacerDelta.Y = 0; RacerDelta.X = 0; RacerDelta.Height = height; RacerDelta.Width = width; RacerDelta.Font = state.LayoutSettings.TextFont; RacerDelta.HasShadow = state.LayoutSettings.DropShadows; RacerDelta.Draw(g); MinimumWidth = 200f; }
public LabelsComponent(SplitsSettings settings, IEnumerable <ColumnData> columns) { Settings = settings; MinimumHeight = 31; MeasureTimeLabel = new SimpleLabel(); MeasureDeltaLabel = new SimpleLabel(); TimeFormatter = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy); DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals); Cache = new GraphicsCache(); LabelsList = new List <SimpleLabel>(); ColumnsList = columns; }
public SplitComponent(SplitsSettings settings) { NoIconShadow = IconShadow.Generate(NoIconImage, Color.Black); NameLabel = new SimpleLabel() { HorizontalAlignment = StringAlignment.Near, X = 8, }; MeasureTimeLabel = new SimpleLabel(); MeasureDeltaLabel = new SimpleLabel(); Settings = settings; TimeFormatter = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy); DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals); MinimumHeight = 31; NeedUpdateAll = true; IsActive = false; Cache = new GraphicsCache(); LabelsList = new List <SimpleLabel>(); }
public SplitComponent(SplitsSettings settings, IEnumerable <ColumnData> columnsList) { NameLabel = new SimpleLabel() { HorizontalAlignment = StringAlignment.Near, X = 8, }; MeasureTimeLabel = new SimpleLabel(); MeasureDeltaLabel = new SimpleLabel(); Settings = settings; ColumnsList = columnsList; TimeFormatter = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy); DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals); MinimumHeight = 31; NeedUpdateAll = true; IsActive = false; Cache = new GraphicsCache(); LabelsList = new List <SimpleLabel>(); }
private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode) { if (Settings.BackgroundGradient == ExtendedGradientType.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 RegularSplitTimeFormatter(Settings.SplitTimesAccuracy); CurrentAccuracy = Settings.SplitTimesAccuracy; } if (Settings.DeltasAccuracy != CurrentDeltaAccuracy || Settings.DropDecimals != CurrentDropDecimals) { DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals); CurrentDeltaAccuracy = Settings.DeltasAccuracy; CurrentDropDecimals = Settings.DropDecimals; } foreach (var label in LabelsList) { label.ShadowColor = state.LayoutSettings.ShadowsColor; 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 == ColumnType.DeltaorSplitTime || column.Type == ColumnType.SegmentDeltaorSegmentTime) { labelWidth = Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth); } else if (column.Type == ColumnType.Delta || column.Type == ColumnType.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); } } }
private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode) { if (NeedUpdateAll) { UpdateAll(state); } if (Settings.BackgroundGradient == ExtendedGradientType.Alternating) { g.FillRectangle(new SolidBrush( state.Run.IndexOf(Split) % 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; foreach (var label in LabelsList) { label.SetActualWidth(g); label.ShadowColor = state.LayoutSettings.ShadowsColor; } MinimumWidth = CalculateLabelsWidth() + IconWidth + 10; MinimumHeight = 0.85f * (g.MeasureString("A", state.LayoutSettings.TimesFont).Height + g.MeasureString("A", state.LayoutSettings.TextFont).Height); if (Settings.SplitTimesAccuracy != CurrentAccuracy) { TimeFormatter = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy); CurrentAccuracy = Settings.SplitTimesAccuracy; } if (Settings.DeltasAccuracy != CurrentDeltaAccuracy || Settings.DropDecimals != CurrentDropDecimals) { DeltaTimeFormatter = new DeltaSplitTimeFormatter(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); } if (DisplayIcon) { var icon = Split.Icon ?? NoIconImage; var shadow = (Split.Icon != null) ? ShadowImage : NoIconShadow; /*if (DateTime.Now.Date.Month == 4 && DateTime.Now.Date.Day == 1) * { * icon = LiveSplit.Web.Share.TwitchEmoteResolver.Resolve("Kappa", true, false, false); * shadow = null; * }*/ 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 == ColumnType.DeltaorSplitTime || column.Type == ColumnType.SegmentDeltaorSegmentTime) { labelWidth = Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth); } else if (column.Type == ColumnType.Delta || column.Type == ColumnType.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; } }