PDA

View Full Version : ANY UI documentation?



Blade[UG]
12-20-2009, 11:43 PM
Is there any documentation whatsoever on the UI stuff, that is useful? It seems that doing anything in UI that doesn't involve simple buttons filled with pre-defined text or images is virtually impossible?

immortius
12-21-2009, 12:16 AM
Not sure. They way I did complex UI stuff (like a map that showed player positions in realtime) was generally create a subclass of UTDrawPanel, draw within the panel using the canvas in the DrawPanel() function, and simply used the UI Editor for handling layout of the different panels.

Really simple example, which isn't particularly wonderful:



class MapNameLabel extends UTDrawPanel;

var() Font TextFont;
var() float FontScale;
var() color DrawColor;

var localized string MapNameLbl;

function DrawPanel() {
local string MapName;
local FontRenderInfo fontInfo;
fontInfo.bClipText = true;

MapName = UTSceneOwner.GetWorldInfo().GetMapName();

Canvas.Font = TextFont;
Canvas.SetPos(0, 0);
Canvas.DrawColor = DrawColor;
Canvas.DrawText(MapNameLbl$MapName,true,fontScale, fontScale,fontInfo);
}

DefaultProperties
{
TextFont=Font'EngineFonts.SmallFont';
FontScale=1
DrawColor=(R=255,G=255,B=255,A=255)
}


Inside the DrawPanel() function, the drawing origin (0,0) is the top-left corner of the panel, and Canvas.ClipX/Y are the width and length of the panel respectively.

Some things can possibly be done by using databinding, I never got around to experimenting with that much though.

Scubahunter
12-29-2009, 08:32 PM
How do you place your new Item? Can you put it on a UIscene or do you add it to the hud class or what?

immortius
12-29-2009, 09:29 PM
I put it in a UIScene. This allows it to be positioned using the visual editor.

Hud code is quite similar, because it also uses the canvas to render. You do have to manual place all the elements in code though.

Blade[UG]
12-29-2009, 09:46 PM
I have yet to encounter anyone who's been able to do anything dynamic in a uiscene, aside from push buttons, except for Angel, and the help that she gave me caused an instant engine crash no matter what i did. :( and after banging on it for 3 weeks straight, all i've been able to do is crash the engine.

immortius
12-29-2009, 11:29 PM
Without knowing specifics of what you are trying to do, no-one is going to be able to help.

Anyhow, here is a video of the ingame map (http://www.youtube.com/watch?v=NOen9HJqYe4) I mentioned earlier.

Blade[UG]
12-30-2009, 01:22 AM
I just want a UIList, in which I can change, via unrealscript, the contents of it's cells.

GeekyPayback
01-04-2010, 09:13 AM
Here's what I figured out. Its not a complete tutorial and its a bit all over the place, but its how I got dynamically generated UI Lists working (and gives a bit of a tutorial on int and ini file usage)

http://wiki.beyondunreal.com/DynamicUIListTutorial

You'll be a guinea pig for how well it works though I'm afraid. Let me know what's broken or missing in the tutorial and I'll update it.

guineapig
01-04-2010, 10:31 AM
What..?

:D

geodav
01-04-2010, 01:52 PM
how about how to select/change the defaultplayer from a list via a menu that would help me lots

Blade[UG]
01-04-2010, 02:22 PM
well, if you can make the linked code work, that should be pretty easily adaptable to that purpose. it looks less easily adaptable to data that is not known prior to startup, though. and i can't get it to work anyway :(

GeekyPayback
01-05-2010, 07:07 AM
@blade - You don't have to do everything I've written there. Forget the ini stuff and just bung in your own AddStr values. It shouldn't crash (its how I got my first version working before I moved it all out to .int files). I'm not sure what you could want that you don't want to be translated into different languages, but any string should work. At least now you are comparing it to a concept that's known to work, rather than randomly crashing your machine.

@GeoDav - I didnt write a tutorial specifically for blade I just wrote what I'd done to get things working in a context people would understand (in other words I don't do requests). What I've written should be enough for you to sort out the problem yourself. You just need to add the mesh values to the data provider and write an exec function on the player controller to change the pawns mesh, then call the function passing the selected mesh when you click an apply button.

As yours is a pre-selected list you can probably use a menulist, but like I said I didn't look into those.

geodav
01-05-2010, 01:59 PM
Thanks GeekyPayback, when i find someone who understands that i'm sure it will help ;) though i did read through it and sort of understood what you where doing (i just can't write it)

in the meantime i'm trying to port Bob Chatman's UT3's Main Menu Tutorial

http://blog.gneu.org/subtopics/unreal-tournament-3/

it now compiles :) 1945hrs

it's now 2130hrs here and i now have a basic copy (working) of the UDK MainMenu and TitleScreen :) :) :)

Blade[UG]
01-06-2010, 03:35 PM
Ha! I think I'm almost there! I've managed to get my own classes, that appear to be setting everything up properly .. but I'm not getting anything inside my UIScene. Can you give me a stupidly quick rundown on how to make the UIScene? I just made a new UIScene that was a sub of my UIScene class, added a UTUIList to it that was tagged with the tag i defined in my UIScene, and saved it .. that doesn't seem to work, though.

geodav
01-07-2010, 01:51 PM
i think the problem might when you create a new UIScene, you need to select which class you want to base it on.

i'm having problems with the buttonbar that i copied over for the UDK InstantAction menu :(

Blade[UG]
01-07-2010, 06:29 PM
well, i've got a uiscene with a uilist, and the list is there, i just can't see it, and it doesn't seem to have any data in it (which may explain why i can't see it)

GeekyPayback
01-08-2010, 09:41 AM
I'd add a `log("Got started"); line at the top of the tabpage PostInitialize(). Check that it appears in your logs when you run the game, then check there are no accessed none messages when you try and set the UILIST values.

I'd also add a `log at the top of initdatastores() and again for each item you add to the list.

Let me know what the log says and that will point things out from there.

Blade[UG]
01-09-2010, 12:13 AM
Everything is calling, just not getting a visible uilist ..

GeekyPayback
01-09-2010, 10:45 AM
show the us the log file - its hard to make something out of nothing ;)

Blade[UG]
01-09-2010, 11:44 AM
sure sure, sorry, was busy working when i sent that last one off.. just a sec

PostInitialize called, InitDataStores called, DSClient=DataStoreClient_0, MyDataStore=GFDataStore_0, AddStr('Available', "Test Entry 1", False) called, list when retrieved is "Test Entry 1".

GeekyPayback
01-11-2010, 07:23 AM
When you use AddStr, you aren't adding to the list. You are adding to the datastore. Is your list using the same datastore that you are filling out?

lstEquipment.SetDataStoreBinding("<EquipmentStore:AvailableEquipment>"); // Hook the list to our data (set up in InitDataStore)

Blade[UG]
01-12-2010, 01:05 AM
yeah they are both set to the same place ..
maybe i need to start with.. how do i get a uilist with something in it, using only the ui editor? is that possible? :D

John J
01-17-2010, 10:15 AM
I posted this in the programming section but after a week got no replies, so hopefully I will here. :)

I used this example for my project and got everything working except for the image/description updating..... or it's updating, but the click thinks I am always on the first entry regardless of the actual entry clicked.

The list is populated correctly and the correct image and text description are displayed properly when the UI scene is opened, but when I click on an entry in the list the image/description still displays the first item in the list. Based on my log, the click event is being registered so I think something is wrong with how the list selection is registered.


function OnWeapon_ValueChanged( UIObject Sender, optional int PlayerIndex=0 )
{
local int SelectedItem;
local GBOUIDataProvider_WeaponAR selWeap;
local string weapname;

//`log ("In value changed "$Sender );

InitDataStores();

`log ("***** List Clicked *****");

if (WeaponProvider.Length == 0)
return;

//SelectedItem = -1;
SelectedItem = WeaponARDataStore.GetCurrentValueIndex('AvailableW eapon');
weapname = WeaponARDataStore.GetStr('AvailableWeapon', SelectedItem);

`log ("weapon name1 = "$weapname);

selWeap = GetSelectedItem(WeaponProvider, weapname);
if(selWeap != none)
{
`log ("***** Update Image/Description *****");
//`log ("image = "$selWeap.IconImage);
imgWeapPreview.SetDatastoreBinding(selWeap.IconIma ge);
lblDescription.SetDatastoreBinding(selWeap.Descrip tion);
}
}

In summary, the list populates but when an item is selected, the image/description still displays the first ones read in and not the ones associated with the list entry.

Hope that's clear. :D

Any ideas?

John

John J
01-17-2010, 12:16 PM
I made a little progress, but it's still not working correctly. I made a new function to do the updating and just called that from the above listed function. The problem now is that it is showing the 'FriendlyName' value form utgame.int and not the desired 'Description' value. Here is the new function:



function UpdateDescriptionLabel()
{
local string NewDescription;
local int SelectedItem;

`log ("***** Dscription Updated *****");

SelectedItem = lstWeapons.GetCurrentItem();

if(class'UTUIMenuList'.static.GetCellFieldString(l stWeapons, 'Description', SelectedItem, NewDescription))
{
lblDescription.SetDataStoreBinding(NewDescription) ;
}
}

I am clearly defining 'Description' as the Tag to get.

-John

GeekyPayback
01-18-2010, 09:22 AM
class'UTUIMenuList'.static.GetCellFieldString is basically saying "get the string from the UIList" - The UIList will only ever contain the friendly name of the weapon. What you want is to get the description from the Datastore.

To do that you get the string value of the item from the datastore (or from the UILISt if you want), then you find the the object in the Provider set by searching for the friendly name. The returned object gives you get at all the values at once.

Do this instead of what you've written



function OnWeapon_ValueChanged( UIObject Sender, optional int PlayerIndex=0 )
{
local int SelectedItem;
local GBOUIDataProvider_WeaponAR selWeap;
local string weapname;

//`log ("In value changed "$Sender );

InitDataStores();

`log ("***** List Clicked *****");

if (WeaponProvider.Length == 0)
return;

SelectedItem = UTUIList(Sender).GetCurrentItem(); // This the bit that wasn't working
weapname = WeaponARDataStore.GetStr('AvailableWeapon', SelectedItem);

`log ("weapon name1 = "$weapname);

selWeap = GetSelectedItem(WeaponProvider, weapname);
if(selWeap != none)
{
`log ("***** Update Image/Description *****");
//`log ("image = "$selWeap.IconImage);
imgWeapPreview.SetDatastoreBinding(selWeap.IconIma ge);
lblDescription.SetDatastoreBinding(selWeap.Descrip tion);
}
}


It should be as simple as that. I had the code right, but hadn't put it on the wiki page.

John J
01-18-2010, 10:57 AM
Hot dog! Works as expected.

Thanks a ton... This thing has been killing me for the past week. :o

-John