Exemplo n.º 1
0
Screen::Screen(shared_ptr<ResourceCtl> res, const JsonObject& entry) {
	_res = res;
	bool status = true;

	_backColor = extractWithDefault<ALLEGRO_COLOR>(entry.getValue("backColor"), al_map_rgb(12, 41, 17));
	_isMapScreen = extractWithDefault<bool>(entry.getValue("map"), false);

	std::string name = extractValue<std::string>(entry.getValue("name"));
	auto framePtr = std::dynamic_pointer_cast<JsonTValue<std::vector<shared_ptr<JsonValue>>>>(entry.getValue("frames"));
	auto elemPtr = std::dynamic_pointer_cast<JsonTValue<std::vector<shared_ptr<JsonValue>>>>(entry.getValue("elements"));

	if (framePtr) {
		auto frameArr = framePtr->getValue();
		for (auto tmp : frameArr) {
			_addFrame(std::dynamic_pointer_cast<JsonObject>(tmp));
		}
	}
	if (elemPtr) {
		auto elemArr = elemPtr->getValue();
		for (auto tmp : elemArr) {
			_addElement(std::dynamic_pointer_cast<JsonObject>(tmp));
		}
	}
}