Skip to content

Commit

Permalink
Merge pull request #55 from TomGrobbe/development
Browse files Browse the repository at this point in the history
Bugfix + debugging change
- Added a "fix" for the fast scrolling "bug".
- Also removed the discord rich presence for when you're not using vMenu with Debug mode enabled.
  • Loading branch information
TomGrobbe authored Mar 9, 2018
2 parents c81663b + aeb3900 commit 5541e28
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Binary file modified NativeUI.dll
Binary file not shown.
Binary file removed NativeUI.dll.old
Binary file not shown.
12 changes: 12 additions & 0 deletions vMenu/CommonFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,18 @@ public void Log(string data)
Debug.WriteLine(data, "");
}
#endregion

public UIMenu GetOpenMenu()
{
foreach (UIMenu m in MainMenu.Mp.ToList())
{
if (m.Visible)
{
return m;
}
}
return null;
}

}
}
24 changes: 18 additions & 6 deletions vMenu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public class MainMenu : BaseScript
public MainMenu()
{
// Set discord rich precense once, allowing it to be overruled by other resources once those load.
SetRichPresence($"{(DebugMode ? "Debugging" : "Enjoying")} vMenu {Version}!");
if (DebugMode)
{
SetRichPresence($"Debugging vMenu {Version}!");
}

if (GetCurrentResourceName() != "vMenu")
{
Exception InvalidNameException = new Exception("\r\n\r\n[vMenu] INSTALLATION ERROR!\r\nThe name of the resource is not valid. Please change the folder name from '" + GetCurrentResourceName() + "' to 'vMenu' (case sensitive) instead!\r\n\r\n\r\n");
Expand All @@ -72,6 +76,7 @@ public MainMenu()
else
{
Tick += OnTick;
Tick += ProcessMenus;
}

}
Expand All @@ -93,7 +98,6 @@ public static void SetPermissions(dynamic dict)
// Add the new permission to the dictionary.
PermissionsManager.SetPermission(permission.Key.ToString(), permission.Value);
}

permissionsSetupDone = true;
}
#endregion
Expand All @@ -113,6 +117,16 @@ public static void SetOptions(dynamic options)
optionsSetupDone = true;
}

/// <summary>
/// This has to be separated from the "draw" function to fix the fast scrolling bug.
/// </summary>
/// <returns></returns>
private async Task ProcessMenus()
{
await Mp.ProcessControlAsync();
Mp.WidthOffset = 50;
}

/// <summary>
/// OnTick runs every game tick.
/// </summary>
Expand Down Expand Up @@ -282,10 +296,8 @@ private async Task OnTick()
}
}
#endregion

// Process all menus in the menu pool (displays them when they're active).
Mp.ProcessMenus();
Mp.WidthOffset = 50;
// Only draw the menu each frame, control handling is done in another Tick task because that needs delays.
Mp.Draw();
}
}

Expand Down

0 comments on commit 5541e28

Please sign in to comment.