Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions MenuAPI/HerritageMenu.cs
Original file line number Diff line number Diff line change
@@ -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)
{
}
}
}
24 changes: 21 additions & 3 deletions MenuAPI/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,6 @@ internal async void Draw()
}

ResetScriptGfxAlign();

MenuItemsYOffset = headerSize.Value;
#endif

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion MenuAPI/MenuController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 24 additions & 0 deletions TestMenu/ExampleMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down