Beispiel #1
0
DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay, FDoorAnimation *anim, DAnimatedDoor::EADType type)
	: DMovingCeiling (sec, false)
{
	double topdist;
	FTextureID picnum;

	m_DoorAnim = anim;

	m_Line1 = line;
	m_Line2 = line;

	for (auto l : sec->Lines)
	{
		if (l == line)
			continue;

		if (l->sidedef[0]->GetTexture(side_t::top) == line->sidedef[0]->GetTexture(side_t::top))
		{
			m_Line2 = l;
			break;
		}
	}


	auto &tex1 = m_Line1->sidedef[0]->textures;
	tex1[side_t::mid].InitFrom(tex1[side_t::top]);

	auto &tex2 = m_Line2->sidedef[0]->textures;
	tex2[side_t::mid].InitFrom(tex2[side_t::top]);

	picnum = tex1[side_t::top].texture;

	// don't forget texture scaling here!
	FTexture *tex = TexMan[picnum];
	topdist = tex ? tex->GetScaledHeight() : 64;

	topdist = m_Sector->ceilingplane.fD() - topdist * m_Sector->ceilingplane.fC();

	m_Type = type;
	m_Status = type == adClose? Waiting : Opening;
	m_Speed = speed;
	m_Delay = delay;
	m_Timer = m_Speed;
	m_Frame = 0;
	m_SetBlocking1 = !!(m_Line1->flags & ML_BLOCKING);
	m_SetBlocking2 = !!(m_Line2->flags & ML_BLOCKING);
	m_Line1->flags |= ML_BLOCKING;
	m_Line2->flags |= ML_BLOCKING;
	m_BotDist = m_Sector->ceilingplane.fD();
	m_Sector->MoveCeiling (2048., topdist, 1);
	if (type == adOpenClose)
	{
		if (m_DoorAnim->OpenSound != NAME_None)
		{
			SN_StartSequence(m_Sector, CHAN_INTERIOR, m_DoorAnim->OpenSound, 1);
		}
	}
}
void FTextureManager::AddHiresTextures (int wadnum)
{
	int firsttx = Wads.GetFirstLump(wadnum);
	int lasttx = Wads.GetLastLump(wadnum);

	char name[9];
	TArray<FTextureID> tlist;

	if (firsttx == -1 || lasttx == -1)
	{
		return;
	}

	name[8] = 0;

	for (;firsttx <= lasttx; ++firsttx)
	{
		if (Wads.GetLumpNamespace(firsttx) == ns_hires)
		{
			Wads.GetLumpName (name, firsttx);

			if (Wads.CheckNumForName (name, ns_hires) == firsttx)
			{
				tlist.Clear();
				int amount = ListTextures(name, tlist);
				if (amount == 0)
				{
					// A texture with this name does not yet exist
					FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any);
					if (newtex != NULL)
					{
						newtex->UseType=FTexture::TEX_Override;
						AddTexture(newtex);
					}
				}
				else
				{
					for(unsigned int i = 0; i < tlist.Size(); i++)
					{
						FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any);
						if (newtex != NULL)
						{
							FTexture * oldtex = Textures[tlist[i].GetIndex()].Texture;

							// Replace the entire texture and adjust the scaling and offset factors.
							newtex->bWorldPanning = true;
							newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
							newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale);
							newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale);
							ReplaceTexture(tlist[i], newtex, true);
						}
					}
				}
				//StartScreen->Progress();
			}
		}
	}
}
Beispiel #3
0
void FTextureManager::ParseCameraTexture(FScanner &sc)
{
	const BITFIELD texflags = TEXMAN_Overridable | TEXMAN_TryAny | TEXMAN_ShortNameOnly;
	int width, height;
	int fitwidth, fitheight;
	FString picname;

	sc.MustGetString ();
	picname = sc.String;
	sc.MustGetNumber ();
	width = sc.Number;
	sc.MustGetNumber ();
	height = sc.Number;
	FTextureID picnum = CheckForTexture (picname, FTexture::TEX_Flat, texflags);
	FTexture *viewer = new FCanvasTexture (picname, width, height);
	if (picnum.Exists())
	{
		FTexture *oldtex = Texture(picnum);
		fitwidth = oldtex->GetScaledWidth ();
		fitheight = oldtex->GetScaledHeight ();
		viewer->UseType = oldtex->UseType;
		ReplaceTexture (picnum, viewer, true);
	}
	else
	{
		fitwidth = width;
		fitheight = height;
		// [GRB] No need for oldtex
		viewer->UseType = FTexture::TEX_Wall;
		AddTexture (viewer);
	}
	if (sc.GetString())
	{
		if (sc.Compare ("fit"))
		{
			sc.MustGetNumber ();
			fitwidth = sc.Number;
			sc.MustGetNumber ();
			fitheight = sc.Number;
		}
		else
		{
			sc.UnGet ();
		}
	}
	if (sc.GetString())
	{
		if (sc.Compare("WorldPanning"))
		{
			viewer->bWorldPanning = true;
		}
		else
		{
			sc.UnGet();
		}
	}
	viewer->SetScaledSize(fitwidth, fitheight);
}
DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay)
	: DMovingCeiling (sec)
{
	fixed_t topdist;
	FTextureID picnum;

	// The DMovingCeiling constructor automatically sets up an interpolation for us.
	// Stop it, since the ceiling is moving instantly here.
	StopInterpolation();
	m_WhichDoorIndex = P_FindSlidingDoorType (line->sidedef[0]->GetTexture(side_t::top));
	if (m_WhichDoorIndex < 0)
	{
		Printf ("EV_SlidingDoor: Textures are not defined for sliding door!");
		m_Status = Dead;
		return;
	}

	m_Line1 = line;
	m_Line2 = line;

	for (int i = 0; i < sec->linecount; ++i)
	{
		if (sec->lines[i] == line)
			continue;

		if (sec->lines[i]->sidedef[0]->GetTexture(side_t::top) == line->sidedef[0]->GetTexture(side_t::top))
		{
			m_Line2 = sec->lines[i];
			break;
		}
	}


	picnum = m_Line1->sidedef[0]->GetTexture(side_t::top);
	m_Line1->sidedef[0]->SetTexture(side_t::mid, picnum);
	m_Line2->sidedef[0]->SetTexture(side_t::mid, picnum);

	// don't forget texture scaling here!
	FTexture *tex = TexMan[picnum];
	topdist = tex ? tex->GetScaledHeight() : 64;

	topdist = m_Sector->ceilingplane.d - topdist * m_Sector->ceilingplane.c;

	m_Status = Opening;
	m_Speed = speed;
	m_Delay = delay;
	m_Timer = m_Speed;
	m_Frame = 0;
	m_Line1->flags |= ML_BLOCKING;
	m_Line2->flags |= ML_BLOCKING;
	m_BotDist = m_Sector->ceilingplane.d;
	MoveCeiling (2048*FRACUNIT, topdist, 1);
	if (DoorAnimations[m_WhichDoorIndex].OpenSound != NAME_None)
	{
		SN_StartSequence (m_Sector, CHAN_INTERIOR, DoorAnimations[m_WhichDoorIndex].OpenSound, 1);
	}
}
Beispiel #5
0
void DIntermissionScreenScroller::Drawer ()
{
	FTexture *tex = TexMan[mFirstPic];
	FTexture *tex2 = TexMan[mSecondPic];
	if (mTicker >= mScrollDelay && mTicker < mScrollDelay + mScrollTime && tex != NULL && tex2 != NULL)
	{

		int fwidth = tex->GetScaledWidth();
		int fheight = tex->GetScaledHeight();

		double xpos1 = 0, ypos1 = 0, xpos2 = 0, ypos2 = 0;

		switch (mScrollDir)
		{
		case SCROLL_Up:
			ypos1 = double(mTicker - mScrollDelay) * fheight / mScrollTime;
			ypos2 = ypos1 - fheight;
			break;

		case SCROLL_Down:
			ypos1 = -double(mTicker - mScrollDelay) * fheight / mScrollTime;
			ypos2 = ypos1 + fheight;
			break;

		case SCROLL_Left:
		default:
			xpos1 = double(mTicker - mScrollDelay) * fwidth / mScrollTime;
			xpos2 = xpos1 - fwidth;
			break;

		case SCROLL_Right:
			xpos1 = -double(mTicker - mScrollDelay) * fwidth / mScrollTime;
			xpos2 = xpos1 + fwidth;
			break;
		}

		screen->DrawTexture (tex, xpos1, ypos1,
			DTA_VirtualWidth, fwidth,
			DTA_VirtualHeight, fheight,
			DTA_Masked, false,
			TAG_DONE);
		screen->DrawTexture (tex2, xpos2, ypos2,
			DTA_VirtualWidth, fwidth,
			DTA_VirtualHeight, fheight,
			DTA_Masked, false,
			TAG_DONE);

		screen->FillBorder (NULL);
		mBackground = mSecondPic;
	}
	else 
	{
		Super::Drawer();
	}
}
Beispiel #6
0
DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay, FDoorAnimation *anim)
	: DMovingCeiling (sec)
{
	fixed_t topdist;
	FTextureID picnum;

	// The DMovingCeiling constructor automatically sets up an interpolation for us.
	// Stop it, since the ceiling is moving instantly here.
	StopInterpolation();
	m_DoorAnim = anim;

	m_Line1 = line;
	m_Line2 = line;

	for (int i = 0; i < sec->linecount; ++i)
	{
		if (sec->lines[i] == line)
			continue;

		if (sec->lines[i]->sidedef[0]->GetTexture(side_t::top) == line->sidedef[0]->GetTexture(side_t::top))
		{
			m_Line2 = sec->lines[i];
			break;
		}
	}


	picnum = m_Line1->sidedef[0]->GetTexture(side_t::top);
	m_Line1->sidedef[0]->SetTexture(side_t::mid, picnum);
	m_Line2->sidedef[0]->SetTexture(side_t::mid, picnum);

	// don't forget texture scaling here!
	FTexture *tex = TexMan[picnum];
	topdist = tex ? tex->GetScaledHeight() : 64;

	topdist = m_Sector->ceilingplane.d - topdist * m_Sector->ceilingplane.c;

	m_Status = Opening;
	m_Speed = speed;
	m_Delay = delay;
	m_Timer = m_Speed;
	m_Frame = 0;
	m_SetBlocking1 = !!(m_Line1->flags & ML_BLOCKING);
	m_SetBlocking2 = !!(m_Line2->flags & ML_BLOCKING);
	m_Line1->flags |= ML_BLOCKING;
	m_Line2->flags |= ML_BLOCKING;
	m_BotDist = m_Sector->ceilingplane.d;
	MoveCeiling (2048*FRACUNIT, topdist, 1);
	if (m_DoorAnim->OpenSound != NAME_None)
	{
		SN_StartSequence (m_Sector, CHAN_INTERIOR, m_DoorAnim->OpenSound, 1);
	}
}
Beispiel #7
0
bool DMenu::MouseEventBack(int type, int x, int y)
{
    if (m_show_backbutton >= 0)
    {
        FTexture *tex = TexMan(gameinfo.mBackButton);
        if (tex != NULL)
        {
            if (m_show_backbutton&1) x -= screen->GetWidth() - tex->GetScaledWidth() * CleanXfac;
            if (m_show_backbutton&2) y -= screen->GetHeight() - tex->GetScaledHeight() * CleanYfac;
            mBackbuttonSelected = ( x >= 0 && x < tex->GetScaledWidth() * CleanXfac &&
                                    y >= 0 && y < tex->GetScaledHeight() * CleanYfac);
            if (mBackbuttonSelected && type == MOUSE_Release)
            {
                if (m_use_mouse == 2) mBackbuttonSelected = false;
                MenuEvent(MKEY_Back, true);
            }
            return mBackbuttonSelected;
        }
    }
    return false;
}
Beispiel #8
0
static inline void CheckShortestTex (FTextureID texnum, fixed_t &minsize)
{
	if (texnum.isValid() || (texnum.isNull() && (i_compatflags & COMPATF_SHORTTEX)))
	{
		FTexture *tex = TexMan[texnum];
		if (tex != NULL)
		{
			fixed_t h = tex->GetScaledHeight()<<FRACBITS;
			if (h < minsize)
			{
				minsize = h;
			}
		}
	}
}
Beispiel #9
0
void DMenu::Drawer ()
{
    if (this == DMenu::CurrentMenu && BackbuttonAlpha > 0 && m_show_backbutton >= 0 && m_use_mouse)
    {
        FTexture *tex = TexMan(gameinfo.mBackButton);
        int w = tex->GetScaledWidth() * CleanXfac;
        int h = tex->GetScaledHeight() * CleanYfac;
        int x = (!(m_show_backbutton&1))? 0:screen->GetWidth() - w;
        int y = (!(m_show_backbutton&2))? 0:screen->GetHeight() - h;
        if (mBackbuttonSelected && (mMouseCapture || m_use_mouse == 1))
        {
            screen->DrawTexture(tex, x, y, DTA_CleanNoMove, true, DTA_ColorOverlay, MAKEARGB(40, 255,255,255), TAG_DONE);
        }
        else
        {
            screen->DrawTexture(tex, x, y, DTA_CleanNoMove, true, DTA_AlphaF, BackbuttonAlpha, TAG_DONE);
        }
    }
}
Beispiel #10
0
FFont::FFont (const char *name, const char *nametemplate, int first, int count, int start)
{
	int i, lump;
	char buffer[12];
	int *charlumps;
	BYTE usedcolors[256], identity[256];
	double *luminosity;
	int maxyoffs;
	bool doomtemplate = gameinfo.gametype == GAME_Doom ? strncmp (nametemplate, "STCFN", 5) == 0 : false;

	Chars = new CharData[count];
	charlumps = new int[count];
	PatchRemap = new BYTE[256];
	Ranges = NULL;
	FirstChar = first;
	LastChar = first + count - 1;
	FontHeight = 0;
	GlobalKerning = false;
	memset (usedcolors, 0, 256);
	Name = copystring (name);
	Next = FirstFont;
	FirstFont = this;

	maxyoffs = 0;

	for (i = 0; i < count; i++)
	{
		sprintf (buffer, nametemplate, i + start);
		lump = Wads.CheckNumForName (buffer, ns_graphics);
		if (doomtemplate && lump >= 0 && i + start == 121)
		{ // HACKHACK: Don't load STCFN121 in doom(2), because
		  // it's not really a lower-case 'y' but an upper-case 'I'.
		  // Because a lot of wads with their own font seem to foolishly
		  // copy STCFN121 and make it an 'I' themselves, wads must
		  // provide STCFN120 (x) and STCFN122 (z) for STCFN121 to load.
			if (Wads.CheckNumForName ("STCFN120", ns_graphics) == -1 ||
				Wads.CheckNumForName ("STCFN122", ns_graphics) == -1)
			{
				lump = -1;
			}
		}
		charlumps[i] = lump;
		if (lump >= 0)
		{
			FTexture *pic = TexMan[TexMan.AddPatch (buffer)];
			int height = pic->GetScaledHeight();
			int yoffs = pic->GetScaledTopOffset();

			if (yoffs > maxyoffs)
			{
				maxyoffs = yoffs;
			}
			height += abs (yoffs);
			if (height > FontHeight)
			{
				FontHeight = height;
			}
			RecordTextureColors (pic, usedcolors);
		}
	}

	ActiveColors = SimpleTranslation (usedcolors, PatchRemap, identity, &luminosity);

	for (i = 0; i < count; i++)
	{
		if (charlumps[i] >= 0)
		{
			Chars[i].Pic = new FFontChar1 (charlumps[i], PatchRemap);
		}
		else
		{
			Chars[i].Pic = NULL;
		}
	}

	if ('N'-first>=0 && 'N'-first<count && Chars['N' - first].Pic)
	{
		SpaceWidth = (Chars['N' - first].Pic->GetScaledWidth() + 1) / 2;
	}
	else
	{
		SpaceWidth = 4;
	}
	BuildTranslations (luminosity, identity, &TranslationParms[0][0]);

	delete[] luminosity;
	delete[] charlumps;
}
Beispiel #11
0
static void R_InitAnimDefs ()
{
	const BITFIELD texflags = FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_TryAny;
	int lump, lastlump = 0;
	
	while ((lump = Wads.FindLump ("ANIMDEFS", &lastlump)) != -1)
	{
		FScanner sc(lump);

		while (sc.GetString ())
		{
			if (sc.Compare ("flat"))
			{
				ParseAnim (sc, false);
			}
			else if (sc.Compare ("texture"))
			{
				ParseAnim (sc, true);
			}
			else if (sc.Compare ("switch"))
			{
				P_ProcessSwitchDef (sc);
			}
			// [GRB] Added warping type 2
			else if (sc.Compare ("warp") || sc.Compare ("warp2"))
			{
				bool isflat = false;
				bool type2 = sc.Compare ("warp2");	// [GRB]
				sc.MustGetString ();
				if (sc.Compare ("flat"))
				{
					isflat = true;
					sc.MustGetString ();
				}
				else if (sc.Compare ("texture"))
				{
					isflat = false;
					sc.MustGetString ();
				}
				else
				{
					sc.ScriptError (NULL);
				}
				FTextureID picnum = TexMan.CheckForTexture (sc.String, isflat ? FTexture::TEX_Flat : FTexture::TEX_Wall, texflags);
				if (picnum.isValid())
				{
					FTexture * warper = TexMan[picnum];

					// don't warp a texture more than once
					if (!warper->bWarped)
					{
						if (type2)	// [GRB]
							warper = new FWarp2Texture (warper);
						else
							warper = new FWarpTexture (warper);
						TexMan.ReplaceTexture (picnum, warper, false);
					}

					if (sc.CheckFloat())
					{
						static_cast<FWarpTexture*>(warper)->SetSpeed(float(sc.Float));
					}

					// No decals on warping textures, by default.
					// Warping information is taken from the last warp 
					// definition for this texture.
					warper->bNoDecals = true;
					if (sc.GetString ())
					{
						if (sc.Compare ("allowdecals"))
						{
							warper->bNoDecals = false;
						}
						else
						{
							sc.UnGet ();
						}
					}
				}
			}
			else if (sc.Compare ("cameratexture"))
			{
				int width, height;
				int fitwidth, fitheight;
				FString picname;

				sc.MustGetString ();
				picname = sc.String;
				sc.MustGetNumber ();
				width = sc.Number;
				sc.MustGetNumber ();
				height = sc.Number;
				FTextureID picnum = TexMan.CheckForTexture (picname, FTexture::TEX_Flat, texflags);
				FTexture *viewer = new FCanvasTexture (picname, width, height);
				if (picnum.Exists())
				{
					FTexture *oldtex = TexMan[picnum];
					fitwidth = oldtex->GetScaledWidth ();
					fitheight = oldtex->GetScaledHeight ();
					viewer->UseType = oldtex->UseType;
					TexMan.ReplaceTexture (picnum, viewer, true);
				}
				else
				{
					fitwidth = width;
					fitheight = height;
					// [GRB] No need for oldtex
					viewer->UseType = FTexture::TEX_Wall;
					TexMan.AddTexture (viewer);
				}
				if (sc.GetString())
				{
					if (sc.Compare ("fit"))
					{
						sc.MustGetNumber ();
						fitwidth = sc.Number;
						sc.MustGetNumber ();
						fitheight = sc.Number;
					}
					else
					{
						sc.UnGet ();
					}
				}
				viewer->SetScaledSize(fitwidth, fitheight);
			}
			else if (sc.Compare ("animatedDoor"))
			{
				P_ParseAnimatedDoor (sc);
			}
			else if (sc.Compare("skyoffset"))
			{
				sc.MustGetString ();
				FTextureID picnum = TexMan.CheckForTexture (sc.String, FTexture::TEX_Wall, texflags);
				sc.MustGetNumber();
				if (picnum.Exists())
				{
					FTexture *tex = TexMan[picnum];
					tex->SkyOffset = sc.Number;
				}
			}
			else
			{
				sc.ScriptError (NULL);
			}
		}
	}
}
Beispiel #12
0
void HandleCommand (bool helphack)
{
    int     i,margin,top,bottom;
    int     picmid;

    switch (toupper(*++text))
    {
    case 'B':
    {
        double bx = ParseNumber();
        double by = ParseNumber();
        double bw = ParseNumber();
        double bh = ParseNumber();
        MenuToRealCoords(bx, by, bw, bh, MENU_CENTER);
        VWB_DrawFill(backgroundFlat, (int)bx, (int)by, (int)(bx+bw), (int)(by+bh));
        RipToEOL();
        break;
    }
    case ';':               // comment
        RipToEOL();
        break;
    case 'P':               // ^P is start of next page, ^E is end of file
    case 'E':
        layoutdone = true;
        text--;             // back up to the '^'
        break;

    case 'C':               // ^c<hex digit> changes text color
        i = toupper(*++text);
        if(i == '[') // Textcolo translation
        {
            fontcolor = 255;
            const BYTE *colorname = (const BYTE *)(text);
            textcolor = V_ParseFontColor(colorname, CR_UNTRANSLATED, CR_UNTRANSLATED+1);
            while(*text++ != ']');
        }
        else
        {
            textcolor = CR_UNTRANSLATED;

            if (i>='0' && i<='9')
                fontcolor = i-'0';
            else if (i>='A' && i<='F')
                fontcolor = i-'A'+10;

            fontcolor *= 16;
            i = toupper(*++text);
            if (i>='0' && i<='9')
                fontcolor += i-'0';
            else if (i>='A' && i<='F')
                fontcolor += i-'A'+10;
            text++;
        }
        break;

    case '>':
        px = 160;
        text++;
        break;

    case 'L':
        py=ParseNumber();
        rowon = (py-TOPMARGIN)/FONTHEIGHT;
        py = TOPMARGIN+rowon*FONTHEIGHT;
        px=ParseNumber();
        while (*text++ != '\n')         // scan to end of line
            ;
        break;

    case 'T':               // ^Tyyy,xxx,ppp,ttt waits ttt tics, then draws pic
        TimedPicCommand (helphack);
        break;

    case 'G':               // ^Gyyy,xxx,ppp draws graphic
    {
        ParsePicCommand (helphack);

        if(!picnum.isValid())
            break;
        FTexture *picture = TexMan(picnum);
        VWB_DrawGraphic (picture, picx&~7,picy, MENU_CENTER);

        //
        // adjust margins
        //
        picmid = picx + picture->GetScaledWidth()/2;
        if (picmid > SCREENMID)
            margin = picx-PICMARGIN;                        // new right margin
        else
            margin = picx+picture->GetScaledWidth()+PICMARGIN;       // new left margin

        top = (picy-TOPMARGIN)/FONTHEIGHT;
        if (top<0)
            top = 0;
        bottom = (picy+picture->GetScaledHeight()-TOPMARGIN)/FONTHEIGHT;
        if (bottom>=TEXTROWS)
            bottom = TEXTROWS-1;

        for (i=top; i<=bottom; i++)
            if (picmid > SCREENMID)
                rightmargin[i] = margin;
            else
                leftmargin[i] = margin;

        //
        // adjust this line if needed
        //
        if (px < (int) leftmargin[rowon])
            px = leftmargin[rowon];
        break;
    }
    }
}