Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   GuiScrollCtrl - Getting max y pos (https://forums.graalonline.com/forums/showthread.php?t=134265886)

jamitsu89 03-04-2012 03:10 PM

GuiScrollCtrl - Getting max y pos
 
Is there a way to check the maximum Y position of a Gui Scroll Control?

Think Client RC. If chat scroll is at the bottom when more text is added, it scrolls down and shows it, whereas if scroll bar is up a tad, it doesn't scroll down to encompass the new text - it simply stays where it is.

EDIT- Nobody knows how to get a similar effect to the Client RC?

jamitsu89 03-09-2012 12:22 PM

Well, in case anyone else also has this problem, I'll post my solution:
PHP Code:

temp.origposition GuiScrollCtrl.scrollpos;

GuiScrollCtrl.scrolltobottom();

temp.maxposition GuiScrollCtrl.scrollpos;



if (
temp.origposition[1] < temp.maxposition[1])

  
GuiScrollCtrl.scrollTo(temp.origposition[0], temp.origposition[1]); 

An unfortunate work around, and doesn't always work, but seems the only way.

fowlplay4 03-09-2012 05:26 PM

Try this:

PHP Code:

//#CLIENTSIDE
function onRCChat() {
  
GuiChatScroll.scrolltobottom();


You'll have to replace the GUI object's name obviously.

cbk1994 03-09-2012 10:55 PM

Quote:

Originally Posted by fowlplay4 (Post 1687580)
Try this:

PHP Code:

//#CLIENTSIDE
function onRCChat() {
  
GuiChatScroll.scrolltobottom();


You'll have to replace the GUI object's name obviously.

I think what he's trying to do instead is make a GuiScrollCtrl scroll to the bottom when the height increases only when it was already scrolled to the bottom.

fowlplay4 03-09-2012 10:59 PM

I feel like that would trigger a GuiScrollControl.onResize() and you can do the same thing there.

PHP Code:

//#CLIENTSIDE
function GuiScrollControl.onResize() { 
  
GuiScrollControl.scrolltobottom();



cbk1994 03-09-2012 11:09 PM

Quote:

Originally Posted by fowlplay4 (Post 1687622)
I feel like that would trigger a GuiScrollControl.onResize() and you can do the same thing there.

PHP Code:

//#CLIENTSIDE
function GuiScrollControl.onResize() { 
  
GuiScrollControl.scrolltobottom();



Except the problem is he only wants to scroll down if it's already scrolled to the bottom. If someone chats in RC but you've scrolled up, it doesn't automatically scroll down for you (that would be annoying).

Tigairius 03-10-2012 12:16 AM

This is how I did it in the Client RC (copied/pasted directly out of the script):

PHP Code:

    // Changed this so RC will scroll back to 
    // normal position. -Tig
    
    // Store the old position before adding text
    
temp.oldpos ScriptedRCScroll.scrollpos;
    
    
// Need to get the position of scroll when it's
    // at the bottom
    
ScriptedRCScroll.scrollToBottom();
    
temp.maxscroll ScriptedRCScroll.scrollpos[1];
    
    
ScriptedRCRCchat.text @= "\n" temp.data;
        
    
// If the scroll wasn't at the bottom, then don't
    // scroll to back to the bottom.
    
if (temp.oldpos[1] != temp.maxscroll) {
      
ScriptedRCScroll.scrollTo(temp.oldpos[0], temp.oldpos[1]);
    } else {
      
ScriptedRCScroll.scrollToBottom();
    }
    
    
// Check to see if the text is bigger than the scroll
    // viewing window, if not, scrolltobottom.
    // Makes sure it will move the scroll down to the bottom
    // if there was previously no scroll showing.
    
if (ScriptedRCRCchat.clientheight ScriptedRCScroll.clientheight ScriptedRCRCchat.profile.getTextHeight()) {
      
ScriptedRCScroll.scrollToBottom();
    } 


jamitsu89 03-10-2012 12:37 AM

Ah lovely, thanks a lot Tig.
And cheers for responding, Jer and Chris.


All times are GMT +2. The time now is 03:34 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.