feat: increment (#149)

This commit is contained in:
iSentrie
2023-02-02 02:51:56 +02:00
committed by GitHub
parent 9480d89429
commit d2b92f67ec

View File

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