Galgame引擎编写,实现对话文本显示

class cTalk {
public:
    cTalk();
    ~cTalk();

     void     Init();
     void     Shutdown();

     void     SetSpeed(int speed);
     void     ConfigFont(const cArgs &parms);
     void     ConfigStyle(const cArgs &parms);
    
     void     SkipText();
     bool     IsEmpty() const;

    void     AddText(const char *text, int addTime);
    void     AddText2(const char *text, int addTime);
    void     Draw(int time);
private:
    bool     initialized;
    // draw info
    srfSheet_t     charSheet;
    int         speed;
    int         drawX;
    int         drawY;
    int         c_lineChars;
    bool         showBold;
    bool         showEdge;
    bool         showShadow;
    bool         showItalic;
    int         boldValue;
    ALLEGRO_COLOR    edgeColor;
    ALLEGRO_COLOR    shadowColor;
    ALLEGRO_COLOR    charColor;
    int         textLength;
    uint16_t     *textPtr;
    int         totalChars;

    // config info
    int     xpos, ypos;
    int     linePitch;
    int     lineChars;
    int     numLines;
    int     charSize;
    int     allowShowChars;

    // text buffer info
    uint16_t         *textBuffer;
    int           textBufferLength;
    ALLEGRO_BITMAP    *textBufferImage;
    int           pixelSize;
    byte         *textImageData;    // locked

    // freetype
    FT_Library       ftLibrary;
    FT_Face         ftFace;
    FT_GlyphSlot      ftGlyphSlot;
    cStr           faceName;

    void     InitFreeType();
    void     DoneFreeType();
    void     CreateTextBimapBuffer();
    void     DrawCharToBitmap(byte *buffer, const int offset_x, const int offset_y, const int bufferPitch);
};

posted @ 2013-10-20 21:47  freemill  阅读(726)  评论(0)    收藏  举报