17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-08 19:52:47 +01:00

Merge pull request #244 from MaSzyna-EU07/split/1-small-fixes

Split/1 small fixes
This commit is contained in:
2026-11-07 11:19:45 +00:00
committed by GitHub
24 changed files with 282 additions and 66 deletions

View File

@@ -270,7 +270,11 @@ void eu07_application::DiscordRPCService()
}
if (currentMode != mode::driver)
{
// the editor and the other modes: nothing to tell, without spinning a core on it
std::this_thread::sleep_for(std::chrono::milliseconds(250));
continue;
}
// Discord RPC updater
if (simulation::is_ready)
@@ -690,19 +694,29 @@ void eu07_application::release_python_lock()
void eu07_application::exit()
{
Global.applicationQuitOrder = true;
// each step of the closing in the log, to tell from it where a closing that hangs stops
auto const closing{std::chrono::steady_clock::now()};
auto const step = [closing](char const *What) {
WriteLog(std::format("Closing: {} at {} ms", What, std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - closing).count()));
};
step("the modes");
for (auto &mode : m_modes)
mode.reset();
step("the renderer");
GfxRenderer->Shutdown();
m_network.reset();
// SafeDelete( simulation::Train );
step("the scenery");
SafeDelete(simulation::Region);
step("the ui and the python workers");
ui_layer::shutdown();
// the python workers detach their GL context on the way out, so they have to be done before the windows they use are destroyed
m_taskqueue.exit();
step("the windows");
for (auto *window : m_windows)
{
glfwDestroyWindow(window);
@@ -713,6 +727,8 @@ void eu07_application::exit()
if (!Global.exec_on_exit.empty())
system(Global.exec_on_exit.c_str());
step("done");
StopLogService();
auto it = Global.threads.find("LogService");
if (it != Global.threads.end())
{

View File

@@ -21,6 +21,8 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/translation.h"
#include "audio/audiorenderer.h"
#include <format>
scenarioloader_mode::scenarioloader_mode() {
m_userinterface = std::make_shared<scenarioloader_ui>();
}
@@ -41,11 +43,26 @@ bool scenarioloader_mode::update() {
WriteLog("using simulation seed: " + std::to_string(Global.random_seed), logtype::generic);
WriteLog("using simulation starting timestamp: " + std::to_string(Global.starting_timestamp), logtype::generic);
// the command line gives the name lowercased, the file may be named in another case, as a scenery made on Windows;
// the scenery is saved back to its own file then
if (auto const cased{FileCased(Global.asCurrentSceneryPath + Global.SceneryFile)}; cased.size() > Global.asCurrentSceneryPath.size())
Global.SceneryFile = cased.substr(Global.asCurrentSceneryPath.size());
Application.set_title( Global.AppName + " (" + Global.SceneryFile + ")" );
WriteLog( "\nLoading scenario \"" + Global.SceneryFile + "\"..." );
timestart = std::chrono::system_clock::now();
state = simulation::State.deserialize_begin(Global.SceneryFile);
try {
state = simulation::State.deserialize_begin(Global.SceneryFile);
}
// the file it can't read, as the parser and the scenery opening it report it
catch (std::runtime_error const &e) {
ErrorLog(std::format("Bad init: scenario \"{}\" couldn't be opened ({})", Global.SceneryFile, e.what()));
state.reset();
Global.SceneryFile.clear();
Application.pop_mode();
Application.push_mode(eu07_application::mode::launcher);
return true;
}
}
try {
@@ -53,8 +70,13 @@ bool scenarioloader_mode::update() {
return true;
}
catch (invalid_scenery_exception &e) {
// back to the launcher as when the scenario can't be opened, not on to the driver mode with the scenery half loaded
ErrorLog( "Bad init: scenario loading failed" );
state.reset();
Global.SceneryFile.clear();
Application.pop_mode();
Application.push_mode(eu07_application::mode::launcher);
return true;
}
// the loading state holds the scenario file open, which on some systems keeps the file from being replaced
// when the scenery is saved in the editor. it'd also get in the way of another load

View File

@@ -569,7 +569,7 @@ void ui_layer::render_hierarchy(){
// fitted to the contents when it first appears; no auto resize, which a docked window can't do
ImGui::SetNextWindowSize(ImVec2(0, 0), ImGuiCond_FirstUseEver);
ImGui::Begin((std::string(STR_C("Scene Hierarchy")) + "###scenehierarchy").c_str(), &m_editor_hierarchy);
ImGui::Text("Registered nodes: %zu", scene::Hierarchy.size());
ImGui::Text(STR_C("Registered nodes: %zu"), scene::Hierarchy.size());
ImGui::BeginChild("hierarchy_list", ImVec2(500, 300), true);
for (auto &entry : scene::Hierarchy)
@@ -600,7 +600,7 @@ void ui_layer::render_hierarchy(){
if (ImGui::IsItemHovered())
{
ImGui::SetTooltip("UUID: %s\nNode type: %s", uuid.c_str(), typeid(*node).name());
ImGui::SetTooltip(STR_C("UUID: %s\nNode type: %s"), uuid.c_str(), typeid(*node).name());
}
}
}
@@ -710,14 +710,14 @@ void ui_layer::render_menu_contents()
GfxRenderer->Debug_Ui_State(ret);
}
if(EditorModeFlag){
ImGui::MenuItem("Hierarchy", nullptr, &m_editor_hierarchy);
ImGui::MenuItem(STR_C("Scene Hierarchy"), nullptr, &m_editor_hierarchy);
bool change_history_enabled = editor_mode::change_history();
if (ImGui::MenuItem("Change History", nullptr, &change_history_enabled))
if (ImGui::MenuItem(STR_C("Change History"), nullptr, &change_history_enabled))
{
editor_mode::set_change_history(change_history_enabled);
}
bool settings_open = editor_mode::settings_open();
if (ImGui::MenuItem("Editor Settings", nullptr, &settings_open))
if (ImGui::MenuItem(STR_C("Editor Settings"), nullptr, &settings_open))
{
editor_mode::set_settings_open(settings_open);
}