67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
import * as NativeUI from '../../libs/NativeUI';
|
|
|
|
const Menu = NativeUI.Menu;
|
|
const MenuItem = NativeUI.UIMenuItem;
|
|
const MenuListItem = NativeUI.UIMenuListItem;
|
|
const MenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
|
|
const BadgeStyle = NativeUI.BadgeStyle;
|
|
const Point = NativeUI.Point;
|
|
const ItemsCollection = NativeUI.ItemsCollection;
|
|
const Color = NativeUI.Color;
|
|
|
|
export default function ammunation(globalData: IGlobalData) {
|
|
|
|
var screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
|
var weapons: Weapon[];
|
|
|
|
mp.events.add("AmmunationShop:LoadNativeUI", (weaponList: string) => {
|
|
mp.gui.chat.push("a "+ weaponList);
|
|
//mp.gui.chat.activate(false);
|
|
//globalData.InMenu = true;
|
|
weapons = JSON.parse(weaponList);
|
|
mp.gui.chat.push("b " +weapons.toString());
|
|
|
|
var menu = getAmmunationMenu();
|
|
|
|
//Schaut nach ob mindestens eine Waffe in weapons existiert welche die CategoryId beinhaltet
|
|
for (var c = 1; c < 9; c++) {
|
|
switch (c) {
|
|
case 1: {//Meelee
|
|
|
|
break;
|
|
}
|
|
|
|
case 2: {//Pistolen
|
|
if (weapons.find(w => w.CategoryId == c)) {
|
|
var pistolItem = new MenuItem("Pistolen", "",);
|
|
menu.AddItem(pistolItem);
|
|
menu.BindMenuToItem(getWeaponsFromCategory(menu, c, "Pistolen"),pistolItem);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
function getAmmunationMenu(): NativeUI.Menu {
|
|
return new Menu("Ammunation", "", new Point(0, screenRes.y / 3), null, null);
|
|
}
|
|
|
|
function getWeaponsFromCategory(parentMenu: NativeUI.Menu, category: number, categoryName: string): NativeUI.Menu {
|
|
var categoryMenu = new Menu(categoryName, "", new Point(0, screenRes.y / 3), null, null);
|
|
|
|
var cWeapons: Weapon[] = weapons.filter(w => w.CategoryId == category);
|
|
|
|
cWeapons.forEach(weapon => {
|
|
var menuItem = new MenuItem(weapon.WeaponModel, "Munition: " + weapon.Ammo);
|
|
categoryMenu.AddItem(menuItem);
|
|
menuItem.SetRightLabel("~g~$~w~" + weapon.Price.toString());
|
|
})
|
|
|
|
return categoryMenu;
|
|
|
|
};
|
|
}; |