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