mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 23:46:59 +00:00
windows compat
This commit is contained in:
parent
6a7bf72df5
commit
ece4a42103
@ -12,6 +12,9 @@ project(
|
||||
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/StaticAnalyzers.cmake)
|
||||
include(cmake/Git.cmake)
|
||||
@ -68,6 +71,7 @@ set(PRJ_LIBRARIES
|
||||
Boost::system
|
||||
Boost::iostreams
|
||||
Boost::thread
|
||||
Boost::filesystem
|
||||
cryptopp::cryptopp
|
||||
ZLIB::ZLIB
|
||||
OpenSSL::SSL
|
||||
@ -81,7 +85,7 @@ find_package(fmt CONFIG REQUIRED)
|
||||
find_package(doctest CONFIG REQUIRED)
|
||||
find_package(spdlog 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(ZLIB REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
@ -115,10 +119,6 @@ include(cmake/CompilerWarnings.cmake)
|
||||
|
||||
# set MT library for msvc - this is required (says documentation)
|
||||
# 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}
|
||||
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);
|
||||
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);
|
||||
|
||||
@ -195,11 +195,11 @@ void Launcher::pre_game() {
|
||||
|
||||
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) {
|
||||
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";
|
||||
@ -268,7 +268,7 @@ void Launcher::game_main() {
|
||||
#if defined(PLATFORM_LINUX)
|
||||
auto game_path = (std::filesystem::path(m_config->game_dir) / "BinLinux/BeamNG.drive.x64").generic_string();
|
||||
#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
|
||||
boost::process::child game(game_path, boost::process::std_out > boost::process::null);
|
||||
std::filesystem::current_path(path);
|
||||
|
@ -3,6 +3,11 @@
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <Shlobj.h>
|
||||
// include after shlobj
|
||||
#include <Shlobj_core.h>
|
||||
|
||||
void plat::ReLaunch(int argc, char** argv) {
|
||||
std::string Arg;
|
||||
@ -28,7 +33,7 @@ void plat::URelaunch(int argc, char** argv) {
|
||||
exit(1);
|
||||
}
|
||||
void plat::set_console_title(const std::string& title) {
|
||||
SetConsoleTitleA(title);
|
||||
SetConsoleTitleA(title.c_str());
|
||||
}
|
||||
void plat::clear_screen() {
|
||||
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) {
|
||||
|
||||
if (uMsg == BFFM_INITIALIZED) {
|
||||
std::string tmp = (const char*)lpData;
|
||||
std::cout << "path: " << tmp << std::endl;
|
||||
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
|
||||
}
|
||||
|
||||
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 };
|
||||
bi.lpszTitle = ("Browse for folder...");
|
||||
bi.lpszTitle = ("Browse for BeamNG.drive folder...");
|
||||
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
|
||||
bi.lpfn = BrowseCallbackProc;
|
||||
bi.lParam = (LPARAM)path_param;
|
||||
|
||||
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
|
||||
LPITEMIDLIST pidl = SHBrowseForFolderA(&bi);
|
||||
|
||||
if (pidl != 0) {
|
||||
// get the name of the folder and put it in path
|
||||
@ -174,4 +179,15 @@ std::string plat::ask_for_folder() {
|
||||
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
|
@ -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.",
|
||||
PRJ_VERSION_MAJOR, PRJ_VERSION_MINOR, PRJ_VERSION_PATCH);
|
||||
|
||||
/*
|
||||
|
||||
Launcher launcher {};
|
||||
|
||||
std::filesystem::path arg0(argv[0]);
|
||||
@ -77,7 +77,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (!enable_dev) {
|
||||
launcher.check_for_updates(argc, argv);
|
||||
//&launcher.check_for_updates(argc, argv);
|
||||
} else {
|
||||
spdlog::debug("Skipping update check due to dev mode");
|
||||
}
|
||||
@ -90,7 +90,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
launcher.start_network();
|
||||
*/
|
||||
/*
|
||||
Launcher launcher {};
|
||||
|
||||
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::info("Shutting down.");
|
||||
*/
|
||||
}
|
||||
|
||||
void setup_logger(bool debug) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user