Skip to content

Commit

Permalink
Merge pull request #27 from manups4e/master
Browse files Browse the repository at this point in the history
Updated Mission Selector
  • Loading branch information
manups4e authored Nov 23, 2020
2 parents de40a2f + 2290fb2 commit 0c63a2d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 22 deletions.
26 changes: 24 additions & 2 deletions MenuExample/MenuExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public async void OpenCustomPauseMenu()
string Txd = API.GetPedheadshotTxdString(mugshot);

MenuContainer.Photo = new NativeUI.Sprite(Txd, Txd, PointF.Empty, SizeF.Empty); // Position and size can be empty.. they'll be handled by the TabView
//this will add our player smugshot to the pause menu
//this will add our player smugshot to the pause menu
MenuContainer.Money = "1000"; // if money and moneySubtitle are empty or not used, the current datetime will be printed
MenuContainer.MoneySubtitle = "Bank = 10";

Expand Down Expand Up @@ -267,7 +267,25 @@ public async void OpenCustomPauseMenu()
};

TabInteractiveListItem Item4 = new TabInteractiveListItem("TabInteractiveListItem", items);

List<MissionInformation> info = new List<MissionInformation>()
{
new MissionInformation("Mission 1", new List<Tuple<string, string>>()
{
new Tuple<string, string>("item 1", "description 1"),
new Tuple<string, string>("item 2", "description 2"),
new Tuple<string, string>("item 3", "description 3"),
new Tuple<string, string>("item 4", "description 4"),
new Tuple<string, string>("item 5", "description 5"),
}),
new MissionInformation("Mission 2", new List<Tuple<string, string>>()
{
new Tuple<string, string>("item 1", "description 1"),
new Tuple<string, string>("item 2", "description 2"),
new Tuple<string, string>("item 3", "description 3"),
new Tuple<string, string>("item 4", "description 4"),
new Tuple<string, string>("item 5", "description 5"),
}),
};
TabSubmenuItem Item5 = new TabSubmenuItem("TabSubmenuItem", new List<TabItem>()
{
new TabItem("simple TabItem"),
Expand All @@ -281,13 +299,17 @@ public async void OpenCustomPauseMenu()
["Item 5"] = "subItem 5",
["Item 6"] = "subItem 6"
}),
new TabMissionSelectItem("Mission tab", info),
new TabInteractiveListItem("TabInteractiveListItem", items)
});
TabMissionSelectItem Item6 = new TabMissionSelectItem("Mission tab", info);

MenuContainer.AddTab(Item1);
MenuContainer.AddTab(Item2);
MenuContainer.AddTab(Item3);
MenuContainer.AddTab(Item4);
MenuContainer.AddTab(Item5);
MenuContainer.AddTab(Item6);
// this way we can choose which tab is the defualt one
Item1.Active = true;
Item1.Focused = true;
Expand Down
3 changes: 1 addition & 2 deletions NativeUI/PauseMenu/TabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ public virtual void Draw()
{
if (!Visible) return;

var res = ScreenTools.ResolutionMaintainRatio;

if (UseDynamicPositionment)
{
SafeSize = new PointF(300, 240);

TopLeft = new PointF(SafeSize.X, SafeSize.Y);
BottomRight = new PointF((int)res.Width - SafeSize.X, (int)res.Height - SafeSize.Y);
BottomRight = new PointF((int)Resolution.Width - SafeSize.X, (int)Resolution.Height - SafeSize.Y);
}

var rectSize = new SizeF(BottomRight.SubtractPoints(TopLeft));
Expand Down
38 changes: 20 additions & 18 deletions NativeUI/PauseMenu/TabMissionSelectItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public MissionLogo(string textureDict, string textureName)

public class TabMissionSelectItem : TabItem
{
protected internal float _add = 0;
public TabMissionSelectItem(string name, IEnumerable<MissionInformation> list) : base(name)
{
base.FadeInWhenFocused = true;
Expand Down Expand Up @@ -148,68 +149,69 @@ public override void Draw()
base.Draw();
if (Heists.Count == 0) return;

var activeWidth = Resolution.Width - SafeSize.X * 2;
var itemSize = new SizeF((int)activeWidth - 515, 40);

var alpha = Focused ? 120 : 30;
var blackAlpha = Focused ? 200 : 100;
var fullAlpha = Focused ? 255 : 150;

Debug.WriteLine("_add = " + _add);
var activeWidth = Resolution.Width - SafeSize.X * 2;
var itemSize = new SizeF((int)activeWidth - (_add + 515), 40);
Debug.WriteLine("itemsize = " + itemSize);
Debug.WriteLine("activeWidth = " + activeWidth);
var counter = 0;
for (int i = _minItem; i < Math.Min(Heists.Count, _maxItem); i++)
{
new UIResRectangle(SafeSize.AddPoints(new PointF(0, (itemSize.Height + 3) * counter)), itemSize, (Index == i && Focused) ? Color.FromArgb(fullAlpha, Colors.White) : Color.FromArgb(blackAlpha, Colors.Black)).Draw();
new UIResText(Heists[i].Name, SafeSize.AddPoints(new PointF(6, 5 + (itemSize.Height + 3) * counter)), 0.35f, Color.FromArgb(fullAlpha, (Index == i && Focused) ? Colors.Black : Colors.White)).Draw();
new UIResRectangle(SafeSize.AddPoints(new PointF(0, 43 * counter)), itemSize, (Index == i && Focused) ? Color.FromArgb(fullAlpha, Colors.White) : Color.FromArgb(blackAlpha, Colors.Black)).Draw();
new UIResText(Heists[i].Name, SafeSize.AddPoints(new PointF(6, 5 + 43 * counter)), 0.35f, Color.FromArgb(fullAlpha, (Index == i && Focused) ? Colors.Black : Colors.White)).Draw();
counter++;
}

if (Heists[Index].Logo == null || string.IsNullOrEmpty(Heists[Index].Logo.FileName))
{
_noLogo.Position = new PointF((int)Resolution.Width - SafeSize.X - 512, SafeSize.Y);
_noLogo.Position = new PointF((int)Resolution.Width - SafeSize.X - (512 + _add), SafeSize.Y);
_noLogo.Color = Color.FromArgb(blackAlpha, 0, 0, 0);
_noLogo.Draw();
}
else if (Heists[Index].Logo != null && Heists[Index].Logo.FileName != null && !Heists[Index].Logo.IsGameTexture)
{
var target = Heists[Index].Logo.FileName;
//var target = Heists[Index].Logo.FileName;
//Sprite.DrawTexture(target, new PointF((int)Resolution.Width - SafeSize.X - 512, SafeSize.Y), new SizeF(512, 256));
}
else if (Heists[Index].Logo != null && Heists[Index].Logo.FileName != null &&
Heists[Index].Logo.IsGameTexture)
{
var newLogo = new Sprite(Heists[Index].Logo.DictionaryName, Heists[Index].Logo.FileName, new PointF(), new SizeF(512, 256))
var newLogo = new Sprite(Heists[Index].Logo.DictionaryName, Heists[Index].Logo.FileName, new PointF((int)Resolution.Width - SafeSize.X - (512 + _add), SafeSize.Y), new SizeF(512, 256))
{
Position = new PointF((int)Resolution.Width - SafeSize.X - 512, SafeSize.Y),
Color = Color.FromArgb(blackAlpha, 0, 0, 0)
};
newLogo.Draw();
}

new UIResRectangle(new PointF((int)Resolution.Width - SafeSize.X - 512, SafeSize.Y + 256), new SizeF(512, 40), Color.FromArgb(fullAlpha, Colors.Black)).Draw();
new UIResText(Heists[Index].Name, new PointF((int)Resolution.Width - SafeSize.X - 4, SafeSize.Y + 260), 0.5f, Color.FromArgb(fullAlpha, Colors.White),
new UIResRectangle(new PointF((int)Resolution.Width - SafeSize.X - (512 + _add), SafeSize.Y + 256), new SizeF(512, 40), Color.FromArgb(fullAlpha, Colors.Black)).Draw();
new UIResText(Heists[Index].Name, new PointF((int)Resolution.Width - SafeSize.X - (4 + _add), SafeSize.Y + 260), 0.5f, Color.FromArgb(fullAlpha, Colors.White),
Font.HouseScript, Alignment.Right).Draw();

for (int i = 0; i < Heists[Index].ValueList.Count; i++)
{
new UIResRectangle(new PointF((int)Resolution.Width - SafeSize.X - 512, SafeSize.Y + 256 + 40 + (40 * i)),
new UIResRectangle(new PointF((int)Resolution.Width - SafeSize.X - (512 + _add), SafeSize.Y + 256 + 40 + (40 * i)),
new SizeF(512, 40), i % 2 == 0 ? Color.FromArgb(alpha, 0, 0, 0) : Color.FromArgb(blackAlpha, 0, 0, 0)).Draw();
var text = Heists[Index].ValueList[i].Item1;
var label = Heists[Index].ValueList[i].Item2;


new UIResText(text, new PointF((int)Resolution.Width - SafeSize.X - 506, SafeSize.Y + 260 + 42 + (40 * i)), 0.35f, Color.FromArgb(fullAlpha, Colors.White)).Draw();
new UIResText(label, new PointF((int)Resolution.Width - SafeSize.X - 6, SafeSize.Y + 260 + 42 + (40 * i)), 0.35f, Color.FromArgb(fullAlpha, Colors.White), Font.ChaletLondon, Alignment.Right).Draw();
new UIResText(text, new PointF((int)Resolution.Width - SafeSize.X - (506 + _add), SafeSize.Y + 260 + 42 + (40 * i)), 0.35f, Color.FromArgb(fullAlpha, Colors.White)).Draw();
new UIResText(label, new PointF((int)Resolution.Width - SafeSize.X - (6 + _add), SafeSize.Y + 260 + 42 + (40 * i)), 0.35f, Color.FromArgb(fullAlpha, Colors.White), Font.ChaletLondon, Alignment.Right).Draw();
}

if (!string.IsNullOrEmpty(Heists[Index].Description))
{
var propLen = Heists[Index].ValueList.Count;
new UIResRectangle(new PointF((int)Resolution.Width - SafeSize.X - 512, SafeSize.Y + 256 + 42 + 40 * propLen),
new UIResRectangle(new PointF((int)Resolution.Width - SafeSize.X - (512 + _add), SafeSize.Y + 256 + 42 + 40 * propLen),
new SizeF(512, 2), Color.FromArgb(fullAlpha, Colors.White)).Draw();
new UIResText(Heists[Index].Description,
new PointF((int)Resolution.Width - SafeSize.X - 508, SafeSize.Y + 256 + 45 + 40 * propLen + 4), 0.35f,
Color.FromArgb(fullAlpha, Colors.White)) { Wrap = 508 }.Draw();
new UIResRectangle(new PointF((int)Resolution.Width - SafeSize.X - 512, SafeSize.Y + 256 + 44 + 40 * propLen),
new PointF((int)Resolution.Width - SafeSize.X - (508 + _add), SafeSize.Y + 256 + 45 + 40 * propLen + 4), 0.35f,
Color.FromArgb(fullAlpha, Colors.White)) { Wrap = (508 + _add) }.Draw();
new UIResRectangle(new PointF((int)Resolution.Width - SafeSize.X - (512 + _add), SafeSize.Y + 256 + 44 + 40 * propLen),
new SizeF(512, 45 * (int)(ScreenTools.GetTextWidth(Heists[Index].Description, Font.ChaletLondon, 0.35f) / 500)),
Color.FromArgb(blackAlpha, 0, 0, 0)).Draw();
}
Expand Down
4 changes: 4 additions & 0 deletions NativeUI/PauseMenu/TabSubmenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public override void Draw()
Items[Index].SafeSize = SafeSize.AddPoints(new PointF((int)activeWidth - submenuWidth, 0));
Items[Index].TopLeft = SafeSize.AddPoints(new PointF((int)activeWidth - submenuWidth, 0));
Items[Index].BottomRight = new PointF((int)Resolution.Width - SafeSize.X, (int)Resolution.Height - SafeSize.Y);
if (Items[Index] is TabMissionSelectItem it)
{
it._add = -420;
}
Items[Index].Draw();
}
}
Expand Down

0 comments on commit 0c63a2d

Please sign in to comment.