conditoinally show a scene fragment
hi hive-dev-mind.
I have an addon that I need to show, via an on/off toggle conditionally. I can't get the fragment to stay hidden, after first enabling it, and then disabling it. I saw this post and tried the following: Code:
fragment:SetConditional(function() Ive also tried conditional code in a conventional callback, like this: Code:
function Ui:ShowHideTLC(makeVis) I have a feeling Im overcomplicating it, as I tend to do, but I cant figure it out. I'm new to Lua, let alone ESOUI. Thanks! |
It definitely looks like you're overcomplicating it :-)
This is just off the top of my head, so hopefully I'm not talking rubbish, but: Try creating your tlcFragment as you are, then add it to the hud/hudui (or whereever you want it to show)eg. Code:
SCENE_MANAGER:GetScene("hud"):AddFragment(tlcFragment) Code:
tlcFragment:SetHiddenForReason("disabled", true) Code:
tlcFragment:SetHiddenForReason("disabled", false) If you like, you can use ZO_HUDFadeSceneFragment to have your fragment fade in/out - you just add a couple of extra parameters to the SetHiddenForReason call, eg. Code:
tlcFragment:SetHiddenForReason("disable", true, FADE_IN_TIMEIN_MS, FADE_OUT_TIME_IN_MS) |
thanks for looking at this for me!
The adding to the scene works fine which I do in the CreateUI function. The SetHiddenForReason call feels like exactly what I need. Ive tried to implement it as follows: Code:
function Ui:ToggleShow() Quote:
|
I'm not near my machine at the moment - have your tried just using
fragment:Show() and fragment:Hide() |
Only fragments support that function where ZO_MixinHideableSceneFragment was used during their initialization,
like ZO_ActionLayerFragment or ZO_HUDFadeSceneFragment You need to use on of the fragments or call ZO_MixinHideableSceneFragment (yourFragmentObject) to add the function to your fragment. See ZOs code at: esoui/libraries/zo_scene/zo_scenefragmenttemplates.lua |
woo! it worked. I did a combo of things from what you've said and some others.
For anyone else, here's what worked for me. Code:
local settings = { It was necessary to wrap in a ~= as it seemed to be hitting some kind of non-initialised race condition. Theres probably a better way of doing that part. Thanks again for your help! |
Quote:
This is an addon I'm likely taking over, so if I do, I might refactor in that format. |
All times are GMT -6. The time now is 01:40 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI