1 /******************************
2 ** Tsunagari Tile Engine **
4 ** Copyright 2011 OmegaSDG **
5 ******************************/
12 #include <json/json.h>
19 * This probably won't be changed ever except maybe with a command line option.
21 #define CLIENT_CONF_FILE "./client.conf"
24 * Values needed prior to creating the GameWindow.
34 * Load the values we need to start initializing the game from a JSON file.
36 * We need to know what size window to create and which World to load. This
37 * information will be stored in a JSON file which we parse here.
39 * @param filename Name of the JSON-encoded file to load from.
40 * @param conf Values are stored here.
42 * @return True if successful
44 static bool parseClientConfig(const std::string filename
, ClientValues
* conf
)
47 Json::Value root
, windowsize
;
49 std::ifstream
file(filename
);
51 if (!reader
.parse(file
, root
)) {
52 printf("Client config failed to parse as JSON\n");
57 * - name of World to load
58 * - width, height, fullscreen-ness of Window
60 conf
->world
= root
.get("world", "_NONE_").asString();
61 if (conf
->world
== "_NONE_") {
62 printf("Client config didn't contain world name\n");
66 windowsize
= root
["windowsize"];
67 if (windowsize
.size() != 2) {
68 printf("Client config windowsize didn't contain 2 values\n");
72 conf
->windowsize
.x
= windowsize
[uint(0)].asUInt();
73 conf
->windowsize
.y
= windowsize
[1].asUInt();
75 conf
->fullscreen
= root
.get("fullscreen", false).asBool();
81 * Load client config and instantiate window.
83 * The client config tells us our window parameters along with which World
84 * we're going to load. The GameWindow class then loads and plays the game.
90 if (!parseClientConfig(CLIENT_CONF_FILE
, &conf
))
93 GameWindow
window(conf
.windowsize
.x
, conf
.windowsize
.y
,