45 #ifdef USE_ANGELSCRIPT
83 if (!ImGui::GetIO().WantCaptureMouse)
103 if (!ImGui::GetIO().WantCaptureMouse)
124 if (!ImGui::GetIO().WantCaptureMouse)
143 !ImGui::GetIO().WantCaptureKeyboard)
156 !ImGui::GetIO().WantCaptureKeyboard)
186 actor->ar_dashboard->windowResized();
208 rw->getCustomAttribute(
"WINDOW", &hWnd);
211 ::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);
213 HINSTANCE
instance = ::GetModuleHandleA(buf);
214 HICON hIcon = ::LoadIconA(
instance, MAKEINTRESOURCEA(101));
217 ::SendMessageA((HWND)hWnd, WM_SETICON, 1, (LPARAM)hIcon);
218 ::SendMessageA((HWND)hWnd, WM_SETICON, 0, (LPARAM)hIcon);
230 LOG(
fmt::format(
"[RoR|Startup|Rendering] Creating OGRE renderer Root object, config='{}'", cfg_filepath));
231 m_ogre_root =
new Ogre::Root(
"", cfg_filepath, log_filepath);
239 LOG(
fmt::format(
"[RoR|Startup|Rendering] Loading OGRE renderer plugins config '{}'.", plugins_path));
242 Ogre::ConfigFile cfg;
243 cfg.load(plugins_path);
245 Ogre::StringVector plugins = cfg.getMultiSetting(
"Plugin");
246 for (Ogre::String plugin_filename: plugins)
252 catch (Ogre::Exception&) {}
255 catch (Ogre::Exception& e)
259 fmt::format(
_L(
"Could not load file '{}' - make sure the game is installed correctly.\n\nDetailed info: {}"), plugins_path, e.getDescription()));
264 bool autodetect_resolution =
false;
269 autodetect_resolution =
true;
270 LOG(
fmt::format(
"[RoR|Startup|Rendering] WARNING - invalid 'ogre.cfg', selecting render plugin manually..."));
273 if (!render_systems.empty())
275 LOG(
fmt::format(
"[RoR|Startup|Rendering] Auto-selected renderer plugin '{}'", render_systems.front()->getName()));
276 m_ogre_root->setRenderSystem(render_systems.front());
285 catch (Ogre::Exception& e)
292 if (rs !=
nullptr && rs !=
m_ogre_root->getRenderSystem())
294 LOG(
fmt::format(
"[RoR|Startup|Rendering] Setting renderer '{}' on behalf of 'app_rendersys_override' (user selection via Settings UI)", rs->getName()));
302 LOG(
fmt::format(
"[RoR|Startup|Rendering] Starting renderer '{}' (without auto-creating render window)",
m_ogre_root->getRenderSystem()->getName()));
306 Ogre::ConfigOptionMap ropts =
m_ogre_root->getRenderSystem()->getConfigOptions();
307 std::stringstream ropts_log;
308 for (
auto& pair: ropts)
310 ropts_log <<
" " << pair.first <<
" = " << pair.second.currentValue <<
" (";
311 for (
auto& val: pair.second.possibleValues)
313 ropts_log << val <<
", ";
317 LOG(
fmt::format(
"[RoR|Startup|Rendering] Renderer options as reported by OGRE:\n{}", ropts_log.str()));
320 Ogre::NameValuePairList miscParams;
321 miscParams[
"FSAA"] = ropts[
"FSAA"].currentValue;
322 miscParams[
"vsync"] = ropts[
"VSync"].currentValue;
323 miscParams[
"gamma"] = ropts[
"sRGB Gamma Conversion"].currentValue;
326 miscParams[
"border"] =
"fixed";
328 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
329 const auto rd = ropts[
"Rendering Device"];
330 const auto it = std::find(rd.possibleValues.begin(), rd.possibleValues.end(), rd.currentValue);
331 const int idx = std::distance(rd.possibleValues.begin(), it);
332 miscParams[
"monitorIndex"] = Ogre::StringConverter::toString(idx);
333 miscParams[
"windowProc"] = Ogre::StringConverter::toString((
size_t)OgreBites::WindowEventUtilities::_WndProc);
337 Ogre::uint32 width, height;
338 std::istringstream mode (ropts[
"Video Mode"].currentValue);
344 if(width < 800) width = 800;
345 if(height < 600) height = 600;
347 if (autodetect_resolution)
349 for (
auto& p_mode_str: ropts[
"Video Mode"].possibleValues)
351 Ogre::uint32 p_width, p_height;
352 std::istringstream p_mode (p_mode_str);
356 if (p_width >= width && p_height >= height)
360 m_ogre_root->getRenderSystem()->setConfigOption(
"Video Mode", p_mode_str);
364 LOG(
fmt::format(
"[RoR|Startup|Rendering] WARNING - invalid 'ogre.cfg', auto-detected resolution {}x{}", width, height));
369 std::stringstream miscParams_log;
370 for (
auto& pair: miscParams)
372 miscParams_log <<
" " << pair.first <<
" = " << pair.second <<
"\n";
374 LOG(
fmt::format(
"[RoR|Startup|Rendering] Creating render window with settings:\n{}", miscParams_log.str()));
379 width, height, ropts[
"Full Screen"].currentValue ==
"Yes", &miscParams);
381 OgreBites::WindowEventUtilities::addWindowEventListener(
m_render_window,
this);
388 m_viewport->setBackgroundColour(Ogre::ColourValue::Black);
395 Ogre::NameValuePairList misc;
396 Ogre::ConfigOptionMap ropts =
m_ogre_root->getRenderSystem()->getConfigOptions();
397 misc[
"FSAA"] = Ogre::StringConverter::parseInt(ropts[
"FSAA"].currentValue, 0);
399 Ogre::RenderWindow* rw = Ogre::Root::getSingleton().createRenderWindow(window_name, width, height,
false, &misc);
405 const std::time_t time = std::time(
nullptr);
408 std::stringstream stamp;
409 stamp << std::put_time(std::localtime(&time),
"%Y-%m-%d_%H-%M-%S") <<
"_" << index
444 _L(
"Screenshot: ") + stamp.str());
472 if (exe_path.empty())
490 if (user_home.empty())
496 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
497 ror_homedir << user_home <<
PATH_SLASH <<
"My Games";
500 #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
501 char* env_SNAP = getenv(
"SNAP_USER_COMMON");
503 ror_homedir = env_SNAP;
505 ror_homedir << user_home <<
PATH_SLASH <<
".rigsofrods";
506 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
507 ror_homedir << user_home <<
PATH_SLASH <<
"RigsOfRods";
522 auto ogre_log_manager = OGRE_NEW Ogre::LogManager();
523 std::string rorlog_path =
PathCombine(logs_dir,
"RoR.log");
524 Ogre::Log* rorlog = ogre_log_manager->createLog(rorlog_path,
true,
true);
525 rorlog->stream() <<
"[RoR] Rigs of Rods (www.rigsofrods.org) version " <<
ROR_VERSION_STRING;
526 std::time_t t = std::time(
nullptr);
527 rorlog->stream() <<
"[RoR] Current date: " << std::put_time(std::localtime(&t),
"%Y-%m-%d");
535 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
538 process_dir =
"/usr/share/rigsofrods/resources/";
553 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(src_path,
"Zip",
"SrcRG");
554 Ogre::FileInfoListPtr fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"SrcRG",
"*",
true);
561 for (
auto file : *fl)
565 fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"SrcRG",
"*");
571 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(dst_path,
"FileSystem",
"DstRG",
false,
false);
572 for (
auto file : *fl)
574 if (
file.uncompressedSize == 0)
576 Ogre::String path =
file.path +
file.basename;
577 if (!Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"DstRG", path)->empty())
579 Ogre::DataStreamPtr src_ds = Ogre::ResourceGroupManager::getSingleton().openResource(path,
"SrcRG");
580 Ogre::DataStreamPtr dst_ds = Ogre::ResourceGroupManager::getSingleton().createResource(path,
"DstRG");
581 std::vector<char> buf(src_ds->size());
582 size_t read = src_ds->read(buf.data(), src_ds->size());
585 dst_ds->write(buf.data(), read);
588 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"SrcRG");
589 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"DstRG");
596 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
605 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(old_ror_homedir,
"FileSystem",
"homedir",
false,
false);
606 Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().createResource(
"OBSOLETE_FOLDER.txt",
"homedir");
607 stream->write(obsoleteMessage.c_str(), obsoleteMessage.length());
608 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"homedir");
610 catch (std::exception & e)
612 RoR::LogFormat(
"Error writing to %s, message: '%s'", old_ror_homedir.c_str(), e.what());
615 "Welcome to Rigs of Rods %s\nPlease note that the mods folder has moved to:\n\"%s\"\nPlease move your mods to the new folder to continue using them",
623 #endif // OGRE_PLATFORM_WIN32