Build Dreierpack Manager as a program of its own

The dreierpack target (Dreierpack.exe) starts the Modern interface without
the original-style window program. It opens Modern worlds only and refuses
original-format saves; OpenBMH.exe is still built beside it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 08:50:33 +01:00
1 parent 749c5ec512
commit d6d691fafb
2 files changed
+130

No files matched your search

+16
View File
@@ -519,6 +519,22 @@ if(MSVC)
src/app/desktop_actions.cpp PROPERTIES COMPILE_OPTIONS /utf-8)
endif()
# Dreierpack Manager: the Modern interface as a program of its own, without the original-style
# window program. It shares the assets directory beside the executable.
if(OPENBMH_BUILD_MODERN_UI)
add_executable(dreierpack src/modern/app/dreierpack_main.cpp)
target_link_libraries(dreierpack PRIVATE bmh_modern_ui bmh_launcher ${BMH_SDL_TARGET})
set_target_properties(dreierpack PROPERTIES WIN32_EXECUTABLE TRUE OUTPUT_NAME Dreierpack)
if(MSVC)
target_compile_options(dreierpack PRIVATE /utf-8)
endif()
if(CMAKE_CONFIGURATION_TYPES)
add_custom_command(TARGET dreierpack POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/assets/modern"
"$<TARGET_FILE_DIR:dreierpack>/assets/modern")
endif()
endif()
# Development helper: drives the career session like the UI, without a window
add_executable(play_check tests/play_check.cpp ${BMH_APP_SESSION_SOURCE})
target_link_libraries(play_check PRIVATE bmhui)
+114
View File
@@ -0,0 +1,114 @@
// SPDX-License-Identifier: GPL-3.0-only
// Dreierpack Manager - the Modern interface on the Modern season core, as a program of its
// own. It opens Modern worlds only; original-style games belong to OpenBMH.
//
// Usage: Dreierpack [<world.obw>] [--ui-career <career.obs>] [--gui-assets <directory>]
// [--ui-userdata <directory>] [--ui-theme midnight|silver|matchday]
// [--ui-size WIDTHxHEIGHT]
// Without a world the main menu opens with the mods beside the program.
#include <SDL.h>
#include <cstdio>
#include <filesystem>
#include <stdexcept>
#include <string>
#include <vector>
#include "launch/archive.hpp"
#include "launch/mods.hpp"
#include "launch/startup_error.hpp"
#include "modern/ui/view.hpp"
#include "version.hpp"
namespace fs = std::filesystem;
using namespace bmh;
namespace {
constexpr const char *kProduct = "Dreierpack Manager";
#ifdef _WIN32
constexpr const char *kProgram = "Dreierpack.exe";
#else
constexpr const char *kProgram = "Dreierpack";
#endif
void show_start_error(const std::string &text) { rml::report_start_error(kProduct, text); }
} // namespace
int main(int argc, char **argv) {
rml::attach_parent_console();
const std::vector<std::string> args = launch::utf8_arguments(argc, argv);
modern_ui::Config config;
fs::path world;
try {
for (size_t i = 1; i < args.size(); ++i) {
const auto is = [&](const char *name) { return args[i] == name; };
const bool value = i + 1 < args.size();
const auto path = [&] { return launch::path_from_utf8(args[++i]); };
if (is("--version")) {
std::printf("%s %s\n", kProduct, bmh::kOpenBmhVersion);
return 0;
} else if (is("--help") || is("-h")) {
std::printf("usage: Dreierpack [<world.obw>] [--ui-career <career.obs>] [--gui-assets <directory>] "
"[--ui-userdata <directory>] [--ui-theme midnight|silver|matchday] [--ui-size WIDTHxHEIGHT]\n");
return 0;
} else if (is("--modern-ui-demo")) {
config.preview_only = true;
} else if (is("--ui-seed") && value) {
const auto text = args[++i];
size_t used = 0;
const auto n = std::stoull(text, &used);
if (used != text.size() || n > UINT32_MAX || text.empty() || text.front() == '-')
throw std::runtime_error("Ungültiger Startseed.");
config.creation_seed = uint32_t(n);
} else if (is("--gui-assets") && value) config.gui_assets = path();
else if (is("--ui-scene") && value) config.scene = args[++i];
else if (is("--ui-theme") && value) config.theme = args[++i];
else if (is("--ui-screenshot") && value) config.screenshot = path();
else if (is("--ui-script") && value) config.commands = path();
else if (is("--ui-career") && value) config.engine_save = path();
else if (is("--ui-state") && value) { config.state = path(); config.preview_only = true; }
else if (is("--ui-preferences") && value) config.preferences = path();
else if (is("--ui-userdata") && value) config.userdata = path();
else if (is("--ui-file-import") && value) config.file_import = path();
else if (is("--ui-file-export") && value) config.file_export = path();
else if (is("--ui-mods") && value) config.mods = path();
else if (is("--ui-mod-import") && value) config.mod_import = path();
else if (is("--ui-size") && value) {
const auto size = args[++i];
const auto separator = size.find('x');
if (separator == std::string::npos) throw std::runtime_error("--ui-size requires WIDTHxHEIGHT");
config.width = std::stoi(size.substr(0, separator));
config.height = std::stoi(size.substr(separator + 1));
if (config.width < 960 || config.width > 7680 || config.height < 540 || config.height > 4320)
throw std::runtime_error("Unsupported window size");
} else if ((is("--run-mod") || is("--mod") || is("--data")) && value) world = path();
else if (args[i].rfind("--", 0) != 0 && world.empty()) world = launch::path_from_utf8(args[i]);
else {
show_start_error("Unknown option or missing argument: " + args[i]);
return 1;
}
}
} catch (const std::exception &e) {
show_start_error(e.what());
return 1;
}
fs::path executable;
if (char *base = SDL_GetBasePath()) {
executable = launch::path_from_utf8(base);
SDL_free(base);
executable /= kProgram;
} else
executable = fs::absolute(launch::path_from_utf8(args.front()));
try {
if (!world.empty() && !modern_ui::is_modern_world(world))
throw std::runtime_error("Dreierpack Manager öffnet nur Modern-Welten. Spiele im Originalstil startet OpenBMH.");
// Saves of original-style games are not taken over here.
const launch::SaveMigrator refuse = [](const fs::path &, const fs::path &, const fs::path &) {
throw std::runtime_error("Spielstände im Originalformat übernimmt OpenBMH, nicht Dreierpack Manager.");
};
config.world = world;
return modern_ui::run(executable, refuse, config);
} catch (const std::exception &e) {
show_start_error(e.what());
return 1;
}
}