Skip to content

Commit

Permalink
refactor: rebuild project with structure
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMcAvoy committed Dec 11, 2024
1 parent 9d071b0 commit d14ae06
Show file tree
Hide file tree
Showing 23 changed files with 953 additions and 1,174 deletions.
48 changes: 19 additions & 29 deletions CarbonLauncher.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35507.96
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CarbonLauncher", "CarbonLauncher\CarbonLauncher.vcxproj", "{E5A80EF0-1C60-4D13-8569-03CF1794CDB6}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CarbonLauncher", "CarbonLauncher\CarbonLauncher.vcxproj", "{F55718C8-63D5-4CCA-8499-07500910C9BC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CarbonSupervisor", "CarbonSupervisor\CarbonSupervisor.vcxproj", "{1F14E774-5A60-4742-9534-712E254FAA60}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DummyGame", "DummyGame\DummyGame.vcxproj", "{A56AC389-85AD-4E6F-9E64-E859DD676099}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CarbonSupervisor", "CarbonSupervisor\CarbonSupervisor.vcxproj", "{97DA7043-249B-4EEA-9116-78A77D28DD84}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -17,35 +15,27 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E5A80EF0-1C60-4D13-8569-03CF1794CDB6}.Debug|x64.ActiveCfg = Debug|x64
{E5A80EF0-1C60-4D13-8569-03CF1794CDB6}.Debug|x64.Build.0 = Debug|x64
{E5A80EF0-1C60-4D13-8569-03CF1794CDB6}.Debug|x86.ActiveCfg = Debug|Win32
{E5A80EF0-1C60-4D13-8569-03CF1794CDB6}.Debug|x86.Build.0 = Debug|Win32
{E5A80EF0-1C60-4D13-8569-03CF1794CDB6}.Release|x64.ActiveCfg = Release|x64
{E5A80EF0-1C60-4D13-8569-03CF1794CDB6}.Release|x64.Build.0 = Release|x64
{E5A80EF0-1C60-4D13-8569-03CF1794CDB6}.Release|x86.ActiveCfg = Release|Win32
{E5A80EF0-1C60-4D13-8569-03CF1794CDB6}.Release|x86.Build.0 = Release|Win32
{1F14E774-5A60-4742-9534-712E254FAA60}.Debug|x64.ActiveCfg = Debug|x64
{1F14E774-5A60-4742-9534-712E254FAA60}.Debug|x64.Build.0 = Debug|x64
{1F14E774-5A60-4742-9534-712E254FAA60}.Debug|x86.ActiveCfg = Debug|Win32
{1F14E774-5A60-4742-9534-712E254FAA60}.Debug|x86.Build.0 = Debug|Win32
{1F14E774-5A60-4742-9534-712E254FAA60}.Release|x64.ActiveCfg = Release|x64
{1F14E774-5A60-4742-9534-712E254FAA60}.Release|x64.Build.0 = Release|x64
{1F14E774-5A60-4742-9534-712E254FAA60}.Release|x86.ActiveCfg = Release|Win32
{1F14E774-5A60-4742-9534-712E254FAA60}.Release|x86.Build.0 = Release|Win32
{A56AC389-85AD-4E6F-9E64-E859DD676099}.Debug|x64.ActiveCfg = Debug|x64
{A56AC389-85AD-4E6F-9E64-E859DD676099}.Debug|x64.Build.0 = Debug|x64
{A56AC389-85AD-4E6F-9E64-E859DD676099}.Debug|x86.ActiveCfg = Debug|Win32
{A56AC389-85AD-4E6F-9E64-E859DD676099}.Debug|x86.Build.0 = Debug|Win32
{A56AC389-85AD-4E6F-9E64-E859DD676099}.Release|x64.ActiveCfg = Release|x64
{A56AC389-85AD-4E6F-9E64-E859DD676099}.Release|x64.Build.0 = Release|x64
{A56AC389-85AD-4E6F-9E64-E859DD676099}.Release|x86.ActiveCfg = Release|Win32
{A56AC389-85AD-4E6F-9E64-E859DD676099}.Release|x86.Build.0 = Release|Win32
{F55718C8-63D5-4CCA-8499-07500910C9BC}.Debug|x64.ActiveCfg = Debug|x64
{F55718C8-63D5-4CCA-8499-07500910C9BC}.Debug|x64.Build.0 = Debug|x64
{F55718C8-63D5-4CCA-8499-07500910C9BC}.Debug|x86.ActiveCfg = Debug|Win32
{F55718C8-63D5-4CCA-8499-07500910C9BC}.Debug|x86.Build.0 = Debug|Win32
{F55718C8-63D5-4CCA-8499-07500910C9BC}.Release|x64.ActiveCfg = Release|x64
{F55718C8-63D5-4CCA-8499-07500910C9BC}.Release|x64.Build.0 = Release|x64
{F55718C8-63D5-4CCA-8499-07500910C9BC}.Release|x86.ActiveCfg = Release|Win32
{F55718C8-63D5-4CCA-8499-07500910C9BC}.Release|x86.Build.0 = Release|Win32
{97DA7043-249B-4EEA-9116-78A77D28DD84}.Debug|x64.ActiveCfg = Debug|x64
{97DA7043-249B-4EEA-9116-78A77D28DD84}.Debug|x64.Build.0 = Debug|x64
{97DA7043-249B-4EEA-9116-78A77D28DD84}.Debug|x86.ActiveCfg = Debug|Win32
{97DA7043-249B-4EEA-9116-78A77D28DD84}.Debug|x86.Build.0 = Debug|Win32
{97DA7043-249B-4EEA-9116-78A77D28DD84}.Release|x64.ActiveCfg = Release|x64
{97DA7043-249B-4EEA-9116-78A77D28DD84}.Release|x64.Build.0 = Release|x64
{97DA7043-249B-4EEA-9116-78A77D28DD84}.Release|x86.ActiveCfg = Release|Win32
{97DA7043-249B-4EEA-9116-78A77D28DD84}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0197DFC4-D5CF-4C67-AEF4-436F47231050}
SolutionGuid = {5C1163F1-0D28-415C-BAC3-80138FA2F668}
EndGlobalSection
EndGlobal
42 changes: 26 additions & 16 deletions CarbonLauncher/CarbonLauncher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,10 @@
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\utils.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\utils.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{e5a80ef0-1c60-4d13-8569-03cf1794cdb6}</ProjectGuid>
<ProjectGuid>{f55718c8-63d5-4cca-8499-07500910c9bc}</ProjectGuid>
<RootNamespace>CarbonLauncher</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
Expand All @@ -37,27 +30,27 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -91,7 +84,7 @@
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
Expand All @@ -108,7 +101,7 @@
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -125,7 +118,7 @@
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
Expand All @@ -142,12 +135,29 @@
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\guimanager.cpp" />
<ClCompile Include="src\discordmanager.cpp" />
<ClCompile Include="src\gamemanager.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\pipemanager.cpp" />
<ClCompile Include="src\state.cpp" />
<ClCompile Include="src\utils.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\guimanager.h" />
<ClInclude Include="include\discordmanager.h" />
<ClInclude Include="include\gamemanager.h" />
<ClInclude Include="include\pipemanager.h" />
<ClInclude Include="include\state.h" />
<ClInclude Include="include\utils.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
28 changes: 28 additions & 0 deletions CarbonLauncher/include/discordmanager.h
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
43 changes: 43 additions & 0 deletions CarbonLauncher/include/gamemanager.h
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
29 changes: 29 additions & 0 deletions CarbonLauncher/include/guimanager.h
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();
47 changes: 47 additions & 0 deletions CarbonLauncher/include/pipemanager.h
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
21 changes: 21 additions & 0 deletions CarbonLauncher/include/state.h
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;
Loading

0 comments on commit d14ae06

Please sign in to comment.