How to Add Characters and Icons to the Font

From The Powder Toy
Revision as of 21:53, 16 August 2013 by wolfy1339 (talk | contribs) (Enter a short summary [alt-b])
Jump to: navigation, search

Defines for the menu sections are located in simulation/SimulationData.h. The names and icons are in LoadMenus() in simulation/SimulationData.cpp. These are what you need to edit to create a new menu.

If you downloaded the legacy source from Github, then you'll find a folder called font. If you look inside it, you'll see that there is packer.c, unpacker.c and editor.c. If you don't see it, then you either downloaded the C++ source code, or you deleted it somehow. If this is the case, then just download the legacy source code again from here: [1]. The instructions for Windows and Linux are different, so be sure to follow the correct instructions.

Windows

0) You will need GNU Make for the next step. You can download GNU Make from here: [2]

1) Get a copy of the old c source, and of the new source. The old source is in the legacy branch on github. Maybe the font editor will eventually be added to the new source.

2) Copy font.h from /data in the new source and and paste it into /font from the old source

3) Navigate into /font, and open a Command Prompt here. Compile the font editor tools using the following commands:

make unpacker.exe packer.exe editor.exe

Alternatively, just download a premade one here, with the added feature of showing the hex id as you edit.

4) In the same terminal run the following command to create a font.bin file the editor can read:

unpacker.exe

5) Run the editor from the terminal, and then use the "+" and "-" keys to go the end and find an empty character. Empty characters look like thermometers, although be careful not to confuse it with the actual thermometer. If it is just erase it via right clicking and left clicking in the drawing field. It will take a lot of pressing "+" to get to the end. Now draw your character. Look in the stdout.txt file in the same directory, and the last number in the file is the char id that corresponds to whatever icon you drew. If you used the precompiled one, you should have seen this number when editing instead.

6) Close down the editor, delete the font.h, and run:

packer.exe > font.h

7) Copy the new font.h into /data from the new source, replacing the old one.

8) For your new menu, replace FF with the last number from the stdout.txt file in the font directory.

{"\xFF", "new menu ftw", 0, 1},

9) Recompile The Powder Toy and you should be ready to go.

Linux

0) This guide was written for the old tpt, font.h is in /data in the new source, not /includes, but the font editor is only in /font from the old source. Things won't work correctly, just copy font.h manually into /font and start from the end of step 2. The old source is in the legacy branch on github.

1) Open a Terminal and cd to the /font directory that's included with the Git source code.

2) Enter the following commands to copy font.h from includes to font and compile the font editor tools:

cp ../includes/font.h .
make unpacker packer editor

3) In the same terminal run the following command to create a font.bin file the editor can read:

./unpacker > output1.txt

5) Run the editor from the terminal and then use the "+" and "-" keys to go the end and find an empty character. Empty characters look like thermometers, although be careful not to confuse it with the actual thermometer. If it is just erase it via right clicking and left clicking in the drawing field. It will take a lot of pressing "+" to get to the end. Now draw your character. and look in output1.txt, and the last number there is the char id and it corresponds to what icon you drew.

6) close down the editor and run:

rm ./font.h
./packer > font.h
cp -f ./font.h ../includes

8) for your new menu, replace FF with the last number from the output1.txt file in the font directory.

{"\xFF", "new menu ftw", 0, 1},

9) Recompile The Powder Toy and you should be ready to go.