Jump to content

Hexadecimal Colour Values in Command1.upk


Neonin

Recommended Posts

Not sure if anyone else is bothered by this but I thought it might be worth documenting at least, even though I'm guessing all you uber-modders out there already worked it out from the fixed constants :tongue:

 

While looking to change the colour of the overall UI from the cyan to something else, I noticed that there were a bunch of hexadecimal colour values stored in Command1.upk. Using JL's great stripped-out ActionScript files I noticed there's a "Colors" section in each one that has the colours set like this...

class Colors
{
   static var NORMAL = "67E8ED";
   static var HILITE = "B9FFFF";
   static var DISABLED = "808080";
   static var BAD = "EE1C25";
   static var GOOD = "5CD16C";
   static var WARNING = "FFD038";
   static var WARNING2 = "F67420";
   static var PSIONIC = "A09CD6";
   static var HYPERWAVE = "F78000";

... and so on. "Great!" I thought to myself, that seems to be what I was looking for. I proceeded to spend five hours going through all the instances of NORMAL (which is the cyan colour) in Command1.upk, and there were a LOT because it's replicated in every ActionScript/Flash thing Johnnylump extracted from the file as well as a lowercase version of the hexadecimal code used in a bunch of HTML-style font tags in various bits of text. I noted down the offsets for each one in a Toolboks mod so that I could quickly change the colour with a find/replace. Job done, I changed the cyan to FF0000 so everything would come up an obvious red.

 

Five hours wasted, nothing happened when I installed the mod ;)

 

I have so far concluded that either the colour values are being overriden/drawn from a default source like the constant values in the exe, or there's another place these are defined I haven't found yet that takes precedence. Just thought I'd document my attempt here in case anyone else looks into this in the future. Sorry if it doesn't make much sense, I'm still pretty new at this!

Edited by Neonin
Link to comment
Share on other sites

Gah, sorry your efforts didn't bear fruit.

 

I'd point to XComGame.upk >> UIUtilities.GetHTMLColoredText() as where (it appears) text colors are assigned. Not sure if those would apply to icons, too, but the color hex in what you posted above lines up with what appears in the function, so you might try changing those and see if it helps!

Link to comment
Share on other sites

This is almost completely off topic right now... But I guess it will become very much on topic when Enemy Within arrives...

How exactly did you strip out the action scripts?

 

I remember reading about it a long time ago but not exactly where and defintively not the details... and I figure it would probably be nice to have script doing it the next time it is needed unless it is very complicated and really needs to be done manually.

Link to comment
Share on other sites

I have so far concluded that either the colour values are being overriden/drawn from a default source like the constant values in the exe, or there's another place these are defined I haven't found yet that takes precedence. Just thought I'd document my attempt here in case anyone else looks into this in the future. Sorry if it doesn't make much sense, I'm still pretty new at this!

You're right about that, a lot of the ActionScript classes used in various GUI components are pulled from a common master file, referred to as '..\gfxComponents\components.swf' which is the single flash file embedded into XComGame.upk.

 

I've tested changing the NORMAL constant from "67E8ED" to "FFFFFF" (pretty straight-forward hex change, as it's plainly readable in XComGame.upk at offset 0xA4C6B8), and sure enough various elements in different UI components in the shell, strategic game and tactical game turned white-ish, mainly text elements like button labels, or the weapon icons in the tactical game.

 

In conclusion, it seems that changing these constants would affect a lot of UI elements, but not all of them and not completely.

This makes sense, as most of the visual components are based on shape definitions, which are separate from ActionScript code and therefore aren't affected by these constants at all. The colors used in shapes (e.g. background panels, button borders and the like) are defined separately for each element in each of the various flash files and it would take a considerable amount of work to find and change all of them - it's not impossible though, just an arduous task :smile:

 

To elaborate on that, each shape is defined by a DefineShape tag, or one of its extensions (DefineShape2, DefineShape3, DefineShape4) in an .swf file. The various SWF tags which can be used are all documented in the SWF File Format Specification.

You can decompile SWF tags via swfdump.exe (part of the excellent SWFTools package) to create a text file containing information like this:

[053]        57 DEFINESHAPE4 defines id 0096
                 bbox [-1.30, -1.30, 957.30, 66.80]
                 | fillstyles(01)        linestyles(01)
                 | 1 ) SOLID 0000007f    1 ) 2.00 e603057f
                 |
                 | fill: 00/01 line:01 - moveTo 956.00 65.50
                 | fill: 00/01 line:01 - lineTo 0.00 65.50
                 | fill: 00/01 line:01 - lineTo 0.00 0.00
                 | fill: 00/01 line:01 - lineTo 956.00 0.00
                 | fill: 00/01 line:01 - lineTo 956.00 65.50
                 |

This tag appears to define a rectangle with a black fill (with 50% opacity) and a bright red (50% opacity) stroke with a with of 2.0 twips (1 twip = 1/20 px). If I'm reading the dump right this is probably the background shape for a sprite used for 'KIA' soldiers in the combat debriefing screen.

Fortunately swfdump.exe can also dump the corresponding hex bytes, so you can quickly identify the corresponding color hex values for modification (which I've highlighted for illustration purposes).

-=> 60 00 87 ff 32 56 57 ff 30 29 c0 80 00 02 55 80 `.‡ÿ2VWÿ0)À€..U€

-=> 00 00 28 f0 01 01 00 00 00 00 7f 01 28 00 a0 02 ..(ð........(. .

-=> 00 03 e6 03 05 7f 11 36 09 56 00 a3 df c5 aa 87 ..æ....6.V.£ßŪ‡

-=> 4d 71 7c 25 58 74 a8 f0 00 Mq|%Xt¨ð.

 

Personally, I think changing the overall color theme of the UI would be a neat thing. It would be most awesome if someone could create a simple utility for users to choose a base color or hue for themselves and creating a customized ToolBoks mod based on that :smile:

I could help with the utility programming part, but I'm not really interested in rifling through all flash files identifying the hundreds of shape definition color offsets needed :sweat:

Edited by XMarksTheSpot
Link to comment
Share on other sites

@Bertilsson: I used the same method JL posted there to strip out the SWF files from Startup.upk (22 of them) so it does work, although you end up with file sizes bigger than strictly necessary as each time you cut out one SWF and leave the rest :P

 

@XMarksTheSpot: Since I already spent five hours identifying 310 instances of a colour code in Command1.upk and their corresponding offsets just to try and do this (although my thinking was instructions to do a find/replace with someones chosen colour on the Toolboks mod, a utility would be even better), I'm willing to give it a go. Considering the effort required though I'm wary about starting before EW hits in case some of these things move around and require the process to be done again.

Link to comment
Share on other sites

[...] (although my thinking was instructions to do a find/replace with someones chosen colour on the Toolboks mod, a utility would be even better), [...]

Replacing all color instances with a single specific color probably wouldn't be a good idea as the various shapes most likely use different shades of the basic cyan color. I think the best option would be identifying all necessary colors and their offsets and dynamically applying some kind of general color transformation to turn each of them into corresponding shades of a different base color, e.g. via hue/saturation/lightness (HSL) shifting.

 

There's still a bunch of UI elements that do not feature the basic cyan theme, e.g. the abduction selection menu (yellow), the landed ufo mission menu (red), the Psi Labs testing notification popup (purple) to name a few.

These could all be grouped under a corresponding color scheme and receive their own color transformation, if desired :) Or each menu could get its own separate transformation, if one would want to further differentiate them from one another.

Link to comment
Share on other sites

This is almost completely off topic right now... But I guess it will become very much on topic when Enemy Within arrives...

How exactly did you strip out the action scripts?

I wrote a tool that strips out all the SWF files in all the UPKs, but no one was interested so I didn't end up ironing out the bugs for it to be released. Makes it a lot quicker and easier than doing it manually. You can then obtain the ActionScripts by using a SWF decompiler.

 

Are people still using dumbo111's method of stripping the SWFs out of the UPKs manually, one by one and replacing the first 3 bytes with FWS? If you haven't already found a SWF extractor, I could write one if it'd be useful and you aren't already using a tool that does this.

I can have a dig around to try and find it, if someone hasn't already started work on a similar tool :smile:

Link to comment
Share on other sites

  • 1 month later...
  • Recently Browsing   0 members

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