Skip to content

Commit

Permalink
Merge pull request #20 from manups4e/master
Browse files Browse the repository at this point in the history
Added MenuGlare Scaleform
  • Loading branch information
manups4e authored Mar 14, 2020
2 parents e651086 + 738186c commit 91f10b0
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion MenuExample/MenuExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void AddMenuAnotherMenu(UIMenu menu)
public MenuExample()
{
_menuPool = new MenuPool();
var mainMenu = new UIMenu("Native UI", "~b~NATIVEUI SHOWCASE");
var mainMenu = new UIMenu("Native UI", "~b~NATIVEUI SHOWCASE", true); // true means add menu Glare scaleform to the menu
_menuPool.Add(mainMenu);
HeritageMenu(mainMenu);
AddMenuKetchup(mainMenu);
Expand Down
8 changes: 4 additions & 4 deletions MenuExample/MenuExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core.Client, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CitizenFX.Core.Client.1.0.1641\lib\net45\CitizenFX.Core.Client.dll</HintPath>
<HintPath>..\packages\CitizenFX.Core.Client.1.0.2207\lib\net45\CitizenFX.Core.Client.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -47,15 +47,15 @@
<ItemGroup>
<Compile Include="MenuExample.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NativeUI\NativeUI.csproj">
<Project>{f3e16ed9-dbf7-4e7b-b04b-9b24b11891d3}</Project>
<Name>NativeUI</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion MenuExample/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CitizenFX.Core.Client" version="1.0.1641" targetFramework="net452" />
<package id="CitizenFX.Core.Client" version="1.0.2207" targetFramework="net452" />
</packages>
2 changes: 1 addition & 1 deletion NativeUI/NativeUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core.Client, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CitizenFX.Core.Client.1.0.1641\lib\net45\CitizenFX.Core.Client.dll</HintPath>
<HintPath>..\packages\CitizenFX.Core.Client.1.0.2207\lib\net45\CitizenFX.Core.Client.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
Expand Down
31 changes: 25 additions & 6 deletions NativeUI/UIMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ public class UIMenu
private readonly UIResRectangle _extraRectangleDown;

private readonly Scaleform _instructionalButtonsScaleform;
private readonly Scaleform _menuGlare;

private readonly int _extraYOffset;

Expand All @@ -880,6 +881,8 @@ public class UIMenu
private SizeF DrawWidth { get; set; }
private bool ReDraw = true;

private bool Glare;

internal readonly static string _selectTextLocalized = Game.GetGXTEntry("HUD_INPUT2");
internal readonly static string _backTextLocalized = Game.GetGXTEntry("HUD_INPUT3");

Expand Down Expand Up @@ -986,7 +989,8 @@ public class UIMenu
/// </summary>
/// <param name="title">Title that appears on the big banner.</param>
/// <param name="subtitle">Subtitle that appears in capital letters in a small black bar.</param>
public UIMenu(string title, string subtitle) : this(title, subtitle, new PointF(0, 0), "commonmenu", "interaction_bgd")
/// <param name="glare">Add menu Glare scaleform?.</param>
public UIMenu(string title, string subtitle, bool glare = false) : this(title, subtitle, new PointF(0, 0), "commonmenu", "interaction_bgd", glare)
{
}

Expand All @@ -997,7 +1001,8 @@ public class UIMenu
/// <param name="title">Title that appears on the big banner.</param>
/// <param name="subtitle">Subtitle that appears in capital letters in a small black bar. Set to "" if you dont want a subtitle.</param>
/// <param name="offset">PointF object with X and Y data for offsets. Applied to all menu elements.</param>
public UIMenu(string title, string subtitle, PointF offset) : this(title, subtitle, offset, "commonmenu", "interaction_bgd")
/// <param name="glare">Add menu Glare scaleform?.</param>
public UIMenu(string title, string subtitle, PointF offset, bool glare = false) : this(title, subtitle, offset, "commonmenu", "interaction_bgd", glare)
{
}

Expand All @@ -1008,7 +1013,8 @@ public UIMenu(string title, string subtitle, PointF offset) : this(title, subtit
/// <param name="subtitle">Subtitle that appears in capital letters in a small black bar. Set to "" if you dont want a subtitle.</param>
/// <param name="offset">PointF object with X and Y data for offsets. Applied to all menu elements.</param>
/// <param name="customBanner">Path to your custom texture.</param>
public UIMenu(string title, string subtitle, PointF offset, string customBanner) : this(title, subtitle, offset, "commonmenu", "interaction_bgd")
/// <param name="glare">Add menu Glare scaleform?.</param>
public UIMenu(string title, string subtitle, PointF offset, string customBanner) : this(title, subtitle, offset, "commonmenu", "interaction_bgd", false)
{
BannerTexture = customBanner;
}
Expand All @@ -1022,13 +1028,15 @@ public UIMenu(string title, string subtitle, PointF offset, string customBanner)
/// <param name="offset">PointF object with X and Y data for offsets. Applied to all menu elements.</param>
/// <param name="spriteLibrary">Sprite library name for the banner.</param>
/// <param name="spriteName">Sprite name for the banner.</param>
public UIMenu(string title, string subtitle, PointF offset, string spriteLibrary, string spriteName)
/// <param name="glare">Add menu Glare scaleform?.</param>
public UIMenu(string title, string subtitle, PointF offset, string spriteLibrary, string spriteName, bool glare = false)
{
Offset = offset;
Children = new Dictionary<UIMenuItem, UIMenu>();
WidthOffset = 0;

Glare = glare;
_instructionalButtonsScaleform = new Scaleform("instructional_buttons");
_menuGlare = new Scaleform("mp_menu_glare");
UpdateScaleform();

_mainMenu = new Container(new PointF(0, 0), new SizeF(700, 500), Color.FromArgb(0, 0, 0, 0));
Expand Down Expand Up @@ -1866,7 +1874,7 @@ public async Task Draw()
if (String.IsNullOrWhiteSpace(BannerTexture))
{
if (BannerSprite != null)
BannerSprite .Draw();
BannerSprite.Draw();
else
{
BannerRectangle?.Draw();
Expand All @@ -1879,6 +1887,17 @@ public async Task Draw()
//Sprite.DrawTexture(BannerTexture, new PointF(start.X + Offset.X, start.Y + Offset.Y), DrawWidth);
}
_mainMenu.Draw();
if (Glare)
{
float x;
float y;
float width = 1.0f;
float height = 1.042f;
x = BannerSprite.Position.X / 1860 + Safe.X / 53.211f + 0.4485f;
y = BannerSprite.Position.Y / 1080 + Safe.Y / 33.195020746888f + 0.468f;
_menuGlare.CallFunction("SET_DATA_SLOT", API.GetGameplayCamRelativeHeading());
API.DrawScaleformMovie(_menuGlare.Handle, x, y, width, height, 255, 255, 255, 255, 0);
}
if (MenuItems.Count == 0 && Windows.Count == 0)
{
API.ResetScriptGfxAlign(); // Safezone end
Expand Down
2 changes: 1 addition & 1 deletion NativeUI/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CitizenFX.Core.Client" version="1.0.1641" targetFramework="net452" />
<package id="CitizenFX.Core.Client" version="1.0.2207" targetFramework="net452" />
</packages>

0 comments on commit 91f10b0

Please sign in to comment.