From e0971450fe8c2b0798458e9d54b5ed05870f8d48 Mon Sep 17 00:00:00 2001 From: Anonymous275 <36374260+Anonymous-275@users.noreply.github.com> Date: Sun, 16 Jan 2022 21:00:57 +0200 Subject: [PATCH] added json header and fixed static linking --- CMakeLists.txt | 25 +++++++++++++++---------- include/Json.h | 10 ++++++++++ include/Launcher.h | 4 ++-- include/Logger.h | 1 + src/Launcher.cpp | 21 ++++++++++++--------- src/{ => gui}/Gui.cpp | 5 ++--- src/{ => gui}/gifs.cpp | 0 src/{ => gui}/gifs.h | 0 src/main.cpp | 7 +++---- 9 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 include/Json.h rename src/{ => gui}/Gui.cpp (96%) rename src/{ => gui}/gifs.cpp (100%) rename src/{ => gui}/gifs.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b58311..3288abd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.0) project(BeamMP-Launcher) - if (WIN32) - #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}) - + message(STATUS "MSVC -> forcing use of statically-linked runtime.") + STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) + STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) find_package(ZLIB REQUIRED) find_package(OpenSSL REQUIRED) #-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static @@ -15,19 +15,24 @@ if (WIN32) link_directories(${VcpkgRoot}/lib) endif(WIN32) +set(wxUSE_STL ON) set(wxBUILD_SHARED OFF) -add_subdirectory(wxWidgets) +set(wxBUILD_MSVC_MULTIPROC ON) +set(wxBUILD_USE_STATIC_RUNTIME ON) +add_subdirectory(include/wxWidgets) +add_subdirectory(include/rapidjson) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") add_executable(${PROJECT_NAME} - src/main.cpp + src/main.cpp include/easylogging++.h src/Launcher.cpp include/Launcher.h src/Logger.cpp include/Logger.h - src/Gui.cpp - src/gifs.cpp src/gifs.h) + src/gui/Gui.cpp include/Json.h + src/gui/gifs.cpp src/gui/gifs.h + ) if (WIN32) @@ -41,4 +46,4 @@ else(WIN32) #MINGW set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -s --static") target_link_libraries(${PROJECT_NAME} discord-rpc ssl crypto ws2_32 ssp crypt32 z) endif(WIN32) -target_include_directories(${PROJECT_NAME} PRIVATE "include") +target_include_directories(${PROJECT_NAME} PRIVATE "include") \ No newline at end of file diff --git a/include/Json.h b/include/Json.h new file mode 100644 index 0000000..26763d3 --- /dev/null +++ b/include/Json.h @@ -0,0 +1,10 @@ +/// +/// Created by Anonymous275 on 1/16/22 +/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info. +/// + +#pragma once +#include +#include +#include +namespace Json = rapidjson; diff --git a/include/Launcher.h b/include/Launcher.h index 81118d1..c065116 100644 --- a/include/Launcher.h +++ b/include/Launcher.h @@ -9,12 +9,12 @@ class Launcher { public: Launcher(int argc, char* argv[]); + const std::string& getFullVersion(){return FullVersion;} const std::string& getWorkingDir(){return DirPath;} const std::string& getVersion(){return Version;} - const std::string& getFullVersion(){return FullVersion;} + void launchGame(); private: void WindowsInit(); - private: std::string DirPath; std::string Version{"3.0"}; diff --git a/include/Logger.h b/include/Logger.h index bda8b5f..420f446 100644 --- a/include/Logger.h +++ b/include/Logger.h @@ -4,6 +4,7 @@ /// #pragma once +#define ELPP_NO_DEFAULT_LOG_FILE #include "easylogging++.h" class Log { diff --git a/src/Launcher.cpp b/src/Launcher.cpp index 153a67f..8b03b91 100644 --- a/src/Launcher.cpp +++ b/src/Launcher.cpp @@ -3,22 +3,25 @@ /// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info. /// +#define WIN32_LEAN_AND_MEAN #include "Launcher.h" -#include +#include "Logger.h" +#include +#include -Launcher::Launcher(int argc, char **argv) : DirPath(argv[0]) { +Launcher::Launcher(int argc, char* argv[]) : DirPath(argv[0]) { DirPath = DirPath.substr(0, DirPath.find_last_of("\\/") + 1); Log::Init(); WindowsInit(); } -#ifdef WIN32 -#define WIN32_LEAN_AND_MEAN -#include +void Launcher::launchGame() { + ShellExecuteA(nullptr, nullptr, "steam://rungameid/284160", nullptr, nullptr, SW_SHOWNORMAL); + ShowWindow(GetConsoleWindow(), HIDE_WINDOW); + LOG(INFO) << "Sus"; +} + void Launcher::WindowsInit() { system("cls"); SetConsoleTitleA(("BeamMP Launcher v" + FullVersion).c_str()); -} -#else //WIN32 -void Launcher::WindowsInit() {} -#endif //WIN32 \ No newline at end of file +} \ No newline at end of file diff --git a/src/Gui.cpp b/src/gui/Gui.cpp similarity index 96% rename from src/Gui.cpp rename to src/gui/Gui.cpp index bab4293..5252d43 100644 --- a/src/Gui.cpp +++ b/src/gui/Gui.cpp @@ -3,9 +3,8 @@ /// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info. /// -#include +#define _CRT_SECURE_NO_WARNINGS #include - #include #ifndef WX_PRECOMP #include @@ -85,7 +84,7 @@ void MyFrame::OnHello(wxCommandEvent& event) { } -int Entry (int argc, char *argv[]) { +int GUIEntry (int argc, char *argv[]) { new MyApp(); return wxEntry(argc, argv); } \ No newline at end of file diff --git a/src/gifs.cpp b/src/gui/gifs.cpp similarity index 100% rename from src/gifs.cpp rename to src/gui/gifs.cpp diff --git a/src/gifs.h b/src/gui/gifs.h similarity index 100% rename from src/gifs.h rename to src/gui/gifs.h diff --git a/src/main.cpp b/src/main.cpp index ffaa774..66887c6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,10 +4,9 @@ /// #include "Launcher.h" - -int Entry (int argc, char *argv[]); - +#include "Logger.h" int main(int argc, char* argv[]) { Launcher launcher(argc, argv); - return Entry(argc, argv); + launcher.launchGame(); + return 0; }