本文整理汇总了C++中common::Archive类的典型用法代码示例。如果您正苦于以下问题:C++ Archive类的具体用法?C++ Archive怎么用?C++ Archive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Archive类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: themeConfigUsable
bool ThemeEngine::themeConfigUsable(const Common::FSNode &node, Common::String &themeName) {
Common::File stream;
bool foundHeader = false;
if (node.getName().matchString("*.zip", true) && !node.isDirectory()) {
Common::Archive *zipArchive = Common::makeZipArchive(node);
if (zipArchive && zipArchive->hasFile("THEMERC")) {
// Open THEMERC from the ZIP file.
stream.open("THEMERC", *zipArchive);
}
// Delete the ZIP archive again. Note: This only works because
// stream.open() only uses ZipArchive::createReadStreamForMember,
// and that in turn happens to read all the data for a given
// archive member into a memory block. So there will be no dangling
// reference to zipArchive anywhere. This could change if we
// ever modify ZipArchive::createReadStreamForMember.
delete zipArchive;
} else if (node.isDirectory()) {
Common::FSNode headerfile = node.getChild("THEMERC");
if (!headerfile.exists() || !headerfile.isReadable() || headerfile.isDirectory())
return false;
stream.open(headerfile);
}
if (stream.isOpen()) {
Common::String stxHeader = stream.readLine();
foundHeader = themeConfigParseHeader(stxHeader, themeName);
}
return foundHeader;
}
开发者ID:megaboy,项目名称:scummvm,代码行数:31,代码来源:ThemeEngine.cpp
示例2: loadFontsBDF
void MacFontManager::loadFontsBDF() {
Common::Archive *dat;
dat = Common::makeZipArchive("classicmacfonts.dat");
if (!dat) {
warning("Could not find classicmacfonts.dat. Falling back to built-in fonts");
_builtInFonts = true;
return;
}
Common::ArchiveMemberList list;
dat->listMembers(list);
for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getName());
Graphics::BdfFont *font = Graphics::BdfFont::loadFont(*stream);
delete stream;
Common::String fontName;
MacFont *macfont;
if (font->getFamilyName() && *font->getFamilyName()) {
fontName = Common::String::format("%s-%s-%d", font->getFamilyName(), font->getFontSlant(), font->getFontSize());
macfont = new MacFont(_fontNames.getVal(font->getFamilyName(), kMacFontNonStandard), font->getFontSize(), parseFontSlant(font->getFontSlant()));
} else { // Get it from the file name
fontName = (*it)->getName();
// Trim the .bdf extension
for (int i = fontName.size() - 1; i >= 0; --i) {
if (fontName[i] == '.') {
while ((uint)i < fontName.size()) {
fontName.deleteLastChar();
}
break;
}
}
macfont = new MacFont(kMacFontNonStandard);
macfont->setName(fontName);
}
FontMan.assignFontToName(fontName, font);
//macfont->setFont(font);
_fontRegistry.setVal(fontName, macfont);
debug(2, " %s", fontName.c_str());
}
_builtInFonts = false;
delete dat;
}
开发者ID:,项目名称:,代码行数:57,代码来源:
示例3: PackFile
Common::Archive *loadUpdateArchive(Common::SeekableReadStream *data) {
Common::SeekableReadStream *updStream = new PackFile(data);
Common::Archive *cab = new MsCabinet(updStream);
Common::Archive *update = new LangFilter(cab, g_grim->getGameLanguage());
Common::ArchiveMemberList list;
if (update->listMembers(list) == 0) {
delete update;
return 0;
} else
return update;
}
开发者ID:Harrypoppins,项目名称:grim_mouse,代码行数:13,代码来源:update.cpp
示例4: listUsableThemes
void ThemeEngine::listUsableThemes(Common::Archive &archive, Common::List<ThemeDescriptor> &list) {
ThemeDescriptor td;
Common::ArchiveMemberList fileList;
archive.listMatchingMembers(fileList, "*.zip");
for (Common::ArchiveMemberList::iterator i = fileList.begin();
i != fileList.end(); ++i) {
td.name.clear();
if (themeConfigUsable(**i, td.name)) {
td.filename = (*i)->getName();
td.id = (*i)->getDisplayName();
// If the name of the node object also contains
// the ".zip" suffix, we will strip it.
if (td.id.matchString("*.zip", true)) {
for (int j = 0; j < 4; ++j)
td.id.deleteLastChar();
}
list.push_back(td);
}
}
fileList.clear();
}
开发者ID:megaboy,项目名称:scummvm,代码行数:25,代码来源:ThemeEngine.cpp
示例5: loadDirectoryAsPackage
bool PackageManager::loadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition) {
Common::FSNode directory(directoryName);
Common::Archive *folderArchive = new Common::FSDirectory(directory, 6);
if (!directory.exists() || (folderArchive == NULL)) {
BS_LOG_ERRORLN("Unable to mount directory \"%s\" to \"%s\".", directoryName.c_str(), mountPosition.c_str());
return false;
} else {
BS_LOGLN("Directory '%s' mounted as '%s'.", directoryName.c_str(), mountPosition.c_str());
Common::ArchiveMemberList files;
folderArchive->listMembers(files);
debug(0, "Capacity %d", files.size());
_archiveList.push_front(new ArchiveEntry(folderArchive, mountPosition));
return true;
}
}
开发者ID:,项目名称:,代码行数:18,代码来源:
示例6: loadPackage
bool PackageManager::loadPackage(const Common::String &fileName, const Common::String &mountPosition) {
debug(3, "loadPackage(%s, %s)", fileName.c_str(), mountPosition.c_str());
Common::Archive *zipFile = Common::makeZipArchive(fileName);
if (zipFile == NULL) {
BS_LOG_ERRORLN("Unable to mount file \"%s\" to \"%s\"", fileName.c_str(), mountPosition.c_str());
return false;
} else {
BS_LOGLN("Package '%s' mounted as '%s'.", fileName.c_str(), mountPosition.c_str());
Common::ArchiveMemberList files;
zipFile->listMembers(files);
debug(3, "Capacity %d", files.size());
for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it)
debug(3, "%s", (*it)->getName().c_str());
_archiveList.push_front(new ArchiveEntry(zipFile, mountPosition));
return true;
}
}
开发者ID:,项目名称:,代码行数:21,代码来源:
示例7: getArchiveMember
/**
* Scans through the archive list for a specified file
*/
Common::ArchiveMemberPtr PackageManager::getArchiveMember(const Common::String &fileName) {
// Loop through checking each archive
Common::List<ArchiveEntry *>::iterator i;
for (i = _archiveList.begin(); i != _archiveList.end(); ++i) {
if (!fileName.hasPrefix((*i)->_mountPath)) {
// The mount path is in different subtree. Skipping
continue;
}
// Look into the archive for the desired file
Common::Archive *archiveFolder = (*i)->archive;
// Construct relative path
Common::String resPath(&fileName.c_str()[(*i)->_mountPath.size()]);
if (archiveFolder->hasFile(resPath)) {
return archiveFolder->getMember(resPath);
}
}
return Common::ArchiveMemberPtr();
}
开发者ID:,项目名称:,代码行数:25,代码来源:
示例8: load
/* load the keyboard into memory */
bool PSPKeyboard::load() {
DEBUG_ENTER_FUNC();
if (_init) {
PSP_DEBUG_PRINT("keyboard already loaded into memory\n");
return true;
}
// For the shell, we must use a hack
#ifdef PSP_KB_SHELL
Common::FSNode node(PSP_KB_SHELL_PATH);
#else /* normal mode */
Common::FSNode node("."); // Look in current directory
#endif
PSP_DEBUG_PRINT("path[%s]\n", node.getPath().c_str());
Common::Archive *fileArchive = NULL;
Common::Archive *zipArchive = NULL;
Common::SeekableReadStream * file = 0;
if (node.getChild("kbd").exists() && node.getChild("kbd").isDirectory()) {
PSP_DEBUG_PRINT("found directory ./kbd\n");
fileArchive = new Common::FSDirectory(node.getChild("kbd"));
}
if (node.getChild("kbd.zip").exists()) {
PSP_DEBUG_PRINT("found kbd.zip\n");
zipArchive = Common::makeZipArchive(node.getChild("kbd.zip"));
}
int i;
// Loop through all png images
for (i = 0; i < guiStringsSize; i++) {
PSP_DEBUG_PRINT("Opening %s.\n", _guiStrings[i]);
// Look for the file in the kbd directory
if (fileArchive && fileArchive->hasFile(_guiStrings[i])) {
PSP_DEBUG_PRINT("found it in kbd directory.\n");
file = fileArchive->createReadStreamForMember(_guiStrings[i]);
if (!file) {
PSP_ERROR("Can't open kbd/%s for keyboard. No keyboard will load.\n", _guiStrings[i]);
goto ERROR;
}
}
// We didn't find it. Look for it in the zip file
else if (zipArchive && zipArchive->hasFile(_guiStrings[i])) {
PSP_DEBUG_PRINT("found it in kbd.zip.\n");
file = zipArchive->createReadStreamForMember(_guiStrings[i]);
if (!file) {
PSP_ERROR("Can't open %s in kbd.zip for keyboard. No keyboard will load.\n", _guiStrings[i]);
goto ERROR;
}
} else { // Couldn't find the file
PSP_ERROR("Can't find %s for keyboard. No keyboard will load.\n", _guiStrings[i]);
goto ERROR;
}
PngLoader image(file, _buffers[i], _palettes[i]);
if (image.allocate() != PngLoader::OK) {
PSP_ERROR("Failed to allocate memory for keyboard image %s\n", _guiStrings[i]);
goto ERROR;
}
if (!image.load()) {
PSP_ERROR("Failed to load image from file %s\n", _guiStrings[i]);
goto ERROR;
}
delete file;
} /* for loop */
_init = true;
delete fileArchive;
delete zipArchive;
return true;
ERROR:
delete file;
delete fileArchive;
delete zipArchive;
for (int j = 0; j < i; j++) {
_buffers[j].deallocate();
_palettes[j].deallocate();
}
_init = false;
return false;
}
开发者ID:St0rmcrow,项目名称:scummvm,代码行数:95,代码来源:pspkeyboard.cpp
示例9: loadFonts
void MacFontManager::loadFonts() {
Common::Archive *dat;
dat = Common::makeZipArchive("classicmacfonts.dat");
if (!dat) {
warning("Could not find classicmacfonts.dat. Falling back to built-in fonts");
_builtInFonts = true;
return;
}
Common::ArchiveMemberList list;
dat->listMembers(list);
for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getName());
Common::MacResManager *fontFile = new Common::MacResManager();
if (!fontFile->loadFromMacBinary(*stream))
continue;
Common::MacResIDArray fonds = fontFile->getResIDArray(MKTAG('F','O','N','D'));
if (fonds.size() > 0) {
for (Common::Array<uint16>::iterator iterator = fonds.begin(); iterator != fonds.end(); ++iterator) {
Common::SeekableReadStream *fond = fontFile->getResource(MKTAG('F', 'O', 'N', 'D'), *iterator);
Common::String familyName = fontFile->getResName(MKTAG('F', 'O', 'N', 'D'), *iterator);
Graphics::MacFontFamily *fontFamily = new MacFontFamily();
fontFamily->load(*fond);
Common::Array<Graphics::MacFontFamily::AsscEntry> *assoc = fontFamily->getAssocTable();
for (uint i = 0; i < assoc->size(); i++) {
debug("size: %d style: %d id: %d", (*assoc)[i]._fontSize, (*assoc)[i]._fontStyle,
(*assoc)[i]._fontID);
Common::SeekableReadStream *fontstream;
MacFont *macfont;
Graphics::MacFONTFont *font;
fontstream = fontFile->getResource(MKTAG('N', 'F', 'N', 'T'), (*assoc)[i]._fontID);
if (!fontstream)
fontstream = fontFile->getResource(MKTAG('F', 'O', 'N', 'T'), (*assoc)[i]._fontID);
if (!fontstream) {
warning("Unknown FontId: %d", (*assoc)[i]._fontID);
continue;
}
font = new Graphics::MacFONTFont;
font->loadFont(*fontstream, fontFamily, (*assoc)[i]._fontSize, (*assoc)[i]._fontStyle);
delete fontstream;
Common::String fontName = Common::String::format("%s-%d-%d", familyName.c_str(), (*assoc)[i]._fontStyle, (*assoc)[i]._fontSize);
macfont = new MacFont(_fontNames.getVal(familyName, kMacFontNonStandard), (*assoc)[i]._fontSize, (*assoc)[i]._fontStyle);
FontMan.assignFontToName(fontName, font);
macfont->setFont(font);
_fontRegistry.setVal(fontName, macfont);
debug(2, " %s", fontName.c_str());
}
delete fond;
}
}
delete fontFile;
}
_builtInFonts = false;
delete dat;
}
开发者ID:,项目名称:,代码行数:81,代码来源:
示例10: loadFont
bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) {
Common::String newFontName;
if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) {
if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
newFontName = "timesbi.ttf";
else if (_style & STTF_BOLD)
newFontName = "timesbd.ttf";
else if (_style & STTF_ITALIC)
newFontName = "timesi.ttf";
else
newFontName = "times.ttf";
} else if (fontName.matchString("*courier new*", true) || fontName.matchString("*courier*", true) || fontName.matchString("*ZorkDeath*", true)) {
if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
newFontName = "courbi.ttf";
else if (_style & STTF_BOLD)
newFontName = "courbd.ttf";
else if (_style & STTF_ITALIC)
newFontName = "couri.ttf";
else
newFontName = "cour.ttf";
} else if (fontName.matchString("*century schoolbook*", true)) {
if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
newFontName = "censcbkbi.ttf";
else if (_style & STTF_BOLD)
newFontName = "censcbkbd.ttf";
else if (_style & STTF_ITALIC)
newFontName = "censcbki.ttf";
else
newFontName = "censcbk.ttf";
} else if (fontName.matchString("*garamond*", true)) {
if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
newFontName = "garabi.ttf";
else if (_style & STTF_BOLD)
newFontName = "garabd.ttf";
else if (_style & STTF_ITALIC)
newFontName = "garai.ttf";
else
newFontName = "gara.ttf";
} else if (fontName.matchString("*arial*", true) || fontName.matchString("*ZorkNormal*", true)) {
if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
newFontName = "arialbi.ttf";
else if (_style & STTF_BOLD)
newFontName = "arialbd.ttf";
else if (_style & STTF_ITALIC)
newFontName = "ariali.ttf";
else
newFontName = "arial.ttf";
} else {
debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
newFontName = "arial.ttf";
}
bool sharp = (_style & STTF_SHARP) == STTF_SHARP;
Common::File *file = _engine->getSearchManager()->openFile(newFontName);
if (!file) {
Common::SeekableReadStream *themeFile = nullptr;
if (ConfMan.hasKey("themepath")) {
Common::FSNode themePath(ConfMan.get("themepath"));
if (themePath.exists()) {
Common::FSNode scummModern = themePath.getChild("scummmodern.zip");
if (scummModern.exists()) {
themeFile = scummModern.createReadStream();
}
}
}
if (!themeFile) { // Fallback : Search for ScummModern.zip in SearchMan.
themeFile = SearchMan.createReadStreamForMember("scummmodern.zip");
}
if (themeFile) {
Common::Archive *themeArchive = Common::makeZipArchive(themeFile);
if (themeArchive->hasFile("FreeSans.ttf")) {
Common::SeekableReadStream *stream = nullptr;
stream = themeArchive->createReadStreamForMember("FreeSans.ttf");
Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display
if (_newFont) {
if (!_font)
delete _font;
_font = _newFont;
}
if (stream)
delete stream;
}
delete themeArchive;
themeArchive = nullptr;
}
} else {
Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display
if (_newFont) {
if (!_font)
delete _font;
_font = _newFont;
}
delete file;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
注:本文中的common::Archive类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论