mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-03 16:37:11 +00:00
windows compat
This commit is contained in:
parent
6a7bf72df5
commit
ece4a42103
@ -12,6 +12,9 @@ project(
|
|||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
message(STATUS "MSVC -> forcing use of statically-linked runtime.")
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
|
||||||
include(cmake/StandardSettings.cmake)
|
include(cmake/StandardSettings.cmake)
|
||||||
include(cmake/StaticAnalyzers.cmake)
|
include(cmake/StaticAnalyzers.cmake)
|
||||||
include(cmake/Git.cmake)
|
include(cmake/Git.cmake)
|
||||||
@ -68,6 +71,7 @@ set(PRJ_LIBRARIES
|
|||||||
Boost::system
|
Boost::system
|
||||||
Boost::iostreams
|
Boost::iostreams
|
||||||
Boost::thread
|
Boost::thread
|
||||||
|
Boost::filesystem
|
||||||
cryptopp::cryptopp
|
cryptopp::cryptopp
|
||||||
ZLIB::ZLIB
|
ZLIB::ZLIB
|
||||||
OpenSSL::SSL
|
OpenSSL::SSL
|
||||||
@ -81,7 +85,7 @@ find_package(fmt CONFIG REQUIRED)
|
|||||||
find_package(doctest CONFIG REQUIRED)
|
find_package(doctest CONFIG REQUIRED)
|
||||||
find_package(spdlog CONFIG REQUIRED)
|
find_package(spdlog CONFIG REQUIRED)
|
||||||
find_package(httplib CONFIG REQUIRED)
|
find_package(httplib CONFIG REQUIRED)
|
||||||
find_package(Boost REQUIRED COMPONENTS system iostreams thread)
|
find_package(Boost REQUIRED COMPONENTS system iostreams thread filesystem)
|
||||||
find_package(cryptopp CONFIG REQUIRED)
|
find_package(cryptopp CONFIG REQUIRED)
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
@ -115,10 +119,6 @@ include(cmake/CompilerWarnings.cmake)
|
|||||||
|
|
||||||
# set MT library for msvc - this is required (says documentation)
|
# set MT library for msvc - this is required (says documentation)
|
||||||
# linux/mac/etc should simply ignore this by default.
|
# linux/mac/etc should simply ignore this by default.
|
||||||
message(STATUS "MSVC -> forcing use of statically-linked runtime.")
|
|
||||||
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
|
||||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
|
||||||
|
|
||||||
set(PRJ_DEFINITIONS ${PRJ_DEFINITIONS}
|
set(PRJ_DEFINITIONS ${PRJ_DEFINITIONS}
|
||||||
PRJ_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
|
PRJ_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
|
||||||
|
@ -115,7 +115,7 @@ void Launcher::check_for_updates(int argc, char** argv) {
|
|||||||
|
|
||||||
transform(LatestHash.begin(), LatestHash.end(), LatestHash.begin(), ::tolower);
|
transform(LatestHash.begin(), LatestHash.end(), LatestHash.begin(), ::tolower);
|
||||||
std::string EP = (m_exe_path.get() / m_exe_name.get()).generic_string();
|
std::string EP = (m_exe_path.get() / m_exe_name.get()).generic_string();
|
||||||
std::string Back = m_exe_path.get() / "BeamMP-Launcher.back";
|
std::string Back = (m_exe_path.get() / "BeamMP-Launcher.back").generic_string();
|
||||||
|
|
||||||
std::string FileHash = sha256_file(EP);
|
std::string FileHash = sha256_file(EP);
|
||||||
|
|
||||||
@ -195,11 +195,11 @@ void Launcher::pre_game() {
|
|||||||
|
|
||||||
auto ZipPath(std::filesystem::path(m_config->game_dir) / "mods/multiplayer/BeamMP.zip");
|
auto ZipPath(std::filesystem::path(m_config->game_dir) / "mods/multiplayer/BeamMP.zip");
|
||||||
|
|
||||||
std::string FileHash = sha256_file(ZipPath);
|
std::string FileHash = sha256_file(ZipPath.generic_string());
|
||||||
|
|
||||||
if (FileHash != LatestHash) {
|
if (FileHash != LatestHash) {
|
||||||
spdlog::info("Downloading BeamMP Update " + LatestHash);
|
spdlog::info("Downloading BeamMP Update " + LatestHash);
|
||||||
HTTP::Download(fmt::format("https://backend.beammp.com/builds/client?download=true&pk={}&branch={}", m_identity->PublicKey, m_config->branch), ZipPath);
|
HTTP::Download(fmt::format("https://backend.beammp.com/builds/client?download=true&pk={}&branch={}", m_identity->PublicKey, m_config->branch), ZipPath.generic_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Target = std::filesystem::path(m_config->game_dir) / "mods/unpacked/beammp";
|
auto Target = std::filesystem::path(m_config->game_dir) / "mods/unpacked/beammp";
|
||||||
@ -268,7 +268,7 @@ void Launcher::game_main() {
|
|||||||
#if defined(PLATFORM_LINUX)
|
#if defined(PLATFORM_LINUX)
|
||||||
auto game_path = (std::filesystem::path(m_config->game_dir) / "BinLinux/BeamNG.drive.x64").generic_string();
|
auto game_path = (std::filesystem::path(m_config->game_dir) / "BinLinux/BeamNG.drive.x64").generic_string();
|
||||||
#elif defined(PLATFORM_WINDOWS)
|
#elif defined(PLATFORM_WINDOWS)
|
||||||
auto game_path = (m_game_dir.get() / "Bin64/BeamNG.drive.x64.exe").generic_string();
|
auto game_path = (std::filesystem::path(m_config->game_dir) / "Bin64/BeamNG.drive.x64.exe").generic_string();
|
||||||
#endif
|
#endif
|
||||||
boost::process::child game(game_path, boost::process::std_out > boost::process::null);
|
boost::process::child game(game_path, boost::process::std_out > boost::process::null);
|
||||||
std::filesystem::current_path(path);
|
std::filesystem::current_path(path);
|
||||||
|
@ -3,6 +3,11 @@
|
|||||||
#if defined(PLATFORM_WINDOWS)
|
#if defined(PLATFORM_WINDOWS)
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <Shlobj.h>
|
||||||
|
// include after shlobj
|
||||||
|
#include <Shlobj_core.h>
|
||||||
|
|
||||||
void plat::ReLaunch(int argc, char** argv) {
|
void plat::ReLaunch(int argc, char** argv) {
|
||||||
std::string Arg;
|
std::string Arg;
|
||||||
@ -28,7 +33,7 @@ void plat::URelaunch(int argc, char** argv) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
void plat::set_console_title(const std::string& title) {
|
void plat::set_console_title(const std::string& title) {
|
||||||
SetConsoleTitleA(title);
|
SetConsoleTitleA(title.c_str());
|
||||||
}
|
}
|
||||||
void plat::clear_screen() {
|
void plat::clear_screen() {
|
||||||
system("cls");
|
system("cls");
|
||||||
@ -135,27 +140,27 @@ std::string plat::get_game_dir_magically() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) {
|
static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) {
|
||||||
|
|
||||||
if (uMsg == BFFM_INITIALIZED) {
|
if (uMsg == BFFM_INITIALIZED) {
|
||||||
std::string tmp = (const char*)lpData;
|
std::string tmp = (const char*)lpData;
|
||||||
std::cout << "path: " << tmp << std::endl;
|
|
||||||
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
|
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::string plat::ask_for_folder() {
|
|
||||||
TCHAR path[MAX_PATH];
|
|
||||||
|
|
||||||
const char* path_param = saved_path.c_str();
|
static std::string impl_ask_for_folder() {
|
||||||
|
TCHAR path[MAX_PATH];
|
||||||
|
std::memset(path, 0, MAX_PATH);
|
||||||
|
|
||||||
|
std::wstring wsaved_path(L"C:\\");
|
||||||
|
const wchar_t* path_param = wsaved_path.c_str();
|
||||||
|
|
||||||
BROWSEINFO bi = { 0 };
|
BROWSEINFO bi = { 0 };
|
||||||
bi.lpszTitle = ("Browse for folder...");
|
bi.lpszTitle = ("Browse for BeamNG.drive folder...");
|
||||||
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
|
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
|
||||||
bi.lpfn = BrowseCallbackProc;
|
bi.lpfn = BrowseCallbackProc;
|
||||||
bi.lParam = (LPARAM)path_param;
|
bi.lParam = (LPARAM)path_param;
|
||||||
|
|
||||||
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
|
LPITEMIDLIST pidl = SHBrowseForFolderA(&bi);
|
||||||
|
|
||||||
if (pidl != 0) {
|
if (pidl != 0) {
|
||||||
// get the name of the folder and put it in path
|
// get the name of the folder and put it in path
|
||||||
@ -174,4 +179,15 @@ std::string plat::ask_for_folder() {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
std::string plat::ask_for_folder() {
|
||||||
|
auto folder = impl_ask_for_folder();
|
||||||
|
while (!std::filesystem::exists(std::filesystem::path(folder) / "BeamNG.drive.exe")) {
|
||||||
|
spdlog::error("This folder ('{}') doesn't contain 'BeamNG.drive.exe', please try again.\n", folder);
|
||||||
|
folder = impl_ask_for_folder();
|
||||||
|
}
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -65,7 +65,7 @@ int main(int argc, char** argv) {
|
|||||||
spdlog::info("BeamMP Launcher v{}.{}.{} is a PRE-RELEASE build. Please report any errors immediately at https://github.com/BeamMP/BeamMP-Launcher.",
|
spdlog::info("BeamMP Launcher v{}.{}.{} is a PRE-RELEASE build. Please report any errors immediately at https://github.com/BeamMP/BeamMP-Launcher.",
|
||||||
PRJ_VERSION_MAJOR, PRJ_VERSION_MINOR, PRJ_VERSION_PATCH);
|
PRJ_VERSION_MAJOR, PRJ_VERSION_MINOR, PRJ_VERSION_PATCH);
|
||||||
|
|
||||||
/*
|
|
||||||
Launcher launcher {};
|
Launcher launcher {};
|
||||||
|
|
||||||
std::filesystem::path arg0(argv[0]);
|
std::filesystem::path arg0(argv[0]);
|
||||||
@ -77,7 +77,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!enable_dev) {
|
if (!enable_dev) {
|
||||||
launcher.check_for_updates(argc, argv);
|
//&launcher.check_for_updates(argc, argv);
|
||||||
} else {
|
} else {
|
||||||
spdlog::debug("Skipping update check due to dev mode");
|
spdlog::debug("Skipping update check due to dev mode");
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
launcher.start_network();
|
launcher.start_network();
|
||||||
*/
|
/*
|
||||||
Launcher launcher {};
|
Launcher launcher {};
|
||||||
|
|
||||||
std::filesystem::path arg0(argv[0]);
|
std::filesystem::path arg0(argv[0]);
|
||||||
@ -104,6 +104,7 @@ int main(int argc, char** argv) {
|
|||||||
spdlog::error("Connection to server closed: {}", e.what());
|
spdlog::error("Connection to server closed: {}", e.what());
|
||||||
}
|
}
|
||||||
spdlog::info("Shutting down.");
|
spdlog::info("Shutting down.");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_logger(bool debug) {
|
void setup_logger(bool debug) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user