Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Items/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ local function NewItem(menu, title)

if (self.hovered) then
Citizen.CreateThread(function()
self.OnStartHover()
if (self.OnStartHover) then
self.OnStartHover()
end
end)
else
Citizen.CreateThread(function()
self.OnEndHover()
if (self.OnEndHover) then
self.OnEndHover()
end
end)
end
end
Expand Down Expand Up @@ -113,7 +117,13 @@ local function NewItem(menu, title)
end

Citizen.CreateThread(function()
self.OnActivate()
if (self.OnActivate) then
while IsDisabledControlPressed(0, 24) do
Citizen.Wait(0)
end

self.OnActivate()
end
end)

if (self.closeOnActivate) then
Expand All @@ -127,7 +137,9 @@ local function NewItem(menu, title)
end

Citizen.CreateThread(function()
self.OnRelease()
if (self.OnRelease) then
self.OnRelease()
end
end)
end

Expand Down
31 changes: 19 additions & 12 deletions Menu/MenuPool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ local disabledControls = {
1, 2, 16, 17, 24, 25, 68, 69, 70, 91, 92, 330, 331, 347, 257
}

local isKeyToggled = false
local isKeyToggledSinceLastTick = false

local function NewMenuPool()
local self = setmetatable({}, MenuPool)

self.menus = {}

self.keys = {
keyboard = {
holdForCursor = holdKey or 19,
interact = interactKey or 25,
activateItem = activateItemKey or 24
}
Expand Down Expand Up @@ -41,7 +43,7 @@ local function NewMenuPool()
return
end

if (IsControlJustPressed(0, self.keys.keyboard.holdForCursor) or IsDisabledControlJustPressed(0, self.keys.keyboard.holdForCursor)) then
if (isKeyToggled and not isKeyToggledSinceLastTick) then
if (self:IsAnyMenuOpen()) then
self:CloseAllMenus()
end
Expand All @@ -50,10 +52,12 @@ local function NewMenuPool()

local resX, resY = GetActiveScreenResolution()
resolution = vector2(resX, resY)

isKeyToggledSinceLastTick = true
end

--not self.settings.holdKeyWithMenuOpen and self:IsAnyMenuOpen()
if (IsControlPressed(0, self.keys.keyboard.holdForCursor) or IsDisabledControlPressed(0, self.keys.keyboard.holdForCursor)) then
if (isKeyToggled and isKeyToggledSinceLastTick) then
SetMouseCursorActiveThisFrame()

local cursorPosition = GetCursorScreenPosition()
Expand Down Expand Up @@ -159,17 +163,10 @@ local function NewMenuPool()
SetMouseCursorSprite(6)
end

-- causes camera problems
--if (screenPosition.y > (resolution.y - 10.0) / resolution.y) then
-- SetGameplayCamRelativePitch(GetGameplayCamRelativePitch() - 25.0 * frameTime, 1.0)
-- SetMouseCursorSprite(9)
--elseif (screenPosition.y < 10.0 / resolution.y) then
-- SetGameplayCamRelativePitch(GetGameplayCamRelativePitch() + 25.0 * frameTime, 1.0)
-- SetMouseCursorSprite(8)
--end
end
elseif (IsControlJustReleased(0, self.keys.keyboard.holdForCursor) or IsDisabledControlJustReleased(0, self.keys.keyboard.holdForCursor)) then
elseif (isKeyToggledSinceLastTick) then
self:Reset()
isKeyToggledSinceLastTick = false
end
end

Expand Down Expand Up @@ -250,3 +247,13 @@ function MenuPool:AddAlternateFunction(_key, _Func)
Func = _Func
})
end

RegisterCommand("+context_menu", function()
isKeyToggled = true
end, false)

RegisterCommand("-context_menu", function()
isKeyToggled = false
end, false)

RegisterKeyMapping("+context_menu", "Context Menu", "keyboard", "LMENU")