Beispiel #1
0
        public void OpenMenu(IMenu menu, Delegate callback)
        {
            if (menu.IsNullOrDefault())
            {
                return;
            }

            var dictionaryLoaded = API.HasStreamedTextureDictLoaded(menu.Dictionary);

            if (!Loaded || !dictionaryLoaded)
            {
                Task.Run(() => MenuVLoadTick(dictionaryLoaded, menu, callback));
                return;
            }

            if (CurrentMenu != null)
            {
                ParentMenus.Add(CurrentMenu);

                CurrentMenu.RemoveOnEvent("update", CurrentUpdateUUID);
                CurrentMenu.RemoveOnEvent("ichange", CurrentItemUpdateUUID);
            }

            CurrentMenu = menu;

            CurrentUpdateUUID = menu.On(
                "update",
                (m, parameters) =>
            {
                var key = (parameters.Length > 0 ? parameters[0] : "unknown") is string v ? v : string.Empty;

                if (string.IsNullOrWhiteSpace(key))
                {
                    return;
                }

                var value = parameters.Length > 1 ? parameters[1] : null;

                switch (key)
                {
                case "title":
                case "Title":
                    SendNuiMessage(new { action = "UPDATE_TITLE", title = value is string t ? t : string.Empty });