diff --git a/MenuAPI/HerritageMenu.cs b/MenuAPI/HerritageMenu.cs new file mode 100644 index 0000000..ef22e99 --- /dev/null +++ b/MenuAPI/HerritageMenu.cs @@ -0,0 +1,26 @@ +namespace MenuAPI +{ + public enum Dad + { + Benjamin, Daniel, Joshua, Noah, Andrew, Juan, Alex, Isaac, Evan, Ethan, Vincent, Angel, Diego, Adrian, Gabriel, Michael, Santiago, Kevin, Louis, Samuel, Anthony, Claude, Niko + } + + public enum Mum + { + Hannah, Aubrey, Jasmine, Gisele, Amelia, Isabella, Zoe, Ava, Camila, Violet, Sophia, Evelyn, Nicole, Ashley, Gracie, Brianna, Natalie, Olivia, Elizabeth, Charlotte, Emma, Misty + } + + public class HerritageMenu : MenuAPI.Menu + { + public Mum CurrentMum; + public Dad CurrentDad; + + public HerritageMenu(string name) : base(name) + { + } + + public HerritageMenu(string name, string subtitle) : base(name, subtitle) + { + } + } +} diff --git a/MenuAPI/Menu.cs b/MenuAPI/Menu.cs index fef9b34..231ae3b 100644 --- a/MenuAPI/Menu.cs +++ b/MenuAPI/Menu.cs @@ -1292,7 +1292,6 @@ internal async void Draw() } ResetScriptGfxAlign(); - MenuItemsYOffset = headerSize.Value; #endif @@ -1322,13 +1321,13 @@ internal async void Draw() #endregion #region Draw Subtitle + float bgHeight = 38f; { #if FIVEM #region draw subtitle background SetScriptGfxAlign(LeftAligned ? 76 : 82, 84); SetScriptGfxAlignParams(0f, 0f, 0f, 0f); - float bgHeight = 38f; float x = (Position.Key + (headerSize.Key / 2f)) / MenuController.ScreenWidth; float y = ((Position.Value + MenuItemsYOffset + (bgHeight / 2f)) / MenuController.ScreenHeight); @@ -1477,7 +1476,25 @@ internal async void Draw() //DrawSprite(MenuController._texture_dict, "gradient_bgd", x, y, width, height, 0f, 255, 255, 255, 255); #if FIVEM - float bgHeight = 38f * MathUtil.Clamp(Size, 0, MaxItemsOnScreen); + + if (this is HerritageMenu) + { + HerritageMenu menu = this as HerritageMenu; + float htexheight = 250f; + + float hx = (Position.Key + (headerSize.Key / 2f)) / MenuController.ScreenWidth; + float hy = ((Position.Value + MenuItemsYOffset + ((htexheight + 1f) / 2f)) / MenuController.ScreenHeight); + float hwidth = headerSize.Key / MenuController.ScreenWidth; + float hheight = (htexheight + 1f) / MenuController.ScreenHeight; + + DrawSprite("pause_menu_pages_char_mom_dad", "mumdadbg", hx, hy, hwidth, hheight, 0f, 255, 255, 255, 255); + DrawSprite("char_creator_portraits", ((int)menu.CurrentDad < 21) ? $"male_{(int)menu.CurrentDad}" : $"special_male_{(int)(menu.CurrentDad - 21)}", (hx * 1.3f), hy, hwidth / 2, hheight, 0f, 255, 255, 255, 255); + DrawSprite("char_creator_portraits", ((int)menu.CurrentMum < 21) ? $"female_{(int)menu.CurrentMum}" : $"special_female_{(int)(menu.CurrentMum - 21)}", (hx / 1.8f), hy, hwidth / 2, hheight, 0f, 255, 255, 255, 255); + + MenuItemsYOffset += htexheight - 1f; + } + + bgHeight = 38f * MathUtil.Clamp(Size, 0, MaxItemsOnScreen); float x = (Position.Key + (headerSize.Key / 2f)) / MenuController.ScreenWidth; float y = ((Position.Value + MenuItemsYOffset + ((bgHeight + 1f) / 2f)) / MenuController.ScreenHeight); @@ -1487,6 +1504,7 @@ internal async void Draw() DrawRect(x, y, width, height, 0, 0, 0, 180); MenuItemsYOffset += bgHeight - 1f; ResetScriptGfxAlign(); + #endif #if REDM //float x = (Position.Key + ((headerSize.Key) / 2f)) / MenuController.ScreenWidth; diff --git a/MenuAPI/MenuController.cs b/MenuAPI/MenuController.cs index 87495c0..7e6b728 100644 --- a/MenuAPI/MenuController.cs +++ b/MenuAPI/MenuController.cs @@ -33,7 +33,9 @@ public class MenuController : BaseScript "mprankbadge", "mpcarhud", "mpcarhud2", - "shared" + "shared", + "char_creator_portraits", + "pause_menu_pages_char_mom_dad" #endif #if REDM "menu_textures", diff --git a/TestMenu/ExampleMenu.cs b/TestMenu/ExampleMenu.cs index d18b782..07c6644 100644 --- a/TestMenu/ExampleMenu.cs +++ b/TestMenu/ExampleMenu.cs @@ -149,6 +149,30 @@ string ChangeCallback(MenuDynamicListItem item, bool left) menu.AddMenuItem(menuButton); MenuController.BindMenuItem(menu, submenu, menuButton); +#if FIVEM + var herritageMenu = new HerritageMenu("Herritage"); + herritageMenu.AddMenuItem(new MenuListItem("Father", ((Dad[])Enum.GetValues(typeof(Dad))).Select(c => c.ToString()).ToList(), 0, "Choose the father of your character.")); + herritageMenu.AddMenuItem(new MenuListItem("Mother", ((Mum[])Enum.GetValues(typeof(Mum))).Select(c => c.ToString()).ToList(), 0, "Choose the mother of your character.")); + + menu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) => + { + if (_listItem.Text == "Father") + { + (menu as HerritageMenu).CurrentDad = ((Dad)_itemIndex); + } + else if (_listItem.Text == "Mother") + { + (menu as HerritageMenu).CurrentMum = ((Mum)_itemIndex); + } + }; + + var bindmenu = new MenuItem("Héritage"); + menu.AddMenuItem(bindmenu); + + MenuController.BindMenuItem(menu, herritageMenu, bindmenu); +#endif + + // Adding items with sprites left & right to the submenu. for (var i = 0; i < Enum.GetValues(typeof(MenuItem.Icon)).Length; i++) {