Add Menu scroll Increment Toggle (#154)

* feat: increment (#149)

* feat: increment att. 2 (#150)

* feat: increment

* changes

* language

* indentations

* indent

* General Improvements (#152)

* style: style changes

* chore: update native name

* fix: add missing argument to ResetPedMovementClipset

* refactor: remove unused code

* refactor: better gender check

* refactor/style: merge to one line and correct argument

---------

Co-authored-by: Mads <madsleander@outlook.com>

* feat: increment for faster surfing lists (#153)

* feat: increment

* changes

* language

* indentations

* indent

* General Improvements (#152)

* style: style changes

* chore: update native name

* fix: add missing argument to ResetPedMovementClipset

* refactor: remove unused code

* refactor: better gender check

* refactor/style: merge to one line and correct argument

* instructional button fix

---------

Co-authored-by: Mads <madsleander@outlook.com>

---------

Co-authored-by: iSentrie <xvender7@gmail.com>
Co-authored-by: Mads <madsleander@outlook.com>
This commit is contained in:
TayMcKenzieNZ
2023-02-02 14:37:02 +13:00
committed by GitHub
parent 1677e346d2
commit dd2d8ec817
3 changed files with 52 additions and 20 deletions

View File

@@ -2423,6 +2423,9 @@ function UIMenu.New(Title, Subtitle, X, Y, TxtDictionary, TxtName)
}, },
Down = { Down = {
Enabled = true, Enabled = true,
},
Increment = {
Enabled = true,
} }
}, },
ParentMenu = nil, ParentMenu = nil,
@@ -2868,6 +2871,8 @@ function UIMenu:Visible(bool)
end end
end end
local paginationValue = 1
function UIMenu:ProcessControl() function UIMenu:ProcessControl()
if not self._Visible then if not self._Visible then
return return
@@ -2882,6 +2887,15 @@ function UIMenu:ProcessControl()
self:GoBack() self:GoBack()
end end
if self.Controls.Increment.Enabled and (IsDisabledControlJustReleased(0, 19) or IsDisabledControlJustReleased(1, 19) or IsDisabledControlJustReleased(2, 19)) then
if paginationValue == 1 then
paginationValue = 10
else
paginationValue = 1
end
self:Visible(true)
end
if #self.Items == 0 then if #self.Items == 0 then
return return
end end
@@ -2972,6 +2986,10 @@ function UIMenu:ProcessControl()
end end
function UIMenu:GoUpOverflow() function UIMenu:GoUpOverflow()
if self:CurrentSelection() < 10 then
paginationValue = 1
end
if #self.Items <= self.Pagination.Total + 1 then if #self.Items <= self.Pagination.Total + 1 then
return return
end end
@@ -2985,10 +3003,10 @@ function UIMenu:GoUpOverflow()
self.ActiveItem = self.ActiveItem + (#self.Items - 1) self.ActiveItem = self.ActiveItem + (#self.Items - 1)
self.Items[self:CurrentSelection()]:Selected(true) self.Items[self:CurrentSelection()]:Selected(true)
else else
self.Pagination.Min = self.Pagination.Min - 1 self.Pagination.Min = self.Pagination.Min - paginationValue
self.Pagination.Max = self.Pagination.Max - 1 self.Pagination.Max = self.Pagination.Max - paginationValue
self.Items[self:CurrentSelection()]:Selected(false) self.Items[self:CurrentSelection()]:Selected(false)
self.ActiveItem = self.ActiveItem - 1 self.ActiveItem = self.ActiveItem - paginationValue
self.Items[self:CurrentSelection()]:Selected(true) self.Items[self:CurrentSelection()]:Selected(true)
end end
else else
@@ -3014,6 +3032,10 @@ function UIMenu:GoUp()
end end
function UIMenu:GoDownOverflow() function UIMenu:GoDownOverflow()
if self:CurrentSelection() > (#self.Items - 10) then
paginationValue = 1
end
if #self.Items <= self.Pagination.Total + 1 then if #self.Items <= self.Pagination.Total + 1 then
return return
end end
@@ -3026,10 +3048,10 @@ function UIMenu:GoDownOverflow()
self.ActiveItem = 1000 - (1000 % #self.Items) self.ActiveItem = 1000 - (1000 % #self.Items)
self.Items[self:CurrentSelection()]:Selected(true) self.Items[self:CurrentSelection()]:Selected(true)
else else
self.Pagination.Max = self.Pagination.Max + 1 self.Pagination.Max = self.Pagination.Max + paginationValue
self.Pagination.Min = self.Pagination.Max - (self.Pagination.Total + 1) self.Pagination.Min = self.Pagination.Max - (self.Pagination.Total + 1)
self.Items[self:CurrentSelection()]:Selected(false) self.Items[self:CurrentSelection()]:Selected(false)
self.ActiveItem = self.ActiveItem + 1 self.ActiveItem = self.ActiveItem + paginationValue
self.Items[self:CurrentSelection()]:Selected(true) self.Items[self:CurrentSelection()]:Selected(true)
end end
else else
@@ -3584,15 +3606,24 @@ function UIMenu:UpdateScaleform()
PopScaleformMovieFunction() PopScaleformMovieFunction()
end end
local count = 2 if self.Controls.Increment.Enabled then
PushScaleformMovieFunction(self.InstructionalScaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(3)
PushScaleformMovieFunctionParameterString(GetControlInstructionalButton(2, 19, 0))
PushScaleformMovieFunctionParameterString(Config.Languages[lang]['btn_increment']..(paginationValue and ': '..paginationValue or ": "..paginationValue))
PopScaleformMovieFunction()
end
local count = 3
for i = 1, #self.InstructionalButtons do for i = 1, #self.InstructionalButtons do
if self.InstructionalButtons[i] then if self.InstructionalButtons[i] then
if #self.InstructionalButtons[i] == 2 then if #self.InstructionalButtons[i] == 3 then
PushScaleformMovieFunction(self.InstructionalScaleform, "SET_DATA_SLOT") PushScaleformMovieFunction(self.InstructionalScaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(count) PushScaleformMovieFunctionParameterInt(count)
PushScaleformMovieFunctionParameterString(self.InstructionalButtons[i][1]) PushScaleformMovieFunctionParameterString(self.InstructionalButtons[i][1])
PushScaleformMovieFunctionParameterString(self.InstructionalButtons[i][2]) PushScaleformMovieFunctionParameterString(self.InstructionalButtons[i][2])
PushScaleformMovieFunctionParameterString(self.InstructionalButtons[i][3])
PopScaleformMovieFunction() PopScaleformMovieFunction()
count = count + 1 count = count + 1
end end

View File

@@ -318,6 +318,7 @@ Config.Languages = {
['btn_select'] = "Select", ['btn_select'] = "Select",
['btn_back'] = "Back", ['btn_back'] = "Back",
['btn_switch'] = "Movement", ['btn_switch'] = "Movement",
['btn_increment'] = "Increment"
}, },
['fi'] = { -- Finnish 🇫🇮 ['fi'] = { -- Finnish 🇫🇮
['emotes'] = 'Animaatiot 🎬', ['emotes'] = 'Animaatiot 🎬',

View File

@@ -47,23 +47,23 @@ local FavoriteEmote = ""
if Config.FavKeybindEnabled then if Config.FavKeybindEnabled then
RegisterCommand('emotefav', function() FavKeybind() end) RegisterCommand('emotefav', function() FavKeybind() end)
RegisterKeyMapping("emotefav", "Execute your favorite emote", "keyboard", Config.FavKeybind) RegisterKeyMapping("emotefav", "Execute your favorite emote", "keyboard", Config.FavKeybind)
local doingFavoriteEmote = false local doingFavoriteEmote = false
function FavKeybind()
if doingFavoriteEmote == false then function FavKeybind()
doingFavoriteEmote = true if doingFavoriteEmote == false then
if not IsPedSittingInAnyVehicle(PlayerPedId()) then doingFavoriteEmote = true
if FavoriteEmote ~= "" and (not CanUseFavKeyBind or CanUseFavKeyBind()) then if not IsPedSittingInAnyVehicle(PlayerPedId()) then
EmoteCommandStart(nil, { FavoriteEmote, 0 }) if FavoriteEmote ~= "" and (not CanUseFavKeyBind or CanUseFavKeyBind()) then
Wait(500) EmoteCommandStart(nil, { FavoriteEmote, 0 })
end Wait(500)
end end
else
EmoteCancel()
doingFavoriteEmote = false
end end
else
EmoteCancel()
doingFavoriteEmote = false
end
end end
end end