From fe72d11697784efe1a5d528f47a1a0d0adabe94b Mon Sep 17 00:00:00 2001 From: mq1n Date: Sun, 8 Jan 2017 20:09:50 +0300 Subject: [PATCH] Added auto skip button Here is explain: https://www.youtube.com/watch?v=rtUb9gMWR54 Added support for it. --- Source/IdleMaster/frmMain.Designer.cs | 13 ++++++++ Source/IdleMaster/frmMain.cs | 44 +++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/Source/IdleMaster/frmMain.Designer.cs b/Source/IdleMaster/frmMain.Designer.cs index 94fcba68..16aa6483 100644 --- a/Source/IdleMaster/frmMain.Designer.cs +++ b/Source/IdleMaster/frmMain.Designer.cs @@ -85,6 +85,7 @@ private void InitializeComponent() this.Hours = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.lblHoursPlayed = new System.Windows.Forms.Label(); this.tmrStatistics = new System.Windows.Forms.Timer(this.components); + this.checkBoxSkipAuto = new System.Windows.Forms.CheckBox(); this.mnuTop.SuspendLayout(); this.ssFooter.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picReadingPage)).BeginInit(); @@ -539,12 +540,23 @@ private void InitializeComponent() this.tmrStatistics.Interval = 60000; this.tmrStatistics.Tick += new System.EventHandler(this.tmrStatistics_Tick); // + // checkBoxSkipAuto + // + this.checkBoxSkipAuto.AutoSize = true; + this.checkBoxSkipAuto.Location = new System.Drawing.Point(274, 115); + this.checkBoxSkipAuto.Name = "checkBoxSkipAuto"; + this.checkBoxSkipAuto.Size = new System.Drawing.Size(15, 14); + this.checkBoxSkipAuto.TabIndex = 30; + this.checkBoxSkipAuto.UseVisualStyleBackColor = true; + this.checkBoxSkipAuto.CheckedChanged += new System.EventHandler(this.checkBoxSkipAuto_CheckedChanged); + // // frmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Control; this.ClientSize = new System.Drawing.Size(304, 339); + this.Controls.Add(this.checkBoxSkipAuto); this.Controls.Add(this.lblHoursPlayed); this.Controls.Add(this.GamesState); this.Controls.Add(this.lblSignedOnAs); @@ -644,6 +656,7 @@ private void InitializeComponent() private Label lblHoursPlayed; private Timer tmrStatistics; private ToolStripMenuItem statisticsToolStripMenuItem; + private CheckBox checkBoxSkipAuto; } } diff --git a/Source/IdleMaster/frmMain.cs b/Source/IdleMaster/frmMain.cs index 37f4ee66..23605920 100644 --- a/Source/IdleMaster/frmMain.cs +++ b/Source/IdleMaster/frmMain.cs @@ -35,6 +35,8 @@ public IEnumerable CanIdleBadges public int TimeLeft = 900; public int RetryCount = 0; public int ReloadCount = 0; + public int skipType = 900; + public bool skipEnabled = false; public int CardsRemaining { get { return CanIdleBadges.Sum(b => b.RemainingCard); } } public int GamesRemaining { get { return CanIdleBadges.Count(); } } public Badge CurrentBadge; @@ -290,7 +292,16 @@ public void StartSoloIdle(Badge badge) tmrCardDropCheck.Enabled = true; // Reset the timer - TimeLeft = CurrentBadge.RemainingCard == 1 ? 300 : 900; + if (CurrentBadge.RemainingCard == 1) + { + skipType = 300; + TimeLeft = 300; + } + else + { + skipType = 900; + TimeLeft = 900; + } // Set the correct buttons on the form for pause / resume btnResume.Visible = false; @@ -552,8 +563,17 @@ public async Task CheckCardDrops(Badge badge) else { // Resets the clock based on the number of remaining drops - TimeLeft = badge.RemainingCard == 1 ? 300 : 900; - } + if (badge.RemainingCard == 1) + { + skipType = 300; + TimeLeft = 300; + } + else + { + skipType = 900; + TimeLeft = 900; + } + } lblCurrentRemaining.Text = badge.RemainingCard + " " + localization.strings.card_drops_remaining; pbIdle.Value = pbIdle.Maximum - badge.RemainingCard; @@ -863,7 +883,10 @@ private async void tmrCardDropCheck_Tick(object sender, EventArgs e) isMultipleIdle = CanIdleBadges.Any(b => b.HoursPlayed < 2 && b.InIdle); if (isMultipleIdle) + { + skipType = 360; TimeLeft = 360; + } } // Check if user is authenticated and if any badge left to idle @@ -873,6 +896,16 @@ private async void tmrCardDropCheck_Tick(object sender, EventArgs e) else { TimeLeft = TimeLeft - 1; + if (skipEnabled) + { + if ( (skipType == 360 && TimeLeft < 355) || + (skipType == 300 && TimeLeft < 295) || + (skipType == 900 && TimeLeft < 895) + ) + btnSkip.PerformClick(); + } + + lblTimer.Text = TimeSpan.FromSeconds(TimeLeft).ToString(@"mm\:ss"); } } @@ -1049,5 +1082,10 @@ private void tmrStatistics_Tick(object sender, EventArgs e) statistics.increaseMinutesIdled(); statistics.checkCardRemaining((uint)CardsRemaining); } + + private void checkBoxSkipAuto_CheckedChanged(object sender, EventArgs e) + { + skipEnabled = checkBoxSkipAuto.Checked; + } } } \ No newline at end of file