Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Jan 28, 2019. It is now read-only.
forked from citizenfx/NativeUI
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMenuExample.cs
More file actions
Latest commit
99 lines (91 loc) · 3.17 KB
/
Copy pathMenuExample.cs
File metadata and controls
99 lines (91 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
usingSystem;
usingSystem.Collections.Generic;
usingNativeUI;
usingCitizenFX.Core;
usingSystem.Threading.Tasks;
publicclassMenuExample:BaseScript
{
privateboolketchup=false;
privatestringdish="Banana";
privateMenuPool_menuPool;
publicvoidAddMenuKetchup(UIMenumenu)
{
varnewitem=newUIMenuCheckboxItem("Add ketchup?",ketchup,"Do you wish to add ketchup?");
menu.AddItem(newitem);
menu.OnCheckboxChange+=(sender,item,checked_)=>
{
if(item==newitem)
{
ketchup=checked_;
CitizenFX.Core.UI.Screen.ShowNotification("~r~Ketchup status: ~b~"+ketchup);
}
};
}
publicvoidAddMenuFoods(UIMenumenu)
{
varfoods=newList<dynamic>
{
"Banana",
"Apple",
"Pizza",
"Quartilicious",
0xF00D,// Dynamic!
};
varnewitem=newUIMenuListItem("Food",foods,0);
menu.AddItem(newitem);
menu.OnListChange+=(sender,item,index)=>
{
if(item==newitem)
{
dish=item.IndexToItem(index).ToString();
CitizenFX.Core.UI.Screen.ShowNotification("Preparing ~b~"+dish+"~w~...");
}
};
}
publicvoidAddMenuCook(UIMenumenu)
{
varnewitem=newUIMenuItem("Cook!","Cook the dish with the appropiate ingredients and ketchup.");
newitem.SetLeftBadge(UIMenuItem.BadgeStyle.Star);
newitem.SetRightBadge(UIMenuItem.BadgeStyle.Tick);
menu.AddItem(newitem);
menu.OnItemSelect+=(sender,item,index)=>
{
if(item==newitem)
{
stringoutput=ketchup?"You have ordered ~b~{0}~w~ ~r~with~w~ ketchup.":"You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";
CitizenFX.Core.UI.Screen.ShowSubtitle(String.Format(output,dish));
}
};
menu.OnIndexChange+=(sender,index)=>
{
if(sender.MenuItems[index]==newitem)
newitem.SetLeftBadge(UIMenuItem.BadgeStyle.None);
};
}
publicvoidAddMenuAnotherMenu(UIMenumenu)
{
varsubmenu=_menuPool.AddSubMenu(menu,"Another Menu");
for(inti=0;i<20;i++)
submenu.AddItem(newUIMenuItem("PageFiller","Sample description that takes more than one line. Moreso, it takes way more than two lines since it's so long. Wow, check out this length!"));
}
publicMenuExample()
{
_menuPool=newMenuPool();
varmainMenu=newUIMenu("Native UI","~b~NATIVEUI SHOWCASE");
_menuPool.Add(mainMenu);
AddMenuKetchup(mainMenu);
AddMenuFoods(mainMenu);
AddMenuCook(mainMenu);
AddMenuAnotherMenu(mainMenu);
_menuPool.RefreshIndex();
Tick+=newFunc<Task>(asyncdelegate
{
_menuPool.ProcessMenus();
if(Game.IsControlJustReleased(1,Control.MultiplayerInfo))// Our menu on/off switch
{
mainMenu.Visible=!mainMenu.Visible;
}
awaitTask.FromResult(0);
});
}
}