Skip to content

Commit

Permalink
fix: miss used flag
Browse files Browse the repository at this point in the history
  • Loading branch information
swkeep committed Sep 13, 2024
1 parent d1996ee commit 9f9f1b9
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions interactionMenu/lua/client/menuContainer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1111,13 +1111,16 @@ local function check_restrictions(restrictions)
end

local function frameworkOptionVisibilityRestrictions(updatedElements, menuId, option, optionIndex, menuOriginalData, pt)
-- #TODO: refactor and add new restrictions
if not Bridge.active then return false end

local shouldHide = false
if option.item then
local res = Bridge.hasItem(option.item)
shouldHide = type(res) == "boolean" and not res
elseif option.job then
end

if option.job or option.gang then
local res = check_restrictions({
job = option.job,
gang = option.gang
Expand All @@ -1126,8 +1129,11 @@ local function frameworkOptionVisibilityRestrictions(updatedElements, menuId, op
end

option.flags.hide = shouldHide

return false
if option.flags.hide == shouldHide then
return false
else
return true
end
end

--- calculate canInteract and update values and refresh UI
Expand All @@ -1154,20 +1160,19 @@ function Container.syncData(scaleform, menuData, refreshUI)
local deleted = menuOriginalData.flags.deleted

if not deleted then
-- menuOriginalData.flags.hide = Container.triggerInteraction(menuId, 'canInteract') or false

for optionIndex, option in ipairs(menu.options) do
local already_inserted = false
-- #TODO: I think we should pass already_inserted to next step and check so we don't override it!
already_inserted = evaluateDynamicValue(updatedElements, menuId, option, optionIndex, menuOriginalData,
passThrough)
already_inserted = evaluateBindValue(updatedElements, menuId, option, optionIndex, menuOriginalData,
passThrough)
already_inserted = updateOptionVisibility(updatedElements, menuId, option, optionIndex, menuOriginalData,
passThrough)
already_inserted = frameworkOptionVisibilityRestrictions(updatedElements, menuId, option, optionIndex,
menuOriginalData,
passThrough)
local result = evaluateDynamicValue(updatedElements, menuId, option, optionIndex, menuOriginalData, passThrough)
if result then already_inserted = true end

result = evaluateBindValue(updatedElements, menuId, option, optionIndex, menuOriginalData, passThrough)
if result then already_inserted = true end

result = updateOptionVisibility(updatedElements, menuId, option, optionIndex, menuOriginalData, passThrough)
if result then already_inserted = true end

result = frameworkOptionVisibilityRestrictions(updatedElements, menuId, option, optionIndex, menuOriginalData, passThrough)
if result then already_inserted = true end

-- to hide option if its canInteract value has been changed
if not already_inserted and option.flags.hide ~= nil and option.flags.hide ~= option.flags.previous_hide then
Expand Down

0 comments on commit 9f9f1b9

Please sign in to comment.