Interface functions editing

Hello, I’d like to ask about something that has always been bothering me in NWN2. I don’t like a couple of features of a piece of interface and I’d wish to change it. I don’t mean editing the .xml files since that is simple, I’d like to change the actual functionality of the thing, what happens inside of it.

Namely the Examine window is bothering me with the fact that upon inspecting a creature it first shows the level of hit points and challenge rating and only then shows description and effects. I’d like to remove the first two things so that we see the description right away.

And when we inspect an item it first shows the description and after that the special abilities of the item, so I’d like to reverse this order so that I dont have to scroll down every time.

I figured to ask this after discovering the existance of stuff that is being made by Lance_Botelle - there’s lots of alteration of interface functions inside of his project.
I dunno if any kind of tutorial for this stuff exists anywhere, so I’d be grateful for insight. :slightly_smiling_face: Cheers!

Actually, editing the examine.xml file will do it.

You should be able to delete/comment out the unwanted text portions and edit the y axis of the text portion you want to keep to raise it up.

You can copy/paste sections within the xml to change the order

There isn’t a lot to the examine.xml.

Edit a copy in the override until you get the results you want.

Remember to make sure there is only one examine.xml in your override.

I use notepad++

Edit: I guess I misread the first post. I thought the desire was to just reorder the info blocks.
:slight_smile:

1 Like

Hi @Envuen

Actually, much of the stuff I do with the interface is to do with XML editing. You have to write new callbacks to update the altered interface for any new feedback required. I have written a tutorial for the basics of this:

https://neverwintervault.org/project/nwn2/other/gui/nwn2-xml-gui-coding-beginners

I confess that I don’t find editing XML files that easy, as they take me a while to grasp and alter, so maybe I am misunderstanding you? However, I believe it could be possible that my tutorial may help guide you to some alterations you are after. :slightly_smiling_face:

The Examine window is (for me) one of the more tricky XML’s to alter as it is often accessed by a context menu. i.e. Right click on a target and select examine. It also has “default” values that can affect the final outcome of its display. Have you noticed any of the alterations of the Examine in my own campaign? It was probably the most complex GUI for me to work on, and even required some fudging to display as I liked due to some hard-coded aspects. Then again, maybe you just need some basic alterations as Axe Edge suggests?

My best advise is to take a look at the tutorial and work through it. If you find that easy enough, then try looking at what I did in my own campaign with the examine.xml, and see if you can figure how to alter stuff for that xml further to your liking. Ignore anything that isn’t to your liking, but just try to see what I did there.

I’m offline for a few hours now, but hopefully, the above is some help for you in the meantime. :slightly_smiling_face:

2 Likes

Actually, unfortunately no :frowning: The .xml file only determines where to display the info, not what info to display

@Lance_Botelle Hello there, yeah I might have not been too precise, what I meant is that I found it simple to change the numbers and the order of things inside of the .xml files but that only changes position and dimensions of the panels/buttons/lists and what not. I did manage to add some new stuff but it was only by copying it from other .xml files. Polishing out any mistakes is simply a matter of trial and error here.

What I’m unable to do is to modify the way some of these elements of interface work. So for instance, in this particular case, inside examine.xml we have the element called UIText name=“EXAMINE_DESCRIPTION_TEXT”. But that’s it, it isn’t determined there what shows up inside of this element and in which order. So there is a function somewhere that determines it, might be hardcoded.

But I saw on the screenshots your - for example - inventory window display data not seen anywhere else (like resistances to specified elements) or brand new windows of interface showing stuff specific to your module so that gave me an idea that it is in fact possible to edit those things somehow.

And there is also a matter of stuff that doesnt have a command attached to it or has a command that does not work properly. Like in the script editor the GetDescription() apparently is unable to grab the text from the toolset entity, we’d have to manually set it first ourselves. But it works for the game itself so it must be using some other method.

By the way I read a bit of your blog and watched a couple of videos, you put some impressive amount of work into your project. Seems like your neverwinterish baby! It was kind of you to make “The Scroll” module available to download even if only in a case such as this, to help other modders learn from your practice.

I downladed your module to take a look at the “My UI” folder and to inspect the “examine.xml”, it already features lots of additional data and references to “gui_examine” which doesn’t exist in the default game. I’m gonna take a look at this tutorial, maybe I’ll be able to re-do some of the stuff as you say.

Thanks for your interest, have a good day

1 Like

@Envuen

Yes, I believe this is part of the difficulty I came up against.

Yes, the inventory is an “easier” XML to edit, as it is what I call a stand-alone type, which simply does one thing and so we can add/alter a lot easier than the more “complex” examine.xml. Looking at the two, one would have assumed the examine to have been easier, but I think the examine does have hard-coded elements and multiple references that make it more complicated to edit, as we have found.

Yes, this is one of the issues I had to work around. IIRC, I made the PC examine the item prior any call, which helped me acquire the description to work with. It’s been a long while since I worked through this code and it is rather involved. It requires close examination of the code to follow what I did to grab it.

That is very kind of you to say. :slight_smile: I’m glad that you have been able to gain from it, and I hope others do too. I hope you have the opportunity to see my next module in The Scroll series when it becomes available. It feels like it has become quite involved in story and making.

Yes, you will see that I have added some extra callbacks to add/change what the examine window shows. As I say above, it was not the easiest GUI to work with, but I did manage to add some new elements that have been helpful. EDIT: The Updated_OC_UI folder is where I have the edited official UI xml files.

The function you may want to look out for is LBAddToDescription (in alb_functions_core). However, you will need to adapt the concept to work with anything you do, as I believe it works alongside other aspects of the overall code.

///////////////////////////////////////////////////////////////////////////////////////////////////
// Adds extra text to creatures/items main description, By Lance Botelle. (Edited EXAMINE GUI also.)
// Added TEXT is assigned either PERMANENT (DEFAULT) or TEMPORARY status. 
// NB: ITEMS: SINGLE TARGET SPECIFIC : DO NOT USE WITH STACKED ITEMS. Tag and variables are preserved.
// PERMANENT texts can normally be appended. A SINGLE TEMPORARY text must be updated as required.
// TEXT IS INSERTED AFTER NORMAL DESCRIPTIVE TEXT: "PERMTEXT" + "TEMPTEXT". (THEN ANY ITEM PROPERTIES.)
///////////////////////////////////////////////////////////////////////////////////////////////////
// CREATURES USE OF XML EXTRA PANE CALLED "POST_DESCRIPTION_TEXT"
// A) A PERMANENT text is normally set only once. (Theoretically could be changed as required.)
// B) TEMPORARY TEXTS USED FOR ANY CURRENT EFFECTS THE CREATURE HAS ON THEM AT EXAMINE TIME ONLY!
///////////////////////////////////////////////////////////////////////////////////////////////////
// ITEMS JUST APPEND THIER NORMAL DESCRIPTION UPDATED WHEN CLICKED ON. "ITEMDECS" UPDATES.
// A) PERMANENT texts are normally appended to any exisiting such texts as required.
// B) TEMPORARY text can only be ONE at a time, so apply sparingly. (NB; Properties handled elsehwere.) 
///////////////////////////////////////////////////////////////////////////////////////////////////
void LBAddToDescription(object oTarget, string sTextAdd = "", int iItemTemp = 0); 
void LBAddToDescription(object oTarget, string sTextAdd = "", int iItemTemp = 0)
{
	// CREATURE POST DESCRIPTION TEXT IS ALWAYS PERMANENT THIS WAY. (CAN OVERWRITE)
	if(GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
	{		
		SetLocalString(oTarget, "POSTDESCTEXT", sTextAdd);
	}
	
	else
	{			
		string sPERMPLUS = GetLocalString(oTarget, "PERMTEXT");
		string sTEMP = GetLocalString(oTarget, "TEMPTEXT");				
		
		// UPDATE (OR ADD TO) A PERMANENT TEXT
		if(iItemTemp == 0)
		{				
			// DO NOT DUPLICATE ANY POTENTIAL EXISTING TEXT
			if(FindSubString(sPERMPLUS, sTextAdd) == -1)
			{
				sPERMPLUS = sPERMPLUS + "\n" + sTextAdd;	
				SetLocalString(oTarget, "PERMTEXT", sPERMPLUS);
			}
			
			else
			{
				return;						
			}
		}
		
		// UPDATE TEMP TEXT
		else if(sTextAdd != "")
		{	
			// CAN ONLY BE ONE INSTANCE FOR ITEMS (OVERWRITES)
			SetLocalString(oTarget, "TEMPTEXT", sTEMP);
			sTEMP = sTextAdd;			
		}
		
		// DELETE TEMP TEXT
		else
		{
			DeleteLocalString(oTarget, "TEMPTEXT");	
			sTEMP = "";		
		}
		
		// UPDATE STRING VARIABLE
		if(sPERMPLUS != "" && sTEMP != ""){sPERMPLUS = sPERMPLUS + "\n" + sTEMP;}
		else if(sPERMPLUS == ""){sPERMPLUS = sTEMP;}
								
		SetLocalString(oTarget, "POSTDESCTEXT", sPERMPLUS);
		
		DeleteLocalString(oTarget, "ITEMDECS");
	}
}
1 Like

You need to edit the XML, to remove what you don’t want.

And to create the new field you want you want.

Then you need to fill the new field, with local variables, and fetch them.

you can use UIObject_Misc_ExecuteServerScript(“gui_helloworld”) inside the XML to call a regular script

and in that script you need to set Variables inside the GUI, and then you can fetch them.

Whatever type you set it’s always a string format.

So in the script “SetLocalGUIVariable”, to assign a value to the GUI variable inside your XML.

I did something like that in my BGR campaign for the stats panel in the character screen XML.
I think it’s It’s a good exemple beceause the panel was made from scratch.

2 Likes

Thanks for the replies. This is a more complex unknown than what I had coded so far but I’ll try to get it to work eventually :grinning:

1 Like