Skip to content

Commit fd4e60a

Browse files
committed
Add the ability to use custom header sprites.
To set one, use `<menu>.HeaderTexture = new KeyValuePair<string, string>(textureDict, textureName);`
1 parent 0e97905 commit fd4e60a

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

MenuAPI/Menu.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ protected virtual void SliderSelectedEvent(Menu menu, MenuSliderItem sliderItem,
259259

260260
#region constants or readonlys
261261
public const float Width = 500f;
262-
263262
#endregion
264263

265264
#region private variables
@@ -288,6 +287,8 @@ private List<MenuItem> VisibleMenuItems
288287

289288
public string MenuSubtitle { get; set; }
290289

290+
public KeyValuePair<string, string> HeaderTexture { get; set; } = new KeyValuePair<string, string>();
291+
291292
public bool IgnoreDontOpenMenus { get; set; } = false;
292293

293294
public int MaxItemsOnScreen { get; internal set; } = 10;
@@ -711,7 +712,23 @@ internal async void Draw()
711712
float width = headerSize.Width / MenuController.ScreenWidth;
712713
float height = headerSize.Height / MenuController.ScreenHeight;
713714

714-
DrawSprite(MenuController._texture_dict, MenuController._header_texture, x, y, width, height, 0f, 255, 255, 255, 255);
715+
if (!string.IsNullOrEmpty(HeaderTexture.Key) && !string.IsNullOrEmpty(HeaderTexture.Value))
716+
{
717+
if (!HasStreamedTextureDictLoaded(HeaderTexture.Key))
718+
{
719+
RequestStreamedTextureDict(HeaderTexture.Key, false);
720+
while (!HasStreamedTextureDictLoaded(HeaderTexture.Key))
721+
{
722+
await BaseScript.Delay(0);
723+
}
724+
}
725+
DrawSprite(HeaderTexture.Key, HeaderTexture.Value, x, y, width, height, 0f, 255, 255, 255, 255);
726+
}
727+
else
728+
{
729+
DrawSprite(MenuController._texture_dict, MenuController._header_texture, x, y, width, height, 0f, 255, 255, 255, 255);
730+
}
731+
715732

716733
ResetScriptGfxAlign();
717734
#endregion

0 commit comments

Comments
 (0)