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);
}
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;
}
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;  
}
Esempio n. 4
0
//===========================================
// 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;
   }
}
Esempio n. 5
0
//--------------------------------------------------------------
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.";
    }

}
Esempio n. 6
0
//===========================================
// 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();
}
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;
}
Esempio n. 8
0
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);
	}

}
Esempio n. 9
0
		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")));
		}
PlayerGraphicsComponent::PlayerGraphicsComponent(const AssetManager& assets, int playerNumber, int animationSpeed)
    : animations_(assets.GetPlayer(playerNumber)),
      animationsMoving_(assets.GetPlayerMoving(playerNumber)),
      animationTime_(0),
      isMoving_(false),
      animationSpeed_(animationSpeed)
{
}
Esempio n. 11
0
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);
	}
}
Esempio n. 12
0
	void loadCustomSounds(const string& mPackName, const string& mPath)
	{
		for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>(mPath + "Sounds/", ".ogg"))
		{
			string fileName{getNameFromPath(filePath, mPath + "Sounds/", "")};
			assetManager.loadSound(mPackName + "_" + fileName, filePath);
			assetManager.getSound(mPackName + "_" + fileName).setVolume(getSoundVolume());
		}
	}
Esempio n. 13
0
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);
}
Esempio n. 14
0
/**
 * 指定されたサウンドファイルを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;
}
Esempio n. 15
0
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);
  }
Esempio n. 16
0
void WebRequest::handleBrowserURL(GURL url)
{
    std::string data("data:text/html;charset=utf-8,");
    if (url.spec() == "browser:incognito") {
        AssetManager* assetManager = globalAssetManager();
        Asset* asset = assetManager->open("webkit/incognito_mode_start_page.html", Asset::ACCESS_BUFFER);
        if (asset) {
            data.append((const char*)asset->getBuffer(false), asset->getLength());
            delete asset;
        }
    }
    GURL dataURL(data.c_str());
    handleDataURL(dataURL);
}
Esempio n. 17
0
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;
}
Esempio n. 18
0
Bomb::Bomb(Game& game, const AssetManager& assets, float xPosition, float yPosition, int power)
    : GameObject(Rectangle(xPosition, yPosition, Width, Height), 30),
      game_(game),
      graphics_(assets.GetBombAnimatedSprite(), 10),
      power_(power)
{
}
Esempio n. 19
0
//-----------------------------------------------------------------------
void TrueTypeFont::Impl::LoadFont(AssetManager const& assets, std::string const& fontPath)
{
    auto binaryFile = assets.OpenStream(fontPath);
    if (!binaryFile.Stream) {
        POMDOG_THROW_EXCEPTION(std::runtime_error, "Failed to open file");
    }

    if (binaryFile.SizeInBytes <= 0) {
        POMDOG_THROW_EXCEPTION(std::runtime_error, "The file is too small");
    }

    Reset();

    using Pomdog::Detail::BinaryReader;
    ttfBinary = BinaryReader::ReadArray<std::uint8_t>(binaryFile.Stream, binaryFile.SizeInBytes);

    const auto offset = stbtt_GetFontOffsetForIndex(ttfBinary.data(), 0);
    if (!stbtt_InitFont(&fontInfo, ttfBinary.data(), offset)) {
        ttfBinary.clear();

        // FUS RO DAH
        POMDOG_THROW_EXCEPTION(std::runtime_error,
            "Failed to initialize truetype font");
    }
}
Esempio n. 20
0
void Page::initDictionary()
{
#if ENABLE(SPELLCHECK)	
		if(!m_dictionary)
		{
			AssetManager* assetManager = globalAssetManager();
			m_asset = assetManager->open("webkit/main.dict", Asset::ACCESS_BUFFER);
			void *dict;
			if (m_asset){
				dict = (void*) m_asset->getBuffer(false);
				m_dictionary = new Dictionary(dict, typedLetterMultiplier, fullWordMultiplier);
				m_dictionary->setAsset(m_asset);
				android_printLog(ANDROID_LOG_DEBUG, "Page","Page::initDictionary Dictionary initialisatised sucessfully");
			}
		}
#endif
}
Esempio n. 21
0
Explosion::Explosion(const AssetManager& assets, int xPosition, int yPosition, int power, std::list<GameObject*>& objects, const Map& map)
    : GameObject(Rectangle(xPosition, yPosition, 0, 0), 14),
      parts_()
{
    // Create the explosion parts.

    parts_.push_back(ExplosionPart(assets.GetExplosionCenter(), xPosition, yPosition, 14));

    // Each loop expands in one direction as long as not blocked and as long as the power is not exhausted.
    // Top
    bool block = false;
    for (int i = 1; (i <= power) && (block == false); ++i)
    {
        if (CanExplode(Rectangle(xPosition, yPosition - 48 * i, 48, 48), objects, map, block) == true)
        {
            AnimatedSprite* sprite = (i == power) ? assets.GetExplosionTopEnd() : assets.GetExplosionVertical(); // The final part has its own sprites.
            parts_.push_back(ExplosionPart(sprite, xPosition, yPosition - 48 * i, 14));
        }
    }
    // Right
    block = false;
    for (int i = 1; (i <= power) && (block == false); ++i)
    {
        if (CanExplode(Rectangle(xPosition + 48 * i, yPosition, 48, 48), objects, map, block) == true)
        {
            AnimatedSprite* sprite = (i == power) ? assets.GetExplosionRightEnd() : assets.GetExplosionHorizontal();
            parts_.push_back(ExplosionPart(sprite, xPosition + 48 * i, yPosition, 14));
        }
    }
    // Bottom
    block = false;
    for (int i = 1; (i <= power) && (block == false); ++i)
    {
        if (CanExplode(Rectangle(xPosition, yPosition + 48 * i, 48, 48), objects, map, block) == true)
        {
            AnimatedSprite* sprite = (i == power) ? assets.GetExplosionBottomEnd() : assets.GetExplosionVertical();
            parts_.push_back(ExplosionPart(sprite, xPosition, yPosition + 48 * i, 14));
        }
    }
    // Left
    block = false;
    for (int i = 1; (i <= power) && (block == false); ++i)
    {
        if (CanExplode(Rectangle(xPosition - 48 * i, yPosition, 48, 48), objects, map, block) == true)
        {
            AnimatedSprite* sprite = (i == power) ? assets.GetExplosionLeftEnd() : assets.GetExplosionHorizontal();
            parts_.push_back(ExplosionPart(sprite, xPosition - 48 * i, yPosition, 14));
        }
    }
}
status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
        const char* name) {
    Asset* asset = assets.open(name, Asset::ACCESS_BUFFER);
    if (!asset)
        return NO_INIT;
    SkBitmap bitmap;
    SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(),
            &bitmap, SkBitmap::kNo_Config, SkImageDecoder::kDecodePixels_Mode);
    asset->close();
    delete asset;

    // ensure we can call getPixels(). No need to call unlock, since the
    // bitmap will go out of scope when we return from this method.
    bitmap.lockPixels();

    const int w = bitmap.width();
    const int h = bitmap.height();
    const void* p = bitmap.getPixels();

    GLint crop[4] = { 0, h, w, -h };
    texture->w = w;
    texture->h = h;

    glGenTextures(1, &texture->name);
    glBindTexture(GL_TEXTURE_2D, texture->name);

    switch (bitmap.getConfig()) {
        case SkBitmap::kA8_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA,
                    GL_UNSIGNED_BYTE, p);
            break;
        case SkBitmap::kARGB_4444_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
                    GL_UNSIGNED_SHORT_4_4_4_4, p);
            break;
        case SkBitmap::kARGB_8888_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
                    GL_UNSIGNED_BYTE, p);
            break;
        case SkBitmap::kRGB_565_Config:
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
                    GL_UNSIGNED_SHORT_5_6_5, p);
            break;
        default:
            break;
    }

    glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    return NO_ERROR;
}
Esempio n. 23
0
	void loadMusic(const string& mPath)
	{
		for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>(mPath + "Music/", ".ogg"))
		{
			string fileName{getNameFromPath(filePath, mPath + "Music/", ".ogg")};

			auto& music(assetManager.loadMusic(fileName, filePath));
			music.openFromFile(filePath);
			music.setVolume(getMusicVolume());
			music.setLoop(true);
		}
	}
Esempio n. 24
0
void LoadBitmaps(JavaVM* vm, JNIEnv* env, jobject objActivity)
{
	vm->AttachCurrentThread(&env, NULL);

	BitmapFactory::Options options = BitmapFactory::Options();
	options.set_inScaled(false); // No pre-scaling
	Activity activity = Activity(objActivity);
	Context context = activity.getApplicationContext();
	AssetManager assetManager = context.getAssets();

	String path = String("");
	std::vector<std::string> files = assetManager.list(path);
	for (int index = 0; index < files.size(); ++index)
	{
		__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, files[index].c_str());
	}

	glGenTextures(TEXTURE_COUNT, &textures[0]);

	int textureId = 0;
	g_controller = LoadTexture(env, assetManager, options, "controller.png", textureId);
	g_buttonA = LoadTexture(env, assetManager, options, "a.png", ++textureId);
	g_dpadDown = LoadTexture(env, assetManager, options, "dpad_down.png", ++textureId);
	g_dpadLeft = LoadTexture(env, assetManager, options, "dpad_left.png", ++textureId);
	g_dpadRight = LoadTexture(env, assetManager, options, "dpad_right.png", ++textureId);
	g_dpadUp = LoadTexture(env, assetManager, options, "dpad_up.png", ++textureId);
	g_leftBumper = LoadTexture(env, assetManager, options, "lb.png", ++textureId);
	g_leftTrigger = LoadTexture(env, assetManager, options, "lt.png", ++textureId);
	g_leftStickInactive = LoadTexture(env, assetManager, options, "l_stick.png", ++textureId);
	g_buttonO = LoadTexture(env, assetManager, options, "o.png", ++textureId);
	g_rightBumper = LoadTexture(env, assetManager, options, "rb.png", ++textureId);
	g_rightTrigger = LoadTexture(env, assetManager, options, "rt.png", ++textureId);
	g_rightStickInactive = LoadTexture(env, assetManager, options, "r_stick.png", ++textureId);
	g_leftStickActive = LoadTexture(env, assetManager, options, "thumbl.png", ++textureId);
	g_rightStickActive = LoadTexture(env, assetManager, options, "thumbr.png", ++textureId);
	g_buttonU = LoadTexture(env, assetManager, options, "u.png", ++textureId);
	g_buttonY = LoadTexture(env, assetManager, options, "y.png", ++textureId);

	__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Loaded %d textures", textureId + 1);
}
void GraphicsManager::DrawWorld()
{ // Draws the game world but calling all of the appropriate draw functions
  AssetManager* pMyAM = AssetManager::GetInstance();
  if (!pMyAM->theBoard->bankerOffer) // If no banker off active draw normally
  {
    theCamera->Process();
    glPushMatrix();
    pMyAM->theMap->DrawData();
    glPopMatrix();
    glPushMatrix();
    pMyAM->theBoard->DrawBoard();
    glPopMatrix();
    glPushMatrix();
    glTranslatef(63, -3, 63);
    pMyAM->DrawModel(MODEL_FLOOR, TEX_FLOOR);
    glTranslatef(0, 6, 0);
    glRotatef(180, 1, 0, 0);
    pMyAM->DrawModel(MODEL_FLOOR, TEX_CEILING);
    glPopMatrix();
    pMyAM->theBoard->CheckBox();
  }
  else                          // else draw end game or banker offer
  {
    pHUD->StartHUD();
    if (pMyAM->theBoard->endGame)
    {
      pHUD->DisplayWin();
    }
    else
    {
      pHUD->DisplayOffer();
    }
    pHUD->StopHUD();
  }

  pHUD->StartHUD(); // Starts and stops the drawing for the HUD to the screen
  pHUD->DisplayHUD();
  pHUD->StopHUD();
} // DrawWorld()
Esempio n. 26
0
//===========================================
// TextEntity::TextEntity
//===========================================
TextEntity::TextEntity(const XmlNode data)
   : Asset(internString("TextEntity")),
     Entity(data.firstChild()),
     m_renderer(Renderer::getInstance()),
     m_model(Renderer::TRIANGLES) {

   try {
      XML_NODE_CHECK(data, TextEntity);

      XmlNode node = data.nthChild(1);
      XML_NODE_CHECK(node, font);

      XmlAttribute attr = node.firstAttribute();
      XML_ATTR_CHECK(attr, ptr);
      long fontId = attr.getLong();

      AssetManager assetManager;
      pFont_t font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(fontId));

      if (!font)
         throw XmlException("Bad asset id", __FILE__, __LINE__);

      m_font = font;

      node = node.nextSibling();
      XML_NODE_CHECK(node, textSize);
      m_size = Vec2f(node.firstChild());

      node = node.nextSibling();
      XML_NODE_CHECK(node, text);
      setText(node.getString());
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class TextEntity; ");
      throw;
   }
}
Esempio n. 27
0
//===========================================
// TextEntity::assignData
//===========================================
void TextEntity::assignData(const XmlNode data) {
   try {
      if (data.isNull() || data.name() != "TextEntity") return;

      XmlNode node = data.nthChild(1);
      if (!node.isNull() && node.name() == "font") {

         XmlAttribute attr = node.firstAttribute();
         if (!attr.isNull() && attr.name() == "ptr") {
            long fontId = attr.getLong();

            AssetManager assetManager;
            pFont_t font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(fontId));

            if (!font)
               throw XmlException("Bad asset id", __FILE__, __LINE__);

            m_font = font;
         }

         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "textSize") {
         m_size = Vec2f(node.firstChild());
         node = node.nextSibling();
      }

      XML_NODE_CHECK(node, text);
      setText(node.getString());
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class TextEntity; ");
      throw;
   }
}
void Gameboard::DrawBoard()
{ // Draws the gameboard into the world
  int texCount = 4;
  AssetManager* pMyAM = AssetManager::GetInstance();
  glTranslatef(6, 0, 10);
  glRotatef(45, 0, 1, 0);
  // Draws the left side of the game board
  pMyAM->DrawModel(MODEL_BOARD_SIDE, TEX_WOOD);
  glTranslatef(1.24, 2.5, -0.01);

  for (int i = 0; i < 2; i++)
  {
    for (int j = 0; j < 11; j++)
    {
      if (!theNotices[texCount-4]->isOpened)
      { // If the notice is opened draw black instead of the cash amount
        pMyAM->DrawModel(MODEL_CASH_NOTICE, texCount);
      }
      else
      {
        pMyAM->DrawModel(MODEL_CASH_NOTICE, TEX_BLACK);
      }
      glTranslatef(0, -0.5, 0);
      texCount++;
    }
    glTranslatef(2, 5.5, 0);
    if(texCount <= 17)
    {
      for (int k = 0; k < 11; k++)
      { // Draws the right side of the notices
        pMyAM->DrawModel(MODEL_CASH_NOTICE, TEX_BLACK);
        glTranslatef(0, -0.5, 0);
      }
      glTranslatef(2, 5.5, 0);
    }
  }
  // Draws the right side, top and bottom of the game board
  glTranslatef(-0.75, -2.5, 0);
  pMyAM->DrawModel(MODEL_BOARD_SIDE, TEX_WOOD);
  glTranslatef(-3.25, -3, 0);
  pMyAM->DrawModel(MODEL_BOARD_BOTTOM, TEX_WOOD);
  glTranslatef(0, 6, 0);
  pMyAM->DrawModel(MODEL_BOARD_BOTTOM, TEX_WOOD);
} // DrawBoard()
Esempio n. 29
0
ParticleClip ParticleLoader::LoadFromJson(AssetManager & assets, std::string const& assetName)
{
    POMDOG_ASSERT(!assetName.empty());

    using Detail::BinaryReader;

    auto binaryFile = assets.OpenStream(assetName);

    if (!binaryFile.Stream) {
        POMDOG_THROW_EXCEPTION(std::runtime_error, "Failed to open file");
    }

    if (binaryFile.SizeInBytes <= 0) {
        POMDOG_THROW_EXCEPTION(std::runtime_error, "The file is too small");
    }

    auto json = BinaryReader::ReadString<char>(binaryFile.Stream, binaryFile.SizeInBytes);
    POMDOG_ASSERT(!json.empty());

    if (json.empty()) {
        POMDOG_THROW_EXCEPTION(std::runtime_error, "The file is too small");
    }

    rapidjson::Document doc;
    doc.Parse(json.data());

    if (doc.HasParseError() || !doc.IsObject() || doc.MemberBegin() == doc.MemberEnd()) {
        // FUS RO DAH
        POMDOG_THROW_EXCEPTION(std::runtime_error, "Failed to parse JSON");
    }

    auto member = doc.MemberBegin();

    if (!member->name.IsString() || !member->value.IsObject()) {
        // FUS RO DAH
        POMDOG_THROW_EXCEPTION(std::runtime_error, "Invalid file format");
    }

    POMDOG_ASSERT(member->name.IsString());
    POMDOG_ASSERT(member->value.IsObject());

    return ReadParticleClip(member->value);
}
Esempio n. 30
0
int LoadTexture(JNIEnv* env, AssetManager& assetManager, const BitmapFactory::Options& options, const char* texturePath, int textureId)
{
	String strController = String(texturePath);
	InputStream stream = assetManager.open(strController);
	Bitmap bitmap = BitmapFactory::decodeStream(stream, 0, options);
	stream.close();
	int width = bitmap.getWidth();
	int height = bitmap.getHeight();
	__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Loaded %s bitmap width=%d height=%d", texturePath, width, height);

	AndroidBitmapInfo info = AndroidBitmapInfo();
	AndroidBitmap_getInfo(env, bitmap.GetInstance(), &info);
	__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "info.width=%d", info.width);
	__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "info.height=%d", info.height);
	__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "info.stride=%d", info.stride);
	__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "info.format=%d", info.format);
	__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "info.flags=%d", info.flags);

	if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
		__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Bitmap format is not RGBA_8888! %s", texturePath);
		return -1;
	}

	glBindTexture(GL_TEXTURE_2D, textures[textureId]);
	__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "glBindTexture=%d", textures[textureId]);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	android_opengl_GLUtils::GLUtils::texImage2D(GL_TEXTURE_2D, 0, bitmap.GetInstance(), 0);

	bitmap.recycle();

	return textureId;
}