Jump to content

Amm counter in the HUD xml


miguick

Recommended Posts

I'm a bit stumped on this so i thought I'd ask for help in case anyone can guide me.

 

I'm trying to locate in the game's menu files where the display for the ammo count is controlled, but so far it's evading me. Plenty of HUD mods can manipulate it without much trouble, I tried making sense of the HUD Editor's scripts to see what it's doing with it after I edit the ammo counter position but I can't understand it.

All I can find related to ammo in the HUDMainMenu xml is the "AmmoTypeLabel" element, but that controls the type of ammo chambered in the weapon, not the ammo counter.

 

Is it under a completely different element? Or in some other menu? Any help is appreciated.

Link to comment
Share on other sites

If you wanted to manipulate the element using SetUIFloat you would use: SetUIFloat "HUDMainMenu\ActionPoints\justify_right_text:1"

 

Now, you may be asking: "There is no element called justify_right_text"

If you look inside HUDMainMenu.xml you can find this text: "<include src="HUDTemplates.xml"/>", that xml file is where most of the HUD is located, it contains a bunch of templates.

 

If you were to edit "justify_right_text" you would be successfully editing the ammo count, but you would also be editing all this as well. There is a way to get around that though.

Edited by IntenseMute
Link to comment
Share on other sites

Oh thank god, the man himself!

 

I admit, I have severe limitations when it comes to working with xml, the last time I did some very simple things for Oblivion but it took me HOURS of trial and error to get them working.

 

I've figured it's at the ActionPoints rect like you say, had no idea how it drew from the templates.

 

Now I guess there's no point in beating around the bush: what I want to do is not manipulating the counter, rather introducing one when the game's own is not visible. So, when not having an actual gun or shooty thing out.

I'm aiming for it to imitate the real thing as much as possible, so perhaps it could have its elements copy the originals'.

 

Right now I was looking at the Quickthrow mod, and apparently it doesn't even use any InjectUI commands? Duh, it uses UIO for that.

 

I was also wondering how to make it play well with other UI mods, as in, yours adds an extra rect "_Wrap" level above ActionPoints rect, would I have to take special measures, or is there some syntax that will avoid having to do that?

 

Or for that matter, I recall oHUD doesn't hide the ammo counter when drawing a melee weapon, probably a bug, but in that case I could go ahead and just hide the thing myself?

 

Thank you for your time, I know this all sounds kinda disjointed but I'm just aiming blind.

 

EDIT: didn't even realize there's a forum more apt for these things, maybe I should report this to be moved there

 

If you wanted to manipulate the element using SetUIFloat you would use: SetUIFloat "HUDMainMenu\ActionPoints\justify_right_text:1"

 

Now, you may be asking: "There is no element called justify_right_text"

If you look inside HUDMainMenu.xml you can find this text: "<include src="HUDTemplates.xml"/>", that xml file is where most of the HUD is located, it contains a bunch of templates.

 

If you were to edit "justify_right_text" you would be successfully editing the ammo count, but you would also be editing all this as well. There is a way to get around that though.

Link to comment
Share on other sites

"what I want to do is not manipulating the counter, rather introducing one when the game's own is not visible. So, when not having an actual gun or shooty thing out. I'm aiming for it to imitate the real thing as much as possible, so perhaps it could have its elements copy the originals'."

Oh boy! That's some complicated stuff right there. Just keep asking questions and I can try and help.

 

 

I was also wondering how to make it play well with other UI mods, as in, yours adds an extra rect "_Wrap" level above ActionPoints rect, would I have to take special measures, or is there some syntax that will avoid having to do that?
If you are editing HUDTemplates.xml, you don't have to do anything special but if you are using InjectUI functions, then you need to do...
If IsModLoaded "TheHUDEdutir.esp" == 1
   InjectUIComponent "HUDMainMenu\AP_Wrap\ActionPoints\justify_right_text:1" "BlahBlahBlah"
EndIf
...and correct it for any mod that edits the path.
You might find this link helpful "Category:Oblivion XML", specifically the categories at the end of the page.
But the best way to learn is to look at other peoples XML file edits.
Edited by IntenseMute
Link to comment
Share on other sites

Oh boy! That's some complicated stuff right there. Just keep asking questions and I can try and help.

Thank you again. I'm not making much progress. I remember in Oblivion I could use OBSE commands to "dissect" any menu with GetTileChildren and GetTileTraits and learn how they were structured at runtime, but there's none of that here and I'm just writing random strings in a script hoping they point to somewhere.

 

I think I can identify the ammo counter's visibility at "HUDMainMenu\ActionPoints\*:4\visible", for the vanilla UI, for your mod it needs that "AP_Wrap\" before ActionPoints. But that's all I can find.

 

"visible"seems to be hardcoded to hide when no gun is equipped, though it can be hidden and shown while a gun is equipped. So I'm guessing that I'll need to make my UI element one way or another, since i can't just manipulate the standard one for what I want?

 

But I don't get the syntax. I don't get how the "*:N" syntax works, no matter how many times I read it. And I have no idea how to retrieve what the ammo counter is actually showing, be it a string or a value.

 

Lets see if i can schematize this:

- When a melee weapon is equipped, I want there to be a counter like the ammo one

- I want it to inherit as many properties as possible from the real counter (position, color, size, alpha...) so that it feels like part of the user's own UI

- I want to manipulate what the counter displays myself. So it isn't necessarily like the original "x/y", but rather shows a flat number, or a string, whatever I tell it in scripts

- I'd rather use an UIO text file for easy injection, I don't know if my aim for it to imitate the real counter would mean compatibility with the "AP_Wrap" would be a problem

Link to comment
Share on other sites

"I think I can identify the ammo counter's visibility at "HUDMainMenu\ActionPoints\*:4\visible", for the vanilla UI, for your mod it needs that "AP_Wrap\" before ActionPoints. But that's all I can find."

What exactly are you trying to find because I can tell you the path to every HUD element. I made this image for somebody else a long time ago, you might find it helpful.

 

""visible"seems to be hardcoded to hide when no gun is equipped, though it can be hidden and shown while a gun is equipped. So I'm guessing that I'll need to make my UI element one way or another, since i can't just manipulate the standard one for what I want?"

Yeah, you gotta clone that if you want to work around that hardcoded garbage.

 

"But I don't get the syntax. I don't get how the "*:N" syntax works, no matter how many times I read it."

Well, here is an example...

<rect name="Parent">
   <rect name="Child">
      <!-- This would be: SetUIFloat "HUDMainMenu\Parent\Child:0" -->
      <!-- ...or... -->
      <!-- This would be: SetUIFloat "HUDMainMenu\Parent\*:0" -->
   </rect>
   
   <rect name="Child">
      <!-- This would be: SetUIFloat "HUDMainMenu\Parent\Child:1" -->
      <!-- ...or... -->
      <!-- This would be: SetUIFloat "HUDMainMenu\Parent\*:1" -->
   </rect>
      
   <rect name="Example">
      <!-- This would be: SetUIFloat "HUDMainMenu\Parent\Example:0" -->
      <!-- ...or... -->
      <!-- This would be: SetUIFloat "HUDMainMenu\Parent\*:2" -->
   </rect>
   
   <rect name="Child">
      <!-- This would be: SetUIFloat "HUDMainMenu\Parent\Child:2" -->
      <!-- ...or... -->
      <!-- This would be: SetUIFloat "HUDMainMenu\Parent\*:3" -->
   </rect>
</rect>

 

 

...For anything that uses templates, it is just a guessing game on what "*:N" is going to be since the order that the elements were added are not shown.

 

"...And I have no idea how to retrieve what the ammo counter is actually showing, be it a string or a value."

If you want to retrieve it through script, you would use...

 

 

Let MyStringVariable := GetUIString "HUDMainMenu\ActionPoints\justify_right_text:1\string"

Set MyFloatVariable To GetUIFloat "HUDMainMenu\ActionPoints\justify_right_text:1\visible"

 

 

...Using "*:4" doesn't work when checking for the string for some reason, use "justify_right_text:1" instead. Don't ask why, because I have no idea!

Also, if you have added another element within "template_justify_right_text", you have to use "justify_right_text:1" to check the visibility. otherwise "*:4" would have been fine.

Link to comment
Share on other sites

This has been every bit as difficult as I remember, and then some. But I couldn't have asked for better help. Thank you IntenseMute.

 

I simply was making every rookie mistake at once. First I wasn't putting my xml under "menus/prefabs". Then I wasn't naming the UIO txt file correctly. Then I wasn't writing the correct path in it. THEN it turns out I needed to refresh MO2 any time I make a change to any file, or else just quick launching the game from the GECK extender fails to load and recognize my changes.

 

I can finally see a TEST string in game, injected under the ActionPoints rect, now it's a matter of manipulating it. I wish I could make it copy traits from the real ammo counter in the xml and then I could leave most of those on "auto-pilot", but after seeing all this I'm guessing copying traits in the xml file from an arbitrary sibling or parent is beyond my skill. I suppose keeping it updated in a script isn't too hard.

Link to comment
Share on other sites

"I wish I could make it copy traits from the real ammo counter in the xml and then I could leave most of those on "auto-pilot", but after seeing all this I'm guessing copying traits in the xml file from an arbitrary sibling or parent is beyond my skill. I suppose keeping it updated in a script isn't too hard."

In the UIO txt file, if you type...

MyFile.xml::@prefabs\hudtemplates.xml::template_justify_right_text
True 

...your injected xml file has now been injected inside the hudtemplates.xml file, and inside the element <template name="template_justify_right_text">.

 

Your xml file should look like this...

 

 

<text name="justify_right_text_clone">
   <visible>0</visible>
   <alpha><copy src="sibling(justify_right_text)" trait="alpha"/></alpha>
   <depth><copy src="sibling(justify_right_text)" trait="depth"/></depth>
   <justify><copy src="sibling(justify_right_text)" trait="justify"/></justify>
   <font><copy src="sibling(justify_right_text)" trait="font"/></font>
   <wrapwidth><copy src="sibling(justify_right_text)" trait="wrapwidth"/></wrapwidth>
   <string><copy src="sibling(justify_right_text)" trait="string"/></string>
   <rotateangle><copy src="sibling(justify_right_text)" trait="rotateangle"/></rotateangle>
   <rotateaxisx><copy src="sibling(justify_right_text)" trait="rotateaxisx"/></rotateaxisx>
   <rotateaxisy><copy src="sibling(justify_right_text)" trait="rotateaxisy"/></rotateaxisy>
   <systemcolor><copy src="parent()" trait="systemcolor"/></systemcolor>
   <red><copy src="sibling(justify_right_text)" trait="red"/></red>
   <green><copy src="sibling(justify_right_text)" trait="green"/></green>
   <blue><copy src="sibling(justify_right_text)" trait="blue"/></blue>
   <x><copy src="sibling(justify_right_text)" trait="x"/></x>
   <y><copy src="sibling(justify_right_text)" trait="y"/></y>
</text> 

 

 

...and the path to control the new clone would be: SetUIFloat "HUDMainMenu\ActionPoints\justify_right_text_clone:1\visible" 1

Edited by IntenseMute
Link to comment
Share on other sites

It's working. It's just as I imagined, and I have you to thank for!

 

I had tried to inject it into the templates files, but I would never have guessed I had to do so at the right rect, so it becomes another "listed" element and thus child nº 1 will be a sibling of the ammo counter. Goddamn, how does one learn to think like this to work with xml?

 

Now I have to wonder if this can be made compatible with mods adding AP_Wraps and overwriting HUDMainMenu with their own templates, but I'm thinking that's a limitation of me being so specific. I suppose that's why most mods just inject their elements at the base HUDMainMenu and change them with scripts.

 

This method indeed puts all parameters on "autopilot" and you don't have to worry about them showing when they shouldn't, but getting injected there means I'd have to check compatibility for each specific UI replacement mod myself. Well I'll just have to decide how I do it.

 

Well, thank you kindly, this was the cherry on top of the mod I'm trying to finish and it is due to you.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...