Exemple #1
0
void ResExtractor::setCursor(int id) {
	CachedCursor *cc = findCachedCursor(id);

	if (cc != NULL) {
		debug(7, "Found cursor %d in cache slot %lu", id, (long)(cc - _cursorCache));
	} else {
		cc = getCachedCursorSlot();
		assert(cc && !cc->valid);

		if (!extractResource(id, cc))
			error("Could not extract cursor %d", id);

		debug(7, "Adding cursor %d to cache slot %lu", id, (long)(cc - _cursorCache));

		cc->valid = true;
		cc->id = id;
		cc->lastUsed = g_system->getMillis();
	}

	if (cc->palette)
		CursorMan.replaceCursorPalette(cc->palette, 0, cc->palSize);

	_vm->setCursorHotspot(cc->hotspotX, cc->hotspotY);
	_vm->setCursorFromBuffer(cc->bitmap, cc->width, cc->height, cc->width);
}
void ResExtractor::setCursor(int id) {
	byte *cursorRes = 0;
	int cursorsize;
	int keycolor = 0;
	CachedCursor *cc = findCachedCursor(id);
	if (cc != NULL) {
		debug(7, "Found cursor %d in cache slot %lu", id, (long)(cc - _cursorCache));
	} else {
		cc = getCachedCursorSlot();
		assert(cc && !cc->valid);
		cursorsize = extractResource(id, &cursorRes);
		convertIcons(cursorRes, cursorsize, &cc->bitmap, &cc->w, &cc->h, &cc->hotspot_x, &cc->hotspot_y, &keycolor, &cc->palette, &cc->palSize);
		debug(7, "Adding cursor %d to cache slot %lu", id, (long)(cc - _cursorCache));
		free(cursorRes);
		cc->valid = true;
		cc->id = id;
		cc->last_used = g_system->getMillis();
	}

	if (cc->palette)
		CursorMan.replaceCursorPalette(cc->palette, 0, cc->palSize);

	_vm->setCursorHotspot(cc->hotspot_x, cc->hotspot_y);
	_vm->setCursorFromBuffer(cc->bitmap, cc->w, cc->h, cc->w);
}