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>
        /// 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();
            }
        }