mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-06-19 23:20:57 +00:00
new discord code, vcpkg to handle the library
This commit is contained in:
@@ -18,7 +18,7 @@ jobs:
|
|||||||
uses: lukka/run-vcpkg@v7
|
uses: lukka/run-vcpkg@v7
|
||||||
id: runvcpkg
|
id: runvcpkg
|
||||||
with:
|
with:
|
||||||
vcpkgArguments: 'zlib openssl'
|
vcpkgArguments: 'zlib discord-rpc openssl'
|
||||||
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
|
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
|
||||||
vcpkgGitCommitId: '75522bb1f2e7d863078bcd06322348f053a9e33f'
|
vcpkgGitCommitId: '75522bb1f2e7d863078bcd06322348f053a9e33f'
|
||||||
vcpkgTriplet: 'x64-windows-static'
|
vcpkgTriplet: 'x64-windows-static'
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ jobs:
|
|||||||
uses: lukka/run-vcpkg@main
|
uses: lukka/run-vcpkg@main
|
||||||
id: runvcpkg
|
id: runvcpkg
|
||||||
with:
|
with:
|
||||||
vcpkgArguments: 'zlib openssl'
|
vcpkgArguments: 'zlib discord-rpc openssl'
|
||||||
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
|
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
|
||||||
vcpkgGitCommitId: '75522bb1f2e7d863078bcd06322348f053a9e33f'
|
vcpkgGitCommitId: '75522bb1f2e7d863078bcd06322348f053a9e33f'
|
||||||
vcpkgTriplet: 'x64-windows-static'
|
vcpkgTriplet: 'x64-windows-static'
|
||||||
|
|||||||
@@ -13,6 +13,3 @@
|
|||||||
[submodule "include/easyloggingpp"]
|
[submodule "include/easyloggingpp"]
|
||||||
path = include/easyloggingpp
|
path = include/easyloggingpp
|
||||||
url = https://github.com/amrayn/easyloggingpp.git
|
url = https://github.com/amrayn/easyloggingpp.git
|
||||||
[submodule "include/discord-rpc"]
|
|
||||||
path = include/discord-rpc
|
|
||||||
url = https://github.com/discord/discord-rpc.git
|
|
||||||
|
|||||||
+4
-3
@@ -45,13 +45,14 @@ add_executable(${PROJECT_NAME}
|
|||||||
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${VcpkgRoot}/lib/discord-rpc.lib
|
||||||
ZLIB::ZLIB OpenSSL::SSL OpenSSL::Crypto ws2_32 wx::net wx::core wx::base Dbghelp)
|
ZLIB::ZLIB discord-rpc OpenSSL::SSL OpenSSL::Crypto ws2_32 wx::net wx::core wx::base Dbghelp)
|
||||||
else(WIN32) #MINGW
|
else(WIN32) #MINGW
|
||||||
add_definitions("-D_WIN32_WINNT=0x0600")
|
add_definitions("-D_WIN32_WINNT=0x0600")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -s --static")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -s --static")
|
||||||
target_link_libraries(${PROJECT_NAME} ssl crypto ws2_32 ssp crypt32 z Dbghelp)
|
target_link_libraries(${PROJECT_NAME} discord-rpc ssl crypto ws2_32 ssp crypt32 z Dbghelp)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
add_definitions(-DELPP_NO_DEFAULT_LOG_FILE)
|
add_definitions(-DELPP_NO_DEFAULT_LOG_FILE)
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE "include")
|
target_include_directories(${PROJECT_NAME} PRIVATE "include")
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE "include/rapidjson/include")
|
target_include_directories(${PROJECT_NAME} PRIVATE "include/rapidjson/include")
|
||||||
|
target_include_directories(${PROJECT_NAME} PRIVATE "include/discord-rpc/include")
|
||||||
|
|||||||
+6
-4
@@ -25,9 +25,6 @@ public: //constructors
|
|||||||
public: //available functions
|
public: //available functions
|
||||||
static void StaticAbort(Launcher* Instance = nullptr);
|
static void StaticAbort(Launcher* Instance = nullptr);
|
||||||
std::string Login(const std::string& fields);
|
std::string Login(const std::string& fields);
|
||||||
static bool Terminated() noexcept;
|
|
||||||
static void setExit(bool exit);
|
|
||||||
static bool getExit();
|
|
||||||
void RunDiscordRPC();
|
void RunDiscordRPC();
|
||||||
void QueryRegistry();
|
void QueryRegistry();
|
||||||
void WaitForGame();
|
void WaitForGame();
|
||||||
@@ -35,12 +32,17 @@ public: //available functions
|
|||||||
void LaunchGame();
|
void LaunchGame();
|
||||||
void CheckKey();
|
void CheckKey();
|
||||||
void SetupMOD();
|
void SetupMOD();
|
||||||
public: //Getters
|
public: //Getters and Setters
|
||||||
|
void setDiscordMessage(const std::string& message);
|
||||||
|
static void setExit(bool exit) noexcept;
|
||||||
const std::string& getFullVersion();
|
const std::string& getFullVersion();
|
||||||
|
static bool Terminated() noexcept;
|
||||||
const std::string& getUserRole();
|
const std::string& getUserRole();
|
||||||
const std::string& getVersion();
|
const std::string& getVersion();
|
||||||
|
static bool getExit() noexcept;
|
||||||
private: //functions
|
private: //functions
|
||||||
std::string GetLocalAppdata();
|
std::string GetLocalAppdata();
|
||||||
|
void UpdatePresence();
|
||||||
void AdminRelaunch();
|
void AdminRelaunch();
|
||||||
void RichPresence();
|
void RichPresence();
|
||||||
void WindowsInit();
|
void WindowsInit();
|
||||||
|
|||||||
Submodule include/discord-rpc deleted from 7c41a8ec19
+37
-10
@@ -3,23 +3,50 @@
|
|||||||
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
|
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
|
||||||
///
|
///
|
||||||
|
|
||||||
|
#include <discord_rpc.h>
|
||||||
#include "Launcher.h"
|
#include "Launcher.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
void handleReady(const DiscordUser* u) {}
|
||||||
|
void handleDisconnected(int errcode, const char* message) {}
|
||||||
|
void handleError(int errcode, const char* message) {
|
||||||
|
LOG(ERROR) << "Discord error: " << message;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Launcher::UpdatePresence() {
|
||||||
|
auto currentTime = std::time(nullptr);
|
||||||
|
DiscordRichPresence discordPresence;
|
||||||
|
memset(&discordPresence, 0, sizeof(discordPresence));
|
||||||
|
discordPresence.state = DiscordMessage.c_str();
|
||||||
|
discordPresence.largeImageKey = "mainlogo";
|
||||||
|
discordPresence.startTimestamp = currentTime - (currentTime - DiscordTime);
|
||||||
|
discordPresence.endTimestamp = 0;
|
||||||
|
DiscordTime = currentTime;
|
||||||
|
Discord_UpdatePresence(&discordPresence);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Launcher::setDiscordMessage(const std::string& message) {
|
||||||
|
DiscordMessage = message;
|
||||||
|
UpdatePresence();
|
||||||
|
}
|
||||||
|
|
||||||
void Launcher::RichPresence() {
|
void Launcher::RichPresence() {
|
||||||
/*Discord_Initialize("629743237988352010", nullptr, 1, nullptr);
|
DiscordEventHandlers handlers;
|
||||||
|
memset(&handlers, 0, sizeof(handlers));
|
||||||
|
handlers.ready = handleReady;
|
||||||
|
handlers.errored = handleError;
|
||||||
|
handlers.disconnected = handleDisconnected;
|
||||||
|
Discord_Initialize("629743237988352010", &handlers, 1, nullptr);
|
||||||
|
UpdatePresence();
|
||||||
while(!Shutdown.load()) {
|
while(!Shutdown.load()) {
|
||||||
DiscordRichPresence discordPresence;
|
Discord_RunCallbacks();
|
||||||
memset(&discordPresence, 0, sizeof(discordPresence));
|
|
||||||
discordPresence.state = DiscordMessage.c_str();
|
|
||||||
discordPresence.startTimestamp = DiscordTime;
|
|
||||||
discordPresence.largeImageKey = "mainlogo";
|
|
||||||
Discord_UpdatePresence(&discordPresence);
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
Discord_ClearPresence();*/
|
Discord_ClearPresence();
|
||||||
|
Discord_Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::RunDiscordRPC() {
|
void Launcher::RunDiscordRPC() {
|
||||||
//DiscordRPC = std::thread(&Launcher::RichPresence, this);
|
DiscordRPC = std::thread(&Launcher::RichPresence, this);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -20,6 +20,7 @@ LONG WINAPI CrashHandler(EXCEPTION_POINTERS* p) {
|
|||||||
std::atomic<bool> Launcher::Shutdown{false}, Launcher::Exit{false};
|
std::atomic<bool> Launcher::Shutdown{false}, Launcher::Exit{false};
|
||||||
Launcher::Launcher(int argc, char* argv[]) : CurrentPath(std::filesystem::path(argv[0])), DiscordMessage("Just launched") {
|
Launcher::Launcher(int argc, char* argv[]) : CurrentPath(std::filesystem::path(argv[0])), DiscordMessage("Just launched") {
|
||||||
Launcher::StaticAbort(this);
|
Launcher::StaticAbort(this);
|
||||||
|
DiscordTime = std::time(nullptr);
|
||||||
Log::Init();
|
Log::Init();
|
||||||
WindowsInit();
|
WindowsInit();
|
||||||
SetUnhandledExceptionFilter(CrashHandler);
|
SetUnhandledExceptionFilter(CrashHandler);
|
||||||
@@ -111,6 +112,7 @@ void Launcher::WaitForGame() {
|
|||||||
throw ShutdownException("Fatal Error");
|
throw ShutdownException("Fatal Error");
|
||||||
}
|
}
|
||||||
LOG(INFO) << "Game found! PID " << GamePID;
|
LOG(INFO) << "Game found! PID " << GamePID;
|
||||||
|
setDiscordMessage("In menus");
|
||||||
//TODO: Inject then start IPC
|
//TODO: Inject then start IPC
|
||||||
while(!Shutdown.load() && BeamNG::GetProcessID() != 0) {
|
while(!Shutdown.load() && BeamNG::GetProcessID() != 0) {
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
@@ -193,10 +195,10 @@ bool Launcher::Terminated() noexcept {
|
|||||||
return Shutdown.load();
|
return Shutdown.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Launcher::getExit() {
|
bool Launcher::getExit() noexcept {
|
||||||
return Exit.load();
|
return Exit.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::setExit(bool exit) {
|
void Launcher::setExit(bool exit) noexcept {
|
||||||
Exit.store(exit);
|
Exit.store(exit);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user