How to localization

  • baizuo
    8th Mar 2012 Member 0 Permalink
    I'm nothing at coding, but I try to build a TPT with languages that my friend can understand.

    I'm using VS2010, it's easy for newbies like me.
    I've successfully build a executable .exe file (71.3 build 137)
    I've got few (maybe silly) questions there:

    0. My powder.exe is only 1.23MB, it must run with other DLLs like SDL.DLL (7 in total). Why? Can I make one that can run itself just like the official release? How?

    1.How to let powder toy show double byte language characters? For example Chinese or Japanese? What can I do with those files under 'font' folder?

  • jacob1
    8th Mar 2012 Developer 0 Permalink
    @baizuo (View Post)
    0. (don't numbers start at 1?)
    I also wish I knew, in my mod I keep having to include them separately, it would be nice to have them included. I haven't searched anywhere to find out how though.

    1.
    It's actually not possible to show Chinese/Japanese characters in the powder toy, the font doesn't include them. You can't add them to the font file either, because there are only about 10-20(?) empty slots in the file. It would take a rewrite of how the font works to be able to support them, and i'm not sure how hard that would be.
    If you want to try and edit the font, you can try these. I think there's something on the wiki about how to use them, but these are slightly different.
  • baizuo
    8th Mar 2012 Member 0 Permalink
    @jacob1 (View Post)
    Thank you for your patient reply!

    The official release might be protected/compressed in kind of executable packers or something I think, like UPX

    Seems it's not possible show those characters with TPT's own system, maybe I should make use of other open-source libraries...
  • vanquish349
    8th Mar 2012 Member 0 Permalink
    simon uses magic to make them not use the dlls
  • baizuo
    8th Mar 2012 Member 0 Permalink
    image

    A small success!
    Modified in Main.c:

    static const char *it_msg_cn
    ....
    //drawtext(vid_buf, 16, 20, it_msg, 255, 255, 255, it>51?255:it*5);
    ttfdrawtext(it_msg_cn);


    Added in graphics.c:

    //drawtext ttf ver.
    TTF_Font *font;
    SDL_Surface *text;
    SDL_Color text_color;
    int ttfdrawtext(const char* textbuf)
    {
    TTF_Init();
    font = TTF_OpenFont("msyh.ttf", 20);
    //text_color = {255, 255, 255};
    text_color.r=255;text_color.g=255;text_color.b=255;
    text = TTF_RenderUTF8_Blended(font,ToUTF8(textbuf),text_color);
    SDL_BlitSurface(text, NULL, sdl_scrn, NULL);
    SDL_Flip(sdl_scrn);
    }


    Maybe I can find a way to replace original text drawing method with SDL_TTF version
    But I need more help on coding, such as how to handle sprintf(); and menu text.
    Is there anyone'd like to help, please PM me! ~
  • abczyx123987
    8th Mar 2012 Member 0 Permalink
    To have it so that Powder Toy doesn't need the dll files, you need to find static library files for each of the libraries it needs...
    I've tried doing that before, with limited success (almost got it, though!).
    (Actually, I've done it using MinGW, but I haven't quite managed to do it with MSVC++...)