fixes
This commit is contained in:
parent
f560a78fc8
commit
f8dd0a8ed1
|
|
@ -250,11 +250,12 @@ String Duration::ToString() const
|
|||
return String("0s");
|
||||
}
|
||||
|
||||
String result;
|
||||
StringStream stream;
|
||||
|
||||
int64_t total_ms = milliseconds_;
|
||||
if (total_ms < 0)
|
||||
{
|
||||
result.append("-");
|
||||
stream << "-";
|
||||
total_ms = -total_ms;
|
||||
}
|
||||
|
||||
|
|
@ -265,23 +266,22 @@ String Duration::ToString() const
|
|||
|
||||
if (hour)
|
||||
{
|
||||
result.append(std::to_string(hour)).append("h");
|
||||
result.append(std::to_string(min)).append("m");
|
||||
stream << hour << 'h' << min << 'm';
|
||||
}
|
||||
else if (min)
|
||||
{
|
||||
result.append(std::to_string(min)).append("m");
|
||||
stream << min << 'm';
|
||||
}
|
||||
|
||||
if (ms != 0)
|
||||
{
|
||||
result.append(std::to_string(static_cast<float>(sec + ms) / 1000.f)).append("s");
|
||||
stream << float(sec) + float(ms) / 1000.f << 's';
|
||||
}
|
||||
else if (sec != 0)
|
||||
{
|
||||
result.append(std::to_string(sec)).append("s");
|
||||
stream << sec << 's';
|
||||
}
|
||||
return result;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
bool Duration::operator==(const Duration& other) const
|
||||
|
|
|
|||
|
|
@ -62,8 +62,31 @@ Task::Task()
|
|||
{
|
||||
}
|
||||
|
||||
void Task::Start()
|
||||
{
|
||||
if (!running_)
|
||||
{
|
||||
running_ = true;
|
||||
if (ticker_)
|
||||
ticker_->Resume();
|
||||
}
|
||||
}
|
||||
|
||||
void Task::Stop()
|
||||
{
|
||||
if (running_)
|
||||
{
|
||||
running_ = false;
|
||||
if (ticker_)
|
||||
ticker_->Pause();
|
||||
}
|
||||
}
|
||||
|
||||
void Task::Update(Duration dt)
|
||||
{
|
||||
if (!running_ || removeable_)
|
||||
return;
|
||||
|
||||
if (!ticker_ || ticker_->GetTotalTickCount() == 0)
|
||||
{
|
||||
Remove();
|
||||
|
|
|
|||
|
|
@ -129,16 +129,6 @@ private:
|
|||
Callback callback_;
|
||||
};
|
||||
|
||||
inline void Task::Start()
|
||||
{
|
||||
running_ = true;
|
||||
}
|
||||
|
||||
inline void Task::Stop()
|
||||
{
|
||||
running_ = false;
|
||||
}
|
||||
|
||||
inline void Task::Remove()
|
||||
{
|
||||
removeable_ = true;
|
||||
|
|
@ -162,6 +152,13 @@ inline TickerPtr Task::GetTicker() const
|
|||
inline void Task::SetTicker(TickerPtr ticker)
|
||||
{
|
||||
ticker_ = ticker;
|
||||
if (ticker_)
|
||||
{
|
||||
if (running_)
|
||||
ticker_->Resume();
|
||||
else
|
||||
ticker_->Pause();
|
||||
}
|
||||
}
|
||||
|
||||
inline Task::Callback Task::GetCallback() const
|
||||
|
|
|
|||
Loading…
Reference in New Issue