Cavestory Mod API
Public Types | Static Public Member Functions | List of all members
CacheSurface Struct Reference

Rendering pipeline for Cavestory Multiplayer. More...

#include <CSMAPI_drawing.h>

Public Types

enum  BitmapBoxType { BMPBOX_TYPE_WIDTH = 0 , BMPBOX_TYPE_HEIGHT , BMPBOX_TYPE_BOTH }
 Bitmap box type for CacheSurface::GetBitmapBoxSize and CacheSurface::DrawBitmapBox. More...
 

Static Public Member Functions

static void InitMemory ()
 Only called once upon engine init. More...
 
static GUI_POINT GetTextSize (FontObject *pFont, const char *pText, int iTextLen=-1)
 Get the size of a string of text w/ a font. More...
 
static BOOL SetCurrentTexture (VideoTexture *pTexture)
 Set the texture that should be used when rendering stuff. More...
 
static BOOL SetSurfaceID (Surface_Ids sid)
 Set the surface ID that we're editing. More...
 
static BOOL SelectRendererSurface (int iCustomMagnification=0)
 Alias of SetSurfaceID, handles selecting SURFACE_ID_RENDERER with a custom magnification. More...
 
static BOOL SetSurfaceIDAndRememberPrevious (Surface_Ids sid)
 Set the surface ID that we're editing. More...
 
static BOOL SelectRendererSurfaceAndRememberPrevious (int iCustomMagnification=0)
 Alias of SetSurfaceID, handles selecting SURFACE_ID_RENDERER with a custom magnification. More...
 
static BOOL RememberSurfaceID ()
 Remember the currently selected SurfaceID. More...
 
static BOOL RestoreSurfaceID ()
 Return the current SurfaceID selection to the last one stored with RememberSurfaceID(). More...
 
static Surface_Ids GetSurfaceID ()
 Get the surface ID that we're currently editing. More...
 
static VideoTextureGetCurrentVideoTexture ()
 Get the currently selected video texture. More...
 
static int GetFreeSurfaceCount ()
 Self-explanatory. More...
 
static bool TryClipPoint (GUI_POINT &p)
 Try to contain a point inside of the clip rect. More...
 
static bool IsInClipRect (GUI_POINT p)
 Check to see if a point is inside the current clip rect. More...
 
static bool IsInClipRect (GUI_RECT r)
 Check to see if a rect is inside the current clip rect. More...
 
static bool IsInClipRectWithCustomMag (GUI_RECT r, int customMagnification)
 Check to see if a rect is inside the current clip rect. More...
 
static void SetClipRect (GUI_RECT *r, bool bAbsoluteRect=false)
 Add a new clip rect. More...
 
static void GetClipRect (GUI_RECT *r)
 Get the current clip rect. More...
 
static void ClearClipRectList ()
 Clear the clip rect. More...
 
static GUI_POINT GetSurfaceIDSize (Surface_Ids sid)
 Get the surface size of a surface. More...
 
static int GetSurfaceIDMagnification (Surface_Ids sid)
 Get the surface magnification level of a surface. More...
 
static Surface_Ids GetNextFreeSurfaceID (int iSkipCount=0, bool bAsyncUse=false, bool bLockMutex=true)
 Get the next free Dynamic Surface ID. More...
 
static bool IsSurfaceAllocated (Surface_Ids sid)
 Checks whether the specified surface is allocated or not. More...
 
static void FreeSurfaceID (Surface_Ids sid)
 Free a surface ID. More...
 
static void UnlockSurfaceID (Surface_Ids sid)
 Free a surface ID and set it as non-async. More...
 
static bool AllocateSurface (int w, int h, Surface_Ids iSurfId=SURFACE_ID_MAX, unsigned int iMagnification=0)
 Allocate a surface ID. More...
 
static bool LoadFileToSurface (const char *pFileName, Surface_Ids iSurfId=SURFACE_ID_MAX, bool bAsync=false, unsigned int iMagnification=0)
 Load an image from a file into the selected surface ID. More...
 
static bool SaveSurfaceToFile (const char *pFileName, Surface_Ids iSurfId=SURFACE_ID_MAX)
 Save an image from a surface to a file. More...
 
static void DrawPixel (GUI_POINT pPoint, unsigned long color, bool bAbsolutePos=false)
 Draw a pixel. More...
 
static void DrawPixels (GUI_POINT *pPointList, unsigned int iPointCount, unsigned long color, bool bAbsolutePos=false)
 Draw pixels. More...
 
static void DrawLine (GUI_POINT start, GUI_POINT end, unsigned long color, bool bUseMagnification=true)
 Draw a line. More...
 
static void DrawStripedLine (GUI_POINT start, GUI_POINT end, unsigned long color)
 Draw a striped line. More...
 
static void DrawStripedRect (GUI_RECT *pRect, unsigned long iColor)
 Draw a striped rect. More...
 
static void DrawGradientLine (GUI_POINT start, GUI_POINT end, unsigned long *colors, int colorcount)
 Draw a line with color gradient. More...
 
static void DrawClearRect (GUI_RECT *r)
 Clear a given rect. More...
 
static void DrawFilledRect (GUI_RECT *r, unsigned long color, bool bAbsolutePos=false)
 Fill a given rect. More...
 
static void DrawRect (GUI_RECT *r, unsigned long color, bool bAbsolutePos=false)
 Outline a given rect. More...
 
static void DrawFilledRectTransparent (GUI_RECT *r, unsigned long color, bool bAbsolutePos=false)
 Fill a given rect. More...
 
static void DrawRectTransparent (GUI_RECT *r, unsigned long color, bool bAbsolutePos=false)
 Outline a given rect. More...
 
static void DrawFilledCircle (GUI_POINT p, int size, unsigned long color, bool invert=false)
 Draw a filled circle. More...
 
static void DrawFilledTriangle (GUI_POINT *points, unsigned long color)
 Draw a filled triangle. More...
 
static void DrawCircle (GUI_POINT p, int size, unsigned long color)
 Draw a circle. More...
 
static void DrawTriangle (GUI_POINT *points, unsigned long color)
 Draw a triangle. More...
 
static GUI_POINT DrawFilledBitmapRect (GUI_RECT *drawRect, GUI_RECT *srcRect, Surface_Ids sid, GUI_POINT drawPadding=GUI_POINT(0, 0))
 Draw a filled bitmap rect. More...
 
static GUI_POINT DrawBitmap (GUI_POINT p, GUI_RECT *srcRect, Surface_Ids sid, bool bAbsolutePos=false)
 Draw an image. More...
 
static GUI_POINT DrawStretchedBitmap (GUI_RECT *r, GUI_RECT *srcRect, Surface_Ids sid, GUI_COLOR color, bool bAbsolutePos=false)
 Draw an image. More...
 
static GUI_POINT DrawColoredBitmap (GUI_POINT p, GUI_RECT *srcRect, Surface_Ids sid, GUI_COLOR color, bool bAbsolutePos=false)
 Draw a colored image. More...
 
static void DrawText (GUI_POINT p, FontObject *font, const char *text, unsigned long color)
 Draw text. More...
 
static void DrawClippedText (GUI_POINT p, FontObject *font, const char *text, unsigned long color, int iStringLength=-1, bool bWrap=false, GUI_POINT *pDrawSize=NULL, int iShadowSize=0, unsigned long iShadowColor=0)
 Draw clipped text. More...
 
static void DrawClippedTextNoMagnification (GUI_POINT p, FontObject *font, const char *text, unsigned long color, int iStringLength=-1, bool bWrap=false, GUI_POINT *pDrawSize=NULL, int iShadowSize=0, unsigned long iShadowColor=0)
 Draw clipped text. More...
 
static void DrawSpecialText (GUI_POINT p, SpecialTextCache *pCache)
 Draw clipped special text. More...
 
static void DrawBitmapBox (GUI_RECT *out_rect, GUI_RECT *bmp_rects, BitmapBoxType type, Surface_Ids bmp_id)
 Draw a bitmap box. More...
 
static void DrawTransparentBitmapBox (GUI_RECT *out_rect, GUI_RECT *bmp_rects, BitmapBoxType type, Surface_Ids bmp_id, int iAlpha)
 Draw a transparent bitmap box. More...
 
static void SetNeedsUpdating ()
 Force an update for this surface internally.
 
static GUI_POINT GetBitmapBoxSize (GUI_POINT *desired_extent, GUI_RECT *bmp_rects, BitmapBoxType type)
 Get the size of a bitmap box. More...
 
static void Put (GUI_POINT out_pos, Surface_Ids sid=SURFACE_ID_MAX, bool bAbsolutePos=false)
 Draw a surface to the screen. More...
 
static void PutAlpha (GUI_POINT out_pos, Surface_Ids sid=SURFACE_ID_MAX, unsigned char Alpha=255, bool bAbsolutePos=false)
 Draw a transparent surface to the screen. More...
 
static GUI_COLOR GetPixelColor (GUI_POINT p, Surface_Ids sid, bool bAbsolutePos=false)
 
static GUI_COLOR GetEntityPixel (NPCHAR *npc, GUI_POINT p)
 

Detailed Description

Rendering pipeline for Cavestory Multiplayer.

Member Enumeration Documentation

◆ BitmapBoxType

Bitmap box type for CacheSurface::GetBitmapBoxSize and CacheSurface::DrawBitmapBox.

Enumerator
BMPBOX_TYPE_WIDTH 

Dynamic width (requires 3 'bmp_rects' elements) – Left, mid-loop, right.

BMPBOX_TYPE_HEIGHT 

Dynamic height (requires 3 'bmp_rects' elements) – Top, mid-loop, bottom.

BMPBOX_TYPE_BOTH 

Dynamic width & height (requires 9 'bmp_rects' elements) – Top-left, top-loop, top-right, mid-left, mid-loop, mid-right, btm-left, btm-loop, btm-right.

Member Function Documentation

◆ AllocateSurface()

static bool CacheSurface::AllocateSurface ( int  w,
int  h,
Surface_Ids  iSurfId = SURFACE_ID_MAX,
unsigned int  iMagnification = 0 
)
static

Allocate a surface ID.

Parameters
wThe width of the new surface.
hThe height of the new surface.
iSurfIdThe surface to use. Leave as 'SURFACE_ID_MAX' to use the currently selected surface.
iMagnificationThe magnification level to use. Pass '0' to use UI scale.
Returns
Returns true on success.
See also
CacheSurface::SetSurfaceID
CacheSurface::GetNextFreeSurfaceID
CacheSurface::FreeSurfaceID

◆ ClearClipRectList()

static void CacheSurface::ClearClipRectList ( )
static

Clear the clip rect.

See also
SetClipRect

◆ DrawBitmap()

static GUI_POINT CacheSurface::DrawBitmap ( GUI_POINT  p,
GUI_RECT srcRect,
Surface_Ids  sid,
bool  bAbsolutePos = false 
)
static

Draw an image.

Parameters
pThe position to draw the image at.
srcRectThe rect to copy from. Can be NULL to copy the entire source image.
sidThe source image's surface ID.
bAbsolutePosIf this is true, then r will not be magnified.
Returns
Returns the size of the validated rect.
Examples
RenderPipeline.cpp.

◆ DrawBitmapBox()

static void CacheSurface::DrawBitmapBox ( GUI_RECT out_rect,
GUI_RECT bmp_rects,
BitmapBoxType  type,
Surface_Ids  bmp_id 
)
static

Draw a bitmap box.

Parameters
out_rectThe rect to draw it at. Can be NULL to use the entire destination surface.
bmp_rectsA list of GUI_RECT. Must conform to the size required by parameter 'type'.
typeThe type of bitmap box to draw.
bmp_idThe source image's surface ID.
Examples
WelcomeMode.cpp.

◆ DrawCircle()

static void CacheSurface::DrawCircle ( GUI_POINT  p,
int  size,
unsigned long  color 
)
static

Draw a circle.

Parameters
pThe center of the circle.
sizeThe size of the circle.
colorThe color of the circle.
See also
CSM_RGB
CSM_RGBA

◆ DrawClearRect()

static void CacheSurface::DrawClearRect ( GUI_RECT r)
static

Clear a given rect.

Parameters
rThe rect to clear. Can be NULL to clear the entire surface.

◆ DrawClippedText()

static void CacheSurface::DrawClippedText ( GUI_POINT  p,
FontObject *  font,
const char *  text,
unsigned long  color,
int  iStringLength = -1,
bool  bWrap = false,
GUI_POINT pDrawSize = NULL,
int  iShadowSize = 0,
unsigned long  iShadowColor = 0 
)
static

Draw clipped text.

Parameters
pThe position to draw the text at.
fontThe font to use.
textThe text to draw.
colorThe color to draw the text with.
iStringLengthThe length of the string to draw. Can be -1 to automatically detect the length of the string.
bWrapWrap the string if it reaches the edge of the clip rect.
pDrawSizeA pointer to a GUI_POINT that will hold the size of the output text.
iShadowSizeThe size of the text's shadow. If set to 0, no shadow will be drawn.
iShadowColorThe color of the shadow.
Note
Unlike CacheSurface::DrawText, this function enforces the clip rect.
See also
CSM_RGB
CSM_RGBA
Examples
RenderPipeline.cpp.

◆ DrawClippedTextNoMagnification()

static void CacheSurface::DrawClippedTextNoMagnification ( GUI_POINT  p,
FontObject *  font,
const char *  text,
unsigned long  color,
int  iStringLength = -1,
bool  bWrap = false,
GUI_POINT pDrawSize = NULL,
int  iShadowSize = 0,
unsigned long  iShadowColor = 0 
)
static

Draw clipped text.

Parameters
pThe position to draw the text at.
fontThe font to use.
textThe text to draw.
colorThe color to draw the text with.
iStringLengthThe length of the string to draw. Can be -1 to automatically detect the length of the string.
bWrapWrap the string if it reaches the edge of the clip rect.
pDrawSizeA pointer to a GUI_POINT that will hold the size of the output text.
iShadowSizeThe size of the text's shadow. If set to 0, no shadow will be drawn.
iShadowColorThe color of the shadow.
Note
Unlike CacheSurface::DrawText, this function enforces the clip rect.
See also
CSM_RGB
CSM_RGBA

◆ DrawColoredBitmap()

static GUI_POINT CacheSurface::DrawColoredBitmap ( GUI_POINT  p,
GUI_RECT srcRect,
Surface_Ids  sid,
GUI_COLOR  color,
bool  bAbsolutePos = false 
)
static

Draw a colored image.

Parameters
pThe position to draw the image at.
srcRectThe rect to copy from. Can be NULL to copy the entire source image.
sidThe source image's surface ID.
colorThe color to modulate the source image by.
bAbsolutePosIf this is true, then r will not be magnified.
Returns
Returns the size of the validated rect.
See also
CSM_RGB
CSM_RGBA

◆ DrawFilledBitmapRect()

static GUI_POINT CacheSurface::DrawFilledBitmapRect ( GUI_RECT drawRect,
GUI_RECT srcRect,
Surface_Ids  sid,
GUI_POINT  drawPadding = GUI_POINT(0, 0) 
)
static

Draw a filled bitmap rect.

Parameters
drawRectThe rect to fill with the source image.
srcRectThe rect to copy from. Can be NULL to copy the entire source image.
sidThe source image's surface ID.
drawPaddingMargin for drawRect.
Returns
Returns the size of the validated rect.

◆ DrawFilledCircle()

static void CacheSurface::DrawFilledCircle ( GUI_POINT  p,
int  size,
unsigned long  color,
bool  invert = false 
)
static

Draw a filled circle.

Parameters
pThe center of the circle.
sizeThe size of the circle.
colorThe color of the circle.
invertIf set to true, then fill everything EXCEPT the inside of the circle.
See also
CSM_RGB
CSM_RGBA

◆ DrawFilledRect()

static void CacheSurface::DrawFilledRect ( GUI_RECT r,
unsigned long  color,
bool  bAbsolutePos = false 
)
static

Fill a given rect.

Parameters
rThe rect to fill. Can be NULL to fill the entire surface.
colorThe color to fill with.
bAbsolutePosIf this is true, then pPoint will not be magnified.
See also
CSM_RGB
CSM_RGBA
Examples
WelcomeMode.cpp.

◆ DrawFilledRectTransparent()

static void CacheSurface::DrawFilledRectTransparent ( GUI_RECT r,
unsigned long  color,
bool  bAbsolutePos = false 
)
static

Fill a given rect.

Parameters
rThe rect to fill. Can be NULL to fill the entire surface.
colorThe color to fill with.
bAbsolutePosIf this is true, then pPoint will not be magnified.
See also
CSM_RGB
CSM_RGBA

◆ DrawFilledTriangle()

static void CacheSurface::DrawFilledTriangle ( GUI_POINT points,
unsigned long  color 
)
static

Draw a filled triangle.

Parameters
pointsA pointer to a GUI_POINT array w/ minimum size 3.
colorThe color of the triangle.
See also
CSM_RGB
CSM_RGBA

◆ DrawGradientLine()

static void CacheSurface::DrawGradientLine ( GUI_POINT  start,
GUI_POINT  end,
unsigned long *  colors,
int  colorcount 
)
static

Draw a line with color gradient.

Parameters
startLine start point.
endLine end point.
colorsA pointer to an array of colors.
colorcountHow many colors are in the 'colors' array. This is how many times the line will be segmented to display each color.
See also
CSM_RGB
CSM_RGBA

◆ DrawLine()

static void CacheSurface::DrawLine ( GUI_POINT  start,
GUI_POINT  end,
unsigned long  color,
bool  bUseMagnification = true 
)
static

Draw a line.

Parameters
startLine start point.
endLine end point.
colorThe color of the line.
bUseMagnificationDraw a line as big as the current magnification amount.
See also
CSM_RGB
CSM_RGBA
Examples
RenderPipeline.cpp.

◆ DrawPixel()

static void CacheSurface::DrawPixel ( GUI_POINT  pPoint,
unsigned long  color,
bool  bAbsolutePos = false 
)
static

Draw a pixel.

Parameters
pPointThe point to draw a pixel at.
colorThe color of the pixel.
bAbsolutePosIf this is true, then pPoint will not be magnified.
See also
CSM_RGB
CSM_RGBA

◆ DrawPixels()

static void CacheSurface::DrawPixels ( GUI_POINT pPointList,
unsigned int  iPointCount,
unsigned long  color,
bool  bAbsolutePos = false 
)
static

Draw pixels.

Parameters
pPointListThe point to draw a pixel at.
iPointCountThe number of points in pPointList.
colorThe color of the pixel.
bAbsolutePosIf this is true, then points in the pPointList will not be magnified.
See also
CSM_RGB
CSM_RGBA

◆ DrawRect()

static void CacheSurface::DrawRect ( GUI_RECT r,
unsigned long  color,
bool  bAbsolutePos = false 
)
static

Outline a given rect.

Parameters
rThe rect to outline. Can be NULL to outline the entire surface.
colorThe color to fill with.
bAbsolutePosIf this is true, then pPoint will not be magnified.
See also
CSM_RGB
CSM_RGBA

◆ DrawRectTransparent()

static void CacheSurface::DrawRectTransparent ( GUI_RECT r,
unsigned long  color,
bool  bAbsolutePos = false 
)
static

Outline a given rect.

Parameters
rThe rect to outline. Can be NULL to outline the entire surface.
colorThe color to fill with.
bAbsolutePosIf this is true, then pPoint will not be magnified.
See also
CSM_RGB
CSM_RGBA

◆ DrawSpecialText()

static void CacheSurface::DrawSpecialText ( GUI_POINT  p,
SpecialTextCache pCache 
)
static

Draw clipped special text.

Parameters
pThe position to draw the text at.
pCacheThe special text cache that holds the drawing instructions.

◆ DrawStretchedBitmap()

static GUI_POINT CacheSurface::DrawStretchedBitmap ( GUI_RECT r,
GUI_RECT srcRect,
Surface_Ids  sid,
GUI_COLOR  color,
bool  bAbsolutePos = false 
)
static

Draw an image.

Parameters
rThe rect to draw the bitmap in.
srcRectThe rect to copy from. Can be NULL to copy the entire source image.
sidThe source image's surface ID.
colorThe color to modulate the source image by.
bAbsolutePosIf this is true, then r will not be magnified.
Returns
Returns the size of the validated rect.

◆ DrawStripedLine()

static void CacheSurface::DrawStripedLine ( GUI_POINT  start,
GUI_POINT  end,
unsigned long  color 
)
static

Draw a striped line.

Parameters
startLine start point.
endLine end point.
colorThe color of the line.
See also
CSM_RGB
CSM_RGBA

◆ DrawStripedRect()

static void CacheSurface::DrawStripedRect ( GUI_RECT pRect,
unsigned long  iColor 
)
static

Draw a striped rect.

Parameters
pRectThe rect to draw.
iColorThe color of the line.
See also
CSM_RGB
CSM_RGBA

◆ DrawText()

static void CacheSurface::DrawText ( GUI_POINT  p,
FontObject *  font,
const char *  text,
unsigned long  color 
)
static

Draw text.

Parameters
pThe position to draw the text at.
fontThe font to use.
textThe text to draw.
colorThe color to draw the text with.
See also
CSM_RGB
CSM_RGBA

◆ DrawTransparentBitmapBox()

static void CacheSurface::DrawTransparentBitmapBox ( GUI_RECT out_rect,
GUI_RECT bmp_rects,
BitmapBoxType  type,
Surface_Ids  bmp_id,
int  iAlpha 
)
static

Draw a transparent bitmap box.

Parameters
out_rectThe rect to draw it at. Can be NULL to use the entire destination surface.
bmp_rectsA list of GUI_RECT. Must conform to the size required by parameter 'type'.
typeThe type of bitmap box to draw.
bmp_idThe source image's surface ID.

◆ DrawTriangle()

static void CacheSurface::DrawTriangle ( GUI_POINT points,
unsigned long  color 
)
static

Draw a triangle.

Parameters
pointsA pointer to a GUI_POINT array w/ minimum size 3.
colorThe color of the triangle.
See also
CSM_RGB
CSM_RGBA

◆ FreeSurfaceID()

static void CacheSurface::FreeSurfaceID ( Surface_Ids  sid)
static

Free a surface ID.

Parameters
sidThe surface ID to free.
Examples
RenderPipeline.cpp.

◆ GetBitmapBoxSize()

static GUI_POINT CacheSurface::GetBitmapBoxSize ( GUI_POINT desired_extent,
GUI_RECT bmp_rects,
BitmapBoxType  type 
)
static

Get the size of a bitmap box.

Parameters
desired_extentThe desired extent of the output.
bmp_rectsA list of GUI_RECT. Must conform to the size required by parameter 'type'.
typeThe type of bitmap box to draw.
Returns
Returns the best-fitting extent.

◆ GetClipRect()

static void CacheSurface::GetClipRect ( GUI_RECT r)
static

Get the current clip rect.

Parameters
rA pointer to a RECT that will hold the clip rect.
Returns
Returns the current clip rect.

◆ GetCurrentVideoTexture()

static VideoTexture* CacheSurface::GetCurrentVideoTexture ( )
static

Get the currently selected video texture.

Returns
Returns the selected video texture object.

◆ GetFreeSurfaceCount()

static int CacheSurface::GetFreeSurfaceCount ( )
static

Self-explanatory.

Returns
Returns how many dynamic surfaces are still allocatable.

◆ GetNextFreeSurfaceID()

static Surface_Ids CacheSurface::GetNextFreeSurfaceID ( int  iSkipCount = 0,
bool  bAsyncUse = false,
bool  bLockMutex = true 
)
static

Get the next free Dynamic Surface ID.

Parameters
iSkipCountSkip this many free slots before returning one.
bAsyncUseIf set to true, then this function will act as if this surface is in use, and will not return it next time.
bLockMutexIf set to true, then the mutex will be locked.
Returns
Returns the next allocatable surface ID if available; Otherwise, returns Surface_Ids::SURFACE_ID_MAX if no surfaces are available.
See also
CacheSurface::FreeSurfaceID
Examples
RenderPipeline.cpp.

◆ GetSurfaceID()

static Surface_Ids CacheSurface::GetSurfaceID ( )
static

Get the surface ID that we're currently editing.

Returns
Returns the selected surface ID.

◆ GetSurfaceIDMagnification()

static int CacheSurface::GetSurfaceIDMagnification ( Surface_Ids  sid)
static

Get the surface magnification level of a surface.

Parameters
sidThe surface ID to get the magnifier of.
Returns
Returns the magnification level of the specified surface id if it's allocated; returns the global magnification level if the given surface ID is not allocated.

◆ GetSurfaceIDSize()

static GUI_POINT CacheSurface::GetSurfaceIDSize ( Surface_Ids  sid)
static

Get the surface size of a surface.

Parameters
sidThe surface ID to get the size of.
Returns
Returns the size of the specified surface id if it's allocated; returns GUI_POINT(0, 0) if the given surface ID is not allocated.

◆ GetTextSize()

static GUI_POINT CacheSurface::GetTextSize ( FontObject *  pFont,
const char *  pText,
int  iTextLen = -1 
)
static

Get the size of a string of text w/ a font.

Parameters
pFontThe font to use.
pTextThe text to get the size of.
iTextLenThe text length.
Returns
Returns the text size.

◆ InitMemory()

static void CacheSurface::InitMemory ( )
static

Only called once upon engine init.

Do not call.

◆ IsInClipRect() [1/2]

static bool CacheSurface::IsInClipRect ( GUI_POINT  p)
static

Check to see if a point is inside the current clip rect.

Parameters
pThe point to test.
Returns
Returns true if the given point is inside the current clip rect.

◆ IsInClipRect() [2/2]

static bool CacheSurface::IsInClipRect ( GUI_RECT  r)
static

Check to see if a rect is inside the current clip rect.

Parameters
rThe rect to test.
Returns
Returns true if the given rect is inside the current clip rect.

◆ IsInClipRectWithCustomMag()

static bool CacheSurface::IsInClipRectWithCustomMag ( GUI_RECT  r,
int  customMagnification 
)
static

Check to see if a rect is inside the current clip rect.

Parameters
rThe rect to test.
customMagnificationThe custom magnification level to use.
Returns
Returns true if the given rect is inside the current clip rect.

◆ IsSurfaceAllocated()

static bool CacheSurface::IsSurfaceAllocated ( Surface_Ids  sid)
static

Checks whether the specified surface is allocated or not.

Parameters
sidThe surface ID to check.
Returns
Returns true if the surface is in use.

◆ LoadFileToSurface()

static bool CacheSurface::LoadFileToSurface ( const char *  pFileName,
Surface_Ids  iSurfId = SURFACE_ID_MAX,
bool  bAsync = false,
unsigned int  iMagnification = 0 
)
static

Load an image from a file into the selected surface ID.

Parameters
pFileNameThe file name of the image.
iSurfIdThe surface to use. Leave as 'SURFACE_ID_MAX' to use the currently selected surface.
bAsyncWhether this is an asynchronous operation or not.
iMagnificationThe magnification level to use. Pass '0' to use UI scale.
Returns
Returns true on success.
See also
CacheSurface::SetSurfaceID
CacheSurface::GetNextFreeSurfaceID
CacheSurface::FreeSurfaceID
Examples
RenderPipeline.cpp.

◆ Put()

static void CacheSurface::Put ( GUI_POINT  out_pos,
Surface_Ids  sid = SURFACE_ID_MAX,
bool  bAbsolutePos = false 
)
static

Draw a surface to the screen.

Parameters
out_posWhere to draw the surface at.
sidThe surface ID to draw. Use CacheSurface::SURFACE_ID_MAX to draw the selected Surface ID.
bAbsolutePosIf this is true, it will use out_pos without magnifying it.

◆ PutAlpha()

static void CacheSurface::PutAlpha ( GUI_POINT  out_pos,
Surface_Ids  sid = SURFACE_ID_MAX,
unsigned char  Alpha = 255,
bool  bAbsolutePos = false 
)
static

Draw a transparent surface to the screen.

Parameters
out_posWhere to draw the surface at.
sidThe surface ID to draw. Use CacheSurface::SURFACE_ID_MAX to draw the selected Surface ID.
AlphaThe amount the image should blend into the background.
bAbsolutePosIf this is true, it will use out_pos without magnifying it.

◆ RememberSurfaceID()

static BOOL CacheSurface::RememberSurfaceID ( )
static

Remember the currently selected SurfaceID.

Can remember up to 32 entries.

See also
SetSurfaceID
RestoreSurfaceID
Returns
Returns true on success, false otherwise.

◆ RestoreSurfaceID()

static BOOL CacheSurface::RestoreSurfaceID ( )
static

Return the current SurfaceID selection to the last one stored with RememberSurfaceID().

See also
SetSurfaceID
RememberSurfaceID
Returns
Returns true on success, false otherwise.

◆ SaveSurfaceToFile()

static bool CacheSurface::SaveSurfaceToFile ( const char *  pFileName,
Surface_Ids  iSurfId = SURFACE_ID_MAX 
)
static

Save an image from a surface to a file.

Parameters
pFileNameThe file name of the image to save.
iSurfIdThe surface to use. Leave as 'SURFACE_ID_MAX' to use the currently selected surface.

◆ SelectRendererSurface()

static BOOL CacheSurface::SelectRendererSurface ( int  iCustomMagnification = 0)
static

Alias of SetSurfaceID, handles selecting SURFACE_ID_RENDERER with a custom magnification.

Parameters
magnificationThe magnification to use. Pass '0' to signify to use 'magnification'.
See also
SetSurfaceID
Returns
Returns true on success, false otherwise.

◆ SelectRendererSurfaceAndRememberPrevious()

static BOOL CacheSurface::SelectRendererSurfaceAndRememberPrevious ( int  iCustomMagnification = 0)
static

Alias of SetSurfaceID, handles selecting SURFACE_ID_RENDERER with a custom magnification.

Parameters
magnificationThe magnification to use. Pass '0' to signify to use 'magnification'.
See also
SetSurfaceID
Returns
Returns true on success, false otherwise.

◆ SetClipRect()

static void CacheSurface::SetClipRect ( GUI_RECT r,
bool  bAbsoluteRect = false 
)
static

Add a new clip rect.

Parameters
rThe rect to set.
bAbsoluteRectIf this is 'false', r will be multiplied by the current magnification.
Note
When a clip rect is set, it is added to a list of Clip Rects, and can be removed from said list by passing 'NULL' to 'r'.
Additionally, if there is already a clip rect in the list, it will contain the new clip rect to be completely inside of the old one.

◆ SetCurrentTexture()

static BOOL CacheSurface::SetCurrentTexture ( VideoTexture pTexture)
static

Set the texture that should be used when rendering stuff.

Parameters
pTextureThe texture to set.
See also
Surface_Ids
Returns
Returns true on success, false otherwise.

◆ SetSurfaceID()

static BOOL CacheSurface::SetSurfaceID ( Surface_Ids  sid)
static

Set the surface ID that we're editing.

Parameters
sidThe surface ID to edit.
See also
Surface_Ids
SelectRendererSurface
Returns
Returns true on success, false otherwise.
Examples
RenderPipeline.cpp.

◆ SetSurfaceIDAndRememberPrevious()

static BOOL CacheSurface::SetSurfaceIDAndRememberPrevious ( Surface_Ids  sid)
static

Set the surface ID that we're editing.

Parameters
sidThe surface ID to edit.
See also
Surface_Ids
SelectRendererSurface
Returns
Returns true on success, false otherwise.

◆ TryClipPoint()

static bool CacheSurface::TryClipPoint ( GUI_POINT p)
static

Try to contain a point inside of the clip rect.

Parameters
pThe point to test.
Returns
Returns true if the point was successfully truncated to the cliprect, false if it could not be.

◆ UnlockSurfaceID()

static void CacheSurface::UnlockSurfaceID ( Surface_Ids  sid)
static

Free a surface ID and set it as non-async.

Parameters
sidThe surface ID to free.

The documentation for this struct was generated from the following file: