mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-23 08:38:58 +00:00
windows compat
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user