From 1392f4db0151d43f99186d4991aea2ecb6cd4a16 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 Aug 2020 18:02:13 +0200 Subject: [PATCH] - handle the view frame with backend features. --- source/blood/src/sbar.cpp | 21 +++++++++++++++++ source/blood/src/view.cpp | 40 --------------------------------- source/blood/src/view.h | 2 ++ source/common/2d/v_2ddrawer.cpp | 14 ++++++------ source/common/2d/v_2ddrawer.h | 2 +- 5 files changed, 31 insertions(+), 48 deletions(-) diff --git a/source/blood/src/sbar.cpp b/source/blood/src/sbar.cpp index d4793751f..f1d8c7dde 100644 --- a/source/blood/src/sbar.cpp +++ b/source/blood/src/sbar.cpp @@ -794,10 +794,31 @@ private: } }; + +static void UpdateFrame(void) +{ + auto tex = tileGetTexture(kBackTile); + + twod->AddFlatFill(0, 0, xdim, gViewY0 - 3, tex); + twod->AddFlatFill(0, gViewY1 + 4, xdim, ydim, tex); + twod->AddFlatFill(0, gViewY0 - 3, gViewX0 - 3, gViewY1 + 4, tex); + twod->AddFlatFill(gViewX1 + 4, gViewY0 - 3, xdim, gViewY1 + 4, tex); + + twod->AddFlatFill(gViewX0 - 3, gViewY0 - 3, gViewX0, gViewY1 + 1, tex, 0, 1, 0xff545454); + twod->AddFlatFill(gViewX0, gViewY0 - 3, gViewX1 + 4, gViewY0, tex, 0, 1, 0xff545454); + twod->AddFlatFill(gViewX1 + 1, gViewY0, gViewX1 + 4, gViewY1 + 4, tex, 0, 1, 0xff2a2a2a); + twod->AddFlatFill(gViewX0 - 3, gViewY1 + 1, gViewX1 + 1, gViewY1 + 4, tex, 0, 1, 0xff2a2a2a); +} + void UpdateStatusBar(ClockTicks arg) { DBloodStatusBar sbar; + if (gViewMode == 3 && gViewSize > 2) + { + UpdateFrame(); + } + sbar.UpdateStatusBar(arg); } diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index dcfe4def5..99fa2c52c 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -1007,28 +1007,6 @@ void viewDrawText(int nFont, const char *pString, int x, int y, int nShade, int } -// for the screen border -void viewTileSprite(int nTile, int nShade, int nPalette, int x1, int y1, int x2, int y2) -{ - Rect rect1 = Rect(x1, y1, x2, y2); - Rect rect2 = Rect(0, 0, xdim, ydim); - rect1 &= rect2; - - if (!rect1) - return; - - dassert(nTile >= 0 && nTile < kMaxTiles); - int width = tilesiz[nTile].x; - int height = tilesiz[nTile].y; - int bx1 = DecBy(rect1.x0+1, width); - int by1 = DecBy(rect1.y0+1, height); - int bx2 = IncBy(rect1.x1-1, width); - int by2 = IncBy(rect1.y1-1, height); - for (int x = bx1; x < bx2; x += width) - for (int y = by1; y < by2; y += height) - rotatesprite(x<<16, y<<16, 65536, 0, nTile, nShade, nPalette, 64+16+8, x1, y1, x2-1, y2-1); -} - void InitStatusBar(void) { tileLoadTile(2200); @@ -1210,27 +1188,9 @@ void viewResizeView(int size) videoSetViewableArea(gViewX0, gViewY0, gViewX1, gViewY1); } -#define kBackTile 253 - -void UpdateFrame(void) -{ - viewTileSprite(kBackTile, 0, 0, 0, 0, xdim, gViewY0-3); - viewTileSprite(kBackTile, 0, 0, 0, gViewY1+4, xdim, ydim); - viewTileSprite(kBackTile, 0, 0, 0, gViewY0-3, gViewX0-3, gViewY1+4); - viewTileSprite(kBackTile, 0, 0, gViewX1+4, gViewY0-3, xdim, gViewY1+4); - - viewTileSprite(kBackTile, 20, 0, gViewX0-3, gViewY0-3, gViewX0, gViewY1+1); - viewTileSprite(kBackTile, 20, 0, gViewX0, gViewY0-3, gViewX1+4, gViewY0); - viewTileSprite(kBackTile, 10, 1, gViewX1+1, gViewY0, gViewX1+4, gViewY1+4); - viewTileSprite(kBackTile, 10, 1, gViewX0-3, gViewY1+1, gViewX1+1, gViewY1+4); -} void viewDrawInterface(ClockTicks arg) { - if (gViewMode == 3) - { - UpdateFrame(); - } UpdateStatusBar(arg); } diff --git a/source/blood/src/view.h b/source/blood/src/view.h index 8dd24c1c5..f9eb4eee6 100644 --- a/source/blood/src/view.h +++ b/source/blood/src/view.h @@ -65,6 +65,8 @@ enum INTERPOLATE_TYPE { enum { + kBackTile = 253, + kCrosshairTile = 2319, kLoadScreen = 2049, kLoadScreenWideBack = 9216, diff --git a/source/common/2d/v_2ddrawer.cpp b/source/common/2d/v_2ddrawer.cpp index 32296fa72..9f7ece257 100644 --- a/source/common/2d/v_2ddrawer.cpp +++ b/source/common/2d/v_2ddrawer.cpp @@ -739,7 +739,7 @@ float F2DDrawer::GetClassicFlatScalarHeight() return sh; } -void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, int local_origin, double flatscale) +void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, int local_origin, double flatscale, PalEntry color) { float fU1, fU2, fV1, fV2; @@ -835,18 +835,18 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTextu dg.mVertIndex = (int)mVertices.Reserve(4); auto ptr = &mVertices[dg.mVertIndex]; - ptr->Set(left, top, 0, fU1, fV1, 0xffffffff); ptr++; + ptr->Set(left, top, 0, fU1, fV1, color); ptr++; if (local_origin < 4) { - ptr->Set(left, bottom, 0, fU1, fV2, 0xffffffff); ptr++; - ptr->Set(right, top, 0, fU2, fV1, 0xffffffff); ptr++; + ptr->Set(left, bottom, 0, fU1, fV2, color); ptr++; + ptr->Set(right, top, 0, fU2, fV1, color); ptr++; } else { - ptr->Set(left, bottom, 0, fU2, fV1, 0xffffffff); ptr++; - ptr->Set(right, top, 0, fU1, fV2, 0xffffffff); ptr++; + ptr->Set(left, bottom, 0, fU2, fV1, color); ptr++; + ptr->Set(right, top, 0, fU1, fV2, color); ptr++; } - ptr->Set(right, bottom, 0, fU2, fV2, 0xffffffff); ptr++; + ptr->Set(right, bottom, 0, fU2, fV2, color); ptr++; dg.mIndexIndex = mIndices.Size(); dg.mIndexCount += 6; AddIndices(dg.mVertIndex, 6, 0, 1, 2, 1, 3, 2); diff --git a/source/common/2d/v_2ddrawer.h b/source/common/2d/v_2ddrawer.h index eaaf488ec..93fdccd86 100644 --- a/source/common/2d/v_2ddrawer.h +++ b/source/common/2d/v_2ddrawer.h @@ -188,7 +188,7 @@ public: void AddPoly(FGameTexture* img, FVector4 *vt, size_t vtcount, unsigned int *ind, size_t idxcount, int translation, PalEntry color, FRenderStyle style, int clipx1, int clipy1, int clipx2, int clipy2); void FillPolygon(int* rx1, int* ry1, int* xb1, int32_t npoints, int picnum, int palette, int shade, int props, const FVector2& xtex, const FVector2& ytex, const FVector2& otex, int clipx1, int clipy1, int clipx2, int clipy2); - void AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, int local_origin = false, double flatscale = 1.0); + void AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, int local_origin = false, double flatscale = 1.0, PalEntry color = 0xffffffff); void AddColorOnlyQuad(int left, int top, int width, int height, PalEntry color, FRenderStyle *style = nullptr, bool prepend = false); void ClearScreen(PalEntry color = 0xff000000);