mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 07:39:19 +02:00
simulation time object
This commit is contained in:
348
World.cpp
348
World.cpp
@@ -39,11 +39,125 @@ std::shared_ptr<ui_panel> UIHeader = std::make_shared<ui_panel>( 20, 20 ); // he
|
||||
std::shared_ptr<ui_panel> UITable = std::make_shared<ui_panel>( 20, 100 ); // schedule or scan table
|
||||
std::shared_ptr<ui_panel> UITranscripts = std::make_shared<ui_panel>( 85, 600 ); // voice transcripts
|
||||
|
||||
namespace Simulation {
|
||||
|
||||
simulation_time Time;
|
||||
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window ); //m7todo: potrzebne do directsound
|
||||
}
|
||||
|
||||
void
|
||||
simulation_time::init() {
|
||||
|
||||
char monthdaycounts[ 2 ][ 13 ] = {
|
||||
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
|
||||
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } };
|
||||
::memcpy( m_monthdaycounts, monthdaycounts, sizeof( monthdaycounts ) );
|
||||
|
||||
// cache requested elements, if any
|
||||
auto const requestedhour = m_time.wHour;
|
||||
auto const requestedminute = m_time.wMinute;
|
||||
|
||||
::GetLocalTime( &m_time );
|
||||
|
||||
if( Global::fMoveLight > 0.0 ) {
|
||||
// day and month of the year can be overriden by scenario setup
|
||||
daymonth( m_time.wDay, m_time.wMonth, m_time.wYear, static_cast<WORD>( Global::fMoveLight ) );
|
||||
}
|
||||
|
||||
if( requestedhour != -1 ) { m_time.wHour = clamp( requestedhour, static_cast<WORD>( 0 ), static_cast<WORD>( 23 ) ); }
|
||||
if( requestedminute != -1 ) { m_time.wMinute = clamp( requestedminute, static_cast<WORD>( 0 ), static_cast<WORD>( 59 ) ); }
|
||||
// if the time is taken from the local clock leave the seconds intact, otherwise set them to zero
|
||||
if( ( requestedhour != -1 ) || ( requestedminute != -1 ) ) {
|
||||
m_time.wSecond = 0;
|
||||
}
|
||||
|
||||
m_yearday = yearday( m_time.wDay, m_time.wMonth, m_time.wYear );
|
||||
}
|
||||
|
||||
void
|
||||
simulation_time::update( double const Deltatime ) {
|
||||
|
||||
// use large enough buffer to hold long time skips
|
||||
auto milliseconds = m_time.wMilliseconds + static_cast<size_t>(std::floor( 1000.0 * Deltatime ));
|
||||
while( milliseconds >= 1000.0 ) {
|
||||
|
||||
++m_time.wSecond;
|
||||
milliseconds -= 1000;
|
||||
}
|
||||
m_time.wMilliseconds = milliseconds;
|
||||
while( m_time.wSecond >= 60 ) {
|
||||
|
||||
++m_time.wMinute;
|
||||
m_time.wSecond -= 60;
|
||||
}
|
||||
while( m_time.wMinute >= 60 ) {
|
||||
|
||||
++m_time.wHour;
|
||||
m_time.wMinute -= 60;
|
||||
}
|
||||
while( m_time.wHour >= 24 ) {
|
||||
|
||||
++m_time.wDay;
|
||||
++m_time.wDayOfWeek;
|
||||
if( m_time.wDayOfWeek >= 7 ) {
|
||||
m_time.wDayOfWeek -= 7;
|
||||
}
|
||||
m_time.wHour -= 24;
|
||||
}
|
||||
int leap = ( m_time.wYear % 4 == 0 ) && ( m_time.wYear % 100 != 0 ) || ( m_time.wYear % 400 == 0 );
|
||||
while( m_time.wDay > m_monthdaycounts[ leap ][ m_time.wMonth ] ) {
|
||||
|
||||
m_time.wDay -= m_monthdaycounts[ leap ][ m_time.wMonth ];
|
||||
++m_time.wMonth;
|
||||
// unlikely but we might've entered a new year
|
||||
if( m_time.wMonth > 12 ) {
|
||||
|
||||
++m_time.wYear;
|
||||
leap = ( m_time.wYear % 4 == 0 ) && ( m_time.wYear % 100 != 0 ) || ( m_time.wYear % 400 == 0 );
|
||||
m_time.wMonth -= 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
simulation_time::yearday( int Day, const int Month, const int Year ) {
|
||||
|
||||
char daytab[ 2 ][ 13 ] = {
|
||||
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
|
||||
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
|
||||
};
|
||||
int i, leap;
|
||||
|
||||
leap = ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 );
|
||||
for( i = 1; i < Month; ++i )
|
||||
Day += daytab[ leap ][ i ];
|
||||
|
||||
return Day;
|
||||
}
|
||||
|
||||
void
|
||||
simulation_time::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yearday ) {
|
||||
|
||||
WORD daytab[ 2 ][ 13 ] = {
|
||||
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
|
||||
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
|
||||
};
|
||||
|
||||
int leap = ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 );
|
||||
WORD idx = 1;
|
||||
while( ( idx < 13 ) && ( Yearday >= daytab[ leap ][ idx ] ) ) {
|
||||
|
||||
++idx;
|
||||
}
|
||||
Month = idx;
|
||||
Day = Yearday - daytab[ leap ][ idx - 1 ];
|
||||
}
|
||||
|
||||
TWorld::TWorld()
|
||||
{
|
||||
// randomize();
|
||||
@@ -54,9 +168,6 @@ TWorld::TWorld()
|
||||
KeyEvents[i] = NULL; // eventy wyzwalane klawiszami cyfrowymi
|
||||
Global::iSlowMotion = 0;
|
||||
// Global::changeDynObj=NULL;
|
||||
OutText1 = ""; // teksty wyświetlane na ekranie
|
||||
OutText2 = "";
|
||||
OutText3 = "";
|
||||
pDynamicNearest = NULL;
|
||||
fTimeBuffer = 0.0; // bufor czasu aktualizacji dla stałego kroku fizyki
|
||||
fMaxDt = 0.01; //[s] początkowy krok czasowy fizyki
|
||||
@@ -176,6 +287,8 @@ bool TWorld::Init( GLFWwindow *Window ) {
|
||||
|
||||
glfwSetWindowTitle( window, ( Global::AppName + " (" + Global::SceneryFile + ")" ).c_str() ); // nazwa scenerii
|
||||
|
||||
Simulation::Time.init();
|
||||
|
||||
Environment.init();
|
||||
Camera.Init(Global::FreeCameraInit[0], Global::FreeCameraInitAngle[0]);
|
||||
|
||||
@@ -324,11 +437,11 @@ void TWorld::OnKeyDown(int cKey)
|
||||
// additional time speedup keys in debug mode
|
||||
if( Global::ctrlState ) {
|
||||
// ctrl-f3
|
||||
GlobalTime->UpdateMTableTime( 20.0 * 60.0 );
|
||||
Simulation::Time.update( 20.0 * 60.0 );
|
||||
}
|
||||
else if( Global::shiftState ) {
|
||||
// shift-f3
|
||||
GlobalTime->UpdateMTableTime( 5.0 * 60.0 );
|
||||
Simulation::Time.update( 5.0 * 60.0 );
|
||||
}
|
||||
}
|
||||
if( ( false == Global::ctrlState )
|
||||
@@ -762,20 +875,19 @@ bool TWorld::Update()
|
||||
if( (Global::iPause == false)
|
||||
|| (m_init == false) )
|
||||
{ // jak pauza, to nie ma po co tego przeliczać
|
||||
GlobalTime->UpdateMTableTime(Timer::GetDeltaTime()); // McZapkie-300302: czas rozkladowy
|
||||
// Ra 2014-07: przeliczenie kąta czasu (do animacji zależnych od czasu)
|
||||
Global::fTimeAngleDeg =
|
||||
GlobalTime->hh * 15.0 + GlobalTime->mm * 0.25 + GlobalTime->mr / 240.0;
|
||||
Global::fClockAngleDeg[0] = 36.0 * (int(GlobalTime->mr) % 10); // jednostki sekund
|
||||
Global::fClockAngleDeg[1] = 36.0 * (int(GlobalTime->mr) / 10); // dziesiątki sekund
|
||||
Global::fClockAngleDeg[2] = 36.0 * (GlobalTime->mm % 10); // jednostki minut
|
||||
Global::fClockAngleDeg[3] = 36.0 * (GlobalTime->mm / 10); // dziesiątki minut
|
||||
Global::fClockAngleDeg[4] = 36.0 * (GlobalTime->hh % 10); // jednostki godzin
|
||||
Global::fClockAngleDeg[5] = 36.0 * (GlobalTime->hh / 10); // dziesiątki godzin
|
||||
Simulation::Time.update( Timer::GetDeltaTime() );
|
||||
auto const &time = Simulation::Time.data();
|
||||
Global::fTimeAngleDeg = time.wHour * 15.0 + time.wMinute * 0.25 + ( ( time.wSecond + 0.001 * time.wMilliseconds ) / 240.0 );
|
||||
Global::fClockAngleDeg[ 0 ] = 36.0 * ( time.wSecond % 10 ); // jednostki sekund
|
||||
Global::fClockAngleDeg[ 1 ] = 36.0 * ( time.wSecond / 10 ); // dziesiątki sekund
|
||||
Global::fClockAngleDeg[ 2 ] = 36.0 * ( time.wMinute % 10 ); // jednostki minut
|
||||
Global::fClockAngleDeg[ 3 ] = 36.0 * ( time.wMinute / 10 ); // dziesiątki minut
|
||||
Global::fClockAngleDeg[ 4 ] = 36.0 * ( time.wHour % 10 ); // jednostki godzin
|
||||
Global::fClockAngleDeg[ 5 ] = 36.0 * ( time.wHour / 10 ); // dziesiątki godzin
|
||||
|
||||
Update_Environment();
|
||||
} // koniec działań niewykonywanych podczas pauzy
|
||||
// poprzednie jakoś tam działało
|
||||
|
||||
// fixed step, simulation time based updates
|
||||
|
||||
@@ -1424,20 +1536,21 @@ TWorld::Render_Cab() {
|
||||
void
|
||||
TWorld::Update_UI() {
|
||||
|
||||
OutText1 = OutText2 = OutText3 = OutText4 = "";
|
||||
UITable->text_lines.clear();
|
||||
std::string uitextline1, uitextline2, uitextline3, uitextline4;
|
||||
|
||||
switch( Global::iTextMode ) {
|
||||
|
||||
case( GLFW_KEY_F1 ) : {
|
||||
// f1, default mode: current time and timetable excerpt
|
||||
OutText1 =
|
||||
auto const &time = Simulation::Time.data();
|
||||
uitextline1 =
|
||||
"Time: "
|
||||
+ to_string( (int)GlobalTime->hh ) + ":"
|
||||
+ ( GlobalTime->mm < 10 ? "0" : "" ) + to_string( GlobalTime->mm ) + ":"
|
||||
+ ( GlobalTime->mr < 10 ? "0" : "" ) + to_string( std::floor( GlobalTime->mr ) );
|
||||
+ to_string( time.wHour ) + ":"
|
||||
+ ( time.wMinute < 10 ? "0" : "" ) + to_string( time.wMinute ) + ":"
|
||||
+ ( time.wSecond < 10 ? "0" : "" ) + to_string( time.wSecond );
|
||||
if( Global::iPause ) {
|
||||
OutText1 += " (paused)";
|
||||
uitextline1 += " (paused)";
|
||||
}
|
||||
|
||||
if( Controlled && ( Controlled->Mechanik != nullptr ) ) {
|
||||
@@ -1445,21 +1558,21 @@ TWorld::Update_UI() {
|
||||
auto const &mover = Controlled->MoverParameters;
|
||||
auto const &driver = Controlled->Mechanik;
|
||||
|
||||
OutText2 = "Throttle: " + to_string( driver->Controlling()->MainCtrlPos, 0, 2 ) + "+" + std::to_string( driver->Controlling()->ScndCtrlPos );
|
||||
if( mover->ActiveDir > 0 ) { OutText2 += " D"; }
|
||||
else if( mover->ActiveDir < 0 ) { OutText2 += " R"; }
|
||||
else { OutText2 += " N"; }
|
||||
uitextline2 = "Throttle: " + to_string( driver->Controlling()->MainCtrlPos, 0, 2 ) + "+" + std::to_string( driver->Controlling()->ScndCtrlPos );
|
||||
if( mover->ActiveDir > 0 ) { uitextline2 += " D"; }
|
||||
else if( mover->ActiveDir < 0 ) { uitextline2 += " R"; }
|
||||
else { uitextline2 += " N"; }
|
||||
|
||||
OutText3 = "Brakes:" + to_string( mover->fBrakeCtrlPos, 1, 5 ) + "+" + std::to_string( mover->LocalBrakePos );
|
||||
uitextline3 = "Brakes:" + to_string( mover->fBrakeCtrlPos, 1, 5 ) + "+" + std::to_string( mover->LocalBrakePos );
|
||||
|
||||
if( Global::iScreenMode[ Global::iTextMode - GLFW_KEY_F1 ] == 1 ) {
|
||||
// detail mode on second key press
|
||||
OutText2 +=
|
||||
uitextline2 +=
|
||||
" Speed: " + std::to_string( static_cast<int>( std::floor( mover->Vel ) ) ) + " km/h"
|
||||
+ " (limit: " + std::to_string( static_cast<int>( std::floor( driver->VelDesired ) ) ) + " km/h"
|
||||
+ ", next limit: " + std::to_string( static_cast<int>( std::floor( Controlled->Mechanik->VelNext ) ) ) + " km/h"
|
||||
+ " in " + to_string( Controlled->Mechanik->ActualProximityDist * 0.001, 1 ) + " km)";
|
||||
OutText3 +=
|
||||
uitextline3 +=
|
||||
" Pressure: " + to_string( mover->BrakePress * 100.0, 2 ) + " kPa"
|
||||
+ " (train pipe: " + to_string( mover->PipePress * 100.0, 2 ) + " kPa)";
|
||||
}
|
||||
@@ -1481,21 +1594,22 @@ TWorld::Update_UI() {
|
||||
auto const table = tmp->Mechanik->Timetable();
|
||||
if( table == nullptr ) { break; }
|
||||
|
||||
OutText1 =
|
||||
auto const &time = Simulation::Time.data();
|
||||
uitextline1 =
|
||||
"Time: "
|
||||
+ to_string( (int)GlobalTime->hh ) + ":"
|
||||
+ ( GlobalTime->mm < 10 ? "0" : "" ) + to_string( GlobalTime->mm ) + ":"
|
||||
+ ( GlobalTime->mr < 10 ? "0" : "" ) + to_string( std::floor( GlobalTime->mr ) );
|
||||
+ to_string( time.wHour ) + ":"
|
||||
+ ( time.wMinute < 10 ? "0" : "" ) + to_string( time.wMinute ) + ":"
|
||||
+ ( time.wSecond < 10 ? "0" : "" ) + to_string( time.wSecond );
|
||||
if( Global::iPause ) {
|
||||
OutText1 += " (paused)";
|
||||
uitextline1 += " (paused)";
|
||||
}
|
||||
|
||||
if( Controlled
|
||||
&& Controlled->Mechanik ) {
|
||||
OutText2 = Global::Bezogonkow( Controlled->Mechanik->Relation(), true ) + " (" + tmp->Mechanik->Timetable()->TrainName + ")";
|
||||
if( !OutText2.empty() ) {
|
||||
uitextline2 = Global::Bezogonkow( Controlled->Mechanik->Relation(), true ) + " (" + tmp->Mechanik->Timetable()->TrainName + ")";
|
||||
if( !uitextline2.empty() ) {
|
||||
// jeśli jest podana relacja, to dodajemy punkt następnego zatrzymania
|
||||
OutText3 = " -> " + Global::Bezogonkow( Controlled->Mechanik->NextStop(), true );
|
||||
uitextline3 = " -> " + Global::Bezogonkow( Controlled->Mechanik->NextStop(), true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1554,69 +1668,69 @@ TWorld::Update_UI() {
|
||||
if( tmp != nullptr ) {
|
||||
//
|
||||
// jeśli domyślny ekran po pierwszym naciśnięciu
|
||||
OutText1 = "Vehicle name: " + tmp->MoverParameters->Name;
|
||||
uitextline1 = "Vehicle name: " + tmp->MoverParameters->Name;
|
||||
|
||||
if( ( tmp->Mechanik == nullptr ) && ( tmp->ctOwner ) ) {
|
||||
// for cars other than leading unit indicate the leader
|
||||
OutText1 += ", owned by " + tmp->ctOwner->OwnerName();
|
||||
uitextline1 += ", owned by " + tmp->ctOwner->OwnerName();
|
||||
}
|
||||
// informacja o sprzęgach
|
||||
OutText1 +=
|
||||
uitextline1 +=
|
||||
" C0:" +
|
||||
( tmp->PrevConnected ?
|
||||
tmp->PrevConnected->GetName() + ":" + to_string( tmp->MoverParameters->Couplers[ 0 ].CouplingFlag ) :
|
||||
"none" );
|
||||
OutText1 +=
|
||||
uitextline1 +=
|
||||
" C1:" +
|
||||
( tmp->NextConnected ?
|
||||
tmp->NextConnected->GetName() + ":" + to_string( tmp->MoverParameters->Couplers[ 1 ].CouplingFlag ) :
|
||||
"none" );
|
||||
|
||||
OutText2 = "Damage status: " + tmp->MoverParameters->EngineDescription( 0 );
|
||||
uitextline2 = "Damage status: " + tmp->MoverParameters->EngineDescription( 0 );
|
||||
|
||||
OutText2 += "; Brake delay: ";
|
||||
uitextline2 += "; Brake delay: ";
|
||||
if( ( tmp->MoverParameters->BrakeDelayFlag & bdelay_G ) == bdelay_G )
|
||||
OutText2 += "G";
|
||||
uitextline2 += "G";
|
||||
if( ( tmp->MoverParameters->BrakeDelayFlag & bdelay_P ) == bdelay_P )
|
||||
OutText2 += "P";
|
||||
uitextline2 += "P";
|
||||
if( ( tmp->MoverParameters->BrakeDelayFlag & bdelay_R ) == bdelay_R )
|
||||
OutText2 += "R";
|
||||
uitextline2 += "R";
|
||||
if( ( tmp->MoverParameters->BrakeDelayFlag & bdelay_M ) == bdelay_M )
|
||||
OutText2 += "+Mg";
|
||||
uitextline2 += "+Mg";
|
||||
|
||||
OutText2 += ", BTP:" + to_string( tmp->MoverParameters->LoadFlag, 0 );
|
||||
uitextline2 += ", BTP:" + to_string( tmp->MoverParameters->LoadFlag, 0 );
|
||||
{
|
||||
OutText2 +=
|
||||
uitextline2 +=
|
||||
"; pant. "
|
||||
+ to_string( tmp->MoverParameters->PantPress, 2 )
|
||||
+ ( tmp->MoverParameters->bPantKurek3 ? "<ZG" : "|ZG" );
|
||||
}
|
||||
|
||||
OutText2 +=
|
||||
uitextline2 +=
|
||||
", MED:"
|
||||
+ to_string( tmp->MoverParameters->LocalBrakePosA, 2 )
|
||||
+ "+"
|
||||
+ to_string( tmp->MoverParameters->AnPos, 2 );
|
||||
|
||||
OutText2 +=
|
||||
uitextline2 +=
|
||||
", Ft:"
|
||||
+ to_string( tmp->MoverParameters->Ft * 0.001f, 0 );
|
||||
|
||||
OutText2 +=
|
||||
uitextline2 +=
|
||||
"; TC:"
|
||||
+ to_string( tmp->MoverParameters->TotalCurrent, 0 );
|
||||
OutText2 +=
|
||||
uitextline2 +=
|
||||
", HV0:"
|
||||
+ to_string( tmp->MoverParameters->HVCouplers[ 0 ][ 1 ], 0 )
|
||||
+ "@"
|
||||
+ to_string( tmp->MoverParameters->HVCouplers[ 0 ][ 0 ], 0 );
|
||||
OutText2 +=
|
||||
uitextline2 +=
|
||||
", HV1:"
|
||||
+ to_string( tmp->MoverParameters->HVCouplers[ 1 ][ 1 ], 0 )
|
||||
+ "@"
|
||||
+ to_string( tmp->MoverParameters->HVCouplers[ 1 ][ 0 ], 0 );
|
||||
|
||||
OutText3 =
|
||||
uitextline3 =
|
||||
"BP: " + to_string( tmp->MoverParameters->BrakePress, 2 )
|
||||
+ " (" + to_string( tmp->MoverParameters->BrakeStatus, 0 )
|
||||
+ "), LBP: " + to_string( tmp->MoverParameters->LocBrakePress, 2 )
|
||||
@@ -1630,16 +1744,16 @@ TWorld::Update_UI() {
|
||||
|
||||
if( tmp->MoverParameters->ManualBrakePos > 0 ) {
|
||||
|
||||
OutText3 += ", manual brake on";
|
||||
uitextline3 += ", manual brake on";
|
||||
}
|
||||
|
||||
if( tmp->MoverParameters->LocalBrakePos > 0 ) {
|
||||
|
||||
OutText3 += ", local brake on";
|
||||
uitextline3 += ", local brake on";
|
||||
}
|
||||
else {
|
||||
|
||||
OutText3 += ", local brake off";
|
||||
uitextline3 += ", local brake off";
|
||||
}
|
||||
|
||||
if( tmp->Mechanik ) {
|
||||
@@ -1649,9 +1763,9 @@ TWorld::Update_UI() {
|
||||
if( tmp->Mechanik->DrivigFlags() & j ) // jak bit ustawiony
|
||||
flags[ i + 1 ] = std::toupper( flags[ i + 1 ] ); // ^= 0x20; // to zmiana na wielką literę
|
||||
|
||||
OutText4 = flags;
|
||||
uitextline4 = flags;
|
||||
|
||||
OutText4 +=
|
||||
uitextline4 +=
|
||||
"Driver: Vd=" + to_string( tmp->Mechanik->VelDesired, 0 )
|
||||
+ " ad=" + to_string( tmp->Mechanik->AccDesired, 2 )
|
||||
+ " Pd=" + to_string( tmp->Mechanik->ActualProximityDist, 0 )
|
||||
@@ -1663,14 +1777,14 @@ TWorld::Update_UI() {
|
||||
if( ( tmp->Mechanik->VelNext == 0.0 )
|
||||
&& ( tmp->Mechanik->eSignNext ) ) {
|
||||
// jeśli ma zapamiętany event semafora, nazwa eventu semafora
|
||||
OutText4 +=
|
||||
uitextline4 +=
|
||||
" ("
|
||||
+ Global::Bezogonkow( tmp->Mechanik->eSignNext->asName )
|
||||
+ ")";
|
||||
}
|
||||
|
||||
// biezaca komenda dla AI
|
||||
OutText4 += ", command: " + tmp->Mechanik->OrderCurrent();
|
||||
uitextline4 += ", command: " + tmp->Mechanik->OrderCurrent();
|
||||
}
|
||||
|
||||
if( Global::iScreenMode[ Global::iTextMode - GLFW_KEY_F1 ] == 1 ) {
|
||||
@@ -1691,7 +1805,7 @@ TWorld::Update_UI() {
|
||||
}
|
||||
else {
|
||||
// wyświetlenie współrzędnych w scenerii oraz kąta kamery, gdy nie mamy wskaźnika
|
||||
OutText1 =
|
||||
uitextline1 =
|
||||
"Camera position: "
|
||||
+ to_string( Camera.Pos.x, 2 ) + " "
|
||||
+ to_string( Camera.Pos.y, 2 ) + " "
|
||||
@@ -1702,8 +1816,8 @@ TWorld::Update_UI() {
|
||||
+ std::string( "S SEE NEN NWW SW" )
|
||||
.substr( 0 + 2 * floor( fmod( 8 + ( Camera.Yaw + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ), 2 );
|
||||
// current luminance level
|
||||
OutText2 = "Light level: " + to_string( Global::fLuminance, 3 );
|
||||
if( Global::FakeLight ) { OutText2 += "(*)"; }
|
||||
uitextline2 = "Light level: " + to_string( Global::fLuminance, 3 );
|
||||
if( Global::FakeLight ) { uitextline2 += "(*)"; }
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1711,13 +1825,13 @@ TWorld::Update_UI() {
|
||||
|
||||
case( GLFW_KEY_F8 ) : {
|
||||
|
||||
OutText1 =
|
||||
uitextline1 =
|
||||
"Draw range x " + to_string( Global::fDistanceFactor, 1 )
|
||||
+ "; FPS: " + to_string( Timer::GetFPS(), 2 );
|
||||
if( Global::iSlowMotion ) {
|
||||
OutText1 += " (slowmotion " + to_string( Global::iSlowMotion ) + ")";
|
||||
uitextline1 += " (slowmotion " + to_string( Global::iSlowMotion ) + ")";
|
||||
}
|
||||
OutText1 +=
|
||||
uitextline1 +=
|
||||
", sectors: " + to_string( Ground.iRendered )
|
||||
+ "/" + to_string( Global::iSegmentsRendered )
|
||||
+ "; FoV: " + to_string( Global::FieldOfView / Global::ZoomFactor, 1 );
|
||||
@@ -1727,12 +1841,12 @@ TWorld::Update_UI() {
|
||||
|
||||
case( GLFW_KEY_F9 ) : {
|
||||
// informacja o wersji, sposobie wyświetlania i błędach OpenGL
|
||||
OutText1 = Global::asVersion; // informacja o wersji
|
||||
uitextline1 = Global::asVersion; // informacja o wersji
|
||||
if( Global::iMultiplayer ) {
|
||||
OutText1 += " (multiplayer mode is active)";
|
||||
uitextline1 += " (multiplayer mode is active)";
|
||||
}
|
||||
|
||||
OutText2 =
|
||||
uitextline2 =
|
||||
std::string("Rendering mode: ")
|
||||
+ ( Global::bUseVBO ?
|
||||
"VBO" :
|
||||
@@ -1746,7 +1860,7 @@ TWorld::Update_UI() {
|
||||
Global::LastGLError = to_string( glerror ) + " (" + Global::Bezogonkow( (char *)gluErrorString( glerror ) ) + ")";
|
||||
}
|
||||
if( false == Global::LastGLError.empty() ) {
|
||||
OutText3 =
|
||||
uitextline3 =
|
||||
"Last openGL error: "
|
||||
+ Global::LastGLError;
|
||||
}
|
||||
@@ -1756,16 +1870,16 @@ TWorld::Update_UI() {
|
||||
|
||||
case( GLFW_KEY_F10 ) : {
|
||||
|
||||
OutText1 = ( "Press [Y] key to quit / Aby zakonczyc program, przycisnij klawisz [Y]." );
|
||||
uitextline1 = ( "Press [Y] key to quit / Aby zakonczyc program, przycisnij klawisz [Y]." );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case( GLFW_KEY_F12 ) : {
|
||||
// opcje włączenia i wyłączenia logowania
|
||||
OutText1 = "[0] Debugmode " + std::string( DebugModeFlag ? "(on)" : "(off)" );
|
||||
OutText2 = "[1] log.txt " + std::string( ( Global::iWriteLogEnabled & 1 ) ? "(on)" : "(off)" );
|
||||
OutText3 = "[2] Console " + std::string( ( Global::iWriteLogEnabled & 2 ) ? "(on)" : "(off)" );
|
||||
uitextline1 = "[0] Debugmode " + std::string( DebugModeFlag ? "(on)" : "(off)" );
|
||||
uitextline2 = "[1] log.txt " + std::string( ( Global::iWriteLogEnabled & 1 ) ? "(on)" : "(off)" );
|
||||
uitextline3 = "[2] Console " + std::string( ( Global::iWriteLogEnabled & 2 ) ? "(on)" : "(off)" );
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1783,7 +1897,7 @@ TWorld::Update_UI() {
|
||||
break;
|
||||
}
|
||||
|
||||
OutText1 =
|
||||
uitextline1 =
|
||||
"vel: " + to_string(tmp->GetVelocity(), 2) + " km/h"
|
||||
+ "; dist: " + to_string(tmp->MoverParameters->DistCounter, 2) + " km"
|
||||
+ "; pos: ("
|
||||
@@ -1792,7 +1906,7 @@ TWorld::Update_UI() {
|
||||
+ to_string( tmp->GetPosition().z, 2 )
|
||||
+ ")";
|
||||
|
||||
OutText2 =
|
||||
uitextline2 =
|
||||
"HamZ=" + to_string( tmp->MoverParameters->fBrakeCtrlPos, 1 )
|
||||
+ "; HamP=" + std::to_string( tmp->MoverParameters->LocalBrakePos ) + "/" + to_string( tmp->MoverParameters->LocalBrakePosA, 2 )
|
||||
+ "; NasJ=" + std::to_string( tmp->MoverParameters->MainCtrlPos ) + "(" + std::to_string( tmp->MoverParameters->MainCtrlActualPos ) + ")"
|
||||
@@ -1808,14 +1922,14 @@ TWorld::Update_UI() {
|
||||
to_string( tmp->MoverParameters->RunningShape.R, 1 ) )
|
||||
+ " An=" + to_string( tmp->MoverParameters->AccN, 2 ); // przyspieszenie poprzeczne
|
||||
|
||||
if( tprev != int( GlobalTime->mr ) ) {
|
||||
tprev = GlobalTime->mr;
|
||||
if( tprev != Simulation::Time.data().wSecond ) {
|
||||
tprev = Simulation::Time.data().wSecond;
|
||||
Acc = ( tmp->MoverParameters->Vel - VelPrev ) / 3.6;
|
||||
VelPrev = tmp->MoverParameters->Vel;
|
||||
}
|
||||
OutText2 += ( "; As=" ) + to_string( Acc, 2 ); // przyspieszenie wzdłużne
|
||||
uitextline2 += ( "; As=" ) + to_string( Acc, 2 ); // przyspieszenie wzdłużne
|
||||
|
||||
OutText3 =
|
||||
uitextline3 =
|
||||
"cyl.ham. " + to_string( tmp->MoverParameters->BrakePress, 2 )
|
||||
+ "; prz.gl. " + to_string( tmp->MoverParameters->PipePress, 2 )
|
||||
+ "; zb.gl. " + to_string( tmp->MoverParameters->CompressedVolume, 2 )
|
||||
@@ -1824,49 +1938,49 @@ TWorld::Update_UI() {
|
||||
|
||||
// McZapkie: warto wiedziec w jakim stanie sa przelaczniki
|
||||
if( tmp->MoverParameters->ConvOvldFlag )
|
||||
OutText3 += " C! ";
|
||||
uitextline3 += " C! ";
|
||||
else if( tmp->MoverParameters->FuseFlag )
|
||||
OutText3 += " F! ";
|
||||
uitextline3 += " F! ";
|
||||
else if( !tmp->MoverParameters->Mains )
|
||||
OutText3 += " () ";
|
||||
uitextline3 += " () ";
|
||||
else {
|
||||
switch(
|
||||
tmp->MoverParameters->ActiveDir *
|
||||
( tmp->MoverParameters->Imin == tmp->MoverParameters->IminLo ?
|
||||
1 :
|
||||
2 ) ) {
|
||||
case 2: { OutText3 += " >> "; break; }
|
||||
case 1: { OutText3 += " -> "; break; }
|
||||
case 0: { OutText3 += " -- "; break; }
|
||||
case -1: { OutText3 += " <- "; break; }
|
||||
case -2: { OutText3 += " << "; break; }
|
||||
case 2: { uitextline3 += " >> "; break; }
|
||||
case 1: { uitextline3 += " -> "; break; }
|
||||
case 0: { uitextline3 += " -- "; break; }
|
||||
case -1: { uitextline3 += " <- "; break; }
|
||||
case -2: { uitextline3 += " << "; break; }
|
||||
}
|
||||
}
|
||||
// McZapkie: predkosc szlakowa
|
||||
if( tmp->MoverParameters->RunningTrack.Velmax == -1 ) {
|
||||
OutText3 += " Vtrack=Vmax";
|
||||
uitextline3 += " Vtrack=Vmax";
|
||||
}
|
||||
else {
|
||||
OutText3 += " Vtrack " + to_string( tmp->MoverParameters->RunningTrack.Velmax, 2 );
|
||||
uitextline3 += " Vtrack " + to_string( tmp->MoverParameters->RunningTrack.Velmax, 2 );
|
||||
}
|
||||
|
||||
if( ( tmp->MoverParameters->EnginePowerSource.SourceType == CurrentCollector )
|
||||
|| ( tmp->MoverParameters->TrainType == dt_EZT ) ) {
|
||||
OutText3 +=
|
||||
uitextline3 +=
|
||||
"; pant. " + to_string( tmp->MoverParameters->PantPress, 2 )
|
||||
+ ( tmp->MoverParameters->bPantKurek3 ? "=" : "^" ) + "ZG";
|
||||
}
|
||||
|
||||
// McZapkie: komenda i jej parametry
|
||||
if( tmp->MoverParameters->CommandIn.Command != ( "" ) ) {
|
||||
OutText4 =
|
||||
uitextline4 =
|
||||
"C:" + tmp->MoverParameters->CommandIn.Command
|
||||
+ " V1=" + to_string( tmp->MoverParameters->CommandIn.Value1, 0 )
|
||||
+ " V2=" + to_string( tmp->MoverParameters->CommandIn.Value2, 0 );
|
||||
}
|
||||
if( ( tmp->Mechanik )
|
||||
&& ( tmp->Mechanik->AIControllFlag == AIdriver ) ) {
|
||||
OutText4 +=
|
||||
uitextline4 +=
|
||||
"AI: Vd=" + to_string( tmp->Mechanik->VelDesired, 0 )
|
||||
+ " ad=" + to_string( tmp->Mechanik->AccDesired, 2 )
|
||||
+ " Pd=" + to_string( tmp->Mechanik->ActualProximityDist, 0 )
|
||||
@@ -1906,7 +2020,7 @@ TWorld::Update_UI() {
|
||||
#ifdef EU07_USE_OLD_UI_CODE
|
||||
if( Controlled && DebugModeFlag && !Global::iTextMode ) {
|
||||
|
||||
OutText1 +=
|
||||
uitextline1 +=
|
||||
( "; d_omega " ) + to_string( Controlled->MoverParameters->dizel_engagedeltaomega, 3 );
|
||||
|
||||
if( Controlled->MoverParameters->EngineType == ElectricInductionMotor ) {
|
||||
@@ -1914,7 +2028,7 @@ TWorld::Update_UI() {
|
||||
for( int i = 0; i <= 8; i++ ) {
|
||||
for( int j = 0; j <= 9; j++ ) {
|
||||
glRasterPos2f( 0.05f + 0.03f * i, 0.16f - 0.01f * j );
|
||||
OutText4 = to_string( Train->fEIMParams[ i ][ j ], 2 );
|
||||
uitextline4 = to_string( Train->fEIMParams[ i ][ j ], 2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1923,24 +2037,23 @@ TWorld::Update_UI() {
|
||||
|
||||
// update the ui header texts
|
||||
auto &headerdata = UIHeader->text_lines;
|
||||
headerdata[ 0 ].data = OutText1;
|
||||
headerdata[ 1 ].data = OutText2;
|
||||
headerdata[ 2 ].data = OutText3;
|
||||
headerdata[ 3 ].data = OutText4;
|
||||
headerdata[ 0 ].data = uitextline1;
|
||||
headerdata[ 1 ].data = uitextline2;
|
||||
headerdata[ 2 ].data = uitextline3;
|
||||
headerdata[ 3 ].data = uitextline4;
|
||||
|
||||
{ // stenogramy dźwięków (ukryć, gdy tabelka skanowania lub rozkład?)
|
||||
auto &transcripts = UITranscripts->text_lines;
|
||||
transcripts.clear();
|
||||
for( auto const &transcript : Global::tranTexts.aLines ) {
|
||||
// stenogramy dźwięków (ukryć, gdy tabelka skanowania lub rozkład?)
|
||||
auto &transcripts = UITranscripts->text_lines;
|
||||
transcripts.clear();
|
||||
for( auto const &transcript : Global::tranTexts.aLines ) {
|
||||
|
||||
if( Global::fTimeAngleDeg >= transcript.fShow ) {
|
||||
if( Global::fTimeAngleDeg >= transcript.fShow ) {
|
||||
|
||||
cParser parser( transcript.asText );
|
||||
while( true == parser.getTokens(1, false, "|") ) {
|
||||
cParser parser( transcript.asText );
|
||||
while( true == parser.getTokens( 1, false, "|" ) ) {
|
||||
|
||||
std::string transcriptline; parser >> transcriptline;
|
||||
transcripts.emplace_back( transcriptline, float4( 1.0f, 1.0f, 0.0f, 1.0f ) );
|
||||
}
|
||||
std::string transcriptline; parser >> transcriptline;
|
||||
transcripts.emplace_back( transcriptline, float4( 1.0f, 1.0f, 0.0f, 1.0f ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2015,15 +2128,12 @@ void TWorld::OnCommandGet(DaneRozkaz *pRozkaz)
|
||||
if (*pRozkaz->iPar & 1) // ustawienie czasu
|
||||
{
|
||||
double t = pRozkaz->fPar[1];
|
||||
GlobalTime->dd = floor(t); // niby nie powinno być dnia, ale...
|
||||
Simulation::Time.data().wDay = std::floor(t); // niby nie powinno być dnia, ale...
|
||||
if (Global::fMoveLight >= 0)
|
||||
Global::fMoveLight = t; // trzeba by deklinację Słońca przeliczyć
|
||||
GlobalTime->hh = floor(24 * t) - 24.0 * GlobalTime->dd;
|
||||
GlobalTime->mm =
|
||||
floor(60 * 24 * t) - 60.0 * (24.0 * GlobalTime->dd + GlobalTime->hh);
|
||||
GlobalTime->mr =
|
||||
floor(60 * 60 * 24 * t) -
|
||||
60.0 * (60.0 * (24.0 * GlobalTime->dd + GlobalTime->hh) + GlobalTime->mm);
|
||||
Simulation::Time.data().wHour = std::floor(24 * t) - 24.0 * Simulation::Time.data().wDay;
|
||||
Simulation::Time.data().wMinute = std::floor(60 * 24 * t) - 60.0 * (24.0 * Simulation::Time.data().wDay + Simulation::Time.data().wHour);
|
||||
Simulation::Time.data().wSecond = std::floor( 60 * 60 * 24 * t ) - 60.0 * ( 60.0 * ( 24.0 * Simulation::Time.data().wDay + Simulation::Time.data().wHour ) + Simulation::Time.data().wMinute );
|
||||
}
|
||||
if (*pRozkaz->iPar & 2)
|
||||
{ // ustawienie flag zapauzowania
|
||||
@@ -2407,10 +2517,12 @@ world_environment::render() {
|
||||
// setup fog
|
||||
if( Global::fFogEnd > 0 ) {
|
||||
// fog setup
|
||||
::glFogi( GL_FOG_MODE, GL_LINEAR );
|
||||
::glFogfv( GL_FOG_COLOR, Global::FogColor );
|
||||
/*
|
||||
::glFogf( GL_FOG_START, Global::fFogStart );
|
||||
::glFogf( GL_FOG_END, Global::fFogEnd );
|
||||
*/
|
||||
::glFogf( GL_FOG_DENSITY, 1.0f / Global::fFogEnd );
|
||||
::glEnable( GL_FOG );
|
||||
}
|
||||
else { ::glDisable( GL_FOG ); }
|
||||
|
||||
Reference in New Issue
Block a user