Aller au contenu

Photo

changing the value of an UIScrollBar


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Olblach

Olblach
  • Members
  • 175 messages
I'm making my first UI for the bank  but I decided to make an input number UI instead of something specific.

It has a slider and an input box, so you can pick an amount with the slider and make fine corrections with the box.

It works, but there is still a problem: when I change the amount in the box the slider doesn't move...

Here is the xml:


<?xml version="1.0" encoding="NWN2UI">

<!-- GUI 3: SCREEN DEFINITIONS -->

<UIScene name="NUMGET" x=ALIGN_CENTER y=ALIGN_CENTER width=500 height=500 priority=SCENE_SCRIPT scriptloadable=true draggable=true idleexpiretime="0.1f" />
        <UIButton name="CloseButton" x="454" y="6" style="STYLE_CLOSE_BUTTON"
                OnLeftClick='UIButton_Input_ScreenClose()'>
		</UIButton>
            <UIPane name="NUMGET_CONTAINER" x="0" y="0" width="230" height="300" >
				<UIText name="NUMGET_MESSAGE" x=ALIGN_PARENT y=25 width=PARENT_WIDTH height=DYNAMIC align=center valign=middle fontfamily="Title_Font" style="1" multiline=false />	
				<UIText name="NUMGET_VALUE" x=95 y=82 fontfamily="Body_Font" width=50 height=18 update=true  editable="true" selectable="true" multiline="false" maxlength="15" 
					 OnUpdate='UIObject_Misc_SetLocalVarString(local:0)' OnUpdate0='UIObject_Misc_ExecuteServerScript("gui_changeTnum","local:0","local:2")'/>
				<UIFrame name="NumFrame" x=95 y=80 width=54 height=22 topleft="tp_frame_tl.tga" topright="tp_frame_tr.tga" 
					bottomleft="tp_frame_bl.tga" bottomright="tp_frame_BR.tga" top="tp_frame_t.tga" bottom="tp_frame_b.tga" left="tp_frame_l.tga" 
					right="tp_frame_r.tga" fillstyle="stretch" fill="tp_frame_bg.tga" border=3 />				
				<UIScrollBar name="NUMGET_SLIDER" style="STYLE_OPTION_SLIDER" x=ALIGN_CENTER y=130 minsize=0 maxsize=100 maxvalue=100
				update=true OnUpdate=UIObject_Misc_SetLocalVarString(local:1) OnUpdate0=UIObject_Misc_ExecuteServerScript("gui_changeSnum","local:1","local:2") ></UIScrollBar>	
				<UIButton name="NUMGET_CONFIRM" x="55" y="250" text="Confirm" style="STYLE_SMALL_BUTTON" OnLeftClick='UIObject_Misc_ExecuteServerScript("gui_numget","local:0","local:3","local:4")'/>	
			</UIPane>



<!-- BACKGROUND IMAGE - This has to come after everything else or it covers what we put in the GUI -->

<UIFrame name="Background" topleft="tp_frame_tl.tga" topright="tp_frame_tr.tga" bottomleft="tp_frame_bl.tga" bottomright="tp_frame_BR.tga" top="tp_frame_t.tga" bottom="tp_frame_b.tga" left="tp_frame_l.tga" right="tp_frame_r.tga" fillstyle="stretch" fill="tp_frame_bg.tga" border=5/>



And the result on screen:

Posted Image

Uploaded with ImageShack.us

Is it a lost cause or is it possible to have the slider move when you change the amount in the box?
I could change it from script or from the UIText in the xml either is acceptable.

Modifié par Olblach, 18 octobre 2010 - 10:57 .


#2
dunniteowl

dunniteowl
  • Members
  • 1 559 messages
If you could tie in to the XML UI Screen the amount of gold available that could be entered (eg: the amount of gold on the character in total) then you should be able to have a script line or two that runs the slider to a percentage of the total available versus the amount being entered.

Obviously in such a case, 0 would be 0, then if a character had 450 gp total, if they entered half that, the slider should move to the center of the slider bar.

Exactly how the bar and amount interact in XML I have no idea whatever. Your reference for getting the bar to indicate a percentage (by view) amount has to be tied, though, to the total amount of gold that can be input into the box at any given time.

dunniteowl

#3
Olblach

Olblach
  • Members
  • 175 messages
Yes, I could remove the input text box then but unfortunately setting maxvalue=local:2 for the UIScrollbar did not work as I expected it would
local:0 is the real amount
local:1 is the percentage
local:2 is the max amount.
The scripts gui_changeSnum and gui_changeTnum perform the magic.
I had a startvalue and a minvalue but I removed these because it was interacting badly with the text box. And because I don't know how to move the slider...
Thanks for the insight.

Modifié par Olblach, 18 octobre 2010 - 12:50 .


#4
MasterChanger

MasterChanger
  • Members
  • 686 messages
Is a slider a scroll-bar? Have you tried SetScrollBarValue, declared in nwscript.nss?

//RWT-OEI 10/06/08
//Sets the scroll bar value on a specified scrollbar on a specified
//screen.
//In order to work, the screen that contains the scroll bar must have
//the ScriptLoadable=true attribute in the <UIScene> tag.
// oPlayer - Player who's GUI needs to be modified.
// sScreenName - GUI Name of the scene that contains the scroll bar
// sScrollBarName - Name of the scroll bar to change the parameters for
// nValue - The value to set the scrollbar to.
void SetScrollBarValue( object oPlayer, string sScreenName, string sScrollBarName, int nValue );


#5
Olblach

Olblach
  • Members
  • 175 messages
Ah cool, I see there is also a function to set maxvalue! I only checked the functions with GUI in the name hehe. Thanks for the info! :wizard:


Edit: Sent to the vault, Pending Approval as of now.

Modifié par Olblach, 18 octobre 2010 - 11:49 .


#6
Olblach

Olblach
  • Members
  • 175 messages
Here: http://nwvault.ign.c...I.Detail&id=153