Thread Tools Display Modes
04/27/14, 04:18 AM   #1
Fathis Ules
Thief Guild Master
 
Fathis Ules's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
TextBuffer:GetNumHistoryLines yet another buggy API

In WoW and GetNumMessages() when you write a long line and if that line is wrapped, taking the space of 3 lines for example, GetNumMessages() will return 3


In Eso and GetNumHistoryLines() when you write a long line and if that line is wrapped, taking the space of 3 lines for example, GetNumHistoryLines will return 1


How is this weakness possible today !
  Reply With Quote
04/27/14, 05:12 AM   #2
thelegendaryof
 
thelegendaryof's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 161
Its technically correct how ESO handles it - after all the textbox width isnt fixed in ESO. Technically its still a single line and not 3 no matter how its displayed for the user. If you really need to get the displayed dimensions you will just have to calculate them yourself and write a similiar function to what WoW has.

Its by no means bugged - its working as intended.
  Reply With Quote
04/27/14, 05:35 AM   #3
Fathis Ules
Thief Guild Master
 
Fathis Ules's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
You don't see it bugged because you don't make use of it

Even when the devs uses it, they have it also buggy because when they write

Lua Code:
  1. function ChatContainer:UpdateScrollVisibility()
  2.     local visible = self.currentBuffer:GetNumVisibleLines()
  3.     local history = self.currentBuffer:GetNumHistoryLines()
  4.     local hide = history <= visible
  5.  
  6.  
  7. self.scrollbar:SetHidden(hide)
  8. self.scrollUpButton:SetHidden(hide)
  9. self.scrollDownButton:SetHidden(hide)
  10. self.scrollEndButton:SetHidden(hide)
  11. end

You will notice the visibility of the slider update perfectly if no lines are wrapped, but as soon as you have many wrapped lines, the slider will be hidden when it should be visible or vice versa

The same code the devs are using works perfectly in Wow because the GetNumHistoryLines() is very well implemented under wow

In Eso they just workaround this weakness by adding a larger value to the slider bar so you can slide at a larger value than what is inside the textbuffer but that's just an ugly workaround they made

Last edited by Fathis Ules : 04/27/14 at 05:47 AM.
  Reply With Quote
04/27/14, 06:05 AM   #4
thelegendaryof
 
thelegendaryof's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 161
Well then its indeed wrongly implemented (not technically bugged) in that case - keep in mind this isnt WoW but a completely other Software - they're just both using Lua and Eso might have been inspired (to whatever dimension) but it is not a 1:1 copy of the WoW-API. Thats especially true for any UI related functionality.

I cant check the behavior myself right now, as I dont have access to a PC atm (I'm writing from my Phone). But there are a few different solutions to that kind of missbehavior. Hack the ChatWindow and correctly calculate the visible Lines for yourself with your own function - that is the most "solid" solution which probably wont break anything else. Another would be hooking / overwriting the global GetNumHistoryLines - which is bound to break many stuff - as you dont know how its functionality is intended by the Developers and last but not least contact the Support/Developers and ask them how its intended to work, and that you found that its implementation in the ChatWindow isnt correctly taking the visible line dimension into consideration and as such leads to a to early/late display of the scrollbar.

All in itself its however pretty useless to complain about it here. Either find a solution for yourself or contact the developers / support like I've written in detail above.

Cheers

Last edited by thelegendaryof : 04/27/14 at 06:15 AM.
  Reply With Quote
04/27/14, 06:22 AM   #5
Fathis Ules
Thief Guild Master
 
Fathis Ules's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
At least the issue is search friendly, not really the case with the official forums, submitted it in /bug but I believe it has more chance to be seen here by a ui designer than on the official forums or even in /bug huhu
  Reply With Quote
05/13/14, 05:50 AM   #6
Kentarii
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
I noticed the shortcomings of these functions when I tried to implement a function to scroll the first line of my textbuffer to the top of the control. Worked fine as long as lines weren't wrapped.. not so much when multiple lines wrapped.

By default, scrolling the textbuffer to the top means that your first line is at the bottom, showing only one line, thus leaving a lot of blank space a the top.
  Reply With Quote
05/20/14, 06:30 AM   #7
thelegendaryof
 
thelegendaryof's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 161
I implemented an own solution in my EditBuffer component that basically uses the EditControl to generate virtual lines like the TextBufferControl but is instead able to correctly calculate the Line-Width due to using a Monospace-Font unlike the native one. See here for how I did it:

http://www.esoui.com/forums/showthread.php?t=1538

SplitLongLines() is what you're seeking for.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » TextBuffer:GetNumHistoryLines yet another buggy API


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