bool device_image_interface::open_image_file(emu_options &options)
{
	const char* path = options.value(instance_name());
	if (strlen(path)>0)
	{
		set_init_phase();
		if (load_internal(path, FALSE, 0, NULL, TRUE)==IMAGE_INIT_PASS)
		{
			if (software_entry()==NULL) return true;
		}
	}
	return false;
}
Esempio n. 2
0
bool device_image_interface::open_image_file(emu_options &options)
{
	const char* path = options.value(instance_name());
	if (*path != 0)
	{
		set_init_phase();
		if (load_internal(path, false, 0, nullptr, true) == image_init_result::PASS)
		{
			if (software_entry()==nullptr) return true;
		}
	}
	return false;
}
Esempio n. 3
0
image_init_result device_image_interface::create(const std::string &path, const image_device_format *create_format, util::option_resolution *create_args)
{
	int format_index = 0;
	int cnt = 0;
	for (auto &format : m_formatlist)
	{
		if (create_format == format.get()) {
			format_index = cnt;
			break;
		}
		cnt++;
	}
	return load_internal(path, true, format_index, create_args, false);
}
Esempio n. 4
0
bool device_image_interface::create(const char *path, const image_device_format *create_format, util::option_resolution *create_args)
{
    int format_index = 0;
    int cnt = 0;
    for (auto &format : m_formatlist)
    {
        if (create_format == format.get()) {
            format_index = cnt;
            break;
        }
        cnt++;
    }
    return load_internal(path, TRUE, format_index, create_args, FALSE);
}
void mattack_actor::load( JsonObject &jo, const std::string &src )
{
    bool strict = src == "dda";

    // Legacy support
    if( !jo.has_string( "id" ) ) {
        id = jo.get_string( "type" );
    } else {
        // Loading ids can't be strict at the moment, since it has to match the stored version
        assign( jo, "id", id, false );
    }

    assign( jo, "cooldown", cooldown, strict );

    load_internal( jo, src );
    // Set was_loaded manually because we don't have generic_factory to do it for us
    was_loaded = true;
}
Esempio n. 6
0
File: scene.cpp Progetto: tapio/weep
void SceneLoader::load(const string& path, Resources& resources)
{
	logDebug("Start loading scene %s", path.c_str());
	uint t0 = Engine::timems();
	m_environment = Json();
	load_internal(path, resources);

	if (!m_environment.is_null() && world->has_system<RenderSystem>()) {
		RenderSystem& renderer = world->get_system<RenderSystem>();
		renderer.env() = parseEnvironment(m_environment, resources, dirname(path));
		renderer.device().setEnvironment(&renderer.env());
	}

	Entity cameraEnt;
	if (world->has_tagged_entity("camera")) {
		cameraEnt = world->get_entity_by_tag("camera");
	} else {
		cameraEnt = world->create();
		cameraEnt.tag("camera");
	}
	if (!cameraEnt.has<Camera>()) {
		cameraEnt.add<Camera>();
		Camera& camera = cameraEnt.get<Camera>();
		float ar = Engine::width() / (float)Engine::height();
		camera.makePerspective(45, ar, 0.1, 1000);
		if (cameraEnt.has<Transform>()) {
			Transform& trans = cameraEnt.get<Transform>();
			camera.updateViewMatrix(trans.position, trans.rotation);
		} else {
			camera.view = glm::lookAt(vec3(0, 0, 1), vec3(0, 0, 0), vec3(0, 1, 0));
		}
	}

	resources.startAsyncLoading();

	uint t1 = Engine::timems();
	logDebug("Loaded scene %s in %dms with %d models, %d bodies, %d lights, %d prefabs", path.c_str(), t1 - t0, numModels, numBodies, numLights, prefabs.size());
}
bool device_image_interface::load(const char *path)
{
    return load_internal(path, FALSE, 0, NULL, FALSE);
}
bool device_image_interface::create(const char *path, const image_device_format *create_format, option_resolution *create_args)
{
    int format_index = (create_format != NULL) ? create_format->m_index : 0;
    return load_internal(path, TRUE, format_index, create_args, FALSE);
}
Esempio n. 9
0
bool legacy_image_device_base::load(const char *path)
{
    return load_internal(path, FALSE, 0, NULL);
}
Esempio n. 10
0
image_init_result device_image_interface::load(const std::string &path)
{
	return load_internal(path, false, 0, nullptr, false);
}
Esempio n. 11
0
static int upgrade (ErlNifEnv * env, void ** priv, void ** old_priv,
                    ERL_NIF_TERM load_info) {

  return load_internal (env, priv, old_priv, load_info, true);
}
Esempio n. 12
0
static int load (ErlNifEnv * env, void ** priv,
                 ERL_NIF_TERM load_info) {

  return load_internal (env, priv, NULL, load_info, false);
}
Esempio n. 13
0
bool device_image_interface::create(const char *path, const image_device_format *create_format, option_resolution *create_args)
{
	int format_index = (create_format != nullptr) ? m_formatlist.indexof(*create_format) : 0;
	return load_internal(path, TRUE, format_index, create_args, FALSE);
}
Esempio n. 14
0
File: scene.cpp Progetto: tapio/weep
void SceneLoader::load_internal(const string& path, Resources& resources)
{
	string pathContext = dirname(path);
	std::string err;
	Json jsonScene = Json::parse(resources.getText(path, Resources::NO_CACHE), err);
	if (!err.empty())
		panic("Failed to read scene %s: %s", path.c_str(), err.c_str());

	if (jsonScene.is_object()) {
		// Handle includes
		if (jsonScene["include"].is_string()) {
			load_internal(resolvePath(pathContext, jsonScene["include"].string_value()), resources);
		} else if (jsonScene["include"].is_array()) {
			for (auto& includePath : jsonScene["include"].array_items())
				load_internal(resolvePath(pathContext, includePath.string_value()), resources);
		}

		// Parse modules
		if (jsonScene["modules"].is_array() && world->has_system<ModuleSystem>()) {
			world->get_system<ModuleSystem>().load(jsonScene["modules"], false);
		}

		// Parse environment
		if (jsonScene["environment"].is_object()) {
			m_environment = assign(m_environment, jsonScene["environment"]);
		}

		// Parse fonts
		if (jsonScene["fonts"].is_object() && world->has_system<ImGuiSystem>()) {
			const Json::object& fonts = jsonScene["fonts"].object_items();
			ImGuiSystem& imgui = world->get_system<ImGuiSystem>();
			for (auto& it : fonts) {
				ASSERT(it.second.is_object());
				string path = resources.findPath(resolvePath(pathContext, it.second["path"].string_value()));
				float size = it.second["size"].number_value();
				imgui.loadFont(it.first, path, size);
			}
		}

		// Parse sounds
		if (jsonScene["sounds"].is_object() && world->has_system<AudioSystem>()) {
			const Json::object& sounds = jsonScene["sounds"].object_items();
			AudioSystem& audio = world->get_system<AudioSystem>();
			for (auto& it : sounds) {
				if (it.second.is_string()) {
					audio.add(it.first, resources.getBinary(resolvePath(pathContext, it.second.string_value())));
				} else if (it.second.is_array()) {
					for (auto& it2 : it.second.array_items()) {
						ASSERT(it2.is_string());
						audio.add(it.first, resources.getBinary(resolvePath(pathContext, it2.string_value())));
					}
				}
			}
		}

		// Parse prefabs
		if (jsonScene["prefabs"].is_object()) {
			const Json::object& scenePrefabs = jsonScene["prefabs"].object_items();
			for (auto& it : scenePrefabs)
				prefabs[it.first] = it.second;
		}
	}

	// Parse objects
	const Json::array& objects = jsonScene.is_array() ? jsonScene.array_items() : jsonScene["objects"].array_items();
	for (uint i = 0; i < objects.size(); ++i) {
		instantiate(objects[i], resources, pathContext);
	}
}