Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to align the timer to the left #8

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions UI/Components/Timer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,19 @@ public void DrawUnscaled(Graphics g, LiveSplitState state, float width, float he
var smallAscent = smallSizeMultiplier * smallFont.FontFamily.GetCellAscent(smallFont.Style);
var shift = (height - ascent - descent) / 2f;

BigTextLabel.X = width - 499 - SmallTextLabel.ActualWidth;
SmallTextLabel.X = width - SmallTextLabel.ActualWidth - 6;
if (Settings.AlignLeft)
{
BigTextLabel.X = 0;
SmallTextLabel.X = 0 + BigTextLabel.ActualWidth;
BigTextLabel.HorizontalAlignment = StringAlignment.Near;
}
else
{
BigTextLabel.X = width - 499 - SmallTextLabel.ActualWidth;
SmallTextLabel.X = width - SmallTextLabel.ActualWidth - 6;
BigTextLabel.HorizontalAlignment = StringAlignment.Far;
}

BigTextLabel.Y = shift;
SmallTextLabel.Y = shift + ascent - smallAscent;
BigTextLabel.Height = 150f;
Expand Down
15 changes: 15 additions & 0 deletions UI/Components/TimerSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions UI/Components/TimerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ private string timerFormat
public bool OverrideSplitColors { get; set; }

public bool CenterTimer { get; set; }

public bool AlignLeft { get; set; }

public bool ShowGradient { get; set; }

Expand Down Expand Up @@ -82,6 +84,7 @@ public TimerSettings()
btnColor1.DataBindings.Add("BackColor", this, "BackgroundColor", false, DataSourceUpdateMode.OnPropertyChanged);
btnColor2.DataBindings.Add("BackColor", this, "BackgroundColor2", false, DataSourceUpdateMode.OnPropertyChanged);
chkCenterTimer.DataBindings.Add("Checked", this, "CenterTimer", false, DataSourceUpdateMode.OnPropertyChanged);
chkAlignTimerLeft.DataBindings.Add("Checked", this, "AlignLeft", false, DataSourceUpdateMode.OnPropertyChanged);
cmbTimingMethod.DataBindings.Add("SelectedItem", this, "TimingMethod", false, DataSourceUpdateMode.OnPropertyChanged);
trkDecimalsSize.DataBindings.Add("Value", this, "DecimalsSize", false, DataSourceUpdateMode.OnPropertyChanged);
cmbDigitsFormat.DataBindings.Add("SelectedItem", this, "DigitsFormat", false, DataSourceUpdateMode.OnPropertyChanged);
Expand Down Expand Up @@ -174,6 +177,7 @@ public void SetSettings(XmlNode node)
BackgroundColor2 = SettingsHelper.ParseColor(element["BackgroundColor2"], Color.Transparent);
GradientString = SettingsHelper.ParseString(element["BackgroundGradient"], DeltasGradientType.Plain.ToString());
CenterTimer = SettingsHelper.ParseBool(element["CenterTimer"], false);
AlignLeft = SettingsHelper.ParseBool(element["AlignLeft"], false);
TimingMethod = SettingsHelper.ParseString(element["TimingMethod"], "Current Timing Method");

if (version >= new Version(1, 3))
Expand Down Expand Up @@ -231,6 +235,7 @@ private int CreateSettingsNode(XmlDocument document, XmlElement parent)
SettingsHelper.CreateSetting(document, parent, "BackgroundColor2", BackgroundColor2) ^
SettingsHelper.CreateSetting(document, parent, "BackgroundGradient", BackgroundGradient) ^
SettingsHelper.CreateSetting(document, parent, "CenterTimer", CenterTimer) ^
SettingsHelper.CreateSetting(document, parent, "AlignLeft", AlignLeft) ^
SettingsHelper.CreateSetting(document, parent, "TimingMethod", TimingMethod) ^
SettingsHelper.CreateSetting(document, parent, "DecimalsSize", DecimalsSize);
}
Expand Down