UI interface customization questions

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

UI interface customization questions

Post by rf900 »

Want to do some customize panels and UI actions, and I am stuck with a couple of things.

1. First I want to use a new bonus button to show up a panel, I managed to show it, but the logic that shows the drop down menu still runs behind. So to hide the UI panel you first have to right click on the game area to remove the dropdown menu that has been generated. Can I override this without touching any core function.

2. Another on, in my panel I want to show unit images (from Data\UI\Textures\Icons, the ones with _slot in it). If I copy the image to my textures folder it works, putting the full path to core directory seems to not work
File Data\UI\Textures\Icons\US_infantry_slot.tga

[CNUnitIcon1]
type button
File US_infantry_slot.tga
x 230
y 140
width 80
height 20
sfxfocus 7
sfx 5

Still this shows the 4 images/states but not the image as a button, what is the way to show it as a button with highlight effect. So I can do a disable afterwards.

3. Also to update the panel info I put code in the Tick function, but appears it is not running. Where can I put code that will update text and other info in the panel constantly.

Thanks
Last edited by rf900 on Thu Jul 11, 2013 8:54 am, edited 1 time in total.
Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Re: UI interface customization questions

Post by Amaris »

2) Um I think you need to put your images into \DATA\UI\Textures and not Data\UI\Textures\Icons.

3) I guess you need a function who set the string of your UI. For my carrier, the UI script (with NAM_UI_SetUIStrings_carrier()) will be set the string as necessary (each time a value is changed):

Code: Select all

FUNCTION UI_OBJ_HANDLE(data, event, id)
{
        ....
	
	NAM_UI_SetUIStrings_carrier(me);
		
        ....

	//button TYPE OF RAID
	if( IsUIObject(id, "CARRIER_Type_Raid" ) == 1 )
	{
		marker = GetAttrib(me, "CARRIER_Type_Raid") ;
		if( event == 0 )
		{
			marker++ ;
		}
		else 
		{
			marker-- ;
		}
		
		if( marker < 1)
		{
			marker = 3 ;
		}
		
		if( marker > 3)
		{
			marker = 1 ;
		}		
		SetAttrib(me, "CARRIER_Type_Raid", marker) ;	
	
		NAM_UI_SetUIStrings_carrier(me);
	}
        ....
“Take care, my friend; watch your six, and do one more roll… just for me.”
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: UI interface customization questions

Post by rf900 »

Thanks Amaris, I know the default image directory is Textures, but I was expecting that putting the path would make it able to find others. I saw some bsf functions that were using the full path, so I thought it may work directly in the txt UI def, will do it by code if there is not easier way. Still I don't know what is the rule that for dds images it will show it as a single image with 4 states or put the four images all together.

I will try the answer to 3, UI_OBJ_HANDLE is probably a listener that is always running so putting code there will be good for me to update some strings constantly.
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: UI interface customization questions

Post by rf900 »

For 2 putting the path like this works: File \Icons\US_infantry_slot.tga

Well, it works but the button area is much bigger than what shown, so it occupies more blank space and moving the mouse over that space makes the button highlight.
Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Re: UI interface customization questions

Post by Amaris »

rf900 wrote:For 2 putting the path like this works: File \Icons\US_infantry_slot.tga

Well, it works but the button area is much bigger than what shown, so it occupies more blank space and moving the mouse over that space makes the button highlight.
Try to re-size your image to the size definite in your UI file:

[CNUnitIcon1]
type button
File US_infantry_slot.tga
x 230
y 140
width 80
height 20

sfxfocus 7
sfx 5
“Take care, my friend; watch your six, and do one more roll… just for me.”
AndrewGardner
Slitherine
Slitherine
Posts: 535
Joined: Tue Nov 13, 2012 6:24 pm

Re: UI interface customization questions

Post by AndrewGardner »

Because the _slot images do not use the normal quarter of the image for each of the button states, you will need to add something like
IMAGEV 0.15
to say that the portion is smaller (in this example 30% of normal) than the typical button size.

UI scripts don't have Tick callbacks, UI_OBJ_RENDER is the closest equivalent.

I'm not clear on the issue you are having with other UIs running behind yours. Perhaps it is an issue with the settings on your root UI object.
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: UI interface customization questions

Post by rf900 »

Thanks Andrew that did it.

As for the bonus I try doing this, but the drop down menu is still showing up. I cannot close my UI panel until I cancel the drop menu in the game area.

// tell us whether the drop menu item should display/be disabled. Anything >= 0 means show as normal
function CHECK_BONUS_BUYUNITS(tilex,tiley,unit)
{
return -1;
}

Edit: Great, UI_OBJ_RENDER does the trick for updating info on the panel.
pipfromslitherine
Site Admin
Site Admin
Posts: 9863
Joined: Wed Mar 23, 2005 10:35 pm

Re: UI interface customization questions

Post by pipfromslitherine »

The bonus->place bonus functionality is somewhat hard coded. I will add functionality to make it more flexible to the BA2 wishlist, but we are unlikely to tinker with the current code that much at this point.

A simpler solution might be to add a (non modal) UI screen with a button to pop up the dialog as needed.

Cheers

Pip
follow me on Twitter here
Post Reply

Return to “Battle Academy : Modders Corner ”