Thread Tools Display Modes
07/03/14, 10:24 AM   #1
L8Knight
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 6
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.
  Reply With Quote
07/03/14, 10:56 AM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
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
  Reply With Quote
07/03/14, 11:13 AM   #3
L8Knight
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 6
Originally Posted by Garkin View Post
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.
  Reply With Quote
07/03/14, 11:38 AM   #4
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by L8Knight View Post
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.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Player Progress Bar Auto Hiding


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off