本文整理汇总了C++中AssetManager类的典型用法代码示例。如果您正苦于以下问题:C++ AssetManager类的具体用法?C++ AssetManager怎么用?C++ AssetManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AssetManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AAssetManager_open
AAsset* AAssetManager_open(AAssetManager* amgr, const char* filename, int mode)
{
Asset::AccessMode amMode;
switch (mode) {
case AASSET_MODE_UNKNOWN:
amMode = Asset::ACCESS_UNKNOWN;
break;
case AASSET_MODE_RANDOM:
amMode = Asset::ACCESS_RANDOM;
break;
case AASSET_MODE_STREAMING:
amMode = Asset::ACCESS_STREAMING;
break;
case AASSET_MODE_BUFFER:
amMode = Asset::ACCESS_BUFFER;
break;
default:
return NULL;
}
AssetManager* mgr = static_cast<AssetManager*>(amgr);
Asset* asset = mgr->open(filename, amMode);
if (asset == NULL) {
return NULL;
}
return new AAsset(asset);
}
示例2: extractSplitDescriptionsFromApk
static Vector<SplitDescription> extractSplitDescriptionsFromApk(const String8& path) {
AssetManager assetManager;
Vector<SplitDescription> splits;
int32_t cookie = 0;
if (!assetManager.addAssetPath(path, &cookie)) {
return splits;
}
const ResTable& res = assetManager.getResources(false);
if (res.getError() == NO_ERROR) {
Vector<ResTable_config> configs;
res.getConfigurations(&configs, true);
const size_t configCount = configs.size();
for (size_t i = 0; i < configCount; i++) {
splits.add();
splits.editTop().config = configs[i];
}
}
AssetDir* dir = assetManager.openNonAssetDir(cookie, "lib");
if (dir != NULL) {
const size_t fileCount = dir->getFileCount();
for (size_t i = 0; i < fileCount; i++) {
splits.add();
Vector<String8> parts = AaptUtil::splitAndLowerCase(dir->getFileName(i), '-');
if (parseAbi(parts, 0, &splits.editTop()) < 0) {
fprintf(stderr, "Malformed library %s\n", dir->getFileName(i).string());
splits.pop();
}
}
delete dir;
}
return splits;
}
示例3: LOGE
static jint norwegianime_BinaryDictionary_open
(JNIEnv *env, jobject object, jobject assetManager, jstring resourceString,
jint typedLetterMultiplier, jint fullWordMultiplier)
{
// Get the native file descriptor from the FileDescriptor object
AssetManager *am = (AssetManager*) env->GetIntField(assetManager, sAssetManagerNativeField);
if (!am) {
LOGE("DICT: Couldn't get AssetManager native peer\n");
return 0;
}
const char *resourcePath = env->GetStringUTFChars(resourceString, NULL);
Asset *dictAsset = am->openNonAsset(resourcePath, Asset::ACCESS_BUFFER);
if (dictAsset == NULL) {
LOGE("DICT: Couldn't get asset %s\n", resourcePath);
env->ReleaseStringUTFChars(resourceString, resourcePath);
return 0;
}
void *dict = (void*) dictAsset->getBuffer(false);
if (dict == NULL) {
LOGE("DICT: Dictionary buffer is null\n");
env->ReleaseStringUTFChars(resourceString, resourcePath);
return 0;
}
Dictionary *dictionary = new Dictionary(dict, typedLetterMultiplier, fullWordMultiplier);
dictionary->setAsset(dictAsset);
env->ReleaseStringUTFChars(resourceString, resourcePath);
return (jint) dictionary;
}
开发者ID:Ajayalal,项目名称:scandinavian-keyboard,代码行数:31,代码来源:com_android_inputmethod_norwegian_BinaryDictionary.cpp
示例4: Asset
//===========================================
// PauseMenu::PauseMenu
//===========================================
PauseMenu::PauseMenu(const XmlNode data)
: Asset(internString("PauseMenu")),
Entity(data.firstChild().firstChild().firstChild()),
Menu(data.firstChild()) {
try {
AssetManager assetManager;
XML_NODE_CHECK(data, PauseMenu);
XmlNode node = data.nthChild(1);
XML_NODE_CHECK(node, flare);
XmlAttribute attr = node.firstAttribute();
XML_ATTR_CHECK(attr, ptr);
long id = attr.getLong();
m_flare = boost::dynamic_pointer_cast<CSprite>(assetManager.getAssetPointer(id));
if (!m_flare)
throw XmlException("Bad asset id for flare item", __FILE__, __LINE__);
m_flare->addToWorld();
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class PauseMenu; ");
throw;
}
}
示例5: unsinkAsset
//--------------------------------------------------------------
void LayerSink::sinkAsset(const string& asset) {
if(lmi != NULL) {
ofxLivedrawEngineInterface* engine = lmi->getEngineInterface();
if(engine != NULL) {
AssetManager* assetManager = engine->getAssetManager();
if(assetManager != NULL) {
ofxVideoSourceInterface* src = assetManager->getSourceAsset(asset);
if(src != NULL) {
unsinkAsset(); // release any current ones
src->attachToSink(this);
} else {
ofLogError("LayerSink") << "sinkAsset: " << asset << " was not a valid source.";
}
} else {
ofLogError("LayerSink") << "sinkAsset: AssetManager was NULL.";
}
} else {
ofLogError("LayerSink") << "sinkAsset: ofxLivedrawEngineInterface was NULL.";
}
} else {
ofLogError("LayerSink") << "sinkAsset: LayerManagerInterface was NULL.";
}
}
示例6: Asset
//===========================================
// CreditsMenu::CreditsMenu
//===========================================
CreditsMenu::CreditsMenu(const XmlNode data)
: Asset(internString("CreditsMenu")),
Entity(data.firstChild().firstChild().firstChild()),
Menu(data.firstChild()) {
try {
AssetManager assetManager;
XML_NODE_CHECK(data, CreditsMenu);
XmlNode node = data.nthChild(1);
XML_NODE_CHECK(node, font);
XmlAttribute attr = node.firstAttribute();
XML_ATTR_CHECK(attr, ptr);
long id = attr.getLong();
m_font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(id));
if (!m_font)
throw XmlException("Bad font asset id", __FILE__, __LINE__);
node = node.nextSibling();
XML_NODE_CHECK(node, fadeInTime);
m_fadeInTime = node.getFloat();
}
catch (XmlException& e) {
e.prepend("Error parsing XML for instance of class CreditsMenu; ");
throw;
}
init();
}
示例7: Typeface_createFromAsset
static SkTypeface* Typeface_createFromAsset(JNIEnv* env, jobject,
jobject jassetMgr,
jstring jpath) {
NPE_CHECK_RETURN_ZERO(env, jassetMgr);
NPE_CHECK_RETURN_ZERO(env, jpath);
AssetManager* mgr = assetManagerForJavaObject(env, jassetMgr);
if (NULL == mgr) {
return NULL;
}
AutoJavaStringToUTF8 str(env, jpath);
Asset* asset = mgr->open(str.c_str(), Asset::ACCESS_BUFFER);
if (NULL == asset) {
return NULL;
}
SkStream* stream = new AssetStreamAdaptor(asset,
AssetStreamAdaptor::kYes_OwnAsset,
AssetStreamAdaptor::kYes_HasMemoryBase);
SkTypeface* face = SkTypeface::CreateFromStream(stream);
// SkTypeFace::CreateFromStream calls ref() on the stream, so we
// need to unref it here or it won't be freed later on
stream->unref();
return face;
}
示例8:
Terrain::Terrain(AssetManager &assetmanager,
const std::vector<gamedata::terrain_type> &terrain_meta,
const std::vector<gamedata::blending_mode> &blending_meta,
bool is_infinite)
:
infinite{is_infinite} {
// TODO:
//this->limit_positive =
//this->limit_negative =
// maps chunk position to chunks
this->chunks = std::unordered_map<coord::chunk, TerrainChunk *, coord_chunk_hash>{};
// activate blending
this->blending_enabled = true;
this->terrain_id_count = terrain_meta.size();
this->blendmode_count = blending_meta.size();
this->textures = new Texture*[this->terrain_id_count];
this->blending_masks = new Texture*[this->blendmode_count];
this->terrain_id_priority_map = new int[this->terrain_id_count];
this->terrain_id_blendmode_map = new int[this->terrain_id_count];
this->influences_buf = new struct influence[this->terrain_id_count];
log::dbg("terrain prefs: %lu tiletypes, %lu blendmodes", this->terrain_id_count, this->blendmode_count);
// create tile textures (snow, ice, grass, whatever)
for (size_t i = 0; i < this->terrain_id_count; i++) {
auto line = &terrain_meta[i];
terrain_t terrain_id = line->terrain_id;
this->validate_terrain(terrain_id);
// TODO: terrain double-define check?
this->terrain_id_priority_map[terrain_id] = line->blend_priority;
this->terrain_id_blendmode_map[terrain_id] = line->blend_mode;
// TODO: remove hardcoding and rely on nyan data
char *terraintex_filename = util::format("converted/Data/terrain.drs/%d.slp.png", line->slp_id);
std::string terraintex_filename_str{terraintex_filename};
delete[] terraintex_filename;
auto new_texture = assetmanager.get_texture(terraintex_filename_str);
this->textures[terrain_id] = new_texture;
}
// create blending masks (see doc/media/blendomatic)
for (size_t i = 0; i < this->blendmode_count; i++) {
auto line = &blending_meta[i];
char *mask_filename = util::format("converted/blendomatic.dat/mode%02d.png", line->blend_mode);
std::string mask_filename_str{mask_filename};
delete[] mask_filename;
this->blending_masks[i] = assetmanager.get_texture(mask_filename_str);
}
}
示例9: getElement
BaseMenuScreen::BaseMenuScreen(const SmashData&smashData)
{
AssetManager* assetManager = smashData.getMenuData()->getAssetManager();
img_headerbar_small = assetManager->getTexture("elements/headerbar_small.png");
img_headerbar_full = assetManager->getTexture("elements/headerbar_full.png");
hoverPulseScale = 1;
hoverPulseGrowing = true;
hoverPulseEnabled = false;
hoverPressed = false;
ScreenElement* element = getElement();
backgroundElement = new ImageElement(assetManager->getTexture("backgrounds/main.png"), ImageElement::DISPLAY_ZOOM);
backgroundElement->setLayoutRule(LAYOUTRULE_LEFT, 0, LAYOUTVALUE_RATIO);
backgroundElement->setLayoutRule(LAYOUTRULE_TOP, 0, LAYOUTVALUE_RATIO);
backgroundElement->setLayoutRule(LAYOUTRULE_RIGHT, 1, LAYOUTVALUE_RATIO);
backgroundElement->setLayoutRule(LAYOUTRULE_BOTTOM, 1, LAYOUTVALUE_RATIO);
element->addChildElement(backgroundElement);
headerbarElement = new ImageElement(img_headerbar_full, ImageElement::DISPLAY_ZOOM);
headerbarElement->setLayoutRule(LAYOUTRULE_LEFT, 0.0, LAYOUTVALUE_RATIO);
headerbarElement->setLayoutRule(LAYOUTRULE_TOP, 0.0, LAYOUTVALUE_RATIO);
headerbarElement->setLayoutRule(LAYOUTRULE_RIGHT, 1.0, LAYOUTVALUE_RATIO);
headerbarElement->setLayoutRule(LAYOUTRULE_BOTTOM, 0.134, LAYOUTVALUE_RATIO);
element->addChildElement(headerbarElement);
element->sendChildElementToBack(headerbarElement);
element->sendChildElementToBack(backgroundElement);
backButton = (SpriteActor*)getItem(addItem(RectD(0, 0, 0.145, 0.145), new Animation(1, assetManager, "buttons/back.png")));
}
示例10:
PlayerGraphicsComponent::PlayerGraphicsComponent(const AssetManager& assets, int playerNumber, int animationSpeed)
: animations_(assets.GetPlayer(playerNumber)),
animationsMoving_(assets.GetPlayerMoving(playerNumber)),
animationTime_(0),
isMoving_(false),
animationSpeed_(animationSpeed)
{
}
示例11: load_terrain
void GameSpec::load_terrain(AssetManager &am) {
// Terrain data files
util::Dir *data_dir = am.get_data_dir();
util::Dir asset_dir = data_dir->append("converted");
std::vector<gamedata::string_resource> string_resources;
util::read_csv_file(asset_dir.join("string_resources.docx"), string_resources);
std::vector<gamedata::terrain_type> terrain_meta;
util::read_csv_file(asset_dir.join("gamedata/gamedata-empiresdat/0000-terrains.docx"), terrain_meta);
std::vector<gamedata::blending_mode> blending_meta;
util::read_csv_file(asset_dir.join("blending_modes.docx"), blending_meta);
// remove any disabled textures
terrain_meta.erase(
std::remove_if(terrain_meta.begin(), terrain_meta.end(),
[](const gamedata::terrain_type &t) { return !t.enabled; }),
terrain_meta.end());
// result attributes
terrain_data.terrain_id_count = terrain_meta.size();
terrain_data.blendmode_count = blending_meta.size();
terrain_data.textures.reserve(terrain_data.terrain_id_count);
terrain_data.blending_masks.reserve(terrain_data.blendmode_count);
terrain_data.terrain_id_priority_map = std::make_unique<int[]>(terrain_data.terrain_id_count);
terrain_data.terrain_id_blendmode_map = std::make_unique<int[]>(terrain_data.terrain_id_count);
terrain_data.influences_buf = std::make_unique<struct influence[]>(terrain_data.terrain_id_count);
log::log(MSG(dbg) << "Terrain prefs: " <<
"tiletypes=" << terrain_data.terrain_id_count << ", "
"blendmodes=" << terrain_data.blendmode_count);
// create tile textures (snow, ice, grass, whatever)
for (size_t i = 0; i < terrain_data.terrain_id_count; i++) {
auto line = &terrain_meta[i];
terrain_t terrain_id = i;
// TODO: validate terrain_id < terrain_id_count
// TODO: terrain double-define check?
terrain_data.terrain_id_priority_map[terrain_id] = line->blend_priority;
terrain_data.terrain_id_blendmode_map[terrain_id] = line->blend_mode;
// TODO: remove hardcoding and rely on nyan data
auto terraintex_filename = util::sformat("%s/%d.slp.png", this->terrain_path.c_str(), line->slp_id);
auto new_texture = am.get_texture(terraintex_filename);
terrain_data.textures[terrain_id] = new_texture;
}
// create blending masks (see doc/media/blendomatic)
for (size_t i = 0; i < terrain_data.blendmode_count; i++) {
auto line = &blending_meta[i];
std::string mask_filename = util::sformat("%s/mode%02d.png", this->blend_path.c_str(), line->blend_mode);
terrain_data.blending_masks[i] = am.get_texture(mask_filename);
}
}
示例12: subfileNotification
void MapfileLoadAction::subfileNotification()
{
Logging::log(Logging::DEBUG, "MapfileLoadAction::subfileNotification\r\n");
// Hackish way to notice when all subfiles arrive
AssetManager* manager = AssetManager::getManagerByType(AssetManager::MAPFILE);
if (manager->checkLocalAssetPresence(assetId))
manager->triggerAssetReceived(assetId);
}
示例13: load
/**
* 指定されたサウンドファイルをOpenALに設定します.
* @param fname ファイル名
* @return true: 成功
*/
bool OpenALPlayer::load(const char *fname) {
AssetManager mgr = AssetManager::getInstance();
std::vector<char> *fdata = mgr.open(fname);
if (fdata) {
bool result = load(fdata);
delete fdata;
return result;
}
return false;
}
示例14:
const Shift::Property *Asset::resolve(
const Shift::ExternalPointer *ptr,
const Shift::ExternalPointerInstanceInformation *,
Shift::ExternalPointerInstanceInformation::ResolveResult *res)
{
const Asset *ptrOwner = ptr->parent()->castTo<Asset>();
AssetManager *manager = ptrOwner->manager();
return manager->resolveAsset(ptr->uncheckedCastTo<Shift::ExternalUuidPointer>()->uuid(), res);
}
示例15: mRotation
Block::Block( Game* game ) : mRotation( 0.0f ), mTerrain( NULL ), mGame( game )
{
mNode = new Node();
mNode->colors[ MaterialSpecular ] = ColorA( 0, 0, 0, 0 );
AssetManager* assetManager = AssetManager::get();
tilePosition = Vec3f::zero();
mTextureOffset = Vec2i( 2, 3 );
mNode->scale = Vec3f::one() * kTileSize;
setTerrainIndex( 0 );
mBlankMask = assetManager->getTexture( "textures/default_black.png" );
mTexturePaintMask = NULL;
}