| 52 | } |
| 53 | |
| 54 | bool OnInitialize() override { |
| 55 | auto exe_dir = rex::filesystem::GetExecutableFolder(); |
| 56 | |
| 57 | // Assets root: arg or default to exe_dir/assets |
| 58 | std::filesystem::path assets_root; |
| 59 | if (auto arg = GetArgument("game_directory")) { |
| 60 | assets_root = *arg; |
| 61 | } else { |
| 62 | assets_root = exe_dir / "assets"; |
| 63 | } |
| 64 | auto game_dir = assets_root / "game"; |
| 65 | auto update_dir = assets_root / "update"; |
| 66 | |
| 67 | // Logging setup from CVARs |
| 68 | std::string log_file_cvar = REXCVAR_GET(log_file); |
| 69 | std::string log_level_str = REXCVAR_GET(log_level); |
| 70 | if (REXCVAR_GET(log_verbose) && log_level_str == "info") { |
| 71 | log_level_str = "trace"; |
| 72 | } |
| 73 | auto log_config = rex::BuildLogConfig( |
| 74 | log_file_cvar.empty() ? nullptr : log_file_cvar.c_str(), |
| 75 | log_level_str, {}); |
| 76 | rex::InitLogging(log_config); |
| 77 | rex::RegisterLogLevelCallback(); |
| 78 | |
| 79 | // Log capture sink for console overlay |
| 80 | log_sink_ = std::make_shared<rex::LogCaptureSink>(); |
| 81 | for (size_t i = 0; i < static_cast<size_t>(rex::LogCategory::Count); ++i) { |
| 82 | auto logger = rex::GetLogger(static_cast<rex::LogCategory>(i)); |
| 83 | if (logger) { |
| 84 | logger->sinks().push_back(log_sink_); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | REXLOG_INFO("Fable2 starting"); |
| 89 | REXLOG_INFO(" Game directory: {}", game_dir.string()); |
| 90 | REXLOG_INFO(" Update directory: {}", update_dir.string()); |
| 91 | |
| 92 | // Create runtime with custom content paths |
| 93 | runtime_ = std::make_unique<rex::Runtime>(game_dir, game_dir, update_dir); |
| 94 | runtime_->set_app_context(&app_context()); |
| 95 | |
| 96 | // Build runtime config with platform backends |
| 97 | rex::RuntimeConfig config; |
| 98 | #if REX_HAS_D3D12 |
| 99 | config.graphics = REX_GRAPHICS_BACKEND(rex::graphics::d3d12::D3D12GraphicsSystem); |
| 100 | #elif REX_HAS_VULKAN |
| 101 | config.graphics = REX_GRAPHICS_BACKEND(rex::graphics::vulkan::VulkanGraphicsSystem); |
| 102 | #endif |
| 103 | config.audio_factory = REX_AUDIO_BACKEND(rex::audio::sdl::SDLAudioSystem); |
| 104 | config.input_factory = REX_INPUT_BACKEND(rex::input::CreateDefaultInputSystem); |
| 105 | |
| 106 | auto status = runtime_->Setup( |
| 107 | static_cast<uint32_t>(PPC_CODE_BASE), |
| 108 | static_cast<uint32_t>(PPC_CODE_SIZE), |
| 109 | static_cast<uint32_t>(PPC_IMAGE_BASE), |
| 110 | static_cast<uint32_t>(PPC_IMAGE_SIZE), |
| 111 | PPCFuncMappings, |
nothing calls this directly
no test coverage detected