From 7e43270318328c287158098a629205df1f4c8530 Mon Sep 17 00:00:00 2001 From: Askaniy Date: Mon, 8 Jul 2024 16:51:07 +0300 Subject: [PATCH] attempt to make exposure value to display rounded --- src/celengine/simulation.cpp | 2 +- src/celengine/simulation.h | 2 +- src/celestia/celestiacore.cpp | 12 ++++++------ src/celestia/qt/qttimetoolbar.cpp | 12 ++++++------ src/celscript/legacy/cmdparser.cpp | 2 +- src/celscript/legacy/command.cpp | 2 +- src/celscript/legacy/command.h | 2 +- src/celscript/lua/celx_celestia.cpp | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/celengine/simulation.cpp b/src/celengine/simulation.cpp index 46806b51890..9d84fcbea25 100644 --- a/src/celengine/simulation.cpp +++ b/src/celengine/simulation.cpp @@ -495,7 +495,7 @@ double Simulation::getTimeScale() const return pauseState?storedTimeScale:timeScale; } -void Simulation::setTimeScale(double _timeScale) +void Simulation::setTimeScale(float _timeScale) { if (pauseState) { diff --git a/src/celengine/simulation.h b/src/celengine/simulation.h index f9f894c6649..4e1746805e2 100644 --- a/src/celengine/simulation.h +++ b/src/celengine/simulation.h @@ -110,7 +110,7 @@ class Simulation SolarSystem* getNearestSolarSystem() const; double getTimeScale() const; - void setTimeScale(double); + void setTimeScale(float); bool getSyncTime() const; void setSyncTime(bool); void synchronizeTime(); diff --git a/src/celestia/celestiacore.cpp b/src/celestia/celestiacore.cpp index ff4a5554f71..8fd7076165f 100644 --- a/src/celestia/celestiacore.cpp +++ b/src/celestia/celestiacore.cpp @@ -1389,7 +1389,7 @@ void CelestiaCore::charEntered(const char *c_p, int modifiers) break; case 'R': - if (c == 'r') // Skip rangechecking as setResolution does it already + if (c == 'r') // Skip range checking as setResolution does it already renderer->setResolution(renderer->getResolution() - 1); else renderer->setResolution(renderer->getResolution() + 1); @@ -1405,7 +1405,7 @@ void CelestiaCore::charEntered(const char *c_p, int modifiers) flash(_("High res textures")); break; } - notifyWatchers(RenderFlagsChanged); //how to synchronize with menu? + notifyWatchers(RenderFlagsChanged); // how to synchronize with menu? break; case 'Q': @@ -1468,16 +1468,16 @@ void CelestiaCore::charEntered(const char *c_p, int modifiers) case '[': { - setExposure(sim->getExposure() * 0.5); - auto buf = fmt::format(loc, _("Exposure time: {:.2f}"), sim->getExposure()); + setExposure(sim->getExposure() * 0.5f); + auto buf = fmt::format(loc, _("Exposure time: {:.6g}"), sim->getExposure()); flash(buf); } break; case ']': { - setExposure(sim->getExposure() * 2.0); - auto buf = fmt::format(loc, _("Exposure time: {:.2f}"), sim->getExposure()); + setExposure(sim->getExposure() * 2.0f); + auto buf = fmt::format(loc, _("Exposure time: {:.6g}"), sim->getExposure()); flash(buf); } break; diff --git a/src/celestia/qt/qttimetoolbar.cpp b/src/celestia/qt/qttimetoolbar.cpp index 18bdd442862..d210db59ede 100644 --- a/src/celestia/qt/qttimetoolbar.cpp +++ b/src/celestia/qt/qttimetoolbar.cpp @@ -89,31 +89,31 @@ TimeToolBar::slotReverseTime() void TimeToolBar::slotRealTime() { - appCore->getSimulation()->setTimeScale(1.0); + appCore->getSimulation()->setTimeScale(1.0f); } void TimeToolBar::slotDoubleTime() { - appCore->getSimulation()->setTimeScale(2.0 * appCore->getSimulation()->getTimeScale()); + appCore->getSimulation()->setTimeScale(2.0f * appCore->getSimulation()->getTimeScale()); } void TimeToolBar::slotHalfTime() { - appCore->getSimulation()->setTimeScale(0.5 * appCore->getSimulation()->getTimeScale()); + appCore->getSimulation()->setTimeScale(0.5f * appCore->getSimulation()->getTimeScale()); } void TimeToolBar::slotFaster() { - appCore->getSimulation()->setTimeScale(10.0 * appCore->getSimulation()->getTimeScale()); + appCore->getSimulation()->setTimeScale(10.0f * appCore->getSimulation()->getTimeScale()); } void TimeToolBar::slotSlower() { - appCore->getSimulation()->setTimeScale(0.1 * appCore->getSimulation()->getTimeScale()); + appCore->getSimulation()->setTimeScale(0.1f * appCore->getSimulation()->getTimeScale()); } void @@ -125,7 +125,7 @@ TimeToolBar::slotCurrentTime() astro::Date celDate(d.year(), d.month(), d.day()); celDate.hour = t.hour(); celDate.minute = t.minute(); - celDate.seconds = (double) t.second() + t.msec() / 1000.0; + celDate.seconds = (double) t.second() + t.msec() * 0.001; appCore->getSimulation()->setTime(astro::UTCtoTDB(celDate)); } diff --git a/src/celscript/legacy/cmdparser.cpp b/src/celscript/legacy/cmdparser.cpp index f5025fc3b8d..e5211973cc3 100644 --- a/src/celscript/legacy/cmdparser.cpp +++ b/src/celscript/legacy/cmdparser.cpp @@ -455,7 +455,7 @@ ParseResult parseTimeCommand(const Hash& paramList, const ScriptMaps&) ParseResult parseTimeRateCommand(const Hash& paramList, const ScriptMaps&) { - auto rate = paramList.getNumber("rate").value_or(1.0); + auto rate = paramList.getNumber("rate").value_or(1.0f); return std::make_unique(rate); } diff --git a/src/celscript/legacy/command.cpp b/src/celscript/legacy/command.cpp index 3f9d93c211c..98957fc5008 100644 --- a/src/celscript/legacy/command.cpp +++ b/src/celscript/legacy/command.cpp @@ -331,7 +331,7 @@ void CommandSetTime::processInstantaneous(ExecutionEnvironment& env) //////////////// // Set time rate command: set the simulation time rate -CommandSetTimeRate::CommandSetTimeRate(double _rate) : rate(_rate) +CommandSetTimeRate::CommandSetTimeRate(float _rate) : rate(_rate) { } diff --git a/src/celscript/legacy/command.h b/src/celscript/legacy/command.h index 5f4e76a8225..fa00de19d93 100644 --- a/src/celscript/legacy/command.h +++ b/src/celscript/legacy/command.h @@ -301,7 +301,7 @@ class CommandSetTime : public InstantaneousCommand class CommandSetTimeRate : public InstantaneousCommand { public: - CommandSetTimeRate(double); + CommandSetTimeRate(float); protected: void processInstantaneous(ExecutionEnvironment&) override; diff --git a/src/celscript/lua/celx_celestia.cpp b/src/celscript/lua/celx_celestia.cpp index 34dc3e1aaa0..7573d4c5a69 100644 --- a/src/celscript/lua/celx_celestia.cpp +++ b/src/celscript/lua/celx_celestia.cpp @@ -1269,7 +1269,7 @@ static int celestia_settimescale(lua_State* l) Celx_CheckArgs(l, 2, 2, "One argument expected to function celestia:settimescale"); CelestiaCore* appCore = this_celestia(l); - double t = Celx_SafeGetNumber(l, 2, AllErrors, "Second arg to celestia:settimescale must be a number"); + float t = Celx_SafeGetNumber(l, 2, AllErrors, "Second arg to celestia:settimescale must be a number"); appCore->getSimulation()->setTimeScale(t); return 0;