Page 1 of 4

My First Patch - Face Customizer

Posted: 04 May 2006 18:07
by BoominGranny
Hi Everyone,

This is my first - and im sure far from perfect patch.
This allows you to customize your face (ie change your eyes, chin, gender all seperate from one another)
Let me know what you think.

7/may/06:
Added Set Default button - that saves the current face as your default for new games
Moved Randomize Face - you now randomize your face by clicking on the picture!

10/may/06:
belugas kindly adopted my patch to meet the OTTD coding convention! thx

Posted: 04 May 2006 18:26
by MeusH
Looks promising. However I miss the "Generate face" randomizer button

Posted: 04 May 2006 18:30
by BoominGranny
True! I kinda ran outa room for more buttons...

Posted: 04 May 2006 18:31
by gigajum
yeah looks quite cool :)
BoominGranny wrote:True! I kinda ran outa room for more buttons...
Then make room for them :)

Posted: 04 May 2006 19:34
by jez
Looks great :-) The 2 things I'd say are, as before, the random generator button should stay in the same way that it works now, and a Save/Load face would be great.

Posted: 04 May 2006 21:14
by Bjarni
BoominGranny wrote:True! I kinda ran outa room for more buttons...
then make the window bigger :wink:

Posted: 04 May 2006 21:49
by Born Acorn
A button the width of the window beneath the face may be just fine.

Posted: 04 May 2006 22:07
by Bjarni
actually I'm not sure I like your window (now is the time to speak your mind :wink: )
I think it would be better if it could move though the list of stuff using the same style as in the news settings window. Also, as mentioned before, the old random face is missing. To make the arrow buttons and stuff, you need to make the window larger, which is ok.

I think it's a nice window for a first try. The window stuff in OpenTTD is not the nicest you can find. I can remember when I made my first window. It took days, but that was also because it was the autoreplace window, so I had to add support for two vertical scrollbars and some stuff regarding the pulldown menu. (tip: always start with something simpler than that)

Posted: 05 May 2006 05:40
by BoominGranny
Good points Bjarni, i've since added the Randomizer back into the window.
I know what you mean by in the message window - thouse left/right buttons? <= => they would work well. At least now you have some control over your face. The problem i have is that the face structure is all over the place so to implement buttons at all i had to set some bits randomly (thats what i did for the eyes) and to set the skin colour i just toggle 3 bits between 0 and 1 to get the skin colour to change, but without the exact structure of how the face works this is the best i (As a rookie C developer) can come up with.

structure as ive figured so far:
32 bits

123=don't seem to do anything
45=chin
6789=eyes/eye brows
10,11,12,13,14,15=mouth/nose
16,17,18,19=hair (also effects skin sometimes!)
20,21,22=clothes/eye colour
23,24,25,26,27=clothes (also effects skin sometimes!)
28,29,30=glasses
31=gender

Posted: 05 May 2006 08:02
by bobingabout
tie is counted seperate from jacket, you have eyes, and eye colour(remap), i think you also have hair colour(remap)
i can't remember everything, and i can't check because i am at work, and everything i used to make my avatar(which gave me a really good look at the faces sprites) is at home.

basicly saying make the eyes and the eye colour, and the hair and hair colour seperate, also, if possable, things like the hair, it kinda looks stupid to have some parts 1 colour, and other parts another, any chance on getting it to make all hair the same colour?

Posted: 05 May 2006 13:39
by PouncingAnt
Your work seems very promising so far!

Ganbatte! (go for it)

Posted: 05 May 2006 14:41
by Archonix
bobingabout wrote: basicly saying make the eyes and the eye colour, and the hair and hair colour seperate, also, if possable, things like the hair, it kinda looks stupid to have some parts 1 colour, and other parts another, any chance on getting it to make all hair the same colour?
It's realistic though. I have ruddy hair and yet a blonde beard*. My dad had black hair and a ginger mustache. Genetics... fun. :)

*Actually it's more complicated than that. I have a blond streak that runs across the top of my scalp, which splits in two and runs down both sides of my mouth. If I had hair over my entire face it'd run down to around the bridge of my nose and then split there, as far as I can tell.

Posted: 05 May 2006 16:17
by scrooge
Hehe, this is the first thing I remember thinking should be fixed, some seven years ago :)
Great work :D

Posted: 05 May 2006 23:10
by BoominGranny
jez wrote:Looks great The 2 things I'd say are, as before, the random generator button should stay in the same way that it works now, and a Save/Load face would be great.
done! :wink:
bobingabout wrote:tie is counted seperate from jacket, you have eyes, and eye colour(remap), i think you also have hair colour(remap)
i can't remember everything, and i can't check because i am at work, and everything i used to make my avatar(which gave me a really good look at the faces sprites) is at home.
are you able to find this out for me when you get a chance and post it here? would be very helpful!

Posted: 08 May 2006 10:47
by bobingabout
what i found out was simply by looking at the grf file decoded by GRFCodec. you'll probably be able to find out more by reading the code, but the only problem there is if its not well documented, knowing exactly what it does.

next time i'm on my laptop, I'll try and get a copy of the faces section uploaded for you to look at.

reason i know eyes and hair are remapable is, all eyes are (remap) blue, and all hair is black(IIRC). therefore, it shouldn't be too hard to make sure when it creates hair, eyebrows and facial hair, that it creates them all of the same colour.

also, you should be able to fudge in more tie colours by using the blue tie(like in my avatar) as a remapable version.

Posted: 08 May 2006 18:17
by MeusH
BoominGranny, I noticed your changes just because now there is a green background behind the face, but please write a post about that so everyone may notice it easily

Posted: 09 May 2006 00:39
by BoominGranny
Changes:
7/may/06:
Added Set Default button - that saves the current face as your default for new games
Moved Randomize Face - you now randomize your face by clicking on the picture!
(please use the diff on my first post - it has been updated with these changes)


MeusH - sure thing :) i'll remember for next time! i just didn't want to "SPAM" people about my patch...

bobingabout - when im at home i will try and have a look at how this colour mapping works in the file that draws the face... it was really confusing code the first time i looked at it... then i can perhaps redo the face drawing code and then have the face number so it includes the colours of face objects and makes a bit more sence (i will make the skin tone have its own bit - infact maybe i will make it 3 or 4 bits so there can be a few skin tones in there....)

Posted: 09 May 2006 10:03
by jez
BoominGranny: The set default thing is good, but even better would be a dialog letting you save to a certain filename and load from a certain filename, much like the save/load game dialogs. Would it be possible to do that?

Posted: 09 May 2006 12:40
by BoominGranny
if you want to be able to save it for good:

open your openttd.cfg (after you've hit set with my patch)

look at the line near the very top under [misc]:

player_face = 594158407

copy the number and that is your players unique face value.

Perhaps i could make the screen so it shows it to you and allows you to enter it? It would be overkill imo to make a save/load just for a one number - its already saved in the savegame...

Posted: 09 May 2006 15:09
by bobingabout
well, the save/load i would want is press save, and it brings up a save face window, then you can enter a name, like for me Tash, then when i play again, instead of creating a new face, just press load and load the face Tash...

however, the unique number thing isn't too hard to do either.

about the face, it'll probably be easier for you to extract the files yourself, download GRFCodec
http://www.ttdpatch.net/grfcodec/
follow the instructions and use the command grfcodec -e trg1.grf, It'll create a PCX and somwhere in there will be the faces, just look for them. Problem is windows XP doesn't open PCX files by default, so, you might want to convert them using infanview. you should be able to come up with something good,

and maybe with the help of peter, or, someone else, add a NewGRF support for new face features? also, the ability to load a PNG file for the face is a good idea, you could have your freaky avatar ingame :P