2019-10-23 20:51:11 +00:00
|
|
|
#pragma once
|
2020-05-25 15:11:32 +00:00
|
|
|
|
2019-10-23 20:51:11 +00:00
|
|
|
#include "v_2ddrawer.h"
|
2020-05-25 15:11:32 +00:00
|
|
|
#include "c_cvars.h"
|
2020-07-03 21:16:12 +00:00
|
|
|
#include "intrect.h"
|
2020-05-25 15:11:32 +00:00
|
|
|
|
|
|
|
// TagItem definitions for DrawTexture. As far as I know, tag lists
|
|
|
|
// originated on the Amiga.
|
|
|
|
//
|
|
|
|
// Think of TagItems as an array of the following structure:
|
|
|
|
//
|
|
|
|
// struct TagItem {
|
|
|
|
// uint32_t ti_Tag;
|
|
|
|
// uint32_t ti_Data;
|
|
|
|
// };
|
2019-10-23 20:51:11 +00:00
|
|
|
|
|
|
|
#define TAG_DONE (0) /* Used to indicate the end of the Tag list */
|
|
|
|
#define TAG_END (0) /* Ditto */
|
|
|
|
/* list pointed to in ti_Data */
|
|
|
|
|
2020-05-25 15:11:32 +00:00
|
|
|
#define TAG_USER ((uint32_t)(1u<<30))
|
|
|
|
|
2019-10-23 20:51:11 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-05-25 15:11:32 +00:00
|
|
|
DTA_Base = TAG_USER + 5000,
|
2019-10-23 20:51:11 +00:00
|
|
|
DTA_DestWidth, // width of area to draw to
|
|
|
|
DTA_DestHeight, // height of area to draw to
|
|
|
|
DTA_Alpha, // alpha value for translucency
|
|
|
|
DTA_FillColor, // color to stencil onto the destination
|
|
|
|
DTA_TranslationIndex, // translation table to recolor the source
|
|
|
|
DTA_AlphaChannel, // bool: the source is an alpha channel; used with DTA_FillColor
|
|
|
|
DTA_Clean, // bool: scale texture size and position by CleanXfac and CleanYfac
|
|
|
|
DTA_320x200, // bool: scale texture size and position to fit on a virtual 320x200 screen
|
|
|
|
DTA_Bottom320x200, // bool: same as DTA_320x200 but centers virtual screen on bottom for 1280x1024 targets
|
|
|
|
DTA_CleanNoMove, // bool: like DTA_Clean but does not reposition output position
|
|
|
|
DTA_CleanNoMove_1, // bool: like DTA_CleanNoMove, but uses Clean[XY]fac_1 instead
|
|
|
|
DTA_FlipX, // bool: flip image horizontally //FIXME: Does not work with DTA_Window(Left|Right)
|
|
|
|
DTA_ShadowColor, // color of shadow
|
|
|
|
DTA_ShadowAlpha, // alpha of shadow
|
|
|
|
DTA_Shadow, // set shadow color and alphas to defaults
|
|
|
|
DTA_VirtualWidth, // pretend the canvas is this wide
|
|
|
|
DTA_VirtualHeight, // pretend the canvas is this tall
|
|
|
|
DTA_TopOffset, // override texture's top offset
|
|
|
|
DTA_LeftOffset, // override texture's left offset
|
|
|
|
DTA_CenterOffset, // bool: override texture's left and top offsets and set them for the texture's middle
|
|
|
|
DTA_CenterBottomOffset,// bool: override texture's left and top offsets and set them for the texture's bottom middle
|
|
|
|
DTA_WindowLeft, // don't draw anything left of this column (on source, not dest)
|
|
|
|
DTA_WindowRight, // don't draw anything at or to the right of this column (on source, not dest)
|
|
|
|
DTA_ClipTop, // don't draw anything above this row (on dest, not source)
|
|
|
|
DTA_ClipBottom, // don't draw anything at or below this row (on dest, not source)
|
|
|
|
DTA_ClipLeft, // don't draw anything to the left of this column (on dest, not source)
|
|
|
|
DTA_ClipRight, // don't draw anything at or to the right of this column (on dest, not source)
|
|
|
|
DTA_Masked, // true(default)=use masks from texture, false=ignore masks
|
|
|
|
DTA_HUDRules, // use fullscreen HUD rules to position and size textures
|
|
|
|
DTA_HUDRulesC, // only used internally for marking HUD_HorizCenter
|
|
|
|
DTA_KeepRatio, // doesn't adjust screen size for DTA_Virtual* if the aspect ratio is not 4:3
|
|
|
|
DTA_RenderStyle, // same as render style for actors
|
|
|
|
DTA_ColorOverlay, // uint32_t: ARGB to overlay on top of image; limited to black for software
|
|
|
|
DTA_BilinearFilter, // bool: apply bilinear filtering to the image
|
|
|
|
DTA_SpecialColormap,// pointer to FSpecialColormapParameters
|
|
|
|
DTA_Desaturate, // explicit desaturation factor (does not do anything in Legacy OpenGL)
|
|
|
|
DTA_Fullscreen, // Draw image fullscreen (same as DTA_VirtualWidth/Height with graphics size.)
|
|
|
|
|
|
|
|
// floating point duplicates of some of the above:
|
|
|
|
DTA_DestWidthF,
|
|
|
|
DTA_DestHeightF,
|
|
|
|
DTA_TopOffsetF,
|
|
|
|
DTA_LeftOffsetF,
|
|
|
|
DTA_VirtualWidthF,
|
|
|
|
DTA_VirtualHeightF,
|
|
|
|
DTA_WindowLeftF,
|
|
|
|
DTA_WindowRightF,
|
|
|
|
|
|
|
|
// For DrawText calls:
|
|
|
|
DTA_TextLen, // stop after this many characters, even if \0 not hit
|
|
|
|
DTA_CellX, // horizontal size of character cell
|
|
|
|
DTA_CellY, // vertical size of character cell
|
|
|
|
|
|
|
|
// New additions.
|
|
|
|
DTA_Color,
|
|
|
|
DTA_FlipY, // bool: flip image vertically
|
|
|
|
DTA_SrcX, // specify a source rectangle (this supersedes the poorly implemented DTA_WindowLeft/Right
|
|
|
|
DTA_SrcY,
|
|
|
|
DTA_SrcWidth,
|
|
|
|
DTA_SrcHeight,
|
|
|
|
DTA_LegacyRenderStyle, // takes an old-style STYLE_* constant instead of an FRenderStyle
|
|
|
|
DTA_Burn, // activates the burn shader for this element
|
|
|
|
DTA_Spacing, // Strings only: Additional spacing between characters
|
|
|
|
DTA_Monospace, // Fonts only: Use a fixed distance between characters.
|
2020-04-08 16:53:47 +00:00
|
|
|
|
|
|
|
DTA_FullscreenEx,
|
2020-06-07 13:02:54 +00:00
|
|
|
DTA_FullscreenScale,
|
2020-06-27 22:32:28 +00:00
|
|
|
DTA_ScaleX,
|
|
|
|
DTA_ScaleY,
|
2020-06-07 13:02:54 +00:00
|
|
|
|
2020-07-03 21:16:12 +00:00
|
|
|
DTA_ViewportX, // Defines the viewport on the screen that should be rendered to.
|
|
|
|
DTA_ViewportY,
|
|
|
|
DTA_ViewportWidth,
|
|
|
|
DTA_ViewportHeight,
|
|
|
|
|
2019-10-23 20:51:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum EMonospacing : int
|
|
|
|
{
|
|
|
|
Off = 0,
|
|
|
|
CellLeft = 1,
|
|
|
|
CellCenter = 2,
|
|
|
|
CellRight = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
HUD_Normal,
|
|
|
|
HUD_HorizCenter
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FFont;
|
2020-05-25 15:11:32 +00:00
|
|
|
struct FRemapTable;
|
|
|
|
class player_t;
|
|
|
|
typedef uint32_t angle_t;
|
2019-10-23 20:51:11 +00:00
|
|
|
|
|
|
|
struct DrawParms
|
|
|
|
{
|
|
|
|
double x, y;
|
|
|
|
double texwidth;
|
|
|
|
double texheight;
|
|
|
|
double destwidth;
|
|
|
|
double destheight;
|
|
|
|
double virtWidth;
|
|
|
|
double virtHeight;
|
|
|
|
double windowleft;
|
|
|
|
double windowright;
|
|
|
|
int cleanmode;
|
|
|
|
int dclip;
|
|
|
|
int uclip;
|
|
|
|
int lclip;
|
|
|
|
int rclip;
|
|
|
|
double top;
|
|
|
|
double left;
|
|
|
|
float Alpha;
|
|
|
|
PalEntry fillcolor;
|
2020-05-25 15:11:32 +00:00
|
|
|
int TranslationId;
|
2019-10-23 20:51:11 +00:00
|
|
|
PalEntry colorOverlay;
|
|
|
|
PalEntry color;
|
|
|
|
int alphaChannel;
|
|
|
|
int flipX;
|
|
|
|
int flipY;
|
|
|
|
//float shadowAlpha;
|
|
|
|
int shadowColor;
|
|
|
|
int keepratio;
|
|
|
|
int masked;
|
|
|
|
int bilinear;
|
|
|
|
FRenderStyle style;
|
2020-05-25 15:11:32 +00:00
|
|
|
struct FSpecialColormap *specialcolormap;
|
2019-10-23 20:51:11 +00:00
|
|
|
int desaturate;
|
|
|
|
int scalex, scaley;
|
|
|
|
int cellx, celly;
|
|
|
|
int monospace;
|
|
|
|
int spacing;
|
|
|
|
int maxstrlen;
|
|
|
|
bool fortext;
|
|
|
|
bool virtBottom;
|
2020-05-25 15:11:32 +00:00
|
|
|
bool burn;
|
2020-06-07 13:02:54 +00:00
|
|
|
int8_t fsscalemode;
|
2019-10-23 20:51:11 +00:00
|
|
|
double srcx, srcy;
|
|
|
|
double srcwidth, srcheight;
|
2020-06-27 22:32:28 +00:00
|
|
|
double patchscalex, patchscaley;
|
2020-07-03 21:16:12 +00:00
|
|
|
IntRect viewport;
|
2019-10-23 20:51:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Va_List
|
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
};
|
|
|
|
|
2020-05-25 15:11:32 +00:00
|
|
|
struct VMVa_List
|
|
|
|
{
|
|
|
|
VMValue *args;
|
|
|
|
int curindex;
|
|
|
|
int numargs;
|
|
|
|
const uint8_t *reginfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
float ActiveRatio (int width, int height, float *trueratio = NULL);
|
|
|
|
inline double ActiveRatio (double width, double height) { return ActiveRatio(int(width), int(height)); }
|
|
|
|
|
|
|
|
int AspectBaseWidth(float aspect);
|
|
|
|
int AspectBaseHeight(float aspect);
|
|
|
|
double AspectPspriteOffset(float aspect);
|
|
|
|
int AspectMultiplier(float aspect);
|
|
|
|
bool AspectTallerThanWide(float aspect);
|
|
|
|
|
|
|
|
extern F2DDrawer* twod;
|
|
|
|
|
|
|
|
int GetUIScale(F2DDrawer* drawer, int altval);
|
|
|
|
int GetConScale(F2DDrawer* drawer, int altval);
|
|
|
|
|
|
|
|
EXTERN_CVAR(Int, uiscale);
|
|
|
|
EXTERN_CVAR(Int, con_scaletext);
|
|
|
|
EXTERN_CVAR(Int, con_scale);
|
|
|
|
|
|
|
|
inline int active_con_scaletext(F2DDrawer* drawer, bool newconfont = false)
|
|
|
|
{
|
|
|
|
return newconfont ? GetConScale(drawer, con_scaletext) : GetUIScale(drawer, con_scaletext);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int active_con_scale(F2DDrawer *drawer)
|
|
|
|
{
|
|
|
|
return GetConScale(drawer, con_scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DrawText
|
|
|
|
#undef DrawText // See WinUser.h for the definition of DrawText as a macro
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template<class T>
|
2020-05-25 21:59:07 +00:00
|
|
|
bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, bool fortext);
|
2020-05-25 15:11:32 +00:00
|
|
|
|
|
|
|
template<class T>
|
|
|
|
void DrawTextCommon(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double y, const T* string, DrawParms& parms);
|
2020-05-25 21:59:07 +00:00
|
|
|
bool SetTextureParms(F2DDrawer *drawer, DrawParms* parms, FGameTexture* img, double x, double y);
|
2020-05-25 15:11:32 +00:00
|
|
|
|
|
|
|
void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, const char* string, int tag_first, ...);
|
|
|
|
void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, const char32_t* string, int tag_first, ...);
|
|
|
|
void DrawChar(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, int character, int tag_first, ...);
|
2020-05-25 21:59:07 +00:00
|
|
|
|
|
|
|
void DrawTexture(F2DDrawer* drawer, FGameTexture* img, double x, double y, int tags_first, ...);
|
2020-05-25 15:11:32 +00:00
|
|
|
|
|
|
|
void DoDim(F2DDrawer* drawer, PalEntry color, float amount, int x1, int y1, int w, int h, FRenderStyle* style = nullptr);
|
|
|
|
void Dim(F2DDrawer* drawer, PalEntry color, float damount, int x1, int y1, int w, int h, FRenderStyle* style = nullptr);
|
|
|
|
|
|
|
|
void DrawBorder(F2DDrawer* drawer, FTextureID, int x1, int y1, int x2, int y2);
|
|
|
|
void DrawFrame(F2DDrawer* twod, PalEntry color, int left, int top, int width, int height, int thickness);
|
|
|
|
|
|
|
|
// Set an area to a specified color
|
|
|
|
void ClearRect(F2DDrawer* drawer, int left, int top, int right, int bottom, int palcolor, uint32_t color);
|
|
|
|
|
|
|
|
void VirtualToRealCoords(F2DDrawer* drawer, double& x, double& y, double& w, double& h, double vwidth, double vheight, bool vbottom = false, bool handleaspect = true);
|
|
|
|
|
|
|
|
// Code that uses these (i.e. SBARINFO) should probably be evaluated for using doubles all around instead.
|
|
|
|
void VirtualToRealCoordsInt(F2DDrawer* drawer, int& x, int& y, int& w, int& h, int vwidth, int vheight, bool vbottom = false, bool handleaspect = true);
|
|
|
|
|
|
|
|
extern int CleanWidth, CleanHeight, CleanXfac, CleanYfac;
|
|
|
|
extern int CleanWidth_1, CleanHeight_1, CleanXfac_1, CleanYfac_1;
|
2020-04-21 19:26:33 +00:00
|
|
|
|
|
|
|
void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* cx1 = NULL, int* cx2 = NULL);
|
|
|
|
|
|
|
|
class ScaleOverrider
|
|
|
|
{
|
|
|
|
int savedxfac, savedyfac, savedwidth, savedheight;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// This is to allow certain elements to use an optimal fullscreen scale which for the menu would be too large.
|
|
|
|
// The old code contained far too much mess to compensate for the menus which negatively affected everything else.
|
|
|
|
// However, for compatibility reasons the currently used variables cannot be changed so they have to be overridden temporarily.
|
|
|
|
// This class provides a safe interface for this because it ensures that the values get restored afterward.
|
|
|
|
// Currently, the intermission and the level summary screen use this.
|
|
|
|
ScaleOverrider(F2DDrawer *drawer)
|
|
|
|
{
|
|
|
|
savedxfac = CleanXfac;
|
|
|
|
savedyfac = CleanYfac;
|
|
|
|
savedwidth = CleanWidth;
|
|
|
|
savedheight = CleanHeight;
|
|
|
|
|
|
|
|
if (drawer)
|
|
|
|
{
|
|
|
|
V_CalcCleanFacs(320, 200, drawer->GetWidth(), drawer->GetHeight(), &CleanXfac, &CleanYfac);
|
|
|
|
CleanWidth = drawer->GetWidth() / CleanXfac;
|
|
|
|
CleanHeight = drawer->GetHeight() / CleanYfac;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~ScaleOverrider()
|
|
|
|
{
|
|
|
|
CleanXfac = savedxfac;
|
|
|
|
CleanYfac = savedyfac;
|
|
|
|
CleanWidth = savedwidth;
|
|
|
|
CleanHeight = savedheight;
|
|
|
|
}
|
|
|
|
};
|