Example #1
0
	void ElevatorList::load(const std::string& path, bool mirror)
	{
		Json::Parser parser;
		Json::Value root = parser.parse(path);

		Int32 width = root.get("width").asInt();
		Int32 height = root.get("height").asInt();

		Size elevators = root.get("elevators").getLength();
		for (Size i = 0; i < elevators; i++) {
			Elevator elevator;
			Json::Value points = root.get("elevators").get(i).get("controlPoints");
			for (Size j = 0; j < points.getLength(); j++) {
				Int32 x = points.get(j).get("x").asInt();
				Int32 y = points.get(j).get("y").asInt();
				elevator.addControlPoint(Elevator::ControlPoint(mirror ? width - 1 - x : x, height - y));
			}
			add(elevator);
		}
	}
Example #2
0
	void Menu::loadPersonData(const std::string& filePath)
	{
		if (!File::exists(filePath))
		{
			return;
		}

		Json::Parser parser;
		Json::Value json = parser.parse(filePath);
		persons.fromJson(json.get("persons"));

		for (const Person& person : persons.list())
		{
			listbox[ALL_PLAYER_LIST]->addItem(person.getName());
		}

		Json::Value playing = json.get("playing");
		for (Size i = 0; i < playing.getLength(); i++)
		{
			std::string name = playing.get(i).asString();
			listbox[CUR_PLAYERS_LIST]->addItem(name);
			listbox[ALL_PLAYER_LIST]->removeItem(name);
		}
	}
Example #3
0
	void Level::load(const std::string& path, bool mirror)
	{
		levelData.clear();
		waterLevel = 0;
		Json::Parser parser;
		Json::Value root = parser.parse(path);

		width = root.get("width").asInt();
		height = root.get("height").asInt();

		Int32 blockCount = width * height;
		Json::Value blocks = root.get("blocks");
		levelData.resize(blockCount);
		for (Size i = 0; i < blocks.getLength(); i++)
		{
			levelData[i] = blocks.get(i).asInt();
		}

		if (mirror)
		{
			mirrorLevelData();
		}
		waterBlock = findWaterType();
	}