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;
267 autodetect_resolution =
true;
268 LOG(
fmt::format(
"[RoR|Startup|Rendering] WARNING - invalid 'ogre.cfg', selecting render plugin manually..."));
271 if (!render_systems.empty())
273 LOG(
fmt::format(
"[RoR|Startup|Rendering] Auto-selected renderer plugin '{}'", render_systems.front()->getName()));
274 m_ogre_root->setRenderSystem(render_systems.front());
284 if (rs !=
nullptr && rs !=
m_ogre_root->getRenderSystem())
286 LOG(
fmt::format(
"[RoR|Startup|Rendering] Setting renderer '{}' on behalf of 'app_rendersys_override' (user selection via Settings UI)", rs->getName()));
294 LOG(
fmt::format(
"[RoR|Startup|Rendering] Starting renderer '{}' (without auto-creating render window)",
m_ogre_root->getRenderSystem()->getName()));
298 Ogre::ConfigOptionMap ropts =
m_ogre_root->getRenderSystem()->getConfigOptions();
299 std::stringstream ropts_log;
300 for (
auto& pair: ropts)
302 ropts_log <<
" " << pair.first <<
" = " << pair.second.currentValue <<
" (";
303 for (
auto& val: pair.second.possibleValues)
305 ropts_log << val <<
", ";
309 LOG(
fmt::format(
"[RoR|Startup|Rendering] Renderer options as reported by OGRE:\n{}", ropts_log.str()));
312 Ogre::NameValuePairList miscParams;
313 miscParams[
"FSAA"] = ropts[
"FSAA"].currentValue;
314 miscParams[
"vsync"] = ropts[
"VSync"].currentValue;
315 miscParams[
"gamma"] = ropts[
"sRGB Gamma Conversion"].currentValue;
318 miscParams[
"border"] =
"fixed";
320 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
321 const auto rd = ropts[
"Rendering Device"];
322 const auto it = std::find(rd.possibleValues.begin(), rd.possibleValues.end(), rd.currentValue);
323 const int idx = std::distance(rd.possibleValues.begin(), it);
324 miscParams[
"monitorIndex"] = Ogre::StringConverter::toString(idx);
325 miscParams[
"windowProc"] = Ogre::StringConverter::toString((
size_t)OgreBites::WindowEventUtilities::_WndProc);
329 Ogre::uint32 width, height;
330 std::istringstream mode (ropts[
"Video Mode"].currentValue);
336 if(width < 800) width = 800;
337 if(height < 600) height = 600;
339 if (autodetect_resolution)
341 for (
auto& p_mode_str: ropts[
"Video Mode"].possibleValues)
343 Ogre::uint32 p_width, p_height;
344 std::istringstream p_mode (p_mode_str);
348 if (p_width >= width && p_height >= height)
352 m_ogre_root->getRenderSystem()->setConfigOption(
"Video Mode", p_mode_str);
356 LOG(
fmt::format(
"[RoR|Startup|Rendering] WARNING - invalid 'ogre.cfg', auto-detected resolution {}x{}", width, height));
361 std::stringstream miscParams_log;
362 for (
auto& pair: miscParams)
364 miscParams_log <<
" " << pair.first <<
" = " << pair.second <<
"\n";
366 LOG(
fmt::format(
"[RoR|Startup|Rendering] Creating render window with settings:\n{}", miscParams_log.str()));
371 width, height, ropts[
"Full Screen"].currentValue ==
"Yes", &miscParams);
373 OgreBites::WindowEventUtilities::addWindowEventListener(
m_render_window,
this);
380 m_viewport->setBackgroundColour(Ogre::ColourValue::Black);
387 Ogre::NameValuePairList misc;
388 Ogre::ConfigOptionMap ropts =
m_ogre_root->getRenderSystem()->getConfigOptions();
389 misc[
"FSAA"] = Ogre::StringConverter::parseInt(ropts[
"FSAA"].currentValue, 0);
391 Ogre::RenderWindow* rw = Ogre::Root::getSingleton().createRenderWindow(window_name, width, height,
false, &misc);
397 const std::time_t time = std::time(
nullptr);
400 std::stringstream stamp;
401 stamp << std::put_time(std::localtime(&time),
"%Y-%m-%d_%H-%M-%S") <<
"_" << index
436 _L(
"Screenshot: ") + stamp.str());
464 if (exe_path.empty())
482 if (user_home.empty())
488 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
489 ror_homedir << user_home <<
PATH_SLASH <<
"My Games";
492 #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
493 char* env_SNAP = getenv(
"SNAP_USER_COMMON");
495 ror_homedir = env_SNAP;
497 ror_homedir << user_home <<
PATH_SLASH <<
".rigsofrods";
498 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
499 ror_homedir << user_home <<
PATH_SLASH <<
"RigsOfRods";
514 auto ogre_log_manager = OGRE_NEW Ogre::LogManager();
515 std::string rorlog_path =
PathCombine(logs_dir,
"RoR.log");
516 Ogre::Log* rorlog = ogre_log_manager->createLog(rorlog_path,
true,
true);
517 rorlog->stream() <<
"[RoR] Rigs of Rods (www.rigsofrods.org) version " <<
ROR_VERSION_STRING;
518 std::time_t t = std::time(
nullptr);
519 rorlog->stream() <<
"[RoR] Current date: " << std::put_time(std::localtime(&t),
"%Y-%m-%d");
527 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
530 process_dir =
"/usr/share/rigsofrods/resources/";
545 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(src_path,
"Zip",
"SrcRG");
546 Ogre::FileInfoListPtr fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"SrcRG",
"*",
true);
553 for (
auto file : *fl)
557 fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"SrcRG",
"*");
563 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(dst_path,
"FileSystem",
"DstRG",
false,
false);
564 for (
auto file : *fl)
566 if (
file.uncompressedSize == 0)
568 Ogre::String path =
file.path +
file.basename;
569 if (!Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"DstRG", path)->empty())
571 Ogre::DataStreamPtr src_ds = Ogre::ResourceGroupManager::getSingleton().openResource(path,
"SrcRG");
572 Ogre::DataStreamPtr dst_ds = Ogre::ResourceGroupManager::getSingleton().createResource(path,
"DstRG");
573 std::vector<char> buf(src_ds->size());
574 size_t read = src_ds->read(buf.data(), src_ds->size());
577 dst_ds->write(buf.data(), read);
580 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"SrcRG");
581 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"DstRG");
588 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
597 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(old_ror_homedir,
"FileSystem",
"homedir",
false,
false);
598 Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().createResource(
"OBSOLETE_FOLDER.txt",
"homedir");
599 stream->write(obsoleteMessage.c_str(), obsoleteMessage.length());
600 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"homedir");
602 catch (std::exception & e)
604 RoR::LogFormat(
"Error writing to %s, message: '%s'", old_ror_homedir.c_str(), e.what());
607 "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",
615 #endif // OGRE_PLATFORM_WIN32