From ef54790c973cc8e586f7520f71c0a4d3e38ab292 Mon Sep 17 00:00:00 2001 From: cartersoft Date: Fri, 10 Jun 2022 16:30:42 +0100 Subject: [PATCH 1/2] boilerplate and gitignore updates --- .gitignore | 288 +++++++++++++++--- LiveSplit.RunCounter.sln | 25 ++ .../LiveSplit.RunCounter.csproj | 54 ++++ .../Properties/AssemblyInfo.cs | 36 +++ .../UI/Components/RunCounterComponent.cs | 89 ++++++ 5 files changed, 446 insertions(+), 46 deletions(-) create mode 100644 LiveSplit.RunCounter.sln create mode 100644 LiveSplit.RunCounter/LiveSplit.RunCounter.csproj create mode 100644 LiveSplit.RunCounter/Properties/AssemblyInfo.cs create mode 100644 LiveSplit.RunCounter/UI/Components/RunCounterComponent.cs diff --git a/.gitignore b/.gitignore index c6127b3..7e17356 100644 --- a/.gitignore +++ b/.gitignore @@ -1,52 +1,248 @@ -# Prerequisites -*.d +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. -# Object files -*.o -*.ko -*.obj -*.elf +# User-specific files +*.suo +*.user +*.sln.docstates +*.userprefs -# Linker output -*.ilk -*.map -*.exp +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +# x64/ +# x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +Builds/ -# Precompiled Headers -*.gch -*.pch +#SVN Stuff +.svn/ + +#API +API/ + +#Website +Website/ + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb +#NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch *.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# If using the old MSBuild-Integrated Package Restore, uncomment this: +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf +# Windows Installer files +*.cab +*.msi +*.msm +*.msp +*.dropbox +.dropbox.attr +LiveSplit/LiveSplit.Core/Updates/GitInfo/branch.txt +LiveSplit/LiveSplit.Core/Updates/GitInfo/version.txt +LiveSplit/LiveSplit.Core/Updates/GitInfo/revision.txt +.vs \ No newline at end of file diff --git a/LiveSplit.RunCounter.sln b/LiveSplit.RunCounter.sln new file mode 100644 index 0000000..b13aa9c --- /dev/null +++ b/LiveSplit.RunCounter.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1972 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveSplit.RunCounter", "LiveSplit.RunCounter\LiveSplit.RunCounter.csproj", "{688643C5-F171-48B0-87F7-AD6BA19EE7D8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {688643C5-F171-48B0-87F7-AD6BA19EE7D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {688643C5-F171-48B0-87F7-AD6BA19EE7D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {688643C5-F171-48B0-87F7-AD6BA19EE7D8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {688643C5-F171-48B0-87F7-AD6BA19EE7D8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EB1F0D80-09C3-4CF0-8E55-1E04E8CD6427} + EndGlobalSection +EndGlobal diff --git a/LiveSplit.RunCounter/LiveSplit.RunCounter.csproj b/LiveSplit.RunCounter/LiveSplit.RunCounter.csproj new file mode 100644 index 0000000..54a70b0 --- /dev/null +++ b/LiveSplit.RunCounter/LiveSplit.RunCounter.csproj @@ -0,0 +1,54 @@ + + + + + Debug + AnyCPU + 688643c5-f171-48b0-87f7-ad6ba19ee7d8 + Library + Properties + LiveSplit.RunCounter + LiveSplit.RunCounter + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LiveSplit.RunCounter/Properties/AssemblyInfo.cs b/LiveSplit.RunCounter/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..46e77d3 --- /dev/null +++ b/LiveSplit.RunCounter/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("LiveSplit.RunCounter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LiveSplit.RunCounter")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("688643c5-f171-48b0-87f7-ad6ba19ee7d8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/LiveSplit.RunCounter/UI/Components/RunCounterComponent.cs b/LiveSplit.RunCounter/UI/Components/RunCounterComponent.cs new file mode 100644 index 0000000..aea19d8 --- /dev/null +++ b/LiveSplit.RunCounter/UI/Components/RunCounterComponent.cs @@ -0,0 +1,89 @@ +using LiveSplit.Model; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Linq; +using System.Windows.Forms; + +namespace LiveSplit.UI.Components +{ + public class RunCounterComponent : IComponent + { + protected InfoTextComponent InternalComponent { get; set; } + public RunCounterSettings Settings { get; set; } + protected LiveSplitState CurrentState { get; set; } + public string ComponentName => "Run Counter"; + + public float HorizontalWidth => InternalComponent.HorizontalWidth; + public float MinimumWidth => InternalComponent.MinimumWidth; + public float VerticalHeight => InternalComponent.VerticalHeight; + public float MinimumHeight => InternalComponent.MinimumHeight; + + public float PaddingTop => InternalComponent.PaddingTop; + public float PaddingLeft => InternalComponent.PaddingLeft; + public float PaddingBottom => InternalComponent.PaddingBottom; + public float PaddingRight => InternalComponent.PaddingRight; + + public IDictionary ContextMenuControls => null; + + public RunCounterComponent(LiveSplitState state) + { + + } + + public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) + { + InternalComponent.NameLabel.HasShadow + = InternalComponent.ValueLabel.HasShadow + = state.LayoutSettings.DropShadows; + + InternalComponent.NameLabel.ForeColor = state.LayoutSettings.TextColor; + InternalComponent.ValueLabel.ForeColor = state.LayoutSettings.TextColor; + + InternalComponent.DrawHorizontal(g, state, height, clipRegion); + } + + public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion) + { + InternalComponent.DisplayTwoRows = Settings.Display2Rows; + + InternalComponent.NameLabel.HasShadow + = InternalComponent.ValueLabel.HasShadow + = state.LayoutSettings.DropShadows; + + InternalComponent.NameLabel.ForeColor = state.LayoutSettings.TextColor; + InternalComponent.ValueLabel.ForeColor = state.LayoutSettings.TextColor; + + InternalComponent.DrawVertical(g, state, width, clipRegion); + } + + public Control GetSettingsControl(LayoutMode mode) + { + Settings.Mode = mode; + return Settings; + } + + public System.Xml.XmlNode GetSettings(System.Xml.XmlDocument document) + { + return Settings.GetSettings(document); + } + + public void SetSettings(System.Xml.XmlNode settings) + { + Settings.SetSettings(settings); + } + + public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) + { + + } + + public void Dispose() + { + + } + + public int GetSettingsHashCode() => Settings.GetSettingsHashCode(); + } +} From 97bfddebee55add6ae00ff03641df5a592c4780d Mon Sep 17 00:00:00 2001 From: cartersoft Date: Fri, 10 Jun 2022 17:47:20 +0100 Subject: [PATCH 2/2] Created the first hit of the plugin --- LiveSplit.RunCounter.sln | 19 +++ .../LiveSplit.RunCounter.csproj | 54 +++++--- .../Properties/AssemblyInfo.cs | 2 + .../UI/Components/RunCounterComponent.cs | 69 +++++++++- .../UI/Components/RunCounterFactory.cs | 17 +++ .../Components/RunCounterSettings.Designer.cs | 84 ++++++++++++ .../UI/Components/RunCounterSettings.cs | 59 +++++++++ .../UI/Components/RunCounterSettings.resx | 120 ++++++++++++++++++ 8 files changed, 404 insertions(+), 20 deletions(-) create mode 100644 LiveSplit.RunCounter/UI/Components/RunCounterFactory.cs create mode 100644 LiveSplit.RunCounter/UI/Components/RunCounterSettings.Designer.cs create mode 100644 LiveSplit.RunCounter/UI/Components/RunCounterSettings.cs create mode 100644 LiveSplit.RunCounter/UI/Components/RunCounterSettings.resx diff --git a/LiveSplit.RunCounter.sln b/LiveSplit.RunCounter.sln index b13aa9c..f59e005 100644 --- a/LiveSplit.RunCounter.sln +++ b/LiveSplit.RunCounter.sln @@ -5,16 +5,35 @@ VisualStudioVersion = 15.0.28307.1972 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveSplit.RunCounter", "LiveSplit.RunCounter\LiveSplit.RunCounter.csproj", "{688643C5-F171-48B0-87F7-AD6BA19EE7D8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveSplit.Core", "..\LiveSplit\LiveSplit\LiveSplit.Core\LiveSplit.Core.csproj", "{6DE847DB-20A3-4848-AEEE-1B4364AECDFB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateManager", "..\LiveSplit\LiveSplit\UpdateManager\UpdateManager.csproj", "{56DEA3A0-2EB7-493B-B50F-A5E3AA8AE52A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Release Candidate|Any CPU = Release Candidate|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {688643C5-F171-48B0-87F7-AD6BA19EE7D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {688643C5-F171-48B0-87F7-AD6BA19EE7D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {688643C5-F171-48B0-87F7-AD6BA19EE7D8}.Release Candidate|Any CPU.ActiveCfg = Release|Any CPU + {688643C5-F171-48B0-87F7-AD6BA19EE7D8}.Release Candidate|Any CPU.Build.0 = Release|Any CPU {688643C5-F171-48B0-87F7-AD6BA19EE7D8}.Release|Any CPU.ActiveCfg = Release|Any CPU {688643C5-F171-48B0-87F7-AD6BA19EE7D8}.Release|Any CPU.Build.0 = Release|Any CPU + {6DE847DB-20A3-4848-AEEE-1B4364AECDFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6DE847DB-20A3-4848-AEEE-1B4364AECDFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6DE847DB-20A3-4848-AEEE-1B4364AECDFB}.Release Candidate|Any CPU.ActiveCfg = Release Candidate|Any CPU + {6DE847DB-20A3-4848-AEEE-1B4364AECDFB}.Release Candidate|Any CPU.Build.0 = Release Candidate|Any CPU + {6DE847DB-20A3-4848-AEEE-1B4364AECDFB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6DE847DB-20A3-4848-AEEE-1B4364AECDFB}.Release|Any CPU.Build.0 = Release|Any CPU + {56DEA3A0-2EB7-493B-B50F-A5E3AA8AE52A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {56DEA3A0-2EB7-493B-B50F-A5E3AA8AE52A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {56DEA3A0-2EB7-493B-B50F-A5E3AA8AE52A}.Release Candidate|Any CPU.ActiveCfg = Release Candidate|Any CPU + {56DEA3A0-2EB7-493B-B50F-A5E3AA8AE52A}.Release Candidate|Any CPU.Build.0 = Release Candidate|Any CPU + {56DEA3A0-2EB7-493B-B50F-A5E3AA8AE52A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {56DEA3A0-2EB7-493B-B50F-A5E3AA8AE52A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/LiveSplit.RunCounter/LiveSplit.RunCounter.csproj b/LiveSplit.RunCounter/LiveSplit.RunCounter.csproj index 54a70b0..186b438 100644 --- a/LiveSplit.RunCounter/LiveSplit.RunCounter.csproj +++ b/LiveSplit.RunCounter/LiveSplit.RunCounter.csproj @@ -1,10 +1,10 @@ - + Debug AnyCPU - 688643c5-f171-48b0-87f7-ad6ba19ee7d8 + {688643C5-F171-48B0-87F7-AD6BA19EE7D8} Library Properties LiveSplit.RunCounter @@ -31,24 +31,42 @@ 4 - - - - - - - - - - - - - - + + + + + + + + + + - + + + + UserControl + + + RunCounterSettings.cs + + + + + {6de847db-20a3-4848-aeee-1b4364aecdfb} + LiveSplit.Core + + + {56dea3a0-2eb7-493b-b50f-a5e3aa8ae52a} + UpdateManager + + + + + RunCounterSettings.cs + - + \ No newline at end of file diff --git a/LiveSplit.RunCounter/Properties/AssemblyInfo.cs b/LiveSplit.RunCounter/Properties/AssemblyInfo.cs index 46e77d3..3e4a1f5 100644 --- a/LiveSplit.RunCounter/Properties/AssemblyInfo.cs +++ b/LiveSplit.RunCounter/Properties/AssemblyInfo.cs @@ -1,6 +1,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using LiveSplit.UI.Components; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information @@ -34,3 +35,4 @@ // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ComponentFactory(typeof(RunCounterFactory))] diff --git a/LiveSplit.RunCounter/UI/Components/RunCounterComponent.cs b/LiveSplit.RunCounter/UI/Components/RunCounterComponent.cs index aea19d8..5fdfe4a 100644 --- a/LiveSplit.RunCounter/UI/Components/RunCounterComponent.cs +++ b/LiveSplit.RunCounter/UI/Components/RunCounterComponent.cs @@ -12,8 +12,11 @@ public class RunCounterComponent : IComponent { protected InfoTextComponent InternalComponent { get; set; } public RunCounterSettings Settings { get; set; } + public GraphicsCache Cache { get; set; } protected LiveSplitState CurrentState { get; set; } public string ComponentName => "Run Counter"; + private int counterValue = 0; + private string counterField = "xx Runs: "; public float HorizontalWidth => InternalComponent.HorizontalWidth; public float MinimumWidth => InternalComponent.MinimumWidth; @@ -29,7 +32,10 @@ public class RunCounterComponent : IComponent public RunCounterComponent(LiveSplitState state) { - + Settings = new RunCounterSettings(); + Cache = new GraphicsCache(); + InternalComponent = new InfoTextComponent("xx Runs: ", "0"); + CurrentState = state; } public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) @@ -76,7 +82,10 @@ public void SetSettings(System.Xml.XmlNode settings) public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { - + string count = GetSimilarTimeCount(getPBTime()).ToString(); + InternalComponent.InformationName = counterField; + InternalComponent.InformationValue = counterValue >= 0 ? count : "?"; + InternalComponent.Update(invalidator, state, width, height, mode); } public void Dispose() @@ -85,5 +94,61 @@ public void Dispose() } public int GetSettingsHashCode() => Settings.GetSettingsHashCode(); + + + // Lets get the PB Time to track + private Attempt getPBTime() + { + var bestTime = TimeSpan.MaxValue; + int bestIndex = 0; + + if (CurrentState.Run.AttemptHistory.Count <= 0) + { + Attempt TempAttempt = new Attempt(); + TempAttempt.Index = 0; + return TempAttempt; + } + + foreach (Attempt attempt in CurrentState.Run.AttemptHistory) + { + if (attempt.Time[CurrentState.CurrentTimingMethod].HasValue) + { + if (attempt.Time[CurrentState.CurrentTimingMethod].Value < bestTime) + { + bestTime = attempt.Time[CurrentState.CurrentTimingMethod].Value; + bestIndex = attempt.Index; + } + } + } + + if (bestIndex == 0) + return CurrentState.Run.AttemptHistory[0]; + return CurrentState.Run.AttemptHistory[bestIndex - 1]; + } + + private int GetSimilarTimeCount(Attempt pbAttempt) + { + int tempCounter = 0; + string pbdays = pbAttempt.Duration.Value.Days.ToString(); // get the days (for really long pbs) + string pbhour = pbAttempt.Duration.Value.Hours.ToString(); // get the hour value (for long pbs) + string pbmin = pbAttempt.Duration.Value.Minutes.ToString(); // get the min value (for all pbs) + + counterField = pbhour + ":" + pbmin + ":xx Runs: "; + + foreach (Attempt attempt in CurrentState.Run.AttemptHistory) { + + // get the attempts that match the same hour and minuite barriers so that any game can use this + string tempd = attempt.Duration.Value.Days.ToString(); + string temph = attempt.Duration.Value.Hours.ToString(); + string tempm = attempt.Duration.Value.Minutes.ToString(); + + if (pbdays.Equals(tempd) && pbhour.Equals(temph) && pbmin.Equals(tempm)) + { + tempCounter++; + } + } + + return tempCounter; + } } } diff --git a/LiveSplit.RunCounter/UI/Components/RunCounterFactory.cs b/LiveSplit.RunCounter/UI/Components/RunCounterFactory.cs new file mode 100644 index 0000000..29ae825 --- /dev/null +++ b/LiveSplit.RunCounter/UI/Components/RunCounterFactory.cs @@ -0,0 +1,17 @@ +using LiveSplit.Model; +using System; + +namespace LiveSplit.UI.Components +{ + public class RunCounterFactory : IComponentFactory + { + public string ComponentName => "Run Counter"; + public string Description => "Displays the amount of similar run times you've had close to your pb (minute barriers)."; + public ComponentCategory Category => ComponentCategory.Information; + public IComponent Create(LiveSplitState state) => new RunCounterComponent(state); + public string UpdateName => ComponentName; + public string UpdateURL => ""; + public string XMLURL => UpdateURL + ""; + public Version Version => Version.Parse("1.0.0"); + } +} diff --git a/LiveSplit.RunCounter/UI/Components/RunCounterSettings.Designer.cs b/LiveSplit.RunCounter/UI/Components/RunCounterSettings.Designer.cs new file mode 100644 index 0000000..9d9a73f --- /dev/null +++ b/LiveSplit.RunCounter/UI/Components/RunCounterSettings.Designer.cs @@ -0,0 +1,84 @@ +namespace LiveSplit.UI.Components +{ + partial class RunCounterSettings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.topLevelLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.chkTwoRows = new System.Windows.Forms.CheckBox(); + this.topLevelLayoutPanel.SuspendLayout(); + this.SuspendLayout(); + // + // topLevelLayoutPanel + // + this.topLevelLayoutPanel.AutoSize = true; + this.topLevelLayoutPanel.ColumnCount = 1; + this.topLevelLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.topLevelLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.topLevelLayoutPanel.Controls.Add(this.chkTwoRows, 0, 0); + this.topLevelLayoutPanel.Location = new System.Drawing.Point(3, 3); + this.topLevelLayoutPanel.Name = "topLevelLayoutPanel"; + this.topLevelLayoutPanel.RowCount = 1; + this.topLevelLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.topLevelLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.topLevelLayoutPanel.Size = new System.Drawing.Size(200, 100); + this.topLevelLayoutPanel.TabIndex = 0; + // + // chkTwoRows + // + this.chkTwoRows.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.chkTwoRows.AutoSize = true; + this.chkTwoRows.Location = new System.Drawing.Point(3, 41); + this.chkTwoRows.Name = "chkTwoRows"; + this.chkTwoRows.Size = new System.Drawing.Size(194, 17); + this.chkTwoRows.TabIndex = 0; + this.chkTwoRows.Text = "Display 2 Rows"; + this.chkTwoRows.UseVisualStyleBackColor = true; + // + // RunCounterSettings + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.Controls.Add(this.topLevelLayoutPanel); + this.Name = "RunCounterSettings"; + this.Size = new System.Drawing.Size(206, 106); + this.Load += new System.EventHandler(this.RunCounterSettings_Load); + this.topLevelLayoutPanel.ResumeLayout(false); + this.topLevelLayoutPanel.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel topLevelLayoutPanel; + private System.Windows.Forms.CheckBox chkTwoRows; + } +} diff --git a/LiveSplit.RunCounter/UI/Components/RunCounterSettings.cs b/LiveSplit.RunCounter/UI/Components/RunCounterSettings.cs new file mode 100644 index 0000000..bdd8d1b --- /dev/null +++ b/LiveSplit.RunCounter/UI/Components/RunCounterSettings.cs @@ -0,0 +1,59 @@ +using System; +using System.Drawing; +using System.Windows.Forms; +using System.Xml; + +namespace LiveSplit.UI.Components +{ + public partial class RunCounterSettings : UserControl + { + public bool Display2Rows { get; set; } + public LayoutMode Mode { get; set; } + + public RunCounterSettings() + { + InitializeComponent(); + Display2Rows = false; + } + + private void RunCounterSettings_Load(object sender, EventArgs e) + { + if (Mode == LayoutMode.Horizontal) + { + chkTwoRows.Enabled = false; + chkTwoRows.DataBindings.Clear(); + chkTwoRows.Checked = true; + } + else + { + chkTwoRows.Enabled = true; + chkTwoRows.DataBindings.Clear(); + chkTwoRows.DataBindings.Add("Checked", this, "Display2Rows", false, DataSourceUpdateMode.OnPropertyChanged); + } + } + + private int CreateSettingsNode(XmlDocument document, XmlElement parent) + { + return SettingsHelper.CreateSetting(document, parent, "Version", "1.0") ^ + SettingsHelper.CreateSetting(document, parent, "Display2Rows", Display2Rows); + } + + public XmlNode GetSettings(XmlDocument document) + { + var parent = document.CreateElement("Settings"); + CreateSettingsNode(document, parent); + return parent; + } + + public int GetSettingsHashCode() + { + return CreateSettingsNode(null, null); + } + + public void SetSettings(XmlNode node) + { + var element = (XmlElement)node; + Display2Rows = SettingsHelper.ParseBool(element["Display2Rows"], false); + } + } +} diff --git a/LiveSplit.RunCounter/UI/Components/RunCounterSettings.resx b/LiveSplit.RunCounter/UI/Components/RunCounterSettings.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/LiveSplit.RunCounter/UI/Components/RunCounterSettings.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file