Gump Pages..

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
User avatar
*Edwards
Forum Regular
Posts: 303
Joined: Fri Dec 28, 2007 11:19 pm

Gump Pages..

Post by *Edwards »

I'm getting headache again! I'm trying to figure why I cannot change to page 3 for exemple because I know the script still running but it doesn't display anything.

Code: Select all

var page := 0;

program command( mobile )

        while( Send_Command( mobile ))
                SleepMS(10);
        endwhile

        return 1;
endprogram

function Send_Command( mobile )

        //Initialize the gump
        var gump := GFCreateGump();
        GFClosable( gump, 0 );
        
        Broadcast( "CommandPage: "+page );
        
        //Load Main Background
	GFResizePic( gump, 0, 0, GFGetCfgConst( "Defaults", "BackGround" ), 500, 525 );

        GFResizePic( gump, 15, 15, GFGetCfgConst( "Defaults", "ForeGround" ), 470, 25 );
	GFTextMid( gump, 15, 17, 470, 1720, "Npc Creation" );

        //BackgroundAreas
	GFResizePic( gump, 15, 45, GFGetCfgConst( "Defaults", "ForeGround" ), 470, 470 );
        GFTextMid( gump, 15, 60, 470, 1720, "Page 1: Global Settings" );
        
        //Help Button
        GFAddButton( gump, 30, 60, 2131, 2131, GF_CLOSE_BTN, 0xA00 );

        //Send Previous-Next-Cancel-Apply Buttons
        GFPage( gump, page );
        
        Action_Button( gump );
        Page_Selector( gump, mobile );
        
        var input := GFSendGump( mobile, gump );
        if( input[0xA00] )
                 return OpenBrowser( mobile, "http://"+SHARD_IP+":5000/brainAI/index.html" );
        elseif( input[0xA01] ) //Cancel Button
                 return 0;
        elseif( input[0xA02] ) //Apply Button
                 return 0;
        elseif( input[0xA03] ) //Previous Button
                 Move_Page( "Previous" );
        elseif( input[0xA04] ) //Next Button
                 Move_Page( "Next" );
        endif
        
        return 1;
endfunction

function Action_Button( byref gump )

         case( page )
                 0: //Cancel or Next Button
                             GFAddButton( gump, 28, 482, 4017, 4018, GF_CLOSE_BTN, 0xA01 );
                             GFTextLine( gump, 60, 482, 1153, "Cancel" );
                 
                             GFAddButton(gump, 445, 482, 4005, 4006, GF_CLOSE_BTN, 0xA04 );
                             GFTextLine( gump, 400, 482, 1153, "Next" );
                             break;
                             
                 1:2:3:4:5:6: //Previous or Next Button
                            GFAddButton( gump, 28, 482, 4014, 4015, GF_CLOSE_BTN, 0xA03 );
                            GFTextLine( gump, 60, 482, 1153, "Previous" );

                            GFAddButton( gump, 445, 482, 4005, 4006, GF_CLOSE_BTN, 0xA04 );
                            GFTextLine( gump, 400, 482, 1153, "Next" );
                            break;

                 7: //Previous or Apply Button
                            GFAddButton( gump, 28, 482, 4014, 4015, GF_CLOSE_BTN, 0xA03 );
                            GFTextLine( gump, 60, 482, 1153, "Previous" );

                            GFAddButton(gump, 445, 482, 4012, 4013, GF_CLOSE_BTN, 0xA02 );
                            GFTextLine( gump, 400, 482, 1153, "Apply" );
                            break;
         endcase

         return gump;
endfunction

function Move_Page( action )

         if( action == "Previous" )
                 page -= 1;
         elseif( action == "Next" )
                 page += 1;
         endif
endfunction
For exemple, I'm able to click next on page 0 to go through page 1 and then when I click my next button again it goes to page 2 yeah but only the background appeir without the next and previous button. Where am I wrong?
Last edited by *Edwards on Sun May 25, 2008 3:38 am, edited 1 time in total.
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

What is the function of Page_Selector(gump, mobile)?
User avatar
*Edwards
Forum Regular
Posts: 303
Joined: Fri Dec 28, 2007 11:19 pm

Post by *Edwards »

Oh, even if I remove that function it doesn't work.
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Post by Pierce »

What does Page 3 display? A lot of information?
Cause if the data size gets to high the gump won't display.
Perhaps that is the reason in your case.
User avatar
*Edwards
Forum Regular
Posts: 303
Joined: Fri Dec 28, 2007 11:19 pm

Post by *Edwards »

Well, for now they all display the samething, a blank page with cancel and next button for the main page, previous and next for the page 2 to 6, and the page 7 shall display previous and save button. As it is now, the gump stop displaying things when I get to page 2 :\.
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

The problem is that you add the buttons into their correct pages but create a new gump every time page is switched.

Technically you first see gump's pages 0 and 1 every time a new one is shown.

So try this.

Code: Select all

var page := 0; 

program command( mobile ) 

        while( Send_Command( mobile )) 
                SleepMS(10); 
        endwhile 

        return 1; 
endprogram 

function Send_Command( mobile ) 

        //Initialize the gump 
        var gump := GFCreateGump(); 
        GFClosable( gump, 0 ); 
        
        Broadcast( "CommandPage: "+page ); 
        
        //Load Main Background 
   GFResizePic( gump, 0, 0, GFGetCfgConst( "Defaults", "BackGround" ), 500, 525 ); 

        GFResizePic( gump, 15, 15, GFGetCfgConst( "Defaults", "ForeGround" ), 470, 25 ); 
   GFTextMid( gump, 15, 17, 470, 1720, "Npc Creation" ); 

        //BackgroundAreas 
   GFResizePic( gump, 15, 45, GFGetCfgConst( "Defaults", "ForeGround" ), 470, 470 ); 
        GFTextMid( gump, 15, 60, 470, 1720, "Page 1: Global Settings" ); 
        
        //Help Button 
        GFAddButton( gump, 30, 60, 2131, 2131, GF_CLOSE_BTN, 0xA00 ); 

        //Send Previous-Next-Cancel-Apply Buttons 
        GFPage( gump, 1 ); 
        
        Action_Button( gump ); 
        Page_Selector( gump, mobile ); 
        
        var input := GFSendGump( mobile, gump ); 
        if( input[0xA00] ) 
                 return OpenBrowser( mobile, "http://"+SHARD_IP+":5000/brainAI/index.html" ); 
        elseif( input[0xA01] ) //Cancel Button 
                 return 0; 
        elseif( input[0xA02] ) //Apply Button 
                 return 0; 
        elseif( input[0xA03] ) //Previous Button 
                 Move_Page( "Previous" ); 
        elseif( input[0xA04] ) //Next Button 
                 Move_Page( "Next" ); 
        endif 
        
        return 1; 
endfunction 

function Action_Button( byref gump ) 

         case( page ) 
                 0: //Cancel or Next Button 
                             GFAddButton( gump, 28, 482, 4017, 4018, GF_CLOSE_BTN, 0xA01 ); 
                             GFTextLine( gump, 60, 482, 1153, "Cancel" ); 
                  
                             GFAddButton(gump, 445, 482, 4005, 4006, GF_CLOSE_BTN, 0xA04 ); 
                             GFTextLine( gump, 400, 482, 1153, "Next" ); 
                             break; 
                              
                 1:2:3:4:5:6: //Previous or Next Button 
                            GFAddButton( gump, 28, 482, 4014, 4015, GF_CLOSE_BTN, 0xA03 ); 
                            GFTextLine( gump, 60, 482, 1153, "Previous" ); 

                            GFAddButton( gump, 445, 482, 4005, 4006, GF_CLOSE_BTN, 0xA04 ); 
                            GFTextLine( gump, 400, 482, 1153, "Next" ); 
                            break; 

                 7: //Previous or Apply Button 
                            GFAddButton( gump, 28, 482, 4014, 4015, GF_CLOSE_BTN, 0xA03 ); 
                            GFTextLine( gump, 60, 482, 1153, "Previous" ); 

                            GFAddButton(gump, 445, 482, 4012, 4013, GF_CLOSE_BTN, 0xA02 ); 
                            GFTextLine( gump, 400, 482, 1153, "Apply" ); 
                            break; 
         endcase 

         return gump; 
endfunction 

function Move_Page( action ) 

         if( action == "Previous" ) 
                 page -= 1; 
         elseif( action == "Next" ) 
                 page += 1; 
         endif 
endfunction
User avatar
*Edwards
Forum Regular
Posts: 303
Joined: Fri Dec 28, 2007 11:19 pm

Post by *Edwards »

Thanks a lot for your help, it works.
Post Reply