diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 562342e91..cd9e9d01b 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -417,16 +417,8 @@ void GameInterface::app_init() I_FatalError("TILES###.ART files not found"); levelLoadDefaults(); + LoadDefinitions(); - loaddefinitionsfile(BLOODWIDESCREENDEF); - - const char* defsfile = G_DefFile(); - uint32_t stime = I_msTime(); - if (!loaddefinitionsfile(defsfile)) - { - uint32_t etime = I_msTime(); - Printf(PRINT_NONOTIFY, "Definitions file \"%s\" loaded in %d ms.\n", defsfile, etime - stime); - } TileFiles.SetBackup(); powerupInit(); Printf(PRINT_NONOTIFY, "Loading cosine table\n"); diff --git a/source/build/include/build.h b/source/build/include/build.h index e66077be9..546364b9a 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -950,7 +950,7 @@ int32_t md_definehud (int32_t modelid, int32_t tilex, vec3f_t add, int32_t md_undefinetile(int32_t tile); int32_t md_undefinemodel(int32_t modelid); -int32_t loaddefinitionsfile(const char *fn); +int32_t loaddefinitionsfile(const char *fn, bool loadadds = false); // if loadboard() fails with -2 return, try loadoldboard(). if it fails with // -2, board is dodgy diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index b9c187b15..3d79dd4f1 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -3204,7 +3204,7 @@ static int32_t defsparser(scriptfile *script) } -int32_t loaddefinitionsfile(const char *fn) +int32_t loaddefinitionsfile(const char *fn, bool loadadds) { scriptfile *script; @@ -3217,7 +3217,7 @@ int32_t loaddefinitionsfile(const char *fn) defsparser(script); } - if (userConfig.AddDefs) for (auto& m : *userConfig.AddDefs) + if (userConfig.AddDefs && loadadds) for (auto& m : *userConfig.AddDefs) { Printf("Loading module \"%s\"\n",m.GetChars()); defsparser_include(m, NULL, NULL); // Q: should we let the external script see our symbol table? diff --git a/source/common/2d/v_draw.cpp b/source/common/2d/v_draw.cpp index dabd72c3d..222659aa7 100644 --- a/source/common/2d/v_draw.cpp +++ b/source/common/2d/v_draw.cpp @@ -335,7 +335,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetClipRect) } -static void CalcFullscreenScale(F2DDrawer* drawer, DrawParms *parms, double srcwidth, double srcheight, int oautoaspect, DoubleRect &rect) +void CalcFullscreenScale(DrawParms *parms, double srcwidth, double srcheight, int oautoaspect, DoubleRect &rect) { auto GetWidth = [=]() { return parms->viewport.width; }; auto GetHeight = [=]() {return parms->viewport.height; }; @@ -475,7 +475,7 @@ bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FGameTexture *img, do { // First calculate the destination rect for an image of the given size and then reposition this object in it. DoubleRect rect; - CalcFullscreenScale(drawer, parms, parms->virtWidth, parms->virtHeight, parms->fsscalemode, rect); + CalcFullscreenScale(parms, parms->virtWidth, parms->virtHeight, parms->fsscalemode, rect); double adder = parms->keepratio < 0 ? 0 : parms->keepratio == 0 ? rect.left : 2 * rect.left; parms->x = parms->viewport.left + adder + parms->x * rect.width / parms->virtWidth; parms->y = parms->viewport.top + rect.top + parms->y * rect.height / parms->virtHeight; @@ -489,7 +489,7 @@ bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FGameTexture *img, do case DTA_FullscreenEx: { DoubleRect rect; - CalcFullscreenScale(drawer, parms, parms->texwidth, parms->texheight, parms->fsscalemode, rect); + CalcFullscreenScale(parms, parms->texwidth, parms->texheight, parms->fsscalemode, rect); parms->keepratio = -1; parms->x = parms->viewport.left + rect.left; parms->y = parms->viewport.top + rect.top; diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index b83dfe9fb..e2a242c37 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1414,4 +1414,35 @@ void DrawCrosshair(int deftile, int health, double xdelta, double scale, PalEntr } DrawGenericCrosshair(crosshair == 0 ? 2 : *crosshair, health, xdelta); } -} \ No newline at end of file +} +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void LoadDefinitions() +{ + loaddefinitionsfile("engine/engine.def"); // Internal stuff that is required. + + const char* defsfile = G_DefFile(); + + cycle_t deftimer; + deftimer.Reset(); + deftimer.Clock(); + if (!loaddefinitionsfile(defsfile, true)) + { + deftimer.Unclock(); + Printf(PRINT_NONOTIFY, "Definitions file \"%s\" loaded in %.3f ms.\n", defsfile, deftimer.TimeMS()); + } + userConfig.AddDefs.reset(); + + // load the widescreen replacements last so that they do not clobber the CRC for the original items so that mod-side replacement are picked up. + if (fileSystem.FindFile("engine/widescreen.def") >= 0 && !Args->CheckParm("-nowidescreen")) + { + loaddefinitionsfile("engine/widescreen.def"); + } + + +} + diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 1103b0c6c..244e077ce 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -161,6 +161,7 @@ struct GrpEntry extern int g_gameType; const char* G_DefaultDefFile(void); const char* G_DefFile(void); +void LoadDefinitions(); // game check shortcuts inline bool isNam() diff --git a/source/core/statusbar.cpp b/source/core/statusbar.cpp index bd3645567..17f7595b7 100644 --- a/source/core/statusbar.cpp +++ b/source/core/statusbar.cpp @@ -821,6 +821,25 @@ short DBaseStatusBar::CalcMagazineAmount(short ammo_remaining, short clip_capaci // //============================================================================ +void DBaseStatusBar::Set43ClipRect() +{ + auto GetWidth = [=]() { return twod->GetWidth(); }; + auto GetHeight = [=]() {return twod->GetHeight(); }; + + auto screenratio = ActiveRatio(GetWidth(), GetHeight()); + if (screenratio < 1.34) return; + + int width = xs_CRoundToInt(GetWidth() * 1.333 / screenratio); + int left = (GetWidth() - width) / 2; + twod->SetClipRect(left, 0, width, GetHeight()); +} + +//============================================================================ +// +// +// +//============================================================================ + void setViewport(int viewSize) { int x0, y0, x1, y1; diff --git a/source/core/statusbar.h b/source/core/statusbar.h index c6580e3ae..d6023e917 100644 --- a/source/core/statusbar.h +++ b/source/core/statusbar.h @@ -197,6 +197,7 @@ public: } void DoDrawAutomapHUD(int crdefault, int highlight); short CalcMagazineAmount(short ammo_remaining, short clip_capacity, bool reloading); + void Set43ClipRect(); //protected: void DrawPowerups (); diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 1cf6e32f8..18827e30a 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -521,14 +521,8 @@ void GameInterface::app_init() // temp - moving InstallEngine(); before FadeOut as we use nextpage() in FadeOut InstallEngine(); + LoadDefinitions(); - const char* defsfile = G_DefFile(); - uint32_t stime = I_msTime(); - if (!loaddefinitionsfile(defsfile)) - { - uint32_t etime = I_msTime(); - Printf(PRINT_NONOTIFY, "Definitions file \"%s\" loaded in %d ms.\n", defsfile, etime - stime); - } TileFiles.SetBackup(); InitView(); diff --git a/source/exhumed/src/status.cpp b/source/exhumed/src/status.cpp index c4661165f..930b0c86b 100644 --- a/source/exhumed/src/status.cpp +++ b/source/exhumed/src/status.cpp @@ -854,7 +854,9 @@ private: { // draw the main bar itself BeginStatusBar(320, 200, 40); + if (hud_size == Hud_StbarOverlay) Set43ClipRect(); DrawGraphic(tileGetTexture(kTileStatusBar), 160, 200, DI_ITEM_CENTER_BOTTOM, 1, -1, -1, 1, 1); + twod->ClearClipRect(); } else if (hud_size == Hud_Mini) { diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index 9371b31a6..f73f6fae4 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -228,34 +228,6 @@ static void setupbackdrop() // //--------------------------------------------------------------------------- -static void loaddefs() -{ - const char* defsfile = G_DefFile(); - cycle_t deftimer; - deftimer.Reset(); - deftimer.Clock(); - if (!loaddefinitionsfile(defsfile)) - { - deftimer.Unclock(); - Printf(PRINT_NONOTIFY, "Definitions file \"%s\" loaded in %.3f ms.\n", defsfile, deftimer.TimeMS()); - } - TileFiles.SetBackup(); - userConfig.AddDefs.reset(); - - // load the internal replacements last so that they do not clobber the CRC for the original items so that mod-side replacement are picked up. - if (fileSystem.FindFile("engine/duke-widescreen.def") >= 0) - { - loaddefinitionsfile("engine/duke-widescreen.def"); - } - -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - static void initTiles() { if (TileFiles.artLoadFiles("tiles%03i.art") < 0) @@ -340,7 +312,8 @@ void GameInterface::app_init() ps[j].auto_aim = 0; } - loaddefs(); + LoadDefinitions(); + TileFiles.SetBackup(); if (ud.multimode > 1) { diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index 388c8a13e..9c973ee76 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -75,10 +75,10 @@ void displaymasks_r(int snum, double smoothratio) if (ps[snum].scuba_on) { - int pin = 0; + //int pin = 0; // to get the proper clock value with regards to interpolation we have add a smoothratio based offset to the value. double interpclock = ud.levelclock + (TICSPERFRAME/65536.) * smoothratio; - if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) pin = RS_STRETCH; + int pin = RS_STRETCH; hud_drawsprite((320 - (tilesiz[SCUBAMASK].x >> 1) - 15), (200 - (tilesiz[SCUBAMASK].y >> 1) + (calcSinTableValue(interpclock) / 1024.)), 49152, 0, SCUBAMASK, 0, p, 2 + 16 + pin); hud_drawsprite((320 - tilesiz[SCUBAMASK + 4].x), (200 - tilesiz[SCUBAMASK + 4].y), 65536, 0, SCUBAMASK + 4, 0, p, 2 + 16 + pin); hud_drawsprite(tilesiz[SCUBAMASK + 4].x, (200 - tilesiz[SCUBAMASK + 4].y), 65536, 0, SCUBAMASK + 4, 0, p, 2 + 4 + 16 + pin); @@ -422,7 +422,7 @@ void displayweapon_r(int snum, double smoothratio) auto displaycrossbow = [&] { - if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) pin = RS_ALIGN_R; + //if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) pin = RS_ALIGN_R; static const uint8_t kb_frames[] = { 0,1,1,2,2,3,2,3,2,3,2,2,2,2,2,2,2,2,2,4,4,4,4,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7 }; if (kb_frames[*kb] == 2 || kb_frames[*kb] == 3) { @@ -449,7 +449,7 @@ void displayweapon_r(int snum, double smoothratio) auto displaychicken = [&] { - if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) pin = RS_ALIGN_R; + //if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) pin = RS_ALIGN_R; if (*kb) { static const uint8_t kb_frames[] = { 0,1,1,2,2,3,2,3,2,3,2,2,2,2,2,2,2,2,2,4,4,4,4,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7 }; @@ -760,7 +760,7 @@ void displayweapon_r(int snum, double smoothratio) dy = 20; if ((*kb) < 20) { - if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) pin = RS_ALIGN_R; + //if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) pin = RS_ALIGN_R; static const int8_t remote_frames[] = { 1,1,1,1,1,2,2,2,2,3,3,3,4,4,4,5,5,5,5,5,6,6,6 }; if (*kb) @@ -811,7 +811,7 @@ void displayweapon_r(int snum, double smoothratio) auto displayblaster = [&] { - if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) pin = RS_ALIGN_R; + //if (!(duke3d_globalflags & DUKE3D_NO_WIDESCREEN_PINNING)) pin = RS_ALIGN_R; if ((*kb)) { char cat_frames[] = { 0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; diff --git a/source/games/duke/src/sbar_d.cpp b/source/games/duke/src/sbar_d.cpp index 7179bfdfe..0400be88e 100644 --- a/source/games/duke/src/sbar_d.cpp +++ b/source/games/duke/src/sbar_d.cpp @@ -380,14 +380,15 @@ public: void Statusbar(int snum) { - int tile = hud_size < Hud_StbarOverlay ? TILE_BOTTOMSTATUSBAR : BOTTOMSTATUSBAR; // always use the narrow version for the overlay. auto p = &ps[snum]; - int h = tilesiz[tile].y; + int h = tilesiz[BOTTOMSTATUSBAR].y; int top = 200 - h; - int left = (320 - tilesiz[tile].x) / 2; + int left = (320 - tilesiz[BOTTOMSTATUSBAR].x) / 2; BeginStatusBar(320, 200, h); DrawInventory(p, 160, 154, 0); - DrawGraphic(tileGetTexture(tile), left, top, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); + if (hud_size == Hud_StbarOverlay) Set43ClipRect(); + DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), left, top, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); + twod->ClearClipRect(); FString format; diff --git a/source/games/duke/src/sbar_r.cpp b/source/games/duke/src/sbar_r.cpp index 2615b0b80..befcc4467 100644 --- a/source/games/duke/src/sbar_r.cpp +++ b/source/games/duke/src/sbar_r.cpp @@ -343,6 +343,7 @@ public: double h = tilesiz[BOTTOMSTATUSBAR].y * scale; double wh = 0; if (hud_size < Hud_Stbar) wh = tilesiz[WEAPONBAR].y * scale; + double left = (320 - tilesiz[BOTTOMSTATUSBAR].x * scale) / 2; double top = 200 - h; BeginStatusBar(320, 200, wh + h); @@ -351,7 +352,9 @@ public: if (hud_size < Hud_Stbar) DrawWeaponBar(p, top); - DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), 0, top, DI_ITEM_LEFT_TOP, 1, -1, -1, scale, scale); + if (hud_size == Hud_StbarOverlay) Set43ClipRect(); + DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), left, top, DI_ITEM_LEFT_TOP, 1, -1, -1, scale, scale); + twod->ClearClipRect(); FString format; diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index a413679e2..5165c72ce 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -227,7 +227,7 @@ void GameInterface::app_init() if (!SW_SHAREWARE) LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information - if (!loaddefinitionsfile(G_DefFile())) Printf(PRINT_NONOTIFY, "Definitions file loaded.\n"); + LoadDefinitions(); TileFiles.SetBackup(); userConfig.AddDefs.reset(); InitFX(); diff --git a/source/sw/src/sbar.cpp b/source/sw/src/sbar.cpp index e43db115c..d6b0769e9 100644 --- a/source/sw/src/sbar.cpp +++ b/source/sw/src/sbar.cpp @@ -665,7 +665,10 @@ private: USERp u = User[pp->PlayerSprite]; BeginStatusBar(320, 200, tileHeight(STATUS_BAR)); - DrawGraphic(tileGetTexture(STATUS_BAR), 0, 200, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, 1, 1); + if (hud_size == Hud_StbarOverlay) Set43ClipRect(); + int left = (320 - tilesiz[STATUS_BAR].x) / 2; + DrawGraphic(tileGetTexture(STATUS_BAR), left, 200, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, 1, 1); + twod->ClearClipRect(); DisplayPanelNumber(PANEL_HEALTH_BOX_X + PANEL_HEALTH_XOFF, PANEL_BOX_Y + PANEL_HEALTH_YOFF, u->Health); DisplayPanelNumber(PANEL_ARMOR_BOX_X + PANEL_ARMOR_XOFF, PANEL_BOX_Y + PANEL_ARMOR_YOFF, pp->Armor); if (u->WeaponNum != WPN_FIST && u->WeaponNum != WPN_SWORD) diff --git a/wadsrc/static/filter/duke/tiles/duke3d/2462.PNG b/wadsrc/static/filter/duke/tiles/duke3d/2462.PNG new file mode 100644 index 000000000..64deb2c43 Binary files /dev/null and b/wadsrc/static/filter/duke/tiles/duke3d/2462.PNG differ