Announcement

Collapse
No announcement yet.

Editable - In - Game - Textbox

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Editable - In - Game - Textbox

    Hello all!

    I need an editable(for user) textbox that can be called during game, with button that saves the typed text to specific string(or basiclly just make a save while exiting a textbox). It is don't have to be flash or sth, just a texture.
    Does anybody know how could it be done? I'm really green at the GUI/HUD things. I bet it is not very hard to make but I don't even know where should I begin :/

    Anyone?

    Thanks for any answers

    #2
    Open Console.uc and check how the console is drawn and how the user can enter text and how it is drawn. If you change the drawing code, you'll get something like an input box. You could add that feature to your existing HUD class (which has access to the Canvas; Canvas is all you need for this case).

    Comment


      #3
      Thanks for answer.

      Sorry, I didn't said earlier - I would like an multiline textbox, and the input from console would be just one-line-textbox :/
      Is there any built-in class in UDK that already contain that element? Or how other way can multiline textbox be done?

      Regards.

      Comment


        #4
        Canvas can be multiline (i hope you mean multiline and not wrapped line). Just store each line into an array of strings. The Console example also has example code of using special inputs (like Backspace etc.).

        Originally posted by LOLOLO View Post
        Thanks for answer.
        Or how other way can multiline textbox be done?
        In older UDK versions UIScene. But that got removed. Nowadays, things like that are done with Scaleform (Flash).

        Comment


          #5
          Yeh, actually I use the version that contains UI Scene still, thanks 4 letting know about this very easy tool.
          Now the only problem is that UI Kismet(in UDK version) don't let to get value of editbox originally. I can make it manually by editing the UIEditBox.uc even(so without Kismet), but(just want to be sure); is it legit to edit original Engine classes?

          Comment


            #6
            Originally posted by LOLOLO View Post
            is it legit to edit original Engine classes?
            Its not best practice but in this case you're locked into a very old version of UDK for UIScenes anyway, and sometimes you have to modify the core classes when sub-classing isn't an option. But be sensible and keep master backups of the main classes and use a source comparison tool like Windiff if you run into problems and have to back out changes... Since UDK development is now firmly frozen, you probably won't ever upgrade the build again either.

            Comment


              #7
              As frankit already said, editing existing classes is not the best practices and it might break the native mapping of functions.

              Originally posted by LOLOLO View Post
              Now the only problem is that UI Kismet(in UDK version) don't let to get value of editbox originally.
              UnrealScript can; and therefore Kismet can. It might not be a shipped kismet action, but you can extend kismet by creating custom kismet actions which could retrieve the text value of given EditBox ui elements.

              Should be a combination of these actions:
              - Get reference of a UIScene
              - Find a given UI object (by tag)
              - Get value of given UI object

              Comment


                #8
                Ok, but UIEditBox from UDK don't contain a OnGetTextValue function(this one is from UT3);

                Code:
                function OnGetTextValue( UIAction_GetTextValue Action )
                {
                	Action.StringValue = GetValue(true);
                }
                So I think Im not able to achieve the data from it without adding this lines, so editing the original class.
                Or.. Maybe when I will call directly from other actor the UIEditBox.GetValue(true) function it'll get it. But how can I find out the name/reference of it? I don't see any tags to set in the UIScene elements :/

                Comment


                  #9
                  OnGetTextValue is used by Kismet (called natively). It's like an event.

                  I don't have any related UDK version installed (featuring UIScene) but the related getter is string GetValue(... bool bReturnUserText...) and the setter would be SetValue(string NewText ...) (or SetDataStoreBinding).

                  As every UI element is instanced, you can just used FindChild(...) on the base scene object to get your edit box. If you open a scene, store that created scene in your kismet. Used your customly created kismet action to retrieve a given object of a scene and use another created kismet action to retrieve the field.

                  Something like the following classes which I just wrote inside this editor. Non of these are tested but in general, these should work.

                  UIAction_FindElement.uc
                  Code:
                  /**
                   * Retrieves the element from an opened scene by its tag
                   */
                  class UIAction_FindElement extends UIAction_Scene;
                  
                  /** Output variable for the element that was found. */
                  var	UIObject		ElementObj;
                  
                  var() name WidgetName;
                  var() bool bRecurse;
                  
                  event Activated()
                  {
                  	local SeqVar_Object ObjVar, OutObjVar;
                  
                  	if (Scene == none)
                  	{
                  		foreach LinkedVariables(class'SeqVar_Object', ObjVar, "Scene")
                  		{
                  			Scene = UIScreenObject(ObjVar.GetObjectValue());
                  			if (Scene != none) break;
                  		}
                  	}
                  
                  	if (Scene != none)
                  	{
                  		ElementObj = Scene.FindChild(WidgetName, bRecurse);
                  	}
                  
                  	if (ElementObj != none)
                  	{
                  		foreach LinkedVariables(class'SeqVar_Object', OutObjVar, "UIElement")
                  		{
                  			OutObjVar.SetObjectValue(ElementObj);
                  		}
                  
                  		// trigger success
                  		OutputLinks[0].bHasImpulse = true;
                  	}
                  	else
                  	{
                  		// trigger failed
                  		OutputLinks[1].bHasImpulse = true;
                  	}
                  }
                  
                  DefaultProperties
                  {
                  	ObjName="Find element"
                  
                  	VariableLinks.Add((ExpectedType=class'SeqVar_Object',LinkDesc="UI Element",PropertyName=UIElement,bWriteable=true))
                  
                  	bRecurse=true
                  }

                  UIAction_EditboxGet.uc
                  Code:
                  /**
                   * Sets the text of a given edit box.
                   */
                  class UIAction_EditboxGet extends UIAction_Scene;
                  
                  var() bool bReturnUserText;
                  
                  event Activated()
                  {
                  	local SeqVar_Object ObjVar;
                  	local SeqVar_String OutValueVar;
                  	local UIEditBox CurEditbox;
                  	local string EditValue;
                  
                  	foreach LinkedVariables(class'SeqVar_Object', ObjVar, "Editbox")
                  	{
                  		CurEditbox = UIEditBox(ObjVar.GetObjectValue());
                  		if (CurEditbox != none) break;
                  	}
                  
                  	if (CurEditbox != none)
                  	{
                  		EditValue = CurEditbox.GetValue(bReturnUserText);
                  
                  		foreach LinkedVariables(class'SeqVar_String', OutValueVar, "Value")
                  		{
                  			OutValueVar = EditValue;
                  		}
                  
                  		// trigger success
                  		OutputLinks[0].bHasImpulse = true;
                  	}
                  	else
                  	{
                  		// trigger failed
                  		OutputLinks[1].bHasImpulse = true;
                  	}
                  }
                  
                  DefaultProperties
                  {
                  	ObjName="Get editbox value"
                  
                  	VariableLinks(0)=(ExpectedType=class'SeqVar_Object',LinkDesc="Editbox",PropertyName=Editbox)
                  	VariableLinks(1)=(ExpectedType=class'SeqVar_String',LinkDesc="Value",PropertyName=EditValue,bWriteable=true)
                  }
                  UIAction_EditboxSet.uc
                  Code:
                  /**
                   * Sets the text of a given edit box.
                   */
                  class UIAction_EditboxSet extends UIAction_Scene;
                  
                  var() string StringValue;
                  var() string bIsMarkup;
                  
                  event Activated()
                  {
                  	local SeqVar_String ValueVar;
                  	local string EditValue;
                  	
                  	local SeqVar_Object ObjVar;
                  	local UIEditBox CurEditbox;
                  	local bool bFound;
                  
                  	foreach LinkedVariables(class'SeqVar_String', ValueVar, "Value")
                  	{
                  		break;
                  	}
                  
                  	if (ValueVar != none)
                  	{
                  		EditValue = OutValueVar.StrValue;
                  	}
                  	else
                  	{
                  		EditValue = StringValue;
                  	}
                  
                  	foreach LinkedVariables(class'SeqVar_Object', ObjVar, "Editbox")
                  	{
                  		CurEditbox = UIEditBox(ObjVar.GetObjectValue());
                  		if (CurEditbox != none)
                  		{
                  			bFound = true;
                  
                  			if (bIsMarkup)
                  				CurEditbox.SetDataStoreBinding(EditValue);
                  			else
                  				CurEditbox.SetValue(EditValue);
                  		}
                  	}
                  
                  	if (bFound)
                  	{
                  		// trigger success
                  		OutputLinks[0].bHasImpulse = true;
                  	}
                  	else
                  	{
                  		// trigger failed
                  		OutputLinks[1].bHasImpulse = true;
                  	}
                  }
                  
                  DefaultProperties
                  {
                  	ObjName="Set editbox value"
                  
                  	VariableLinks(0)=(ExpectedType=class'SeqVar_Object',LinkDesc="Editbox",PropertyName=Editbox)
                  	VariableLinks(1)=(ExpectedType=class'SeqVar_String',LinkDesc="Value",PropertyName=EditValue)
                  }

                  Comment

                  Working...
                  X