PDA

View Full Version : [How to] Editing GFX files



Clonesa
20th Feb 10, 8:04 PM
Don't have a lot of time to go into detail atm. Working on a client's website. Anyway:

http://www.modsrus.com/wiki/doku.php?id=dow2:formats:gfx

Edited ingame_options.gfx:
http://www.modsrus.com/images/dow2_edited_gfx.jpg

What I still want to do after I have time is properly convert an fla I edited back to a game readable gfx. I've been editing the swf file directly, but this isn't nearly as powerful.

I recommend flasm and/or trillix.

part of ingame_options.gfx ActionScript:


function Receive_SetTooltipInfo(instance_name, type, title, description, title_2, description_2)
{
var instance = eval(instance_name);
if (instance == undefined)
{
trace("Receive_SetTooltipInfo: Instance \"" + instance_name + "\" is undefined.");
}
else
{
if (type != undefined)
{
instance.tooltip_type = type;
}
if (title != undefined)
{
instance.tooltip_title = title;
}
if (description != undefined)
{
instance.tooltip_description = description;
}
if (title2 != undefined)
{
instance.tooltip_title_2 = title_2;
}
if (description2 != undefined)
{
instance.tooltip_description_2 = description_2;
}
return true;
}
return false;
}

horusheretic
20th Feb 10, 10:35 PM
and isnt it illegal to modify such .gfx files?

Copernicus
21st Feb 10, 5:22 AM
Modifying these files should not be worse than modifying anything else that ships with the game; however, messing with their proprietary file format may bring us into some kind of legal gray area (if it is gray and not black at all).
Having read what Clonesa wrote makes me believe that Scaleform really should be worried as this shows that their tools are just some well-made editors and nothing really new.

-cope.

Edit: What I thought was special about Scaleform GFX was the ability to link it with C++-code (or basically anything binary); this is something that might ruin our party here as I'm not sure whether such stuff can be accomplished using normal flash-editors.
Edit2: Scaleform GFX seems to use lots of DDS images; can standard SWF handle them as well?
Edit3: Scaleform GFX uses this (http://tulrich.com/textweb.pl?path=geekstuff/gameswf.txt).

Kresjah
21st Feb 10, 9:52 AM
Regarding legal issues, etc., I recommend reading this thread on GFX files editing and DoW1 and legal implications back then.

http://forums.relicnews.com/showthread.php?t=178165

Croaxleigh
21st Feb 10, 11:19 AM
Cope: Scaleform freely admits that they use Flash. The program in question (Scaleform GFX) is essentially a skinning tool; it applies Flash movies as textures on objects. The problem with this is that the software is provided under license to developers and Scaleform has in the past been very protective of their IP (which includes their proprietary .gfx format.) Hell, just to evaluate the software you have to be a representative of a company that might be interested in purchase and have one or more projects in development that could benefit from GFX (and unless they've changed up their demo, the "evaluation" is basically a .gfx viewer and some sample files so that you can see how it works... and that viewer will only work for a set number of days from the point of activation.)

My experiences with this are firsthand, by the way; everything that I've said on the matter comes from working directly with a Scaleform 2.x evaluation kit, talking with a Scaleform representative, and talking with Buggo about it back when she was Relic's community manager.

For the moment, I'm going to remove the link in this thread and weigh in with Grabnutz (since he's the head of this section) on what to do with it. I'm going to leave the thread open for discussion, and do a bit of checking around as well so that perhaps a definitive answer on the .gfx matter can be found once and for all.

Clonesa
21st Feb 10, 12:55 PM
I would have to agree with Cope in the sense that editing these files is no different than editing any other files that ship with the game or injecting DLLs. Remember that SGA and RelicChunky are both proprietary formats. Its all about intention. As long as you aren't trying to make a profit, bypass security for the purpose of warez or trying to harm the game experience for others by hacking, you'll be fine.

I also question how much proprietary shit the format actually contains when the header can simply be renamed to transform it into a flash file. From what I can tell it contains references to external text and images rather than being self contained. This is the only difference I could find from a normal flash movie (although I haven't really dug in). It seems their proprietary technology is the library itself not the file format.

Besides, discussing this is not in any way illegal. Distributing the files could be interpreted as a copyright violation depending on how many jackasses there are at Scaleform, but could so could distributing SGA files and even screenshots of the game.

Croaxleigh
21st Feb 10, 1:17 PM
The main difference is that Relic gives permission for the .sga files and their other formats to be accessed and edited. They have also specifically said in the past to not attempt to edit the .gfx files because of issues with Scaleform. I hope to have a definitive answer on the matter of .gfx editing (at least in regards to this forum) soon so as to eliminate the "mythos of GFX" that has cropped up around this particular file type and Relic's past warnings about attempting to mod it.

Copernicus
21st Feb 10, 1:30 PM
The main point is releasing information about the file format. Nobody will ever stop me editing files on my hard drive but releasing something like a full guide to the GFX format certainly is ... critical.
If I as a private person edit those files without releasing any information on how to do that and choose to release the files there shouldn't be a problem. Well, that's just my opinion and we should definitely wait for the 'official' answer that Croaxleigh is speaking of though.

Clonesa
23rd Feb 10, 1:40 AM
Scaleform takes the images in the swf, exports them and changes them to references in the .gfx. Same with some text and fonts. I'm not very familiar with Flash, but Flash has all of its assets stored internally so Flash editors will not understand these references. Also .gfx files seem to be able to store addition ActionScript in places not understood by most Flash editors.

I think I've found a tricky technique we can use to edit the ActionScript and turn it back into a game readable .gfx file.

DoW2 does not use Scaleform 3.x, probably 2.x.... not sure.

Croaxleigh
23rd Feb 10, 6:01 AM
Well, they were definitely using 2.x in the DC/SS days (somewhere between 2.5 and 2.7 if I recall correctly.) As DoW2 was in development during this time, it would make sense if they used the same version for it since they already had the license for it.

biribe
23rd Feb 10, 1:45 PM
Hi everyone,

I'm part of the Scaleform management team and wanted to follow up on this discussion. We're pleased to see there's interest in modifying the UI and understand your concerns around GFX files.

Just to clarify, Scaleform has no problem with users modifying a games UI that's built with GFx and Flash. We leave it up to the game developer to decide if their content should be modifiable or not. Many developers, especially on the console, restrict users from modifying files for security reasons. Again, we leave it up to the developer.

Scaleform's IP is mainly in the core technology and tools, and not necessary the format, at least not yet :) To date, GFX files are very similar to SWF files except for a few optimizations around resources (images, fonts, and gradients). In the near future, however, we will be making heavier changes to the GFX format, namely around ActionScript byte code and shape data, at which point, the files will look a lot different from SWFs.

Because GFX files are binary and subject to change (just like new versions of SWF files), we do not recommend developers try to reverse engineer the GFX format. Instead, it's much better if the game developer provides the actual FLA files and allows modders to republish the SWFs. If the developer does not want to provide the FLAs, they probably do not want users modifying the content. It's also important for the developer to allow SWF files to be loaded. Scaleform makes that optional.

Again, this is totally up to the developer.

What we do not allow licensed developers to do at this time is distribute the Scaleform SDK (code, tools, samples, docs) or any part inside, including the tool that converts SWFs to GFX files. We understand this makes it harder for modders and are working on a solution.

Our goal is to introduce a MOD Kit later this year that licensed developers can include with their game if they want it moddable. The MOD Kit will help make it easy to customize the UI, however, game developers will need to include the FLAs and associated AS files for completeness.

We monitor various game forums (we're actually huge gamers ourselves) and will certainly inform everyone when the MOD Kit is available. We're also going to open up many parts of the Scaleform SDK to academics and indies later this year, which will help everyone more.

I hope this helps!

Thanks,
-- Brendan

Copernicus
23rd Feb 10, 2:28 PM
Thanks for registering just to post in this thread, biribe; and also thanks for clearing things up.

It's good to know that we're still on the 'good side' and I'm very pleased to hear that you're working on this mod-kit! Until then we shall probably ask Relic for the FLA files or intensify our research about the GFX-format and how to interact with the game.

Clonesa
23rd Feb 10, 3:01 PM
Huzzah! Very cool stuff to hear about the mod kit opening up of scaleform and also the confirmation on some of the poking around I've done.

I wonder if there are debug functions left in the game for rendering SWF files (I imagine this is how they tested their UI stuff).

Croaxleigh
23rd Feb 10, 3:17 PM
See, told you that we'd get to the bottom of this. *smiles* And here I was expecting just a canned ham e-mail response...

Thanks very much for taking an interest in this and clearing things up for us in regards to this matter, Brendan. It's very much appreciated.

Copernicus
23rd Feb 10, 3:21 PM
@Clonesa:
I've got no experience with all this flash stuff at all but you can just replace any GFX file with an SWF file and it will load fine.

Clonesa
23rd Feb 10, 3:23 PM
Reeeaaaallly!? :)

Croaxleigh
23rd Feb 10, 3:30 PM
There was an alternate metamap campaign done in either DC or SS that did something similar... the only problem is that the end result ended up not displaying correctly so it had to be done as a flat map with square territories. That may have had something to do with how the user was implementing it, however.

Copernicus
23rd Feb 10, 3:49 PM
Displaying some sort of flashy colorful boxes was no problem for me (at least it seemed to work flawlessly back then (http://forums.relicnews.com/showthread.php?t=239164)); making the new UI actually useful is what I consider difficult.

Clonesa
23rd Feb 10, 4:01 PM
That would likely be reliant on ActionScript and possibly the scaleform library's functions.

Basically my idea for editing the AS goes as such:

1) Convert .gfx to .swf.

2) Open .swf with Trillix or Sothink and extract the AS.

3) Decompile .swf to .flm (flash bytecode) using flasm.

4) Edit .as as you require and compile into .flm using flasm.

5) Use a text editor to view the diff and copy over changes as needed (may take a bit of asm knowledge).

6) Compile yur altered .flm of the main flash file back into .swf and convert back to .gfx (or not :P)

Khorney
23rd Feb 10, 4:25 PM
crings, jiggings and help me bawb, awesome stuff, can't wait for some custom campaign and multiplyer menu stuff.

using this, woudl it be possible to make the army painter search for badges in a seperate folder? or would that still require -de mode to be active do you reckon? i realise its still early days, but can't blame me for being excited =p

Croaxleigh
23rd Feb 10, 4:45 PM
I guess I could go ahead and move this to the Tutorials forum while I'm at it...

FollowTheGourd
3rd Mar 10, 5:52 PM
Thought I might be able to mention a bit of what I've done to edit SWF files for the UI in another game... I haven't looked at DoW II in ages, but I'm guessing it's pretty much the same. I used to have an account here, but it seems to have vanished without a trace. tl;dr? This probably sounds like an insane hassle, but it's really not that bad actually...

This is a bit of a brain dump instead of a proper HOWTO, but hopefully you find it useful. It's great news to hear that ScaleForm is going to create actual modder and indie resources - before I read this, I kept thinking gloomily about the future of modding games. I saw this through a recent google search and couldn't resist. There seems like there's all this misinformation out there, but people modded the UI for Crysis and I hadn't known Scaleform to take issue with that.

Anyhoo... I used FLASM too at first, but madness lies that way after a while... you can use an open source ActionScript 2.0 compiler, MTASC, to compile your changes, but getting all that set up is a bit of a task but it pays off. Also, MTASC is pickier than the compiler that comes with Flash Professional, but I'm not a Flash guy so I didn't really want to shell out > $600 bucks when there are free, legitimate alternatives.

You can first get the open source FlashDevelop IDE which comes with MTASC and the standard Flash library. If you have the SWFs and the ActionScript *.as files, then what you can do is create an empty ActionScript 2 project, in the project settings turn off "use main entry point" and under the project "injection" tab, point it to the SWF you want to update with your new ActionScript.

You'll also want to update the project classpaths to point to your game's ActionScript library. Just in my experience, there seem to be some properties on some of the standard classes that would normally prevent the script from compiling - but in that case what you can do is modify the so-called intrinsic files to let the compiler know about them. E.g., you can add needed function and var declarations to the intrinsic class interfaces under C:\Program Files\FlashDevelop\Tools\mtasc.

Also if you press Ctrl+J you'll get the type explorer where you can right click on a folder (that you've added to your classpath) and select "convert to intrinsic". So this way you only need to compile the actual *.as file you're making changes to and keep the others around as intrinsics. Using the IDE's SWF injection I mentioned above will make it so you don't have to worry about recompiling everything.

You'll probably get a bunch of warnings like "... needs the class <Whatever> which was not compiled" but that's just MTASC not liking how some class names are used outside of what you're compiling like in Flash registerObject calls.

Now the bigger issue is that MTASC is pickier about things than Adobe's compiler. You'll often have to write this.varname or ClassName.varname instead of just varname, and MTASC doesn't like named *nested* functions. So you'll sometimes have to convert function FooBar() { ... } into something like "this.FooBar = function() { };" or "_root.FooBar = function() { };". But also make sure that the variable for the function is a class member and not function-local or it'll just be a register or randomly named variable when compiled, or just not be available in the scope you need it to be.

MTASC is also pickier about the scope of local variables. It may sound weird, but in ActionScript 2.0 a function-local variable is defined for the scope of the function - it doesn't matter if declared in an if-statement or in braces. But the MTASC compiler will enforce that you define the variable in a "proper" scope, so you may need to move where it's declared if you want things to compile. E.g., "if (foo) { var tmp = 1; } else { tmp = 2; }" won't fly with MTASC.

Also it seems like MTASC doesn't like the global function "Array", but doesn't mind if you use the constructor instead. E.g., I've had issues with var ar = Array(...), but var ar = new Array(...) works or you could use the square-bracket notation instead.

Some other stuff... if you want multiple projects, just create the projects all in the same dir (but create folders if you want to separate stuff and adjust the project classpath accordingly).
Also, don't necessarily set "Always compile" for the *.as file or you might run into duplicate definition errors - things should get drawn in as needed, but I think you need to set it for classes in the original SWF you wish to update. That might be a little hit and miss at first, but you can always check to make sure your changes got in.

Also, looking at the output in FLASM, MTASC might not generate the most blazing bytecode ever - but neither does Adobe's compiler. Just some things I noticed is that Adobe's will use function argument registers more than MTASC seems to... e.g., "push '_root'; getVariable" vs just a r:_root register.

One last thing... you may want to organize your *.as files so you combine the ones that are commonly used across different SWF files so you're not always having to edit multiple copies of SomeClass.as for each SWF that uses it.

Also, I noticed a bug in sothink that I emailed them about: doubles are formatted as single-precision floating point. But some other tools, e.g., flare, get the value correctly. You might want to search your *.as files for "E-" and "E+" to look for these misformatted values if you're using it.

EDIT: Here's a bug with Trillix I noticed, but they said it'll be fixed soon: if you have "var foo = this" and if a register is used for 'foo', then Trillix doesn't properly initialize the register... but instead just uses 'this' everywhere else. This causes problems if you needed that variable to choose between using 'this' and possibly another object. E.g., "var obj = this; if (something) { obj = someOtherObject; } someFunc.doIt(obj);" only works as long as "obj" is stored as a variable and not a register, which is up to the original compiler.

dnd
19th Mar 10, 10:50 AM
i don't know flash at all...how hard is it to move UI elements around? specifically, in the inventory skills screen, if i want to move a button, is that possible?

etherdragn
19th Mar 10, 12:16 PM
My two cents on what I learned when modding the DC meta-map. The same rules apply to any UI screen I believe however.

The artwork is all in the sga file. The GFX/SWF file acts like an rollover/overlay layer that controls the artwork elements. So for example a territory on a campaign map and the highlight border are both 3D objects. When you mouseover the GFX file highlights the territory and renders the border visible. My inability to extract the swf from the gfx file is why I couldn't arrange it how I wanted. I can confirm that a .swf file will load and work in the interface instead of a gfx. I believe that if You can get that swf file the at the very least, rearranging and replacing visuals in the UI is unlimited.

FollowTheGourd
20th Mar 10, 8:14 PM
i don't know flash at all...how hard is it to move UI elements around? specifically, in the inventory skills screen, if i want to move a button, is that possible?

While probably as easy as just changing the _x and _y properties, there's probably some more stuff you'd need to learn to do things without relying on a fixed screen resolution.

Anyway, you might want to look into ActionScript 2.0 (the UI files are probably Flash 8 extended a little by GFx stuff):

http://download.macromedia.com/pub/documentation/en/flash/fl8/fl8_learning_as2.pdf

http://livedocs.adobe.com/flash/9.0/main/flash_as2_learning.pdf

You can do a lot of graphical stuff with just scripting in Flash. But not having looked inside DoW II's UI, I can only speak in vagaries about it.

kornelord
10th May 10, 8:09 AM
I try to change for my mod the hero_selection_panel.gfx and main_menu.gfx in order to replace "multiplayer" by "space hulk" and race names by "terminators" etc...
But as I can't replace the words in the ucs file, i have opened these files with hex-editor and y juste change:

$9032442 by $9600000

It's work for all the races except eldars, because there is one number less: $810000, and when I replace by $9600000, the menu does not appear (I think it's this).
So I have converted gfx into fla file, and when I open it, I see this (I use Macromedia Flash 8.0 and I have never made flash files...):


http://zepload.com/images/1273601033_hero_selection_panel.png


Finally, my question is: where can I edit the links ($810000) to UCS file ?

Promythyus
10th May 10, 11:56 PM
I think you're adding an extra character, which might break it (an extra 0 on your string opposed to relic's)?

Edit: Oh wait, you mentioned that.

Maybe you could edit it in the actionscript, unsure though...

Croaxleigh
12th May 10, 9:01 PM
the UI files are probably Flash 8 extended a little by GFx stuff
I know that with GFX 1.x, Flash 6 was used. Not sure about GFX 2.x, or what version Relic used for DoW2. (DC and SS were almost certainly done using 1.x, because 2.0 came out after DC.)

Darkbladecr
15th May 10, 7:06 AM
you may need Action script 3 or the new flash players, thus CS3 or CS4.

FollowTheGourd
16th May 10, 12:19 PM
If you want a quick way of checking, open the gfx/swf in a hex editor and look at the fourth byte (i.e., offset 3). That's the Flash version in the header.

Khorney
7th Nov 10, 12:11 PM
did you ever make any progress with this clonesa? i've just got round to taking alook at it and just wondering whether we've got any more to work on.

essentially what i'm looking todo is like what the the FoK guys were doing with the .screen files in DoW1 and extending the UI by adding more options and buttons. i've already found assets in the game which point to an earlier build where there were 3 tabs on the HQ for different things - units, tech and wargear, similar to the way in DoW1 and CoH the HQ is able to do global researches and stuff. i'll see if i can restore this and open up some more options, but any hints you may have would be greatly appreciated =)

EDIT: trying to open building_tech_panel.gfx.

i've followed the tut, changed the first 3 bytes, edited the extensions to swf, tried to open with trillix decompiler but no dice, just says its corrupted =/

Gabriel Gorgutz
28th Dec 10, 11:03 AM
Did Scaleform ever release that MOD Kit? Did we ever get anywhere with this project?

I want my 4th commander and additional race selections for Khorne's sake!

Shuma
28th Dec 10, 12:00 PM
No.

Khorney
28th Dec 10, 7:00 PM
if anyone was interested, i fixed the corruption issues and managed to extract, i believe the extension had to be FWS instead or something. i can check if someone wants to know

didn't get much further though

Gabriel Gorgutz
29th Dec 10, 9:53 AM
I am interested. Would you care to elaborate on what is possible to do with it, now that you've managed to fix and extract?

Khorney
29th Dec 10, 10:57 AM
well, it has a bunch of lists of the assets and other things too, like where icons go and such, but its all written in actionscript or something so i wasn't able to make much sense of it.

Clonesa would be a much better person to ask if you actually want to achieve something =P we just gave up and used SCAR and hacky workarounds instead, but if we were bale to add buttons and things that would make things alot easier.

Khorney
29th Dec 10, 10:58 AM
well, it has a bunch of lists of the assets and other things too, like where icons go and such, but its all written in actionscript or something so i wasn't able to make much sense of it.

Clonesa would be a much better person to ask if you actually want to achieve something =P we just gave up and used SCAR and hacky workarounds instead, but if we were bale to add buttons and things that would make things alot easier.

Gabriel Gorgutz
29th Jul 12, 8:59 PM
Is there a contact email for biribe? Seems he only posted once, and hasn't been active on here since then, so I doubt that pm'ing him would do any good.