- widescreen asset setup and consolidation of .def file loading.

This commit is contained in:
Christoph Oelckers 2020-09-16 16:42:44 +02:00
parent 234fae011e
commit 6776508239
17 changed files with 85 additions and 65 deletions

View file

@ -417,16 +417,8 @@ void GameInterface::app_init()
I_FatalError("TILES###.ART files not found"); I_FatalError("TILES###.ART files not found");
levelLoadDefaults(); 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(); TileFiles.SetBackup();
powerupInit(); powerupInit();
Printf(PRINT_NONOTIFY, "Loading cosine table\n"); Printf(PRINT_NONOTIFY, "Loading cosine table\n");

View file

@ -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_undefinetile(int32_t tile);
int32_t md_undefinemodel(int32_t modelid); 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 // if loadboard() fails with -2 return, try loadoldboard(). if it fails with
// -2, board is dodgy // -2, board is dodgy

View file

@ -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; scriptfile *script;
@ -3217,7 +3217,7 @@ int32_t loaddefinitionsfile(const char *fn)
defsparser(script); 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()); Printf("Loading module \"%s\"\n",m.GetChars());
defsparser_include(m, NULL, NULL); // Q: should we let the external script see our symbol table? defsparser_include(m, NULL, NULL); // Q: should we let the external script see our symbol table?

View file

@ -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 GetWidth = [=]() { return parms->viewport.width; };
auto GetHeight = [=]() {return parms->viewport.height; }; 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. // First calculate the destination rect for an image of the given size and then reposition this object in it.
DoubleRect rect; 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; 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->x = parms->viewport.left + adder + parms->x * rect.width / parms->virtWidth;
parms->y = parms->viewport.top + rect.top + parms->y * rect.height / parms->virtHeight; 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: case DTA_FullscreenEx:
{ {
DoubleRect rect; 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->keepratio = -1;
parms->x = parms->viewport.left + rect.left; parms->x = parms->viewport.left + rect.left;
parms->y = parms->viewport.top + rect.top; parms->y = parms->viewport.top + rect.top;

View file

@ -1415,3 +1415,34 @@ void DrawCrosshair(int deftile, int health, double xdelta, double scale, PalEntr
DrawGenericCrosshair(crosshair == 0 ? 2 : *crosshair, health, xdelta); DrawGenericCrosshair(crosshair == 0 ? 2 : *crosshair, health, xdelta);
} }
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
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");
}
}

View file

@ -161,6 +161,7 @@ struct GrpEntry
extern int g_gameType; extern int g_gameType;
const char* G_DefaultDefFile(void); const char* G_DefaultDefFile(void);
const char* G_DefFile(void); const char* G_DefFile(void);
void LoadDefinitions();
// game check shortcuts // game check shortcuts
inline bool isNam() inline bool isNam()

View file

@ -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) void setViewport(int viewSize)
{ {
int x0, y0, x1, y1; int x0, y0, x1, y1;

View file

@ -197,6 +197,7 @@ public:
} }
void DoDrawAutomapHUD(int crdefault, int highlight); void DoDrawAutomapHUD(int crdefault, int highlight);
short CalcMagazineAmount(short ammo_remaining, short clip_capacity, bool reloading); short CalcMagazineAmount(short ammo_remaining, short clip_capacity, bool reloading);
void Set43ClipRect();
//protected: //protected:
void DrawPowerups (); void DrawPowerups ();

View file

@ -521,14 +521,8 @@ void GameInterface::app_init()
// temp - moving InstallEngine(); before FadeOut as we use nextpage() in FadeOut // temp - moving InstallEngine(); before FadeOut as we use nextpage() in FadeOut
InstallEngine(); 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(); TileFiles.SetBackup();
InitView(); InitView();

View file

@ -854,7 +854,9 @@ private:
{ {
// draw the main bar itself // draw the main bar itself
BeginStatusBar(320, 200, 40); BeginStatusBar(320, 200, 40);
if (hud_size == Hud_StbarOverlay) Set43ClipRect();
DrawGraphic(tileGetTexture(kTileStatusBar), 160, 200, DI_ITEM_CENTER_BOTTOM, 1, -1, -1, 1, 1); DrawGraphic(tileGetTexture(kTileStatusBar), 160, 200, DI_ITEM_CENTER_BOTTOM, 1, -1, -1, 1, 1);
twod->ClearClipRect();
} }
else if (hud_size == Hud_Mini) else if (hud_size == Hud_Mini)
{ {

View file

@ -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() static void initTiles()
{ {
if (TileFiles.artLoadFiles("tiles%03i.art") < 0) if (TileFiles.artLoadFiles("tiles%03i.art") < 0)
@ -340,7 +312,8 @@ void GameInterface::app_init()
ps[j].auto_aim = 0; ps[j].auto_aim = 0;
} }
loaddefs(); LoadDefinitions();
TileFiles.SetBackup();
if (ud.multimode > 1) if (ud.multimode > 1)
{ {

View file

@ -75,10 +75,10 @@ void displaymasks_r(int snum, double smoothratio)
if (ps[snum].scuba_on) 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. // 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; 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].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((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); 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 = [&] 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 }; 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) if (kb_frames[*kb] == 2 || kb_frames[*kb] == 3)
{ {
@ -449,7 +449,7 @@ void displayweapon_r(int snum, double smoothratio)
auto displaychicken = [&] 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) 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 }; 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; dy = 20;
if ((*kb) < 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 }; 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) if (*kb)
@ -811,7 +811,7 @@ void displayweapon_r(int snum, double smoothratio)
auto displayblaster = [&] 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)) 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 }; 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 };

View file

@ -380,14 +380,15 @@ public:
void Statusbar(int snum) 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]; auto p = &ps[snum];
int h = tilesiz[tile].y; int h = tilesiz[BOTTOMSTATUSBAR].y;
int top = 200 - h; int top = 200 - h;
int left = (320 - tilesiz[tile].x) / 2; int left = (320 - tilesiz[BOTTOMSTATUSBAR].x) / 2;
BeginStatusBar(320, 200, h); BeginStatusBar(320, 200, h);
DrawInventory(p, 160, 154, 0); 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; FString format;

View file

@ -343,6 +343,7 @@ public:
double h = tilesiz[BOTTOMSTATUSBAR].y * scale; double h = tilesiz[BOTTOMSTATUSBAR].y * scale;
double wh = 0; double wh = 0;
if (hud_size < Hud_Stbar) wh = tilesiz[WEAPONBAR].y * scale; if (hud_size < Hud_Stbar) wh = tilesiz[WEAPONBAR].y * scale;
double left = (320 - tilesiz[BOTTOMSTATUSBAR].x * scale) / 2;
double top = 200 - h; double top = 200 - h;
BeginStatusBar(320, 200, wh + h); BeginStatusBar(320, 200, wh + h);
@ -351,7 +352,9 @@ public:
if (hud_size < Hud_Stbar) if (hud_size < Hud_Stbar)
DrawWeaponBar(p, top); 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; FString format;

View file

@ -227,7 +227,7 @@ void GameInterface::app_init()
if (!SW_SHAREWARE) if (!SW_SHAREWARE)
LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information
if (!loaddefinitionsfile(G_DefFile())) Printf(PRINT_NONOTIFY, "Definitions file loaded.\n"); LoadDefinitions();
TileFiles.SetBackup(); TileFiles.SetBackup();
userConfig.AddDefs.reset(); userConfig.AddDefs.reset();
InitFX(); InitFX();

View file

@ -665,7 +665,10 @@ private:
USERp u = User[pp->PlayerSprite]; USERp u = User[pp->PlayerSprite];
BeginStatusBar(320, 200, tileHeight(STATUS_BAR)); 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_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); 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) if (u->WeaponNum != WPN_FIST && u->WeaponNum != WPN_SWORD)

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB