mirror of
https://github.com/ppy/osu
synced 2025-01-09 23:59:44 +00:00
Merge pull request #12100 from bdach/invalid-thread-mutation-tablet
Fix transform mutations from invalid thread on tablet disconnection/reconnection
This commit is contained in:
commit
0bb6fbdd38
@ -125,17 +125,20 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
tablet.BindTo(handler.Tablet);
|
tablet.BindTo(handler.Tablet);
|
||||||
tablet.BindValueChanged(val =>
|
tablet.BindValueChanged(_ => Scheduler.AddOnce(updateTabletDetails));
|
||||||
{
|
|
||||||
tabletContainer.Size = val.NewValue?.Size ?? Vector2.Zero;
|
|
||||||
tabletName.Text = val.NewValue?.Name ?? string.Empty;
|
|
||||||
checkBounds();
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
|
updateTabletDetails();
|
||||||
// initial animation should be instant.
|
// initial animation should be instant.
|
||||||
FinishTransforms(true);
|
FinishTransforms(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateTabletDetails()
|
||||||
|
{
|
||||||
|
tabletContainer.Size = tablet.Value?.Size ?? Vector2.Zero;
|
||||||
|
tabletName.Text = tablet.Value?.Name ?? string.Empty;
|
||||||
|
checkBounds();
|
||||||
|
}
|
||||||
|
|
||||||
private static int greatestCommonDivider(int a, int b)
|
private static int greatestCommonDivider(int a, int b)
|
||||||
{
|
{
|
||||||
while (b != 0)
|
while (b != 0)
|
||||||
|
@ -196,19 +196,13 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
tablet.BindTo(tabletHandler.Tablet);
|
tablet.BindTo(tabletHandler.Tablet);
|
||||||
tablet.BindValueChanged(val =>
|
tablet.BindValueChanged(val =>
|
||||||
{
|
{
|
||||||
|
Scheduler.AddOnce(toggleVisibility);
|
||||||
|
|
||||||
var tab = val.NewValue;
|
var tab = val.NewValue;
|
||||||
|
|
||||||
bool tabletFound = tab != null;
|
bool tabletFound = tab != null;
|
||||||
|
|
||||||
if (!tabletFound)
|
if (!tabletFound)
|
||||||
{
|
|
||||||
mainSettings.Hide();
|
|
||||||
noTabletMessage.Show();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
mainSettings.Show();
|
|
||||||
noTabletMessage.Hide();
|
|
||||||
|
|
||||||
offsetX.MaxValue = tab.Size.X;
|
offsetX.MaxValue = tab.Size.X;
|
||||||
offsetX.Default = tab.Size.X / 2;
|
offsetX.Default = tab.Size.X / 2;
|
||||||
@ -222,13 +216,28 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void toggleVisibility()
|
||||||
|
{
|
||||||
|
bool tabletFound = tablet.Value != null;
|
||||||
|
|
||||||
|
if (!tabletFound)
|
||||||
|
{
|
||||||
|
mainSettings.Hide();
|
||||||
|
noTabletMessage.Show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mainSettings.Show();
|
||||||
|
noTabletMessage.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
private void applyAspectRatio(BindableNumber<float> sizeChanged)
|
private void applyAspectRatio(BindableNumber<float> sizeChanged)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!aspectLock.Value)
|
if (!aspectLock.Value)
|
||||||
{
|
{
|
||||||
float proposedAspectRatio = curentAspectRatio;
|
float proposedAspectRatio = currentAspectRatio;
|
||||||
|
|
||||||
if (proposedAspectRatio >= aspectRatio.MinValue && proposedAspectRatio <= aspectRatio.MaxValue)
|
if (proposedAspectRatio >= aspectRatio.MinValue && proposedAspectRatio <= aspectRatio.MaxValue)
|
||||||
{
|
{
|
||||||
@ -269,8 +278,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
aspectLock.Value = true;
|
aspectLock.Value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAspectRatio() => aspectRatio.Value = curentAspectRatio;
|
private void updateAspectRatio() => aspectRatio.Value = currentAspectRatio;
|
||||||
|
|
||||||
private float curentAspectRatio => sizeX.Value / sizeY.Value;
|
private float currentAspectRatio => sizeX.Value / sizeY.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user