summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-client/UserExperience/UserInterface.hpp
blob: aaa4b108e84f2de7debbc77111a74def8dc57586 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once

#include <windows.h>
#include <thread>
#include <cstdint>
#include <cstdio>
#include <atomic>

namespace UserExperience
{
	// Execution states define a moment in the execution of the loader.
	// These may be changed externally by other threads.
	enum ExecutionState : uint16_t
	{
		EXECUTION_WAITING, // Displays the message 'please wait...'.
		EXECUTION_ERROR,   // Displays an error.
		EXECUTION_LOG_IN,  // Displays the log-in dialog.
		EXECUTION_CHOOSE   // Displays the game selection dialog.
	};

	enum ErrorReason : uint16_t
	{
		ERROR_GENERIC_ERROR,
		ERROR_INVALID_HWID,
		ERROR_SHADOW_BAN
	};

	enum SelectedGame : uint16_t
	{
		GAME_CSGO,
		GAME_CSGO_BETA,
		GAME_MAX
	};

	// Structure that holds global data that will be used by the UI.
	struct UserExperienceData
	{
		// Is the user interface initialised?
		bool           m_Ready          = false;
			
		// Holds the current execution state of the loader.
		ExecutionState m_ExecutionState = EXECUTION_WAITING;

		// Holds the username/password combo entered in the UI.
		char           m_Username[128];
		char           m_Password[128];

		// Does the user have special access?
		bool           m_SpecialAccess  = false;

		// Holds the selected game.
		uint16_t       m_SelectedGame   = GAME_CSGO;

		// Holds the current error message.
		ErrorReason    m_Error          = ERROR_GENERIC_ERROR;
	};

	// User experience handler.
	class UserInterface
	{
	public:
		UserExperienceData m_Data;

		// Creates a window.
		bool Start();

		// Creates an UI thread, call only once.
		void RunUiFrame();
	};

	using UserInterfacePtr = std::unique_ptr<UserInterface>;
}

extern UserExperience::UserInterfacePtr UserInterface;

// Sick macros, retard.

#define ERROR_ASSERT(Error, ...) { char Buffer[1024 * 16]; sprintf_s(Buffer, sizeof Buffer, Error, __VA_ARGS__); MessageBoxA(0, Buffer, "", MB_ICONERROR); ExitProcess(0); }
#define INFO_ASSERT(Error, ...)  { char Buffer[1024 * 16]; sprintf_s(Buffer, sizeof Buffer, Error, __VA_ARGS__); MessageBoxA(0, Buffer, "", MB_OK); ExitProcess(0); }