mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Work work
This commit is contained in:
@@ -352,7 +352,7 @@ namespace ArchiSteamFarm {
|
||||
SteamClient.Disconnect();
|
||||
}
|
||||
|
||||
Program.OnBotShutdown();
|
||||
Events.OnBotShutdown();
|
||||
}
|
||||
|
||||
internal void OnFarmingStopped() => ResetGamesPlayed();
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
using SteamKit2;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using SteamKit2;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
internal static class Events {
|
||||
internal static void OnBotShutdown() {
|
||||
if (Program.ShutdownSequenceInitialized || Program.WCF.IsServerRunning() || Bot.Bots.Values.Any(bot => bot.KeepRunning)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.LogGenericInfo("No bots are running, exiting");
|
||||
Task.Delay(5000).Wait();
|
||||
Program.Shutdown();
|
||||
}
|
||||
|
||||
internal static void OnStateUpdated(Bot bot, SteamFriends.PersonaStateCallback callback) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,16 +43,17 @@ namespace ArchiSteamFarm {
|
||||
Server // Normal + WCF server
|
||||
}
|
||||
|
||||
internal static readonly WCF WCF = new WCF();
|
||||
|
||||
private static readonly object ConsoleLock = new object();
|
||||
private static readonly ManualResetEventSlim ShutdownResetEvent = new ManualResetEventSlim(false);
|
||||
private static readonly WCF WCF = new WCF();
|
||||
|
||||
internal static bool IsRunningAsService { get; private set; }
|
||||
internal static bool ShutdownSequenceInitialized { get; private set; }
|
||||
internal static GlobalConfig GlobalConfig { get; private set; }
|
||||
internal static GlobalDatabase GlobalDatabase { get; private set; }
|
||||
internal static WebBrowser WebBrowser { get; private set; }
|
||||
|
||||
private static bool ShutdownSequenceInitialized;
|
||||
private static EMode Mode = EMode.Normal;
|
||||
|
||||
internal static void Exit(byte exitCode = 0) {
|
||||
@@ -134,25 +135,7 @@ namespace ArchiSteamFarm {
|
||||
return !string.IsNullOrEmpty(result) ? result.Trim() : null;
|
||||
}
|
||||
|
||||
internal static void OnBotShutdown() {
|
||||
if (ShutdownSequenceInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Bot.Bots.Values.Any(bot => bot.KeepRunning)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (WCF.IsServerRunning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.LogGenericInfo("No bots are running, exiting");
|
||||
Thread.Sleep(5000);
|
||||
ShutdownResetEvent.Set();
|
||||
}
|
||||
|
||||
private static void Shutdown() {
|
||||
internal static void Shutdown() {
|
||||
if (!InitShutdownSequence()) {
|
||||
return;
|
||||
}
|
||||
@@ -286,7 +269,7 @@ namespace ArchiSteamFarm {
|
||||
Logging.InitCoreLoggers();
|
||||
Logging.LogGenericInfo("ASF V" + SharedInfo.Version);
|
||||
|
||||
if (!Runtime.IsRuntimeSupported()) {
|
||||
if (!Runtime.IsRuntimeSupported) {
|
||||
Logging.LogGenericError("ASF detected unsupported runtime version, program might NOT run correctly in current environment. You're running it at your own risk!");
|
||||
Thread.Sleep(10000);
|
||||
}
|
||||
@@ -378,7 +361,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
// Check if we got any bots running
|
||||
if (!isRunning) {
|
||||
OnBotShutdown();
|
||||
Events.OnBotShutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,40 +55,51 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool IsRuntimeSupported() {
|
||||
if (IsRunningOnMono) {
|
||||
Version monoVersion = GetMonoVersion();
|
||||
if (monoVersion == null) {
|
||||
Logging.LogNullError(nameof(monoVersion));
|
||||
private static bool? _IsRuntimeSupported;
|
||||
internal static bool IsRuntimeSupported {
|
||||
get {
|
||||
if (_IsRuntimeSupported.HasValue) {
|
||||
return _IsRuntimeSupported.Value;
|
||||
}
|
||||
|
||||
if (IsRunningOnMono) {
|
||||
Version monoVersion = GetMonoVersion();
|
||||
if (monoVersion == null) {
|
||||
Logging.LogNullError(nameof(monoVersion));
|
||||
return false;
|
||||
}
|
||||
|
||||
Version minMonoVersion = new Version(4, 4);
|
||||
|
||||
if (monoVersion >= minMonoVersion) {
|
||||
Logging.LogGenericInfo("Your Mono version is OK. Required: " + minMonoVersion + " | Found: " + monoVersion);
|
||||
_IsRuntimeSupported = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Logging.LogGenericWarning("Your Mono version is too old. Required: " + minMonoVersion + " | Found: " + monoVersion);
|
||||
_IsRuntimeSupported = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Version minMonoVersion = new Version(4, 4);
|
||||
Version netVersion = GetNetVersion();
|
||||
if (netVersion == null) {
|
||||
Logging.LogNullError(nameof(netVersion));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (monoVersion >= minMonoVersion) {
|
||||
Logging.LogGenericInfo("Your Mono version is OK. Required: " + minMonoVersion + " | Found: " + monoVersion);
|
||||
Version minNetVersion = new Version(4, 6);
|
||||
|
||||
if (netVersion >= minNetVersion) {
|
||||
Logging.LogGenericInfo("Your .NET version is OK. Required: " + minNetVersion + " | Found: " + netVersion);
|
||||
_IsRuntimeSupported = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Logging.LogGenericWarning("Your Mono version is too old. Required: " + minMonoVersion + " | Found: " + monoVersion);
|
||||
Logging.LogGenericWarning("Your .NET version is too old. Required: " + minNetVersion + " | Found: " + netVersion);
|
||||
_IsRuntimeSupported = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Version netVersion = GetNetVersion();
|
||||
if (netVersion == null) {
|
||||
Logging.LogNullError(nameof(netVersion));
|
||||
return false;
|
||||
}
|
||||
|
||||
Version minNetVersion = new Version(4, 6);
|
||||
|
||||
if (netVersion >= minNetVersion) {
|
||||
Logging.LogGenericInfo("Your .NET version is OK. Required: " + minNetVersion + " | Found: " + netVersion);
|
||||
return true;
|
||||
}
|
||||
|
||||
Logging.LogGenericWarning("Your .NET version is too old. Required: " + minNetVersion + " | Found: " + netVersion);
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Remove me once Mono 4.6 is released
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace ArchiSteamFarm {
|
||||
// Therefore, call mono-incompatible options in their own function to avoid that, and just leave the function call here
|
||||
// When compiling on Mono, this section is omitted entirely as we never run Mono-compiled ASF on Windows
|
||||
// Moreover, Mono compiler doesn't even include ReusePort field in ServicePointManager, so it's crucial to avoid compilation error
|
||||
if (!Runtime.IsRunningOnMono) {
|
||||
if (Runtime.IsRuntimeSupported && !Runtime.IsRunningOnMono) {
|
||||
InitNonMonoBehaviour();
|
||||
}
|
||||
#endif
|
||||
|
||||
1
GUI/BotStatusForm.Designer.cs
generated
1
GUI/BotStatusForm.Designer.cs
generated
@@ -47,6 +47,7 @@
|
||||
this.AutoScroll = true;
|
||||
this.ClientSize = new System.Drawing.Size(651, 513);
|
||||
this.Controls.Add(this.AvatarPictureBox);
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Name = "BotStatusForm";
|
||||
this.Text = "BotStatusForm";
|
||||
|
||||
@@ -4,6 +4,8 @@ using SteamKit2;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace ArchiSteamFarm {
|
||||
internal static class Events {
|
||||
internal static void OnBotShutdown() { }
|
||||
|
||||
internal static void OnStateUpdated(Bot bot, SteamFriends.PersonaStateCallback callback) {
|
||||
if ((bot == null) || (callback == null)) {
|
||||
Logging.LogNullError(nameof(bot) + " || " + nameof(callback));
|
||||
|
||||
1
GUI/MainForm.Designer.cs
generated
1
GUI/MainForm.Designer.cs
generated
@@ -102,6 +102,7 @@
|
||||
this.Controls.Add(this.LogTextBox);
|
||||
this.Controls.Add(this.BotListView);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.DoubleBuffered = true;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "MainForm";
|
||||
|
||||
@@ -11,14 +11,12 @@ using GUI;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace ArchiSteamFarm {
|
||||
internal static class Program {
|
||||
internal static bool IsRunningAsService => false;
|
||||
|
||||
internal static GlobalConfig GlobalConfig { get; private set; }
|
||||
internal static GlobalDatabase GlobalDatabase { get; private set; }
|
||||
internal static WebBrowser WebBrowser { get; private set; }
|
||||
|
||||
internal static string GetUserInput(SharedInfo.EUserInputType userInputType, string botName = SharedInfo.ASF, string extraInformation = null) {
|
||||
return null;
|
||||
return null; // TODO
|
||||
}
|
||||
|
||||
internal static void Exit(int exitCode = 0) {
|
||||
@@ -38,10 +36,6 @@ namespace ArchiSteamFarm {
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
internal static void OnBotShutdown() {
|
||||
|
||||
}
|
||||
|
||||
internal static void InitShutdownSequence() {
|
||||
foreach (Bot bot in Bot.Bots.Values.Where(bot => bot.KeepRunning)) {
|
||||
bot.Stop();
|
||||
@@ -95,7 +89,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
Logging.InitCoreLoggers();
|
||||
|
||||
if (!Runtime.IsRuntimeSupported()) {
|
||||
if (!Runtime.IsRuntimeSupported) {
|
||||
Logging.LogGenericError("ASF detected unsupported runtime version, program might NOT run correctly in current environment. You're running it at your own risk!");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using ArchiSteamFarm;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// 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("GUI")]
|
||||
@@ -14,8 +14,8 @@ using ArchiSteamFarm;
|
||||
[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
|
||||
// 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)]
|
||||
|
||||
@@ -25,11 +25,11 @@ using ArchiSteamFarm;
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// 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(SharedInfo.VersionNumber)]
|
||||
|
||||
Reference in New Issue
Block a user