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()));
272 LOG(
fmt::format(
"[RoR|Startup|Rendering] WARNING - invalid 'ogre.cfg', selecting render plugin manually..."));
275 if (!render_systems.empty())
277 LOG(
fmt::format(
"[RoR|Startup|Rendering] Auto-selected renderer plugin '{}'", render_systems.front()->getName()));
278 m_ogre_root->setRenderSystem(render_systems.front());
288 if (rs !=
nullptr && rs !=
m_ogre_root->getRenderSystem())
290 LOG(
fmt::format(
"[RoR|Startup|Rendering] Setting renderer '{}' on behalf of 'app_rendersys_override' (user selection via Settings UI)", rs->getName()));
298 LOG(
fmt::format(
"[RoR|Startup|Rendering] Starting renderer '{}' (without auto-creating render window)",
m_ogre_root->getRenderSystem()->getName()));
302 Ogre::ConfigOptionMap ropts =
m_ogre_root->getRenderSystem()->getConfigOptions();
303 std::stringstream ropts_log;
304 for (
auto& pair: ropts)
306 ropts_log <<
" " << pair.first <<
" = " << pair.second.currentValue <<
" (";
307 for (
auto& val: pair.second.possibleValues)
309 ropts_log << val <<
", ";
313 LOG(
fmt::format(
"[RoR|Startup|Rendering] Renderer options as reported by OGRE:\n{}", ropts_log.str()));
316 Ogre::NameValuePairList miscParams;
317 miscParams[
"FSAA"] = ropts[
"FSAA"].currentValue;
318 miscParams[
"vsync"] = ropts[
"VSync"].currentValue;
319 miscParams[
"gamma"] = ropts[
"sRGB Gamma Conversion"].currentValue;
322 miscParams[
"border"] =
"fixed";
324 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
325 const auto rd = ropts[
"Rendering Device"];
326 const auto it = std::find(rd.possibleValues.begin(), rd.possibleValues.end(), rd.currentValue);
327 const int idx = std::distance(rd.possibleValues.begin(), it);
328 miscParams[
"monitorIndex"] = Ogre::StringConverter::toString(idx);
329 miscParams[
"windowProc"] = Ogre::StringConverter::toString((
size_t)OgreBites::WindowEventUtilities::_WndProc);
333 Ogre::uint32 width, height;
334 std::istringstream mode (ropts[
"Video Mode"].currentValue);
340 if(width < 800) width = 800;
341 if(height < 600) height = 600;
344 std::stringstream miscParams_log;
345 for (
auto& pair: miscParams)
347 miscParams_log <<
" " << pair.first <<
" = " << pair.second <<
"\n";
349 LOG(
fmt::format(
"[RoR|Startup|Rendering] Creating render window with settings:\n{}", miscParams_log.str()));
354 width, height, ropts[
"Full Screen"].currentValue ==
"Yes", &miscParams);
362 m_viewport->setBackgroundColour(Ogre::ColourValue::Black);
369 Ogre::NameValuePairList misc;
370 Ogre::ConfigOptionMap ropts =
m_ogre_root->getRenderSystem()->getConfigOptions();
371 misc[
"FSAA"] = Ogre::StringConverter::parseInt(ropts[
"FSAA"].currentValue, 0);
373 Ogre::RenderWindow* rw = Ogre::Root::getSingleton().createRenderWindow(window_name, width, height,
false, &misc);
379 const std::time_t time = std::time(
nullptr);
382 std::stringstream stamp;
383 stamp << std::put_time(std::localtime(&time),
"%Y-%m-%d_%H-%M-%S") <<
"_" << index
418 _L(
"Screenshot: ") + stamp.str());
446 if (exe_path.empty())
464 if (user_home.empty())
470 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
471 ror_homedir << user_home <<
PATH_SLASH <<
"My Games";
474 #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
475 char* env_SNAP = getenv(
"SNAP_USER_COMMON");
477 ror_homedir = env_SNAP;
479 ror_homedir << user_home <<
PATH_SLASH <<
".rigsofrods";
480 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
481 ror_homedir << user_home <<
PATH_SLASH <<
"RigsOfRods";
496 auto ogre_log_manager = OGRE_NEW Ogre::LogManager();
497 std::string rorlog_path =
PathCombine(logs_dir,
"RoR.log");
498 Ogre::Log* rorlog = ogre_log_manager->createLog(rorlog_path,
true,
true);
499 rorlog->stream() <<
"[RoR] Rigs of Rods (www.rigsofrods.org) version " <<
ROR_VERSION_STRING;
500 std::time_t t = std::time(
nullptr);
501 rorlog->stream() <<
"[RoR] Current date: " << std::put_time(std::localtime(&t),
"%Y-%m-%d");
509 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
512 process_dir =
"/usr/share/rigsofrods/resources/";
527 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(src_path,
"Zip",
"SrcRG");
528 Ogre::FileInfoListPtr fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"SrcRG",
"*",
true);
535 for (
auto file : *fl)
539 fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"SrcRG",
"*");
545 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(dst_path,
"FileSystem",
"DstRG",
false,
false);
546 for (
auto file : *fl)
548 if (
file.uncompressedSize == 0)
550 Ogre::String path =
file.path +
file.basename;
551 if (!Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"DstRG", path)->empty())
553 Ogre::DataStreamPtr src_ds = Ogre::ResourceGroupManager::getSingleton().openResource(path,
"SrcRG");
554 Ogre::DataStreamPtr dst_ds = Ogre::ResourceGroupManager::getSingleton().createResource(path,
"DstRG");
555 std::vector<char> buf(src_ds->size());
556 size_t read = src_ds->read(buf.data(), src_ds->size());
559 dst_ds->write(buf.data(), read);
562 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"SrcRG");
563 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"DstRG");
570 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
579 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(old_ror_homedir,
"FileSystem",
"homedir",
false,
false);
580 Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().createResource(
"OBSOLETE_FOLDER.txt",
"homedir");
581 stream->write(obsoleteMessage.c_str(), obsoleteMessage.length());
582 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"homedir");
584 catch (std::exception & e)
586 RoR::LogFormat(
"Error writing to %s, message: '%s'", old_ror_homedir.c_str(), e.what());
589 "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",
597 #endif // OGRE_PLATFORM_WIN32