Exemplo n.º 1
0
void R_ParseTrnslate()
{
	customTranslationMap.Clear();
	translationtables[TRANSLATION_Custom].Clear();

	int lump;
	int lastlump = 0;
	while (-1 != (lump = Wads.FindLump("TRNSLATE", &lastlump)))
	{
		FScanner sc(lump);
		while (sc.GetToken())
		{
			sc.TokenMustBe(TK_Identifier);

			FName newtrans = sc.String;
			FRemapTable *base = nullptr;
			if (sc.CheckToken(':'))
			{
				sc.MustGetAnyToken();
				if (sc.TokenType == TK_IntConst)
				{
					int max = 6;
					if (sc.Number < 0 || sc.Number > max)
					{
						sc.ScriptError("Translation must be in the range [0,%d]", max);
					}
					base = translationtables[TRANSLATION_Standard][sc.Number];
				}
				else if (sc.TokenType == TK_Identifier)
				{
					int tnum = R_FindCustomTranslation(sc.String);
					if (tnum == -1)
					{
						sc.ScriptError("Base translation '%s' not found in '%s'", sc.String, newtrans.GetChars());
					}
					base = translationtables[GetTranslationType(tnum)][GetTranslationIndex(tnum)];
				}
				else
				{
					// error out.
					sc.TokenMustBe(TK_Identifier);
				}
			}
			sc.MustGetToken('=');
			FRemapTable NewTranslation;
			if (base != nullptr)  NewTranslation = *base;
			else NewTranslation.MakeIdentity();
			do
			{
				sc.MustGetToken(TK_StringConst);
				NewTranslation.AddToTranslation(sc.String);
			} while (sc.CheckToken(','));

			int trans = NewTranslation.StoreTranslation(TRANSLATION_Custom);
			customTranslationMap[newtrans] = trans;
		}
	}
}
Exemplo n.º 2
0
FRemapTable *TranslationToTable(int translation)
{
	unsigned int type = GetTranslationType(translation);
	unsigned int index = GetTranslationIndex(translation);
	TAutoGrowArray<FRemapTablePtr, FRemapTable *> *slots;

	if (type <= 0 || type >= NUM_TRANSLATION_TABLES)
	{
		return NULL;
	}
	slots = &translationtables[type];
	if (index >= slots->Size())
	{
		return NULL;
	}
	return slots->operator[](index);
}
Exemplo n.º 3
0
void DIntermissionScreenCast::Init(FIntermissionAction *desc, bool first)
{
	Super::Init(desc, first);
	mName = static_cast<FIntermissionActionCast*>(desc)->mName;
	mClass = PClass::FindClass(static_cast<FIntermissionActionCast*>(desc)->mCastClass);
	if (mClass != NULL) mDefaults = GetDefaultByType(mClass);
	else
	{
		mDefaults = NULL;
		caststate = NULL;
		return;
	}

	mCastSounds.Resize(static_cast<FIntermissionActionCast*>(desc)->mCastSounds.Size());
	for (unsigned i=0; i < mCastSounds.Size(); i++)
	{
		mCastSounds[i].mSequence = static_cast<FIntermissionActionCast*>(desc)->mCastSounds[i].mSequence;
		mCastSounds[i].mIndex = static_cast<FIntermissionActionCast*>(desc)->mCastSounds[i].mIndex;
		mCastSounds[i].mSound = static_cast<FIntermissionActionCast*>(desc)->mCastSounds[i].mSound;
	}
	caststate = mDefaults->SeeState;
	if (mClass->IsDescendantOf(RUNTIME_CLASS(APlayerPawn)))
	{
		advplayerstate = mDefaults->MissileState;
		casttranslation = translationtables[TRANSLATION_Players][consoleplayer];
	}
	else
	{
		advplayerstate = NULL;
		casttranslation = NULL;
		if (mDefaults->Translation != 0)
		{
			casttranslation = translationtables[GetTranslationType(mDefaults->Translation)]
												[GetTranslationIndex(mDefaults->Translation)];
		}
	}
	castdeath = false;
	castframes = 0;
	castonmelee = 0;
	castattacking = false;
	if (mDefaults->SeeSound)
	{
		S_Sound (CHAN_VOICE | CHAN_UI, mDefaults->SeeSound, 1, ATTN_NONE);
	}
}