View Single Post
03/16/23, 03:16 PM   #9
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
It should be enough to create your IO_BLUR_FRAGMENT fragment and add it to HUD_SCENE once
Code:
HUD_SCENE:AddFragment(IO_BLUR_FRAGMENT)
Attention: This will make it show as soon as you close a menu, or move, as the HUD_SCENE will be shown then.
To prevent this you'd have to either remove the fragment from the HUD_SCENE if it should not show, or add some condition at the
OnStateChange callback (see one of my last posts about it): As the FRAGMENT_STATE_SHOWING occurs -> check the actual stamina and if it's above the threshold hide the fragment again!
Shoudl be possible via IO_BLUR_FRAGMENT:Hide()

For your stamina OnPowerUpdate checks:
Scene fragments should use the base class ZO_HideableSceneFragmentMixin, and that class provides a function
:SetHiddenForReason()
Code:
ZO_HideableSceneFragmentMixin:SetHiddenForReason(reason, hidden, customShowDuration, customHideDuration)
So you could use that function to show/hide the fragment based on the stamina percentage:
Lua Code:
  1. IO_BLUR_FRAGMENT:SetHiddenForReason("StaminaThresholdChecks_FreeTextAfaik", (staminaPercent > thresholdValue and true) or false, 0, 0)



Edit:
Example code
Lua Code:
  1. local function hideTLCIfNotStaminaThresholdMet()
  2.  return currentPlayerStamina > thresHoldStamina --return true = hide, if stamina is high enough
  3. end
  4.  
  5. local fragment = ZO_HUDFadeSceneFragment:New(TestTLC, nil, 0)
  6.     local function OnTestTLCFragmentStateChange(oldState, newState)
  7.         if newState == SCENE_FRAGMENT_SHOWING then
  8. d("[TestTLC]Fragment showing")
  9.             fragment:SetHiddenForReason("ShouldntShow", hideTLCIfNotStaminaThresholdMet(), 0, 0)
  10.         --elseif newState == SCENE_FRAGMENT_HIDDEN then
  11.         end
  12.     end
  13.     fragment:RegisterCallback("StateChange", OnTestTLCFragmentStateChange)
  14.     --Hide in menus/Show at fighting UI
  15.     HUD_SCENE:AddFragment(fragment)

Last edited by Baertram : 03/16/23 at 06:35 PM.
  Reply With Quote