changes to twn.toml specification of resolution, make it optional as well
This commit is contained in:
		@@ -5,7 +5,6 @@ app_id = "bunnymark"
 | 
			
		||||
dev_id = "morshy"
 | 
			
		||||
 | 
			
		||||
[game]
 | 
			
		||||
base_render_width = 640
 | 
			
		||||
base_render_height = 480
 | 
			
		||||
resolution = [ 640, 480 ]
 | 
			
		||||
 | 
			
		||||
[engine]
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,6 @@ app_id = "platformer-demo"
 | 
			
		||||
dev_id = "townengine-team"
 | 
			
		||||
 | 
			
		||||
[game]
 | 
			
		||||
base_render_width = 640
 | 
			
		||||
base_render_height = 360
 | 
			
		||||
resolution = [ 640, 360 ]
 | 
			
		||||
 | 
			
		||||
[engine]
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,10 @@
 | 
			
		||||
[about]
 | 
			
		||||
title = "Serene Scenery"
 | 
			
		||||
developer = "Townengine Team"
 | 
			
		||||
app_id = "platformer-demo"
 | 
			
		||||
app_id = "scenery-demo"
 | 
			
		||||
dev_id = "townengine-team"
 | 
			
		||||
 | 
			
		||||
[game]
 | 
			
		||||
base_render_width = 640
 | 
			
		||||
base_render_height = 360
 | 
			
		||||
resolution = [ 640, 360 ]
 | 
			
		||||
 | 
			
		||||
[engine]
 | 
			
		||||
 
 | 
			
		||||
@@ -13,8 +13,7 @@ dev_id = "you"
 | 
			
		||||
 | 
			
		||||
# Game runtime details
 | 
			
		||||
[game]
 | 
			
		||||
base_render_width = 640
 | 
			
		||||
base_render_height = 480
 | 
			
		||||
resolution = [ 640, 480 ]
 | 
			
		||||
#debug = true
 | 
			
		||||
 | 
			
		||||
# Engine tweaks. You probably don't need to change these
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,6 @@ app_id = "twnlua"
 | 
			
		||||
dev_id = "somebody"
 | 
			
		||||
 | 
			
		||||
[game]
 | 
			
		||||
base_render_width = 640
 | 
			
		||||
base_render_height = 360
 | 
			
		||||
resolution = [ 640, 360 ]
 | 
			
		||||
 | 
			
		||||
[engine]
 | 
			
		||||
 
 | 
			
		||||
@@ -423,11 +423,7 @@ static bool initialize(void) {
 | 
			
		||||
    /* debug mode defaults to being enabled */
 | 
			
		||||
    /* pass --debug or --release to force a mode, ignoring configuration */
 | 
			
		||||
    toml_datum_t datum_debug = toml_bool_in(game, "debug");
 | 
			
		||||
    if (!datum_debug.ok) {
 | 
			
		||||
        ctx.game.debug = true;
 | 
			
		||||
    } else {
 | 
			
		||||
        ctx.game.debug = datum_debug.u.b;
 | 
			
		||||
    }
 | 
			
		||||
    ctx.game.debug = datum_debug.ok ? datum_debug.u.b : true;
 | 
			
		||||
 | 
			
		||||
#ifdef EMSCRIPTEN
 | 
			
		||||
    /* emscripten interpretes those as GL ES version against WebGL */
 | 
			
		||||
@@ -454,10 +450,9 @@ static bool initialize(void) {
 | 
			
		||||
    /* init got far enough to create a window */
 | 
			
		||||
    {
 | 
			
		||||
        toml_datum_t datum_title = toml_string_in(about, "title");
 | 
			
		||||
        if (!datum_title.ok) {
 | 
			
		||||
            CRY("Initialization failed", "Valid about.title expected in configuration file");
 | 
			
		||||
            goto fail;
 | 
			
		||||
        }
 | 
			
		||||
        if (!datum_title.ok)
 | 
			
		||||
            datum_title.u.s = "townengine project";
 | 
			
		||||
 | 
			
		||||
        /* not yet used
 | 
			
		||||
        toml_datum_t datum_developer = toml_string_in(about, "developer");
 | 
			
		||||
        if (!datum_developer.ok) {
 | 
			
		||||
@@ -465,32 +460,44 @@ static bool initialize(void) {
 | 
			
		||||
            goto fail;
 | 
			
		||||
        }
 | 
			
		||||
        */
 | 
			
		||||
        toml_datum_t datum_base_render_width = toml_int_in(game, "base_render_width");
 | 
			
		||||
        if (!datum_base_render_width.ok) {
 | 
			
		||||
            CRY("Initialization failed", "Valid game.base_render_width expected in configuration file");
 | 
			
		||||
            goto fail;
 | 
			
		||||
        }
 | 
			
		||||
        ctx.base_render_width = datum_base_render_width.u.i;
 | 
			
		||||
        ctx.game.resolution.x = (float)ctx.base_render_width;
 | 
			
		||||
 | 
			
		||||
        toml_datum_t datum_base_render_height = toml_int_in(game, "base_render_height");
 | 
			
		||||
        if (!datum_base_render_height.ok) {
 | 
			
		||||
            CRY("Initialization failed", "Valid game.base_render_height expected in configuration file");
 | 
			
		||||
        toml_array_t *datum_resolution = toml_array_in(game, "resolution");
 | 
			
		||||
        if (datum_resolution) {
 | 
			
		||||
            toml_datum_t datum_base_render_width = toml_int_at(datum_resolution, 0);
 | 
			
		||||
            if (!datum_base_render_width.ok) {
 | 
			
		||||
                CRY("Initialization failed", "Valid game.resolution expected in configuration file");
 | 
			
		||||
                goto fail;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            toml_datum_t datum_base_render_height = toml_int_at(datum_resolution, 1);
 | 
			
		||||
            if (!datum_base_render_height.ok) {
 | 
			
		||||
                CRY("Initialization failed", "Valid game.resolution expected in configuration file");
 | 
			
		||||
                goto fail;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            ctx.base_render_width = datum_base_render_width.u.i;
 | 
			
		||||
            ctx.base_render_height = datum_base_render_height.u.i;
 | 
			
		||||
 | 
			
		||||
        } else {
 | 
			
		||||
            ctx.base_render_width = 640;
 | 
			
		||||
            ctx.base_render_height = 360;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ctx.game.resolution.x = (float)ctx.base_render_width;
 | 
			
		||||
        ctx.game.resolution.y = (float)ctx.base_render_height;
 | 
			
		||||
 | 
			
		||||
        ctx.window = SDL_CreateWindow(datum_title.u.s,
 | 
			
		||||
                                      SDL_WINDOWPOS_CENTERED,
 | 
			
		||||
                                      SDL_WINDOWPOS_CENTERED,
 | 
			
		||||
                                      (int)datum_base_render_width.u.i,
 | 
			
		||||
                                      (int)datum_base_render_height.u.i,
 | 
			
		||||
                                      (int)ctx.base_render_width,
 | 
			
		||||
                                      (int)ctx.base_render_height,
 | 
			
		||||
                                      //SDL_WINDOW_ALLOW_HIGHDPI |
 | 
			
		||||
                                          SDL_WINDOW_RESIZABLE |
 | 
			
		||||
                                          SDL_WINDOW_OPENGL);
 | 
			
		||||
 | 
			
		||||
        if (datum_title.ok)
 | 
			
		||||
            SDL_free(datum_title.u.s);
 | 
			
		||||
 | 
			
		||||
        //SDL_free(datum_developer.u.s);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user