Exemplo n.º 1
0
 /// <summary>
 /// Selects the grid item that is currently being highlighted.
 /// </summary>
 public static async void Select()
 {
     PlaySoundFrontend(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", false);
     if (currentHoverIndex != 8 && currentHoverIndex != 6 && currentHoverIndex != 7)
     {
         _scale.CallFunction("SET_GRID_ITEM_VOTE", currentHoverIndex, 0, 0, true, true);
         lastSelection = new KeyValuePair <int, int>(currentPage, currentHoverIndex);
     }
     else if (currentHoverIndex != 7)
     {
         if (currentPage < GridPages.Count() - 1 && currentHoverIndex == 8)
         {
             await ShowPage(currentPage + 1, GridPages.Count());
         }
         if (currentPage > 0 && GridPages.Count() > 1 && currentHoverIndex == 6)
         {
             await ShowPage(currentPage - 1, GridPages.Count());
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Adds a new page to the GridSelector window.
 /// </summary>
 /// <param name="names">A list of the 6 grid item titles/names.</param>
 /// <param name="descriptions">A list of the 6 grid item descriptions.</param>
 /// <param name="textureDicts">A list of the 6 grid item texture dictionary names.</param>
 /// <param name="textureNames">A list of the 6 grid item texture names.</param>
 /// <param name="isFirstPage">Make this the first page, and disable the "previous page" button.</param>
 /// <param name="isLastPage">Make this the last page, and disable the "next page" button.</param>
 public static void AddPage(string[] names, string[] descriptions, string[] textureDicts, string[] textureNames, bool isFirstPage, bool isLastPage)
 {
     if (names.Count() < 6 || descriptions.Count() < 6 || textureDicts.Count() < 6 || textureNames.Count() < 6)
     {
         Debug.WriteLine("Not enough items for this page. Please ensure all (6) required grid items have names, descriptions and a texture dict/name.");
     }
     else
     {
         var items = new Item[9];
         for (var i = 0; i < 6; i++)
         {
             items[i] = new Item()
             {
                 title       = names[i],
                 description = descriptions[i],
                 selected    = false,
                 votes       = 0,
                 textureDict = textureDicts[i],
                 textureName = textureNames[i],
                 enabled     = true
             };
         }
         items[6] = new Item()
         {
             title       = "Previous Page",
             description = "Go to the previous page.",
             enabled     = !isFirstPage,
             selected    = false,
             textureDict = "",
             textureName = "",
             votes       = 0
         };
         items[7] = new Item()
         {
             title       = "Confirm Selection",
             description = "Confirm your selected vehicle and mark yourself as ready, this will lock your selection.",
             enabled     = true,
             selected    = false,
             textureDict = "",
             textureName = "",
             votes       = 0
         };
         items[8] = new Item()
         {
             title       = "Next Page",
             description = "Go to the next page.",
             enabled     = !isLastPage,
             selected    = false,
             textureDict = "",
             textureName = "",
             votes       = 0
         };
         GridPages.Add(new GridPage()
         {
             currentHover = 0,
             isFirstPage  = isFirstPage,
             isLastPage   = isLastPage,
             selected     = -1,
             items        = items
         });
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Shows the page provided by pageIndex.
        /// </summary>
        /// <param name="pageIndex">The page to show.</param>
        /// <param name="maxPages">Used to update the max pages on the top right corner.</param>
        /// <returns></returns>
        public static async Task ShowPage(int pageIndex, int maxPages)
        {
            if (GridPages.Count() < pageIndex)
            {
                Debug.WriteLine("Page does not exist.");
            }
            else
            {
                if (currentPage != pageIndex)
                {
                    if (lastSelection.Key == pageIndex)
                    {
                        await LoadPage(pageIndex, lastSelection.Value, currentHoverIndex, maxPages);
                    }
                    else
                    {
                        await LoadPage(pageIndex, -1, currentHoverIndex, maxPages);
                    }

                    currentPage = pageIndex;
                }
                if (!_scale.IsLoaded)
                {
                    RequestScaleformMovie("MP_NEXT_JOB_SELECTION");
                    while (_scale.IsLoaded)
                    {
                        await Delay(0);
                    }
                }
                if (currentHoverIndex < 6)
                {
                    _scale.CallFunction("SET_SELECTION", currentHoverIndex, GetVehicleName(GridPages[pageIndex].items[currentHoverIndex].title),
                                        GridPages[pageIndex].items[currentHoverIndex].description, false);
                }
                else
                {
                    _scale.CallFunction("SET_SELECTION", currentHoverIndex, GridPages[pageIndex].items[currentHoverIndex].title,
                                        GridPages[pageIndex].items[currentHoverIndex].description, false);
                }
                if (currentPage == lastSelection.Key)
                {
                    for (var i = 0; i < 9; i++)
                    {
                        _scale.CallFunction("SET_GRID_ITEM_VOTE", i, 0, 0, false, false);
                    }
                    _scale.CallFunction("SET_GRID_ITEM_VOTE", lastSelection.Value, 1, 0, true, false);
                }
                else
                {
                    if (lastSelection.Value == 7)
                    {
                        for (var i = 0; i < 9; i++)
                        {
                            _scale.CallFunction("SET_GRID_ITEM_VOTE", i, 0, 0, false, false);
                        }
                        _scale.CallFunction("SET_GRID_ITEM_VOTE", lastSelection.Value, 1, 0, true, false);
                    }
                }
                _scale.Render2D();
            }
        }