Example #1
0
int main(int argc, char *argv[])
{
    SDL_ILBM_Format format = SDL_ILBM_AUTO_FORMAT;
    unsigned int lowresPixelScaleFactor = 0;
    unsigned int number = 0;
    unsigned int options = 0;
    char *filename;
    
#ifdef _MSC_VER
    unsigned int optind = 1;
    unsigned int i; 

    int formatFollows = FALSE;
    int lowresPixelScaleFactorFollows = FALSE;
    int numberFollows = FALSE;

    for (i = 1; i < argc; i++)
    {
        if (formatFollows)
        {
            formatFollows = FALSE;
            format = determineFormat(argv[i]);
            optind++;
        }
        else if (lowresPixelScaleFactorFollows)
        {
            lowresPixelScaleFactorFollows = FALSE;
            lowresPixelScaleFactor = determineLowresPixelScaleFactor(argv[i]);
            optind++;
        }
        else if (numberFollows)
        {
            numberFollows = FALSE;
            number = atoi(argv[i]);
            optind++;
        }
        else if (strcmp(argv[i], "/f") == 0)
        {
            formatFollows = TRUE;
            optind++;
        }
        else if(strcmp(argv[i], "/C") == 0)
        {
            options |= SDL_ILBM_OPTION_CYCLE;
            optind++;
        }
        else if(strcmp(argv[i], "/s") == 0)
        {
            options |= SDL_ILBM_OPTION_STRETCH;
            optind++;
        }
        else if (strcmp(argv[i], "/c") == 0)
        {
            lowresPixelScaleFactorFollows = TRUE;
            optind++;
        }
        else if (strcmp(argv[i], "/F") == 0)
        {
            options |= SDL_ILBM_OPTION_FULLSCREEN;
            optind++;
        }
        else if (strcmp(argv[i], "/n") == 0)
        {
            numberFollows = TRUE;
            optind++;
        }
        else if (strcmp(argv[i], "/?") == 0)
        {
            printUsage(argv[0]);
            return 0;
        }
        else if (strcmp(argv[i], "/v") == 0)
        {
            printVersion(argv[0]);
            return 0;
        }
    }
#else
    int c, option_index = 0;
    struct option long_options[] =
    {
        {"format", required_argument, 0, 'f'},
        {"cycle", no_argument, 0, 'C'},
        {"stretch", no_argument, 0, 's'},
        {"correct-aspect", required_argument, 0, 'c'},
        {"fullscreen", no_argument, 0, 'F'},
        {"number", required_argument, 0, 'n'},
        {"help", no_argument, 0, 'h'},
        {"version", no_argument, 0, 'v'},
        {0, 0, 0, 0}
    };

    /* Parse command-line options */
    while((c = getopt_long(argc, argv, "f:Csc:Fn:hv", long_options, &option_index)) != -1)
    {
        switch(c)
        {
            case 'f':
                format = determineFormat(optarg);
                break;
            case 'C':
                options |= SDL_ILBM_OPTION_CYCLE;
                break;
            case 's':
                options |= SDL_ILBM_OPTION_STRETCH;
                break;
            case 'c':
                lowresPixelScaleFactor = determineLowresPixelScaleFactor(optarg);
                break;
            case 'F':
                options |= SDL_ILBM_OPTION_FULLSCREEN;
                break;
            case 'n':
                number = atoi(optarg);
                break;
            case 'h':
            case '?':
                printUsage(argv[0]);
                return 0;
            case 'v':
                printVersion(argv[0]);
                return 0;
        }
    }
#endif

    /* Validate non options */
    
    if (optind >= argc)
        filename = NULL;
    else
        filename = argv[optind];
        
    return SDL_ILBM_viewILBMImages(filename, format, number, lowresPixelScaleFactor, options);
}
Example #2
0
void Gource::logic(float t, float dt) {

    if(draw_loading) return;

    if(message_timer>0.0f) message_timer -= dt;
    if(splash>0.0f)        splash -= dt;

    //init log file
    if(commitlog == 0) {

        try {

            commitlog = determineFormat(logfile);

        } catch(SeekLogException& exception) {
            throw SDLAppException("unable to read log file");
        }

        if(commitlog == 0) {
            //if not in a git dir and no log file, show help
            if(logfile.size() == 0 || logfile == ".") {
                SDL_Quit();

                SDLAppException exception("");
                exception.setShowHelp(true);
                throw exception;
            } else if(SDLAppDirExists(logfile)) {
                throw SDLAppException("directory not supported");
            } else {
                throw SDLAppException("unsupported log format (you may need to regenerate your log file)");
            }
        }

        if(gGourceSettings.start_position>0.0) {
            seekTo(gGourceSettings.start_position);
        }
    }

    slider.logic(dt);

    //apply rotation
    if(rotate_angle != 0.0f) {

        float s = sinf(rotate_angle);
        float c = cosf(rotate_angle);

        root->rotate(s, c);

        for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) {
            RUser* user = it->second;

            vec2f userpos = user->getPos();

            user->setPos(userpos.rotate(s, c));
        }

        rotate_angle = 0.0f;
    }

    //still want to update camera while paused
    if(paused) {
        updateBounds();
        updateQuadTree();
        updateCamera(dt);
        return;
    }

    // get more entries
    if(commitqueue.size() == 0) {
        readLog();
    }

    //loop in attempt to find commits
    if(commitqueue.size()==0 && commitlog->isSeekable() && gGourceSettings.loop) {
        first_read=true;
        seekTo(0.0);
        readLog();
    }

    if(currtime==0 && commitqueue.size()) {
        currtime   = lasttime = commitqueue[0].timestamp;
        subseconds = 0.0;
    }

    //set current time
    float time_inc = (dt * 86400.0 * gGourceSettings.days_per_second);
    int seconds    = (int) time_inc;

    subseconds += time_inc - ((float) seconds);

    if(subseconds >= 1.0) {
        currtime   += (int) subseconds;
        subseconds -= (int) subseconds;
    }

    currtime += seconds;

    // delete files
    for(std::vector<RFile*>::iterator it = gGourceRemovedFiles.begin(); it != gGourceRemovedFiles.end(); it++) {
        deleteFile(*it);
    }

    gGourceRemovedFiles.clear();


    //add commits up until the current time
    while(commitqueue.size() > 0) {

        RCommit commit = commitqueue[0];

        //auto skip ahead, unless stop_position_reached
        if(gGourceSettings.auto_skip_seconds>=0.0 && idle_time >= gGourceSettings.auto_skip_seconds && !stop_position_reached) {
            currtime = lasttime = commit.timestamp;
            idle_time = 0.0;
        }

        if(commit.timestamp > currtime) break;

        processCommit(commit, t);

        currtime = lasttime = commit.timestamp;
        subseconds = 0.0;

        commitqueue.pop_front();
    }

    //reset loop counters
    gGourceUserInnerLoops = 0;
    gGourceDirNodeInnerLoops = 0;
    gGourceFileInnerLoops = 0;

    interactUsers();
    updateUsers(t, dt);

    updateQuadTree();
    updateBounds();
    updateDirs(dt);

    updateCamera(dt);

    updateTime(commitqueue.size() > 0 ? currtime : lasttime);
}
Example #3
0
void Gource::logic(float t, float dt) {

    if(draw_loading) return;

    if(splash>0.0) splash -= dt;

    //init log file
    if(commitlog == 0) {
        commitlog = determineFormat(logfile);

        if(commitlog == 0) {
            //if not in a git dir and no log file, show help
            if(logfile.size() == 0 || logfile == ".") {
                SDL_Quit();
                gource_help("");
            } else if(SDLAppDirExists(logfile)) {
                gource_quit("Directory not supported.");
            } else {
                gource_quit("Unsupported log format.  You may need to regenerate your log file.");
            }
        }

        if(start_position>0.0) {
            seekTo(start_position);
        }
    }

    slider.logic(dt);

    //still want to update camera while paused
    if(paused) {
        updateCamera(dt);
        return;
    }

    // get more entries
    if(commitqueue.size() == 0) {
        readLog();
    }

    //loop in attempt to find commits
    if(commitqueue.size()==0 && commitlog->isSeekable() && gGourceFileLoop) {
        first_read=true;
        seekTo(0.0);
        readLog();
    }

    if(currtime==0 && commitqueue.size()) {
        currtime   = commitqueue[0].timestamp;
        subseconds = 0.0;
    }

    //set current time
    float time_inc = (dt * 86400.0 * gGourceDaysPerSecond);
    int seconds    = (int) time_inc;

    subseconds += time_inc - ((float) seconds);

    if(subseconds >= 1.0) {
        currtime   += (int) subseconds;
        subseconds -= (int) subseconds;
    }

    currtime += seconds;

    // delete files
    for(std::vector<RFile*>::iterator it = gGourceRemovedFiles.begin(); it != gGourceRemovedFiles.end(); it++) {
        deleteFile(*it);
    }

    gGourceRemovedFiles.clear();


    //add commits up until the current time
    while(commitqueue.size() > 0) {

        RCommit commit = commitqueue[0];

        if(gGourceAutoSkipSeconds>=0.0 && idle_time >= gGourceAutoSkipSeconds) {
            currtime = commit.timestamp;
            idle_time = 0.0;
        }

        if(commit.timestamp > currtime) break;

        processCommit(commit, t);

        currtime = commit.timestamp;
        subseconds = 0.0;

        commitqueue.pop_front();
    }

    //reset loop counters
    gGourceUserInnerLoops = 0;
    gGourceDirNodeInnerLoops = 0;
    gGourceFileInnerLoops = 0;

    interactUsers();
    interactDirs();

    updateUsers(t, dt);
    updateDirs(dt);

    updateCamera(dt);

    updateTime();
}
Example #4
0
void Gource::logic(float t, float dt) {
    dt = std::min(dt, gGourceMaxDelta);

    if(draw_loading) return;

    if(splash>0.0) splash -= dt;

    //init log file
    if(commitlog == 0) {
        commitlog = determineFormat(logfile);

        if(commitlog == 0) {
            printf("unsupported log file or directory not supported\n", logfile.c_str());
            exit(1);
        }

        if(start_position>0.0) {
            seekTo(start_position);
        }
    }

    slider.logic(dt);

    if(paused) return;

    elapsed_time += dt * 86400.0 * gGourceDaysPerSecond;

    // get more entries
    if(commitqueue.size() == 0) {
        readLog();
    }

    //loop in attempt to find commits
    if(commitqueue.size()==0 && commitlog->isSeekable()) {
        seekTo(0.0);

        readLog();

        if(commitqueue.size() == 0 && starttime==0) {
            debugLog("no commits and starttime is not defined - cant continue\n");
            exit(1);
        }
    }

    if(starttime==0) {
        starttime = commitqueue[0].timestamp;
    }

    //set current time
    currtime = starttime + elapsed_time;
    float csubsec  = elapsed_time - floorf(elapsed_time);


    // delete files
    for(std::vector<RFile*>::iterator it = gGourceRemovedFiles.begin(); it != gGourceRemovedFiles.end(); it++) {
        deleteFile(*it);
    }

    gGourceRemovedFiles.clear();


    //add commits up until the current time
    while(commitqueue.size() > 0) {

        RCommit commit = commitqueue[0];

        if(gGourceAutoSkipSeconds>=0.0 && idle_time >= gGourceAutoSkipSeconds) {
            currtime = commit.timestamp;
            elapsed_time = commit.timestamp - starttime;
            idle_time = 0.0;
        }

        if(commit.timestamp > currtime) break;

        processCommit(commit);
        commitqueue.pop_front();
    }

    //reset loop counters
    gGourceUserInnerLoops = 0;
    gGourceDirNodeInnerLoops = 0;
    gGourceFileInnerLoops = 0;

    interactUsers();
    interactDirs();

    updateUsers(dt);
    updateDirs(dt);

    updateTime();
}