std::string CLangInfo::GetSpeedAsString(const CSpeed& speed) const { if (!speed.IsValid()) return g_localizeStrings.Get(13205); // "Unknown" return StringUtils::Format("%s%s", speed.ToString(GetSpeedUnit()).c_str(), GetSpeedUnitString().c_str()); }
void CWeatherJob::SetFromProperties() { // Load in our tokens if necessary if (m_localizedTokens.empty()) LoadLocalizedToken(); CGUIWindow* window = g_windowManager.GetWindow(WINDOW_WEATHER); if (window) { CDateTime time = CDateTime::GetCurrentDateTime(); m_info.lastUpdateTime = time.GetAsLocalizedDateTime(false, false); m_info.currentConditions = window->GetProperty("Current.Condition").asString(); m_info.currentIcon = ConstructPath(window->GetProperty("Current.OutlookIcon").asString()); LocalizeOverview(m_info.currentConditions); FormatTemperature(m_info.currentTemperature, strtod(window->GetProperty("Current.Temperature").asString().c_str(), nullptr)); FormatTemperature(m_info.currentFeelsLike, strtod(window->GetProperty("Current.FeelsLike").asString().c_str(), nullptr)); m_info.currentUVIndex = window->GetProperty("Current.UVIndex").asString(); LocalizeOverview(m_info.currentUVIndex); CSpeed speed = CSpeed::CreateFromKilometresPerHour(strtol(window->GetProperty("Current.Wind").asString().c_str(),0,10)); std::string direction = window->GetProperty("Current.WindDirection").asString(); if (direction == "CALM") m_info.currentWind = g_localizeStrings.Get(1410); else { LocalizeOverviewToken(direction); m_info.currentWind = StringUtils::Format(g_localizeStrings.Get(434).c_str(), direction.c_str(), (int)speed.To(g_langInfo.GetSpeedUnit()), g_langInfo.GetSpeedUnitString().c_str()); } std::string windspeed = StringUtils::Format("%i %s", (int)speed.To(g_langInfo.GetSpeedUnit()), g_langInfo.GetSpeedUnitString().c_str()); window->SetProperty("Current.WindSpeed",windspeed); FormatTemperature(m_info.currentDewPoint, strtod(window->GetProperty("Current.DewPoint").asString().c_str(), nullptr)); if (window->GetProperty("Current.Humidity").asString().empty()) m_info.currentHumidity.clear(); else m_info.currentHumidity = StringUtils::Format("%s%%", window->GetProperty("Current.Humidity").asString().c_str()); m_info.location = window->GetProperty("Current.Location").asString(); for (int i=0;i<NUM_DAYS;++i) { std::string strDay = StringUtils::Format("Day%i.Title",i); m_info.forecast[i].m_day = window->GetProperty(strDay).asString(); LocalizeOverviewToken(m_info.forecast[i].m_day); strDay = StringUtils::Format("Day%i.HighTemp",i); FormatTemperature(m_info.forecast[i].m_high, strtod(window->GetProperty(strDay).asString().c_str(), nullptr)); strDay = StringUtils::Format("Day%i.LowTemp",i); FormatTemperature(m_info.forecast[i].m_low, strtod(window->GetProperty(strDay).asString().c_str(), nullptr)); strDay = StringUtils::Format("Day%i.OutlookIcon",i); m_info.forecast[i].m_icon = ConstructPath(window->GetProperty(strDay).asString()); strDay = StringUtils::Format("Day%i.Outlook",i); m_info.forecast[i].m_overview = window->GetProperty(strDay).asString(); LocalizeOverview(m_info.forecast[i].m_overview); } } }
CSpeed CSpeed::operator /(const CSpeed& right) const { assert(IsValid()); assert(right.IsValid()); CSpeed temp(*this); if (!IsValid() || !right.IsValid()) temp.SetValid(false); else temp.m_value /= right.m_value; return temp; }
bool CSpeed::operator ==(const CSpeed& right) const { assert(IsValid()); assert(right.IsValid()); if (!IsValid() || !right.IsValid()) return false; if (this == &right) return true; return (m_value == right.m_value); }
void ALeft::execute(const sf::Int32 elapsed) { // TODO: Verif' they are existing components // #1 get all components CAcceleration * acceleration; acceleration = (CAcceleration *) parent->getComponent("Acceleration"); CSpeed * speed; speed = (CSpeed *) parent->getComponent("Speed"); CPosition * position; position = (CPosition *) parent->getComponent("Position"); // #2 add values speed->setHSpeed((speed->getHSpeed())-(acceleration->getHAcceleration())); position->setX((position->getX())+(speed->getHSpeed())); // #3 change sprites TODO // example : if elapsed > modulotime/2 then ... }
void ARight::execute(const sf::Int64 elapsed) { // TODO: Verif' they are existing components // #1 get all components sf::Int64 tempElapsedSum = getElapsedSum() + elapsed; CAcceleration * acceleration; acceleration = (CAcceleration *) parent->getComponent("Acceleration"); CSpeed * speed = (CSpeed *) parent->getComponent("Speed"); CPosition * position = (CPosition *) parent->getComponent("Position"); CSprite * sprite = (CSprite *) parent->getComponent("Sprite"); if (speed->getHSpeed() < -1.2) { // #2a go back to 0 speed->setHSpeed((speed->getHSpeed())-((float)(speed->getHSpeed())/8.0)); position->setX((position->getX())+(speed->getHSpeed())); sprite->updatePosition(); } else { // #2b add values speed->setHSpeed((speed->getHSpeed())+ ((float)elapsed/acceleration->getHAcceleration()* speed->getHSpeedMax())); position->setX((position->getX())+ceil((speed->getHSpeed()))); // round sup sprite->updatePosition(); } // #3 change sprites sf::Int64 temp = 0; int k = 0; //index to read in tab while (temp < tempElapsedSum) { ++k; temp = temp + (getModuloTime()/getSubSprites().size()); } if ((k-1)>=getSubSprites().size()) {k=getSubSprites().size();} sprite->updateSubSprite(getSubSprites().at(k-1)); sprite->setDirection("right"); setElapsedSum(tempElapsedSum%getModuloTime()); }
void ALeft::execute(const sf::Int32 elapsed) { // TODO: Verif' they are existing components // #1 get all components CSpeed * speed; speed = (CSpeed *) parent->getComponent("Speed"); CAcceleration * acceleration; acceleration = (CAcceleration *) parent->getComponent("Acceleration"); CPosition * position; position = (CPosition *) parent->getComponent("Position"); if (speed->getHSpeed() > 1.2) { // #2a go back to 0 speed->setHSpeed((speed->getHSpeed())-((float)(speed->getHSpeed())/8.0)); position->setX((position->getX())+(speed->getHSpeed())); } else { // #2b increase speed speed->setHSpeed((speed->getHSpeed())-(acceleration->getHAcceleration())); position->setX((position->getX())+(speed->getHSpeed())); } // #3 change sprites TODO // example : if elapsed > modulotime/2 then ... }
void AStand::execute(const sf::Int32 elapsed) { // TODO: Verif' they are existing components // #1 get all components CSpeed * speed; speed = (CSpeed *) parent->getComponent("Speed"); if ((float) std::abs(speed->getHSpeed()) > 1.2) { CAcceleration * acceleration; acceleration = (CAcceleration *) parent->getComponent("Acceleration"); CPosition * position; position = (CPosition *) parent->getComponent("Position"); // #2 add value speed->setHSpeed((speed->getHSpeed())-((float)(speed->getHSpeed())/8.0)); position->setX((position->getX())+(speed->getHSpeed())); } else { speed->setHSpeed(0.0); } // #3 change sprites TODO // example : if elapsed > modulotime/2 then ... }