Пример #1
0
SDLAppSettings::SDLAppSettings() {
    setDisplayDefaults();

    default_section_name = "settings";

    //conf entries in other sections
    conf_sections["viewport"]           = "display";
    conf_sections["windowed"]           = "display";
    conf_sections["fullscreen"]         = "display";
    conf_sections["multi-sampling"]     = "display";
    conf_sections["output-ppm-stream"]  = "display";
    conf_sections["output-framerate"]   = "display";
    conf_sections["transparent"]        = "display";
    conf_sections["no-vsync"]           = "display";

    //translate args
    arg_aliases["f"]   = "fullscreen";
    arg_aliases["w"]   = "windowed";
    arg_aliases["o"]   = "output-ppm-stream";
    arg_aliases["r"]   = "output-framerate";

    //boolean args
    arg_types["viewport"]          = "string";
    arg_types["windowed"]          = "bool";
    arg_types["fullscreen"]        = "bool";
    arg_types["transparent"]       = "bool";
    arg_types["multi-sampling"]    = "bool";
    arg_types["no-vsync"]          = "bool";
    arg_types["output-ppm-stream"] = "string";
    arg_types["output-framerate"]  = "int";

}
Пример #2
0
void SDLAppSettings::importDisplaySettings(ConfFile& conffile) {

    setDisplayDefaults();

    ConfSection* display_settings = conffile.getSection("display");

    if(display_settings == 0) return;

    ConfEntry* entry = 0;

    bool viewport_specified = false;

    if((entry = display_settings->getEntry("viewport")) != 0) {

        std::string viewport = entry->getString();



        int width  = 0;
        int height = 0;
        bool no_resize = false;

        if(parseViewport(viewport, width, height, no_resize)) {
            display_width   = width;
            display_height  = height;
            if(no_resize) resizable = false;

            viewport_specified = true;
        } else {
            conffile.invalidValueException(entry);
        }
    }

    if(display_settings->getBool("multi-sampling")) {
        multisample = true;
    }

    if(display_settings->getBool("fullscreen")) {
        fullscreen = true;
    }

    if(display_settings->getBool("windowed")) {
        fullscreen = false;
    }

    // default to use desktop resolution for fullscreen unless specified
    if(fullscreen && !viewport_specified) {
        display_width  = 0;
        display_height = 0;
    }

    if(display_settings->getBool("transparent")) {
        transparent = true;
    }

    if(display_settings->getBool("no-vsync")) {
        vsync = false;
    }

    if((entry = display_settings->getEntry("output-ppm-stream")) != 0) {

        if(!entry->hasValue()) {
            conffile.entryException(entry, "specify ppm output file or '-' for stdout");
        }

        output_ppm_filename = entry->getString();

#ifdef _WIN32
        if(output_ppm_filename == "-") {
            conffile.entryException(entry, "stdout PPM mode not supported on Windows");
        }
#endif
    }

    if((entry = display_settings->getEntry("output-framerate")) != 0) {

        if(!entry->hasValue()) {
             conffile.entryException(entry, "specify framerate (25,30,60)");
        }

        output_framerate = entry->getInt();

        if(   output_framerate != 25
            && output_framerate != 30
            && output_framerate != 60) {
            conffile.entryException(entry, "supported framerates are 25,30,60");
        }
    }
}
Пример #3
0
void SDLAppSettings::importDisplaySettings(ConfFile& conffile) {

    setDisplayDefaults();

    ConfSection* display_settings = conffile.getSection("display");

    if(display_settings == 0) return;

    ConfEntry* entry = 0;

    if((entry = display_settings->getEntry("viewport")) != 0) {

        std::string viewport = entry->getString();

        int width  = 0;
        int height = 0;

        size_t x = viewport.rfind("x");

        if(x != std::string::npos && x != 0 && x != viewport.size()-1) {
            std::string widthstr  = viewport.substr(0, x);
            std::string heightstr = viewport.substr(x+1);

            width  = atoi(widthstr.c_str());
            height = atoi(heightstr.c_str());
        }

        if(width>0 && height>0) {
            display_width  = width;
            display_height = height;
        } else {
            conffile.invalidValueException(entry);
        }
    }

    if(display_settings->getBool("multi-sampling")) {
        multisample = true;
    }

    if(display_settings->getBool("fullscreen")) {
        fullscreen = true;
    }

    if(display_settings->getBool("windowed")) {
        fullscreen = false;
    }

    if(display_settings->getBool("transparent")) {
        transparent = true;
    }

    if((entry = display_settings->getEntry("output-ppm-stream")) != 0) {

        if(!entry->hasValue()) {
            conffile.entryException(entry, "specify ppm output file or '-' for stdout");
        }

        output_ppm_filename = entry->getString();

#ifdef _WIN32
        if(output_ppm_filename == "-") {
            conffile.entryException(entry, "stdout PPM mode not supported on Windows");
        }
#endif
    }

    if((entry = display_settings->getEntry("output-framerate")) != 0) {

        if(!entry->hasValue()) {
             conffile.entryException(entry, "specify framerate (25,30,60)");
        }

        output_framerate = entry->getInt();

        if(   output_framerate != 25
            && output_framerate != 30
            && output_framerate != 60) {
            conffile.entryException(entry, "supported framerates are 25,30,60");
        }
    }
}