コード例 #1
0
ファイル: detection.cpp プロジェクト: mokerjoke/scummvm
	virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const {
		Wintermute::BasePersistenceManager pm(target, true);
		SaveStateDescriptor retVal;
		retVal.setDescription("Invalid savegame");
		pm.getSaveStateDesc(slot, retVal);
		return retVal;
	}
コード例 #2
0
void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) {
	Common::String filename = getFilenameForSlot(slot);
	debugC(kWintermuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot);
	if (DID_FAIL(readHeader(filename))) {
		warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str());
		return;
	}
	desc.setSaveSlot(slot);
	desc.setDescription(_savedDescription);
	desc.setDeletableFlag(true);
	desc.setWriteProtectedFlag(false);

	if (_thumbnailDataSize > 0) {
		Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize);
		Graphics::BitmapDecoder bmpDecoder;
		if (bmpDecoder.loadStream(thumbStream)) {
			Graphics::Surface *surf = NULL;
			surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat());
			TransparentSurface *scaleableSurface = new TransparentSurface(*surf, false);
			Graphics::Surface *scaled = scaleableSurface->scale(kThumbnailWidth, kThumbnailHeight2);
			desc.setThumbnail(scaled);
			delete scaleableSurface;
			delete surf;
		}
	}

	desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday);
	desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min);
	desc.setPlayTime(0);
}
コード例 #3
0
	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override {
		SaveStateDescriptor descriptor;
		if (slot == 0) {
			descriptor.setWriteProtectedFlag(true);
			descriptor.setDeletableFlag(false);
		}

		Common::String filename = StarkEngine::formatSaveName(target, slot);
		Common::InSaveFile *save = g_system->getSavefileManager()->openForLoading(filename);
		if (!save) {
			return descriptor;
		}

		SaveMetadata metadata;
		Common::ErrorCode readError = metadata.read(save, filename);
		if (readError != Common::kNoError) {
			delete save;
			return descriptor;
		}

		descriptor.setDescription(metadata.description);

		if (metadata.version >= 9) {
			Graphics::Surface *thumb = metadata.readGameScreenThumbnail(save);
			descriptor.setThumbnail(thumb);
			descriptor.setPlayTime(metadata.totalPlayTime);
			descriptor.setSaveDate(metadata.saveYear, metadata.saveMonth, metadata.saveDay);
			descriptor.setSaveTime(metadata.saveHour, metadata.saveMinute);
		}

		delete save;

		return descriptor;
	}
コード例 #4
0
ファイル: stateloader.cpp プロジェクト: AReim1982/scummvm
void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDescriptor &desc) {
	int day = (header.date >> 24) & 0xFF;
	int month = (header.date >> 16) & 0xFF;
	int year = header.date & 0xFFFF;
	desc.setSaveDate(year, month, day);
	int hour = (header.time >> 8) & 0xFF;
	int minutes = header.time & 0xFF;
	desc.setSaveTime(hour, minutes);
	desc.setPlayTime(header.playtime * 1000);

	desc.setDescription(header.description);
}
コード例 #5
0
void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) {
    Common::String filename = getFilenameForSlot(slot);
    debugC(kWintermuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot);
    if (DID_FAIL(readHeader(filename))) {
        debugC(kWintermuteDebugSaveGame, "getSavedDesc(%d) - Failed for %s", slot, filename.c_str());
        return;
    }
    desc.setSaveSlot(slot);
    desc.setDescription(_savedDescription);
    desc.setDeletableFlag(true);
    desc.setWriteProtectedFlag(false);

    int thumbSize = 0;
    byte *thumbData = nullptr;
    if (_scummVMThumbSize > 0) {
        thumbSize = _scummVMThumbSize;
        thumbData = _scummVMThumbnailData;
    } else if (_thumbnailDataSize > 0) {
        thumbSize = _thumbnailDataSize;
        thumbData = _thumbnailData;
    }

    if (thumbSize > 0) {
        Common::MemoryReadStream thumbStream(thumbData, thumbSize, DisposeAfterUse::NO);
        Graphics::BitmapDecoder bmpDecoder;
        if (bmpDecoder.loadStream(thumbStream)) {
            const Graphics::Surface *bmpSurface = bmpDecoder.getSurface();
            TransparentSurface *scaleableSurface = new TransparentSurface(*bmpSurface, false);
            Graphics::Surface *scaled = scaleableSurface->scale(kThumbnailWidth, kThumbnailHeight2);
            Graphics::Surface *thumb = scaled->convertTo(g_system->getOverlayFormat());
            desc.setThumbnail(thumb);
            delete scaleableSurface;
            scaled->free();
            delete scaled;
        }
    }

    desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday);
    desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min);
    desc.setPlayTime(0);
}