Skip to content

Commit

Permalink
0.8.1829.34599
Browse files Browse the repository at this point in the history
  • Loading branch information
gro-ove committed Oct 1, 2018
1 parent cd50693 commit 405b59a
Show file tree
Hide file tree
Showing 69 changed files with 768 additions and 410 deletions.
6 changes: 3 additions & 3 deletions AcManager.Controls/ControlsStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions AcManager.Controls/Themes/CarBlock.xaml
Expand Up @@ -37,9 +37,9 @@
</DockPanel>
</mui:BooleanSwitch>
<mui:PlaceholderTextBlock c:PropertiesGrid.Label="Total driven:" Placeholder=""
Text="{Binding TotalDrivenDistance, Converter={StaticResource MultiplyConverter}, ConverterParameter=1e-3, StringFormat='{}{0:F1} km'}" />
Text="{Binding TotalDrivenDistanceKm, Converter={StaticResource MultiplyConverter}, ConverterParameter={x:Static t:SettingsHolder+CommonSettings.DistanceMultiplier}, StringFormat={x:Static t:SettingsHolder+CommonSettings.DistanceFormat}}" />
<mui:PlaceholderTextBlock c:PropertiesGrid.Label="Speed achieved:" Placeholder=""
Text="{Binding MaxSpeedAchieved, StringFormat='{}{0:F1} km/h'}"
Text="{Binding MaxSpeedAchieved, Converter={StaticResource MultiplyConverter}, ConverterParameter={x:Static t:SettingsHolder+CommonSettings.DistanceMultiplier}, StringFormat={x:Static t:SettingsHolder+CommonSettings.SpeedFormat}}"
Visibility="{Binding MaxSpeedAchieved, Converter={StaticResource EnumToVisibilityConverter}, ConverterParameter='≠0'}" />
<mui:PlaceholderTextBlock c:PropertiesGrid.Label="Steer lock:" Placeholder="" Text="{Binding SteerLock, StringFormat='{}{0:F0}°'}"
Visibility="{Binding DisplaySteerLock, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Static t:SettingsHolder.Content}}" />
Expand Down Expand Up @@ -165,9 +165,9 @@
</DockPanel>
</mui:BooleanSwitch>
<mui:PlaceholderTextBlock c:PropertiesGrid.Label="Total driven:" Placeholder=""
Text="{Binding TotalDrivenDistance, Converter={StaticResource MultiplyConverter}, ConverterParameter=1e-3, StringFormat='{}{0:F1} km'}" />
Text="{Binding TotalDrivenDistanceKm, Converter={StaticResource MultiplyConverter}, ConverterParameter={x:Static t:SettingsHolder+CommonSettings.DistanceMultiplier}, StringFormat={x:Static t:SettingsHolder+CommonSettings.DistanceFormat}}" />
<mui:PlaceholderTextBlock c:PropertiesGrid.Label="Speed achieved:" Placeholder=""
Text="{Binding MaxSpeedAchieved, StringFormat='{}{0:F1} km/h'}"
Text="{Binding MaxSpeedAchieved, Converter={StaticResource MultiplyConverter}, ConverterParameter={x:Static t:SettingsHolder+CommonSettings.DistanceMultiplier}, StringFormat={x:Static t:SettingsHolder+CommonSettings.SpeedFormat}}"
Visibility="{Binding MaxSpeedAchieved, Converter={StaticResource EnumToVisibilityConverter}, ConverterParameter='≠0'}" />
<mui:PlaceholderTextBlock c:PropertiesGrid.Label="Steer lock:" Placeholder="" Text="{Binding SteerLock, StringFormat='{}{0:F0}°'}"
Visibility="{Binding DisplaySteerLock, Converter={StaticResource BooleanToVisibilityConverter}, Source={x:Static t:SettingsHolder.Content}}" />
Expand Down
16 changes: 12 additions & 4 deletions AcManager.Controls/Themes/RaceGridEditorTable.xaml
Expand Up @@ -234,8 +234,12 @@

<DockPanel DataContext="{Binding AiLimitationDetails.FinalGearRatio}" Margin="0 8 0 0"
Visibility="{Binding Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=inverse}">
<TextBlock Text="{Binding RatioMaxSpeed, StringFormat='Maximum speed: {0:F1} km/h'}" Style="{StaticResource Small}" DockPanel.Dock="Bottom"
Margin="0 4 0 0" Visibility="{Binding RatioMaxSpeed, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=inverse}" />
<TextBlock Style="{StaticResource Small}" DockPanel.Dock="Bottom" Margin="0 4 0 0"
Visibility="{Binding RatioMaxSpeed, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=inverse}">
<Run Text="Maximum speed: " />
<Run
Text="{Binding RatioMaxSpeed, Mode=OneWay, ConverterParameter={x:Static t:SettingsHolder+CommonSettings.DistanceMultiplier}, StringFormat={x:Static t:SettingsHolder+CommonSettings.SpeedFormat}}" />
</TextBlock>
<TextBlock Text="{Binding DisplayName, StringFormat={x:Static mui:ColonConverter.FormatNoSpaceAfterwards}}" Margin="0 2 0 4" Width="100"
DockPanel.Dock="Left" Style="{StaticResource Label}" VerticalAlignment="Top" />
<mui:BetterComboBox SelectedItem="{Binding ValuePair}" ItemsSource="{Binding Values}" IsEditable="False" DisplayMemberPath="Key"
Expand Down Expand Up @@ -295,8 +299,12 @@

<DockPanel DataContext="{Binding AiLimitationDetails.FinalGearRatio}" Margin="0 8 0 0"
Visibility="{Binding Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=inverse}">
<TextBlock Text="{Binding RatioMaxSpeed, StringFormat='Maximum speed: {0:F1} km/h'}" Style="{StaticResource Small}" DockPanel.Dock="Bottom"
Margin="0 4 0 0" Visibility="{Binding RatioMaxSpeed, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=inverse}" />
<TextBlock Style="{StaticResource Small}" DockPanel.Dock="Bottom" Margin="0 4 0 0"
Visibility="{Binding RatioMaxSpeed, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=inverse}">
<Run Text="Maximum speed: " />
<Run
Text="{Binding RatioMaxSpeed, Mode=OneWay, ConverterParameter={x:Static t:SettingsHolder+CommonSettings.DistanceMultiplier}, StringFormat={x:Static t:SettingsHolder+CommonSettings.SpeedFormat}}" />
</TextBlock>
<TextBlock Text="{Binding DisplayName, StringFormat={x:Static mui:ColonConverter.FormatNoSpaceAfterwards}}" Margin="0 2 0 4" Width="100"
DockPanel.Dock="Left" Style="{StaticResource Label}" VerticalAlignment="Top" />
<mui:BetterComboBox SelectedItem="{Binding ValuePair}" ItemsSource="{Binding Values}" IsEditable="False" DisplayMemberPath="Key"
Expand Down
6 changes: 3 additions & 3 deletions AcManager.Controls/Themes/TrackBlock.xaml
@@ -1,6 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:AcManager.Controls" xmlns:mui="http://firstfloorsoftware.com/ModernUI" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:t="http://acstuff.ru/app/tools" mc:Ignorable="d">
<ResourceDictionary.MergedDictionaries>
<mui:SharedResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/Converters.xaml" />
<mui:SharedResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/TextBlock.xaml" />
Expand All @@ -27,7 +27,7 @@
<c:PropertiesGrid Columns="1" LabelPadding="0 1 0 0" VerticalSpacing="4">
<c:RatingBar c:PropertiesGrid.Label="Rating:" Rating="{Binding MainTrackObject.Rating}" HorizontalAlignment="Left" />
<mui:PlaceholderTextBlock c:PropertiesGrid.Label="Total driven:" Placeholder=""
Text="{Binding TotalDrivenDistance, Converter={StaticResource MultiplyConverter}, ConverterParameter=1e-3, StringFormat='{}{0:F1} km'}" />
Text="{Binding TotalDrivenDistanceKm, Converter={StaticResource MultiplyConverter}, ConverterParameter={x:Static t:SettingsHolder+CommonSettings.DistanceMultiplier}, StringFormat={x:Static t:SettingsHolder+CommonSettings.DistanceFormat}}" />
</c:PropertiesGrid>
<c:BestLapsList TrackId="{Binding IdWithLayout}" Margin="0 4 0 0" Limit="10" />
</StackPanel>
Expand Down Expand Up @@ -124,7 +124,7 @@
<c:PropertiesGrid Columns="1" LabelPadding="0 1 0 0" VerticalSpacing="4">
<c:RatingBar c:PropertiesGrid.Label="Rating:" Rating="{Binding MainTrackObject.Rating}" HorizontalAlignment="Left" />
<mui:PlaceholderTextBlock c:PropertiesGrid.Label="Total driven:" Placeholder=""
Text="{Binding TotalDrivenDistance, Converter={StaticResource MultiplyConverter}, ConverterParameter=1e-3, StringFormat='{}{0:F1} km'}" />
Text="{Binding TotalDrivenDistanceKm, Converter={StaticResource MultiplyConverter}, ConverterParameter={x:Static t:SettingsHolder+CommonSettings.DistanceMultiplier}, StringFormat={x:Static t:SettingsHolder+CommonSettings.DistanceFormat}}" />
</c:PropertiesGrid>
<c:BestLapsList TrackId="{Binding IdWithLayout}" Margin="0 4 0 0" Limit="10" />
</StackPanel>
Expand Down
5 changes: 4 additions & 1 deletion AcManager.Controls/UserControls/Cef/CefSharpWrapper.cs
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -239,8 +240,10 @@ internal class CefSharpWrapper : IWebSomething, IDisplayHandler {

public bool CanConvertFilenames => true;

private static readonly Regex PathUrlFix = new Regex("^file(?=://)", RegexOptions.Compiled | RegexOptions.IgnoreCase);

public string ConvertFilename(string filename) {
return filename == null ? null : new Uri(filename, UriKind.Absolute).AbsoluteUri.Replace(@"file", AltFilesHandlerFactory.SchemeName);
return filename == null ? null : PathUrlFix.Replace(new Uri(filename, UriKind.Absolute).AbsoluteUri, AltFilesHandlerFactory.SchemeName);
}

public ICommand BackCommand => _inner?.BackCommand ?? UnavailableCommand.Instance;
Expand Down
20 changes: 19 additions & 1 deletion AcManager.Controls/UserControls/Web/AcCompatibleApiBridge.cs
Expand Up @@ -86,13 +86,31 @@ public class AcCompatibleApiBridge : JsBridgeBase {
}
function getSkins(car){ return car._skins || (car._skins = JSON.parse(window.external.GetSkins(car.id))); }
function getSkinMeta(car){ return car._skinmeta || (car._skinmeta = JSON.parse(window.external.GetSkinMeta(car.id))); }
function find(a, f, p1, p2) { return p1 && a.filter(function (n){ return (p2 ? n[p1][p2] : n[p1]).indexOf(f) > -1; }); }
function find(a, f, p1, p2) {
if (p1 === 'id') window.external.SetLastAccessed(f, a === __AC.CarsArray);
return p1 && a.filter(function (n){ return (p2 ? n[p1][p2] : n[p1]).indexOf(f) > -1; });
}
window.__AC.findCar = find.bind(null, __AC.CarsArray);
window.__AC.findTrack = find.bind(null, __AC.TracksArray);
}()</script>");
}
}

[UsedImplicitly]
public void SetLastAccessed(string id, bool car) {
Logging.Debug($"Last accessed: {id} (car: {car})");
if (car) {
_raceConfig["RACE"]["MODEL"] = id;
_raceConfig["CAR_0"]["MODEL"] = id;
} else {
var track = TracksManager.Instance.GetLayoutByKunosId(id);
if (track != null) {
_raceConfig["RACE"]["TRACK"] = track.Id;
_raceConfig["RACE"]["CONFIG_TRACK"] = track.LayoutId;
}
}
}

[UsedImplicitly]
public string GetSkins(string carId) {
var car = CarsManager.Instance.GetById(carId);
Expand Down
3 changes: 2 additions & 1 deletion AcManager.Controls/ViewModels/TrackStateViewModel.cs
Expand Up @@ -50,6 +50,7 @@ public class TrackStateViewModel : TrackStateViewModelBase, IUserPresetable, IUs
private static double? LoadGrip(string data) {
try {
var o = JObject.Parse(data);
if (o["w"].As(false)) return -1d;
return o["s"].As<double>();
} catch (Exception e) {
Logging.Error(e.Message);
Expand All @@ -59,7 +60,7 @@ public class TrackStateViewModel : TrackStateViewModelBase, IUserPresetable, IUs

string IUserPresetableCustomDisplay.GetDisplayName(string name, string data) {
var g = LoadGrip(data);
return g.HasValue ? $"{name} ({g.Value * 100:F0}%)" : $"{name} (?)";
return g.HasValue ? g == -1d ? name : $"{name} ({g.Value * 100:F0}%)" : $"{name} (?)";
}

int IUserPresetableCustomSorting.Compare(string aName, string aData, string bName, string bData) {
Expand Down
26 changes: 24 additions & 2 deletions AcManager.Controls/ViewModels/TrackStateViewModelBase.cs
Expand Up @@ -14,6 +14,13 @@ public class TrackStateViewModelBase : NotifyPropertyChanged {
public static readonly PresetsCategory PresetableCategory = new PresetsCategory("Track States");

#region Properties
private bool _weatherDefined;

public bool WeatherDefined {
get => _weatherDefined;
set => Apply(value, ref _weatherDefined);
}

private double _gripStart;

public double GripStart {
Expand Down Expand Up @@ -104,6 +111,9 @@ private class SaveableData {

[JsonProperty("d")]
public string Description;

[JsonProperty("w")]
public bool WeatherDefined;
}

protected virtual void SaveLater() {
Expand All @@ -118,13 +128,15 @@ private class SaveableData {
GripTransfer = GripTransfer,
GripRandomness = GripRandomness,
LapGain = LapGain,
Description = Description
Description = Description,
WeatherDefined = WeatherDefined,
}, o => {
GripStart = o.GripStart;
GripTransfer = o.GripTransfer;
GripRandomness = o.GripRandomness;
LapGain = o.LapGain;
Description = o.Description;
WeatherDefined = o.WeatherDefined;
});
}

Expand Down Expand Up @@ -172,7 +184,17 @@ private class SaveableData {
/// save any changes if they will occur.
/// </summary>
/// <param name="section">INI-file section.</param>
public static TrackStateViewModelBase CreateBuiltIn([NotNull] IniFileSection section) {
public static TrackStateViewModelBase CreateBuiltIn([CanBeNull] IniFileSection section) {
if (section == null) {
return new TrackStateViewModelBase(null, false) {
WeatherDefined = true,
GripStart = 95d / 100d,
GripRandomness = 2d / 100d,
LapGain = 132,
Description = "Track state specified by weather, or Green, in case weather doesn’t specify track state"
};
}

return new TrackStateViewModelBase(null, false) {
GripStart = section.GetDouble("SESSION_START", 95d) / 100d,
GripTransfer = section.GetDouble("SESSION_TRANSFER", 90d) / 100d,
Expand Down
5 changes: 4 additions & 1 deletion AcManager.Controls/ViewModels/TrackStatesHelper.cs
Expand Up @@ -48,7 +48,7 @@ public class TrackStatesHelper : IDisposable {
await Task.Delay(300);
(Application.Current?.Dispatcher ?? Dispatcher.CurrentDispatcher).Invoke(RegisterBuiltInPresets);
break;
} catch (IOException) {}
} catch (IOException) { }
}
} finally {
_inProgress = false;
Expand Down Expand Up @@ -76,6 +76,9 @@ public class TrackStatesHelper : IDisposable {

private void RegisterBuiltInPresets() {
PresetsManager.Instance.ClearBuiltInPresets(TrackStateViewModelBase.PresetableCategory);
PresetsManager.Instance.RegisterBuiltInPreset(TrackStateViewModelBase.CreateBuiltIn(null).ToBytes(),
TrackStateViewModelBase.PresetableCategory, "Auto (set by weather)");

foreach (var preset in GetBuiltInPresets()) {
PresetsManager.Instance.RegisterBuiltInPreset(preset.Item2.ToBytes(), TrackStateViewModelBase.PresetableCategory, preset.Item1);
}
Expand Down
13 changes: 13 additions & 0 deletions AcManager.Tools/AcManager.Tools.csproj
Expand Up @@ -95,6 +95,14 @@
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="TimeZoneConverter, Version=2.4.1.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\TimeZoneConverter.2.4.1\lib\net45\TimeZoneConverter.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Unosquare.Labs.EmbedIO, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\Unosquare.Labs.EmbedIO\Unosquare.Labs.EmbedIO.dll</HintPath>
Expand Down Expand Up @@ -249,7 +257,9 @@
<Compile Include="GameProperties\CarSpecificControlsPresetHelper.cs" />
<Compile Include="GameProperties\CarSpecificHelperBase.cs" />
<Compile Include="GameProperties\ContinueRaceHelper.cs" />
<Compile Include="GameProperties\CustomTrackState.cs" />
<Compile Include="GameProperties\DBoxIntegration.cs" />
<Compile Include="GameProperties\DrivenDistance.cs" />
<Compile Include="GameProperties\ExtraHotkeysRaceHelper.cs" />
<Compile Include="GameProperties\ImmediateCancelHelper.cs" />
<Compile Include="GameProperties\InGameApp\CmInGameAppDelayedInputParams.cs" />
Expand All @@ -259,6 +269,9 @@
<Compile Include="GameProperties\ModeSpecificPresetsHelper.cs" />
<Compile Include="GameProperties\NationCodeProvider.cs" />
<Compile Include="GameProperties\RhmService.cs" />
<Compile Include="GameProperties\TrackDetails.cs" />
<Compile Include="GameProperties\WeatherDetails.cs" />
<Compile Include="GameProperties\WeatherSpecificDate.cs" />
<Compile Include="GameProperties\TemporaryFileReplacement.cs" />
<Compile Include="GameProperties\ScreenshotsConverter.cs" />
<Compile Include="GameProperties\RaceCommandExecutor.cs" />
Expand Down

0 comments on commit 405b59a

Please sign in to comment.