44 #ifdef USE_ANGELSCRIPT
82 if (!ImGui::GetIO().WantCaptureMouse)
102 if (!ImGui::GetIO().WantCaptureMouse)
123 if (!ImGui::GetIO().WantCaptureMouse)
142 !ImGui::GetIO().WantCaptureKeyboard)
155 !ImGui::GetIO().WantCaptureKeyboard)
182 actor->ar_dashboard->windowResized();
204 rw->getCustomAttribute(
"WINDOW", &hWnd);
207 ::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);
209 HINSTANCE
instance = ::GetModuleHandleA(buf);
210 HICON hIcon = ::LoadIconA(
instance, MAKEINTRESOURCEA(101));
213 ::SendMessageA((HWND)hWnd, WM_SETICON, 1, (LPARAM)hIcon);
214 ::SendMessageA((HWND)hWnd, WM_SETICON, 0, (LPARAM)hIcon);
226 LOG(
fmt::format(
"[RoR|Startup|Rendering] Creating OGRE renderer Root object, config='{}'", cfg_filepath));
227 m_ogre_root =
new Ogre::Root(
"", cfg_filepath, log_filepath);
235 LOG(
fmt::format(
"[RoR|Startup|Rendering] Loading OGRE renderer plugins config '{}'.", plugins_path));
238 Ogre::ConfigFile cfg;
239 cfg.load(plugins_path);
241 Ogre::StringVector plugins = cfg.getMultiSetting(
"Plugin");
242 for (Ogre::String plugin_filename: plugins)
248 catch (Ogre::Exception&) {}
251 catch (Ogre::Exception& e)
255 fmt::format(
_L(
"Could not load file '{}' - make sure the game is installed correctly.\n\nDetailed info: {}"), plugins_path, e.getDescription()));
260 bool autodetect_resolution =
false;
263 autodetect_resolution =
true;
264 LOG(
fmt::format(
"[RoR|Startup|Rendering] WARNING - invalid 'ogre.cfg', selecting render plugin manually..."));
267 if (!render_systems.empty())
269 LOG(
fmt::format(
"[RoR|Startup|Rendering] Auto-selected renderer plugin '{}'", render_systems.front()->getName()));
270 m_ogre_root->setRenderSystem(render_systems.front());
280 if (rs !=
nullptr && rs !=
m_ogre_root->getRenderSystem())
282 LOG(
fmt::format(
"[RoR|Startup|Rendering] Setting renderer '{}' on behalf of 'app_rendersys_override' (user selection via Settings UI)", rs->getName()));
290 LOG(
fmt::format(
"[RoR|Startup|Rendering] Starting renderer '{}' (without auto-creating render window)",
m_ogre_root->getRenderSystem()->getName()));
294 Ogre::ConfigOptionMap ropts =
m_ogre_root->getRenderSystem()->getConfigOptions();
295 std::stringstream ropts_log;
296 for (
auto& pair: ropts)
298 ropts_log <<
" " << pair.first <<
" = " << pair.second.currentValue <<
" (";
299 for (
auto& val: pair.second.possibleValues)
301 ropts_log << val <<
", ";
305 LOG(
fmt::format(
"[RoR|Startup|Rendering] Renderer options as reported by OGRE:\n{}", ropts_log.str()));
308 Ogre::NameValuePairList miscParams;
309 miscParams[
"FSAA"] = ropts[
"FSAA"].currentValue;
310 miscParams[
"vsync"] = ropts[
"VSync"].currentValue;
311 miscParams[
"gamma"] = ropts[
"sRGB Gamma Conversion"].currentValue;
314 miscParams[
"border"] =
"fixed";
316 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
317 const auto rd = ropts[
"Rendering Device"];
318 const auto it = std::find(rd.possibleValues.begin(), rd.possibleValues.end(), rd.currentValue);
319 const int idx = std::distance(rd.possibleValues.begin(), it);
320 miscParams[
"monitorIndex"] = Ogre::StringConverter::toString(idx);
321 miscParams[
"windowProc"] = Ogre::StringConverter::toString((
size_t)OgreBites::WindowEventUtilities::_WndProc);
325 Ogre::uint32 width, height;
326 std::istringstream mode (ropts[
"Video Mode"].currentValue);
332 if(width < 800) width = 800;
333 if(height < 600) height = 600;
335 if (autodetect_resolution)
337 for (
auto& p_mode_str: ropts[
"Video Mode"].possibleValues)
339 Ogre::uint32 p_width, p_height;
340 std::istringstream p_mode (p_mode_str);
344 if (p_width >= width && p_height >= height)
348 m_ogre_root->getRenderSystem()->setConfigOption(
"Video Mode", p_mode_str);
352 LOG(
fmt::format(
"[RoR|Startup|Rendering] WARNING - invalid 'ogre.cfg', auto-detected resolution {}x{}", width, height));
357 std::stringstream miscParams_log;
358 for (
auto& pair: miscParams)
360 miscParams_log <<
" " << pair.first <<
" = " << pair.second <<
"\n";
362 LOG(
fmt::format(
"[RoR|Startup|Rendering] Creating render window with settings:\n{}", miscParams_log.str()));
367 width, height, ropts[
"Full Screen"].currentValue ==
"Yes", &miscParams);
369 OgreBites::WindowEventUtilities::addWindowEventListener(
m_render_window,
this);
376 m_viewport->setBackgroundColour(Ogre::ColourValue::Black);
383 Ogre::NameValuePairList misc;
384 Ogre::ConfigOptionMap ropts =
m_ogre_root->getRenderSystem()->getConfigOptions();
385 misc[
"FSAA"] = Ogre::StringConverter::parseInt(ropts[
"FSAA"].currentValue, 0);
387 Ogre::RenderWindow* rw = Ogre::Root::getSingleton().createRenderWindow(window_name, width, height,
false, &misc);
393 const std::time_t time = std::time(
nullptr);
396 std::stringstream stamp;
397 stamp << std::put_time(std::localtime(&time),
"%Y-%m-%d_%H-%M-%S") <<
"_" << index
432 _L(
"Screenshot: ") + stamp.str());
460 if (exe_path.empty())
478 if (user_home.empty())
484 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
485 ror_homedir << user_home <<
PATH_SLASH <<
"My Games";
488 #elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
489 char* env_SNAP = getenv(
"SNAP_USER_COMMON");
491 ror_homedir = env_SNAP;
493 ror_homedir << user_home <<
PATH_SLASH <<
".rigsofrods";
494 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
495 ror_homedir << user_home <<
PATH_SLASH <<
"RigsOfRods";
510 auto ogre_log_manager = OGRE_NEW Ogre::LogManager();
511 std::string rorlog_path =
PathCombine(logs_dir,
"RoR.log");
512 Ogre::Log* rorlog = ogre_log_manager->createLog(rorlog_path,
true,
true);
513 rorlog->stream() <<
"[RoR] Rigs of Rods (www.rigsofrods.org) version " <<
ROR_VERSION_STRING;
514 std::time_t t = std::time(
nullptr);
515 rorlog->stream() <<
"[RoR] Current date: " << std::put_time(std::localtime(&t),
"%Y-%m-%d");
523 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
526 process_dir =
"/usr/share/rigsofrods/resources/";
541 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(src_path,
"Zip",
"SrcRG");
542 Ogre::FileInfoListPtr fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"SrcRG",
"*",
true);
549 for (
auto file : *fl)
553 fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"SrcRG",
"*");
559 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(dst_path,
"FileSystem",
"DstRG",
false,
false);
560 for (
auto file : *fl)
562 if (
file.uncompressedSize == 0)
564 Ogre::String path =
file.path +
file.basename;
565 if (!Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
"DstRG", path)->empty())
567 Ogre::DataStreamPtr src_ds = Ogre::ResourceGroupManager::getSingleton().openResource(path,
"SrcRG");
568 Ogre::DataStreamPtr dst_ds = Ogre::ResourceGroupManager::getSingleton().createResource(path,
"DstRG");
569 std::vector<char> buf(src_ds->size());
570 size_t read = src_ds->read(buf.data(), src_ds->size());
573 dst_ds->write(buf.data(), read);
576 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"SrcRG");
577 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"DstRG");
584 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
593 Ogre::ResourceGroupManager::getSingleton().addResourceLocation(old_ror_homedir,
"FileSystem",
"homedir",
false,
false);
594 Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().createResource(
"OBSOLETE_FOLDER.txt",
"homedir");
595 stream->write(obsoleteMessage.c_str(), obsoleteMessage.length());
596 Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(
"homedir");
598 catch (std::exception & e)
600 RoR::LogFormat(
"Error writing to %s, message: '%s'", old_ror_homedir.c_str(), e.what());
603 "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",
611 #endif // OGRE_PLATFORM_WIN32