mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 17:29:18 +02:00
keep timespeed after f6, add fpslimit
This commit is contained in:
10
Globals.cpp
10
Globals.cpp
@@ -386,7 +386,8 @@ global_settings::ConfigParse(cParser &Parser) {
|
|||||||
{
|
{
|
||||||
// przyspieszenie czasu, zmienna do testów
|
// przyspieszenie czasu, zmienna do testów
|
||||||
Parser.getTokens(1, false);
|
Parser.getTokens(1, false);
|
||||||
Parser >> fTimeSpeed;
|
Parser >> default_timespeed;
|
||||||
|
fTimeSpeed = default_timespeed;
|
||||||
}
|
}
|
||||||
else if (token == "multisampling")
|
else if (token == "multisampling")
|
||||||
{
|
{
|
||||||
@@ -698,6 +699,13 @@ global_settings::ConfigParse(cParser &Parser) {
|
|||||||
Parser.getTokens(1);
|
Parser.getTokens(1);
|
||||||
Parser >> gfx_shadowmap_enabled;
|
Parser >> gfx_shadowmap_enabled;
|
||||||
}
|
}
|
||||||
|
else if (token == "fpslimit")
|
||||||
|
{
|
||||||
|
Parser.getTokens(1);
|
||||||
|
float fpslimit;
|
||||||
|
Parser >> fpslimit;
|
||||||
|
minframetime = std::chrono::duration<float>(1.0f / fpslimit);
|
||||||
|
}
|
||||||
else if (token == "gfx.envmap.enabled")
|
else if (token == "gfx.envmap.enabled")
|
||||||
{
|
{
|
||||||
Parser.getTokens(1);
|
Parser.getTokens(1);
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ struct global_settings {
|
|||||||
double fMoveLight{ -1 }; // numer dnia w roku albo -1
|
double fMoveLight{ -1 }; // numer dnia w roku albo -1
|
||||||
bool FakeLight{ false }; // toggle between fixed and dynamic daylight
|
bool FakeLight{ false }; // toggle between fixed and dynamic daylight
|
||||||
double fTimeSpeed{ 1.0 }; // przyspieszenie czasu, zmienna do testów
|
double fTimeSpeed{ 1.0 }; // przyspieszenie czasu, zmienna do testów
|
||||||
|
double default_timespeed { 1.0 }; // timescale loaded from config
|
||||||
double fLatitudeDeg{ 52.0 }; // szerokość geograficzna
|
double fLatitudeDeg{ 52.0 }; // szerokość geograficzna
|
||||||
float ScenarioTimeOverride { std::numeric_limits<float>::quiet_NaN() }; // requested scenario start time
|
float ScenarioTimeOverride { std::numeric_limits<float>::quiet_NaN() }; // requested scenario start time
|
||||||
float ScenarioTimeOffset { 0.f }; // time shift (in hours) applied to train timetables
|
float ScenarioTimeOffset { 0.f }; // time shift (in hours) applied to train timetables
|
||||||
@@ -177,6 +178,8 @@ struct global_settings {
|
|||||||
bool dds_upper_origin = false;
|
bool dds_upper_origin = false;
|
||||||
bool captureonstart = true;
|
bool captureonstart = true;
|
||||||
|
|
||||||
|
std::chrono::duration<float> minframetime {0.0f};
|
||||||
|
|
||||||
bool python_mipmaps = true;
|
bool python_mipmaps = true;
|
||||||
bool python_displaywindows = false;
|
bool python_displaywindows = false;
|
||||||
bool python_threadedupload = true;
|
bool python_threadedupload = true;
|
||||||
|
|||||||
7
Timer.h
7
Timer.h
@@ -35,9 +35,12 @@ public:
|
|||||||
void
|
void
|
||||||
start() {
|
start() {
|
||||||
m_start = std::chrono::steady_clock::now(); }
|
m_start = std::chrono::steady_clock::now(); }
|
||||||
void
|
std::chrono::duration<float, std::milli>
|
||||||
stop() {
|
stop() {
|
||||||
m_accumulator = 0.95f * m_accumulator + std::chrono::duration_cast<std::chrono::microseconds>( ( std::chrono::steady_clock::now() - m_start ) ).count() / 1000.f; }
|
auto duration = std::chrono::duration_cast<std::chrono::microseconds>( ( std::chrono::steady_clock::now() - m_start ) );
|
||||||
|
m_accumulator = 0.95f * m_accumulator + duration.count() / 1000.f;
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
float
|
float
|
||||||
average() const {
|
average() const {
|
||||||
return m_accumulator / 20.f;}
|
return m_accumulator / 20.f;}
|
||||||
|
|||||||
@@ -172,7 +172,9 @@ eu07_application::run() {
|
|||||||
screenshot_man.make_screenshot();
|
screenshot_man.make_screenshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer::subsystem.mainloop_total.stop();
|
auto frametime = Timer::subsystem.mainloop_total.stop();
|
||||||
|
if (Global.minframetime.count() != 0.0f && (Global.minframetime - frametime).count() > 0.0f)
|
||||||
|
std::this_thread::sleep_for(Global.minframetime - frametime);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -746,7 +746,7 @@ driver_mode::OnKeyDown(int cKey) {
|
|||||||
if( DebugModeFlag ) {
|
if( DebugModeFlag ) {
|
||||||
|
|
||||||
if( Global.ctrlState ) { Global.fTimeSpeed = ( Global.shiftState ? 60.0 : 20.0 ); }
|
if( Global.ctrlState ) { Global.fTimeSpeed = ( Global.shiftState ? 60.0 : 20.0 ); }
|
||||||
else { Global.fTimeSpeed = ( Global.shiftState ? 5.0 : 1.0 ); }
|
else { Global.fTimeSpeed = ( Global.shiftState ? 5.0 : Global.default_timespeed ); }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user