16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

build 170712. increased amount of generic cab items, varying command repeat rate for mouse control

This commit is contained in:
tmj-fstate
2017-07-12 18:09:51 +02:00
parent 16718d53bb
commit 9877b37e1f
17 changed files with 403 additions and 186 deletions

View File

@@ -68,7 +68,7 @@ namespace input {
keyboard_input Keyboard; keyboard_input Keyboard;
mouse_input Mouse; mouse_input Mouse;
gamepad_input Gamepad; gamepad_input Gamepad;
glm::dvec2 mouse_pos; // stores last mouse position in control picking mode glm::dvec2 mouse_pickmodepos; // stores last mouse position in control picking mode
} }
@@ -144,8 +144,8 @@ void mouse_button_callback( GLFWwindow* window, int button, int action, int mods
} }
} }
void key_callback( GLFWwindow *window, int key, int scancode, int action, int mods ) void key_callback( GLFWwindow *window, int key, int scancode, int action, int mods ) {
{
input::Keyboard.key( key, action ); input::Keyboard.key( key, action );
Global::shiftState = ( mods & GLFW_MOD_SHIFT ) ? true : false; Global::shiftState = ( mods & GLFW_MOD_SHIFT ) ? true : false;
@@ -159,14 +159,14 @@ void key_callback( GLFWwindow *window, int key, int scancode, int action, int mo
if( Global::ControlPicking ) { if( Global::ControlPicking ) {
// switch off // switch off
glfwGetCursorPos( window, &input::mouse_pos.x, &input::mouse_pos.y ); glfwGetCursorPos( window, &input::mouse_pickmodepos.x, &input::mouse_pickmodepos.y );
glfwSetInputMode( window, GLFW_CURSOR, GLFW_CURSOR_DISABLED ); glfwSetInputMode( window, GLFW_CURSOR, GLFW_CURSOR_DISABLED );
glfwSetCursorPos( window, 0, 0 ); glfwSetCursorPos( window, 0, 0 );
} }
else { else {
// enter picking mode // enter picking mode
glfwSetInputMode( window, GLFW_CURSOR, GLFW_CURSOR_NORMAL ); glfwSetInputMode( window, GLFW_CURSOR, GLFW_CURSOR_NORMAL );
glfwSetCursorPos( window, input::mouse_pos.x, input::mouse_pos.y ); glfwSetCursorPos( window, input::mouse_pickmodepos.x, input::mouse_pickmodepos.y );
} }
// actually toggle the mode // actually toggle the mode
Global::ControlPicking = !Global::ControlPicking; Global::ControlPicking = !Global::ControlPicking;
@@ -183,8 +183,8 @@ void key_callback( GLFWwindow *window, int key, int scancode, int action, int mo
return; return;
} }
if( action == GLFW_PRESS || action == GLFW_REPEAT ) if( action == GLFW_PRESS || action == GLFW_REPEAT ) {
{
World.OnKeyDown( key ); World.OnKeyDown( key );
switch( key ) switch( key )

View File

@@ -47,16 +47,6 @@ void SetDeltaTime(double t)
DeltaTime = t; DeltaTime = t;
} }
double GetSimulationTime()
{
return fSimulationTime;
}
void SetSimulationTime(double t)
{
fSimulationTime = t;
}
bool GetSoundTimer() bool GetSoundTimer()
{ // Ra: być może, by dźwięki nie modyfikowały się zbyt często, po 0.1s zeruje się ten licznik { // Ra: być może, by dźwięki nie modyfikowały się zbyt często, po 0.1s zeruje się ten licznik
return (fSoundTimer == 0.0f); return (fSoundTimer == 0.0f);

View File

@@ -21,10 +21,6 @@ double GetfSinceStart();
void SetDeltaTime(double v); void SetDeltaTime(double v);
double GetSimulationTime();
void SetSimulationTime(double v);
bool GetSoundTimer(); bool GetSoundTimer();
double GetFPS(); double GetFPS();

190
Train.cpp
View File

@@ -225,7 +225,17 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::departureannounce, &TTrain::OnCommand_departureannounce }, { user_command::departureannounce, &TTrain::OnCommand_departureannounce },
{ user_command::hornlowactivate, &TTrain::OnCommand_hornlowactivate }, { user_command::hornlowactivate, &TTrain::OnCommand_hornlowactivate },
{ user_command::hornhighactivate, &TTrain::OnCommand_hornhighactivate }, { user_command::hornhighactivate, &TTrain::OnCommand_hornhighactivate },
{ user_command::radiotoggle, &TTrain::OnCommand_radiotoggle } { user_command::radiotoggle, &TTrain::OnCommand_radiotoggle },
{ user_command::generictoggle0, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle1, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle2, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle3, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle4, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle5, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle6, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle7, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle8, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle9, &TTrain::OnCommand_generictoggle }
}; };
std::vector<std::string> const TTrain::fPress_labels = { std::vector<std::string> const TTrain::fPress_labels = {
@@ -233,9 +243,10 @@ std::vector<std::string> const TTrain::fPress_labels = {
"ch1: ", "ch2: ", "ch3: ", "ch4: ", "ch5: ", "ch6: ", "ch7: ", "ch8: ", "ch9: ", "ch0: " "ch1: ", "ch2: ", "ch3: ", "ch4: ", "ch5: ", "ch6: ", "ch7: ", "ch8: ", "ch9: ", "ch0: "
}; };
TTrain::TTrain() TTrain::TTrain() {
{ /*
ActiveUniversal4 = false; Universal4Active = false;
*/
ShowNextCurrent = false; ShowNextCurrent = false;
// McZapkie-240302 - przyda sie do tachometru // McZapkie-240302 - przyda sie do tachometru
fTachoVelocity = 0; fTachoVelocity = 0;
@@ -257,7 +268,7 @@ TTrain::TTrain()
bCabLightDim = false; bCabLightDim = false;
//----- //-----
pMechSittingPosition = vector3(0, 0, 0); // ABu: 180404 pMechSittingPosition = vector3(0, 0, 0); // ABu: 180404
LampkaUniversal3_st = false; // ABu: 030405 InstrumentLightActive = false; // ABu: 030405
dsbNastawnikJazdy = NULL; dsbNastawnikJazdy = NULL;
dsbNastawnikBocz = NULL; dsbNastawnikBocz = NULL;
dsbRelay = NULL; dsbRelay = NULL;
@@ -424,7 +435,7 @@ PyObject *TTrain::GetTrainState() {
PyDict_SetItemString( dict, "ca", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_aware ) ) ); PyDict_SetItemString( dict, "ca", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_aware ) ) );
PyDict_SetItemString( dict, "shp", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) ) ); PyDict_SetItemString( dict, "shp", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) ) );
PyDict_SetItemString( dict, "pantpress", PyGetFloat( mvControlled->PantPress ) ); PyDict_SetItemString( dict, "pantpress", PyGetFloat( mvControlled->PantPress ) );
PyDict_SetItemString( dict, "universal3", PyGetBool( LampkaUniversal3_st ) ); PyDict_SetItemString( dict, "universal3", PyGetBool( InstrumentLightActive ) );
// movement data // movement data
PyDict_SetItemString( dict, "velocity", PyGetFloat( mover->Vel ) ); PyDict_SetItemString( dict, "velocity", PyGetFloat( mover->Vel ) );
PyDict_SetItemString( dict, "tractionforce", PyGetFloat( mover->Ft ) ); PyDict_SetItemString( dict, "tractionforce", PyGetFloat( mover->Ft ) );
@@ -2665,7 +2676,7 @@ void TTrain::OnCommand_instrumentlighttoggle( TTrain *Train, command_data const
// NOTE: the check is disabled, as we're presuming light control is present in every vehicle // NOTE: the check is disabled, as we're presuming light control is present in every vehicle
// TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels
if( Train->ggUniversal3Button.SubModel == nullptr ) { if( Train->ggInstrumentLightButton.SubModel == nullptr ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_PRESS ) {
WriteLog( "Universal3 switch is missing, or wasn't defined" ); WriteLog( "Universal3 switch is missing, or wasn't defined" );
} }
@@ -2675,25 +2686,25 @@ void TTrain::OnCommand_instrumentlighttoggle( TTrain *Train, command_data const
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_PRESS ) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down // only reacting to press, so the switch doesn't flip back and forth if key is held down
// NOTE: instrument lighting isn't fully implemented, so we have to rely on the state of the 'button' i.e. light itself // NOTE: instrument lighting isn't fully implemented, so we have to rely on the state of the 'button' i.e. light itself
if( false == Train->LampkaUniversal3_st ) { if( false == Train->InstrumentLightActive ) {
// turn on // turn on
Train->LampkaUniversal3_st = true; Train->InstrumentLightActive = true;
// audio feedback // audio feedback
if( Train->ggUniversal3Button.GetValue() < 0.5 ) { if( Train->ggInstrumentLightButton.GetValue() < 0.5 ) {
Train->play_sound( Train->dsbSwitch ); Train->play_sound( Train->dsbSwitch );
} }
// visual feedback // visual feedback
Train->ggUniversal3Button.UpdateValue( 1.0 ); Train->ggInstrumentLightButton.UpdateValue( 1.0 );
} }
else { else {
//turn off //turn off
Train->LampkaUniversal3_st = false; Train->InstrumentLightActive = false;
// audio feedback // audio feedback
if( Train->ggUniversal3Button.GetValue() > 0.5 ) { if( Train->ggInstrumentLightButton.GetValue() > 0.5 ) {
Train->play_sound( Train->dsbSwitch ); Train->play_sound( Train->dsbSwitch );
} }
// visual feedback // visual feedback
Train->ggUniversal3Button.UpdateValue( 0.0 ); Train->ggInstrumentLightButton.UpdateValue( 0.0 );
} }
} }
} }
@@ -2732,6 +2743,41 @@ void TTrain::OnCommand_heatingtoggle( TTrain *Train, command_data const &Command
} }
} }
void TTrain::OnCommand_generictoggle( TTrain *Train, command_data const &Command ) {
auto const itemindex = static_cast<int>( Command.command ) - static_cast<int>( user_command::generictoggle0 );
auto &item = Train->ggUniversals[ itemindex ];
if( item.SubModel == nullptr ) {
if( Command.action == GLFW_PRESS ) {
WriteLog( "Train generic item " + std::to_string( itemindex ) + " is missing, or wasn't defined" );
}
return;
}
if( Command.action == GLFW_PRESS ) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( item.GetValue() < 0.25 ) {
// turn on
// audio feedback
if( item.GetValue() < 0.5 ) {
Train->play_sound( Train->dsbSwitch );
}
// visual feedback
item.UpdateValue( 1.0 );
}
else {
//turn off
// audio feedback
if( item.GetValue() > 0.5 ) {
Train->play_sound( Train->dsbSwitch );
}
// visual feedback
item.UpdateValue( 0.0 );
}
}
}
void TTrain::OnCommand_doorlocktoggle( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_doorlocktoggle( TTrain *Train, command_data const &Command ) {
if( Train->ggDoorSignallingButton.SubModel == nullptr ) { if( Train->ggDoorSignallingButton.SubModel == nullptr ) {
@@ -5193,7 +5239,6 @@ bool TTrain::Update( double const Deltatime )
} }
else else
ggMainOffButton.UpdateValue(0); ggMainOffButton.UpdateValue(0);
#endif
/* if (cKey==Global::Keys[k_Main]) //z shiftem /* if (cKey==Global::Keys[k_Main]) //z shiftem
{ {
ggMainOnButton.PutValue(1); ggMainOnButton.PutValue(1);
@@ -5220,7 +5265,6 @@ bool TTrain::Update( double const Deltatime )
} }
} }
else */ else */
#ifdef EU07_USE_OLD_COMMAND_SYSTEM
//---------------- //----------------
// hunter-131211: czuwak przeniesiony z OnKeyPress // hunter-131211: czuwak przeniesiony z OnKeyPress
// hunter-091012: zrobiony test czuwaka // hunter-091012: zrobiony test czuwaka
@@ -5253,7 +5297,6 @@ bool TTrain::Update( double const Deltatime )
} }
CAflag = false; CAflag = false;
} }
#endif
/* /*
if ( Console::Pressed(Global::Keys[k_Czuwak]) ) if ( Console::Pressed(Global::Keys[k_Czuwak]) )
{ {
@@ -5292,7 +5335,6 @@ bool TTrain::Update( double const Deltatime )
} }
*/ */
#ifdef EU07_USE_OLD_COMMAND_SYSTEM
if( Console::Pressed( Global::Keys[ k_Sand ] ) ) if( Console::Pressed( Global::Keys[ k_Sand ] ) )
{ {
if (mvControlled->TrainType != dt_EZT && ggSandButton.SubModel != NULL) if (mvControlled->TrainType != dt_EZT && ggSandButton.SubModel != NULL)
@@ -5375,7 +5417,6 @@ bool TTrain::Update( double const Deltatime )
ggCompressorButton.PutValue(0); ggCompressorButton.PutValue(0);
mvControlled->CompressorSwitch(false); mvControlled->CompressorSwitch(false);
} }
#endif
/* /*
bez szifta bez szifta
if (cKey==Global::Keys[k_Converter]) //NBMX wyl przetwornicy if (cKey==Global::Keys[k_Converter]) //NBMX wyl przetwornicy
@@ -5398,7 +5439,6 @@ bool TTrain::Update( double const Deltatime )
else else
*/ */
//----------------- //-----------------
#ifdef EU07_USE_OLD_COMMAND_SYSTEM
if ((!FreeFlyModeFlag) && if ((!FreeFlyModeFlag) &&
(!(DynamicObject->Mechanik ? DynamicObject->Mechanik->AIControllFlag : false))) (!(DynamicObject->Mechanik ? DynamicObject->Mechanik->AIControllFlag : false)))
{ {
@@ -5422,7 +5462,6 @@ bool TTrain::Update( double const Deltatime )
else else
mvOccupied->BrakeReleaser(0); mvOccupied->BrakeReleaser(0);
} // FFMF } // FFMF
#endif
if (Console::Pressed(Global::Keys[k_Univ1])) if (Console::Pressed(Global::Keys[k_Univ1]))
{ {
@@ -5435,13 +5474,11 @@ bool TTrain::Update( double const Deltatime )
ggUniversal1Button.DecValue(dt / 2); ggUniversal1Button.DecValue(dt / 2);
} }
} }
#ifdef EU07_USE_OLD_COMMAND_SYSTEM
if (!Console::Pressed(Global::Keys[k_SmallCompressor])) if (!Console::Pressed(Global::Keys[k_SmallCompressor]))
// Ra: przecieść to na zwolnienie klawisza // Ra: przecieść to na zwolnienie klawisza
if (DynamicObject->Mechanik ? !DynamicObject->Mechanik->AIControllFlag : if (DynamicObject->Mechanik ? !DynamicObject->Mechanik->AIControllFlag :
false) // nie wyłączać, gdy AI false) // nie wyłączać, gdy AI
mvControlled->PantCompFlag = false; // wyłączona, gdy nie trzymamy klawisza mvControlled->PantCompFlag = false; // wyłączona, gdy nie trzymamy klawisza
#else
/* /*
// NOTE: disabled to allow 'prototypical' 'tricking' pantograph compressor into running unattended // NOTE: disabled to allow 'prototypical' 'tricking' pantograph compressor into running unattended
if( ( ( DynamicObject->Mechanik != nullptr ) if( ( ( DynamicObject->Mechanik != nullptr )
@@ -5454,7 +5491,6 @@ bool TTrain::Update( double const Deltatime )
mvControlled->PantCompFlag = false; mvControlled->PantCompFlag = false;
} }
*/ */
#endif
if (Console::Pressed(Global::Keys[k_Univ2])) if (Console::Pressed(Global::Keys[k_Univ2]))
{ {
if (!DebugModeFlag) if (!DebugModeFlag)
@@ -5467,7 +5503,6 @@ bool TTrain::Update( double const Deltatime )
} }
} }
#ifdef EU07_USE_OLD_COMMAND_SYSTEM
// hunter-091012: zrobione z uwzglednieniem przelacznika swiatla // hunter-091012: zrobione z uwzglednieniem przelacznika swiatla
if (Console::Pressed(Global::Keys[k_Univ3])) if (Console::Pressed(Global::Keys[k_Univ3]))
{ {
@@ -5484,13 +5519,13 @@ bool TTrain::Update( double const Deltatime )
} }
else else
{ {
if (ggUniversal3Button.SubModel) if (ggInstrumentLightButton.SubModel)
{ {
ggUniversal3Button.PutValue(1); // hunter-131211: z UpdateValue na ggInstrumentLightButton.PutValue(1); // hunter-131211: z UpdateValue na
// PutValue - by zachowywal sie jak // PutValue - by zachowywal sie jak
// pozostale przelaczniki // pozostale przelaczniki
if (btLampkaUniversal3.Active()) if (btInstrumentLight.Active())
LampkaUniversal3_st = true; InstrumentLightActive = true;
} }
} }
} }
@@ -5507,37 +5542,37 @@ bool TTrain::Update( double const Deltatime )
} }
else else
{ {
if (ggUniversal3Button.SubModel) if (ggInstrumentLightButton.SubModel)
{ {
ggUniversal3Button.PutValue(0); // hunter-131211: z UpdateValue na ggInstrumentLightButton.PutValue(0); // hunter-131211: z UpdateValue na
// PutValue - by zachowywal sie jak // PutValue - by zachowywal sie jak
// pozostale przelaczniki // pozostale przelaczniki
if (btLampkaUniversal3.Active()) if (btInstrumentLight.Active())
LampkaUniversal3_st = false; InstrumentLightActive = false;
} }
} }
} }
} }
#endif #endif
// ABu030405 obsluga lampki uniwersalnej: // ABu030405 obsluga lampki uniwersalnej:
if (btLampkaUniversal3.Active()) // w ogóle jest if (btInstrumentLight.Active()) // w ogóle jest
if (LampkaUniversal3_st) // załączona if (InstrumentLightActive) // załączona
switch (LampkaUniversal3_typ) switch (InstrumentLightType)
{ {
case 0: case 0:
btLampkaUniversal3.Turn( mvControlled->Battery || mvControlled->ConverterFlag ); btInstrumentLight.Turn( mvControlled->Battery || mvControlled->ConverterFlag );
break; break;
case 1: case 1:
btLampkaUniversal3.Turn(mvControlled->Mains); btInstrumentLight.Turn(mvControlled->Mains);
break; break;
case 2: case 2:
btLampkaUniversal3.Turn(mvControlled->ConverterFlag); btInstrumentLight.Turn(mvControlled->ConverterFlag);
break; break;
default: default:
btLampkaUniversal3.TurnOff(); btInstrumentLight.TurnOff();
} }
else else
btLampkaUniversal3.TurnOff(); btInstrumentLight.TurnOff();
#ifdef EU07_USE_OLD_COMMAND_SYSTEM #ifdef EU07_USE_OLD_COMMAND_SYSTEM
// hunter-091012: przepisanie univ4 i zrobione z uwzglednieniem przelacznika // hunter-091012: przepisanie univ4 i zrobione z uwzglednieniem przelacznika
@@ -5556,7 +5591,7 @@ bool TTrain::Update( double const Deltatime )
} }
else else
{ {
ActiveUniversal4 = true; Universal4Active = true;
// ggUniversal4Button.UpdateValue(1); // ggUniversal4Button.UpdateValue(1);
} }
} }
@@ -5574,7 +5609,7 @@ bool TTrain::Update( double const Deltatime )
} }
else else
{ {
ActiveUniversal4 = false; Universal4Active = false;
// ggUniversal4Button.UpdateValue(0); // ggUniversal4Button.UpdateValue(0);
} }
} }
@@ -5889,18 +5924,23 @@ bool TTrain::Update( double const Deltatime )
ggHornButton.Update(); ggHornButton.Update();
ggHornLowButton.Update(); ggHornLowButton.Update();
ggHornHighButton.Update(); ggHornHighButton.Update();
/*
ggUniversal1Button.Update(); ggUniversal1Button.Update();
ggUniversal2Button.Update(); ggUniversal2Button.Update();
ggUniversal3Button.Update(); if( Universal4Active ) {
ggUniversal4Button.PermIncValue( dt );
}
ggUniversal4Button.Update();
*/
for( auto &universal : ggUniversals ) {
universal.Update();
}
// hunter-091012 // hunter-091012
ggInstrumentLightButton.Update();
ggCabLightButton.Update(); ggCabLightButton.Update();
ggCabLightDimButton.Update(); ggCabLightDimButton.Update();
ggBatteryButton.Update(); ggBatteryButton.Update();
//------ //------
if (ActiveUniversal4)
ggUniversal4Button.PermIncValue(dt);
ggUniversal4Button.Update();
#ifdef EU07_USE_OLD_COMMAND_SYSTEM #ifdef EU07_USE_OLD_COMMAND_SYSTEM
ggMainOffButton.UpdateValue(0); ggMainOffButton.UpdateValue(0);
ggMainOnButton.UpdateValue(0); ggMainOnButton.UpdateValue(0);
@@ -6460,7 +6500,9 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
DynamicObject DynamicObject
->mdModel; // McZapkie-170103: szukaj elementy kabiny w glownym modelu ->mdModel; // McZapkie-170103: szukaj elementy kabiny w glownym modelu
} }
ActiveUniversal4 = false; /*
Universal4Active = false;
*/
clear_cab_controls(); clear_cab_controls();
} }
if (nullptr == DynamicObject->mdKabina) if (nullptr == DynamicObject->mdKabina)
@@ -6706,14 +6748,19 @@ void TTrain::clear_cab_controls()
ggHornLowButton.Clear(); ggHornLowButton.Clear();
ggHornHighButton.Clear(); ggHornHighButton.Clear();
ggNextCurrentButton.Clear(); ggNextCurrentButton.Clear();
/*
ggUniversal1Button.Clear(); ggUniversal1Button.Clear();
ggUniversal2Button.Clear(); ggUniversal2Button.Clear();
ggUniversal3Button.Clear(); ggUniversal4Button.Clear();
*/
for( auto &universal : ggUniversals ) {
universal.Clear();
}
ggInstrumentLightButton.Clear();
// hunter-091012 // hunter-091012
ggCabLightButton.Clear(); ggCabLightButton.Clear();
ggCabLightDimButton.Clear(); ggCabLightDimButton.Clear();
//------- //-------
ggUniversal4Button.Clear();
ggFuseButton.Clear(); ggFuseButton.Clear();
ggConverterFuseButton.Clear(); ggConverterFuseButton.Clear();
ggStLinOffButton.Clear(); ggStLinOffButton.Clear();
@@ -6772,7 +6819,7 @@ void TTrain::clear_cab_controls()
btLampkaRadio.Clear(); btLampkaRadio.Clear();
btLampkaHamulecReczny.Clear(); btLampkaHamulecReczny.Clear();
btLampkaBlokadaDrzwi.Clear(); btLampkaBlokadaDrzwi.Clear();
btLampkaUniversal3.Clear(); btInstrumentLight.Clear();
btLampkaWentZaluzje.Clear(); btLampkaWentZaluzje.Clear();
btLampkaOgrzewanieSkladu.Clear(11); btLampkaOgrzewanieSkladu.Clear(11);
btLampkaSHP.Clear(0); btLampkaSHP.Clear(0);
@@ -6930,8 +6977,8 @@ void TTrain::set_cab_controls() {
if( true == bCabLightDim ) { if( true == bCabLightDim ) {
ggCabLightDimButton.PutValue( 1.0 ); ggCabLightDimButton.PutValue( 1.0 );
} }
if( true == LampkaUniversal3_st ) { if( true == InstrumentLightActive ) {
ggUniversal3Button.PutValue( 1.0 ); ggInstrumentLightButton.PutValue( 1.0 );
} }
// doors // doors
// NOTE: we're relying on the cab models to have switches reversed for the rear cab(?) // NOTE: we're relying on the cab models to have switches reversed for the rear cab(?)
@@ -7073,20 +7120,20 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
{ {
btLampkaWysRozr.Load(Parser, DynamicObject->mdKabina); btLampkaWysRozr.Load(Parser, DynamicObject->mdKabina);
} }
else if (Label == "i-universal3:") else if (Label == "i-instrumentlight:")
{ {
btLampkaUniversal3.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); btInstrumentLight.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel);
LampkaUniversal3_typ = 0; InstrumentLightType = 0;
} }
else if (Label == "i-universal3_M:") else if (Label == "i-instrumentlight_M:")
{ {
btLampkaUniversal3.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); btInstrumentLight.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel);
LampkaUniversal3_typ = 1; InstrumentLightType = 1;
} }
else if (Label == "i-universal3_C:") else if (Label == "i-instrumentlight_C:")
{ {
btLampkaUniversal3.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); btInstrumentLight.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel);
LampkaUniversal3_typ = 2; InstrumentLightType = 2;
} }
else if (Label == "i-vent_trim:") else if (Label == "i-vent_trim:")
{ {
@@ -7279,9 +7326,20 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
{ "signalling_sw:", ggSignallingButton }, { "signalling_sw:", ggSignallingButton },
{ "door_signalling_sw:", ggDoorSignallingButton }, { "door_signalling_sw:", ggDoorSignallingButton },
{ "nextcurrent_sw:", ggNextCurrentButton }, { "nextcurrent_sw:", ggNextCurrentButton },
{ "instrumentlight_sw:", ggInstrumentLightButton },
{ "cablight_sw:", ggCabLightButton }, { "cablight_sw:", ggCabLightButton },
{ "cablightdim_sw:", ggCabLightDimButton }, { "cablightdim_sw:", ggCabLightDimButton },
{ "battery_sw:", ggBatteryButton } { "battery_sw:", ggBatteryButton },
{ "universal0:", ggUniversals[ 0 ] },
{ "universal1:", ggUniversals[ 1 ] },
{ "universal2:", ggUniversals[ 2 ] },
{ "universal3:", ggUniversals[ 3 ] },
{ "universal4:", ggUniversals[ 4 ] },
{ "universal5:", ggUniversals[ 5 ] },
{ "universal6:", ggUniversals[ 6 ] },
{ "universal7:", ggUniversals[ 7 ] },
{ "universal8:", ggUniversals[ 8 ] },
{ "universal9:", ggUniversals[ 9 ] }
}; };
auto lookup = gauges.find( Label ); auto lookup = gauges.find( Label );
if( lookup != gauges.end() ) { if( lookup != gauges.end() ) {
@@ -7292,6 +7350,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
else if( Label == "mainctrlact:" ) { else if( Label == "mainctrlact:" ) {
ggMainCtrlAct.Load( Parser, DynamicObject->mdKabina, DynamicObject->mdModel ); ggMainCtrlAct.Load( Parser, DynamicObject->mdKabina, DynamicObject->mdModel );
} }
/*
else if (Label == "universal1:") else if (Label == "universal1:")
{ {
ggUniversal1Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); ggUniversal1Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel);
@@ -7302,12 +7361,13 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
} }
else if (Label == "universal3:") else if (Label == "universal3:")
{ {
ggUniversal3Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); ggInstrumentLightButton.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel);
} }
else if (Label == "universal4:") else if (Label == "universal4:")
{ {
ggUniversal4Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); ggUniversal4Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel);
} }
*/
// SEKCJA WSKAZNIKOW // SEKCJA WSKAZNIKOW
else if ((Label == "tachometer:") || (Label == "tachometerb:")) else if ((Label == "tachometer:") || (Label == "tachometerb:"))
{ {

14
Train.h
View File

@@ -73,7 +73,6 @@ class TTrain
{ {
public: public:
bool CabChange(int iDirection); bool CabChange(int iDirection);
bool ActiveUniversal4;
bool ShowNextCurrent; // pokaz przd w podlaczonej lokomotywie (ET41) bool ShowNextCurrent; // pokaz przd w podlaczonej lokomotywie (ET41)
bool InitializeCab(int NewCabNo, std::string const &asFileName); bool InitializeCab(int NewCabNo, std::string const &asFileName);
TTrain(); TTrain();
@@ -189,6 +188,7 @@ class TTrain
static void OnCommand_hornlowactivate( TTrain *Train, command_data const &Command ); static void OnCommand_hornlowactivate( TTrain *Train, command_data const &Command );
static void OnCommand_hornhighactivate( TTrain *Train, command_data const &Command ); static void OnCommand_hornhighactivate( TTrain *Train, command_data const &Command );
static void OnCommand_radiotoggle( TTrain *Train, command_data const &Command ); static void OnCommand_radiotoggle( TTrain *Train, command_data const &Command );
static void OnCommand_generictoggle( TTrain *Train, command_data const &Command );
// members // members
TDynamicObject *DynamicObject; // przestawia zmiana pojazdu [F5] TDynamicObject *DynamicObject; // przestawia zmiana pojazdu [F5]
@@ -277,12 +277,16 @@ public: // reszta może by?publiczna
TGauge ggHornLowButton; TGauge ggHornLowButton;
TGauge ggHornHighButton; TGauge ggHornHighButton;
TGauge ggNextCurrentButton; TGauge ggNextCurrentButton;
/*
// ABu 090305 - uniwersalne przyciski // ABu 090305 - uniwersalne przyciski
TGauge ggUniversal1Button; TGauge ggUniversal1Button;
TGauge ggUniversal2Button; TGauge ggUniversal2Button;
TGauge ggUniversal3Button;
TGauge ggUniversal4Button; TGauge ggUniversal4Button;
bool Universal4Active;
*/
std::array<TGauge, 10> ggUniversals; // NOTE: temporary arrangement until we have dynamically built control table
TGauge ggInstrumentLightButton;
TGauge ggCabLightButton; // hunter-091012: przelacznik oswietlania kabiny TGauge ggCabLightButton; // hunter-091012: przelacznik oswietlania kabiny
TGauge ggCabLightDimButton; // hunter-091012: przelacznik przyciemnienia TGauge ggCabLightDimButton; // hunter-091012: przelacznik przyciemnienia
TGauge ggBatteryButton; // Stele 161228 hebelek baterii TGauge ggBatteryButton; // Stele 161228 hebelek baterii
@@ -335,9 +339,9 @@ public: // reszta może by?publiczna
// TButton btLampkaUnknown; // TButton btLampkaUnknown;
TButton btLampkaOpory; TButton btLampkaOpory;
TButton btLampkaWysRozr; TButton btLampkaWysRozr;
TButton btLampkaUniversal3; TButton btInstrumentLight;
int LampkaUniversal3_typ; // ABu 030405 - swiecenie uzaleznione od: 0-nic, 1-obw.gl, 2-przetw. int InstrumentLightType; // ABu 030405 - swiecenie uzaleznione od: 0-nic, 1-obw.gl, 2-przetw.
bool LampkaUniversal3_st; bool InstrumentLightActive;
TButton btLampkaWentZaluzje; // ET22 TButton btLampkaWentZaluzje; // ET22
TButton btLampkaOgrzewanieSkladu; TButton btLampkaOgrzewanieSkladu;
TButton btLampkaSHP; TButton btLampkaSHP;

View File

@@ -30,6 +30,7 @@ http://mozilla.org/MPL/2.0/.
#include "Console.h" #include "Console.h"
#include "color.h" #include "color.h"
#include "uilayer.h" #include "uilayer.h"
#include "translation.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -180,20 +181,6 @@ simulation_time::julian_day() const {
return JD; return JD;
} }
namespace locale {
std::string
control( std::string const &Label ) {
auto const lookup = m_controls.find( Label );
return (
lookup != m_controls.end() ?
lookup->second :
"" );
}
}
TWorld::TWorld() TWorld::TWorld()
{ {
// randomize(); // randomize();
@@ -717,8 +704,8 @@ void TWorld::OnKeyDown(int cKey)
Global::iTextMode = GLFW_KEY_F1; // to wyświetlić zegar i informację Global::iTextMode = GLFW_KEY_F1; // to wyświetlić zegar i informację
} }
} }
else if( ( cKey == GLFW_KEY_PAUSE ) && ( Global::ctrlState ) ) { else if( ( cKey == GLFW_KEY_PAUSE ) && ( Global::ctrlState ) && ( Global::shiftState ) ) {
//[Ctrl]+[Break] hamowanie wszystkich pojazdów w okolicy //[Ctrl]+[Break] hamowanie wszystkich pojazdów w okolicy // added shift to prevent odd issue with glfw producing pause presses on its own
if (Controlled->MoverParameters->Radio) if (Controlled->MoverParameters->Radio)
Ground.RadioStop(Camera.Pos); Ground.RadioStop(Camera.Pos);
} }
@@ -1288,7 +1275,7 @@ TWorld::Update_UI() {
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
UILayer.set_tooltip( locale::control( Train->GetLabel( GfxRenderer.Pick_Control() ) ) ); UILayer.set_tooltip( locale::label_cab_control( Train->GetLabel( GfxRenderer.Pick_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

68
World.h
View File

@@ -60,74 +60,6 @@ extern simulation_time Time;
} }
namespace locale {
std::string
control( std::string const &Label );
static std::unordered_map<std::string, std::string> m_controls = {
{ "mainctrl:", "master controller" },
{ "scndctrl:", "second controller" },
{ "dirkey:" , "reverser" },
{ "brakectrl:", "train brake" },
{ "localbrake:", "independent brake" },
{ "manualbrake:", "manual brake" },
{ "brakeprofile_sw:", "brake acting speed" },
{ "brakeprofileg_sw:", "brake acting speed: cargo" },
{ "brakeprofiler_sw:", "brake acting speed: rapid" },
{ "maxcurrent_sw:", "motor overload relay threshold" },
{ "main_off_bt:", "line breaker" },
{ "main_on_bt:", "line breaker" },
{ "security_reset_bt:", "alerter" },
{ "releaser_bt:", "independent brake releaser" },
{ "sand_bt:", "sandbox" },
{ "antislip_bt:", "wheelspin brake" },
{ "horn_bt:", "horn" },
{ "hornlow_bt:", "low tone horn" },
{ "hornhigh_bt:", "high tone horn" },
{ "fuse_bt:", "motor overload relay reset" },
{ "converterfuse_bt:", "converter overload relay reset" },
{ "stlinoff_bt:", "motor connectors" },
{ "door_left_sw:", "left door" },
{ "door_right_sw:", "right door" },
{ "departure_signal_bt:", "departure signal" },
{ "upperlight_sw:", "upper headlight" },
{ "leftlight_sw:", "left headlight" },
{ "rightlight_sw:", "right headlight" },
{ "dimheadlights_sw:", "headlights dimmer" },
{ "leftend_sw:", "left marker light" },
{ "rightend_sw:", "right marker light" },
{ "lights_sw:", "light pattern" },
{ "rearupperlight_sw:", "rear upper headlight" },
{ "rearleftlight_sw:", "rear left headlight" },
{ "rearrightlight_sw:", "rear right headlight" },
{ "rearleftend_sw:", "rear left marker light" },
{ "rearrightend_sw:", "rear right marker light" },
{ "compressor_sw:", "compressor" },
{ "compressorlocal_sw:", "local compressor" },
{ "converter_sw:", "converter" },
{ "converterlocal_sw:", "local converter" },
{ "converteroff_sw:", "converter" },
{ "main_sw:", "line breaker" },
{ "radio_sw:", "radio" },
{ "pantfront_sw:", "front pantograph" },
{ "pantrear_sw:", "rear pantograph" },
{ "pantfrontoff_sw:", "front pantograph" },
{ "pantrearoff_sw:", "rear pantograph" },
{ "pantalloff_sw:", "all pantographs" },
{ "pantselected_sw:", "selected pantograph" },
{ "pantselectedoff_sw:", "selected pantograph" },
{ "trainheating_sw:", "heating" },
{ "signalling_sw:", "braking indicator" },
{ "door_signalling_sw:", "door locking" },
{ "nextcurrent_sw:", "current indicator source" },
{ "cablight_sw:", "interior light" },
{ "cablightdim_sw:", "interior light dimmer" },
{ "battery_sw:", "battery" }
};
}
// wrapper for environment elements -- sky, sun, stars, clouds etc // wrapper for environment elements -- sky, sun, stars, clouds etc
class world_environment { class world_environment {

View File

@@ -125,6 +125,16 @@ const int k_Univ4 = 69;
const int k_EndSign = 70; const int k_EndSign = 70;
const int k_Active = 71; const int k_Active = 71;
*/ */
{ "generictoggle0", command_target::vehicle },
{ "generictoggle1", command_target::vehicle },
{ "generictoggle2", command_target::vehicle },
{ "generictoggle3", command_target::vehicle },
{ "generictoggle4", command_target::vehicle },
{ "generictoggle5", command_target::vehicle },
{ "generictoggle6", command_target::vehicle },
{ "generictoggle7", command_target::vehicle },
{ "generictoggle8", command_target::vehicle },
{ "generictoggle9", command_target::vehicle },
{ "batterytoggle", command_target::vehicle } { "batterytoggle", command_target::vehicle }
/* /*
const int k_WalkMode = 73; const int k_WalkMode = 73;

View File

@@ -120,6 +120,16 @@ const int k_Univ4 = 69;
const int k_EndSign = 70; const int k_EndSign = 70;
const int k_Active = 71; const int k_Active = 71;
*/ */
generictoggle0,
generictoggle1,
generictoggle2,
generictoggle3,
generictoggle4,
generictoggle5,
generictoggle6,
generictoggle7,
generictoggle8,
generictoggle9,
batterytoggle, batterytoggle,
/* /*
const int k_WalkMode = 73; const int k_WalkMode = 73;
@@ -149,8 +159,6 @@ struct command_description {
command_target target; command_target target;
}; };
typedef std::vector<command_description> commanddescription_sequence;
struct command_data { struct command_data {
user_command command; user_command command;
@@ -188,6 +196,8 @@ private:
// but realistically it's not like we're going to run more than one simulation at a time // but realistically it's not like we're going to run more than one simulation at a time
namespace simulation { namespace simulation {
typedef std::vector<command_description> commanddescription_sequence;
extern command_queue Commands; extern command_queue Commands;
// TODO: add name to command map, and wrap these two into helper object // TODO: add name to command map, and wrap these two into helper object
extern commanddescription_sequence Commands_descriptions; extern commanddescription_sequence Commands_descriptions;

View File

@@ -28,6 +28,8 @@ keyboard_input::recall_bindings() {
++commandid; ++commandid;
} }
std::unordered_map<std::string, int> nametokeymap = { std::unordered_map<std::string, int> nametokeymap = {
{ "0", GLFW_KEY_0 }, { "1", GLFW_KEY_1 }, { "2", GLFW_KEY_2 }, { "3", GLFW_KEY_3 }, { "4", GLFW_KEY_4 },
{ "5", GLFW_KEY_5 }, { "6", GLFW_KEY_6 }, { "7", GLFW_KEY_7 }, { "8", GLFW_KEY_8 }, { "9", GLFW_KEY_9 },
{ "a", GLFW_KEY_A }, { "b", GLFW_KEY_B }, { "c", GLFW_KEY_C }, { "d", GLFW_KEY_D }, { "e", GLFW_KEY_E }, { "a", GLFW_KEY_A }, { "b", GLFW_KEY_B }, { "c", GLFW_KEY_C }, { "d", GLFW_KEY_D }, { "e", GLFW_KEY_E },
{ "f", GLFW_KEY_F }, { "g", GLFW_KEY_G }, { "h", GLFW_KEY_H }, { "i", GLFW_KEY_I }, { "j", GLFW_KEY_J }, { "f", GLFW_KEY_F }, { "g", GLFW_KEY_G }, { "h", GLFW_KEY_H }, { "i", GLFW_KEY_I }, { "j", GLFW_KEY_J },
{ "k", GLFW_KEY_K }, { "l", GLFW_KEY_L }, { "m", GLFW_KEY_M }, { "n", GLFW_KEY_N }, { "o", GLFW_KEY_O }, { "k", GLFW_KEY_K }, { "l", GLFW_KEY_L }, { "m", GLFW_KEY_M }, { "n", GLFW_KEY_N }, { "o", GLFW_KEY_O },
@@ -348,6 +350,26 @@ const int k_Univ4 = 69;
const int k_EndSign = 70; const int k_EndSign = 70;
const int k_Active = 71; const int k_Active = 71;
*/ */
// "generictoggle0"
{ GLFW_KEY_0 },
// "generictoggle1"
{ GLFW_KEY_1 },
// "generictoggle2"
{ GLFW_KEY_2 },
// "generictoggle3"
{ GLFW_KEY_3 },
// "generictoggle4"
{ GLFW_KEY_4 },
// "generictoggle5"
{ GLFW_KEY_5 },
// "generictoggle6"
{ GLFW_KEY_6 },
// "generictoggle7"
{ GLFW_KEY_7 },
// "generictoggle8"
{ GLFW_KEY_8 },
// "generictoggle9"
{ GLFW_KEY_9 },
// "batterytoggle" // "batterytoggle"
{ GLFW_KEY_J } { GLFW_KEY_J }
/* /*

View File

@@ -228,6 +228,9 @@
<ClCompile Include="mouseinput.cpp"> <ClCompile Include="mouseinput.cpp">
<Filter>Source Files\input</Filter> <Filter>Source Files\input</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="translation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Globals.h"> <ClInclude Include="Globals.h">
@@ -446,6 +449,9 @@
<ClInclude Include="mouseinput.h"> <ClInclude Include="mouseinput.h">
<Filter>Header Files\input</Filter> <Filter>Header Files\input</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="translation.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="maszyna.rc"> <ResourceCompile Include="maszyna.rc">

View File

@@ -9,6 +9,7 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h" #include "stdafx.h"
#include "mouseinput.h" #include "mouseinput.h"
#include "usefull.h"
#include "globals.h" #include "globals.h"
#include "timer.h" #include "timer.h"
#include "world.h" #include "world.h"
@@ -17,6 +18,17 @@ http://mozilla.org/MPL/2.0/.
extern TWorld World; extern TWorld World;
bool
mouse_input::init() {
#ifdef _WINDOWS
DWORD systemkeyboardspeed;
::SystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &systemkeyboardspeed, 0 );
m_updaterate = interpolate( 0.5, 0.04, systemkeyboardspeed / 31.0 );
#endif
return true;
}
void void
mouse_input::move( double Mousex, double Mousey ) { mouse_input::move( double Mousex, double Mousey ) {
@@ -76,11 +88,13 @@ mouse_input::button( int const Button, int const Action ) {
mousecommand = user_command::none; mousecommand = user_command::none;
} }
else { else {
// if it's the right mouse button that got released, stop view panning // if it's the right mouse button that got released and we had no command active, we were potentially in view panning mode; stop it
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) { if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
m_pickmodepanning = false; m_pickmodepanning = false;
} }
} }
// if we were in varying command repeat rate, we can stop that now. done without any conditions, to catch some unforeseen edge cases
m_varyingpollrate = false;
} }
else { else {
// if not release then it's press // if not release then it's press
@@ -114,6 +128,25 @@ mouse_input::button( int const Button, int const Action ) {
if( mousecommand == user_command::mastercontrollerincrease ) { if( mousecommand == user_command::mastercontrollerincrease ) {
m_updateaccumulator -= 0.15; // extra pause on first increase of master controller m_updateaccumulator -= 0.15; // extra pause on first increase of master controller
} }
switch( mousecommand ) {
case user_command::mastercontrollerincrease:
case user_command::mastercontrollerdecrease:
case user_command::secondcontrollerincrease:
case user_command::secondcontrollerdecrease:
case user_command::trainbrakeincrease:
case user_command::trainbrakedecrease:
case user_command::independentbrakeincrease:
case user_command::independentbrakedecrease: {
// these commands trigger varying repeat rate mode,
// which scales the rate based on the distance of the cursor from its point when the command was first issued
m_commandstartcursor = m_cursorposition;
m_varyingpollrate = true;
break;
}
default: {
break;
}
}
} }
} }
else { else {
@@ -131,11 +164,16 @@ mouse_input::poll() {
m_updateaccumulator += Timer::GetDeltaRenderTime(); m_updateaccumulator += Timer::GetDeltaRenderTime();
if( m_updateaccumulator < 0.1 ) { auto updaterate { m_updaterate };
if( m_varyingpollrate ) {
updaterate /= std::max( 0.15, 2.0 * glm::length( m_cursorposition - m_commandstartcursor ) / std::max( 1, Global::ScreenHeight ) );
}
if( m_updateaccumulator < updaterate ) {
// too early for any work // too early for any work
return; return;
} }
m_updateaccumulator -= 0.1; m_updateaccumulator -= updaterate;
if( m_mousecommandleft != user_command::none ) { if( m_mousecommandleft != user_command::none ) {
// NOTE: basic keyboard controls don't have any parameters // NOTE: basic keyboard controls don't have any parameters
@@ -320,6 +358,9 @@ mouse_input::default_bindings() {
{ "nextcurrent_sw:", { { "nextcurrent_sw:", {
user_command::mucurrentindicatorothersourceactivate, user_command::mucurrentindicatorothersourceactivate,
user_command::none } }, user_command::none } },
{ "instrumentlight_sw:", {
user_command::instrumentlighttoggle,
user_command::none } },
{ "cablight_sw:", { { "cablight_sw:", {
user_command::interiorlighttoggle, user_command::interiorlighttoggle,
user_command::none } }, user_command::none } },
@@ -328,6 +369,36 @@ mouse_input::default_bindings() {
user_command::none } }, user_command::none } },
{ "battery_sw:", { { "battery_sw:", {
user_command::batterytoggle, user_command::batterytoggle,
user_command::none } },
{ "universal0:", {
user_command::generictoggle0,
user_command::none } },
{ "universal1:", {
user_command::generictoggle1,
user_command::none } },
{ "universal2:", {
user_command::generictoggle2,
user_command::none } },
{ "universal3:", {
user_command::generictoggle3,
user_command::none } },
{ "universal4:", {
user_command::generictoggle4,
user_command::none } },
{ "universal5:", {
user_command::generictoggle5,
user_command::none } },
{ "universal6:", {
user_command::generictoggle6,
user_command::none } },
{ "universal7:", {
user_command::generictoggle7,
user_command::none } },
{ "universal8:", {
user_command::generictoggle8,
user_command::none } },
{ "universal9:", {
user_command::generictoggle9,
user_command::none } } user_command::none } }
}; };
} }

View File

@@ -10,7 +10,6 @@ http://mozilla.org/MPL/2.0/.
#pragma once #pragma once
#include <unordered_map> #include <unordered_map>
#include <array>
#include "command.h" #include "command.h"
class mouse_input { class mouse_input {
@@ -21,7 +20,7 @@ public:
// methods // methods
bool bool
init() { return true; } init();
void void
move( double const Mousex, double const Mousey ); move( double const Mousex, double const Mousey );
void void
@@ -48,13 +47,16 @@ private:
default_bindings(); default_bindings();
// members // members
command_relay m_relay;
controlcommands_map m_mousecommands; controlcommands_map m_mousecommands;
user_command m_mousecommandleft { user_command::none }; // last if any command issued with left mouse button user_command m_mousecommandleft { user_command::none }; // last if any command issued with left mouse button
user_command m_mousecommandright { user_command::none }; // last if any command issued with right mouse button user_command m_mousecommandright { user_command::none }; // last if any command issued with right mouse button
command_relay m_relay; double m_updaterate { 0.075 };
double m_updateaccumulator { 0.0 }; double m_updateaccumulator { 0.0 };
bool m_pickmodepanning { false }; // indicates mouse is in view panning mode bool m_pickmodepanning { false }; // indicates mouse is in view panning mode
glm::dvec2 m_cursorposition; // stored last mouse position, used for panning glm::dvec2 m_cursorposition; // stored last cursor position, used for panning
glm::dvec2 m_commandstartcursor; // helper, cursor position when the command was initiated
bool m_varyingpollrate { false }; // indicates rate of command repeats is affected by the cursor position
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -39,6 +39,7 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <array>
#include <vector> #include <vector>
#include <deque> #include <deque>
#include <list> #include <list>

31
translation.cpp Normal file
View File

@@ -0,0 +1,31 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
/*
MaSzyna EU07 locomotive simulator
Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
*/
#include "stdafx.h"
#include "translation.h"
namespace locale {
std::string
label_cab_control( std::string const &Label ) {
auto const lookup = m_cabcontrols.find( Label );
return (
lookup != m_cabcontrols.end() ?
lookup->second :
"" );
}
} // namespace locale
//---------------------------------------------------------------------------

95
translation.h Normal file
View File

@@ -0,0 +1,95 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <string>
#include <unordered_map>
namespace locale {
std::string
label_cab_control( std::string const &Label );
static std::unordered_map<std::string, std::string> m_cabcontrols = {
{ "mainctrl:", "master controller" },
{ "scndctrl:", "second controller" },
{ "dirkey:" , "reverser" },
{ "brakectrl:", "train brake" },
{ "localbrake:", "independent brake" },
{ "manualbrake:", "manual brake" },
{ "brakeprofile_sw:", "brake acting speed" },
{ "brakeprofileg_sw:", "brake acting speed: cargo" },
{ "brakeprofiler_sw:", "brake acting speed: rapid" },
{ "maxcurrent_sw:", "motor overload relay threshold" },
{ "main_off_bt:", "line breaker" },
{ "main_on_bt:", "line breaker" },
{ "security_reset_bt:", "alerter" },
{ "releaser_bt:", "independent brake releaser" },
{ "sand_bt:", "sandbox" },
{ "antislip_bt:", "wheelspin brake" },
{ "horn_bt:", "horn" },
{ "hornlow_bt:", "low tone horn" },
{ "hornhigh_bt:", "high tone horn" },
{ "fuse_bt:", "motor overload relay reset" },
{ "converterfuse_bt:", "converter overload relay reset" },
{ "stlinoff_bt:", "motor connectors" },
{ "door_left_sw:", "left door" },
{ "door_right_sw:", "right door" },
{ "departure_signal_bt:", "departure signal" },
{ "upperlight_sw:", "upper headlight" },
{ "leftlight_sw:", "left headlight" },
{ "rightlight_sw:", "right headlight" },
{ "dimheadlights_sw:", "headlights dimmer" },
{ "leftend_sw:", "left marker light" },
{ "rightend_sw:", "right marker light" },
{ "lights_sw:", "light pattern" },
{ "rearupperlight_sw:", "rear upper headlight" },
{ "rearleftlight_sw:", "rear left headlight" },
{ "rearrightlight_sw:", "rear right headlight" },
{ "rearleftend_sw:", "rear left marker light" },
{ "rearrightend_sw:", "rear right marker light" },
{ "compressor_sw:", "compressor" },
{ "compressorlocal_sw:", "local compressor" },
{ "converter_sw:", "converter" },
{ "converterlocal_sw:", "local converter" },
{ "converteroff_sw:", "converter" },
{ "main_sw:", "line breaker" },
{ "radio_sw:", "radio" },
{ "pantfront_sw:", "front pantograph" },
{ "pantrear_sw:", "rear pantograph" },
{ "pantfrontoff_sw:", "front pantograph" },
{ "pantrearoff_sw:", "rear pantograph" },
{ "pantalloff_sw:", "all pantographs" },
{ "pantselected_sw:", "selected pantograph" },
{ "pantselectedoff_sw:", "selected pantograph" },
{ "trainheating_sw:", "heating" },
{ "signalling_sw:", "braking indicator" },
{ "door_signalling_sw:", "door locking" },
{ "nextcurrent_sw:", "current indicator source" },
{ "instrumentlight_sw:", "instrument light" },
{ "cablight_sw:", "interior light" },
{ "cablightdim_sw:", "interior light dimmer" },
{ "battery_sw:", "battery" },
{ "universal0:", "generic" },
{ "universal1:", "generic" },
{ "universal2:", "generic" },
{ "universal3:", "generic" },
{ "universal4:", "generic" },
{ "universal5:", "generic" },
{ "universal6:", "generic" },
{ "universal7:", "generic" },
{ "universal8:", "generic" },
{ "universal9:", "generic" }
};
}
//---------------------------------------------------------------------------

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 17 #define VERSION_MAJOR 17
#define VERSION_MINOR 710 #define VERSION_MINOR 712
#define VERSION_REVISION 0 #define VERSION_REVISION 0