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