Hide console on Release configuration. (#244)

This commit is contained in:
Skyth (Asilkan) 2025-01-30 19:16:21 +03:00 committed by GitHub
parent c78c2010a3
commit 9fea5f9e4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 31 additions and 1 deletions

View file

@ -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()

View file

@ -172,6 +172,9 @@ int main(int argc, char *argv[])
Config::Load();
if (Config::ShowConsole)
os::process::ShowConsole();
HostStartup();
std::filesystem::path modulePath;

View file

@ -6,6 +6,7 @@
#include <kernel/function.h>
#include <kernel/heap.h>
#include <user/paths.h>
#include <os/process.h>
#include <xxHashMap.h>
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;

View file

@ -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.
}

View file

@ -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<std::string>& args, std::filesystem::path work = {});
void ShowConsole();
}

View file

@ -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);
}
}

View file

@ -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);