ESOUI SVN TaosGroupUltimate

[/] [trunk/] [TaosGroupUltimate/] [util/] [UiHelper.lua] - Rev 46

Go to most recent revision | Compare with Previous | Blame | View Log

--[[
        Addon: util
        Author: TProg Taonnor
        Created by @Taonnor
]]--

--[[
        Class definition (Static class)
]]--
-- A table in hole lua workspace must be unique
-- The ui helper is global util table, used in several of my addons
-- The table is created as "static" class without constructor and static helper methods
if (TaosUiHelper == nil) then
        TaosUiHelper = {}
        TaosUiHelper.__index = TaosUiHelper

    --[[
                Creates a ZO_FadeSceneFragment of given Control with specific "SetHidden" behavior
        ]]--
    function TaosUiHelper:CreateFadeSceneFragment(control)
            local fragment = ZO_FadeSceneFragment:New(control)
        
            fragment:RegisterCallback("StateChange",
                    function (oldState, newState)
                            if (newState == SCENE_FRAGMENT_HIDING) then
                                    control:SetHidden(true)
                            end
                    end)
        
            return fragment
    end

    --[[
                Adds a SceneFragment to default "hud" scene, which consists of reticle and mouse scene
        ]]--
    function TaosUiHelper:AddFragmentToHudScene(fragment)
        SCENE_MANAGER:GetScene("hud"):AddFragment(fragment) -- Reticle Scene
                SCENE_MANAGER:GetScene("hudui"):AddFragment(fragment) -- Mouse Scene
    end

    --[[
                Removes a SceneFragment from default "hud" scene, which consists of reticle and mouse scene
        ]]--
    function TaosUiHelper:RemoveFragmentFromHudScene(fragment)
        SCENE_MANAGER:GetScene("hud"):RemoveFragment(fragment) -- Reticle Scene
                SCENE_MANAGER:GetScene("hudui"):RemoveFragment(fragment) -- Mouse Scene
    end

end

Go to most recent revision | Compare with Previous | Blame