mirror of
https://github.com/sesouthall/PCGameShuffler.git
synced 2026-08-01 17:22:34 -05:00
Add a switching time option to give the user's machine time to minimize, then pause, then unpause the next game.
This commit is contained in:
parent
44d71b2319
commit
1bc1c7910a
27
GameShuffler/Form1.Designer.cs
generated
27
GameShuffler/Form1.Designer.cs
generated
|
|
@ -49,6 +49,8 @@ namespace GameShuffler
|
|||
refreshButton = new Button();
|
||||
stopButton = new Button();
|
||||
label7 = new Label();
|
||||
label8 = new Label();
|
||||
switchingTimeTextBox = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// runningProcessesSelectionList
|
||||
|
|
@ -124,7 +126,7 @@ namespace GameShuffler
|
|||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(465, 389);
|
||||
label5.Location = new Point(456, 389);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(77, 25);
|
||||
label5.TabIndex = 8;
|
||||
|
|
@ -133,7 +135,7 @@ namespace GameShuffler
|
|||
// label6
|
||||
//
|
||||
label6.AutoSize = true;
|
||||
label6.Location = new Point(465, 426);
|
||||
label6.Location = new Point(456, 426);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(77, 25);
|
||||
label6.TabIndex = 9;
|
||||
|
|
@ -169,11 +171,30 @@ namespace GameShuffler
|
|||
label7.TabIndex = 12;
|
||||
label7.Text = "Press PageUp to move to the next game";
|
||||
//
|
||||
// label8
|
||||
//
|
||||
label8.AutoSize = true;
|
||||
label8.Location = new Point(539, 389);
|
||||
label8.Name = "label8";
|
||||
label8.Size = new Size(167, 25);
|
||||
label8.TabIndex = 13;
|
||||
label8.Text = "Switching time (ms)";
|
||||
//
|
||||
// switchingTimeTextBox
|
||||
//
|
||||
switchingTimeTextBox.Location = new Point(710, 389);
|
||||
switchingTimeTextBox.Name = "switchingTimeTextBox";
|
||||
switchingTimeTextBox.Size = new Size(50, 31);
|
||||
switchingTimeTextBox.TabIndex = 14;
|
||||
switchingTimeTextBox.Text = "100";
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 593);
|
||||
Controls.Add(switchingTimeTextBox);
|
||||
Controls.Add(label8);
|
||||
Controls.Add(label7);
|
||||
Controls.Add(stopButton);
|
||||
Controls.Add(refreshButton);
|
||||
|
|
@ -208,5 +229,7 @@ namespace GameShuffler
|
|||
private Button refreshButton;
|
||||
private Button stopButton;
|
||||
private Label label7;
|
||||
private Label label8;
|
||||
private TextBox switchingTimeTextBox;
|
||||
}
|
||||
}
|
||||
|
|
@ -49,6 +49,7 @@ namespace GameShuffler
|
|||
|
||||
int minShuffleTime = 0;
|
||||
int maxShuffleTime = 0;
|
||||
int switchingTime = 0;
|
||||
List<Process> gamesToShuffle = new List<Process>();
|
||||
|
||||
Process? currentGame = null;
|
||||
|
|
@ -82,21 +83,31 @@ namespace GameShuffler
|
|||
if (!int.TryParse(minTimeTextBox.Text, out minShuffleTime) || minShuffleTime < 0)
|
||||
{
|
||||
MessageBox.Show("Minimum shuffle time must be a positive number");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(maxTimeTextBox.Text, out maxShuffleTime) || maxShuffleTime < minShuffleTime)
|
||||
{
|
||||
MessageBox.Show("Maximum shuffle time must be a positive number greater than minimum shuffle time");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(switchingTimeTextBox.Text, out switchingTime) || switchingTime < 0)
|
||||
{
|
||||
MessageBox.Show("Switching time must be a positive number");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!RegisterHotKey(this.Handle, RemoveGameKeyId, 0x0000, RemoveGameKey))
|
||||
{
|
||||
MessageBox.Show("Failed to initialize remove game key");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!RegisterHotKey(this.Handle, NextGameKeyId, 0x0000, NextGameKey))
|
||||
{
|
||||
MessageBox.Show("Failed to initialize next game key");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var processString in runningProcessesSelectionList.CheckedItems)
|
||||
|
|
@ -155,9 +166,11 @@ namespace GameShuffler
|
|||
if (currentGame != null && gamesToShuffle.Count > 1)
|
||||
{
|
||||
ShowWindow(currentGame.MainWindowHandle, 7);
|
||||
Thread.Sleep(switchingTime/2);
|
||||
SuspendProcess(currentGame);
|
||||
}
|
||||
|
||||
Thread.Sleep(switchingTime/2);
|
||||
StartNewGame();
|
||||
|
||||
Thread.Sleep(rand.Next(minShuffleTime, maxShuffleTime)*1000);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user