Skip to content

Commit

Permalink
changed: Weather properties for temperature now don't include the units.
Browse files Browse the repository at this point in the history
added: System.TemperatureUnits to get the units.

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/linuxport/XBMC@18045 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information
jmarshallnz committed Feb 24, 2009
1 parent 8bda426 commit 2148b3b
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 47 deletions.
22 changes: 11 additions & 11 deletions skin/PM3.HD/720p/MyWeather.xml
Expand Up @@ -58,7 +58,7 @@
<font>font35b</font>
<align>center</align>
<aligny>center</aligny>
<info>Window.Property(Current.Temperature)</info>
<label>$INFO[Window.Property(Current.Temperature)]$INFO[System.TemperatureUnits]</label>
<textcolor>white</textcolor>
<shadowcolor>black</shadowcolor>
</control>
Expand Down Expand Up @@ -154,7 +154,7 @@
<font>font12</font>
<align>left</align>
<aligny>center</aligny>
<info>Window.Property(Current.FeelsLike)</info>
<label>$INFO[Window.Property(Current.FeelsLike)]$INFO[System.TemperatureUnits]</label>
<textcolor>white</textcolor>
</control>
<control type="label">
Expand All @@ -165,7 +165,7 @@
<font>font12</font>
<align>left</align>
<aligny>center</aligny>
<info>Window.Property(Current.DewPoint)</info>
<label>$INFO[Window.Property(Current.DewPoint)]$INFO[System.TemperatureUnits]</label>
<textcolor>white</textcolor>
</control>
<control type="label">
Expand Down Expand Up @@ -259,7 +259,7 @@
<posx>110</posx>
<posy>50</posy>
<height>20</height>
<info>Window.Property(Day0.HighTemp)</info>
<label>$INFO[Window.Property(Day0.HighTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
<align>left</align>
<aligny>center</aligny>
Expand All @@ -282,7 +282,7 @@
<posx>290</posx>
<posy>50</posy>
<height>20</height>
<info>Window.Property(Day0.LowTemp)</info>
<label>$INFO[Window.Property(Day0.LowTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
<align>left</align>
<aligny>center</aligny>
Expand Down Expand Up @@ -358,7 +358,7 @@
<posx>110</posx>
<posy>50</posy>
<height>20</height>
<info>Window.Property(Day1.HighTemp)</info>
<label>$INFO[Window.Property(Day1.HighTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
<align>left</align>
<aligny>center</aligny>
Expand All @@ -381,7 +381,7 @@
<posx>290</posx>
<posy>50</posy>
<height>20</height>
<info>Window.Property(Day1.LowTemp)</info>
<label>$INFO[Window.Property(Day1.LowTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
<align>left</align>
<aligny>center</aligny>
Expand Down Expand Up @@ -457,7 +457,7 @@
<posx>110</posx>
<posy>50</posy>
<height>20</height>
<info>Window.Property(Day2.HighTemp)</info>
<label>$INFO[Window.Property(Day2.HighTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
<align>left</align>
<aligny>center</aligny>
Expand All @@ -480,7 +480,7 @@
<posx>290</posx>
<posy>50</posy>
<height>20</height>
<info>Window.Property(Day2.LowTemp)</info>
<label>$INFO[Window.Property(Day2.LowTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
<align>left</align>
<aligny>center</aligny>
Expand Down Expand Up @@ -556,7 +556,7 @@
<posx>110</posx>
<posy>50</posy>
<height>20</height>
<info>Window.Property(Day3.HighTemp)</info>
<label>$INFO[Window.Property(Day3.HighTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
<align>left</align>
<aligny>center</aligny>
Expand All @@ -579,7 +579,7 @@
<posx>290</posx>
<posy>50</posy>
<height>20</height>
<info>Window.Property(Day3.LowTemp)</info>
<label>$INFO[Window.Property(Day3.LowTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
<align>left</align>
<aligny>center</aligny>
Expand Down
22 changes: 11 additions & 11 deletions skin/Project Mayhem III/PAL/MyWeather.xml
Expand Up @@ -277,15 +277,15 @@
<description>current temp label</description>
<posx>335</posx>
<posy>168</posy>
<info>Window.Property(Current.Temperature)</info>
<label>$INFO[Window.Property(Current.Temperature)]$INFO[System.TemperatureUnits]</label>
<font>font10</font>
<include>contentpanelslide</include>
</control>
<control type="label">
<description>current feels like label</description>
<posx>335</posx>
<posy>188</posy>
<info>Window.Property(Current.FeelsLike)</info>
<label>$INFO[Window.Property(Current.FeelsLike)]$INFO[System.TemperatureUnits]</label>
<font>font10</font>
<include>contentpanelslide</include>
</control>
Expand All @@ -309,7 +309,7 @@
<description>current dew label</description>
<posx>335</posx>
<posy>208</posy>
<info>Window.Property(Current.DewPoint)</info>
<label>$INFO[Window.Property(Current.DewPoint)]$INFO[System.TemperatureUnits]</label>
<font>font10</font>
<include>contentpanelslide</include>
</control>
Expand Down Expand Up @@ -373,7 +373,7 @@
<description>high value</description>
<posx>160</posx>
<posy>30</posy>
<info>Window.Property(Day0.HighTemp)</info>
<label>$INFO[Window.Property(Day0.HighTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
</control>
<control type="label">
Expand All @@ -388,7 +388,7 @@
<description>low value</description>
<posx>160</posx>
<posy>50</posy>
<info>Window.Property(Day0.LowTemp)</info>
<label>$INFO[Window.Property(Day0.LowTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
</control>
<control type="label">
Expand Down Expand Up @@ -452,7 +452,7 @@
<description>high value</description>
<posx>160</posx>
<posy>30</posy>
<info>Window.Property(Day1.HighTemp)</info>
<label>$INFO[Window.Property(Day1.HighTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
</control>
<control type="label">
Expand All @@ -467,7 +467,7 @@
<description>low value</description>
<posx>160</posx>
<posy>50</posy>
<info>Window.Property(Day1.LowTemp)</info>
<label>$INFO[Window.Property(Day1.LowTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
</control>
<control type="label">
Expand Down Expand Up @@ -531,7 +531,7 @@
<description>high value</description>
<posx>160</posx>
<posy>30</posy>
<info>Window.Property(Day2.HighTemp)</info>
<label>$INFO[Window.Property(Day2.HighTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
</control>
<control type="label">
Expand All @@ -546,7 +546,7 @@
<description>low value</description>
<posx>160</posx>
<posy>50</posy>
<info>Window.Property(Day2.LowTemp)</info>
<label>$INFO[Window.Property(Day2.LowTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
</control>
<control type="label">
Expand Down Expand Up @@ -610,7 +610,7 @@
<description>high value</description>
<posx>160</posx>
<posy>30</posy>
<info>Window.Property(Day3.HighTemp)</info>
<label>$INFO[Window.Property(Day3.HighTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
</control>
<control type="label">
Expand All @@ -625,7 +625,7 @@
<description>low value</description>
<posx>160</posx>
<posy>50</posy>
<info>Window.Property(Day3.LowTemp)</info>
<label>$INFO[Window.Property(Day3.LowTemp)]$INFO[System.TemperatureUnits]</label>
<font>font12</font>
</control>
<control type="label">
Expand Down
16 changes: 10 additions & 6 deletions xbmc/GUIWindowWeather.cpp
Expand Up @@ -192,10 +192,14 @@ void CGUIWindowWeather::UpdateButtons()
SET_CONTROL_LABEL(WEATHER_LABEL_LOCATION, g_weatherManager.GetLocation(m_iCurWeather));
SET_CONTROL_LABEL(CONTROL_LABELUPDATED, g_weatherManager.GetLastUpdateTime());

for (DWORD dwID = WEATHER_LABEL_CURRENT_COND; dwID <= WEATHER_LABEL_CURRENT_HUMI; dwID++)
{
SET_CONTROL_LABEL(dwID, g_weatherManager.GetInfo(dwID));
}
SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_COND, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND));
SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_TEMP, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP) + g_langInfo.GetTempUnitString());
SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_FEEL, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_FEEL) + g_langInfo.GetTempUnitString());
SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_UVID, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_UVID));
SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_WIND, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_WIND));
SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_DEWP, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_DEWP) + g_langInfo.GetTempUnitString());
SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_HUMI, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_HUMI));

CGUIImage *pImage = (CGUIImage *)GetControl(WEATHER_IMAGE_CURRENT_ICON);
if (pImage) pImage->SetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON));

Expand All @@ -210,8 +214,8 @@ void CGUIWindowWeather::UpdateButtons()
for (int i = 0; i < NUM_DAYS; i++)
{
SET_CONTROL_LABEL(CONTROL_LABELD0DAY + (i*10), g_weatherManager.m_dfForcast[i].m_szDay);
SET_CONTROL_LABEL(CONTROL_LABELD0HI + (i*10), g_weatherManager.m_dfForcast[i].m_szHigh);
SET_CONTROL_LABEL(CONTROL_LABELD0LOW + (i*10), g_weatherManager.m_dfForcast[i].m_szLow);
SET_CONTROL_LABEL(CONTROL_LABELD0HI + (i*10), g_weatherManager.m_dfForcast[i].m_szHigh + g_langInfo.GetTempUnitString());
SET_CONTROL_LABEL(CONTROL_LABELD0LOW + (i*10), g_weatherManager.m_dfForcast[i].m_szLow + g_langInfo.GetTempUnitString());
SET_CONTROL_LABEL(CONTROL_LABELD0GEN + (i*10), g_weatherManager.m_dfForcast[i].m_szOverview);
pImage = (CGUIImage *)GetControl(CONTROL_IMAGED0IMG + (i * 10));
if (pImage) pImage->SetFileName(g_weatherManager.m_dfForcast[i].m_szIcon);
Expand Down
18 changes: 12 additions & 6 deletions xbmc/Temperature.cpp
Expand Up @@ -441,13 +441,11 @@ double CTemperature::ToNewton() const
return (m_value-32.0f)*11.0f/60.0f;
}

// Returns temperature as localized string
CStdString CTemperature::ToString() const
double CTemperature::ToLocale() const
{
if (!IsValid())
return g_localizeStrings.Get(13205); // "Unknown"

double value=0.0;
return 0;
double value = 0.0;

switch(g_langInfo.GetTempUnit())
{
Expand Down Expand Up @@ -479,9 +477,17 @@ CStdString CTemperature::ToString() const
ASSERT(false);
break;
}
return value;
}

// Returns temperature as localized string
CStdString CTemperature::ToString() const
{
if (!IsValid())
return g_localizeStrings.Get(13205); // "Unknown"

CStdString str;
str.Format("%2.0f%s", value, g_langInfo.GetTempUnitString().c_str());
str.Format("%2.0f%s", ToLocale(), g_langInfo.GetTempUnitString().c_str());

return str;
}
1 change: 1 addition & 0 deletions xbmc/Temperature.h
Expand Up @@ -95,6 +95,7 @@ class CTemperature : public ISerializable
double ToDelisle() const;
double ToNewton() const;

double ToLocale() const;
CStdString ToString() const;

protected:
Expand Down
6 changes: 5 additions & 1 deletion xbmc/utils/GUIInfoManager.cpp
Expand Up @@ -332,6 +332,7 @@ int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition)
else if (strTest.Equals("system.memory(total)")) ret = SYSTEM_TOTAL_MEMORY;

else if (strTest.Equals("system.language")) ret = SYSTEM_LANGUAGE;
else if (strTest.Equals("system.temperatureunits")) ret = SYSTEM_TEMPERATURE_UNITS;
else if (strTest.Equals("system.screenmode")) ret = SYSTEM_SCREEN_MODE;
else if (strTest.Equals("system.screenwidth")) ret = SYSTEM_SCREEN_WIDTH;
else if (strTest.Equals("system.screenheight")) ret = SYSTEM_SCREEN_HEIGHT;
Expand Down Expand Up @@ -934,7 +935,7 @@ CStdString CGUIInfoManager::GetLabel(int info, DWORD contextWindow)
strLabel = strLabel.Trim();
break;
case WEATHER_TEMPERATURE:
strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP);
strLabel.Format("%s%s", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP), g_langInfo.GetTempUnitString().c_str());
break;
case WEATHER_LOCATION:
strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_LOCATION);
Expand Down Expand Up @@ -1266,6 +1267,9 @@ CStdString CGUIInfoManager::GetLabel(int info, DWORD contextWindow)
case SYSTEM_LANGUAGE:
strLabel = g_guiSettings.GetString("locale.language");
break;
case SYSTEM_TEMPERATURE_UNITS:
strLabel = g_langInfo.GetTempUnitString();
break;
case SYSTEM_PROGRESS_BAR:
{
int percent = GetInt(SYSTEM_PROGRESS_BAR);
Expand Down
1 change: 1 addition & 0 deletions xbmc/utils/GUIInfoManager.h
Expand Up @@ -104,6 +104,7 @@ class CDateTime;
#define WEATHER_IS_FETCHED 103
#define WEATHER_FANART_CODE 104

#define SYSTEM_TEMPERATURE_UNITS 106
#define SYSTEM_PROGRESS_BAR 107
#define SYSTEM_LANGUAGE 108
#define SYSTEM_TIME 110
Expand Down
10 changes: 5 additions & 5 deletions xbmc/utils/Weather.cpp
Expand Up @@ -352,10 +352,10 @@ bool CWeather::LoadWeather(const CStdString &weatherXML)

GetInteger(pElement, "tmp", iTmpInt); //current temp
CTemperature temp=CTemperature::CreateFromCelsius(iTmpInt);
sprintf(m_szCurrentTemperature, "%s", temp.ToString().c_str());
sprintf(m_szCurrentTemperature, "%2.0f", temp.ToLocale());
GetInteger(pElement, "flik", iTmpInt); //current 'Feels Like'
CTemperature tempFlik=CTemperature::CreateFromCelsius(iTmpInt);
sprintf(m_szCurrentFeelsLike, "%s", tempFlik.ToString().c_str());
sprintf(m_szCurrentFeelsLike, "%2.0f", tempFlik.ToLocale());

TiXmlElement *pNestElement = pElement->FirstChildElement("wind"); //current wind
if (pNestElement)
Expand Down Expand Up @@ -397,7 +397,7 @@ bool CWeather::LoadWeather(const CStdString &weatherXML)

GetInteger(pElement, "dewp", iTmpInt); //current dew point
CTemperature dewPoint=CTemperature::CreateFromCelsius(iTmpInt);
sprintf(m_szCurrentDewPoint, "%s", dewPoint.ToString().c_str());
sprintf(m_szCurrentDewPoint, "%2.0f", dewPoint.ToLocale());
}
//future forcast
pElement = pRootElement->FirstChildElement("dayf");
Expand All @@ -421,7 +421,7 @@ bool CWeather::LoadWeather(const CStdString &weatherXML)
else
{
CTemperature temp=CTemperature::CreateFromCelsius(atoi(iTmpStr));
sprintf(m_dfForcast[i].m_szHigh, "%s", temp.ToString().c_str());
sprintf(m_dfForcast[i].m_szHigh, "%2.0f", temp.ToLocale());
}

GetString(pOneDayElement, "low", iTmpStr, "");
Expand All @@ -430,7 +430,7 @@ bool CWeather::LoadWeather(const CStdString &weatherXML)
else
{
CTemperature temp=CTemperature::CreateFromCelsius(atoi(iTmpStr));
sprintf(m_dfForcast[i].m_szLow, "%s", temp.ToString().c_str());
sprintf(m_dfForcast[i].m_szLow, "%2.0f", temp.ToLocale());
}

TiXmlElement *pDayTimeElement = pOneDayElement->FirstChildElement("part"); //grab the first day/night part (should be day)
Expand Down
7 changes: 0 additions & 7 deletions xbmc/utils/Weather.h
Expand Up @@ -65,13 +65,6 @@ class CWeather : public CInfoLoader

char *GetLocation(int iLocation);
char *GetLastUpdateTime() { return m_szLastUpdateTime; };
char *GetCurrentConditions() { return m_szCurrentConditions; };
char *GetCurrentTemperature() { return m_szCurrentTemperature; };
char *GetCurrentFeelsLike() { return m_szCurrentFeelsLike; };
char *GetCurrentUVIndex() { return m_szCurrentUVIndex; };
char *GetCurrentWind() { return m_szCurrentWind; };
char *GetCurrentDewPoint() { return m_szCurrentDewPoint; };
char *GetCurrentHumidity() { return m_szCurrentHumidity; };
bool IsFetched();
void Reset();

Expand Down

0 comments on commit 2148b3b

Please sign in to comment.