ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Player Progress Bar Auto Hiding (https://www.esoui.com/forums/showthread.php?t=1897)

L8Knight 07/03/14 10:24 AM

Player Progress Bar Auto Hiding
 
I wrote an experience bar add-on that always displays the player progress bar (a.k.a. experience bar). I make use of scene manager to take care of hiding and showing the add-on.

Lua Code:
  1. SCENE_MANAGER:GetScene("hud"):AddFragment(ZO_PlayerProgressBarCurrentFragment)
  2. SCENE_MANAGER:GetScene("hudui"):AddFragment(ZO_PlayerProgressBarCurrentFragment)
  3. SCENE_MANAGER:GetScene("interact"):AddFragment(ZO_PlayerProgressBarCurrentFragment)

This works really well and takes care of most of the heavy lifting. The only other event I need to track is when experience is gained. In that event I update my text label and flash the amount gained.

My problem is when the player is a veteran. For some reason, when a veteran player kills a mob the progress bar is hidden. I see an extra "OnHide" event called after the experience gain events. This does not happen prior to veteran status. I can redisplay the bar by shifting in and out of a scene (like opening and closing my inventory view).

I need some help debugging and troubleshooting this. If anyone has any ideas please share them. I'm not sure how to find out what is causing the progress bar to be hidden.

I have a temporary fix in the latest version of my add-on that calls ZO_PlayerProgressBarCurrentFragment:RefreshBaseType() to redisplay the progress bar, but this ends up causing a "flash" of the bar that I would like to avoid.

Garkin 07/03/14 10:56 AM

I'm not really sure why, but there are 2 progress bar fragments:
PLAYER_PROGRESS_BAR_FRAGMENT
PLAYER_PROGRESS_BAR_CURRENT_FRAGMENT
Most of the scenes contains both fragments, so I believe that you will need to show both of them.

This is how it is done in Azurah and it seems to be working:
Lua Code:
  1. --db.displayStyle == 1 --UI default
  2. --db.displayStyle == 2 --always shown
  3. --db.displayStyle == 2 --always hidden
  4.  
  5. local function OnCraftStart()
  6.    if (db.displayStyle == 2) then
  7.       ZO_PlayerProgressBar:SetAlpha(0)
  8.    end
  9. end
  10.  
  11. local function OnCraftEnd()
  12.    if (db.displayStyle == 2) then
  13.       ZO_PlayerProgressBar:SetAlpha(1)
  14.    end
  15. end
  16.  
  17. function Azurah:ConfigureExperienceBarDisplay()
  18.    --if conditional returns false, fragment will not be shown on the scene
  19.    PLAYER_PROGRESS_BAR_FRAGMENT:SetConditional(function() return not (db.displayStyle == 3) end)
  20.    PLAYER_PROGRESS_BAR_CURRENT_FRAGMENT:SetConditional(function() return not (db.displayStyle == 3) end)
  21.  
  22.    if db.displayStyle == 2 then
  23.       EVENT_MANAGER:RegisterForEvent(self.name .. 'Experience', EVENT_CRAFTING_STATION_INTERACT,      OnCraftStart)
  24.       EVENT_MANAGER:RegisterForEvent(self.name .. 'Experience', EVENT_END_CRAFTING_STATION_INTERACT,  OnCraftEnd)
  25.       HUD_SCENE:AddFragment(PLAYER_PROGRESS_BAR_FRAGMENT)
  26.       HUD_SCENE:AddFragment(PLAYER_PROGRESS_BAR_CURRENT_FRAGMENT)
  27.       HUD_UI_SCENE:AddFragment(PLAYER_PROGRESS_BAR_FRAGMENT)
  28.       HUD_UI_SCENE:AddFragment(PLAYER_PROGRESS_BAR_CURRENT_FRAGMENT)
  29.    else
  30.       EVENT_MANAGER:UnregisterForEvent(self.name .. 'Experience', EVENT_CRAFTING_STATION_INTERACT)
  31.       EVENT_MANAGER:UnregisterForEvent(self.name .. 'Experience', EVENT_END_CRAFTING_STATION_INTERACT)
  32.       HUD_SCENE:RemoveFragment(PLAYER_PROGRESS_BAR_FRAGMENT)
  33.       HUD_SCENE:RemoveFragment(PLAYER_PROGRESS_BAR_CURRENT_FRAGMENT)
  34.       HUD_UI_SCENE:RemoveFragment(PLAYER_PROGRESS_BAR_FRAGMENT)
  35.       HUD_UI_SCENE:RemoveFragment(PLAYER_PROGRESS_BAR_CURRENT_FRAGMENT)
  36.    end
  37. end

L8Knight 07/03/14 11:13 AM

Quote:

Originally Posted by Garkin (Post 10116)
I'm not really sure why, but there are 2 progress bar fragments:
PLAYER_PROGRESS_BAR_FRAGMENT
PLAYER_PROGRESS_BAR_CURRENT_FRAGMENT
Most of the scenes contains both fragments, so I believe that you will need to show both of them.

That worked, thanks! I looked at Azurah but must have been looking at an older version.

As an aside, what is the difference between PLAYER_PROGRESS_BAR_FRAGMENT and ZO_ProgressBarFragment? The latter one seems to be nil during add-on initialization.

Garkin 07/03/14 11:38 AM

Quote:

Originally Posted by L8Knight (Post 10117)
That worked, thanks! I looked at Azurah but must have been looking at an older version.

As an aside, what is the difference between PLAYER_PROGRESS_BAR_FRAGMENT and ZO_ProgressBarFragment? The latter one seems to be nil during add-on initialization.

Lua Code:
  1. PLAYER_PROGRESS_BAR_FRAGMENT = ZO_PlayerProgressBarFragment:New()
  2. PLAYER_PROGRESS_BAR_CURRENT_FRAGMENT = ZO_PlayerProgressBarCurrentFragment:New()
PLAYER_PROGRESS_BAR_FRAGMENT is an instance of ZO_PlayerProgressBarFragment class.


All times are GMT -6. The time now is 08:07 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI