Jump to content

Help adding a simple UI texture?


MachDelta

Recommended Posts

Hey everyone, I'm struggling with what should be a fairly simple task. I wanted to add a simple icon to the HUD for a mod, and I tried piecing together some tutorials and even other mods that do it, but I'm running into several issues:

 

1) Primarily, UnrealEd does not seem to treat my packages properly. I can import a texture just fine and assign it to a new package. The texture will show up in the content browser but no matter what I try the actual package will not appear on the package browser on the left. Furthermore, when I go to save my package UnrealEd will not give me a choice of name or extension, or location, or anything really. It automatically names it and sticks .u at the end (although, if memory serves, Unreal extensions are entirely cosmetic). Then, when I reboot UnrealEd and open my package, nothing appears, neither texture nor package, yet UnrealEd has hooked onto the file because the shell throws a fit if you try to move/rename/delete it. Not really sure how to troubleshoot this one. I'm generally a very patient person, but UnrealEd has an incredible ability to cut right to my inner Mr. Hyde.

 

 

2) The biggest problem is that after all this fighting with UnrealEd I still can't get the texture to appear in game. Any attempt to invoke it by spawning a UIIcon fails and I get the default "IMG" on a rainbow texture. I've triple checked the command

icon = spawn(class'UIIcon', TestPanel).initicon('TestIcon',"img:///Packagename.Category.Texturename",,,64);

but it doesn't appear. I don't know if this is a problem with how I'm invoking it, or if I have to explicitly tell the game to load the package in a config somewhere, or if the package itself is corrupted (my suspect), or what.

 

 

3) That 85mb shader cache file it drags along... WTF? I know there are other threads dealing with this issue but I was focused on solving my other issues first. Is there a quick solution to this garbage?

 

 

So, anyone feel like walking a moron through some of this? Much appreciated.

 

 

 

Edit: I realized that the source image is no where near 38k so out of curiosity I opened the file UnrealEd created in Notepad++ and to my surprise found most of the mod's scripts sitting in there too. What in the hell is going on with this thing? :mad:

Edited by MachDelta
Link to comment
Share on other sites

 

 

I'm generally a very patient person, but UnrealEd has an incredible ability to cut right to my inner Mr. Hyde.

 

I feel you. I am in exactly the same position with this annoying rainbow img. Other mods obviously have it working. In fact when I copy a upk file from another mod and use their graphic in my mod, it works. So there is some trick about creating a upk which the game "likes". I will keep beating my head against the wall, and let you know if I find any magic trick. If you get it working please post here.

 

Of course if anybody else would like to explain to the two "morons" that would be great.

Link to comment
Share on other sites

My own problems are not so much as adding textures but to replace any defaults. In terms of pre-declared components, btw. Gee, just take a look at my qUIck Project thread and you'll understand what's mostly involved.

 

I've heard this whole restriction can be explained in a simple way; IF the engine can't find correct references (archetypes, addressable tags, archive paths, etc) there's no way it would loop them in as valid.

Secondly, the destination context matters a lot. GFX, straight up UI/HUD placeholders, indirect components, models... and many more situations.

 

We can benefit from a "UIListeners" method i gather... but that is a freaking difficult process to master reliably. For code savvy people maybe - but to the common man, there's a lot of dependencies to deal with -- many of which burried in extra functions or obfuscated locations or instructions.

 

IMHO, the only reasonable solution to every kind of indirect re-texturing attempts probably still is a gamble with "TexMod style" processing... rightfully adapted (by some genius IDE coder out there in the wild) to the most recent XC2 properties. We simply need a supplemental SDK toolset specifically aimed at controlling (reasonably) any graphics related issues.

 

Otherwise, we're doomed to building mod results in months rather than just a few hours of drag/drop fiddling with proper resources already tied with rational principles -- documented enough.

Edited by Zyxpsilon
Link to comment
Share on other sites

I have a upk file which I created from scratch, which looks like it has the right stuff when I look at it in the xcom editor. But, when I refer to this resource in game, it comes up with the rainbow missing image. So, I am glad that your upk file is working, but mine isn't, and I can't figure out what step I missed.

Link to comment
Share on other sites

Okay first & foremost... HOW do you declare this already archived file to the "Engine"??

 

For example, my newly colored Classes are only accessible via XComClassData.INI -- simply because, the code structure was designed with such a direct method for _them_.

Everything else seems off-limits unless connected with actual texturing Hooks that the engine can easily detect.

Edited by Zyxpsilon
Link to comment
Share on other sites

OK, here are two upk files (attached in a zip file). The first one is from the rifleman mod and I can refer to its class icon fine. The second one I created, but the images only display as the rainbow img. Can you help me understand what is wrong with the way I created the upk file, or the textures?

 

Both upk files are in my content directory. When I have this line in my custom soldier class, the rifleman icon displays fine in game:

+IconImage=img:///UILibrary_Rifleman.class_rifleman

When I have this line, I get the rainbow img:

+IconImage=img:///AdventRookies.class_viper

The filenames and resource names are correct. In the log file I see this error:

[0085.36] Warning: Warning, Failed to load 'Texture AdventRookies.class_viper': Failed to find object 'Texture AdventRookies.class_viper'

 

The only difference I can see is that my textures are type DXT1 while the rifleman texture is type DXT5. I cannot find a graphics tool that lets me choose which flavor of TGA file to save. Photoshop doesn't speak TGA at all. I converted using irfanview, but I can't find any way to control the DXT type it writes out.

 

I have gone through this guide, which TBH is kind of hard to follow:

http://imgur.com/a/rQ3aJ

 

I thought I was onto something when I re-read step 11 regarding the LOD setting. But, for an existing texture, you can right click and choose "Properties...", then expand the Texture section, and find the LODGroup option. By default it is "World", I set it to UI, saved and retried. But that does not fix the problem.

 

Any suggestions? I hope it is something simple.

Edited by davidlallen
Link to comment
Share on other sites

The trick with Texturing properties is that their inherent details can make or break the feed-loop necessary for the code to recognise how the various settings match with intended conditions.

As a generic rule of thumb, it's always a good idea to find similar objects straight from UE3 files, examine the configuration of valid (default) files and presume the context is the point of reference you'd have to follow to the letter. Barring the fact that some instances *DO* insist on receiving their hooks from archetypes (or other means of code functions), the end-result should be consistent -- the engine expects *THIS* and it shouldn't ever be *THAT*.

 

The TC_??? options also have strict compression steps which override a fair chunk of custom settings (LOD included, btw)... it pushes a number of key factors to determine if DXT1 or DXT5 might serve better for example. It's nearly random, sadly.

 

TGA -- i would highly recommend Gimp for it. Reliably made solid versions of anything i dared dumping into it. And since its filtering steps also include 32b/Alpha support natively, it's the most obvious solution around. Between Adobe or Photoshop 1000$+ scams & the FREE-Gimp!... well, you decide. :wink:

 

PS; There's much more to any "+IconImage=img..." instructions that meets the eye, btw. (( Capital letters or not! )) :ninja:

Edited by Zyxpsilon
Link to comment
Share on other sites

Hey everyone, I'm struggling with what should be a fairly simple task. I wanted to add a simple icon to the HUD for a mod, and I tried piecing together some tutorials and even other mods that do it, but I'm running into several issues:

 

1) Primarily, UnrealEd does not seem to treat my packages properly. I can import a texture just fine and assign it to a new package. The texture will show up in the content browser but no matter what I try the actual package will not appear on the package browser on the left. Furthermore, when I go to save my package UnrealEd will not give me a choice of name or extension, or location, or anything really. It automatically names it and sticks .u at the end (although, if memory serves, Unreal extensions are entirely cosmetic). Then, when I reboot UnrealEd and open my package, nothing appears, neither texture nor package, yet UnrealEd has hooked onto the file because the shell throws a fit if you try to move/rename/delete it. Not really sure how to troubleshoot this one. I'm generally a very patient person, but UnrealEd has an incredible ability to cut right to my inner Mr. Hyde.

 

 

2) The biggest problem is that after all this fighting with UnrealEd I still can't get the texture to appear in game. Any attempt to invoke it by spawning a UIIcon fails and I get the default "IMG" on a rainbow texture. I've triple checked the command

icon = spawn(class'UIIcon', TestPanel).initicon('TestIcon',"img:///Packagename.Category.Texturename",,,64);

but it doesn't appear. I don't know if this is a problem with how I'm invoking it, or if I have to explicitly tell the game to load the package in a config somewhere, or if the package itself is corrupted (my suspect), or what.

 

 

3) That 85mb shader cache file it drags along... WTF? I know there are other threads dealing with this issue but I was focused on solving my other issues first. Is there a quick solution to this garbage?

 

 

So, anyone feel like walking a moron through some of this? Much appreciated.

 

 

 

Edit: I realized that the source image is no where near 38k so out of curiosity I opened the file UnrealEd created in Notepad++ and to my surprise found most of the mod's scripts sitting in there too. What in the hell is going on with this thing? :mad:

 

 

1) When you create a new art content package, you won't be saving/storing it into the XComGame content folder -- that's basically reserved for the base game content.

 

When you first create your art package, it won't show up under the "XComGame" folder in packages, but will show up in the "NewPackages" folder. When you save your package, you should save it into your mod's content folder. For example : C:\Games\X2 Projects\Stage1Mods\LW_SMGPack\LW_SMGPack\Content\LWSMG_CV.upk . Note that this is outside of both the SDK and the game folders, so it will complain if you have any assets that are referencing things inside your package, but it will still work. When you want to edit your art package, open the copy from the same folder as above -- it will now show up in the "External" folder.

 

However, you still need to add your art package to your mod project. Within ModBuddy, with you project open, in the Solution Explorer, right-click on the Content folder, and select "Add / Existing Item...". Now select the upk that you just saved into your mod's content folder. This step is necessary so that when you build your project, any content packages will be copied to the SDK and game folders. Further, if you need shaders precompiled (the second step of build process), this is where the Build dll looks for your content packages to be processed -- but ONLY if they are added to the ModBuddy project.

 

I'm not sure why it is saving with a *.u extension -- all of my content packages are always saved with *.upk. Be sure you're not trying to save your art into your script package (which has a *.u extension) ... script packages and art packages should be kept separate.

 

-----------------

 

2) The method I use to avoid typos is to open the art package in UnrealEd, right-click on the UI texture and select "Copy Full Name to Clipboard". Then paste this into your *.uc script file. This returns, as an example, something like : Texture2D'UILibrary_SMG.magnetic.Inv_LWMagSMG'. To convert this to what's used when loading, change it to : "img:///UILibrary_SMG.magnetic.Inv_LWMagSMG".

 

Note that you can't use the "img:///" part when defining a config variable, as the config parser has trouble with this (this is an Unreal Engine thing, not a Firaxis thing). To get around this I define the root part as config, and prefix the "img:///" part in code. For example:

 

In Configuration file:

SMG_MG_ImagePath=UILibrary_SMG.magnetic.Inv_LWMagSMG

In Template code:

Template.strImage = "img:///" $ default.SMG_MG_ImagePath; 

It looks like this was fixed in XCOM 2, as the base-game config files have entries such as :

RewardImagePath=img:///UILibrary_Common.HackReward_LargeIntelCache

-----------------

3) Yes, the local shader cache is an issue. Firaxis doesn't use automated systems to build shader caches -- they built that just for us modders.

The issue seems to be that if a local shader cache gets built while you are using UnrealEd (basically you are doing something interesting, and it has to build a shader at run-time to support that), that local shader cache is getting joined with what is built by the Build script.

As mentioned in TrackTwo's post, you need to clear out the UnrealEd local shader cache, then rebuild the mods.

-----------------

P.S. The reason the script files are there in the package is because we are not cooking our packages, so they have extra stuff for debugging in them. Cooking cleans all that stuff out, and optimizes everything for quicker loading (particular on consoles).

Link to comment
Share on other sites

Thanks for the background. What do you suggest I should try next? I really have no ideas. Do you think DXT1 vs DXT5 is the problem, or is that just one random bit of information?

 

I opened up your files as well. We generally use the PNG format instead of TGA. Practically speaking, the main difference between DXT1 and DXT5 is that DXT5 supports an alpha channel, while DXT1 doesn't. So your class_viper image likely doesn't have an alpha channel, which you're going to want.

 

I mostly see DXT1 textures used for normal maps (since they only use two channels anyhow), although there are some regular images that use DXT1 (e.g. Texture2D'UILibrary_Common.HackReward_largeIntelCache'), and that seems to load fine, so it shouldn't have any problems loading your image, either.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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