Example #1
0
void Sound::PrepareStaticBuffer()
{
	buffer = SoundBuffer::CreateStatic(fileName);
	if(1 == buffer->GetRetainCount()) 
	{
		DVVERIFY(provider->Init());
		buffer->FullFill(provider);
	}
}
Example #2
0
bool GraphicsFontDefinition::LoadFontDefinition(const FilePath & fontDefName)
{
    File * file = 0;

//    size_t pos = fontDefName.rfind("/");
//    String fileName = fontDefName.substr(pos + 1);
//    String pathName = fontDefName.substr(0, pos + 1) + LocalizationSystem::Instance()->GetCurrentLocale() + "/" + fileName;

    FilePath pathName = fontDefName.GetDirectory() + (LocalizationSystem::Instance()->GetCurrentLocale() + "/" + fontDefName.GetFilename());

    file = File::Create(pathName, File::READ|File::OPEN);

    if (!file)
    {
        file = File::Create(fontDefName, File::READ|File::OPEN);
        if (!file)
        {
            return false;
        }
    }

    char header[4];
    DVVERIFY(file->Read(header, 4) == 4);
    if ((header[0] != 'F') || (header[1] != 'D') || (header[2] != 'E') || (header[3] != 'F'))
    {
        SafeRelease(file);
        return false;
    }
    uint32 version = 0;
    DVVERIFY(file->Read(&version, 4) == 4);
    if (version != 1)
    {
        SafeRelease(file);
        return false;
    }

    DVVERIFY(file->Read(&fontAscent, 4) == 4);
    DVVERIFY(file->Read(&fontDescent, 4) == 4);
    DVVERIFY(file->Read(&fontLeading, 4) == 4);
    DVVERIFY(file->Read(&fontXHeight, 4) == 4);
    DVVERIFY(file->Read(&charLeftRightPadding, 4) == 4);
    DVVERIFY(file->Read(&charTopBottomPadding, 4) == 4);

    fontHeight = (uint32)(fontAscent + fontDescent + fontLeading + 0.5f);

    DVVERIFY(file->Read(&tableLenght, 4) == 4);
    characterTable = new char16[tableLenght];
    characterPreShift = new float32[tableLenght];
    characterWidthTable = new float32[tableLenght];
    kerningBaseShift = new float32[tableLenght];
    kerningTable = new KerningPair*[tableLenght];

    for (int32 t = 0; t < tableLenght; ++t)
    {
        // BORODA: THIS IS FIX BECAUSE CHAR16 isn't char16 on MacOS and iPhone
        unsigned short c = 0;
        DVVERIFY(file->Read(&c, 2) == 2);
        characterTable[t] = c;
        DVVERIFY(file->Read(&characterPreShift[t], 4) == 4);
        DVVERIFY(file->Read(&characterWidthTable[t], 4) == 4);
        //Logger::Debug("char: %c idx: %d",  characterTable[t], t);
    }

    DVVERIFY(file->Read(&defaultShiftValue, 4) == 4);

    for (int t = 0; t < tableLenght; ++t)
    {
        DVVERIFY(file->Read(&kerningBaseShift[t], 4) == 4);
        //Logger::Debug("base: %c baseshift:%f preshift:%f", characterTable[t], kerningBaseShift[t], characterPreShift[t]);
    }

    DVVERIFY(file->Read(&kerningPairCount, 4) == 4);
    for (int32 k = 0; k < tableLenght; ++k)
        kerningTable[k] = 0;

    for (int32 kp = 0; kp < kerningPairCount; ++kp)
    {
        unsigned short s1short;
        DVVERIFY(file->Read(&s1short, 2) == 2);
        unsigned short s2short;
        DVVERIFY(file->Read(&s2short, 2) == 2);
        float32 shift;
        DVVERIFY(file->Read(&shift, 4) == 4);

        KerningPair * p = new KerningPair();
        p->ch1Index = s1short;
        p->ch2Index = s2short;
        p->shift = shift;
        AddKerningPair(p);
        //file->Read(&kerningTable[s1][s2], 4, 1, fontFP);
    }

//	for (int32 t = 0; t < tableLenght; ++t)
//	{
//		//Logger::Debug("char check: %c idx: %d",  characterTable[t], t);
//	}


    SafeRelease(file);
    return true;
}