本文整理汇总了C++中PackageManager类的典型用法代码示例。如果您正苦于以下问题:C++ PackageManager类的具体用法?C++ PackageManager怎么用?C++ PackageManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PackageManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _imageDataPtr
SWImage::SWImage(const Common::String &filename, bool &result) :
_imageDataPtr(0),
_width(0),
_height(0) {
result = false;
PackageManager *pPackage = Kernel::getInstance()->getPackage();
assert(pPackage);
// Load file
byte *pFileData;
uint fileSize;
pFileData = pPackage->getFile(filename, &fileSize);
if (!pFileData) {
error("File \"%s\" could not be loaded.", filename.c_str());
return;
}
// Uncompress the image
int pitch;
byte *pUncompressedData;
if (!ImgLoader::decodePNGImage(pFileData, fileSize, pUncompressedData, _width, _height, pitch)) {
error("Could not decode image.");
return;
}
// Cleanup FileData
delete[] pFileData;
_imageDataPtr = (uint *)pUncompressedData;
result = true;
return;
}
示例2: LoadPackage
static int LoadPackage(lua_State *L) {
const char* str = lua_tostring(L,-1);
PackageManager* p = App::getPackageManager();
p->LoadPackage(str);
lua_pop(L,1);
return 0;
}
示例3: _pKernel
FontResource::FontResource(Kernel *pKernel, const Common::String &fileName) :
_pKernel(pKernel),
_valid(false),
Resource(fileName, Resource::TYPE_FONT),
Common::XMLParser() {
// Get a pointer to the package manager
assert(_pKernel);
PackageManager *pPackage = _pKernel->getPackage();
assert(pPackage);
// Load the contents of the file
uint fileSize;
char *xmlData = pPackage->getXmlFile(getFileName(), &fileSize);
if (!xmlData) {
error("Could not read \"%s\".", getFileName().c_str());
return;
}
// Parse the contents
if (!loadBuffer((const byte *)xmlData, fileSize))
return;
_valid = parse();
close();
free(xmlData);
}
示例4: warning
bool FontResource::parserCallback_font(ParserNode *node) {
// Get the attributes of the font
Common::String bitmapFilename = node->values["bitmap"];
if (!parseIntegerKey(node->values["lineheight"], 1, &_lineHeight)) {
warning("Illegal or missing lineheight attribute in <font> tag in \"%s\". Assuming default (\"%d\").",
getFileName().c_str(), DEFAULT_LINEHEIGHT);
_lineHeight = DEFAULT_LINEHEIGHT;
}
if (!parseIntegerKey(node->values["gap"], 1, &_gapWidth)) {
warning("Illegal or missing gap attribute in <font> tag in \"%s\". Assuming default (\"%d\").",
getFileName().c_str(), DEFAULT_GAPWIDTH);
_gapWidth = DEFAULT_GAPWIDTH;
}
// Get a reference to the package manager
assert(_pKernel);
PackageManager *pPackage = _pKernel->getPackage();
assert(pPackage);
// Get the full path and filename for the bitmap resource
_bitmapFileName = pPackage->getAbsolutePath(bitmapFilename);
if (_bitmapFileName == "") {
error("Image file \"%s\" was specified in <font> tag of \"%s\" but could not be found.",
_bitmapFileName.c_str(), getFileName().c_str());
}
// Pre-cache the resource
if (!_pKernel->getResourceManager()->precacheResource(_bitmapFileName)) {
error("Could not precache \"%s\".", _bitmapFileName.c_str());
}
return true;
}
示例5: AddSearchPath
static int AddSearchPath(lua_State *L) {
const char* str = lua_tostring(L,-1);
PackageManager* p = App::getPackageManager();
p->addSearchPath(str);
lua_pop(L,1);
return 0;
}
示例6: PackageManager
PackageManager* Project::createPackage()
{
PackageManager* pkgMgr = new PackageManager();
pkgMgr->metadata()->setName("Untitled Package");
mPackageManagers.push_back(pkgMgr);
return pkgMgr;
}
示例7: main
int
main(void)
{
PackageManager app;
app.Run();
return 0;
}
示例8: _type
Resource::Resource(const Common::String &fileName, RESOURCE_TYPES type) :
_type(type),
_refCount(0) {
PackageManager *pPM = Kernel::getInstance()->getPackage();
assert(pPM);
_fileName = pPM->getAbsolutePath(fileName);
}
示例9: _data
RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
_data(0),
_width(0),
_height(0),
_isTransparent(true) {
result = false;
PackageManager *pPackage = Kernel::getInstance()->getPackage();
assert(pPackage);
_backSurface = Kernel::getInstance()->getGfx()->getSurface();
// Load file
byte *pFileData;
uint fileSize;
bool isPNG = true;
if (filename.hasPrefix("/saves")) {
pFileData = readSavegameThumbnail(filename, fileSize, isPNG);
} else {
pFileData = pPackage->getFile(filename, &fileSize);
}
if (!pFileData) {
error("File \"%s\" could not be loaded.", filename.c_str());
return;
}
// Uncompress the image
int pitch;
if (isPNG)
result = ImgLoader::decodePNGImage(pFileData, fileSize, _data, _width, _height, pitch);
else
result = ImgLoader::decodeThumbnailImage(pFileData, fileSize, _data, _width, _height, pitch);
if (!result) {
error("Could not decode image.");
delete[] pFileData;
return;
}
// Cleanup FileData
delete[] pFileData;
_doCleanup = true;
#if defined(SCUMM_LITTLE_ENDIAN)
// Makes sense for LE only at the moment
checkForTransparency();
#endif
return;
}
示例10: main
int main(int ac, char **av) {
PackageManager pkgMan;
JsonParser parser;
std::string cmd, topic, type;
int cpt;
int size = parser.getSize();;
while (parser.parseNextPackage(cmd, topic, type, cpt)) {
std::cout << "launch package:" << cmd << " " << topic << " " << type <<std::endl;
pkgMan.launchPackage(cmd, topic, type);
std::cout << "Package " << cpt << "/" << size << " launched..." << std::endl;
sleep(2);
}
std::cout << std::endl << "<<< MscProject launched >>>" << std::endl << std::endl;
return 0;
}
示例11: checkImport
//throw on error
static ResolutionResult checkImport(const PackageManager& pm, const ParseResultPtr& pr, const std::string& pkgName, const CustomTypeExprNode* tnode, const std::string& type)
{
PackagePtr pkg = pm.package(pkgName);
NodePtr node = pkg->getExport(type);
TypeKind kind;
if (node) {
switch (node->type()) {
case NodeType_InterfaceDecl:
kind = TypeKind_Interface;
break;
case NodeType_EnumDecl:
kind = TypeKind_Enum;
break;
case NodeType_StructDecl:
kind = TypeKind_Struct;
break;
default:
pr->addDiag(Diagnostic(DiagnosticType_Error, "'" + type + "' in package '" + pkgName + "' is not a type", tnode->loc()));
throw std::runtime_error("Not a type");
break;
}
return ResolutionResult(pkgName, type, kind);
}
pr->addDiag(Diagnostic(DiagnosticType_Error, "Can't find '" + type + "' in package '" + pkgName + "'", tnode->loc()));
throw std::runtime_error("Can't find import");
}
示例12: pathname
bool Project::write(ProgressFeedback* feedback)
{
String pathname(mPath);
pathname += PATHSEP;
pathname += mName;
pathname += ".project";
TiXmlDocument doc;
TiXmlDeclaration decl("1.0", "", "");
doc.InsertEndChild(decl);
TiXmlElement project("project");
std::stringstream ss;
ss << mVersion;
std::string str(ss.str());
project.SetAttribute("version", str.c_str());
ss.str("");
ss << mPackageManagers.size();
str.assign(ss.str());
project.SetAttribute("package_count", str.c_str());
String packagePath(mPath);
packagePath += "/packages/";
for (PackageManagers::iterator it = mPackageManagers.begin(); it != mPackageManagers.end(); ++it) {
PackageManager* pkgMgr = *it;
TiXmlElement package("package");
String name(pkgMgr->metadata()->getName());
package.SetAttribute("name", name);
name = pkgMgr->packageFilename();
package.SetAttribute("filename", name);
project.InsertEndChild(package);
// write out the actual package file
pkgMgr->save(packagePath);
}
doc.InsertEndChild(project);
doc.SaveFile(pathname);
return true;
}
示例13: add
void
PackageManager::add(const PackageManager & theOther) {
AC_TRACE << "add from package '" << theOther.getSearchPath() << "'";
PackageList::const_iterator it = theOther._myPackages.begin();
for (; it != theOther._myPackages.end(); ++it) {
add(*it);
}
}
示例14: dir
bool Sword25Engine::loadPackages() {
PackageManager *packageManagerPtr = Kernel::getInstance()->getPackage();
assert(packageManagerPtr);
// Load the main package
if (!packageManagerPtr->loadPackage("data.b25c", "/"))
return false;
// Get the contents of the main program directory and sort them alphabetically
Common::FSNode dir(ConfMan.get("path"));
Common::FSList files;
if (!dir.isDirectory() || !dir.getChildren(files, Common::FSNode::kListAll)) {
warning("Game data path does not exist or is not a directory");
return false;
}
Common::sort(files.begin(), files.end());
// Identify all patch packages
// The filename of patch packages must have the form patch??.b25c, with the question marks
// are placeholders for numbers.
// Since the filenames have been sorted, patches are mounted with low numbers first, through
// to ones with high numbers. This is important, because newly mount packages overwrite
// existing files in the virtual file system, if they include files with the same name.
for (Common::FSList::const_iterator it = files.begin(); it != files.end(); ++it) {
if (it->getName().matchString("patch???.b25c", true))
if (!packageManagerPtr->loadPackage(it->getName(), "/"))
return false;
}
// Identify and mount all language packages
// The filename of the packages have the form lang_*.b25c (eg. lang_de.b25c)
for (Common::FSList::const_iterator it = files.begin(); it != files.end(); ++it) {
if (it->getName().matchString("lang_*.b25c", true))
if (!packageManagerPtr->loadPackage(it->getName(), "/"))
return false;
}
return true;
}
示例15: _imageDataPtr
SWImage::SWImage(const Common::String &filename, bool &result) :
_imageDataPtr(0),
_width(0),
_height(0) {
result = false;
PackageManager *pPackage = Kernel::getInstance()->getPackage();
assert(pPackage);
// Datei laden
byte *pFileData;
uint fileSize;
pFileData = pPackage->getFile(filename, &fileSize);
if (!pFileData) {
error("File \"%s\" could not be loaded.", filename.c_str());
return;
}
// Bildeigenschaften bestimmen
int pitch;
if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) {
error("Could not read image properties.");
return;
}
// Das Bild dekomprimieren
byte *pUncompressedData;
if (!PNGLoader::decodeImage(pFileData, fileSize, pUncompressedData, _width, _height, pitch)) {
error("Could not decode image.");
return;
}
// Dateidaten freigeben
delete[] pFileData;
_imageDataPtr = (uint *)pUncompressedData;
result = true;
return;
}