Skip to content

Commit

Permalink
attempt to make exposure value to display rounded
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaniy committed Jul 8, 2024
1 parent e203600 commit 7e43270
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/celengine/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ double Simulation::getTimeScale() const
return pauseState?storedTimeScale:timeScale;
}

void Simulation::setTimeScale(double _timeScale)
void Simulation::setTimeScale(float _timeScale)
{
if (pauseState)
{
Expand Down
2 changes: 1 addition & 1 deletion src/celengine/simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions src/celestia/celestiacore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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':
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/celestia/qt/qttimetoolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/celscript/legacy/cmdparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ ParseResult parseTimeCommand(const Hash& paramList, const ScriptMaps&)

ParseResult parseTimeRateCommand(const Hash& paramList, const ScriptMaps&)
{
auto rate = paramList.getNumber<double>("rate").value_or(1.0);
auto rate = paramList.getNumber<float>("rate").value_or(1.0f);
return std::make_unique<CommandSetTimeRate>(rate);
}

Expand Down
2 changes: 1 addition & 1 deletion src/celscript/legacy/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/celscript/legacy/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class CommandSetTime : public InstantaneousCommand
class CommandSetTimeRate : public InstantaneousCommand
{
public:
CommandSetTimeRate(double);
CommandSetTimeRate(float);

protected:
void processInstantaneous(ExecutionEnvironment&) override;
Expand Down
2 changes: 1 addition & 1 deletion src/celscript/lua/celx_celestia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7e43270

Please sign in to comment.