Skip to content

Commit

Permalink
Better override notice tooltip, fix crashing with multiple overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
KimihikoAkayasaki committed Apr 4, 2023
1 parent f0ae02c commit 83c4387
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Amethyst/Assets/Strings/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"/DevicesPage/Badges/Devices/Base": "Base",
"/DevicesPage/Badges/Devices/Override": "Override",
"/DevicesPage/Badges/Devices/Error": "Error",
"/DevicesPage/ToolTips/Overrides/Overlapping": "This joint is currently overiden by:\n{0}",
"/DevicesPage/ToolTips/Overrides/Overlapping": "This joint is currently overridden by {0}",
"/DevicesPage/Devices/Reload/Title": "Plugin configuration has changed!",
"/DevicesPage/Devices/Reload/Content": "A new plugin has been added or removed. Amethyst must be restarted for these changes to take effect.",
"/DevicesPage/Devices/Reload/Restart": "Restart Amethyst",
Expand Down
2 changes: 1 addition & 1 deletion Amethyst/Assets/Strings/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"/DevicesPage/Badges/Devices/Base": "Base",
"/DevicesPage/Badges/Devices/Override": "Override",
"/DevicesPage/Badges/Devices/Error": "Error",
"/DevicesPage/ToolTips/Overrides/Overlapping": "This joint is currently overiden by:\n{0}",
"/DevicesPage/ToolTips/Overrides/Overlapping": "This joint is currently overridden by {0}",
"/DevicesPage/Devices/Reload/Title": "Plugin configuration has changed!",
"/DevicesPage/Devices/Reload/Content": "A new plugin has been added or removed. Amethyst must be restarted for these changes to take effect.",
"/DevicesPage/Devices/Reload/Restart": "Restart Amethyst",
Expand Down
2 changes: 1 addition & 1 deletion Amethyst/Assets/Strings/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"/DevicesPage/Badges/Devices/Base": "Base",
"/DevicesPage/Badges/Devices/Override": "Override",
"/DevicesPage/Badges/Devices/Error": "Error",
"/DevicesPage/ToolTips/Overrides/Overlapping": "This joint is currently overiden by:\n{0}",
"/DevicesPage/ToolTips/Overrides/Overlapping": "This joint is currently overridden by {0}",
"/DevicesPage/Devices/Reload/Title": "Plugin configuration has changed!",
"/DevicesPage/Devices/Reload/Content": "A new plugin has been added or removed. Amethyst must be restarted for these changes to take effect.",
"/DevicesPage/Devices/Reload/Restart": "Restart Amethyst",
Expand Down
2 changes: 1 addition & 1 deletion Amethyst/Assets/Strings/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"/DevicesPage/Badges/Devices/Base": "Base",
"/DevicesPage/Badges/Devices/Override": "Override",
"/DevicesPage/Badges/Devices/Error": "Error",
"/DevicesPage/ToolTips/Overrides/Overlapping": "This joint is currently overiden by:\n{0}",
"/DevicesPage/ToolTips/Overrides/Overlapping": "This joint is currently overridden by {0}",
"/DevicesPage/Devices/Reload/Title": "Plugin configuration has changed!",
"/DevicesPage/Devices/Reload/Content": "A new plugin has been added or removed. Amethyst must be restarted for these changes to take effect.",
"/DevicesPage/Devices/Reload/Restart": "Restart Amethyst",
Expand Down
9 changes: 5 additions & 4 deletions Amethyst/Classes/AppTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ public class AppTracker : INotifyPropertyChanged
// Is this joint overridden?
public bool IsPositionOverridden
{
get => !string.IsNullOrEmpty(OverrideGuid) && _isPositionOverridden;
get => !string.IsNullOrEmpty(OverrideGuid) && AppPlugins.IsOverride(OverrideGuid) && _isPositionOverridden;
set => _isPositionOverridden = value;
}

public bool IsOrientationOverridden
{
get => !string.IsNullOrEmpty(OverrideGuid) && _isOrientationOverridden;
get => !string.IsNullOrEmpty(OverrideGuid) && AppPlugins.IsOverride(OverrideGuid) && _isOrientationOverridden;
set => _isOrientationOverridden = value;
}

Expand Down Expand Up @@ -429,8 +429,9 @@ public bool IsOrientationOverriddenBySelectedDevice
!string.IsNullOrEmpty(OverrideGuid) && OverrideGuid != AppData.Settings.SelectedTrackingDeviceGuid;

[JsonIgnore]
public string OverriddenByOtherDeviceString => string.Format(Interfacing.LocalizedJsonString(
"/DevicesPage/ToolTips/Overrides/Overlapping"), ManagingDeviceGuid);
public string OverriddenByOtherDeviceString => string.Format(
Interfacing.LocalizedJsonString("/DevicesPage/ToolTips/Overrides/Overlapping"),
$"{AppPlugins.GetDevice(ManagingDeviceGuid).Device?.Name ?? "INVALID"} (GUID: {ManagingDeviceGuid})");

// MVVM: a connection of the transitions each tracker expander should animate
[JsonIgnore] public TransitionCollection SettingsExpanderTransitions { get; set; } = new();
Expand Down
14 changes: 10 additions & 4 deletions Amethyst/Controls/OverrideExpander.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,24 @@
</Grid.RowDefinitions>

<!--Title Container-->
<Grid Grid.Column="0">
<Grid Grid.Column="0" HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>

<TextBlock FontWeight="SemiBold" FontSize="15"
Margin="0,-3,0,0"
Grid.Column="1" Margin="0,-3,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalTextAlignment="Center"
Text="{x:Bind TrackerName, Mode=OneWay}" />

<InfoBadge
Background="{ThemeResource SystemFillColorAttentionBrush}"
Grid.Column="2" Background="{ThemeResource SystemFillColorAttentionBrush}"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,-12,-10" Width="17" Height="17"
Margin="3,0,0,-10" Width="17" Height="17"
ToolTipService.ToolTip="{x:Bind OverriddenByOtherDeviceString, Mode=OneWay}"
Opacity="{x:Bind BoolToOpacity(IsOverriddenByOtherDevice), Mode=OneWay}">
<InfoBadge.IconSource>
Expand Down
3 changes: 2 additions & 1 deletion Amethyst/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,8 @@ public MainWindow()
// Log our used overrides to the telemetry module
Analytics.TrackEvent("OverrideDevices", new Dictionary<string, string>(
AppData.Settings.OverrideDevicesGuidMap
.Select(x => new KeyValuePair<string, string>("Guid", x))));
.Select(x => new KeyValuePair<string, string>(
$"Guid{AppData.Settings.OverrideDevicesGuidMap.ToList().IndexOf(x)}", x))));

// Setup device change watchdog : local devices
var localWatcher = new FileSystemWatcher
Expand Down

0 comments on commit 83c4387

Please sign in to comment.