-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rebuild project with structure
- Loading branch information
Showing
23 changed files
with
953 additions
and
1,174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <discord-game-sdk/discord_game_sdk.h> | ||
#include <discord-game-sdk/discord.h> | ||
|
||
#include <string> | ||
#include <memory> | ||
|
||
namespace Carbon { | ||
class DiscordManager { | ||
public: | ||
DiscordManager(); | ||
~DiscordManager(); | ||
|
||
void UpdateState(const std::string& state); | ||
void UpdateDetails(const std::string& details); | ||
|
||
void UpdateActivity() const; | ||
discord::Activity& GetActivity(); | ||
|
||
void Update(); | ||
|
||
discord::User currentUser = discord::User{}; | ||
discord::Activity currentActivity = discord::Activity{}; | ||
|
||
std::unique_ptr<discord::Core> core = nullptr; | ||
}; | ||
}; // namespace Carbon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
|
||
#include <Windows.h> | ||
#include <TlHelp32.h> | ||
|
||
#include <optional> | ||
#include <vector> | ||
#include <thread> | ||
#include <mutex> | ||
|
||
namespace Carbon { | ||
class GameManager { | ||
public: | ||
GameManager(); | ||
~GameManager(); | ||
|
||
bool IsGameRunning(); | ||
|
||
void InjectModule(const std::string& modulePath); | ||
|
||
void StartGame(); | ||
void KillGame(); | ||
|
||
// TODO: Send a message to the | ||
// supervisor to stop the game | ||
// void StopGame(); | ||
|
||
private: | ||
// Checks every 1s if the game is running | ||
std::thread gameStatusThread; | ||
std::mutex gameStatusMutex; | ||
|
||
// Tracks when the game was first seen as running by the GameManager | ||
std::optional<std::chrono::time_point<std::chrono::system_clock>> gameStartedTime; | ||
|
||
std::vector<MODULEENTRY32> modules; | ||
bool gameRunning = false; | ||
|
||
DWORD pid = 0; | ||
}; | ||
}; // namespace Carbon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
#define GLFW_INCLUDE_NONE | ||
|
||
#include <Windows.h> | ||
|
||
#include <functional> | ||
|
||
#include <GLFW/glfw3.h> | ||
|
||
namespace Carbon { | ||
class GUIManager { | ||
public: | ||
GUIManager(HINSTANCE hInstance); | ||
~GUIManager(); | ||
|
||
void RenderCallback(std::function<void()> callback) { | ||
this->renderCallback = callback; | ||
} | ||
|
||
void Run() const; | ||
|
||
GLFWwindow* window; | ||
std::function<void()> renderCallback; | ||
}; | ||
}; // namespace Carbon | ||
|
||
void _GUI(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
#include <Windows.h> | ||
|
||
#include <optional> | ||
#include <vector> | ||
#include <string> | ||
#include <thread> | ||
#include <mutex> | ||
#include <queue> | ||
|
||
namespace Carbon { | ||
enum class PacketType { | ||
LOADED, // Sent when the game is loaded | ||
STATECHANGE, // Sent when the game state changes (e.g. menu -> game) | ||
LOG, // (e.g.game log [will be implemented later]) | ||
UNKNOWNTYPE // Unknown packet type | ||
}; | ||
|
||
class Packet { | ||
public: | ||
PacketType type = PacketType::UNKNOWNTYPE; | ||
std::optional<std::string> data; | ||
}; | ||
|
||
class PipeManager { | ||
public: | ||
PipeManager(); | ||
~PipeManager(); | ||
|
||
bool pipeInitialized = false; | ||
|
||
std::mutex pipeMutex; | ||
std::vector<Packet> packets = {}; | ||
|
||
std::vector<Packet>& GetPackets() { | ||
std::lock_guard<std::mutex> lock(this->pipeMutex); | ||
return this->packets; | ||
} | ||
|
||
std::queue<Packet> GetPacketsByType(PacketType packet); | ||
|
||
private: | ||
std::thread pipeReader; | ||
}; | ||
}; // namespace Carbon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "guimanager.h" | ||
#include "discordmanager.h" | ||
#include "gamemanager.h" | ||
#include "pipemanager.h" | ||
|
||
namespace Carbon { | ||
class CarbonState_t { | ||
public: | ||
Carbon::GUIManager* guiManager; | ||
Carbon::DiscordManager* discordManager; | ||
Carbon::GameManager* gameManager; | ||
Carbon::PipeManager* pipeManager; | ||
|
||
//const char* processTarget = "DummyGame.exe"; (NOTE: this is not included in this repo at the moment) | ||
const char* processTarget = "ScrapMechanic.exe"; | ||
}; | ||
}; // namespace Carbon | ||
|
||
extern Carbon::CarbonState_t C; |
Oops, something went wrong.