Skip to content

Commit

Permalink
C# UIMenu: Fix SwitchTo fading too late or too soon
Browse files Browse the repository at this point in the history
  • Loading branch information
manups4e committed Nov 8, 2023
1 parent 01ca905 commit 53a99dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions ScaleformUI_Csharp/Menus/MenuHandler.cs
Expand Up @@ -64,6 +64,8 @@ public static async Task SwitchTo(this MenuBase currentMenu, MenuBase newMenu, i

if (currentMenu is UIMenu old)
{
await old.FadeOutMenu();
currentMenu.Visible = false;
if (newMenu is UIMenu newer)
{
if (inheritOldMenuParams)
Expand All @@ -78,7 +80,8 @@ public static async Task SwitchTo(this MenuBase currentMenu, MenuBase newMenu, i
newer.Glare = old.Glare;
newer.EnableAnimation = old.EnableAnimation;
newer.Enabled3DAnimations = old.Enabled3DAnimations;
newer.MouseSettings(old.MouseControlsEnabled, old.MouseEdgeEnabled, old.MouseWheelControlEnabled, old.ResetCursorOnOpen, old.leftClickEnabled);
newer.fadingTime = old.fadingTime;
newer.SetMouse(old.MouseControlsEnabled, old.MouseEdgeEnabled, old.MouseWheelControlEnabled, old.ResetCursorOnOpen, old.leftClickEnabled);
}
newer.CurrentSelection = newMenuCurrentSelection != 0 ? newMenuCurrentSelection : 0;
}
Expand All @@ -88,12 +91,8 @@ public static async Task SwitchTo(this MenuBase currentMenu, MenuBase newMenu, i
radio.CurrentSelection = newMenuCurrentSelection != 0 ? newMenuCurrentSelection : 0;
}

if (currentMenu is UIMenu _old)
await _old.FadeOutMenu();
currentMenu.Visible = false;

newMenu.Visible = true;
if (newMenu is UIMenu _newer)
await _newer.FadeInMenu();
BreadcrumbsHandler.Forward(newMenu, data);
BreadcrumbsHandler.SwitchInProgress = false;
}
Expand Down
8 changes: 4 additions & 4 deletions ScaleformUI_Csharp/Menus/UIMenu/UIMenu.cs
Expand Up @@ -1033,7 +1033,7 @@ public ItemFont DescriptionFont
public bool AlternativeTitle = false;
private bool canBuild = true;
private bool isFading;
private float fadingTime = 0.1f;
internal float fadingTime = 0.1f;
internal bool itemless = false;
public PointF Offset { get; internal set; }

Expand Down Expand Up @@ -2314,7 +2314,7 @@ internal async void BuildUpMenuAsync(bool itemsOnly = false)
BeginTextCommandScaleformString("ScaleformUILongDesc");
EndTextCommandScaleformString_2();
EndScaleformMovieMethod();
FadeInMenu();
await FadeInMenu();
isBuilding = false;
return;
}
Expand Down Expand Up @@ -2404,7 +2404,7 @@ internal async void BuildUpMenuAsync(bool itemsOnly = false)
Main.scaleformUI.CallFunction("ENABLE_MOUSE", MouseControlsEnabled);
Main.scaleformUI.CallFunction("ENABLE_3D_ANIMATIONS", enabled3DAnimations);
EnableAnimation = _animEnabled;
FadeInMenu();
await FadeInMenu();
isBuilding = false;
}

Expand All @@ -2416,7 +2416,7 @@ internal async void BuildUpMenuAsync(bool itemsOnly = false)
/// <param name="isWheelEnabled">Enables mouse wheel to scroll items</param>
/// <param name="resetCursorOnOpen">Resets cursor's position on menu open</param>
/// <param name="leftClickSelect">If MouseControls are not enabled and this is true, left click selects the current item without pointing</param>
public void MouseSettings(bool enableMouseControls, bool enableEdge, bool isWheelEnabled, bool resetCursorOnOpen, bool leftClickSelect)
public void SetMouse(bool enableMouseControls, bool enableEdge, bool isWheelEnabled, bool resetCursorOnOpen, bool leftClickSelect)
{
MouseControlsEnabled = enableMouseControls;
MouseEdgeEnabled = enableEdge;
Expand Down

0 comments on commit 53a99dc

Please sign in to comment.