コード例 #1
0
ファイル: Renderer.cpp プロジェクト: JERlabs/JERonimo
 const bool Renderer::doesRenderToTexture() const
 {
     if(!isLoaded())
         return false;
     return bool(getInfo()->flags & SDL_RENDERER_TARGETTEXTURE);
 }
コード例 #2
0
ファイル: creatureui.cpp プロジェクト: AdamSC1-ddg/yatc
void CreatureUI::Blit(int x, int y, float scale, int map_x, int map_y) const
{
    if (!m_obj)
		return;

	if(map_x != 0 && map_y != 0) {
		x = x - std::floor(m_obj->xOffset * scale);
		y = y - std::floor(m_obj->yOffset * scale);
	}
	else {
		// shrink larger creatures to be 32x32
		scale *= (32.f/(float)m_obj->rendersize);
	}

    if (!isLoaded()) {
        printf("Not loaded!\n");
        return;
    }

    uint32_t activeframe = 0;

    uint32_t spriteSize, partSize, aniSize;
	spriteSize = m_obj->width * m_obj->height * m_obj->blendframes;
	partSize = spriteSize * m_obj->xdiv;
	aniSize = partSize * m_obj->ydiv;

	Creature* n = (Creature*)this;

    if(n->getOutfit().m_looktype != 0){
    	if(map_x != 0 && map_y != 0)
			activeframe = ((m_walkState == 1. && !isPreWalking()) ? n->getTurnDir() :  n->getLookDir()) * spriteSize; // creature must have different turning direction and looking (moving) direction... if moving, moving direction takes precendence, if standing, turning direction takes precendence
		else
			activeframe = DIRECTION_SOUTH * spriteSize;
    }


	float walkoffx = 0.f, walkoffy = 0.f;
	if(map_x != 0 && map_y != 0) {
		getWalkOffset(walkoffx, walkoffy, scale);
	}

	//for(uint32_t k = 0; k < m_obj->blendframes; ++k){ // note: if it's anything except item, there won't be blendframes...
	{
	    uint32_t aframes;
	    if(m_obj->animcount == 3 && (map_x != 0 && map_y != 0)){
			aframes = aniSize * (m_walkState == 1. ? 0 : (((int)(m_walkState*100) / 25) % 2 + 1));
		}
	    else if(m_obj->idleAnim){
		    // TODO (nfries88): all appearances that animate while idle.
		    //aframes = 0;
            uint32_t animationTime = (g_frameTime - m_startTime)/100;
            aframes = 0;/*(map_x % m_obj->xdiv + (map_y % m_obj->ydiv)*m_obj->xdiv +
					(animationTime % m_obj->animcount)*m_obj->xdiv*m_obj->ydiv)*
					spriteSize;*/
		}
		else if(n->getOutfit().m_looktype == 0 && n->getOutfit().m_lookitem == 0){
		    uint32_t animationTime = (g_frameTime - m_startTime)/100;
            aframes = (map_x % m_obj->xdiv + (map_y % m_obj->ydiv)*m_obj->xdiv +
					(animationTime % m_obj->animcount)*m_obj->xdiv*m_obj->ydiv)*
					spriteSize;
            activeframe = 0;
		}
		else {
		    aframes = 0;
		}

		//Square around the creature
		if(g_frameTime - n->getSquareStart() < 1000){
			g_engine->drawRectangleLines(x + walkoffx, y + walkoffy, 32*scale, 32*scale, oRGBA(0,0,0,0));
		}

		//Red square around the attacked creature
		if(n->getID() == GlobalVariables::getAttackID()) {
			// "Faded Red" - right color. (Verified)
			g_engine->drawRectangleLines((x+1) + walkoffx, (y+1) + walkoffy, 32*scale, 32*scale, oRGBA(224, 64, 64, 255), 2*scale);
		}
		//Green square around the followed creature
		else if(n->getID() == GlobalVariables::getFollowID()) {
			// "Light Green" - right color. (Verified)
			g_engine->drawRectangleLines((x+2) + walkoffx, (y+2) + walkoffy, 32*scale, 32*scale, oRGBA(64, 224, 64, 255), 2*scale);
		}

		// "Creature Squares" sent by the server
		if((map_x != 0 && map_y != 0) && (n->getSquareStart() + 1000) >= g_frameTime)
		{
			g_engine->drawRectangleLines(x + walkoffx, y + walkoffy, 34*scale, 34*scale, n->getSquareColor(), 2*scale);
		}

		for(uint32_t i = 0; i < m_obj->height; ++i){
			for(uint32_t j = 0; j < m_obj->width; ++j){

				ASSERT(activeframe + aframes < m_obj->numsprites);

				int draw_x = (int)(x - j*32*scale + walkoffx);
				int draw_y = (int)(y - i*32*scale + walkoffy);

                if (m_gfx[activeframe + aframes])
                    m_gfx[activeframe + aframes]->Blit(draw_x, draw_y, 0, 0, 32, 32, 32*scale, 32*scale);
                else
                    printf("Warning: rendering creature failed since sprite %d is NULL\n", activeframe+aframes);

                if(m_obj->ydiv != 1){
                	if(n->getOutfit().m_addons & 1){
                    	m_gfx[activeframe + partSize + aframes]->Blit(draw_x, draw_y, 0, 0, 32, 32, 32*scale, 32*scale);
                	}
                	if(n->getOutfit().m_addons & 2){
                    	m_gfx[activeframe + partSize*2 + aframes]->Blit(draw_x, draw_y, 0, 0, 32, 32, 32*scale, 32*scale);
                	}
                }

				activeframe++;
			}
		}
	}
}
コード例 #3
0
// Deletes shader and frees memory in GPU.
void CShader::deleteShader()
{
	if(!isLoaded())return;
	bLoaded = false;
	glDeleteShader(uiShader);
}
unsigned long ofxTLDepthImageSequence::getDurationInMillis(){
	if(!isLoaded()) return 0;
	return depthImageSequence->getDurationInMillis();
}
void ofxTLDepthImageSequence::update(ofEventArgs& args){
	if(isLoaded() && getAutoUpdate()){
		selectTimeInMillis( timeline->getCurrentTimeMillis() );
	}
}
コード例 #6
0
void CityRegionImplementation::notifyEnter(SceneObject* object) {
	if (object->getCityRegion().get() != _this.getReferenceUnsafeStaticCast() && object->isPlayerCreature())
		currentPlayers.increment();

	object->setCityRegion(_this.getReferenceUnsafeStaticCast());

	if (object->isBazaarTerminal() || object->isVendor()) {

		if (object->isBazaarTerminal())
			bazaars.put(object->getObjectID(), cast<TangibleObject*>(object));

		AuctionTerminalDataComponent* terminalData = NULL;
		DataObjectComponentReference* data = object->getDataObjectComponent();
		if(data != NULL && data->get() != NULL && data->get()->isAuctionTerminalData())
			terminalData = cast<AuctionTerminalDataComponent*>(data->get());

		if(terminalData != NULL)
			terminalData->updateUID();
	}

	if (isClientRegion())
		return;

	if (object->isCreatureObject()) {
		CreatureObject* creature = cast<CreatureObject*>(object);

		StringIdChatParameter params("city/city", "city_enter_city"); //You have entered %TT (%TO).
		params.setTT(getRegionName());

		UnicodeString strRank = StringIdManager::instance()->getStringId(String("@city/city:rank" + String::valueOf(cityRank)).hashCode());

		if (citySpecialization.isEmpty()) {
			params.setTO(strRank);
		}
		else {
			UnicodeString citySpec = StringIdManager::instance()->getStringId(citySpecialization.hashCode());
			params.setTO(strRank + ", " + citySpec);
		}

		creature->sendSystemMessage(params);

		applySpecializationModifiers(creature);
	}

	if (object->isStructureObject()) {
		StructureObject* structure = cast<StructureObject*>(object);
		CityManager* cityManager = getZone()->getZoneServer()->getCityManager();

		Locker slocker(&structureListMutex);

		if (isLoaded() && !completeStructureList.contains(structure->getObjectID()) && structure->getBaseMaintenanceRate() > 0) {
			cityManager->sendAddStructureMails(_this.getReferenceUnsafeStaticCast(), structure);
		}

		if (structure->isBuildingObject()) {

			BuildingObject* building = cast<BuildingObject*>(object);
			uint64 ownerID = structure->getOwnerObjectID();

			ManagedReference<CreatureObject*> owner = zone->getZoneServer()->getObject(ownerID).castTo<CreatureObject*>();

			if(owner != NULL && owner->isPlayerCreature() && building->isResidence() && !isCitizen(ownerID)) {
				cityManager->registerCitizen(_this.getReferenceUnsafeStaticCast(), owner);
			}
		 }

		completeStructureList.put(structure->getObjectID());

		if (structure->isCivicStructure() && !structure->isDecoration()) {
			addStructure(structure);
		} else if (structure->isCommercialStructure()) {
			addCommercialStructure(structure);
		}

		if (registered) {
			zone->registerObjectWithPlanetaryMap(structure);
		}
	}

	if (object->isDecoration() && object->getParent().get() == NULL) {
		addDecoration(object);
	}

	if (registered && cityMissionTerminals.contains(object)) {
		zone->registerObjectWithPlanetaryMap(object);
	}

	if (!registered && citySkillTrainers.contains(object)) {
		zone->unregisterObjectWithPlanetaryMap(object);
	}
}
unsigned long ofxTLDepthImageSequence::getSelectedTimeInMillis(){
	if(!isLoaded()) return 0;
	return depthImageSequence->getCurrentMilliseconds();
}
コード例 #8
0
ファイル: CSSFontFaceSource.cpp プロジェクト: dslab-epfl/warr
SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
{
    // If the font hasn't loaded or an error occurred, then we've got nothing.
    if (!isValid())
        return 0;

#if ENABLE(SVG_FONTS)
    if (!m_font && !m_svgFontFaceElement) {
#else
    if (!m_font) {
#endif
        SimpleFontData* fontData = fontCache()->getCachedFontData(fontDescription, m_string);

        // We're local. Just return a SimpleFontData from the normal cache.
        return fontData;
    }

    // See if we have a mapping in our FontData cache.
    unsigned hashKey = fontDescription.computedPixelSize() << 3 | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);
    if (SimpleFontData* cachedData = m_fontDataTable.get(hashKey))
        return cachedData;

    OwnPtr<SimpleFontData> fontData;

    // If we are still loading, then we let the system pick a font.
    if (isLoaded()) {
        if (m_font) {
#if ENABLE(SVG_FONTS)
            if (m_font->isSVGFont()) {
                // For SVG fonts parse the external SVG document, and extract the <font> element.
                if (!m_font->ensureSVGFontData())
                    return 0;

                if (!m_externalSVGFontElement)
                    m_externalSVGFontElement = m_font->getSVGFontById(SVGURIReference::getTarget(m_string));

                if (!m_externalSVGFontElement)
                    return 0;

                SVGFontFaceElement* fontFaceElement = 0;

                // Select first <font-face> child
                for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
                    if (fontChild->hasTagName(SVGNames::font_faceTag)) {
                        fontFaceElement = static_cast<SVGFontFaceElement*>(fontChild);
                        break;
                    }
                }

                if (fontFaceElement) {
                    if (!m_svgFontFaceElement) {
                        // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
                        // Use the imported <font-face> tag as referencing font-face element for these cases.
                        m_svgFontFaceElement = fontFaceElement;
                    }

                    fontData.set(new SimpleFontData(adoptPtr(new SVGFontData(fontFaceElement)), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));
                }
            } else
#endif
            {
                // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
                if (!m_font->ensureCustomFontData())
                    return 0;

                fontData.set(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.orientation(), fontDescription.renderingMode()), true, false));
            }
        } else {
#if ENABLE(SVG_FONTS)
            // In-Document SVG Fonts
            if (m_svgFontFaceElement)
                fontData.set(new SimpleFontData(adoptPtr(new SVGFontData(m_svgFontFaceElement)), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));
#endif
        }
    } else {
        // Kick off the load now.
        if (CachedResourceLoader* cachedResourceLoader = fontSelector->cachedResourceLoader())
            m_font->beginLoadIfNeeded(cachedResourceLoader);
        // FIXME: m_string is a URL so it makes no sense to pass it as a family name.
        SimpleFontData* tempData = fontCache()->getCachedFontData(fontDescription, m_string);
        if (!tempData)
            tempData = fontCache()->getLastResortFallbackFont(fontDescription);

        fontData.set(new SimpleFontData(tempData->platformData(), true, true));
    }

    SimpleFontData* fontDataRawPtr = fontData.leakPtr();
    m_fontDataTable.set(hashKey, fontDataRawPtr);

    return fontDataRawPtr;
}

#if ENABLE(SVG_FONTS)
bool CSSFontFaceSource::isSVGFontFaceSource() const
{
    return m_svgFontFaceElement || (m_font && m_font->isSVGFont());
}
#endif

}
コード例 #9
0
void WAbstractToggleButton::setNoFormData()
{
  if (isLoaded() && isEnabled())
    checked_ = false;
}
コード例 #10
0
ファイル: raids.cpp プロジェクト: ChubNtuck/avesta74
bool Raid::loadFromXml(const std::string& _filename)
{
	if(isLoaded()){
		return true;
	}

    filename = _filename;
	xmlDocPtr doc = xmlParseFile(_filename.c_str());

	if(doc){
		xmlNodePtr root, eventNode;
		root = xmlDocGetRootElement(doc);

		if(xmlStrcmp(root->name,(const xmlChar*)"raid") != 0){
			std::cout << "[Error] Raids: Wrong root node." << std::endl;
			xmlFreeDoc(doc);
			return false;
		}

		std::string strValue;

		eventNode = root->children;
		while(eventNode){
			RaidEvent* event;
			if(xmlStrcmp(eventNode->name, (const xmlChar*)"announce") == 0){
				event = new AnnounceEvent();
			}
			else if(xmlStrcmp(eventNode->name, (const xmlChar*)"singlespawn") == 0){
				event = new SingleSpawnEvent();
			}
			else if(xmlStrcmp(eventNode->name, (const xmlChar*)"areaspawn") == 0){
				event = new AreaSpawnEvent();
			}
			else if(xmlStrcmp(eventNode->name, (const xmlChar*)"script") == 0){
				event = new ScriptEvent();
			}
			else{
				eventNode = eventNode->next;
				continue;
			}

			if(event->configureRaidEvent(eventNode)){
				raidEvents.push_back(event);
			}
			else{
				std::cout << "Raids: Error in file(" << _filename <<") eventNode: " << eventNode->name << std::endl;
				delete event;
			}
			eventNode = eventNode->next;
		}

		//sort by delay time
		std::sort(raidEvents.begin(), raidEvents.end(), RaidEvent::compareEvents);

		xmlFreeDoc(doc);
	}
	else{
		std::cout << "[Error] Raid: Could not load " << _filename << "!" << std::endl;
		return false;
	}

	loaded = true;
	return true;
}
コード例 #11
0
ファイル: raids.cpp プロジェクト: ChubNtuck/avesta74
bool Raids::loadFromXml(const std::string& _filename)
{
	if(isLoaded()){
		return true;
	}

	filename = _filename;

	xmlDocPtr doc = xmlParseFile(filename.c_str());

	if(doc){
		xmlNodePtr root, raidNode;
		root = xmlDocGetRootElement(doc);

		if(xmlStrcmp(root->name,(const xmlChar*)"raids") != 0){
			std::cout << "[Error] Raids: Wrong root node." << std::endl;
			xmlFreeDoc(doc);
			return false;
		}

		int intValue;
		std::string strValue;

		raidNode = root->children;
		while(raidNode){
			if(xmlStrcmp(raidNode->name, (const xmlChar*)"raid") == 0){
				std::string name, file;
				uint32_t interval, margin;

				if(readXMLString(raidNode, "name", strValue)){
					name = strValue;
				}
				else{
					std::cout << "[Error] Raids: name tag missing for raid." << std::endl;
					raidNode = raidNode->next;
					continue;
				}

				if(readXMLString(raidNode, "file", strValue)){
					file = strValue;
				}
				else{
					std::stringstream ss;
					ss << "raids/" << name << ".xml";
					file = ss.str();
					std::cout << "[Warning] Raids: file tag missing for raid " << name << ". Using default: " << file << std::endl;
				}

				//interval2 is the average interval between
				// 2 executions of the raid in minutes
				if(readXMLInteger(raidNode, "interval2", intValue)){
					interval = intValue * 60; //transform  to seconds
				}
				else{
					std::cout << "[Error] Raids: interval2 tag missing for raid " << name << std::endl;
					raidNode = raidNode->next;
					continue;
				}

				if(readXMLInteger(raidNode, "margin", intValue)){
					margin = intValue * 60 * 1000; //transform to milliseconds
				}
				else{
					std::cout << "[Warning] Raids: margin tag missing for raid " << name << std::endl;
					margin = 0;
				}

				Raid* newRaid = new Raid(name, interval, margin);
				if(!newRaid){
					xmlFreeDoc(doc);
					return false;
				}

				bool ret = newRaid->loadFromXml(g_config.getString(ConfigManager::DATA_DIRECTORY) + "raids/" + file);
				if(!ret){
					std::cout << "[Error] Raids: failed to load raid " << name << std::endl;
					delete newRaid;
				}
				else{
					raidList.push_back(newRaid);
				}
			}

			raidNode = raidNode->next;
		}

		xmlFreeDoc(doc);

	}
	else{
		std::cout << "[Error] Raids: Could not load " << filename << std::endl;
		return false;
	}

	loaded = true;
	return true;
}
コード例 #12
0
bool ofGstVideoUtils::isInitialized() const{
	return isLoaded();
}
コード例 #13
0
void FontResource::willUseFontData()
{
    if (!isLoaded())
        m_histograms.willUseFontData();
}
コード例 #14
0
ファイル: Renderer.cpp プロジェクト: JERlabs/JERonimo
 const Uint32 Renderer::getNumTextureFormats() const
 {
     if(!isLoaded())
         return 0;
     return getInfo()->num_texture_formats;
 }
コード例 #15
0
ファイル: FreeImage.cpp プロジェクト: Oriode/Simplepp
	void FreeImage::setFlipY( bool value ) {
		if ( isLoaded() && value != this -> invertY ) {
			FreeImage_FlipVertical( this -> freeImage );
		}
		this -> invertY = value;
	}
コード例 #16
0
PassRefPtr<CustomFilterCompiledProgram> CustomFilterProgram::compileProgramWithContext(GraphicsContext3D* context)
{
    ASSERT(isLoaded());
    return CustomFilterCompiledProgram::create(context, vertexShaderString(), fragmentShaderString());
}
コード例 #17
0
ファイル: raids.cpp プロジェクト: milbradt/TFS
bool Raid::loadFromXml(const std::string& _filename)
{
	if(isLoaded())
		return true;

	xmlDocPtr doc = xmlParseFile(_filename.c_str());
	if(!doc)
	{
		std::clog << "[Error - Raid::loadFromXml] Could not load raid file (" << _filename << ")." << std::endl;
		std::clog << getLastXMLError() << std::endl;
		return false;
	}

	xmlNodePtr root, eventNode;
	root = xmlDocGetRootElement(doc);
	if(xmlStrcmp(root->name,(const xmlChar*)"raid"))
	{
		std::clog << "[Error - Raid::loadFromXml] Malformed raid file (" << _filename << ")." << std::endl;
		xmlFreeDoc(doc);
		return false;
	}

	std::string strValue;
	eventNode = root->children;
	while(eventNode)
	{
		RaidEvent* event;
		if(!xmlStrcmp(eventNode->name, (const xmlChar*)"announce"))
			event = new AnnounceEvent(this, ref);
		else if(!xmlStrcmp(eventNode->name, (const xmlChar*)"effect"))
			event = new EffectEvent(this, ref);
		else if(!xmlStrcmp(eventNode->name, (const xmlChar*)"itemspawn"))
			event = new ItemSpawnEvent(this, ref);
		else if(!xmlStrcmp(eventNode->name, (const xmlChar*)"singlespawn"))
			event = new SingleSpawnEvent(this, ref);
		else if(!xmlStrcmp(eventNode->name, (const xmlChar*)"areaspawn"))
			event = new AreaSpawnEvent(this, ref);
		else if(!xmlStrcmp(eventNode->name, (const xmlChar*)"script"))
			event = new ScriptEvent(this, ref);
		else
		{
			eventNode = eventNode->next;
			continue;
		}

		if(!event->configureRaidEvent(eventNode))
		{
			std::clog << "[Error - Raid::loadFromXml] Could not configure raid in file: " << _filename << ", eventNode: " << eventNode->name << std::endl;
			delete event;
		}
		else
			raidEvents.push_back(event);

		eventNode = eventNode->next;
	}

	//sort by delay time
	std::sort(raidEvents.begin(), raidEvents.end(), RaidEvent::compareEvents);
	xmlFreeDoc(doc);

	loaded = true;
	return true;
}
コード例 #18
0
PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription)
{
    // If the font hasn't loaded or an error occurred, then we've got nothing.
    if (!isValid())
        return 0;

    if (isLocal()) {
        // We're local. Just return a SimpleFontData from the normal cache.
        // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
        RefPtr<SimpleFontData> fontData = FontCache::fontCache()->getFontData(fontDescription, m_string, true);
        m_histograms.recordLocalFont(fontData);
        return fontData;
    }

    // See if we have a mapping in our FontData cache.
    AtomicString emptyFontFamily = "";
    FontCacheKey key = fontDescription.cacheKey(emptyFontFamily);

    RefPtr<SimpleFontData>& fontData = m_fontDataTable.add(key.hash(), 0).iterator->value;
    if (fontData)
        return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.

    // If we are still loading, then we let the system pick a font.
    if (isLoaded()) {
        if (m_font) {
#if ENABLE(SVG_FONTS)
            if (m_hasExternalSVGFont) {
                // For SVG fonts parse the external SVG document, and extract the <font> element.
                if (!m_font->ensureSVGFontData())
                    return 0;

                if (!m_externalSVGFontElement) {
                    String fragmentIdentifier;
                    size_t start = m_string.find('#');
                    if (start != kNotFound)
                        fragmentIdentifier = m_string.string().substring(start + 1);
                    m_externalSVGFontElement = m_font->getSVGFontById(fragmentIdentifier);
                }

                if (!m_externalSVGFontElement)
                    return 0;

                SVGFontFaceElement* fontFaceElement = 0;

                // Select first <font-face> child
                for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
                    if (fontChild->hasTagName(SVGNames::font_faceTag)) {
                        fontFaceElement = toSVGFontFaceElement(fontChild);
                        break;
                    }
                }

                if (fontFaceElement) {
                    if (!m_svgFontFaceElement) {
                        // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
                        // Use the imported <font-face> tag as referencing font-face element for these cases.
                        m_svgFontFaceElement = fontFaceElement;
                    }

                    fontData = SimpleFontData::create(
                        SVGFontData::create(fontFaceElement),
                        fontDescription.effectiveFontSize(),
                        fontDescription.isSyntheticBold(),
                        fontDescription.isSyntheticItalic());
                }
            } else
#endif
            {
                // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
                if (!m_font->ensureCustomFontData())
                    return 0;

                fontData = SimpleFontData::create(
                    m_font->platformDataFromCustomData(fontDescription.effectiveFontSize(),
                        fontDescription.isSyntheticBold(), fontDescription.isSyntheticItalic(),
                        fontDescription.orientation(), fontDescription.widthVariant()), CustomFontData::create(false));
            }
        } else {
#if ENABLE(SVG_FONTS)
            // In-Document SVG Fonts
            if (m_svgFontFaceElement) {
                fontData = SimpleFontData::create(
                    SVGFontData::create(m_svgFontFaceElement.get()),
                    fontDescription.effectiveFontSize(),
                    fontDescription.isSyntheticBold(),
                    fontDescription.isSyntheticItalic());
            }
#endif
        }
    } else {
        // This temporary font is not retained and should not be returned.
        FontCachePurgePreventer fontCachePurgePreventer;
        SimpleFontData* temporaryFont = FontCache::fontCache()->getNonRetainedLastResortFallbackFont(fontDescription);
        if (!temporaryFont) {
            ASSERT_NOT_REACHED();
            return 0;
        }
        RefPtr<CSSCustomFontData> cssFontData = CSSCustomFontData::create(true);
        cssFontData->setCSSFontFaceSource(this);
        fontData = SimpleFontData::create(temporaryFont->platformData(), cssFontData);
    }

    return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.
}
コード例 #19
0
PassRefPtr<SimpleFontData> CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
{
    // If the font hasn't loaded or an error occurred, then we've got nothing.
    if (!isValid())
        return 0;

    if (!m_font
#if ENABLE(SVG_FONTS)
            && !m_svgFontFaceElement
#endif
    ) {
        // We're local. Just return a SimpleFontData from the normal cache.
        // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter.
        return fontCache()->getCachedFontData(fontDescription, m_string, true);
    }

    // See if we have a mapping in our FontData cache.
    unsigned hashKey = (fontDescription.computedPixelSize() + 1) << 5 | fontDescription.widthVariant() << 3
                       | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);

    RefPtr<SimpleFontData>& fontData = m_fontDataTable.add(hashKey, 0).iterator->value;
    if (fontData)
        return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.

    // If we are still loading, then we let the system pick a font.
    if (isLoaded()) {
        if (m_font) {
#if ENABLE(SVG_FONTS)
            if (m_hasExternalSVGFont) {
                // For SVG fonts parse the external SVG document, and extract the <font> element.
                if (!m_font->ensureSVGFontData())
                    return 0;

                if (!m_externalSVGFontElement) {
                    String fragmentIdentifier;
                    size_t start = m_string.find('#');
                    if (start != notFound)
                        fragmentIdentifier = m_string.string().substring(start + 1);
                    m_externalSVGFontElement = m_font->getSVGFontById(fragmentIdentifier);
                }

                if (!m_externalSVGFontElement)
                    return 0;

                if (auto fontFaceElement = Traversal<SVGFontFaceElement>::firstChild(m_externalSVGFontElement.get())) {
                    if (!m_svgFontFaceElement) {
                        // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
                        // Use the imported <font-face> tag as referencing font-face element for these cases.
                        m_svgFontFaceElement = fontFaceElement;
                    }

                    fontData = SimpleFontData::create(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
                }
            } else
#endif
            {
                // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
                if (!m_font->ensureCustomFontData())
                    return 0;

                fontData = SimpleFontData::create(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic,
                    fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false);
            }
        } else {
#if ENABLE(SVG_FONTS)
            // In-Document SVG Fonts
            if (m_svgFontFaceElement)
                fontData = SimpleFontData::create(SVGFontData::create(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
#endif
        }
    } else {
        // Kick off the load. Do it soon rather than now, because we may be in the middle of layout,
        // and the loader may invoke arbitrary delegate or event handler code.
        fontSelector->beginLoadingFontSoon(m_font.get());

        // This temporary font is not retained and should not be returned.
        FontCachePurgePreventer fontCachePurgePreventer;
        SimpleFontData* temporaryFont = fontCache()->getNonRetainedLastResortFallbackFont(fontDescription);
        fontData = SimpleFontData::create(temporaryFont->platformData(), true, true);
    }

    return fontData; // No release, because fontData is a reference to a RefPtr that is held in the m_fontDataTable.
}
コード例 #20
0
	//-----------------------------------------------------------------------
	void PagingLandScapePage::load()
	{
		touch();

		if (isLoaded()) {
			S_LOG_WARNING("PagingLandScapePage at (" << mTableX << ", " << mTableZ << ") already loading/loaded, ignoring load() request");
			return;
		}

		S_LOG_VERBOSE("Loading PagingLandScapePage at (" << mTableX << ", " << mTableZ << ")");

		if (mPageState == STATE_INITED) {
			preloadInBackground();
			// it takes a while to do it, so we don't bother trying to load and failing
			return;
		}

		if (mPageState == STATE_PRELOADED) {

			// load texture
			S_LOG_VERBOSE("Loading texture for PagingLandScapePage at (" << mTableX << ", " << mTableZ << ")");
			mPageMgr.getSceneManager()->getTextureManager()->load(mTableX, mTableZ);

			// initialize tile containers
			mTiles.reserve(mNumTiles);
			mTiles.resize(mNumTiles);
			for (size_t i = 0; i < mNumTiles; ++i) {
				mTiles[i].reserve(mNumTiles);
				mTiles[i].resize(mNumTiles);
			}

			// initialize tiles
			PagingLandScapeTileManager* tileMgr = mPageMgr.getSceneManager()->getTileManager();
			for (size_t i = 0; i < mTiles.size(); ++i) {
				for (size_t j = 0; j < mTiles[i].size(); ++j) {
					PagingLandScapeTile* tile = tileMgr->getTile();
					assert (tile);
					mTiles[i][j] = tile;
					tile->init(mPageNode, mTableX, mTableZ, i, j);

					// set up tile neighbors within page
					if (j > 0) {
						PagingLandScapeTile* northTile = mTiles[i][j-1];
						tile->_setNeighbor(NORTH, northTile);
						northTile->_setNeighbor(SOUTH, tile);
					}
					if (i > 0) {
						PagingLandScapeTile* westTile = mTiles[i-1][j];
						tile->_setNeighbor(WEST, westTile);
						westTile->_setNeighbor(EAST, tile);    
					}
				}
			}

			// set new state
			mPageState = STATE_LOADED;

			// set page neighbors
			setNeighbors();

			// fire event
			fireEvent(EVENT_LOADED);

		} else if (mPageState == STATE_PRELOADING) {
			// wait...
			return;
		} else {
			S_LOG_WARNING("PagingLandScapePage at (" << mTableX << ", " << mTableZ << ") already loaded, proceeding to show it");
		}

		show(true);
	}
int ofxTLDepthImageSequence::frameForTime(long timeInMillis){
	if(!isLoaded()) return 0;
	return depthImageSequence->frameForTime(timeInMillis);
}
コード例 #22
0
	//-----------------------------------------------------------------------
	void PagingLandScapePage::setNeighbor(Neighbor n, PagingLandScapePage* p)
	{
		// set page neighbor
		mNeighbors[n] = p;
	 
		// if neigther are loaded, nothing else to do
		const bool thisLoaded = isLoaded();
		const bool neighLoaded = p && p->isLoaded();
		if (!thisLoaded && !neighLoaded) {
			return;
		}

		assert (!thisLoaded || (thisLoaded && !mTiles.empty()));

		// tiles, 0 if not loaded
		PagingLandScapeTile* tileInCurrPage = 0;
		PagingLandScapeTile* tileInNeighborPage = 0;

		// indices for borders
		const unsigned int iNorthBorder = 0;
		const unsigned int iSouthBorder = mNumTiles - 1;
		const unsigned int iEastBorder = mNumTiles - 1;
		const unsigned int iWestBorder = 0;

		// walk the tiles in each border, and set roles accordingly
		switch (n) {
		case EAST:
		{
			for (unsigned int j = 0; j < mNumTiles; ++j) {
				if (thisLoaded) {
					// tiles of this page along east border
					tileInCurrPage = mTiles[iEastBorder][j];
				}

				if (neighLoaded) {
					// tiles of neighbor page along west border
					tileInNeighborPage = p->getTile(iWestBorder, j);
				}

				// set neighbor tiles
				if (tileInCurrPage) {
					tileInCurrPage->_setNeighbor(EAST, tileInNeighborPage);
				}
				if (tileInNeighborPage) {
					tileInNeighborPage->_setNeighbor(WEST, tileInCurrPage);
				}
			}
		}
		break;
		case WEST:
		{
			for (unsigned int j = 0; j < mNumTiles; ++j) {
				if (thisLoaded) {
					// tiles of this page along west border
					tileInCurrPage = mTiles[iWestBorder][j];
				}

				if (neighLoaded) {
					// tiles of neighbor page along east border
					tileInNeighborPage = p->getTile(iEastBorder, j);
				}

				// set neighbor tiles
				if (tileInCurrPage) {
					tileInCurrPage->_setNeighbor(WEST, tileInNeighborPage);
				}
				if (tileInNeighborPage) {
					tileInNeighborPage->_setNeighbor(EAST, tileInCurrPage);
				}
			}
		}
		break;
		case NORTH:
		{
			for (unsigned int i = 0; i < mNumTiles; ++i) {
				if (thisLoaded) {
					// tiles of this page along north border
					tileInCurrPage = mTiles[i][iNorthBorder];
				}

				if (neighLoaded) {
					// tiles of neighbor page along south border
					tileInNeighborPage = p->getTile(i, iSouthBorder);
				}

				// set neighbor tiles
				if (tileInCurrPage) {
					tileInCurrPage->_setNeighbor(NORTH, tileInNeighborPage);
				}
				if (tileInNeighborPage) {
					tileInNeighborPage->_setNeighbor(SOUTH, tileInCurrPage);
				}
			}
		}
		break;
		case SOUTH:
		{
			for (unsigned int i = 0; i < mNumTiles; ++i) {
				if (thisLoaded) {
					// tiles of this page along south border
					tileInCurrPage = mTiles[i][iSouthBorder];
				}

				if (neighLoaded) {
					// tiles of neighbor page along north border
					tileInNeighborPage = p->getTile(i, iNorthBorder);
				}

				// set neighbor tiles
				if (tileInCurrPage) {
					tileInCurrPage->_setNeighbor(SOUTH, tileInNeighborPage);
				}
				if (tileInNeighborPage) {
					tileInNeighborPage->_setNeighbor(NORTH, tileInCurrPage);
				}
			}
		}
		break;
		default:
			break;
		}
	}
int ofxTLDepthImageSequence::getSelectedFrame(){
	if(!isLoaded()) return 0;
	return depthImageSequence->getCurrentFrame();
}
コード例 #24
0
ファイル: KDPatch.cpp プロジェクト: Artorios/IDAplugins-1
// 插件可以从plugins.cfg文件中,被传进一个整型参数。
// 当按下不同的热键或者菜单时,您需要一个插件做不同
// 的事情时,这非常有用。
void __stdcall IDAP_run(int arg)
{
	// 插件的实体
	//在LOG中显示一个字符串
	char *lpInBuf = NULL;
	char *lpTmpBuf = NULL;
	char *lpFilePath = NULL;
	char szValue[MAXSTR + 1] = "";
	char szInValue[MAXSTR + 1] = "";
	//	char szTmp[100] = {0};
	int nPatchLogFlags = 1;
	uval_t nAddres = get_screen_ea();
	asize_t nCount = 1;
	USHORT nWriteRadio = 0;		//单选按钮
	USHORT nSerializeRadio = -1;		//单选按钮
	USHORT checkmask = 0;
	asize_t j = 0;
	asize_t i = 0;
	//	qstrncpy(szInValue,"",sizeof(szInValue));

	if(AskUsingForm_c(dialog, szInValue, &nAddres, &nCount, &nWriteRadio, &nSerializeRadio, &checkmask) == 1)
	{
		if(checkmask & 1)
		{
			nAddres = get_screen_ea();
		}
		size_t len = strlen(szInValue);
		for(i = 0; i < len; i++)
		{
			if(szInValue[i] != ' ')
			{
				szValue[j++] = szInValue[i];
			}
		}
		len = strlen(szValue);
		size_t nHexLen = len / 2;
		if(!len)
		{
			if( lpFilePath = askfile_cv(0, "*.*", "OpenPath", 0))
			{
				FILE* handle = fopen(lpFilePath, "rb");
				if(handle == NULL)
				{
					warning("打开文件失败 Error!\n");
					return;
				}
				fseek(handle, 0, SEEK_END);
				nHexLen = ftell(handle);
				fseek(handle, 0, SEEK_SET);
				lpTmpBuf = (char *)malloc(nHexLen + 1);
				memset(lpTmpBuf, 0, nHexLen + 1);
				fread(lpTmpBuf, 1, nHexLen, handle);
				fclose(handle);
				strcpy(szValue, lpFilePath);
			}
			else
			{
				warning("请输入数据");
				return;
			}

		}
		else if(len % 2)
		{
			warning("数据长度不是2的倍数");
			return;
		}
		else
		{
			for(i = 0;i < len;i++)
			{
				if(!isxdigit(szValue[i]))
				{
					warning("数据中含有非16进制值");
					return;
				}
			}
			lpTmpBuf = (char *) malloc(nHexLen * 2 + 1);
			memset(lpTmpBuf, 0, nHexLen * 2 + 1);
			for(i = 0; i < nHexLen; i++)
			{
				sscanf(&szValue[i * 2],"%02x",lpTmpBuf + i);
			}
		}
		if(nSerializeRadio >= 0)
		{
			asize_t nSerializeSize = (nSerializeRadio + 1) * 4;
			asize_t nSerializeCount = nHexLen * nCount / nSerializeSize;
			for(i = 0; i < nSerializeCount; i++)
			{
				reversedbuf((unsigned char*)lpTmpBuf + nSerializeSize *i, nSerializeSize);
			}
		}
		lpInBuf = (char*)malloc(nHexLen * nCount * 2 + 1);
		memset(lpInBuf, 0, nHexLen * nCount * 2 + 1);
		for(i = 0; i < nCount; i++)
		{
			memcpy(lpInBuf + i * nHexLen, lpTmpBuf, nHexLen);
		}
		free(lpTmpBuf);
		msg("==============修补数据库数据==============\n");
		msg("String Value = %s\n",szValue);
#ifdef __EA64__
		msg("Addres:0x%llX  ValueSize = 0x%llX  Index:%d check = %d\n",nAddres, nHexLen, nCount,checkmask);
#else
		msg("Addres:0x%08X  ValueSize = 0x%08X  Index:%d check = %d\n",nAddres, nHexLen, nCount,checkmask);
#endif
		if(!nWriteRadio)
		{
			msg("WriteData \n",nWriteRadio);
		}
		else
		{
			msg("XorWrite Data \n",nWriteRadio);
		}
		if( nHexLen * nCount > 0x100)
		{
			nPatchLogFlags = askyn_c(0, "%s", "是否打印日志!(默认不打印)\n因为数据量过大会影响IDA会假死!\nNo或Cancel表示不打印日志!\n");
		}
		////////////////////	
		uint32 nSum = 0;
		uchar *mem = NULL;
		if(isLoaded(nAddres) && isLoaded(nAddres + nCount *  nHexLen - 1))
		{

			mem = (uchar *)malloc(nCount *  nHexLen + 1);
			if(mem == NULL)
			{
				warning("malloc 函数执行失败!");
				return;
			}
			get_many_bytes(nAddres,mem, nCount *  nHexLen);
			if(nPatchLogFlags > 0)
			{
				msg("原始数据:\n");
				for(i = 0; i < nCount *  nHexLen; i++)
				{	
					msg("%02X", mem[i]);
				}
				msg("\n");
			}

		}
		else
		{
			if(!isLoaded(nAddres))
			{
				warning("数据地址错误: 0x%p",nAddres);
			}
			else
			{
				warning("写入数据长度过大");
			}
			return;
		}
		///////////////////////////
		//		long nValue = 0;
		for(j = 0;j < nCount;j++)
		{
			for(i = 0;i < nHexLen; i++)
			{
				//				memcpy(szTmp,&szInValue[j * len + i * 2],2);
				//sscanf(&szValue[i * 2],"%02x",&nValue);
				if(nWriteRadio == 1)
				{
					lpInBuf[nSum] ^=   mem[nSum];
				}
				mem[nSum++] = lpInBuf[nSum];

			}
		}
		put_many_bytes(nAddres, mem, nSum);
		if(nPatchLogFlags > 0)
		{
			msg("补丁数据:\n");
			for(i = 0; i < nSum; i++)
			{	
				msg("%02X", mem[i]);
			}
			msg("\n");
		}
		refresh_idaview_anyway();		//刷新反汇编窗口
		free(mem);
		free(lpInBuf);

	}
	return;
}
コード例 #25
0
ファイル: raids.cpp プロジェクト: HeavenIsLost/ChronusServer
bool Raids::loadFromXml()
{
	if (isLoaded()) {
		return true;
	}

	pugi::xml_document doc;
	pugi::xml_parse_result result = doc.load_file("data/raids/raids.xml");
	if (!result) {
		std::cout << "[Error - Raids::loadFromXml] Failed to load data/raids/raids.xml: " << result.description() << std::endl;
		return false;
	}

	for (pugi::xml_node raidNode = doc.child("raids").first_child(); raidNode; raidNode = raidNode.next_sibling()) {
		std::string name, file;
		uint32_t interval, margin;

		pugi::xml_attribute attr;
		if ((attr = raidNode.attribute("name"))) {
			name = attr.as_string();
		} else {
			std::cout << "[Error - Raids::loadFromXml] Name tag missing for raid" << std::endl;
			continue;
		}

		if ((attr = raidNode.attribute("file"))) {
			file = attr.as_string();
		} else {
			std::ostringstream ss;
			ss << "raids/" << name << ".xml";
			file = ss.str();
			std::cout << "[Warning - Raids::loadFromXml] File tag missing for raid " << name << ". Using default: " << file << std::endl;
		}

		interval = pugi::cast<uint32_t>(raidNode.attribute("interval2").value()) * 60;
		if (interval == 0) {
			std::cout << "[Error - Raids::loadFromXml] interval2 tag missing or zero (would divide by 0) for raid: " << name << std::endl;
			continue;
		}

		if ((attr = raidNode.attribute("margin"))) {
			margin = pugi::cast<uint32_t>(attr.value()) * 60 * 1000;
		} else {
			std::cout << "[Warning - Raids::loadFromXml] margin tag missing for raid: " << name << std::endl;
			margin = 0;
		}

		bool repeat;
		if ((attr = raidNode.attribute("repeat"))) {
			repeat = booleanString(attr.as_string());
		} else {
			repeat = false;
		}

		Raid* newRaid = new Raid(name, interval, margin, repeat);
		if (newRaid->loadFromXml("data/raids/" + file)) {
			raidList.push_back(newRaid);
		} else {
			std::cout << "[Error - Raids::loadFromXml] Failed to load raid: " << name << std::endl;
			delete newRaid;
		}
	}

	loaded = true;
	return true;
}
コード例 #26
0
ファイル: sqlite_database.cpp プロジェクト: cppan/cppan
void SqliteDatabase::save(const path &fn) const
{
    if (!isLoaded())
        return;
    save_from_memory_to_file(fn.string(), db);
}
コード例 #27
0
ファイル: CSSFontFaceSource.cpp プロジェクト: Xertz/EAWebKit
SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic, CSSFontSelector* fontSelector)
{
    // If the font hasn't loaded or an error occurred, then we've got nothing.
    if (!isValid())
        return 0;

#if ENABLE(SVG_FONTS)
    if (!m_font && !m_svgFontFaceElement) {
#else
    if (!m_font) {
#endif
        // We're local. Just return a SimpleFontData from the normal cache.
        return fontCache()->getCachedFontData(fontDescription, m_string);
    }

    // See if we have a mapping in our FontData cache.
	unsigned hashKey = (fontDescription.computedPixelSize() + 1) << 6 | fontDescription.widthVariant() << 4
                       | (fontDescription.textOrientation() == TextOrientationUpright ? 8 : 0) | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);
    if (SimpleFontData* cachedData = m_fontDataTable.get(hashKey))
        return cachedData;

    OwnPtr<SimpleFontData> fontData;

    // If we are still loading, then we let the system pick a font.
    if (isLoaded()) {
        if (m_font) {
#if ENABLE(SVG_FONTS)
            if (m_hasExternalSVGFont) {
                // For SVG fonts parse the external SVG document, and extract the <font> element.
                if (!m_font->ensureSVGFontData())
                    return 0;

                if (!m_externalSVGFontElement) {
                    String fragmentIdentifier;
                    size_t start = m_string.find('#');
                    if (start != notFound)
                        fragmentIdentifier = m_string.string().substring(start + 1);
                    m_externalSVGFontElement = m_font->getSVGFontById(fragmentIdentifier);
                }

                if (!m_externalSVGFontElement)
                    return 0;

                SVGFontFaceElement* fontFaceElement = 0;

                // Select first <font-face> child
                for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
                    if (fontChild->hasTagName(SVGNames::font_faceTag)) {
                        fontFaceElement = static_cast<SVGFontFaceElement*>(fontChild);
                        break;
                    }
                }

                if (fontFaceElement) {
                    if (!m_svgFontFaceElement) {
                        // We're created using a CSS @font-face rule, that means we're not associated with a SVGFontFaceElement.
                        // Use the imported <font-face> tag as referencing font-face element for these cases.
                        m_svgFontFaceElement = fontFaceElement;
                    }

                    fontData = adoptPtr(new SimpleFontData(SVGFontData::create(fontFaceElement), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));
                }
            } else
#endif
            {
                // Create new FontPlatformData from our CGFontRef, point size and ATSFontRef.
                if (!m_font->ensureCustomFontData())
                    return 0;

                fontData = adoptPtr(new SimpleFontData(m_font->platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, fontDescription.orientation(),
                                                                                   fontDescription.textOrientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false));
            }
        } else {
#if ENABLE(SVG_FONTS)
            // In-Document SVG Fonts
            if (m_svgFontFaceElement)
                fontData = adoptPtr(new SimpleFontData(SVGFontData::create(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic));
#endif
        }
    } else {
        // Kick off the load now. Do it on a zero-delay timer rather than synchronously, because we may be in
        // the middle of layout, and the loader may invoke arbitrary delegate or event handler code.
        m_fontSelector = fontSelector;
        if (!m_loadStartTimer.isActive())
            m_loadStartTimer.startOneShot(0);

        // This temporary font is not retained and should not be returned.
        FontCachePurgePreventer fontCachePurgePreventer;
        SimpleFontData* temporaryFont = fontCache()->getNonRetainedLastResortFallbackFont(fontDescription);
        fontData = adoptPtr(new SimpleFontData(temporaryFont->platformData(), true, true));
    }

    SimpleFontData* fontDataRawPtr = fontData.leakPtr();
    m_fontDataTable.set(hashKey, fontDataRawPtr);

    return fontDataRawPtr;
}

void CSSFontFaceSource::startLoadingTimerFired(Timer<WebCore::CSSFontFaceSource>*)
{
    ASSERT(m_font);
    ASSERT(m_fontSelector);

    if (CachedResourceLoader* cachedResourceLoader = m_fontSelector->cachedResourceLoader())
        m_font->beginLoadIfNeeded(cachedResourceLoader);

    m_fontSelector = nullptr;
}
コード例 #28
0
	QVariant PluginManager::data (const QModelIndex& index, int role) const
	{
		if (!index.isValid () ||
				index.row () >= GetSize ())
			return QVariant ();

		if (role == Roles::PluginObject)
		{
			auto loader = AvailablePlugins_ [index.row ()];
			if (!loader || !loader->isLoaded ())
				return QVariant ();

			return QVariant::fromValue<QObject*> (loader->instance ());
		}
		else if (role == Roles::PluginID)
		{
			auto loader = AvailablePlugins_ [index.row ()];
			if (!loader || !loader->isLoaded ())
				return QVariant ();

			return qobject_cast<IInfo*> (loader->instance ())->GetUniqueID ();
		}
		else if (role == Roles::PluginFilename)
		{
			auto loader = AvailablePlugins_ [index.row ()];
			if (!loader)
				return QVariant ();

			return loader->fileName ();
		}

		switch (index.column ())
		{
			case 0:
				switch (role)
				{
					case Qt::DisplayRole:
						{
							QSettings settings (QCoreApplication::organizationName (),
									QCoreApplication::applicationName () + "-pg");
							settings.beginGroup ("Plugins");
							settings.beginGroup (AvailablePlugins_.at (index.row ())->fileName ());
							QVariant result = settings.value ("Name");
							settings.endGroup ();
							settings.endGroup ();
							return result;
						}
					case Qt::DecorationRole:
						{
							const auto& path = AvailablePlugins_.at (index.row ())->fileName ();
							const auto fName = path.toUtf8 ().toBase64 ().replace ('/', '_');
							const auto& res = QPixmap (QString (IconsDir_.absoluteFilePath (fName)));
							return res.isNull () ? DefaultPluginIcon_ : res;
						}
					case Qt::CheckStateRole:
						{
							QSettings settings (QCoreApplication::organizationName (),
									QCoreApplication::applicationName () + "-pg");
							settings.beginGroup ("Plugins");
							settings.beginGroup (AvailablePlugins_.at (index.row ())->fileName ());
							bool result = settings.value ("AllowLoad", true).toBool ();
							settings.endGroup ();
							settings.endGroup ();
							return result ? Qt::Checked : Qt::Unchecked;
						}
					case Qt::ForegroundRole:
						return QApplication::palette ()
							.brush (AvailablePlugins_.at (index.row ())->isLoaded () ?
									QPalette::Normal :
									QPalette::Disabled,
								QPalette::WindowText);
					default:
						return QVariant ();
				}
			case 1:
				if (role == Qt::DisplayRole)
				{
					QSettings settings (QCoreApplication::organizationName (),
							QCoreApplication::applicationName () + "-pg");
					settings.beginGroup ("Plugins");
					settings.beginGroup (AvailablePlugins_.at (index.row ())->fileName ());
					QVariant result = settings.value ("Info");
					settings.endGroup ();
					settings.endGroup ();
					return result;
				}
				else if (role == Qt::ForegroundRole)
					return QApplication::palette ()
						.brush (AvailablePlugins_.at (index.row ())->isLoaded () ?
								QPalette::Normal :
								QPalette::Disabled,
							QPalette::WindowText);
				else
					return QVariant ();
			case 2:
				if (role == Qt::SizeHintRole)
					return QSize (32, 32);
				else
					return QVariant ();
			default:
				return QVariant ();
		}
	}
コード例 #29
0
ファイル: Antecedent.cpp プロジェクト: ecksun/fuzzylite
    scalar Antecedent::activationDegree(const TNorm* conjunction, const SNorm* disjunction,
            const Expression* node) const {
        if (not isLoaded()) {
            throw fl::Exception("[antecedent error] antecedent <" + _text + "> is not loaded", FL_AT);
        }
        const Proposition* proposition = dynamic_cast<const Proposition*> (node);
        if (proposition) {
            if (not proposition->variable->isEnabled()) {
                return 0.0;
            }

            if (not proposition->hedges.empty()) {
                //if last hedge is "Any", apply hedges in reverse order and return degree
                std::vector<Hedge*>::const_reverse_iterator rit = proposition->hedges.rbegin();
                if (dynamic_cast<Any*> (*rit)) {
                    scalar result = (*rit)->hedge(fl::nan);
                    while (++rit != proposition->hedges.rend()) {
                        result = (*rit)->hedge(result);
                    }
                    return result;
                }
            }
            scalar result = fl::nan;
            if (OutputVariable * outputVariable = dynamic_cast<OutputVariable*> (proposition->variable)) {
                result = outputVariable->fuzzyOutput()->activationDegree(proposition->term);
            } else {
                Variable* variable = proposition->variable;
                scalar value = variable->getValue();
                if (variable->isLockValueInRange()) {
                    value = fl::Op::bound(value, variable->getMinimum(), variable->getMaximum());
                }
                result = proposition->term->membership(value);
            }

            for (std::vector<Hedge*>::const_reverse_iterator rit = proposition->hedges.rbegin();
                    rit != proposition->hedges.rend(); ++rit) {
                result = (*rit)->hedge(result);
            }
            return result;
        }
        //if node is an operator
        const Operator* fuzzyOperator = dynamic_cast<const Operator*> (node);
        if (fuzzyOperator) {
            if (not (fuzzyOperator->left and fuzzyOperator->right)) {
                std::ostringstream ex;
                ex << "[syntax error] left and right operands must exist";
                throw fl::Exception(ex.str(), FL_AT);
            }
            if (fuzzyOperator->name == Rule::andKeyword()) {
                if (not conjunction) throw fl::Exception("[conjunction error] "
                        "the following rule requires a conjunction operator:\n" + _text, FL_AT);
                return conjunction->compute(
                        this->activationDegree(conjunction, disjunction, fuzzyOperator->left),
                        this->activationDegree(conjunction, disjunction, fuzzyOperator->right));
            }

            if (fuzzyOperator->name == Rule::orKeyword()) {
                if (not disjunction) throw fl::Exception("[disjunction error] "
                        "the following rule requires a disjunction operator:\n" + _text, FL_AT);
                return disjunction->compute(
                        this->activationDegree(conjunction, disjunction, fuzzyOperator->left),
                        this->activationDegree(conjunction, disjunction, fuzzyOperator->right));
            }
            std::ostringstream ex;
            ex << "[syntax error] operator <" << fuzzyOperator->name << "> not recognized";
            throw fl::Exception(ex.str(), FL_AT);

        } else {
            std::ostringstream ss;
            ss << "[antecedent error] expected a Proposition or Operator, but found <"
                    << (node ? node->toString() : "null") << ">";
            throw fl::Exception(ss.str(), FL_AT);
        }

    }
コード例 #30
0
ファイル: Renderer.cpp プロジェクト: JERlabs/JERonimo
 const bool Renderer::presentsVSync() const
 {
     if(!isLoaded())
         return false;
     return bool(getInfo()->flags & SDL_RENDERER_PRESENTVSYNC);
 }