Added support for custom weather icon

fonts_experiment 1.0.2.7
Valeriy Mironov 2018-01-13 17:43:09 +02:00
parent 3e6f8c44fe
commit 7ef631924d
4 changed files with 33 additions and 2 deletions

View File

@ -0,0 +1,21 @@
using WatchFace.Parser.Attributes;
namespace WatchFace.Parser.Elements.WeatherElements
{
public class CustomWeatherIcon
{
[ParameterId(1)]
public long X { get; set; }
[ParameterId(2)]
public long Y { get; set; }
[ParameterId(3)]
[ParameterImageIndex]
public long ImageIndex { get; set; }
[ParameterId(4)]
[ParameterImagesCount]
public long ImagesCount { get; set; }
}
}

View File

@ -10,7 +10,8 @@ namespace WatchFace.Parser.Elements.WeatherElements
[ParameterId(1)]
public Coordinates Coordinates { get; set; }
// TODO: Looks like here should be Id 2 also
[ParameterId(2)]
public CustomWeatherIcon CustomIcon { get; set; }
[ParameterId(3)]
public Coordinates CoordinatesAlt { get; set; }

View File

@ -10,6 +10,7 @@ namespace WatchFace.Parser.Models.Elements
base(parameter, parent, name) { }
public CoordinatesElement Current { get; set; }
public ImageSetElement CustomIcon { get; set; }
public CoordinatesElement CurrentAlt { get; set; }
public CoordinatesElement Unknown4 { get; set; }
@ -18,7 +19,11 @@ namespace WatchFace.Parser.Models.Elements
var useAltCoordinates = CurrentAlt != null && state.CurrentTemperature == null;
var iconCoordinates = useAltCoordinates ? CurrentAlt : Current;
drawer.DrawImage(LoadWeatherImage(state.CurrentWeather), iconCoordinates.X, iconCoordinates.Y);
if (iconCoordinates != null)
drawer.DrawImage(LoadWeatherImage(state.CurrentWeather), iconCoordinates.X, iconCoordinates.Y);
if (CustomIcon != null)
drawer.DrawImage(resources[CustomIcon.ImageIndex + 1], CustomIcon.X, CustomIcon.Y);
}
private static Bitmap LoadWeatherImage(WeatherCondition weather)
@ -35,6 +40,9 @@ namespace WatchFace.Parser.Models.Elements
case 1:
Current = new CoordinatesElement(parameter, this);
return Current;
case 2:
CustomIcon = new ImageSetElement(parameter, this);
return CustomIcon;
case 3:
CurrentAlt = new CoordinatesElement(parameter, this);
return CurrentAlt;

View File

@ -73,6 +73,7 @@
<Compile Include="Elements\TimeElements\AmPm.cs" />
<Compile Include="Elements\TimeElements\TwoDigits.cs" />
<Compile Include="Elements\Weather.cs" />
<Compile Include="Elements\WeatherElements\CustomWeatherIcon.cs" />
<Compile Include="Elements\WeatherElements\AirPollution.cs" />
<Compile Include="Elements\WeatherElements\OneLineTemperature.cs" />
<Compile Include="Elements\WeatherElements\SeparateTemperature.cs" />