示例#1
0
文件: themer.c 项目: Mojofreem/flub
void tsMenuDraw(tsMenuState_t *state) {
    int k;
    int y = state->y;
    int x = state->x;

    glLoadIdentity();
    glEnable(GL_BLEND);
    for(k = 0; (state->menu[k].name != NULL); k++) {
        if(state->pos == (k)) {
            glColor3f(0.5, 1.0, 0.5);
        } else {
            glColor3f(0.2, 0.2, 0.2);
        }
        fontPos(x, y);
        fontBlitStr(state->font, state->menu[k].name);
        y += fontGetHeight(state->font) + 2;
    }
}
示例#2
0
文件: test.c 项目: Mojofreem/flub
void doFpsCounter( void )
{
    static Uint32 last = 0;
    static int frames = 0;
    static int fps = 0;
    Uint32 now;

    if(last == 0) {
        last = SDL_GetTicks();
    }
    now = SDL_GetTicks();

    frames++;

    if((now - last) >= 1000) {
        fps = frames;
        frames = 0;
        last += 1000;
    }

    fontPos(620, 5);
    glColor3f(0.5, 0.5, 1.0);
    fontBlitInt(fpsFont, fps);
}
示例#3
0
文件: test.c 项目: Mojofreem/flub
int main(int argc, char *argv[]) {
    eCmdLineStatus_t status;
    int keepGoing = 1;
    Uint32 lastTick;
    Uint32 current;
    Uint32 elapsed;
    Uint32 counter = 0;
    //GLuint img, fid;
    int iw, ih, fw, fh;
    const texture_t *dlg;
    const texture_t *misc;
    flubSlice_t *slice;
    //flubSlice_t *sliceTest;
    font_t *fnt;
    int eventCount;
    int pos;
    int w;
    gfxMeshObj_t *mesh;
    gfxMeshObj_t *fontMesh;
    sound_t *sound;
    char cwdbuf[1024];
    font_t *pfont;

    const texture_t *tex_misc;
    const texture_t *tex_dlg;
    const texture_t *tex_tiles;
    flubSlice_t *dlg_title;
    flubSlice_t *dlg_body;
    gfxMeshObj_t *meshFont;
    gfxMeshObj_t *meshChain;
    gfxMeshObj_t *meshDlg;
    gfxMeshObj_t *meshTiles;
    gfxMeshObj_t *meshMisc;
    gfxEffect_t *effect;

    int tileMap[127];
    char *scene[3] = {
            "#######\n#UIIIO#\n#JKKKL#\n#WWWWW#\n#######\n#######\n#######",
            "       \n       \n       \n  w P  \n    F  \nCCCCVCC\n       ",
            "       \n       \n       \n    D  \n       \n       \n       ",
    };

    tileMap['#'] = 0;
    tileMap['U'] = 23;
    tileMap['I'] = 7;
    tileMap['O'] = 24;
    tileMap['J'] = 21;
    tileMap['K'] = 5;
    tileMap['L'] = 22;
    tileMap['W'] = 16;
    tileMap['w'] = 32;
    tileMap['P'] = 36;
    tileMap['D'] = 37;
    tileMap['F'] = 33;
    tileMap['C'] = 34;
    tileMap['V'] = 19;

    flubSprite_t *sprites;

    //log_message = physfs_log;

    if(!appInit(argc, argv)) {
        return 1;
    }

    // Register command line params and config vars

#if 0
    infof("### Adding font ###################################");
    if(!flubFontLoad("flub/font/times.12.stbfont")) {
        errorf("Unable to load times font.");
    }
    if(!flubFontLoad("flub/font/courier.12.stbfont")) {
        errorf("Unable to load courier font.");
    }
#endif

    status = appStart(NULL);
    if(status != eCMDLINE_OK) {
        return ((status == eCMDLINE_EXIT_SUCCESS) ? 0 : 1);
    }

    //infof("Working dir: [%s]", getcwd(cwdbuf, sizeof(cwdbuf)));


    //enumDir("");
    //enumDir("assets");

    fnt = fontGet("consolas", 12, 0);
    if(fnt == NULL) {
        infof("Unable to get font");
        return 1;
    }
    fpsFont = fnt;
    //fid = fontGetGLImage(fnt, &fw, &fh);
    //fid = fontGetGLTexture(fnt);

    //info("Font loaded, targeting images.");

    //infof("Working dir: [%s]", getcwd(cwdbuf, sizeof(cwdbuf)));

    misc = texmgrGet("flub-keycap-misc");
    dlg = texmgrLoad( "work/dungeondlg2.gif", "dungeondlg2", GL_NEAREST, GL_NEAREST, 1, 255, 0, 255);
    //img = texmgrQuickLoad( "assets/misc/test_img.gif", GL_NEAREST, GL_NEAREST, 0, 0, 0, 0, &iw, &ih);
    footex = dlg;

    slice = gfxSliceCreate(dlg, 0, 0, 18, 22, 74, 69, 126, 106);
    //sliceTest = gfxSliceCreate(dlg, 145, 6, 150, 11, 182, 27, 186, 31);
    //infof("Texture id for flubmisc1 is %d", misc->id);

    //vboTestInit(misc->id);

    sound = audioSoundGet("resources/sounds/menumove.wav");

    mesh = gfxMeshCreate(MESH_QUAD_SIZE(40), 0, misc);
    //infof("The mesh is 0x%p", mesh);
    gfxTexMeshBlit(mesh, misc, 20, 20);
    //gfxMeshBlit(mesh, 220, 20);
    //gfxMeshBlit(mesh, 420, 20);
    //gfxMeshBlit(mesh, 20, 220);
    //gfxMeshBlit(mesh, 220, 220);
    //gfxMeshBlit(mesh, 420, 220);

    //infof("Vertices: %d", mesh->pos);

    fontMesh = gfxMeshCreate(256 * 2, GFX_MESH_FLAG_COLOR, NULL);
    gfxMeshTextureAssign(fontMesh, fontTextureGet(fnt));

    fontPos(150, 240);
    fontBlitCMesh(fontMesh, fnt, 'F');
    fontBlitCMesh(fontMesh, fnt, 'o');
    fontBlitCMesh(fontMesh, fnt, 'o');
    fontPos(150, 260);
    fontBlitStrMesh(fontMesh, fnt, "fontBlitStrMesh();");
    fontPos(150, 280);
    fontBlitStrNMesh(fontMesh, fnt, "fontBlitStrNMesh(); is too long", 19);
    fontPos(150, 300);
    fontBlitStrfMesh(fontMesh, fnt, "font%sStrf();", "Blit");
    fontPos(150, 320);
    fontBlitQCStrMesh(fontMesh, fnt, "font^2Blit^1QC^wStr();");
    fontPos(150, 340);
    fontBlitIntMesh(fontMesh, fnt, 12345);
    fontPos(150, 360);
    fontBlitFloatMesh(fontMesh, fnt, 12.345, 3);

    // Blitter test resources
    tex_misc = texmgrGet("flub-keycap-misc");
    tex_dlg = texmgrGet("dungeondlg2");
    tex_tiles = texmgrLoad( "work/tiletest.gif", "testtiles", GL_NEAREST, GL_NEAREST, 1, 255, 0, 255);

    sprites = gfxSpriteCreate(tex_tiles, 16, 16);

    dlg_title = gfxSliceCreate(tex_misc, 41, 17, 43, 19, 60, 26, 62, 28);
    dlg_body = gfxSliceCreate(tex_misc, 41, 29, 43, 30, 60, 40, 62, 42);

    // Create meshes for font, flubmisc, and flubsimplegui
    meshFont = gfxMeshCreate(MESH_QUAD_SIZE(100), GFX_MESH_FLAG_COLOR, fontTextureGet(fnt));
    meshDlg = gfxMeshCreate(MESH_QUAD_SIZE(200), GFX_MESH_FLAG_COLOR, tex_dlg);
    meshTiles = gfxMeshCreate(MESH_QUAD_SIZE(400), 0, tex_tiles);
    meshMisc = gfxMeshCreate(MESH_QUAD_SIZE(400), GFX_MESH_FLAG_COLOR, tex_misc);

    meshChain = meshFont;
    gfxMeshAppendToChain(meshChain, meshMisc);
    gfxMeshAppendToChain(meshChain, meshDlg);
    gfxMeshAppendToChain(meshChain, meshTiles);

    // Excercise mesh blitters
    gfxTexMeshBlit(meshChain, tex_misc, 400, 5);
    gfxTexMeshBlitSub(meshChain, tex_dlg, 145, 6, 186, 31, 400, 200, 450, 250);
    gfxTexMeshTile(meshChain, tex_dlg, 150, 11, 180, 25, 400, 260, 500, 400);
    blitMeshSpriteMap(meshChain, sprites, 200, 20, tileMap, scene, 3);
    gfxSpriteMeshBlitResize(meshChain, sprites, 36, 0, 0, 63, 63);


    gfxSliceMeshBlit(meshChain, dlg_title, 200, 300, 320, 315);
    gfxSliceMeshBlit(meshChain, dlg_body, 200, 316, 320, 440);
    gfxKeycapMeshBlit(meshChain, fnt, "META_WINDOWS", 200, 260, NULL, NULL);
    gfxKeycapMeshBlit(meshChain, fnt, "Ctrl", 240, 260, NULL, NULL);
    gfxKeycapMeshBlit(meshChain, fnt, "PgDn", 280, 260, NULL, NULL);

    effectMesh = meshDlg;
    effectStart = meshDlg->pos;
    gfxSliceMeshBlit(meshDlg, slice, 10, 50, 150, 190);
    effectStop = meshDlg->pos;

    effect = gfxEffectFade(effectMesh, effectStart, effectStop, 0.0, 1.0, 2000);
    effect->completed = fadeinCompleted;
    gfxEffectRegister(effect);


    if((!flubFontLoad("pirulen.30.stbfont")) ||
       ((pfont = fontGet("pirulen", 30, 0)) == NULL)) {
        fatal("Unable to load pirulen font");
        return 0;
    }

    inputActionBind("KEY_BACKQUOTE", "showconsole");
    //glBlendFunc(GL_ONE, GL_ZERO);
    //glDisable(GL_BLEND);
    //glEnable(GL_TEXTURE_2D);

    info("### Loading theme ###############");
    flubGuiThemeLoad("assets/data/flub-basic.theme");
    info("### Done loading theme ##########");

    lastTick = SDL_GetTicks();
    while (keepGoing) {
        current = SDL_GetTicks();
        elapsed = current - lastTick;
        lastTick = current;
        counter += elapsed;
        if(counter >= 2500) {
            if(sound != NULL) {
                //Mix_PlayChannel(0, sound, 0);
            }
            counter -= 2500;
        }
        // Process every event
        SDL_Event ev;
        // wait no more than 15ms to avoid exceeding 67 fps
        //while (SDL_WaitEventTimeout(&ev, 15)) {
        eventCount = 0;
        while(inputPollEvent(&ev)) {
            eventCount++;
            switch (ev.type) {
                case SDL_QUIT:
                    keepGoing = 0;
                    break;
                case SDL_TEXTINPUT:
                    break;
                case SDL_KEYUP:
                    switch (ev.key.keysym.sym) {
                        case SDLK_HOME:
                            break;
                        case SDLK_END:
                            break;
                        case SDLK_PAGEUP:
                            break;
                        case SDLK_PAGEDOWN:
                            break;
                        case SDLK_UP:
                        case SDLK_e:
                            break;
                        case SDLK_DOWN:
                        case SDLK_d:
                            break;
                        case SDLK_w:
                            break;
                        case SDLK_r:
                            break;
                        case SDLK_LEFT:
                        case SDLK_s:
                            break;
                        case SDLK_RIGHT:
                        case SDLK_f:
                            break;
                        case SDLK_ESCAPE:
                            keepGoing = 0;
                            break;
                        case SDLK_BACKQUOTE:
                            break;
    					case SDLK_RETURN:
    						break;
                    }
                    break;
                case SDL_KEYDOWN:
                    switch (ev.key.keysym.sym) {
                        case SDLK_HOME:
                            videoScreenshot("screenshot");
                            break;
                        case SDLK_END:
                            break;
                        case SDLK_PAGEUP:
                            break;
                        case SDLK_PAGEDOWN:
                            break;
                        case SDLK_UP:
                        case SDLK_e:
                            break;
                        case SDLK_DOWN:
                        case SDLK_d:
                            break;
                        case SDLK_w:
                            break;
                        case SDLK_r:
                            break;
                        case SDLK_LEFT:
                        case SDLK_s:
                            break;
                        case SDLK_RIGHT:
                        case SDLK_f:
                            break;
                        case SDLK_ESCAPE:
                            keepGoing = 0;
                            break;
                        case SDLK_BACKQUOTE:
                            /*
                            if(consoleVisible()) {
                                consoleShow(0);
                            } else {
                                consoleShow(1);
                            }
                            */
                            break;
                    }
                    break;
                case SDL_CONTROLLERBUTTONDOWN:
                    break;
                case SDL_CONTROLLERBUTTONUP:
                    break;
                case SDL_CONTROLLERAXISMOTION:
                    break;
            }
            if(eventCount >= BULK_EVENT_LIMIT) {
                break;
            }
        }
        videoClear();

        //glDisable(GL_DEPTH_TEST);
        //glDisable(GL_CULL_FACE);
        //glDisable(GL_BLEND);

        videoPushGLState();
        videoOrthoMode();

        glLoadIdentity();
        glColor3f(1.0, 1.0, 1.0);
        //glEnable(GL_BLEND);
        //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

        //fontSetColor(1.0, 1.0, 1.0);
        //gfxBlitKeyStr(fnt, "Use [META_UP] and [META_DOWN] to select a menu option.", 10, 440, NULL, NULL);
        //gfxBlitKeyStr(fnt, "Use [~] to open the console.", 10, 460, NULL, NULL);


        glLoadIdentity();

        //gfxTexTile(tex_dlg, 150, 11, 180, 25, 200, 260, 298, 400);
        //gfxTexBlit(tex_misc, 200, 5);
        //gfxTexBlitSub(tex_misc, 0, 0, 127, 127, 0, 5, 127, 132);

        //gfxMeshRender(fontMesh);

        //gfxSliceBlit(dlg_title, 200, 300, 320, 315);
        //gfxSliceBlit(dlg_body, 200, 316, 320, 440);
        //gfxSliceBlit(slice, 10, 50, 150, 190);


        glLoadIdentity();

        //fontMode();
        //fontPos(10, 200);
        //fontBlitStr(pfont, "This Is A Test! Werd, yo!");
        //glLoadIdentity();
        //gfxTexBlit(fontTextureGet(pfont), 10, 200);

        //videoPushGLState();
        //videoOrthoMode();

        //vboTestRender();

        //gfxGLBlit(img, 380, 10, 380 + iw, 10 + ih);


        //fontSetColor(0.5, 1.0, 0.5);
        //fontSetColor(1.0, 1.0, 1.0);
        //gfxGLBlit(fid, 5, 5, fw, fh);

        //gfxTexBlit(misc, 25, 120);
        //gfxGLBlit(misc->id, 5, 100, 5 + misc->width, 100 + misc->height);


        gfxMeshRender(meshChain);

        //videoPopGLState();

        if(!appUpdate(current)) {
            keepGoing = 0;
        }
    }

    gfxMeshDestroy(mesh);

    return 0;
}
示例#4
0
文件: themer.c 项目: Mojofreem/flub
int main(int argc, char *argv[]) {
    font_t *font;
    const texture_t *texture;
    const texture_t *misc;
    flubSlice_t *dlg_body;
    flubSlice_t *dlg_title;
    eCmdLineStatus_t status;
    int keepGoing = 1;
    Uint32 lastTick;
    Uint32 current;
    Uint32 elapsed;
    SDL_Event ev;
    int eventCount;
    FILE *fp;
    eThemerState_t state = eThemerStateType;
    tsMenuState_t menuState;
    tsMenuEntry_t menuEntries[] = {
            {"Bitmap", eCompBitmap},
            {"Animation", eCompAnimation},
            {"Tile", eCompTile},
            {"Slice", eCompSlice},
            {NULL, 0},
        };
    int pos = 0;
    int curx = 0;
    int cury = 0;
    compState_t parentComp, *comp, *walk;
    flubSimpleEdit_t *edit;
    const char *path = "flub-theme.txt";
    appCmdlineCtx_t appCtx = {.path = NULL};

    if(!appInit(argc, argv)) {
        return 1;
    }

    // Register command line params and config vars

    if((status = appStart(&appCtx)) != eCMDLINE_OK) {
        return ((status == eCMDLINE_EXIT_SUCCESS) ? 0 : 1);
    }
    if(appCtx.path != NULL) {
        path = appCtx.path;
    }

    if((fp = fopen(path, "a+t")) == NULL) {
        errorf("Failed to open theme output file.");
        return 1;
    } else {
        infof("Opened output file \"%s\"", path);
    }

    if((font = fontGet("consolas", 12, 0)) == NULL) {
        infof("Unable to get font");
        return 1;
    }

    texture = texmgrGet("flub-simple-gui");
    misc = texmgrGet("flub-keycap-misc");
    dlg_body = gfxSliceCreate(misc, 41, 29, 43, 30, 60, 40, 62, 42);
    dlg_title = gfxSliceCreate(misc, 41, 17, 43, 19, 60, 26, 62, 28);

    inputActionBind("KEY_BACKQUOTE", "showconsole");

    tsMenuInit(&menuState, font, menuEntries, 310, 45);
    edit = flubSimpleEditCreate(font, 30, 310, 70);
    tsCompStateInit(&parentComp, texture, menuState.pos);
    comp = &parentComp;

    lastTick = SDL_GetTicks();
    while (keepGoing) {
        current = SDL_GetTicks();
        elapsed = current - lastTick;
        lastTick = current;

        tsCompAnimUpdate(comp, elapsed);

        eventCount = 0;
        while(inputPollEvent(&ev)) {
            eventCount++;
            if(ev.type == SDL_QUIT) {
                keepGoing = 0;
                break;
            }

            if(ev.type == SDL_KEYDOWN) {
                if(ev.key.keysym.sym == SDLK_ESCAPE) {
                    state = eThemerStateConfirm;
                    break;
                } else if(ev.key.keysym.sym == SDLK_HOME) {
                    videoScreenshot("screenshot");
                    break;
                }
            }

            switch(state) {
                default:
                case eThemerStateType:
                    if(tsMenuInput(&menuState, &ev)) {
                        state = eThemerStatePoints;
                        comp = tsCompStateClear(comp);
                        curx = 0;
                        cury = 0;
                        tsCompStateInit(comp, texture, menuState.pos);
                    }
                    break;
                case eThemerStatePoints:
                    if(ev.type == SDL_KEYDOWN) {
                        switch (ev.key.keysym.sym) {
                            case SDLK_END:
                                flubSimpleEditSet(edit, "comp");
                                flubSimpleEditActive(edit, 1);
                                state = eThemerStateName;
                                break;
                            case SDLK_INSERT:
                                comp = tsCompStateAddFrame(comp);
                                break;
                            case SDLK_EQUALS:
                                comp = tsCompFrameNext(comp);
                                break;
                            case SDLK_BACKSLASH:
                                tsCompAnimToggle(comp);
                                break;
                            case SDLK_PAGEUP:
                                if(ev.key.keysym.mod & KMOD_SHIFT) {
                                    tsCompAnimAdjust(comp, 10);
                                } else {
                                    tsCompAnimAdjust(comp, 1);
                                }
                                break;
                            case SDLK_PAGEDOWN:
                                if(ev.key.keysym.mod & KMOD_SHIFT) {
                                    tsCompAnimAdjust(comp, -10);
                                } else {
                                    tsCompAnimAdjust(comp, -1);
                                }
                                if(comp->delay < 0) {
                                    comp->delay = 0;
                                }
                                break;
                            case SDLK_UP:
                                tsCompPosUpdate(comp, 0, -1,
                                                ((ev.key.keysym.mod & KMOD_SHIFT) ? 1 : 0),
                                                ((ev.key.keysym.mod & KMOD_CTRL) ? 1 : 0),
                                                &curx, &cury);
                                break;
                            case SDLK_DOWN:
                                tsCompPosUpdate(comp, 0, 1,
                                                ((ev.key.keysym.mod & KMOD_SHIFT) ? 1 : 0),
                                                ((ev.key.keysym.mod & KMOD_CTRL) ? 1 : 0),
                                                &curx, &cury);
                                break;
                            case SDLK_LEFT:
                                tsCompPosUpdate(comp, -1, 0,
                                                ((ev.key.keysym.mod & KMOD_SHIFT) ? 1 : 0),
                                                ((ev.key.keysym.mod & KMOD_CTRL) ? 1 : 0),
                                                &curx, &cury);
                                break;
                            case SDLK_RIGHT:
                                tsCompPosUpdate(comp, 1, 0,
                                                ((ev.key.keysym.mod & KMOD_SHIFT) ? 1 : 0),
                                                ((ev.key.keysym.mod & KMOD_CTRL) ? 1 : 0),
                                                &curx, &cury);
                                break;
                            case SDLK_RETURN:
                                tsCompNextPoint(comp, &curx, &cury);
                                break;
                        }
                    }
                    break;
                case eThemerStateName:
                    if(flubSimpleEditInput(edit, &ev)) {
                        // Save the entry
                        if(comp->type == eCompSlice) {
                            fprintf(fp,"%s %d %d %d %d %d %d %d %d\n", edit->buf,
                                    comp->pos[0][0], comp->pos[0][1],
                                    comp->pos[1][0], comp->pos[1][1],
                                    comp->pos[2][0], comp->pos[2][1],
                                    comp->pos[3][0], comp->pos[3][1]);
                        } else if(comp->type == eCompAnimation) {
                            fprintf(fp, "%s %d %d ", edit->buf,
                                    (comp->pos[1][0] - comp->pos[0][0] + 1),
                                    (comp->pos[1][1] - comp->pos[0][1]));
                            if(comp->parent == NULL) {
                                walk = comp;
                            } else {
                                walk = comp->parent;
                            }
                            for(; walk != NULL; walk = walk->next) {
                                fprintf(fp, "%d %d %d ", walk->pos[0][0], walk->pos[0][1], walk->delay);
                            }
                        } else {
                            fprintf(fp,"%s %d %d %d %d\n", edit->buf,
                                    comp->pos[0][0], comp->pos[0][1],
                                    comp->pos[1][0], comp->pos[1][1]);
                        }
                        state = eThemerStateType;
                        break;
                    }
                    break;
                case eThemerStateConfirm:
                    if(ev.type == SDL_KEYDOWN) {
                        switch (ev.key.keysym.sym) {
                            case SDLK_END:
                                keepGoing = 0;
                                break;
                            case SDLK_RETURN:
                                state = eThemerStateType;
                                break;
                        }
                        break;
                    }
                    break;
            }
            if(eventCount >= BULK_EVENT_LIMIT) {
                break;
            }
        }
        videoClear();

        videoPushGLState();
        videoOrthoMode();

        glLoadIdentity();
        glColor3f(1.0, 1.0, 1.0);

        // Title
        gfxSliceBlit(dlg_title, 0, 0, 639, 20);
        fontMode();
        fontPos(5, 5);
        fontSetColor(0.0, 0.0, 0.0);
        fontBlitStr(font, "Flub Themer");

        // Image
        glLoadIdentity();
        drawTexture(texture, 10, 30);

        // State name
        fontMode();
        fontSetColor(1.0, 1.0, 1.0);
        fontPos(300, 25);

        switch(state) {
            default:
            case eThemerStateType:
                fontBlitStr(font, "Select component type:");
                tsMenuDraw(&menuState);
                break;
            case eThemerStatePoints:
                fontBlitStr(font, "Select points:");
                drawFragment(texture, dlg_body, comp);
                drawCrosshair(misc, curx + 10, cury + 30);
                fontMode();
                fontPos(5, 300);
                fontSetColor(1.0, 1.0, 1.0);
                fontBlitStrf(font, "X: %3d  Y: %3d", curx, cury);
                tsCompPointInfo(comp, font, 310, 50);
                if((comp->type == eCompAnimation) &&
                   (((comp->parent != NULL) && (comp->parent->animGo)) ||
                    (comp->animGo))) {
                    fontPos(310, 250);
                    fontSetColor(1.0, 1.0, 1.0);
                    fontBlitStrf(font, "Animating");
                }
                break;
            case eThemerStateName:
                fontBlitStr(font, "Select component type:");
                fontMode();
                fontPos(310, 50);
                fontSetColor(1.0, 1.0, 1.0);
                fontBlitStr(font, "Enter component name");
                flubSimpleEditDraw(edit);
                break;
            case eThemerStateConfirm:
                fontBlitStr(font, "Are you sure you want to quit?");
                gfxBlitKeyStr(font, "Press [End] to exit, [Return] to continue.", 310, 50, NULL, NULL);
                break;
        }

        if(!appUpdate(current)) {
            keepGoing = 0;
        }
    }
    fclose(fp);
    return 0;
}
示例#5
0
文件: themer.c 项目: Mojofreem/flub
void tsCompPointInfo(compState_t *state, font_t *font, int x, int y) {
    int k;
    int w, h;
    int valid = 1;

    fontMode();
    fontPos(x, y);
    glColor3f(0.3, 0.3, 0.3);
    fontBlitStr(font, "Frame ");
    glColor3f(1.0, 1.0, 1.0);
    fontBlitInt(font, state->frame + 1);
    glColor3f(0.3, 0.3, 0.3);
    fontBlitStr(font, "/");
    glColor3f(1.0, 1.0, 1.0);
    if(state->parent == NULL) {
        fontBlitInt(font, state->total);
    } else {
        fontBlitInt(font, state->parent->total);
    }

    y += (fontGetHeight(font) * 2);

    for(k = 0; k < ((state->type == eCompSlice) ? 4 : 2); k++) {
        if(k == state->active) {
            if(state->valid[k]) {
                glColor3f(0.0, 1.0, 0.0);
            } else {
                glColor3f(5.0, 1.0, 0.0);
            }
        } else {
            if(state->valid[k]) {
                glColor3f(0.3, 0.5, 0.3);
            } else {
                glColor3f(0.5, 0.3, 0.3);
            }
        }
        fontPos(x, y);
        fontBlitStrf(font, "%d: (%3d, %3d)", k + 1, state->pos[k][0], state->pos[k][1]);
        y += fontGetHeight(font);
    }
    y += fontGetHeight(font);
    fontPos(x, y);
    glColor3f(0.3, 0.3, 0.3);
    if(state->type == eCompSlice) {
        if((!state->valid[1]) || (!state->valid[2]) || (!state->valid[3])) {
            valid = 0;
        }
        w = state->pos[3][0] - state->pos[0][0];
        h = state->pos[3][1] - state->pos[0][1];
    } else {
        if(!state->valid[1]) {
            valid = 0;
        }
        w = state->pos[1][0] - state->pos[0][0];
        h = state->pos[1][1] - state->pos[0][1];
    }
    w++;
    h++;
    if(valid) {
        fontBlitStrf(font, "Size: %dx%d", w, h);
    } else {
        fontBlitStrf(font, "Size: --x--");
    }
    if(state->type == eCompAnimation) {
        y += (fontGetHeight(font) * 2);
        fontPos(x, y);
        fontBlitStr(font, "Delay: ");
        glColor3f(1.0, 1.0, 1.0);
        fontBlitStrf(font, "%4d ms", state->delay);
    }
}
示例#6
0
	/**
	* @brief Add a text to be render queue with the current properties set by user calls
	*/
	void FontManager::addText()
	{
		// Check the manager is ok
		if ( !isValid() )
		{
			LOG_ERROR( "text error: FontManager not properly initialized. The init method has not been called or there are no active font" );
			return;
		}

		// Add a new font (to be rendered later)
		MovableText* newText = getNewText();

		// Font properties
		newText->setFontName( m_activeFontProperties.fontName );
		newText->setCharacterHeight( m_activeFontProperties.size );
		newText->setLeading( m_activeFontProperties.leading );
		newText->setColor( GraphicsManager::getSingleton().getFillColor().normalized() );
		newText->setTextAreaWidth( m_activeFontProperties.width );
		newText->setTextAreaHeight( m_activeFontProperties.height );
		newText->setTextAlignment(m_activeFontProperties.halign, m_activeFontProperties.valign);
		newText->setCaption( m_activeFontProperties.text.toUTF() );
		newText->setWordWrap( m_activeFontProperties.wordWrap );

		// Text display properties
		newText->showOnTop();
		newText->setAlwaysFaceCamera( false );
		newText->show();

		// Get global transformation
		Transform &t = GraphicsManager::getSingleton().m_transforms.top();

		// Font Position
		Vector fontPos( m_activeFontProperties.x, m_activeFontProperties.y, m_activeFontProperties.z );
		Vector transformedPos = t.getPosition() + fontPos;
		Vector scale = t.getScale();

		// Control current coordinate system
		if ( GraphicsManager::getSingleton().isProcessingMode() )
		{
			if ( m_activeFontProperties.render2d )
			{
				newText->setPosition( transformedPos.x, height - transformedPos.y );	
				newText->setScale( scale.x, -scale.y );
			}
			else
			{
				newText->setPosition( transformedPos );	
				newText->setScale( scale.x, -scale.y, scale.z );
			}
			
			newText->getParentNode()->setOrientation( t.getRotQuaternion().Inverse() );
		}
		else
		{
			if ( m_activeFontProperties.render2d )
			{
				newText->setPosition( transformedPos.x, transformedPos.y );	
				newText->setScale( scale.x, scale.y );
			}
			else
			{
				newText->setPosition( transformedPos );	
				newText->setScale( scale );
			}

			newText->getParentNode()->setOrientation( t.getRotQuaternion() );
		}

		// Setup text geometry for render
		newText->_setupGeometry();
	}