diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index c598842d7..015b574e6 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -21,6 +21,7 @@ http://mozilla.org/MPL/2.0/. #include "world/TractionPower.h" #include "vehicle/Camera.h" #include "world/mtable.h" +#include "world/stationnames.h" #include "vehicle/Train.h" #include "vehicle/Driver.h" #include "vehicle/drivingaid.h" @@ -350,9 +351,10 @@ timetable_panel::update() { // destination { - auto textline = Bezogonkow( owner->Relation(), true ); + // the names with the letters their files have, in utf-8 as the user interface takes it + auto textline = table.relation_caption(); if( false == textline.empty() ) { - textline += " (" + Bezogonkow( owner->TrainName(), true ) + ")"; + textline += " (" + data_name_to_utf8( owner->TrainName(), true ) + ")"; } text_lines.emplace_back( textline, Global.UITextColor ); } @@ -419,10 +421,9 @@ timetable_panel::update() { vmax += to_string( tableline->vmax, 0 ); vmax = vmax.substr( vmax.size() - 3, 3 ); // z wyrównaniem do prawej } - auto const station { ( - Bezogonkow( tableline->StationName, true ) - + " " ) - .substr( 0, 34 ) }; + // the name as the timetable spells it; in utf-8 a letter can take more than one byte, the column is + // 34 characters wide + auto const station { utf8_fit( timetable::station_caption( tableline->StationLabel ), 34 ) }; auto const location { ( ( tableline->km > 0.0 ? to_string( tableline->km, 2 ) : @@ -1164,7 +1165,7 @@ debug_panel::update_section_ai( std::vector &Output ) const { if( mechanik.VelNext == 0.0 && mechanik.eSignNext ) { // jeśli ma zapamiętany event semafora, nazwa eventu semafora - Output.emplace_back( "Current signal: " + Bezogonkow( mechanik.eSignNext->m_name ), Global.UITextColor ); + Output.emplace_back( "Current signal: " + data_name_to_utf8( mechanik.eSignNext->m_name ), Global.UITextColor ); } // distances @@ -1275,7 +1276,7 @@ debug_panel::update_section_scantable( std::vector &Output ) const { do { auto const scanline = mechanik.TableText( i ); if( scanline.empty() ) { break; } - Output.emplace_back( Bezogonkow( scanline ), Global.UITextColor ); + Output.emplace_back( data_name_to_utf8( scanline ), Global.UITextColor ); ++i; } while( i < speedtablesize ); if( Output.size() == 1 ) { diff --git a/application/editoruipanels.cpp b/application/editoruipanels.cpp index da3b56741..5b6a5a3ee 100644 --- a/application/editoruipanels.cpp +++ b/application/editoruipanels.cpp @@ -166,14 +166,14 @@ void itemproperties_panel::update(scene::basic_node *Node) } } */ - textline = format(STR_C("Name: %s"), (node->name().empty() ? std::string{STR_C("(no name)")} : Bezogonkow(node->name())).c_str()) + "\n" + format(STR_C("Type: %s"), node->node_type.c_str()); + textline = format(STR_C("Name: %s"), (node->name().empty() ? std::string{STR_C("(no name)")} : data_name_to_utf8(node->name())).c_str()) + "\n" + format(STR_C("Type: %s"), node->node_type.c_str()); text_lines.emplace_back(textline, Global.UITextColor); textline = format(STR_C("Location: %.2f, %.2f, %.2f (distance %.1f m)"), node->location().x, node->location().y, node->location().z, glm::length(glm::dvec3{node->location().x, 0.0, node->location().z} - glm::dvec3{camera.Pos.x, 0.0, camera.Pos.z})) + "\nUUID: " + node->uuid.to_string(); if (scene::Layers.valid(node->layer())) { - textline += "\n" + format(STR_C("Layer: %s"), Bezogonkow(scene::Layers.layer(node->layer()).name).c_str()); + textline += "\n" + format(STR_C("Layer: %s"), data_name_to_utf8(scene::Layers.layer(node->layer()).name).c_str()); } text_lines.emplace_back(textline, Global.UITextColor); @@ -286,7 +286,7 @@ void itemproperties_panel::update(scene::basic_node *Node) { textline += ", "; } - textline += event.second != nullptr ? Bezogonkow(event.second->m_name) : event.first + STR_C(" (missing)"); + textline += event.second != nullptr ? data_name_to_utf8(event.second->m_name) : event.first + STR_C(" (missing)"); } textline += "] "; } @@ -299,7 +299,7 @@ void itemproperties_panel::update(scene::basic_node *Node) textline = format(STR_C("Data: [%s] [%.2f] [%.2f]"), subnode->Text().c_str(), subnode->Value1(), subnode->Value2()); text_lines.emplace_back(textline, Global.UITextColor); - textline = format(STR_C("Track: %s"), (subnode->asTrackName.empty() ? std::string{STR_C("(none)")} : Bezogonkow(subnode->asTrackName)).c_str()); + textline = format(STR_C("Track: %s"), (subnode->asTrackName.empty() ? std::string{STR_C("(none)")} : data_name_to_utf8(subnode->asTrackName)).c_str()); text_lines.emplace_back(textline, Global.UITextColor); } @@ -888,7 +888,7 @@ void nodebank_panel::render_templates_list(std::string const &Filter) ImGui::TextDisabled(" %s", entry.category.c_str()); } category = &entry.category; - auto const label{(entry.category.empty() ? " " : " ") + entry.name + " (" + Bezogonkow(entry.file) + ")##inc" + std::to_string(entryidx)}; + auto const label{(entry.category.empty() ? " " : " ") + entry.name + " (" + data_name_to_utf8(entry.file) + ")##inc" + std::to_string(entryidx)}; if (list_item(label.c_str(), entry.statement == m_selectedtemplate)) m_selectedtemplate = entry.statement; ++listed; @@ -1704,7 +1704,7 @@ std::string layer_content(scene::basic_layer const &Layer) std::string layer_name(scene::layer_handle const Layer) { - return scene::Layers.valid(Layer) ? Bezogonkow(scene::Layers.layer(Layer).name) : std::string{STR_C("(none)")}; + return scene::Layers.valid(Layer) ? data_name_to_utf8(scene::Layers.layer(Layer).name) : std::string{STR_C("(none)")}; } // button which can be greyed out, with an explanation shown when it's hovered @@ -1748,7 +1748,7 @@ void itemproperties_panel::render_include() auto &include{*m_include}; include.active = false; - ImGui::Text(STR_C("include: %s"), Bezogonkow(include.target).c_str()); + ImGui::Text(STR_C("include: %s"), data_name_to_utf8(include.target).c_str()); if (false == include.info.name.empty()) { ImGui::TextDisabled("%s", include.info.name.c_str()); @@ -2280,7 +2280,7 @@ void includes_panel::render_list() { auto const &entry{entries[m_listed[row]]}; auto const marker{entry.complete ? std::string{STR_C("[ready]")} + " " : entry.described ? std::string{STR_C("[incomplete]")} + " " : std::string{}}; - auto const label{marker + Bezogonkow(entry.file) + (entry.name.empty() ? "" : " - " + entry.name) + "##" + std::to_string(m_listed[row])}; + auto const label{marker + data_name_to_utf8(entry.file) + (entry.name.empty() ? "" : " - " + entry.name) + "##" + std::to_string(m_listed[row])}; if (false == entry.described) { ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled)); @@ -2310,7 +2310,7 @@ void includes_panel::render_list() void includes_panel::render_description() { ImGui::Separator(); - ImGui::Text("%s", Bezogonkow(m_file).c_str()); + ImGui::Text("%s", data_name_to_utf8(m_file).c_str()); input_text(STR_C("Name"), m_info.name); input_text(STR_C("Category"), m_info.category); input_text(STR_C("Description"), m_info.description); @@ -2388,7 +2388,7 @@ void includes_panel::render_description() { std::string error; m_statuserror = false == editor_includes::save(m_file, m_info, error); - m_status = m_statuserror ? error : format(STR_C("Description saved in \"%s\""), Bezogonkow(m_file).c_str()); + m_status = m_statuserror ? error : format(STR_C("Description saved in \"%s\""), data_name_to_utf8(m_file).c_str()); if (false == m_statuserror) { EditorIncludes.update(m_file); diff --git a/application/uitranscripts.cpp b/application/uitranscripts.cpp index 7ce360530..dc0aec0eb 100644 --- a/application/uitranscripts.cpp +++ b/application/uitranscripts.cpp @@ -38,8 +38,8 @@ TTranscripts::Add( std::string const &txt, bool /*backgorund*/ ) { if( true == txt.empty() ) { return; } - std::string asciitext{ txt }; win1250_to_ascii( asciitext ); // TODO: launch relevant conversion table based on language - cParser parser( asciitext ); + // the captions are read as their files have them (windows-1250, the newer ones utf-8) and shown with their letters + cParser parser( txt ); while( true == parser.getTokens( 3, false, "[]\n" ) ) { float begin{ 0.f }; @@ -49,14 +49,14 @@ TTranscripts::Add( std::string const &txt, bool /*backgorund*/ ) { >> begin >> end >> transcript; - AddLine( transcript, static_cast(0.10 * begin), static_cast(0.12 * end), false ); + AddLine( data_text_to_utf8( transcript ), static_cast(0.10 * begin), static_cast(0.12 * end), false ); } // try to handle malformed(?) cases with no show/hide times std::string transcript; parser >> transcript; while( false == transcript.empty() ) { // WriteLog( "Transcript text with no display/hide times: \"" + transcript + "\"" ); - AddLine( transcript, 0.0, static_cast(0.12 * static_cast(transcript.size())), false ); + AddLine( data_text_to_utf8( transcript ), 0.0, static_cast(0.12 * static_cast(transcript.size())), false ); transcript = ""; parser >> transcript; } } diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp index 5dbc6efbf..41f67398c 100644 --- a/simulation/simulationstateserializer.cpp +++ b/simulation/simulationstateserializer.cpp @@ -250,8 +250,8 @@ state_serializer::deserialize_assignment( cParser &Input, scene::scratch_data &S while( false == token.empty() && token != "endassignment" ) { // assignment is expected to come as string pairs: language id and the actual assignment enclosed in quotes to form a single token - auto assignment{ Input.getToken() }; - win1250_to_ascii( assignment ); + // the assignment is only shown to the player, so it's kept with its letters, in utf-8 as the user interface takes it + auto const assignment{ data_text_to_utf8( Input.getToken() ) }; Scratchpad.trainset.assignment.emplace( token, assignment ); token = Input.getToken(); }