Skip to content

Commit

Permalink
0.8.1846.34878
Browse files Browse the repository at this point in the history
  • Loading branch information
gro-ove committed Oct 17, 2018
1 parent cb7faee commit 7135668
Show file tree
Hide file tree
Showing 46 changed files with 1,306 additions and 220 deletions.
89 changes: 67 additions & 22 deletions AcManager.Controls/Assets/AcSettingsSpecific.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns:acs="clr-namespace:AcManager.Tools.Helpers.AcSettingsControls;assembly=AcManager.Tools" xmlns:mui="http://firstfloorsoftware.com/ModernUI"
xmlns:c="clr-namespace:AcManager.Controls" xmlns:acset="clr-namespace:AcManager.Tools.Helpers.AcSettings;assembly=AcManager.Tools"
xmlns:t="http://acstuff.ru/app/tools" xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:helpers="clr-namespace:AcManager.Controls.Helpers">
xmlns:helpers="clr-namespace:AcManager.Controls.Helpers" xmlns:se="clr-namespace:AcManager.Controls.Services">
<ResourceDictionary.MergedDictionaries>
<mui:SharedResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/TextBlock.xaml" />
<mui:SharedResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/Converters.xaml" />
Expand Down Expand Up @@ -286,8 +286,8 @@
</mui:Cell>
</Button>

<Button Grid.Column="2" ToolTip="Steering wheel button (secondary; binded keyboard button is required)" DataContext="{Binding WheelButtonAlt}" Margin="4 0 0 0"
Command="{Binding ToggleWaitingCommand, Source={x:Static acset:AcSettingsHolder.Controls}}" CommandParameter="{Binding}"
<Button Grid.Column="2" ToolTip="Steering wheel button (secondary; binded keyboard button is required)" DataContext="{Binding WheelButtonAlt}"
Margin="4 0 0 0" Command="{Binding ToggleWaitingCommand, Source={x:Static acset:AcSettingsHolder.Controls}}" CommandParameter="{Binding}"
Style="{StaticResource WaitingButton}" ToolTipService.ShowOnDisabled="True">
<Button.IsEnabled>
<MultiBinding Converter="{StaticResource AndConverter}">
Expand Down Expand Up @@ -450,26 +450,36 @@
</Style>

<DataTemplate x:Key="PythonAppConfig.ItemTemplate" DataType="t:PythonAppConfigValue">
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsNonDefault}" Value="True">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource Accent}" />
</DataTrigger>
</DataTemplate.Triggers>
<Border mui:ContextMenuAdvancement.PropagateToChildren="True" Background="Transparent">
<FrameworkElement.ContextMenu>
<ContextMenu IsEnabled="{Binding IsResettable}">
<MenuItem Header="{x:Static c:ControlsStrings.Common_Reset}" Command="{Binding ResetCommand}" />
<MenuItem Header="{x:Static c:ControlsStrings.Common_Reset}" Command="{Binding ResetCommand}" IsEnabled="{Binding IsNonDefault}" />
</ContextMenu>
</FrameworkElement.ContextMenu>

<ContentControl Content="{Binding}" ToolTip="{Binding ToolTip}" IsEnabled="{Binding IsEnabled}">
<ContentControl.Resources>
<DataTemplate DataType="{x:Type t:PythonAppConfigBoolValue}">
<CheckBox IsChecked="{Binding Value}">
<Label Content="{Binding DisplayName}" />
<CheckBox IsChecked="{Binding Value}" Height="23" VerticalAlignment="Top">
<Label x:Name="Label" Content="{Binding DisplayName}" />
</CheckBox>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsNonDefault}" Value="True">
<Setter Property="Foreground" Value="{DynamicResource Accent}" TargetName="Label" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>

<DataTemplate DataType="{x:Type t:PythonAppConfigRangeValue}">
<DockPanel>
<mui:ValueLabel Content="{Binding DisplayName}" Value="{Binding Value}" mui:BetterTextBox.Mode="Number" Postfix="{Binding Postfix}"
<mui:ValueLabel Content="{Binding DisplayName}" Value="{Binding DisplayValue}" mui:BetterTextBox.Mode="Number" Postfix="{Binding DisplayPostix}"
Style="{StaticResource PythonAppConfig.ValueLabel}" />
<Slider Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Value="{Binding Value}" TickFrequency="{Binding Tick}"
<Slider Minimum="{Binding Minimum.Value}" Maximum="{Binding Maximum.Value}" Value="{Binding Value}" TickFrequency="{Binding Tick}"
TickPlacement="BottomRight" />
</DockPanel>
</DataTemplate>
Expand All @@ -485,7 +495,8 @@
<TextBlock Text="{Binding DisplayName, StringFormat={x:Static mui:ColonConverter.FormatNoSpaceAfterwards}}" Style="{StaticResource Label}"
DockPanel.Dock="Left" Margin="0 0 8 0" Width="120" TextAlignment="Left" />
<Button CommandParameter="{Binding}" Style="{StaticResource WaitingButton}" Margin="0 0 8 0"
Command="{Binding KeyBindingsController.ToggleWaitingCommand, RelativeSource={RelativeSource AncestorType=helpers:ILocalKeyBindings}}">
Command="{Binding KeyBindingsController.ToggleWaitingCommand, RelativeSource={RelativeSource AncestorType=helpers:ILocalKeyBindings}}"
Height="23" VerticalAlignment="Top">
<mui:Cell>
<mui:Cell Visibility="{Binding IsWaiting, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter='inverse hidden'}">
<TextBlock Text="{Binding DisplayValue}" FontWeight="Bold" HorizontalAlignment="Left" TextTrimming="CharacterEllipsis" />
Expand All @@ -506,15 +517,16 @@
<DockPanel>
<Label Content="{Binding DisplayName}" ContentStringFormat="{x:Static mui:ColonConverter.FormatNoSpaceAfterwards}"
Style="{StaticResource PythonAppConfig.PropertyLabel}" />
<mui:BetterTextBox Text="{Binding Value}" Mode="Number" Placeholder="?" />
<mui:BetterTextBox Text="{Binding Value}" Mode="Number" Placeholder="?" Height="23" VerticalAlignment="Top" />
</DockPanel>
</DataTemplate>

<DataTemplate DataType="{x:Type t:PythonAppConfigOptionsValue}">
<DockPanel>
<Label Content="{Binding DisplayName}" ContentStringFormat="{x:Static mui:ColonConverter.FormatNoSpaceAfterwards}"
Style="{StaticResource PythonAppConfig.PropertyLabel}" />
<mui:BetterComboBox ItemsSource="{Binding Values}" DisplayMemberPath="DisplayName" SelectedItem="{Binding Value, Mode=TwoWay}" IsEditable="False" />
<mui:BetterComboBox ItemsSource="{Binding Values}" DisplayMemberPath="DisplayName" SelectedItem="{Binding Value, Mode=TwoWay}" IsEditable="False"
Height="23" VerticalAlignment="Top" />
</DockPanel>
</DataTemplate>

Expand All @@ -531,7 +543,7 @@
<DockPanel>
<Label Content="{Binding DisplayName}" ContentStringFormat="{x:Static mui:ColonConverter.FormatNoSpaceAfterwards}"
Style="{StaticResource PythonAppConfig.PropertyLabel}" />
<mui:BetterTextBox Text="{Binding Value}" Placeholder="?" />
<mui:BetterTextBox Text="{Binding Value}" Placeholder="?" Height="23" VerticalAlignment="Top" />
</DockPanel>
</DataTemplate>
</ContentControl.Resources>
Expand All @@ -543,19 +555,30 @@
<mui:UniformGridWithOrientation Orientation="Vertical" VerticalSpacing="4" HorizontalSpacing="20" Columns="2" />
</ItemsPanelTemplate>

<DataTemplate x:Key="PythonAppConfig.SectionTemplate" DataType="{x:Type t:PythonAppConfig}">
<DockPanel>
<TextBlock Text="{Binding DisplayName, StringFormat={x:Static mui:ColonConverter.FormatNoSpaceAfterwards}}" DockPanel.Dock="Top" Margin="0 0 0 8"
TextWrapping="Wrap" Style="{StaticResource Label}" />
<ItemsControl ItemsSource="{Binding}" Margin="20 0 0 20" ItemTemplate="{StaticResource PythonAppConfig.ItemTemplate}"
ItemsPanel="{StaticResource PythonAppConfig.SectionItemsPanel}" />
</DockPanel>
<DataTemplate x:Key="PythonAppConfig.SectionTemplate" DataType="{x:Type t:PythonAppConfigSection}">
<mui:Switch Value="{Binding Key}">
<DockPanel mui:Switch.When="" Margin="0 0 0 20">
<mui:BetterImage Filename="{Binding Preview}" Height="160" Width="160" DockPanel.Dock="Left" Stretch="UniformToFill" DecodeWidth="640"
Margin="0 0 20 0" CollapseIfNull="True" se:ImageViewerService.Image="{Binding Preview}" />
<mui:BbCodeBlock Mode="WithoutBbCodes" Text="{Binding FullName}" DockPanel.Dock="Top" TextWrapping="Wrap" Style="{StaticResource Heading2}" />
<mui:BbCodeBlock Text="{Binding Description}" DockPanel.Dock="Top" Margin="0 20 0 0" TextWrapping="Wrap"
Visibility="{Binding Description, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=inverse}" />
<mui:BbCodeBlock Text="{Binding Url}" DockPanel.Dock="Top" Margin="0 8 0 0" TextWrapping="Wrap"
Visibility="{Binding Url, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=inverse}" />
</DockPanel>
<DockPanel>
<TextBlock Text="{Binding DisplayName, StringFormat={x:Static mui:ColonConverter.FormatNoSpaceAfterwards}}" DockPanel.Dock="Top" Margin="0 0 0 8"
TextWrapping="Wrap" Style="{StaticResource Label}" ToolTip="{Binding ToolTip}" />
<ItemsControl ItemsSource="{Binding}" Margin="20 0 0 20" ItemTemplate="{StaticResource PythonAppConfig.ItemTemplate}"
ItemsPanel="{StaticResource PythonAppConfig.SectionItemsPanel}" />
</DockPanel>
</mui:Switch>
</DataTemplate>

<DataTemplate x:Key="PythonAppConfig" DataType="{x:Type t:PythonAppConfig}">
<DockPanel>
<Button DockPanel.Dock="Bottom" Margin="0 8 0 0" Content="{x:Static c:ControlsStrings.Common_Reset}" Command="{Binding ResetCommand}"
Visibility="{Binding IsResettable, Converter={StaticResource BooleanToVisibilityConverter}}" />
Visibility="{Binding IsNonDefault, Converter={StaticResource BooleanToVisibilityConverter}}" />
<TextBlock Text="{Binding DisplayName}" Style="{StaticResource Heading2}" DockPanel.Dock="Top" Margin="0 0 0 8" />
<ItemsControl ItemsSource="{Binding Sections}" Margin="20 0 0 -20" ItemTemplate="{StaticResource PythonAppConfig.SectionTemplate}" />
</DockPanel>
Expand All @@ -565,7 +588,7 @@
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<DockPanel VerticalAlignment="Top">
<Button DockPanel.Dock="Bottom" Margin="0 20 0 0" Content="{x:Static c:ControlsStrings.Common_Reset}" Command="{Binding ResetCommand}"
Visibility="{Binding IsResettable, Converter={StaticResource BooleanToVisibilityConverter}}" />
Visibility="{Binding IsNonDefault, Converter={StaticResource BooleanToVisibilityConverter}}" />
<ItemsControl ItemsSource="{Binding Sections[0]}" ItemTemplate="{StaticResource PythonAppConfig.ItemTemplate}"
ItemsPanel="{StaticResource PythonAppConfig.SectionItemsPanel}" VerticalAlignment="Top" />
</DockPanel>
Expand All @@ -576,9 +599,31 @@
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<DockPanel VerticalAlignment="Top">
<Button DockPanel.Dock="Bottom" Margin="0 20 0 0" Content="{x:Static c:ControlsStrings.Common_Reset}" Command="{Binding ResetCommand}"
Visibility="{Binding IsResettable, Converter={StaticResource BooleanToVisibilityConverter}}" />
Visibility="{Binding IsNonDefault, Converter={StaticResource BooleanToVisibilityConverter}}" />
<ItemsControl ItemsSource="{Binding Sections}" ItemTemplate="{StaticResource PythonAppConfig.SectionTemplate}" Margin="0 0 0 -20" />
</DockPanel>
</ScrollViewer>
</DataTemplate>

<DataTemplate x:Key="PythonAppConfig.Compact.SectionTemplate" DataType="{x:Type t:PythonAppConfigSection}">
<mui:Switch Value="{Binding Key}">
<Border mui:Switch.When="" />
<DockPanel>
<TextBlock Text="{Binding DisplayName, StringFormat={x:Static mui:ColonConverter.FormatNoSpaceAfterwards}}" DockPanel.Dock="Top" Margin="0 0 0 8"
TextWrapping="Wrap" Style="{StaticResource Label}" ToolTip="{Binding ToolTip}" />
<ItemsControl ItemsSource="{Binding}" Margin="20 0 0 20" ItemTemplate="{StaticResource PythonAppConfig.ItemTemplate}"
ItemsPanel="{StaticResource PythonAppConfig.SectionItemsPanel}" />
</DockPanel>
</mui:Switch>
</DataTemplate>

<DataTemplate x:Key="PythonAppConfig.Compact.NoHeader" DataType="{x:Type t:PythonAppConfig}">
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<DockPanel VerticalAlignment="Top">
<Button DockPanel.Dock="Bottom" Margin="0 20 0 0" Content="{x:Static c:ControlsStrings.Common_Reset}" Command="{Binding ResetCommand}"
Visibility="{Binding IsNonDefault, Converter={StaticResource BooleanToVisibilityConverter}}" />
<ItemsControl ItemsSource="{Binding Sections}" ItemTemplate="{StaticResource PythonAppConfig.Compact.SectionTemplate}" Margin="0 0 0 -20" />
</DockPanel>
</ScrollViewer>
</DataTemplate>
</ResourceDictionary>
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.

11 changes: 9 additions & 2 deletions AcManager.Controls/Dialogs/ImageViewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,17 @@ private void OnKeyUp(object sender, KeyEventArgs e) {
e.Key == Key.Q || e.Key == Key.W && Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) {
e.Handled = true;
Close();
} else if (e.Key == Key.S && Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) {
e.Handled = true;
Model.SaveCommand.Execute(null);
} else if (e.Key == Key.Enter) {
IsSelected = true;
e.Handled = true;
Close();
if (Model.SaveCommand.CanExecute(null)) {
Model.SaveCommand.Execute(null);
} else {
IsSelected = true;
Close();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion AcManager.Tools/Helpers/AcStringValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static string GetCountryFromId([NotNull] string countryId) {

private static readonly Regex UpperAcronimRegex = new Regex(@"\b(?:
[234]d|a(?:i|cc?|mg)|b(?:r|mw)|c(?:cgt|pu|sl|ts|tr\d*)|d(?:mc|rs|s3|tm)|
g(?:gt|pu|rm|sr|t[\dbceirsx]?\d?)|ffb|
g(?:gt|pu|rm|sr|t[\dbceirsx]?\d?)|f(?:x|fb)|
h(?:dr|ks|rt)|ita|jtc|ksdrift|lms?|
m(?:c12|gu|p\d*)|n(?:a|vidia)|rs[\drs]?|s(?:[lm]|r8)|qv|vdc|wrc)\b",
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
Expand Down
8 changes: 8 additions & 0 deletions AcManager.Tools/Helpers/Api/ApiCacheThing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private async Task<byte[]> GetBytesAsyncInner([NotNull] string url, string cache
lock (_cache) {
cache = _cache.GetValueOrDefault(cacheKey);
}

if (cache != null && cache.Item2 > DateTime.Now - actualAliveTime) {
return cache.Item1;
}
Expand Down Expand Up @@ -159,5 +160,12 @@ public Task<string> GetStringAsync([NotNull] string url, string cacheKey = null,
if (_stringTasks.TryGetValue(url, out var s)) return s;
return _stringTasks[url] = GetStringAsyncInner(url, cacheKey, aliveTime, cancellation);
}

public void ResetCache([NotNull] string cacheKey) {
lock (_cache) {
_cache.Remove(cacheKey);
}
FileUtils.TryToDelete(FilesStorage.Instance.GetTemporaryFilename(_directory, cacheKey));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static async Task<Tuple<RemoteSetupInformation, string>> GetSetupFullInfo

private static List<RemoteSetupInformation> _parsed;
private static DateTime _parsedLifeSpan;
private static DateTime? _errorSkip;

private static string[] ListUrls = {
"http://194.67.219.50:12012/setups",
Expand All @@ -83,7 +84,12 @@ public static async Task<Tuple<RemoteSetupInformation, string>> GetSetupFullInfo
}

public static async Task<List<RemoteSetupInformation>> GetAvailableSetupsInner(string carId, CancellationToken cancellation = default(CancellationToken)) {
if (_parsed != null && DateTime.Now < _parsedLifeSpan) {
var now = DateTime.Now;
if (_errorSkip.HasValue && now < _errorSkip.Value) {
return null;
}

if (_parsed != null && now < _parsedLifeSpan) {
// A little bit of extra caching to avoid going to a different thread to reparse already loaded data
// for each new car.
return _parsed.Where(x => x.CarId == carId).ToList();
Expand All @@ -102,7 +108,9 @@ public static async Task<Tuple<RemoteSetupInformation, string>> GetSetupFullInfo
break;
} catch (Exception e) {
Logging.Warning($"Error while loading {url}: {e}");
Cache.ResetCache("List.json");
if (url == ListUrls.Last()) {
Logging.Warning("No more URLs to try");
throw;
}
}
Expand All @@ -119,6 +127,7 @@ public static async Task<Tuple<RemoteSetupInformation, string>> GetSetupFullInfo
Logging.Warning(e);
}

_errorSkip = DateTime.Now + TimeSpan.FromHours(3);
return null;
}
}
Expand Down
8 changes: 6 additions & 2 deletions AcManager.Tools/Managers/Online/ServerEntry.Join.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public IReadOnlyList<string> NonAvailableReasons {
/// </summary>
[CanBeNull]
public string NonAvailableReasonsString => _naReasons == null ? null : (_naReasonsString ?? (_naReasonsString = _naReasons.JoinToString('\n')));

private string _naReasonsString;

private IEnumerable<string> GetNonAvailableReasons() {
Expand Down Expand Up @@ -232,7 +233,10 @@ private async Task Join(object o) {
return;
}

if (BookingMode && !ReferenceEquals(o, ActualJoin) && !ReferenceEquals(o, ForceJoin)) {
// if (BookingMode && !ReferenceEquals(o, ActualJoin) && !ReferenceEquals(o, ForceJoin)) {
// if (!IsBookedForPlayer && BookingMode && !ReferenceEquals(o, ActualJoin) && !ReferenceEquals(o, ForceJoin)) {
if ((!IsBookedForPlayer || CurrentSessionType == Game.SessionType.Booking)
&& BookingMode && !ReferenceEquals(o, ActualJoin) && !ReferenceEquals(o, ForceJoin)) {
if (_factory == null) {
Logging.Error("Booking: UI factory is missing");
return;
Expand Down Expand Up @@ -284,4 +288,4 @@ public static void RegisterFactory(IAnyFactory<IBookingUi> factory) {
_factory = factory;
}
}
}
}
Loading

0 comments on commit 7135668

Please sign in to comment.