Skip to content

Commit ea9ea38

Browse files
committed
HourBoostr mono compatible
1 parent 361c9cb commit ea9ea38

21 files changed

Lines changed: 63 additions & 302 deletions

File tree

HourBoostr/.vs/HourBoostr/v15/.suo

-10 KB
Binary file not shown.

HourBoostr/HourBoostr/Bot.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Collections.Specialized;
44
using System.Threading;
55
using System.IO;
6-
using System.Windows.Forms;
76
using System.Timers;
87
using System.Linq;
98
using System.Security.Cryptography;
@@ -166,7 +165,7 @@ public Bot(Config.AccountSettings info)
166165
};
167166
mAccountSettings = info;
168167
mSteam.games = info.Games;
169-
mSteam.sentryPath = Path.Combine(Application.StartupPath, string.Format("Sentryfiles\\{0}.sentry", info.Details.Username));
168+
mSteam.sentryPath = string.Format("Sentryfiles/{0}.sentry", info.Details.Username);
170169

171170
/*Set up steamweb*/
172171
mSteam.web = new SteamWeb();
@@ -503,6 +502,7 @@ without the user needing to enter their Authentication code*/
503502

504503
mSteam.uniqueId = callback.UniqueID.ToString();
505504
mSteam.user.AcceptNewLoginKey(callback);
505+
Settings.UpdateAccount(mAccountSettings);
506506

507507
if (mAccountSettings.ConnectToSteamCommunity)
508508
{

HourBoostr/HourBoostr/Config.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ public class Config
1111
/// </summary>
1212
public class Settings
1313
{
14-
/// <summary>
15-
/// If we should automatically hide the program to tray bar
16-
/// I fucking hate this so I want to disable it
17-
/// </summary>
18-
public bool HideToTrayAutomatically { get; set; } = true;
19-
20-
2114
/// <summary>
2215
/// If we should check for updates when we start the program
2316
/// </summary>

HourBoostr/HourBoostr/EndPoint.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
using System.Windows.Forms;
2-
using System.IO;
1+
using System.IO;
32

43
namespace HourBoostr
54
{
65
class EndPoint
76
{
8-
public static string SETTINGS_FILE_PATH = Path.Combine(Application.StartupPath, "Settings.json");
9-
public static string GLOBAL_SETTINGS_FILE_PATH = Path.Combine(Application.StartupPath, "GlobalDB.hb");
10-
public static string SENTRY_FOLDER_PATH = Path.Combine(Application.StartupPath, "Sentryfiles");
11-
public static string LOG_FOLDER_PATH = Path.Combine(Application.StartupPath, "Logs");
12-
public static string CONSOLE_TITLE = $"HourBoostr v{Application.ProductVersion}";
7+
public static string SETTINGS_FILE_PATH = "Settings.json";
8+
public static string GLOBAL_SETTINGS_FILE_PATH = "GlobalDB.hb";
9+
public static string SENTRY_FOLDER_PATH = "Sentryfiles";
10+
public static string LOG_FOLDER_PATH = "Logs";
11+
public static string CONSOLE_TITLE = $"HourBoostr v{Utils.GetVersion()}";
1312
public static string STEAM_GROUP_URL = "http://steamcommunity.com/gid/103582791455389825";
1413
public static string VERSION_FILE = "https://raw.githubusercontent.com/Ezzpify/HourBoostr/master/version.txt";
1514
}

HourBoostr/HourBoostr/HourBoostr.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
<Reference Include="System.Core" />
5151
<Reference Include="System.Drawing" />
5252
<Reference Include="System.Web" />
53-
<Reference Include="System.Windows.Forms" />
5453
<Reference Include="System.Xml.Linq" />
5554
<Reference Include="System.Data.DataSetExtensions" />
5655
<Reference Include="Microsoft.CSharp" />
@@ -81,6 +80,7 @@
8180
<Compile Include="Steam.cs" />
8281
<Compile Include="SteamWeb.cs" />
8382
<Compile Include="Update.cs" />
83+
<Compile Include="Utils.cs" />
8484
</ItemGroup>
8585
<ItemGroup>
8686
<None Include="App.config" />
@@ -96,6 +96,7 @@
9696
<EmbeddedResource Include="Properties\Resources.resx">
9797
<Generator>ResXFileCodeGenerator</Generator>
9898
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
99+
<SubType>Designer</SubType>
99100
</EmbeddedResource>
100101
</ItemGroup>
101102
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

HourBoostr/HourBoostr/Program.cs

Lines changed: 2 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,12 @@
11
using System;
22
using System.IO;
3-
using System.Windows.Forms;
43
using System.Threading;
54
using System.Runtime.InteropServices;
65

76
namespace HourBoostr
87
{
98
class Program
109
{
11-
#region Imports
12-
13-
/// <summary>
14-
/// DllImport for setting foreground of a window
15-
/// </summary>
16-
/// <param name="hWnd">Hwnd of window to manage</param>
17-
/// <returns>Returns bool</returns>
18-
[DllImport("user32.dll")]
19-
public static extern bool SetForegroundWindow(IntPtr hWnd);
20-
21-
22-
/// <summary>
23-
/// DllImport for getting current console window intptr
24-
/// </summary>
25-
/// <returns>Returns IntPtr</returns>
26-
[DllImport("kernel32.dll")]
27-
static extern IntPtr GetConsoleWindow();
28-
29-
30-
/// <summary>
31-
/// DllImport for showing/hiding window
32-
/// </summary>
33-
/// <param name="hWnd">Hwnd of window to manage</param>
34-
/// <param name="nCmdShow">Show parameter</param>
35-
/// <returns>Returns bool</returns>
36-
[DllImport("user32.dll")]
37-
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
38-
39-
40-
/// <summary>
41-
/// DllImport to catch the exit event
42-
/// </summary>
43-
/// <returns>Returns bool</returns>
44-
[DllImport("kernel32.dll", SetLastError = true)]
45-
private static extern bool SetConsoleCtrlHandler(ConsoleEventDelegate callback, bool add);
46-
private delegate bool ConsoleEventDelegate(int eventType);
47-
48-
#endregion Imports
49-
50-
51-
/// <summary>
52-
/// Application tray icon
53-
/// Used for hiding/showing the application in a click
54-
/// </summary>
55-
static private NotifyIcon mTrayIcon = new NotifyIcon();
56-
57-
58-
/// <summary>
59-
/// Console event handler
60-
/// </summary>
61-
static private ConsoleEventDelegate mEventHandler;
62-
63-
64-
/// <summary>
65-
/// Application settings
66-
/// </summary>
67-
static private Config.Settings mSettings;
68-
69-
70-
/// <summary>
71-
/// Thread variables
72-
/// </summary>
73-
static private Thread mThreadTray;
74-
75-
7610
/// <summary>
7711
/// Global database
7812
/// </summary>
@@ -85,100 +19,6 @@ class Program
8519
static private Session mSession;
8620

8721

88-
/// <summary>
89-
/// Represents if the console is hidden
90-
/// </summary>
91-
static private bool mIsHidden;
92-
93-
94-
/// <summary>
95-
/// HACK HACK!
96-
/// Initialize the tray icon thread
97-
/// Keep it running
98-
/// </summary>
99-
static private void ToTray()
100-
{
101-
/*Set TrayIcon information*/
102-
mTrayIcon.Text = "HourBoostr\nClick to Show/Hide";
103-
mTrayIcon.Icon = Properties.Resources.icon;
104-
mTrayIcon.Click += new EventHandler(TrayIcon_Click);
105-
mTrayIcon.Visible = true;
106-
Application.Run();
107-
108-
/*To keep TrayIcon from dissapearing,
109-
we need to keep the thread running*/
110-
while (true) { Thread.Sleep(250); }
111-
}
112-
113-
114-
/// <summary>
115-
/// TrayIcon click event
116-
/// Show/Hide the window depending on its state
117-
/// </summary>
118-
static private void TrayIcon_Click(object sender, EventArgs e)
119-
{
120-
ShowConsole(mIsHidden);
121-
}
122-
123-
124-
/// <summary>
125-
/// Show/Hide the console window
126-
/// </summary>
127-
/// <param name="show">True to show, false to hide</param>
128-
static private void ShowConsole(bool show)
129-
{
130-
if (show)
131-
{
132-
ShowWindow(GetConsoleWindow(), 5);
133-
SetForegroundWindow(GetConsoleWindow());
134-
}
135-
else
136-
{
137-
ShowWindow(GetConsoleWindow(), 0);
138-
}
139-
140-
mIsHidden = !show;
141-
}
142-
143-
144-
/// <summary>
145-
/// Catch exit event
146-
/// Realistically we have 4-5 seconds to preform this
147-
/// action before windows forces the program to close
148-
/// </summary>
149-
/// <param name="eventType">Event type</param>
150-
/// <returns>Returns bool</returns>
151-
static bool ConsoleEventCallback(int eventType)
152-
{
153-
/*eventType 2 being Exit event*/
154-
if (eventType == 2)
155-
{
156-
if (mSession != null)
157-
{
158-
/*Disconnect all clients*/
159-
Console.WriteLine("\n\nDisconnecting...");
160-
foreach (var Bot in mSession.mActiveBotList)
161-
{
162-
Bot.mIsRunning = false;
163-
Bot.mSteam.client.Disconnect();
164-
}
165-
166-
/*Update settings*/
167-
if (Settings.UpdateSettings(mSettings, mSession.mSettings))
168-
Console.WriteLine("Updated user settings");
169-
}
170-
171-
mTrayIcon.Visible = false;
172-
mTrayIcon.Dispose();
173-
174-
Console.WriteLine("Exiting...");
175-
Thread.Sleep(500);
176-
}
177-
178-
return false;
179-
}
180-
181-
18222
/// <summary>
18323
/// Main function
18424
/// Too many comments
@@ -192,20 +32,6 @@ static void Main(string[] args)
19232
Directory.CreateDirectory(EndPoint.SENTRY_FOLDER_PATH);
19333
Directory.CreateDirectory(EndPoint.LOG_FOLDER_PATH);
19434

195-
/*Set exit events so we'll log out all accounts if application is exited*/
196-
mEventHandler = new ConsoleEventDelegate(ConsoleEventCallback);
197-
SetConsoleCtrlHandler(mEventHandler, true);
198-
199-
/*Start the trayicon thread*/
200-
mThreadTray = new Thread(ToTray);
201-
mThreadTray.Start();
202-
203-
/*We'll read and store the settings twice since we'll compare the two objects later on
204-
to see if something has changed by the user during runtime*/
205-
mSettings = Settings.GetSettings();
206-
if (mSettings == null)
207-
return;
208-
20935
/*Load global database*/
21036
mGlobalDB = GlobalDB.Load(EndPoint.GLOBAL_SETTINGS_FILE_PATH);
21137
if (mGlobalDB == null)
@@ -226,20 +52,12 @@ static void Main(string[] args)
22652
mSession = new Session(settings);
22753
while (mSession.mBwg.IsBusy)
22854
Thread.Sleep(250);
229-
230-
if (settings.HideToTrayAutomatically)
231-
{
232-
mTrayIcon.ShowBalloonTip(1000, "HourBoostr", "I'm down here!", ToolTipIcon.Info);
233-
ShowConsole(false);
234-
}
23555
}
23656
else
23757
{
238-
Console.WriteLine("No accounts were loaded from settings.");
58+
Console.WriteLine("No accounts were loaded from settings. Press any key to exit.");
59+
Console.ReadKey();
23960
}
240-
241-
while (true)
242-
Thread.Sleep(250);
24361
}
24462
}
24563
}

HourBoostr/HourBoostr/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.0.1")]
36-
[assembly: AssemblyFileVersion("3.0.1")]
35+
[assembly: AssemblyVersion("3.1.0")]
36+
[assembly: AssemblyFileVersion("3.1.0")]

HourBoostr/HourBoostr/Session.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using System.Threading;
44
using System.Reflection;
55
using System.ComponentModel;
6-
using System.Diagnostics;
7-
using System.Windows.Forms;
86
using System.IO;
97
using SteamKit2;
108
using SteamKit2.Discovery;
@@ -47,11 +45,7 @@ public Session(Config.Settings settings)
4745
mSettings = settings;
4846

4947
if (settings.CheckForUpdates && Update.IsUpdateAvailable())
50-
{
51-
var diagResult = MessageBox.Show("There seems to be an update available.\nCheck it out?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
52-
if (diagResult == DialogResult.Yes)
53-
Process.Start("https://github.com/Ezzpify/HourBoostr/releases/latest");
54-
}
48+
Console.WriteLine("There's an update available. Check out https://github.com/Ezzpify/HourBoostr/releases/latest");
5549

5650
mBwg.DoWork += MBwg_DoWork;
5751
mBwg.RunWorkerAsync();
@@ -89,9 +83,9 @@ private void MBwg_DoWork(object sender, DoWorkEventArgs e)
8983
Console.WriteLine($" | | |___ _ _ ___| |_ ___ ___ ___| |_ ___ ");
9084
Console.WriteLine($" | | . | | | _| . | . | . |_ -| _| _|");
9185
Console.WriteLine($" |__|__|___|___|_| |___|___|___|___|_| |_| \n");
92-
Console.WriteLine($" Source: https://github.com/Ezzpify/");
86+
Console.WriteLine($" Source: https://github.com/Ezzpify/HourBoostr");
9387
Console.WriteLine($" Build date: {File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location)}");
94-
Console.WriteLine($" Version: {Application.ProductVersion}\n");
88+
Console.WriteLine($" Version: {Utils.GetVersion()}\n");
9589
Console.WriteLine($" ----------------------------------------");
9690
Console.WriteLine($"\n Loaded {mActiveBotList.Count} accounts\n\n Account list:");
9791
mActiveBotList.ForEach(o => Console.WriteLine(" {0} | {1} Games", o.mAccountSettings.Details.Username, o.mSteam.games.Count));

0 commit comments

Comments
 (0)