44 #ifdef USE_ANGELSCRIPT
81 if (!ImGui::GetIO().WantCaptureMouse)
105 if (!ImGui::GetIO().WantCaptureMouse)
107 bool handled =
false;
132 if (!ImGui::GetIO().WantCaptureMouse)
134 bool handled =
false;
157 !ImGui::GetIO().WantCaptureKeyboard)
170 !ImGui::GetIO().WantCaptureKeyboard)
197 actor->ar_dashboard->windowResized();
214 rw->getCustomAttribute(
"WINDOW", &hWnd);
217 ::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);
219 HINSTANCE
instance = ::GetModuleHandleA(buf);
220 HICON hIcon = ::LoadIconA(
instance, MAKEINTRESOURCEA(101));
223 ::SendMessageA((HWND)hWnd, WM_SETICON, 1, (LPARAM)hIcon);
224 ::SendMessageA((HWND)hWnd, WM_SETICON, 0, (LPARAM)hIcon);
236 LOG(
fmt::format(
"[RoR|Startup|Rendering] Creating OGRE renderer Root object, config='{}'", cfg_filepath));
237 m_ogre_root =
new Ogre::Root(
"", cfg_filepath, log_filepath);
245 LOG(
fmt::format(
"[RoR|Startup|Rendering] Loading OGRE renderer plugins config '{}'.", plugins_path));
248 Ogre::ConfigFile cfg;
249 cfg.load(plugins_path);
251 Ogre::StringVector plugins = cfg.getMultiSetting(
"Plugin");
252 for (Ogre::String plugin_filename: plugins)
258 catch (Ogre::Exception&) {}
261 catch (Ogre::Exception& e)
265 fmt::format(
_L(
"Could not load file '{}' - make sure the game is installed correctly.\n\nDetailed info: {}"), plugins_path, e.getDescription()));
270 bool autodetect_resolution =
false;
273 autodetect_resolution =
true;
274 LOG(
fmt::format(
"[RoR|Startup|Rendering] WARNING - invalid 'ogre.cfg', selecting render plugin manually..."));
277 if (!render_systems.empty())
279 LOG(
fmt::format(
"[RoR|Startup|Rendering] Auto-selected renderer plugin '{}'", render_systems.front()->getName()));
280 m_ogre_root->setRenderSystem(render_systems.front());
290 if (rs !=
nullptr && rs !=
m_ogre_root->getRenderSystem())
292 LOG(
fmt::format(
"[RoR|Startup|Rendering] Setting renderer '{}' on behalf of 'app_rendersys_override' (user selection via Settings UI)", rs->getName()));
300 LOG(
fmt::format(
"[RoR|Startup|Rendering] Starting renderer '{}' (without auto-creating render window)",
m_ogre_root->getRenderSystem()->getName()));
304 Ogre::ConfigOptionMap ropts =
m_ogre_root->getRenderSystem()->getConfigOptions();
305 std::stringstream ropts_log;
306 for (
auto& pair: ropts)
308 ropts_log <<
" " << pair.first <<
" = " << pair.second.currentValue <<
" (";
309 for (
auto& val: pair.second.possibleValues)
311 ropts_log << val <<
", ";
315 LOG(
fmt::format(
"[RoR|Startup|Rendering] Renderer options as reported by OGRE:\n{}", ropts_log.str()));
318 Ogre::NameValuePairList miscParams;
319 miscParams[
"FSAA"] = ropts[
"FSAA"].currentValue;
320 miscParams[
"vsync"] = ropts[
"VSync"].currentValue;
321 miscParams[
"gamma"] = ropts[
"sRGB Gamma Conversion"].currentValue;
324 miscParams[
"border"] =
"fixed";
326 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
327 const auto rd = ropts[
"Rendering Device"];
328 const auto it = std::find(rd.possibleValues.begin(), rd.possibleValues.end(), rd.currentValue);
329 const int idx = std::distance(rd.possibleValues.begin(), it);
330 miscParams[
"monitorIndex"] = Ogre::StringConverter::toString(idx);
331 miscParams[
"windowProc"] = Ogre::StringConverter::toString((
size_t)OgreBites::WindowEventUtilities::_WndProc);
335 Ogre::uint32 width, height;
336 std::istringstream mode (ropts[
"Video Mode"].currentValue);
342 if(width < 800) width = 800;
343 if(height < 600) height = 600;
345 if (autodetect_resolution)
347 for (
auto& p_mode_str: ropts[
"Video Mode"].possibleValues)
349 Ogre::uint32 p_width, p_height;
350 std::istringstream p_mode (p_mode_str);
354 if (p_width >= width && p_height >= height)
358 m_ogre_root->getRenderSystem()->setConfigOption(
"Video Mode", p_mode_str);
362 LOG(
fmt::format(
"[RoR|Startup|Rendering] WARNING - invalid 'ogre.cfg', auto-detected resolution {}x{}", width, height));
367 std::stringstream miscParams_log;
368 for (
auto& pair: miscParams)
370 miscParams_log <<
" " << pair.first <<
" = " << pair.second <<
"\n";
372 LOG(
fmt::format(
"[RoR|Startup|Rendering] Creating render window with settings:\n{}", miscParams_log.str()));
377 width, height, ropts[
"Full Screen"].currentValue ==
"Yes", &miscParams);
385 m_viewport->setBackgroundColour(Ogre::ColourValue::Black);
392 Ogre::NameValuePairList misc;
393 Ogre::ConfigOptionMap ropts =
m_ogre_root->getRenderSystem()->getConfigOptions();
394 misc[
"FSAA"] = Ogre::StringConverter::parseInt(ropts[
"FSAA"].currentValue, 0);
396 Ogre::RenderWindow* rw = Ogre::Root::getSingleton().createRenderWindow(window_name, width, height,
false, &misc);
402 const std::time_t time = std::time(
nullptr);
405 std::stringstream stamp;
406 stamp << std::put_time(std::localtime(&time),
"%Y-%m-%d_%H-%M-%S") <<
"_" << index
441 _L(
"Screenshot: ") + stamp.str());
469 if (exe_path.empty())
487 if (user_home.empty())
493 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
494 ror_homedir << user_home <<
PATH_SLASH <<
"My Games";
497 #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
498 char* env_SNAP = getenv(
"SNAP_USER_COMMON");
500 ror_homedir = env_SNAP;
502 ror_homedir << user_home <<
PATH_SLASH <<
".rigsofrods";
503 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
504 ror_homedir << user_home <<
PATH_SLASH <<
"RigsOfRods";
519 auto ogre_log_manager = OGRE_NEW Ogre::LogManager();
520 std::string rorlog_path =
PathCombine(logs_dir,
"RoR.log");
521 Ogre::Log* rorlog = ogre_log_manager->createLog(rorlog_path,
true,
true);
522 rorlog->stream() <<
"[RoR] Rigs of Rods (www.rigsofrods.org) version " <<
ROR_VERSION_STRING;
523 std::time_t t = std::time(
nullptr);
524 rorlog->stream() <<
"[RoR] Current date: " << std::put_time(std::localtime(&t),
"%Y-%m-%d");
532 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
535 process_dir =
"/usr/share/rigsofrods/resources/";
550 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(src_path,
"Zip",
"SrcRG");
551 Ogre::FileInfoListPtr fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"SrcRG",
"*",
true);
558 for (
auto file : *fl)
562 fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"SrcRG",
"*");
568 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(dst_path,
"FileSystem",
"DstRG",
false,
false);
569 for (
auto file : *fl)
571 if (
file.uncompressedSize == 0)
573 Ogre::String path =
file.path +
file.basename;
574 if (!Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"DstRG", path)->empty())
576 Ogre::DataStreamPtr src_ds = Ogre::ResourceGroupManager::getSingleton().openResource(path,
"SrcRG");
577 Ogre::DataStreamPtr dst_ds = Ogre::ResourceGroupManager::getSingleton().createResource(path,
"DstRG");
578 std::vector<char> buf(src_ds->size());
579 size_t read = src_ds->read(buf.data(), src_ds->size());
582 dst_ds->write(buf.data(), read);
585 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"SrcRG");
586 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"DstRG");
593 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
602 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(old_ror_homedir,
"FileSystem",
"homedir",
false,
false);
603 Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().createResource(
"OBSOLETE_FOLDER.txt",
"homedir");
604 stream->write(obsoleteMessage.c_str(), obsoleteMessage.length());
605 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"homedir");
607 catch (std::exception & e)
609 RoR::LogFormat(
"Error writing to %s, message: '%s'", old_ror_homedir.c_str(), e.what());
612 "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",
620 #endif // OGRE_PLATFORM_WIN32