16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00
This commit is contained in:
milek7
2019-07-02 15:33:49 +02:00
parent d039207b03
commit a0c44fbaa3
15 changed files with 140 additions and 135 deletions

View File

@@ -1708,20 +1708,20 @@ std::array<char, 64> orderbuffer;
std::string TController::OrderCurrent() const std::string TController::OrderCurrent() const
{ // pobranie aktualnego rozkazu celem wyświetlenia { // pobranie aktualnego rozkazu celem wyświetlenia
auto const order { OrderCurrentGet() }; auto const order { OrderCurrentGet() };
if( order & Change_direction ) { if( order & Change_direction ) {
return locale::strings[ locale::string::driver_scenario_changedirection ]; return STR(driver_scenario_changedirection);
} }
switch( OrderList[ OrderPos ] ) { switch( OrderList[ OrderPos ] ) {
case Wait_for_orders: { return locale::strings[ locale::string::driver_scenario_waitfororders ]; } case Wait_for_orders: { return STR(driver_scenario_waitfororders); }
case Prepare_engine: { return locale::strings[ locale::string::driver_scenario_prepareengine ]; } case Prepare_engine: { return STR(driver_scenario_prepareengine); }
case Release_engine: { return locale::strings[ locale::string::driver_scenario_releaseengine ]; } case Release_engine: { return STR(driver_scenario_releaseengine); }
case Change_direction: { return locale::strings[ locale::string::driver_scenario_changedirection ]; } case Change_direction: { return STR(driver_scenario_changedirection); }
case Connect: { return locale::strings[ locale::string::driver_scenario_connect ]; } case Connect: { return STR(driver_scenario_connect); }
case Disconnect: { case Disconnect: {
if( iVehicleCount < 0 ) { if( iVehicleCount < 0 ) {
// done with uncoupling, order should update shortly // done with uncoupling, order should update shortly
return locale::strings[ locale::string::driver_scenario_waitfororders ]; return STR(driver_scenario_waitfororders);
} }
// try to provide some task details // try to provide some task details
auto const count { iVehicleCount }; auto const count { iVehicleCount };
@@ -1730,25 +1730,25 @@ std::string TController::OrderCurrent() const
std::snprintf( std::snprintf(
orderbuffer.data(), orderbuffer.size(), orderbuffer.data(), orderbuffer.size(),
( iVehicleCount < 5 ? ( iVehicleCount < 5 ?
locale::strings[ locale::string::driver_scenario_fewvehicles ].c_str() : // 2-4 STR_C(driver_scenario_fewvehicles) : // 2-4
locale::strings[ locale::string::driver_scenario_somevehicles ].c_str() ), // 5+ STR_C(driver_scenario_somevehicles) ), // 5+
count ); count );
} }
auto const countstring { ( auto const countstring { (
count == 0 ? locale::strings[ locale::string::driver_scenario_allvehicles ] : count == 0 ? STR(driver_scenario_allvehicles) :
count == 1 ? locale::strings[ locale::string::driver_scenario_onevehicle ] : count == 1 ? STR(driver_scenario_onevehicle) :
orderbuffer.data() ) }; orderbuffer.data() ) };
std::snprintf( std::snprintf(
orderbuffer.data(), orderbuffer.size(), orderbuffer.data(), orderbuffer.size(),
locale::strings[ locale::string::driver_scenario_disconnect ].c_str(), STR_C(driver_scenario_disconnect),
countstring.c_str() ); countstring.c_str() );
return orderbuffer.data(); return orderbuffer.data();
} }
case Shunt: { return locale::strings[ locale::string::driver_scenario_shunt ]; } case Shunt: { return STR(driver_scenario_shunt); }
case Loose_shunt: { return locale::strings[ locale::string::driver_scenario_looseshunt ]; } case Loose_shunt: { return STR(driver_scenario_looseshunt); }
case Obey_train: { return locale::strings[ locale::string::driver_scenario_obeytrain ]; } case Obey_train: { return STR(driver_scenario_obeytrain); }
case Bank: { return locale::strings[ locale::string::driver_scenario_bank ]; } case Bank: { return STR(driver_scenario_bank); }
default: { return{}; } default: { return{}; }
} }
}; };

View File

@@ -622,7 +622,7 @@ eu07_application::init_settings( int Argc, char *Argv[] ) {
int int
eu07_application::init_locale() { eu07_application::init_locale() {
locale::init(); Translations.init();
return 0; return 0;
} }

View File

@@ -37,17 +37,17 @@ driver_ui::driver_ui() {
add_external_panel( &m_cameraviewpanel ); add_external_panel( &m_cameraviewpanel );
m_logpanel.is_open = false; m_logpanel.is_open = false;
m_aidpanel.title = locale::strings[ locale::string::driver_aid_header ]; m_aidpanel.title = STR(driver_aid_header);
m_scenariopanel.title = locale::strings[ locale::string::driver_scenario_header ]; m_scenariopanel.title = STR(driver_scenario_header);
m_scenariopanel.size_min = { 435, 85 }; m_scenariopanel.size_min = { 435, 85 };
m_scenariopanel.size_max = { Global.iWindowWidth * 0.95, Global.iWindowHeight * 0.95 }; m_scenariopanel.size_max = { Global.iWindowWidth * 0.95, Global.iWindowHeight * 0.95 };
m_timetablepanel.title = locale::strings[ locale::string::driver_timetable_header ]; m_timetablepanel.title = STR(driver_timetable_header);
m_timetablepanel.size_min = { 435, 110 }; m_timetablepanel.size_min = { 435, 110 };
m_timetablepanel.size_max = { 435, Global.iWindowHeight * 0.95 }; m_timetablepanel.size_max = { 435, Global.iWindowHeight * 0.95 };
m_transcriptspanel.title = locale::strings[ locale::string::driver_transcripts_header ]; m_transcriptspanel.title = STR(driver_transcripts_header);
m_transcriptspanel.size_min = { 435, 85 }; m_transcriptspanel.size_min = { 435, 85 };
m_transcriptspanel.size_max = { Global.iWindowWidth * 0.95, Global.iWindowHeight * 0.95 }; m_transcriptspanel.size_max = { Global.iWindowWidth * 0.95, Global.iWindowHeight * 0.95 };
} }
@@ -55,10 +55,10 @@ driver_ui::driver_ui() {
void driver_ui::render_menu_contents() { void driver_ui::render_menu_contents() {
ui_layer::render_menu_contents(); ui_layer::render_menu_contents();
if (ImGui::BeginMenu(locale::strings[locale::string::ui_mode_windows].c_str())) if (ImGui::BeginMenu(STR_C(ui_mode_windows)))
{ {
ImGui::MenuItem(m_aidpanel.title.c_str(), "F1", &m_aidpanel.is_open); ImGui::MenuItem(m_aidpanel.title.c_str(), "F1", &m_aidpanel.is_open);
ImGui::MenuItem(locale::strings[locale::string::driver_timetable_name].c_str(), "F2", &m_timetablepanel.is_open); ImGui::MenuItem(STR_C(driver_timetable_name), "F2", &m_timetablepanel.is_open);
ImGui::MenuItem(m_debugpanel.name().c_str(), "F12", &m_debugpanel.is_open); ImGui::MenuItem(m_debugpanel.name().c_str(), "F12", &m_debugpanel.is_open);
ImGui::MenuItem(m_mappanel.name().c_str(), "Tab", &m_mappanel.is_open); ImGui::MenuItem(m_mappanel.name().c_str(), "Tab", &m_mappanel.is_open);
ImGui::MenuItem(m_vehiclelist.name().c_str(), nullptr, &m_vehiclelist.is_open); ImGui::MenuItem(m_vehiclelist.name().c_str(), nullptr, &m_vehiclelist.is_open);
@@ -192,7 +192,7 @@ driver_ui::update() {
if( ( train != nullptr ) && ( false == FreeFlyModeFlag ) ) { if( ( train != nullptr ) && ( false == FreeFlyModeFlag ) ) {
if( false == DebugModeFlag ) { if( false == DebugModeFlag ) {
// in regular mode show control functions, for defined controls // in regular mode show control functions, for defined controls
set_tooltip( locale::label_cab_control( train->GetLabel( GfxRenderer.get_picked_control() ) ) ); set_tooltip( Translations.label_cab_control( train->GetLabel( GfxRenderer.get_picked_control() ) ) );
} }
else { else {
// in debug mode show names of submodels, to help with cab setup and/or debugging // in debug mode show names of submodels, to help with cab setup and/or debugging
@@ -228,18 +228,18 @@ driver_ui::set_cursor( bool const Visible ) {
void void
driver_ui::render_() { driver_ui::render_() {
// pause/quit modal // pause/quit modal
auto const popupheader { locale::strings[ locale::string::driver_pause_header ].c_str() }; auto const popupheader { STR_C(driver_pause_header) };
if (m_paused && !m_pause_modal_opened) if (m_paused && !m_pause_modal_opened)
{ {
m_pause_modal_opened = true; m_pause_modal_opened = true;
ImGui::OpenPopup(popupheader); ImGui::OpenPopup(popupheader);
} }
if( ImGui::BeginPopupModal( popupheader, &m_pause_modal_opened, ImGuiWindowFlags_AlwaysAutoResize ) ) { if( ImGui::BeginPopupModal( popupheader, &m_pause_modal_opened, ImGuiWindowFlags_AlwaysAutoResize ) ) {
auto const popupwidth{ locale::strings[ locale::string::driver_pause_header ].size() * 7 }; auto const popupwidth{ STR(driver_pause_header).size() * 7 };
if( ImGui::Button( locale::strings[ locale::string::driver_pause_resume ].c_str(), ImVec2( popupwidth, 0 ) ) ) { if( ImGui::Button( STR_C(driver_pause_resume), ImVec2( popupwidth, 0 ) ) ) {
m_relay.post(user_command::pausetoggle, 0.0, 0.0, GLFW_PRESS, 0); m_relay.post(user_command::pausetoggle, 0.0, 0.0, GLFW_PRESS, 0);
} }
if( ImGui::Button( locale::strings[ locale::string::driver_pause_quit ].c_str(), ImVec2( popupwidth, 0 ) ) ) { if( ImGui::Button( STR_C(driver_pause_quit), ImVec2( popupwidth, 0 ) ) ) {
m_relay.post(user_command::quitsimulation, 0.0, 0.0, GLFW_PRESS, 0); m_relay.post(user_command::quitsimulation, 0.0, 0.0, GLFW_PRESS, 0);
} }
if (!m_paused) if (!m_paused)

View File

@@ -53,7 +53,7 @@ drivingaid_panel::update() {
if( std::abs( grade ) >= 0.25 ) { if( std::abs( grade ) >= 0.25 ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_aid_grade ].c_str(), STR_C(driver_aid_grade),
grade ); grade );
gradetext = m_buffer.data(); gradetext = m_buffer.data();
} }
@@ -64,7 +64,7 @@ drivingaid_panel::update() {
if( nextspeedlimit != speedlimit ) { if( nextspeedlimit != speedlimit ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_aid_nextlimit ].c_str(), STR_C(driver_aid_nextlimit),
nextspeedlimit, nextspeedlimit,
driver->ActualProximityDist * 0.001 ); driver->ActualProximityDist * 0.001 );
nextspeedlimittext = m_buffer.data(); nextspeedlimittext = m_buffer.data();
@@ -72,7 +72,7 @@ drivingaid_panel::update() {
// current speed and limit // current speed and limit
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_aid_speedlimit ].c_str(), STR_C(driver_aid_speedlimit),
static_cast<int>( std::floor( mover->Vel ) ), static_cast<int>( std::floor( mover->Vel ) ),
speedlimit, speedlimit,
nextspeedlimittext.c_str(), nextspeedlimittext.c_str(),
@@ -82,7 +82,7 @@ drivingaid_panel::update() {
// base data and optional bits put together // base data and optional bits put together
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_aid_throttle ].c_str(), STR_C(driver_aid_throttle),
driver->Controlling()->MainCtrlPos, driver->Controlling()->MainCtrlPos,
driver->Controlling()->ScndCtrlPos, driver->Controlling()->ScndCtrlPos,
( mover->ActiveDir > 0 ? 'D' : mover->ActiveDir < 0 ? 'R' : 'N' ), ( mover->ActiveDir > 0 ? 'D' : mover->ActiveDir < 0 ? 'R' : 'N' ),
@@ -96,14 +96,14 @@ drivingaid_panel::update() {
if( is_expanded ) { if( is_expanded ) {
std::snprintf ( std::snprintf (
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_aid_pressures ].c_str(), STR_C(driver_aid_pressures),
mover->BrakePress * 100, mover->BrakePress * 100,
mover->PipePress * 100 ); mover->PipePress * 100 );
expandedtext = m_buffer.data(); expandedtext = m_buffer.data();
} }
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_aid_brakes ].c_str(), STR_C(driver_aid_brakes),
mover->fBrakeCtrlPos, mover->fBrakeCtrlPos,
mover->LocalBrakePosA * LocalBrakePosNo, mover->LocalBrakePosA * LocalBrakePosNo,
( mover->SlippingWheels ? '!' : ' ' ), ( mover->SlippingWheels ? '!' : ' ' ),
@@ -119,7 +119,7 @@ drivingaid_panel::update() {
if( stoptime > 0 ) { if( stoptime > 0 ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_aid_loadinginprogress ].c_str(), STR_C(driver_aid_loadinginprogress),
stoptime ); stoptime );
expandedtext = m_buffer.data(); expandedtext = m_buffer.data();
} }
@@ -128,7 +128,7 @@ drivingaid_panel::update() {
if( trackblockdistance <= 75.0 ) { if( trackblockdistance <= 75.0 ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_aid_vehicleahead ].c_str(), STR_C(driver_aid_vehicleahead),
trackblockdistance ); trackblockdistance );
expandedtext = m_buffer.data(); expandedtext = m_buffer.data();
} }
@@ -136,11 +136,11 @@ drivingaid_panel::update() {
} }
std::string textline = std::string textline =
( mover->SecuritySystem.is_vigilance_blinking() ? ( mover->SecuritySystem.is_vigilance_blinking() ?
locale::strings[ locale::string::driver_aid_alerter ] : STR(driver_aid_alerter) :
" " ); " " );
textline += textline +=
( mover->SecuritySystem.is_cabsignal_blinking() ? ( mover->SecuritySystem.is_cabsignal_blinking() ?
locale::strings[ locale::string::driver_aid_shp ] : STR(driver_aid_shp) :
" " ); " " );
text_lines.emplace_back( textline + " " + expandedtext, Global.UITextColor ); text_lines.emplace_back( textline + " " + expandedtext, Global.UITextColor );
@@ -169,7 +169,7 @@ scenario_panel::update() {
if( owner == nullptr ) { return; } if( owner == nullptr ) { return; }
std::string textline = std::string textline =
locale::strings[ locale::string::driver_scenario_currenttask ] + "\n " STR(driver_scenario_currenttask) + "\n "
+ owner->OrderCurrent(); + owner->OrderCurrent();
text_lines.emplace_back( textline, Global.UITextColor ); text_lines.emplace_back( textline, Global.UITextColor );
@@ -205,7 +205,7 @@ scenario_panel::render() {
m_nearest->Mechanik : m_nearest->Mechanik :
m_nearest->ctOwner ) }; m_nearest->ctOwner ) };
if( owner != nullptr ) { if( owner != nullptr ) {
auto const assignmentheader { locale::strings[ locale::string::driver_scenario_assignment ] }; auto const assignmentheader { STR(driver_scenario_assignment) };
if( ( false == owner->assignment().empty() ) if( ( false == owner->assignment().empty() )
&& ( true == ImGui::CollapsingHeader( assignmentheader.c_str() ) ) ) { && ( true == ImGui::CollapsingHeader( assignmentheader.c_str() ) ) ) {
ImGui::TextWrapped( "%s", owner->assignment().c_str() ); ImGui::TextWrapped( "%s", owner->assignment().c_str() );
@@ -236,9 +236,9 @@ timetable_panel::update() {
{ // current time { // current time
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_timetable_header ].c_str(), STR_C(driver_timetable_header),
37, 37, 37, 37,
locale::strings[ locale::string::driver_timetable_name ].c_str(), STR_C(driver_timetable_name),
time.wHour, time.wHour,
time.wMinute, time.wMinute,
time.wSecond ); time.wSecond );
@@ -300,7 +300,7 @@ timetable_panel::update() {
} }
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_timetable_consistdata ].c_str(), STR_C(driver_timetable_consistdata),
static_cast<int>( table->LocLoad ), static_cast<int>( table->LocLoad ),
static_cast<int>( consistmass / 1000 ), static_cast<int>( consistmass / 1000 ),
static_cast<int>( consistlength ) ); static_cast<int>( consistlength ) );
@@ -311,7 +311,7 @@ timetable_panel::update() {
if( 0 == table->StationCount ) { if( 0 == table->StationCount ) {
// only bother if there's stations to list // only bother if there's stations to list
text_lines.emplace_back( locale::strings[ locale::string::driver_timetable_notimetable ], Global.UITextColor ); text_lines.emplace_back( STR(driver_timetable_notimetable), Global.UITextColor );
} }
else { else {
@@ -554,9 +554,9 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::debug_vehicle_nameloadstatuscouplers ].c_str(), STR_C(debug_vehicle_nameloadstatuscouplers),
mover.Name.c_str(), mover.Name.c_str(),
std::string( isowned ? locale::strings[ locale::string::debug_vehicle_owned ].c_str() + vehicle.ctOwner->OwnerName() : "" ).c_str(), std::string( isowned ? STR(debug_vehicle_owned) + vehicle.ctOwner->OwnerName() : "" ).c_str(),
mover.LoadAmount, mover.LoadAmount,
mover.LoadType.name.c_str(), mover.LoadType.name.c_str(),
mover.EngineDescription( 0 ).c_str(), mover.EngineDescription( 0 ).c_str(),
@@ -569,7 +569,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::debug_vehicle_devicespower ].c_str(), STR_C(debug_vehicle_devicespower),
// devices // devices
( mover.Battery ? 'B' : '.' ), ( mover.Battery ? 'B' : '.' ),
( mover.Mains ? 'M' : '.' ), ( mover.Mains ? 'M' : '.' ),
@@ -585,8 +585,8 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
( mover.ConvOvldFlag ? '!' : '.' ), ( mover.ConvOvldFlag ? '!' : '.' ),
( mover.CompressorFlag ? 'C' : ( false == mover.CompressorAllowLocal ? '-' : ( ( mover.CompressorAllow || mover.CompressorStart == start_t::automatic ) ? 'c' : '.' ) ) ), ( mover.CompressorFlag ? 'C' : ( false == mover.CompressorAllowLocal ? '-' : ( ( mover.CompressorAllow || mover.CompressorStart == start_t::automatic ) ? 'c' : '.' ) ) ),
( mover.CompressorGovernorLock ? '!' : '.' ), ( mover.CompressorGovernorLock ? '!' : '.' ),
std::string( isplayervehicle ? locale::strings[ locale::string::debug_vehicle_radio ] + ( mover.Radio ? std::to_string( m_input.train->RadioChannel() ) : "-" ) : "" ).c_str(), std::string( isplayervehicle ? STR(debug_vehicle_radio) + ( mover.Radio ? std::to_string( m_input.train->RadioChannel() ) : "-" ) : "" ).c_str(),
std::string( isdieselenginepowered ? locale::strings[ locale::string::debug_vehicle_oilpressure ] + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(), std::string( isdieselenginepowered ? STR(debug_vehicle_oilpressure) + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(),
// power transfers // power transfers
mover.Couplers[ end::front ].power_high.voltage, mover.Couplers[ end::front ].power_high.voltage,
mover.Couplers[ end::front ].power_high.current, mover.Couplers[ end::front ].power_high.current,
@@ -600,11 +600,11 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::debug_vehicle_controllersenginerevolutions ].c_str(), STR_C(debug_vehicle_controllersenginerevolutions),
// controllers // controllers
mover.MainCtrlPos, mover.MainCtrlPos,
mover.MainCtrlActualPos, mover.MainCtrlActualPos,
std::string( isdieselinshuntmode ? to_string( mover.AnPos, 2 ) + locale::strings[ locale::string::debug_vehicle_shuntmode ] : std::to_string( mover.ScndCtrlPos ) + "(" + std::to_string( mover.ScndCtrlActualPos ) + ")" ).c_str(), std::string( isdieselinshuntmode ? to_string( mover.AnPos, 2 ) + STR(debug_vehicle_shuntmode) : std::to_string( mover.ScndCtrlPos ) + "(" + std::to_string( mover.ScndCtrlActualPos ) + ")" ).c_str(),
// engine // engine
mover.EnginePower, mover.EnginePower,
std::abs( mover.TrainType == dt_EZT ? mover.ShowCurrent( 0 ) : mover.Im ), std::abs( mover.TrainType == dt_EZT ? mover.ShowCurrent( 0 ) : mover.Im ),
@@ -622,7 +622,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
if( isdieselenginepowered ) { if( isdieselenginepowered ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::debug_vehicle_temperatures ].c_str(), STR_C(debug_vehicle_temperatures),
mover.dizel_heat.Ts, mover.dizel_heat.Ts,
mover.dizel_heat.To, mover.dizel_heat.To,
mover.dizel_heat.temperatura1, mover.dizel_heat.temperatura1,
@@ -635,7 +635,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::debug_vehicle_brakespressures ].c_str(), STR_C(debug_vehicle_brakespressures),
// brakes // brakes
mover.fBrakeCtrlPos, mover.fBrakeCtrlPos,
mover.LocalBrakePosA, mover.LocalBrakePosA,
@@ -661,7 +661,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
if( mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { if( mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::debug_vehicle_pantograph ].c_str(), STR_C(debug_vehicle_pantograph),
mover.PantPress, mover.PantPress,
( mover.bPantKurek3 ? '-' : '|' ) ); ( mover.bPantKurek3 ? '-' : '|' ) );
textline += m_buffer.data(); textline += m_buffer.data();
@@ -677,7 +677,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::debug_vehicle_forcesaccelerationvelocityposition ].c_str(), STR_C(debug_vehicle_forcesaccelerationvelocityposition),
// forces // forces
mover.Ft * 0.001f * ( mover.ActiveCab ? mover.ActiveCab : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->ActiveCab : 1 ) + 0.001f, mover.Ft * 0.001f * ( mover.ActiveCab ? mover.ActiveCab : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->ActiveCab : 1 ) + 0.001f,
mover.Fb * 0.001f, mover.Fb * 0.001f,
@@ -702,7 +702,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
std::string std::string
debug_panel::update_vehicle_coupler( int const Side ) { debug_panel::update_vehicle_coupler( int const Side ) {
// NOTE: mover and vehicle are guaranteed to be valid by the caller // NOTE: mover and vehicle are guaranteed to be valid by the caller
std::string couplerstatus { locale::strings[ locale::string::debug_vehicle_none ] }; std::string couplerstatus { STR(debug_vehicle_none) };
auto const *connected { m_input.vehicle->MoverParameters->Neighbours[ Side ].vehicle }; auto const *connected { m_input.vehicle->MoverParameters->Neighbours[ Side ].vehicle };

View File

@@ -74,7 +74,7 @@ const std::string *editor_ui::get_active_node_template() {
void editor_ui::render_menu_contents() { void editor_ui::render_menu_contents() {
ui_layer::render_menu_contents(); ui_layer::render_menu_contents();
if (ImGui::BeginMenu(locale::strings[locale::string::ui_mode_windows].c_str())) if (ImGui::BeginMenu(STR_C(ui_mode_windows)))
{ {
ImGui::MenuItem(m_nodebankpanel.title.c_str(), nullptr, &m_nodebankpanel.is_open); ImGui::MenuItem(m_nodebankpanel.title.c_str(), nullptr, &m_nodebankpanel.is_open);
ImGui::EndMenu(); ImGui::EndMenu();

View File

@@ -25,13 +25,6 @@ extern bool key_shift;
class keyboard_input { class keyboard_input {
public: public:
// types // types
/*
struct binding_setup {
user_command command;
int binding;
};*/
using bindingsetup_sequence = std::map<user_command, int>; using bindingsetup_sequence = std::map<user_command, int>;
enum keymodifier : int { enum keymodifier : int {

View File

@@ -83,7 +83,7 @@ scenarioloader_mode::enter() {
m_userinterface->set_background( "logo" ); m_userinterface->set_background( "logo" );
Application.set_title( Global.AppName + " (" + Global.SceneryFile + ")" ); Application.set_title( Global.AppName + " (" + Global.SceneryFile + ")" );
m_userinterface->set_progress(); m_userinterface->set_progress();
m_userinterface->set_progress(locale::strings[locale::string::ui_loading_scenery]); m_userinterface->set_progress(STR(ui_loading_scenery));
GfxRenderer.Render(); GfxRenderer.Render();
} }

View File

@@ -576,8 +576,7 @@ void locale::init()
return; return;
} }
while (stream.eof()) while (parse_translation(stream));
parse_translation(stream);
WriteLog("translation: " + std::to_string(lang_mapping.size()) + " strings loaded"); WriteLog("translation: " + std::to_string(lang_mapping.size()) + " strings loaded");
} }
@@ -587,7 +586,7 @@ const std::string& locale::lookup_s(const std::string &msg, bool constant)
if (constant) { if (constant) {
auto it = pointer_cache.find(&msg); auto it = pointer_cache.find(&msg);
if (it != pointer_cache.end()) if (it != pointer_cache.end())
return *(it->second); return *((const std::string*)(it->second));
} }
auto it = lang_mapping.find(msg); auto it = lang_mapping.find(msg);
@@ -602,25 +601,27 @@ const std::string& locale::lookup_s(const std::string &msg, bool constant)
return msg; return msg;
} }
const char* locale::lookup(const char *msg, bool constant) const char* locale::lookup_c(const char *msg, bool constant)
{ {
if (constant) { if (constant) {
auto it = pointer_cache.find(&msg); auto it = pointer_cache.find(msg);
if (it != pointer_cache.end()) if (it != pointer_cache.end())
return it->second->c_str(); return (const char*)(it->second);
} }
auto it = lang_mapping.find(std::string(msg)); auto it = lang_mapping.find(std::string(msg));
if (it != lang_mapping.end()) { if (it != lang_mapping.end()) {
if (constant) if (constant)
pointer_cache.emplace(&msg, &(it->second)); pointer_cache.emplace(msg, it->second.c_str());
return it->second.c_str(); return it->second.c_str();
} }
if (constant)
pointer_cache.emplace(msg, msg);
return msg; return msg;
} }
void locale::parse_translation(std::istream &stream) bool locale::parse_translation(std::istream &stream)
{ {
std::string line; std::string line;
@@ -649,11 +650,17 @@ void locale::parse_translation(std::istream &stream)
msgctxt += parse_c_literal(line); msgctxt += parse_c_literal(line);
} }
else { else {
if (!msgid.empty() && !msgstr.empty()) if (!msgid.empty() && !msgstr.empty()) {
lang_mapping.emplace(msgctxt + "\x1d" + msgid, msgstr); if (!msgctxt.empty())
return; lang_mapping.emplace(msgctxt + "\x1d" + msgid, msgstr);
else
lang_mapping.emplace(msgid, msgstr);
}
return true;
} }
} }
return false;
} }
std::string locale::parse_c_literal(const std::string &str) std::string locale::parse_c_literal(const std::string &str)
@@ -665,7 +672,7 @@ std::string locale::parse_c_literal(const std::string &str)
bool escape = false; bool escape = false;
char c; char c;
while ((c = stream.get()) != stream.eof()) { while ((c = stream.get()) != std::char_traits<char>::eof()) {
if (!escape && c == '"') if (!escape && c == '"')
active = !active; active = !active;
else if (active && !escape && c == '\\') else if (active && !escape && c == '\\')
@@ -826,3 +833,5 @@ std::string locale::label_cab_control(std::string const &Label)
lookup_s(it->second) : lookup_s(it->second) :
"" ); "" );
} }
locale Translations;

View File

@@ -226,20 +226,23 @@ http://mozilla.org/MPL/2.0/.
class locale { class locale {
public: public:
static void init(); void init();
static std::string label_cab_control(const std::string &Label); std::string label_cab_control(const std::string &Label);
static const char* lookup(const char *msg, bool constant = true); const char* lookup_c(const char *msg, bool constant = false);
static const std::string& lookup_s(const std::string &msg, bool constant = true); const std::string& lookup_s(const std::string &msg, bool constant = false);
private: private:
static void parse_translation(std::istream &stream); bool parse_translation(std::istream &stream);
static std::string parse_c_literal(const std::string &str); std::string parse_c_literal(const std::string &str);
static std::unordered_map<std::string, std::string> lang_mapping; std::unordered_map<std::string, std::string> lang_mapping;
static std::unordered_map<const void*, std::string*> pointer_cache; std::unordered_map<const void*, const void*> pointer_cache;
}; };
#define LOC_STR(x) locale::lookup_s(#x) extern locale Translations;
#define LOC_STR_C(x) locale::lookup(#x)
#define STR(x) Translations.lookup_s(#x, true)
#define STR_C(x) Translations.lookup_c(#x, true)
#define STRC(x, c) Translations.lookup_s(c "\x1d" #x, true)
#define STRC_C(x, c) Translations.lookup_c(c "\x1d" #x, true)

View File

@@ -77,7 +77,7 @@ void ui_panel::register_popup(std::unique_ptr<ui::popup> &&popup)
void ui_expandable_panel::render_contents() void ui_expandable_panel::render_contents()
{ {
ImGui::Checkbox(LOC_STR(ui_expand), &is_expanded); ImGui::Checkbox(STR_C(ui_expand), &is_expanded);
ui_panel::render_contents(); ui_panel::render_contents();
} }
@@ -269,14 +269,14 @@ void ui_layer::render_quit_widget()
return; return;
ImGui::SetNextWindowSize(ImVec2(0, 0)); ImGui::SetNextWindowSize(ImVec2(0, 0));
ImGui::Begin(LOC_STR(ui_quit), &m_quit_active, ImGuiWindowFlags_NoResize); ImGui::Begin(STR_C(ui_quit), &m_quit_active, ImGuiWindowFlags_NoResize);
ImGui::TextUnformatted(LOC_STR(ui_quit_simulation_q)); ImGui::TextUnformatted(STR_C(ui_quit_simulation_q));
if (ImGui::Button(LOC_STR(ui_yes))) { if (ImGui::Button(STR_C(ui_yes))) {
command_relay relay; command_relay relay;
relay.post(user_command::quitsimulation, 0.0, 0.0, GLFW_PRESS, 0); relay.post(user_command::quitsimulation, 0.0, 0.0, GLFW_PRESS, 0);
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(LOC_STR(ui_no))) if (ImGui::Button(STR_C(ui_no)))
m_quit_active = false; m_quit_active = false;
ImGui::End(); ImGui::End();
} }
@@ -334,7 +334,7 @@ void ui_layer::render_progress()
ImGui::SetNextWindowPos(ImVec2(50, 50)); ImGui::SetNextWindowPos(ImVec2(50, 50));
ImGui::SetNextWindowSize(ImVec2(0, 0)); ImGui::SetNextWindowSize(ImVec2(0, 0));
ImGui::Begin(LOC_STR(ui_loading), nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); ImGui::Begin(STR_C(ui_loading), nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
if (!m_progresstext.empty()) if (!m_progresstext.empty())
ImGui::ProgressBar(m_progress, ImVec2(300, 0), m_progresstext.c_str()); ImGui::ProgressBar(m_progress, ImVec2(300, 0), m_progresstext.c_str());
else else
@@ -366,29 +366,29 @@ void ui_layer::render_tooltip()
void ui_layer::render_menu_contents() void ui_layer::render_menu_contents()
{ {
if (ImGui::BeginMenu(LOC_STR(ui_general))) if (ImGui::BeginMenu(STR_C(ui_general)))
{ {
ImGui::MenuItem(LOC_STR(ui_debug_mode), nullptr, &DebugModeFlag); ImGui::MenuItem(STR_C(ui_debug_mode), nullptr, &DebugModeFlag);
ImGui::MenuItem(LOC_STR(ui_quit), "F10", &m_quit_active); ImGui::MenuItem(STR_C(ui_quit), "F10", &m_quit_active);
ImGui::EndMenu(); ImGui::EndMenu();
} }
if (ImGui::BeginMenu(LOC_STR(ui_tools))) if (ImGui::BeginMenu(STR_C(ui_tools)))
{ {
static bool log = Global.iWriteLogEnabled & 1; static bool log = Global.iWriteLogEnabled & 1;
ImGui::MenuItem(LOC_STR(ui_logging_to_log), nullptr, &log); ImGui::MenuItem(STR_C(ui_logging_to_log), nullptr, &log);
if (log) if (log)
Global.iWriteLogEnabled |= 1; Global.iWriteLogEnabled |= 1;
else else
Global.iWriteLogEnabled &= ~1; Global.iWriteLogEnabled &= ~1;
if (ImGui::MenuItem(LOC_STR(ui_screenshot), "PrtScr")) if (ImGui::MenuItem(STR_C(ui_screenshot), "PrtScr"))
Application.queue_screenshot(); Application.queue_screenshot();
ImGui::EndMenu(); ImGui::EndMenu();
} }
if (ImGui::BeginMenu(LOC_STR(ui_windows))) if (ImGui::BeginMenu(STR_C(ui_windows)))
{ {
ImGui::MenuItem(LOC_STR(ui_log), "F9", &m_logpanel.is_open); ImGui::MenuItem(STR_C(ui_log), "F9", &m_logpanel.is_open);
if (DebugModeFlag) { if (DebugModeFlag) {
ImGui::MenuItem("ImGui Demo", nullptr, &m_imgui_demo); ImGui::MenuItem("ImGui Demo", nullptr, &m_imgui_demo);
ImGui::MenuItem("Headlight config", nullptr, &GfxRenderer.debug_ui_active); ImGui::MenuItem("Headlight config", nullptr, &GfxRenderer.debug_ui_active);

View File

@@ -4,7 +4,7 @@
#include "Logs.h" #include "Logs.h"
ui::cameraview_panel::cameraview_panel() ui::cameraview_panel::cameraview_panel()
: ui_panel(LOC_STR(cameraview_window), false) : ui_panel(STR_C(cameraview_window), false)
{ {
size_min = { -2, -2 }; size_min = { -2, -2 };
} }

View File

@@ -8,7 +8,7 @@
#include "Driver.h" #include "Driver.h"
#include "AnimModel.h" #include "AnimModel.h"
ui::map_panel::map_panel() : ui_panel(LOC_STR(ui_map), false) ui::map_panel::map_panel() : ui_panel(STR_C(ui_map), false)
{ {
size_min = {200, 200}; size_min = {200, 200};
size_max = {fb_size, fb_size}; size_max = {fb_size, fb_size};
@@ -445,13 +445,13 @@ void ui::launcher_window::render_content()
{ {
ImGui::TextUnformatted(m_switch->name.c_str()); ImGui::TextUnformatted(m_switch->name.c_str());
const std::string &open_label = locale::strings[ const std::string &open_label = STR(
m_switch->type == map::launcher::track_switch m_switch->type == map::launcher::track_switch
? locale::string::map_straight : locale::string::map_open]; ? locale::string::map_straight : locale::string::map_open);
const std::string &close_label = locale::strings[ const std::string &close_label = STR(
m_switch->type == map::launcher::track_switch m_switch->type == map::launcher::track_switch
? locale::string::map_divert : locale::string::map_close]; ? locale::string::map_divert : locale::string::map_close);
if (ImGui::Button(open_label.c_str())) if (ImGui::Button(open_label.c_str()))
{ {
@@ -495,7 +495,7 @@ void ui::obstacle_insert_window::render_content()
return; return;
} }
ImGui::TextUnformatted(LOC_STR(map_obstacle_insert)); ImGui::TextUnformatted(STR_C(map_obstacle_insert));
for (auto const &entry : m_obstacles) for (auto const &entry : m_obstacles)
{ {
if (ImGui::Button(entry.first.c_str())) if (ImGui::Button(entry.first.c_str()))
@@ -526,7 +526,7 @@ ui::obstacle_remove_window::obstacle_remove_window(ui_panel &panel, std::shared_
void ui::obstacle_remove_window::render_content() void ui::obstacle_remove_window::render_content()
{ {
if (ImGui::Button(LOC_STR(map_obstacle_remove))) { if (ImGui::Button(STR_C(map_obstacle_remove))) {
m_relay.post(user_command::deletemodel, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(), &m_obstacle->model_name); m_relay.post(user_command::deletemodel, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(), &m_obstacle->model_name);
auto &entries = map::Objects.entries; auto &entries = map::Objects.entries;

View File

@@ -3,20 +3,20 @@
#include "simulationtime.h" #include "simulationtime.h"
#include "Globals.h" #include "Globals.h"
ui::time_panel::time_panel() : ui_panel(LOC_STR(time_window), false) ui::time_panel::time_panel() : ui_panel(STR_C(time_window), false)
{ {
size.x = 450; size.x = 450;
} }
void ui::time_panel::render_contents() void ui::time_panel::render_contents()
{ {
ImGui::SliderFloat(LOC_STR(time_time), &time, 0.0f, 24.0f, "%.1f"); ImGui::SliderFloat(STR_C(time_time), &time, 0.0f, 24.0f, "%.1f");
ImGui::SliderInt(LOC_STR(time_yearday), &yearday, 1, 365); ImGui::SliderInt(STR_C(time_yearday), &yearday, 1, 365);
ImGui::SliderFloat(LOC_STR(time_visibility), &fog, 50.0f, 3000.0f, "%.0f"); ImGui::SliderFloat(STR_C(time_visibility), &fog, 50.0f, 3000.0f, "%.0f");
ImGui::SliderFloat(LOC_STR(time_weather), &overcast, 0.0f, 2.0f, "%.1f"); ImGui::SliderFloat(STR_C(time_weather), &overcast, 0.0f, 2.0f, "%.1f");
ImGui::SliderFloat(LOC_STR(time_temperature), &temperature, -20.0f, 40.0f, "%.0f"); ImGui::SliderFloat(STR_C(time_temperature), &temperature, -20.0f, 40.0f, "%.0f");
if (ImGui::Button(LOC_STR(time_apply))) if (ImGui::Button(STR_C(time_apply)))
{ {
m_relay.post(user_command::setdatetime, (double)yearday, time, 1, 0); m_relay.post(user_command::setdatetime, (double)yearday, time, 1, 0);
m_relay.post(user_command::setweather, fog, overcast, 1, 0); m_relay.post(user_command::setweather, fog, overcast, 1, 0);

View File

@@ -5,7 +5,7 @@
#include "widgets/vehicleparams.h" #include "widgets/vehicleparams.h"
ui::vehiclelist_panel::vehiclelist_panel(ui_layer &parent) ui::vehiclelist_panel::vehiclelist_panel(ui_layer &parent)
: ui_panel(LOC_STR(vehiclelist_window), false), m_parent(parent) : ui_panel(STR_C(vehiclelist_window), false), m_parent(parent)
{ {
} }

View File

@@ -6,7 +6,7 @@
#include "Train.h" #include "Train.h"
ui::vehicleparams_panel::vehicleparams_panel(const std::string &vehicle) ui::vehicleparams_panel::vehicleparams_panel(const std::string &vehicle)
: ui_panel(std::string(locale::strings[locale::string::vehicleparams_window]) + ": " + vehicle, false), m_vehicle_name(vehicle) : ui_panel(std::string(STR(vehicleparams_window)) + ": " + vehicle, false), m_vehicle_name(vehicle)
{ {
} }
@@ -53,7 +53,7 @@ void ui::vehicleparams_panel::render_contents()
std::snprintf( std::snprintf(
buffer.data(), buffer.size(), buffer.data(), buffer.size(),
locale::strings[ locale::string::debug_vehicle_devicespower ].c_str(), STR_C(debug_vehicle_devicespower),
// devices // devices
( mover.Battery ? 'B' : '.' ), ( mover.Battery ? 'B' : '.' ),
( mover.Mains ? 'M' : '.' ), ( mover.Mains ? 'M' : '.' ),
@@ -70,7 +70,7 @@ void ui::vehicleparams_panel::render_contents()
( mover.CompressorFlag ? 'C' : ( false == mover.CompressorAllowLocal ? '-' : ( ( mover.CompressorAllow || mover.CompressorStart == start_t::automatic ) ? 'c' : '.' ) ) ), ( mover.CompressorFlag ? 'C' : ( false == mover.CompressorAllowLocal ? '-' : ( ( mover.CompressorAllow || mover.CompressorStart == start_t::automatic ) ? 'c' : '.' ) ) ),
( mover.CompressorGovernorLock ? '!' : '.' ), ( mover.CompressorGovernorLock ? '!' : '.' ),
"", "",
std::string( isdieselenginepowered ? locale::strings[ locale::string::debug_vehicle_oilpressure ] + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(), std::string( isdieselenginepowered ? STR(debug_vehicle_oilpressure) + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(),
// power transfers // power transfers
mover.Couplers[ end::front ].power_high.voltage, mover.Couplers[ end::front ].power_high.voltage,
mover.Couplers[ end::front ].power_high.current, mover.Couplers[ end::front ].power_high.current,
@@ -84,11 +84,11 @@ void ui::vehicleparams_panel::render_contents()
std::snprintf( std::snprintf(
buffer.data(), buffer.size(), buffer.data(), buffer.size(),
locale::strings[ locale::string::debug_vehicle_controllersenginerevolutions ].c_str(), STR_C(debug_vehicle_controllersenginerevolutions),
// controllers // controllers
mover.MainCtrlPos, mover.MainCtrlPos,
mover.MainCtrlActualPos, mover.MainCtrlActualPos,
std::string( isdieselinshuntmode ? to_string( mover.AnPos, 2 ) + locale::strings[ locale::string::debug_vehicle_shuntmode ] : std::to_string( mover.ScndCtrlPos ) + "(" + std::to_string( mover.ScndCtrlActualPos ) + ")" ).c_str(), std::string( isdieselinshuntmode ? to_string( mover.AnPos, 2 ) + STR(debug_vehicle_shuntmode) : std::to_string( mover.ScndCtrlPos ) + "(" + std::to_string( mover.ScndCtrlActualPos ) + ")" ).c_str(),
// engine // engine
mover.EnginePower, mover.EnginePower,
std::abs( mover.TrainType == dt_EZT ? mover.ShowCurrent( 0 ) : mover.Im ), std::abs( mover.TrainType == dt_EZT ? mover.ShowCurrent( 0 ) : mover.Im ),
@@ -106,7 +106,7 @@ void ui::vehicleparams_panel::render_contents()
if( isdieselenginepowered ) { if( isdieselenginepowered ) {
std::snprintf( std::snprintf(
buffer.data(), buffer.size(), buffer.data(), buffer.size(),
locale::strings[ locale::string::debug_vehicle_temperatures ].c_str(), STR_C(debug_vehicle_temperatures),
mover.dizel_heat.Ts, mover.dizel_heat.Ts,
mover.dizel_heat.To, mover.dizel_heat.To,
mover.dizel_heat.temperatura1, mover.dizel_heat.temperatura1,
@@ -132,7 +132,7 @@ void ui::vehicleparams_panel::render_contents()
std::snprintf( std::snprintf(
buffer.data(), buffer.size(), buffer.data(), buffer.size(),
locale::strings[ locale::string::debug_vehicle_brakespressures ].c_str(), STR_C(debug_vehicle_brakespressures),
// brakes // brakes
mover.fBrakeCtrlPos, mover.fBrakeCtrlPos,
mover.LocalBrakePosA, mover.LocalBrakePosA,
@@ -158,7 +158,7 @@ void ui::vehicleparams_panel::render_contents()
if( mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { if( mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) {
std::snprintf( std::snprintf(
buffer.data(), buffer.size(), buffer.data(), buffer.size(),
locale::strings[ locale::string::debug_vehicle_pantograph ].c_str(), STR_C(debug_vehicle_pantograph),
mover.PantPress, mover.PantPress,
( mover.bPantKurek3 ? '-' : '|' ) ); ( mover.bPantKurek3 ? '-' : '|' ) );
ImGui::TextUnformatted(buffer.data()); ImGui::TextUnformatted(buffer.data());
@@ -166,7 +166,7 @@ void ui::vehicleparams_panel::render_contents()
std::snprintf( std::snprintf(
buffer.data(), buffer.size(), buffer.data(), buffer.size(),
locale::strings[ locale::string::debug_vehicle_forcesaccelerationvelocityposition ].c_str(), STR_C(debug_vehicle_forcesaccelerationvelocityposition),
// forces // forces
mover.Ft * 0.001f * ( mover.ActiveCab ? mover.ActiveCab : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->ActiveCab : 1 ) + 0.001f, mover.Ft * 0.001f * ( mover.ActiveCab ? mover.ActiveCab : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->ActiveCab : 1 ) + 0.001f,
mover.Fb * 0.001f, mover.Fb * 0.001f,
@@ -186,40 +186,40 @@ void ui::vehicleparams_panel::render_contents()
ImGui::TextUnformatted(buffer.data()); ImGui::TextUnformatted(buffer.data());
if (ImGui::Button(LOC_STR(vehicleparams_radiostop))) if (ImGui::Button(STR_C(vehicleparams_radiostop)))
m_relay.post(user_command::radiostop, 0.0, 0.0, GLFW_PRESS, 0, vehicle_ptr->GetPosition()); m_relay.post(user_command::radiostop, 0.0, 0.0, GLFW_PRESS, 0, vehicle_ptr->GetPosition());
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(LOC_STR(vehicleparams_reset))) if (ImGui::Button(STR_C(vehicleparams_reset)))
m_relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name()); m_relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(LOC_STR(vehicleparams_resetposition))) { if (ImGui::Button(STR_C(vehicleparams_resetposition))) {
std::string payload = vehicle_ptr->name() + '%' + vehicle_ptr->initial_track->name(); std::string payload = vehicle_ptr->name() + '%' + vehicle_ptr->initial_track->name();
m_relay.post(user_command::consistteleport, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &payload); m_relay.post(user_command::consistteleport, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &payload);
m_relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name()); m_relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
} }
if (ImGui::Button(LOC_STR(vehicleparams_resetpipe))) if (ImGui::Button(STR_C(vehicleparams_resetpipe)))
m_relay.post(user_command::fillcompressor, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name()); m_relay.post(user_command::fillcompressor, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(LOC_STR(vehicleparams_rupturepipe))) if (ImGui::Button(STR_C(vehicleparams_rupturepipe)))
m_relay.post(user_command::pullalarmchain, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name()); m_relay.post(user_command::pullalarmchain, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
ImGui::SameLine(); ImGui::SameLine();
ImGui::Button(LOC_STR(cab_releaser_bt)); ImGui::Button(STR_C(cab_releaser_bt));
if (ImGui::IsItemClicked()) if (ImGui::IsItemClicked())
m_relay.post(user_command::consistreleaser, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name()); m_relay.post(user_command::consistreleaser, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
if (ImGui::IsItemDeactivated()) if (ImGui::IsItemDeactivated())
m_relay.post(user_command::consistreleaser, 0.0, 0.0, GLFW_RELEASE, 0, glm::vec3(0.0f), &vehicle_ptr->name()); m_relay.post(user_command::consistreleaser, 0.0, 0.0, GLFW_RELEASE, 0, glm::vec3(0.0f), &vehicle_ptr->name());
if (vehicle_ptr->MoverParameters->V < 0.01) { if (vehicle_ptr->MoverParameters->V < 0.01) {
if (ImGui::Button(LOC_STR(vehicleparams_move500f))) if (ImGui::Button(STR_C(vehicleparams_move500f)))
m_relay.post(user_command::dynamicmove, 500.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name()); m_relay.post(user_command::dynamicmove, 500.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(LOC_STR(vehicleparams_move500b))) if (ImGui::Button(STR_C(vehicleparams_move500b)))
m_relay.post(user_command::dynamicmove, -500.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name()); m_relay.post(user_command::dynamicmove, -500.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
} }
} }