diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index 92c7ade..8dc0635 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -293,7 +293,12 @@ if (WIN32) set(WIN32_ICON_PATH "${PROJECT_SOURCE_DIR}/../UnleashedRecompResources/images/game_icon.ico") configure_file("res/win32/res.rc.template" "${CMAKE_BINARY_DIR}/res.rc" @ONLY) - add_executable(UnleashedRecomp ${UNLEASHED_RECOMP_CXX_SOURCES} "${CMAKE_BINARY_DIR}/res.rc") + add_executable(UnleashedRecomp ${UNLEASHED_RECOMP_CXX_SOURCES} "${CMAKE_BINARY_DIR}/res.rc") + + # Hide console for release configurations. + if (${CMAKE_BUILD_TYPE} MATCHES "Release") + target_link_options(UnleashedRecomp PRIVATE "/SUBSYSTEM:WINDOWS" "/ENTRY:mainCRTStartup") + endif() else() add_executable(UnleashedRecomp ${UNLEASHED_RECOMP_CXX_SOURCES}) endif() diff --git a/UnleashedRecomp/main.cpp b/UnleashedRecomp/main.cpp index 6c14d33..65aaab3 100644 --- a/UnleashedRecomp/main.cpp +++ b/UnleashedRecomp/main.cpp @@ -172,6 +172,9 @@ int main(int argc, char *argv[]) Config::Load(); + if (Config::ShowConsole) + os::process::ShowConsole(); + HostStartup(); std::filesystem::path modulePath; diff --git a/UnleashedRecomp/mod/mod_loader.cpp b/UnleashedRecomp/mod/mod_loader.cpp index 8d704b3..2aecb3f 100644 --- a/UnleashedRecomp/mod/mod_loader.cpp +++ b/UnleashedRecomp/mod/mod_loader.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include enum class ModType @@ -115,6 +116,9 @@ void ModLoader::Init() ModLoader::s_saveFilePath /= "SYS-DATA"; } + if (configIni.getString("CPKREDIR", "LogType", std::string()) == "console") + os::process::ShowConsole(); + std::string modsDbIniFilePathU8 = configIni.getString("CPKREDIR", "ModsDbIni", ""); if (modsDbIniFilePathU8.empty()) return; diff --git a/UnleashedRecomp/os/linux/process_linux.cpp b/UnleashedRecomp/os/linux/process_linux.cpp index 3a9dc89..276fc0c 100644 --- a/UnleashedRecomp/os/linux/process_linux.cpp +++ b/UnleashedRecomp/os/linux/process_linux.cpp @@ -60,3 +60,8 @@ bool os::process::StartProcess(const std::filesystem::path& path, const std::vec return true; } + +void os::process::ShowConsole() +{ + // Unnecessary on Linux. +} diff --git a/UnleashedRecomp/os/process.h b/UnleashedRecomp/os/process.h index f93ce53..a81caed 100644 --- a/UnleashedRecomp/os/process.h +++ b/UnleashedRecomp/os/process.h @@ -6,4 +6,5 @@ namespace os::process std::filesystem::path GetWorkingDirectory(); bool SetWorkingDirectory(const std::filesystem::path& path); bool StartProcess(const std::filesystem::path& path, const std::vector& args, std::filesystem::path work = {}); + void ShowConsole(); } diff --git a/UnleashedRecomp/os/win32/process_win32.cpp b/UnleashedRecomp/os/win32/process_win32.cpp index 1ad6145..230846b 100644 --- a/UnleashedRecomp/os/win32/process_win32.cpp +++ b/UnleashedRecomp/os/win32/process_win32.cpp @@ -51,3 +51,14 @@ bool os::process::StartProcess(const std::filesystem::path& path, const std::vec return true; } + +void os::process::ShowConsole() +{ + if (GetConsoleWindow() == nullptr) + { + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stderr); + freopen("CONOUT$", "w", stdout); + } +} diff --git a/UnleashedRecomp/user/config_def.h b/UnleashedRecomp/user/config_def.h index 33fcde1..729cb49 100644 --- a/UnleashedRecomp/user/config_def.h +++ b/UnleashedRecomp/user/config_def.h @@ -8,6 +8,7 @@ CONFIG_DEFINE_LOCALISED("System", bool, Hints, true); CONFIG_DEFINE_LOCALISED("System", bool, ControlTutorial, true); CONFIG_DEFINE_LOCALISED("System", bool, AchievementNotifications, true); CONFIG_DEFINE_ENUM_LOCALISED("System", ETimeOfDayTransition, TimeOfDayTransition, ETimeOfDayTransition::Xbox); +CONFIG_DEFINE("System", bool, ShowConsole, false); CONFIG_DEFINE_LOCALISED("Input", bool, InvertCameraX, false); CONFIG_DEFINE_LOCALISED("Input", bool, InvertCameraY, false);