Cavestory Mod API
CSMAPI_drawing.h
Go to the documentation of this file.
1 /*
2  Cavestory Multiplayer API
3  Copyright (C) 2021 Johnny Ledger
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
26 #pragma once
27 
28 class VideoTexture;
29 struct NPCHAR;
30 #include <List.h>
31 #include <CSMAPI_begincode.h>
32 
33 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
34 
38 
39 struct Mouse
40 {
41  static CAVESTORY_MOD_API void SetMousePosition(GUI_POINT new_position);
42  static CAVESTORY_MOD_API GUI_POINT GetMousePosition();
43 
44  static CAVESTORY_MOD_API void SetVisible(bool val);
45  static CAVESTORY_MOD_API bool IsVisible();
46 };
47 
50 
54 
55 typedef struct FontObject FontObject;
57 
60 #define FONT_OBJECT_SIZE 1040
61 
62 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
63 
65 #define TEXT_SIZE(font_object, string, ptr_x, ptr_y) GetTextSize(font_object, string, strlen(string), &ptr_x, &ptr_y); ptr_x /= magnification; ptr_y /= magnification;
66 
68 #define TEXT_SIZE_2(font_object, string, string_length, ptr_x, ptr_y) GetTextSize(font_object, string, string_length, &ptr_x, &ptr_y); ptr_x /= magnification; ptr_y /= magnification;
69 
71 #define TEXT_WIDTH(font_object, string) (GetTextWidth(font_object, string) / magnification)
72 
74 #define TEXT_HEIGHT(font_object, string) (GetTextHeight(font_object, string) / magnification)
75 
77 #define TEXT_WIDTH_2(font_object, string, string_length) (GetTextWidth(font_object, string, string_length) / magnification)
78 
80 #define TEXT_HEIGHT_2(font_object, string, string_length) (GetTextHeight(font_object, string, string_length) / magnification)
81 
83 #define TEXT_WIDTH_2S(font_object, string) (GetTextWidth(font_object, string, strlen(string)) / magnification)
84 
86 #define TEXT_HEIGHT_2S(font_object, string) (GetTextHeight(font_object, string, strlen(string)) / magnification)
87 
89 #define FONT_ASCII_HEIGHT(font_object) (GetTextHeight(font_object, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") / magnification)
90 
91 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
92 
94 #define UI_TEXT_SIZE(font_object, string, ptr_x, ptr_y) GetTextSize(font_object, string, strlen(string), &ptr_x, &ptr_y); ptr_x /= CSM_GetUIMagnificationLevel(); ptr_y /= CSM_GetUIMagnificationLevel();
95 
97 #define UI_TEXT_SIZE_2(font_object, string, string_length, ptr_x, ptr_y) GetTextSize(font_object, string, string_length, &ptr_x, &ptr_y); ptr_x /= CSM_GetUIMagnificationLevel(); ptr_y /= CSM_GetUIMagnificationLevel();
98 
100 #define UI_TEXT_WIDTH(font_object, string) (GetTextWidth(font_object, string) / CSM_GetUIMagnificationLevel())
101 
103 #define UI_TEXT_HEIGHT(font_object, string) (GetTextHeight(font_object, string) / CSM_GetUIMagnificationLevel())
104 
106 #define UI_TEXT_WIDTH_2(font_object, string, string_length) (GetTextWidth(font_object, string, string_length) / CSM_GetUIMagnificationLevel())
107 
109 #define UI_TEXT_HEIGHT_2(font_object, string, string_length) (GetTextHeight(font_object, string, string_length) / CSM_GetUIMagnificationLevel())
110 
112 #define UI_TEXT_WIDTH_2S(font_object, string) (GetTextWidth(font_object, string, strlen(string)) / CSM_GetUIMagnificationLevel())
113 
115 #define UI_TEXT_HEIGHT_2S(font_object, string) (GetTextHeight(font_object, string, strlen(string)) / CSM_GetUIMagnificationLevel())
116 
118 #define UI_FONT_ASCII_HEIGHT(font_object) (GetTextHeight(font_object, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") / CSM_GetUIMagnificationLevel())
119 
120 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
121 
123 #define CUSTOMMAG_TEXT_SIZE(INPUT_MAG, font_object, string, ptr_x, ptr_y) GetTextSize(font_object, string, strlen(string), &ptr_x, &ptr_y); ptr_x /= INPUT_MAG; ptr_y /= INPUT_MAG;
124 
126 #define CUSTOMMAG_TEXT_SIZE_2(INPUT_MAG, font_object, string, string_length, ptr_x, ptr_y) GetTextSize(font_object, string, string_length, &ptr_x, &ptr_y); ptr_x /= INPUT_MAG; ptr_y /= INPUT_MAG;
127 
129 #define CUSTOMMAG_TEXT_WIDTH(INPUT_MAG, font_object, string) (GetTextWidth(font_object, string) / INPUT_MAG)
130 
132 #define CUSTOMMAG_TEXT_HEIGHT(INPUT_MAG, font_object, string) (GetTextHeight(font_object, string) / INPUT_MAG)
133 
135 #define CUSTOMMAG_TEXT_WIDTH_2(INPUT_MAG, font_object, string, string_length) (GetTextWidth(font_object, string, string_length) / INPUT_MAG)
136 
138 #define CUSTOMMAG_TEXT_HEIGHT_2(INPUT_MAG, font_object, string, string_length) (GetTextHeight(font_object, string, string_length) / INPUT_MAG)
139 
141 #define CUSTOMMAG_TEXT_WIDTH_2S(INPUT_MAG, font_object, string) (GetTextWidth(font_object, string, strlen(string)) / INPUT_MAG)
142 
144 #define CUSTOMMAG_TEXT_HEIGHT_2S(INPUT_MAG, font_object, string) (GetTextHeight(font_object, string, strlen(string)) / INPUT_MAG)
145 
147 #define CUSTOMMAG_FONT_ASCII_HEIGHT(INPUT_MAG, font_object) (GetTextHeight(font_object, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") / INPUT_MAG)
148 
149 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
150 
155 
160 
166 extern CAVESTORY_MOD_API void SetFontCharacterWhitelist(const unsigned char* pWhitelist);
167 
172 extern CAVESTORY_MOD_API void SetFontWhitelistEnabled(bool bEnabled);
173 
177 extern CAVESTORY_MOD_API const unsigned char* GetFontCharacterWhitelist();
178 
188 extern CAVESTORY_MOD_API FontObject* LoadFontFromFile(const char* pFileName, unsigned int cell_width, unsigned int cell_height, VideoTexture* pTexture = NULL, FontManager* pManager = NULL);
189 
194 extern CAVESTORY_MOD_API void SetFontTexture(FontObject* pFont, VideoTexture* pTexture);
195 
206 extern CAVESTORY_MOD_API FontObject* LoadFontFromData(const unsigned char* data, size_t data_size, unsigned int cell_width, unsigned int cell_height, VideoTexture* pTexture = NULL, FontManager* pManager = NULL);
207 
218 extern CAVESTORY_MOD_API FontObject* LoadFont(const char* font_filename, unsigned int cell_width, unsigned int cell_height, VideoTexture* pTexture = NULL, FontManager* pManager = NULL);
219 
227 extern CAVESTORY_MOD_API void GetTextSize(FontObject* font_object, const char* string, size_t string_length, int* size_x, int* size_y);
228 
236 extern CAVESTORY_MOD_API unsigned int GetTextWidth(FontObject* font_object, const char* string, size_t string_length = size_t(-1));
237 
245 extern CAVESTORY_MOD_API unsigned int GetTextHeight(FontObject* font_object, const char* string, size_t string_length = size_t(-1));
246 
253 extern CAVESTORY_MOD_API BOOL IsFontLinkedToTexture(FontObject* font_object, VideoTexture* pTexture);
254 
260 extern CAVESTORY_MOD_API int GetFontMagnification(FontObject* font_object);
261 
267 extern CAVESTORY_MOD_API int GetFontHeight(FontObject* font_object);
268 
285 extern CAVESTORY_MOD_API void DrawNormalText(FontObject* font_object, unsigned char* bitmap_buffer, size_t bitmap_pitch, int bitmap_width, int bitmap_height, int x, int y, unsigned long colour, const char* string, size_t string_length);
286 
307 extern CAVESTORY_MOD_API void DrawClippedText(FontObject* font_object, unsigned char* bitmap_buffer, size_t bitmap_pitch, int bitmap_width, int bitmap_height, int x, int y, unsigned long colour, const char* string, size_t string_length, int clipLEFT, int clipTOP, int clipRIGHT, int clipBOTTOM, float iOutAlpha = 1.f);
308 
312 extern CAVESTORY_MOD_API void UnloadFont(FontObject* font_object);
313 
320 extern CAVESTORY_MOD_API unsigned long UTF8ToUnicode(const unsigned char* string, unsigned int* bytes_read);
321 
325 
329 
332 
336 
340 {
344 
347  int tab_num;
348 
352 
355  unsigned long color;
356 
359  char* start;
360 
363  int length;
364 
368 
372 
376 
380 
383  int line_no;
384 
388 };
389 
393 {
397 
401 
404  List<SpecialTextNode*> mTextList;
405 
408  char* mFullText;
409  int mFullTextSize;
410  int mFullTextLen;
411 
415 
419 
429  bool Parse(FontObject* pFont, const char* pString, int iLength = -1, unsigned long iColor = 0xFFFFFFFF, int iDestWidth = 0);
430 
433  void Free();
434 };
435 
439 {
443  {
445  BMPBOX_TYPE_WIDTH = 0,
446 
449 
451  BMPBOX_TYPE_BOTH
452  };
453 
456  static void InitMemory();
457 
465  static GUI_POINT GetTextSize(FontObject* pFont, const char* pText, int iTextLen = -1);
466 
473  static BOOL SetCurrentTexture(VideoTexture* pTexture);
474 
482  static BOOL SetSurfaceID(Surface_Ids sid);
483 
490  static BOOL SelectRendererSurface(int iCustomMagnification = 0);
491 
500 
507  static BOOL SelectRendererSurfaceAndRememberPrevious(int iCustomMagnification = 0);
508 
514  static BOOL RememberSurfaceID();
515 
521  static BOOL RestoreSurfaceID();
522 
527 
532 
536  static int GetFreeSurfaceCount();
537 
543  static bool TryClipPoint(GUI_POINT& p);
544 
550  static bool IsInClipRect(GUI_POINT p);
551 
557  static bool IsInClipRect(GUI_RECT r);
558 
565  static bool IsInClipRectWithCustomMag(GUI_RECT r, int customMagnification);
566 
574  static void SetClipRect(GUI_RECT* r, bool bAbsoluteRect = false);
575 
581  static void GetClipRect(GUI_RECT* r);
582 
586  static void ClearClipRectList();
587 
594 
601 
611  static Surface_Ids GetNextFreeSurfaceID(int iSkipCount = 0, bool bAsyncUse = false, bool bLockMutex = true);
612 
618  static bool IsSurfaceAllocated(Surface_Ids sid);
619 
623  static void FreeSurfaceID(Surface_Ids sid);
624 
628  static void UnlockSurfaceID(Surface_Ids sid);
629 
642  static bool AllocateSurface(int w, int h, Surface_Ids iSurfId = SURFACE_ID_MAX, unsigned int iMagnification = 0);
643 
656  static bool LoadFileToSurface(const char* pFileName, Surface_Ids iSurfId = SURFACE_ID_MAX, bool bAsync = false, unsigned int iMagnification = 0);
657 
662  static bool SaveSurfaceToFile(const char* pFileName, Surface_Ids iSurfId = SURFACE_ID_MAX);
663 
672  static void DrawPixel(GUI_POINT pPoint, unsigned long color, bool bAbsolutePos = false);
673 
683  static void DrawPixels(GUI_POINT* pPointList, unsigned int iPointCount, unsigned long color, bool bAbsolutePos = false);
684 
694  static void DrawLine(GUI_POINT start, GUI_POINT end, unsigned long color, bool bUseMagnification = true);
695 
704  static void DrawStripedLine(GUI_POINT start, GUI_POINT end, unsigned long color);
705 
713  static void DrawStripedRect(GUI_RECT* pRect, unsigned long iColor);
714 
724  static void DrawGradientLine(GUI_POINT start, GUI_POINT end, unsigned long* colors, int colorcount);
725 
729  static void DrawClearRect(GUI_RECT* r);
730 
739  static void DrawFilledRect(GUI_RECT* r, unsigned long color, bool bAbsolutePos = false);
740 
749  static void DrawRect(GUI_RECT* r, unsigned long color, bool bAbsolutePos = false);
750 
759  static void DrawFilledRectTransparent(GUI_RECT* r, unsigned long color, bool bAbsolutePos = false);
760 
769  static void DrawRectTransparent(GUI_RECT* r, unsigned long color, bool bAbsolutePos = false);
770 
780  static void DrawFilledCircle(GUI_POINT p, int size, unsigned long color, bool invert = false);
781 
789  static void DrawFilledTriangle(GUI_POINT* points, unsigned long color);
790 
799  static void DrawCircle(GUI_POINT p, int size, unsigned long color);
800 
808  static void DrawTriangle(GUI_POINT* points, unsigned long color);
809 
818  static GUI_POINT DrawFilledBitmapRect(GUI_RECT* drawRect, GUI_RECT* srcRect, Surface_Ids sid, GUI_POINT drawPadding = GUI_POINT(0, 0));
819 
828  static GUI_POINT DrawBitmap(GUI_POINT p, GUI_RECT* srcRect, Surface_Ids sid, bool bAbsolutePos = false);
829 
839  static GUI_POINT DrawStretchedBitmap(GUI_RECT* r, GUI_RECT* srcRect, Surface_Ids sid, GUI_COLOR color, bool bAbsolutePos = false);
840 
853  static GUI_POINT DrawColoredBitmap(GUI_POINT p, GUI_RECT* srcRect, Surface_Ids sid, GUI_COLOR color, bool bAbsolutePos = false);
854 
864  static void DrawText(GUI_POINT p, FontObject* font, const char* text, unsigned long color);
865 
882  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);
883 
900  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);
901 
906  static void DrawSpecialText(GUI_POINT p, SpecialTextCache* pCache);
907 
914  static void DrawBitmapBox(GUI_RECT* out_rect, GUI_RECT* bmp_rects, BitmapBoxType type, Surface_Ids bmp_id);
915 
922  static void DrawTransparentBitmapBox(GUI_RECT* out_rect, GUI_RECT* bmp_rects, BitmapBoxType type, Surface_Ids bmp_id, int iAlpha);
923 
926  static void SetNeedsUpdating();
927 
935  static GUI_POINT GetBitmapBoxSize(GUI_POINT* desired_extent, GUI_RECT* bmp_rects, BitmapBoxType type);
936 
942  static void Put(GUI_POINT out_pos, Surface_Ids sid = SURFACE_ID_MAX, bool bAbsolutePos = false);
943 
950  static void PutAlpha(GUI_POINT out_pos, Surface_Ids sid = SURFACE_ID_MAX, unsigned char Alpha = 255, bool bAbsolutePos = false);
951 
952 #ifdef _DEBUG
953  static void ShowSurfaceId(Surface_Ids sid, GUI_RECT* r, bool waitForInput = false);
954  static void DebugShow();
955 #endif
956 
957  static GUI_COLOR GetPixelColor(GUI_POINT p, Surface_Ids sid, bool bAbsolutePos = false);
958  static GUI_COLOR GetEntityPixel(NPCHAR* npc, GUI_POINT p);
959 };
960 
964 (
965  Surface_Ids sid,
966  GUI_RECT* rect,
967  CSM_QSA_Data* out
968 );
969 
973 (
974  CSM_QSA_Data* qsaptr
975 );
976 
979 extern CAVESTORY_MOD_API int ghWnd;
980 
984 
991  int hWnd
992 );
993 
1002  RECT* rcView,
1003  int x,
1004  int y,
1005  RECT* rect,
1006  Surface_Ids surf_no
1007 );
1008 
1017  RECT *rcView,
1018  int x,
1019  int y,
1020  RECT *rect,
1021  Surface_Ids surf_no
1022 );
1023 
1033  RECT *rcView,
1034  int x,
1035  int y,
1036  RECT *rect,
1037  Surface_Ids surf_no,
1038  int scalar
1039 );
1040 
1050  RECT *rcView,
1051  int x,
1052  int y,
1053  RECT *rect,
1054  Surface_Ids surf_no,
1055  int scalar
1056 );
1057 
1066  RECT* rcView,
1067  int x,
1068  int y,
1069  RECT* rect,
1070  Surface_Ids surf_no
1071 );
1072 
1083 extern CAVESTORY_MOD_API void PutBitmap8(RECT* rcView, int x, int y, RECT* rect, Surface_Ids surf_no, int r, int g, int b);
1084 
1093 extern CAVESTORY_MOD_API void PutBitmap9(RECT* rcView, int x, int y, RECT* rect, Surface_Ids surf_no, int alpha);
1094 
1101 extern CAVESTORY_MOD_API void PutBitmap10(int x, int y, RECT* rect, Surface_Ids surf_no);
1102 
1112 extern CAVESTORY_MOD_API void PutBitmap11(int x, int y, RECT* rect, Surface_Ids surf_no, int r, int g, int b);
1113 
1122 extern CAVESTORY_MOD_API void PutBitmap12(RECT* rcView, Surface_Ids dst_surf_no, int x, int y, RECT* src_rect, Surface_Ids src_surf_no, bool async = false);
1123 
1135 extern CAVESTORY_MOD_API void PutBitmap13(RECT* rcView, Surface_Ids dst_surf_no, int x, int y, RECT* src_rect, Surface_Ids src_surf_no, int r, int g, int b, bool async = false);
1136 
1148 extern CAVESTORY_MOD_API void PutBitmap14(int x, int y, int w, int h, RECT* rect, Surface_Ids surf_no, int r, int g, int b);
1149 
1156  RECT* pDstRect,
1157  RECT* pSrcRect,
1158  Surface_Ids iSurfaceNo
1159 );
1160 
1172  RECT* rcView,
1173  int x,
1174  int y,
1175  RECT* rect,
1176  Surface_Ids surf_no,
1177  float angle,
1178  int center_x,
1179  int center_y
1180 );
1181 
1188  RECT* pDstRect,
1189  RECT* pSrcRect,
1190  Surface_Ids iSurfaceNo
1191 );
1192 
1200  RECT* pDstRect,
1201  RECT* pSrcRect,
1202  Surface_Ids iSurfaceNo,
1203  Surface_Ids iDestSurfaceNo
1204 );
1205 
1211  Surface_Ids iSurfNo,
1212  unsigned long iColor
1213 );
1214 
1219  Surface_Ids iSurfNo
1220 );
1221 
1227 extern CAVESTORY_MOD_API void PutNumber3(int x, int y, int value);
1228 
1235 extern CAVESTORY_MOD_API void PutNumber4(int x, int y, int value, BOOL bZero);
1236 
1245 extern CAVESTORY_MOD_API void PutSpecificNpChar(NPCHAR* npc, int fx, int fy, bool bIgnorePutFunc = false, int* iDrawX = NULL, int* iDrawY = NULL);
1246 
1249 
1250 #include <CSMAPI_endcode.h>
1251 
1252 //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Surface_Ids
List of surface IDs.
Definition: CSMAPI_enums.h:714
@ SURFACE_ID_MAX
Number of surfaces.
Definition: CSMAPI_enums.h:866
A handle for fonts.
Definition: CSMAPI_types.h:357
Manages fonts.
Definition: CSMAPI_types.h:255
An editable texture API.
Definition: VideoTexture.h:51
CAVESTORY_MOD_API FontObject * LoadFontFromFile(const char *pFileName, unsigned int cell_width, unsigned int cell_height, VideoTexture *pTexture=NULL, FontManager *pManager=NULL)
Load a font object from a file.
CAVESTORY_MOD_API int GetFontHeight(FontObject *font_object)
Get the general render height of a font.
CAVESTORY_MOD_API void SetFontTexture(FontObject *pFont, VideoTexture *pTexture)
Link a font to a texture.
CAVESTORY_MOD_API unsigned int GetTextHeight(FontObject *font_object, const char *string, size_t string_length=size_t(-1))
Get the rendered height of text.
CAVESTORY_MOD_API void UnloadFont(FontObject *font_object)
Unload a font object.
CAVESTORY_MOD_API void DrawClippedText(FontObject *font_object, unsigned char *bitmap_buffer, size_t bitmap_pitch, int bitmap_width, int bitmap_height, int x, int y, unsigned long colour, const char *string, size_t string_length, int clipLEFT, int clipTOP, int clipRIGHT, int clipBOTTOM, float iOutAlpha=1.f)
Draw clipped text onto a bitmap.
CAVESTORY_MOD_API void DrawNormalText(FontObject *font_object, unsigned char *bitmap_buffer, size_t bitmap_pitch, int bitmap_width, int bitmap_height, int x, int y, unsigned long colour, const char *string, size_t string_length)
Draw normal text onto a bitmap.
CAVESTORY_MOD_API int CSM_GetChatMagnificationLevel()
Get the current chat magnification.
CAVESTORY_MOD_API unsigned int GetTextWidth(FontObject *font_object, const char *string, size_t string_length=size_t(-1))
Get the rendered width of text.
CAVESTORY_MOD_API int GetFontMagnification(FontObject *font_object)
Get the magnification level of a font object.
CAVESTORY_MOD_API void DeInitFont()
Do not use.
CAVESTORY_MOD_API void SetFontCharacterWhitelist(const unsigned char *pWhitelist)
Set a whitelist for the rendering system.
CAVESTORY_MOD_API FontObject * LoadFontFromData(const unsigned char *data, size_t data_size, unsigned int cell_width, unsigned int cell_height, VideoTexture *pTexture=NULL, FontManager *pManager=NULL)
Load a font object from data.
CAVESTORY_MOD_API const unsigned char * GetFontCharacterWhitelist()
Get the current font whitelist.
CAVESTORY_MOD_API void SetFontWhitelistEnabled(bool bEnabled)
Set whether the whitelist is active or not.
CAVESTORY_MOD_API void InitFont()
Do not use.
CAVESTORY_MOD_API void GetTextSize(FontObject *font_object, const char *string, size_t string_length, int *size_x, int *size_y)
Get the rendered size of text.
CAVESTORY_MOD_API int CSM_GetUIMagnificationLevel()
Get the current UI magnification.
CAVESTORY_MOD_API BOOL IsFontLinkedToTexture(FontObject *font_object, VideoTexture *pTexture)
Check to see if a font is linked with a texture.
CAVESTORY_MOD_API unsigned long UTF8ToUnicode(const unsigned char *string, unsigned int *bytes_read)
Convert UTF8 to unicode.
CAVESTORY_MOD_API FontObject * LoadFont(const char *font_filename, unsigned int cell_width, unsigned int cell_height, VideoTexture *pTexture=NULL, FontManager *pManager=NULL)
Load a font from Windows.
CAVESTORY_MOD_API void PutBitmap15(RECT *pDstRect, RECT *pSrcRect, Surface_Ids iSurfaceNo)
Draw a surface directly to the screen.
CAVESTORY_MOD_API void CSM_QSA_Begin(Surface_Ids sid, GUI_RECT *rect, CSM_QSA_Data *out)
Begin the quick surface access.
CAVESTORY_MOD_API void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no)
Draw bitmap to the screen with transparency.
CAVESTORY_MOD_API void PutBitmap13(RECT *rcView, Surface_Ids dst_surf_no, int x, int y, RECT *src_rect, Surface_Ids src_surf_no, int r, int g, int b, bool async=false)
Draw bitmap to the screen with transparency & color modulation.
CAVESTORY_MOD_API void PutNumber4(int x, int y, int value, BOOL bZero)
Draw a number to the screen.
CAVESTORY_MOD_API void PutFramePerSecound()
Draw FPS in the top-right corner.
CAVESTORY_MOD_API void PutBitmap5(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no, int scalar)
Draw bitmap to the screen.
CAVESTORY_MOD_API void PutBitmap16(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no, float angle, int center_x, int center_y)
Draw a bitmap that's rotated around a center point.
CAVESTORY_MOD_API void PutBitmap9(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no, int alpha)
Draw bitmap to the screen.
CAVESTORY_MOD_API void PutBitmap17(RECT *pDstRect, RECT *pSrcRect, Surface_Ids iSurfaceNo)
Draw a surface directly to the screen, with magnified support.
CAVESTORY_MOD_API void PutBitmap10(int x, int y, RECT *rect, Surface_Ids surf_no)
Draw bitmap to the screen.
CAVESTORY_MOD_API void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no)
Draw bitmap to the screen.
CAVESTORY_MOD_API void PutBitmap11(int x, int y, RECT *rect, Surface_Ids surf_no, int r, int g, int b)
Draw bitmap to the screen.
CAVESTORY_MOD_API void PutBitmap7(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no)
Draw bitmap to the screen.
CAVESTORY_MOD_API void PutBitmap14(int x, int y, int w, int h, RECT *rect, Surface_Ids surf_no, int r, int g, int b)
Draw a stretched colored bitmap to the screen.
CAVESTORY_MOD_API int ghWnd
Placeholder until we restore the WinAPI code.
CAVESTORY_MOD_API void PutNumber3(int x, int y, int value)
Draw a number to the screen.
CAVESTORY_MOD_API BOOL Flip_SystemTask(int hWnd)
Flip the renderer.
CAVESTORY_MOD_API void CSM_QSA_Free(CSM_QSA_Data *qsaptr)
Free QSA access.
CAVESTORY_MOD_API void ModBitmap(Surface_Ids iSurfNo, unsigned long iColor)
Set the color modulation of a surface.
CAVESTORY_MOD_API void PutSpecificNpChar(NPCHAR *npc, int fx, int fy, bool bIgnorePutFunc=false, int *iDrawX=NULL, int *iDrawY=NULL)
Draw an NPC to the screen.
CAVESTORY_MOD_API void PutBitmap12(RECT *rcView, Surface_Ids dst_surf_no, int x, int y, RECT *src_rect, Surface_Ids src_surf_no, bool async=false)
Draw bitmap to the screen with transparency.
CAVESTORY_MOD_API void PutBitmap6(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no, int scalar)
Draw bitmap to the screen.
CAVESTORY_MOD_API void PutBitmap8(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no, int r, int g, int b)
Draw bitmap to the screen.
CAVESTORY_MOD_API void PutBitmap18(RECT *pDstRect, RECT *pSrcRect, Surface_Ids iSurfaceNo, Surface_Ids iDestSurfaceNo)
Draw a surface directly to another surface, with magnified support.
CAVESTORY_MOD_API void ClearBitmapMod(Surface_Ids iSurfNo)
Clear the color modulation of a surface.
#define CAVESTORY_MOD_API
Exports / imports Cavestory Mod API functions & classes.
Definition: CSMAPI_begincode.h:30
Quick Surface Access data.
Definition: CSMAPI_types.h:7345
Rendering pipeline for Cavestory Multiplayer.
Definition: CSMAPI_drawing.h:439
static VideoTexture * GetCurrentVideoTexture()
Get the currently selected video texture.
static void DrawRect(GUI_RECT *r, unsigned long color, bool bAbsolutePos=false)
Outline a given rect.
static void DrawTransparentBitmapBox(GUI_RECT *out_rect, GUI_RECT *bmp_rects, BitmapBoxType type, Surface_Ids bmp_id, int iAlpha)
Draw a transparent bitmap box.
static BOOL SelectRendererSurfaceAndRememberPrevious(int iCustomMagnification=0)
Alias of SetSurfaceID, handles selecting SURFACE_ID_RENDERER with a custom magnification.
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.
static GUI_POINT DrawColoredBitmap(GUI_POINT p, GUI_RECT *srcRect, Surface_Ids sid, GUI_COLOR color, bool bAbsolutePos=false)
Draw a colored image.
static GUI_POINT DrawBitmap(GUI_POINT p, GUI_RECT *srcRect, Surface_Ids sid, bool bAbsolutePos=false)
Draw an image.
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.
static void DrawCircle(GUI_POINT p, int size, unsigned long color)
Draw a circle.
static void FreeSurfaceID(Surface_Ids sid)
Free a surface ID.
static GUI_POINT GetTextSize(FontObject *pFont, const char *pText, int iTextLen=-1)
Get the size of a string of text w/ a font.
static void GetClipRect(GUI_RECT *r)
Get the current clip rect.
static BOOL SetSurfaceIDAndRememberPrevious(Surface_Ids sid)
Set the surface ID that we're editing.
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.
static void DrawFilledRectTransparent(GUI_RECT *r, unsigned long color, bool bAbsolutePos=false)
Fill a given rect.
static void DrawFilledTriangle(GUI_POINT *points, unsigned long color)
Draw a filled triangle.
static void DrawBitmapBox(GUI_RECT *out_rect, GUI_RECT *bmp_rects, BitmapBoxType type, Surface_Ids bmp_id)
Draw a bitmap box.
static BOOL SetSurfaceID(Surface_Ids sid)
Set the surface ID that we're editing.
static void DrawPixels(GUI_POINT *pPointList, unsigned int iPointCount, unsigned long color, bool bAbsolutePos=false)
Draw pixels.
static void DrawRectTransparent(GUI_RECT *r, unsigned long color, bool bAbsolutePos=false)
Outline a given rect.
static void DrawPixel(GUI_POINT pPoint, unsigned long color, bool bAbsolutePos=false)
Draw a pixel.
BitmapBoxType
Bitmap box type for CacheSurface::GetBitmapBoxSize and CacheSurface::DrawBitmapBox.
Definition: CSMAPI_drawing.h:443
@ BMPBOX_TYPE_HEIGHT
Dynamic height (requires 3 'bmp_rects' elements) – Top, mid-loop, bottom.
Definition: CSMAPI_drawing.h:448
static BOOL SelectRendererSurface(int iCustomMagnification=0)
Alias of SetSurfaceID, handles selecting SURFACE_ID_RENDERER with a custom magnification.
static void Put(GUI_POINT out_pos, Surface_Ids sid=SURFACE_ID_MAX, bool bAbsolutePos=false)
Draw a surface to the screen.
static void UnlockSurfaceID(Surface_Ids sid)
Free a surface ID and set it as non-async.
static void SetNeedsUpdating()
Force an update for this surface internally.
static bool TryClipPoint(GUI_POINT &p)
Try to contain a point inside of the clip rect.
static Surface_Ids GetSurfaceID()
Get the surface ID that we're currently editing.
static void DrawText(GUI_POINT p, FontObject *font, const char *text, unsigned long color)
Draw text.
static void DrawLine(GUI_POINT start, GUI_POINT end, unsigned long color, bool bUseMagnification=true)
Draw a line.
static Surface_Ids GetNextFreeSurfaceID(int iSkipCount=0, bool bAsyncUse=false, bool bLockMutex=true)
Get the next free Dynamic Surface ID.
static bool IsInClipRect(GUI_POINT p)
Check to see if a point is inside the current clip rect.
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.
static bool AllocateSurface(int w, int h, Surface_Ids iSurfId=SURFACE_ID_MAX, unsigned int iMagnification=0)
Allocate a surface ID.
static void DrawFilledCircle(GUI_POINT p, int size, unsigned long color, bool invert=false)
Draw a filled circle.
static GUI_POINT GetBitmapBoxSize(GUI_POINT *desired_extent, GUI_RECT *bmp_rects, BitmapBoxType type)
Get the size of a bitmap box.
static BOOL SetCurrentTexture(VideoTexture *pTexture)
Set the texture that should be used when rendering stuff.
static bool IsInClipRectWithCustomMag(GUI_RECT r, int customMagnification)
Check to see if a rect is inside the current clip rect.
static bool IsSurfaceAllocated(Surface_Ids sid)
Checks whether the specified surface is allocated or not.
static void InitMemory()
Only called once upon engine init.
static bool SaveSurfaceToFile(const char *pFileName, Surface_Ids iSurfId=SURFACE_ID_MAX)
Save an image from a surface to a file.
static BOOL RememberSurfaceID()
Remember the currently selected SurfaceID.
static GUI_POINT GetSurfaceIDSize(Surface_Ids sid)
Get the surface size of a surface.
static void DrawTriangle(GUI_POINT *points, unsigned long color)
Draw a triangle.
static void DrawStripedRect(GUI_RECT *pRect, unsigned long iColor)
Draw a striped rect.
static void ClearClipRectList()
Clear the clip rect.
static int GetFreeSurfaceCount()
Self-explanatory.
static int GetSurfaceIDMagnification(Surface_Ids sid)
Get the surface magnification level of a surface.
static void DrawFilledRect(GUI_RECT *r, unsigned long color, bool bAbsolutePos=false)
Fill a given rect.
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.
static void SetClipRect(GUI_RECT *r, bool bAbsoluteRect=false)
Add a new clip rect.
static void DrawStripedLine(GUI_POINT start, GUI_POINT end, unsigned long color)
Draw a striped line.
static GUI_POINT DrawStretchedBitmap(GUI_RECT *r, GUI_RECT *srcRect, Surface_Ids sid, GUI_COLOR color, bool bAbsolutePos=false)
Draw an image.
static void DrawGradientLine(GUI_POINT start, GUI_POINT end, unsigned long *colors, int colorcount)
Draw a line with color gradient.
static void DrawSpecialText(GUI_POINT p, SpecialTextCache *pCache)
Draw clipped special text.
static void DrawClearRect(GUI_RECT *r)
Clear a given rect.
static bool IsInClipRect(GUI_RECT r)
Check to see if a rect is inside the current clip rect.
static BOOL RestoreSurfaceID()
Return the current SurfaceID selection to the last one stored with RememberSurfaceID().
Manages colors.
Definition: CSMAPI_types.h:497
Manages points.
Definition: CSMAPI_types.h:546
Definition: CSMAPI_types.h:842
Definition: CSMAPI_drawing.h:40
NPC object.
Definition: CSMAPI_types.h:2021
Rect structure.
Definition: CSMAPI_types.h:125
A cache object to store parsed special text.
Definition: CSMAPI_drawing.h:393
char * mFullText
The full text for this cache.
Definition: CSMAPI_drawing.h:408
~SpecialTextCache()
Deconstructor.
List< SpecialTextNode * > mTextList
Node list for this cache.
Definition: CSMAPI_drawing.h:404
GUI_RECT rect
The draw rect.
Definition: CSMAPI_drawing.h:396
SpecialTextCache()
Constructor.
void Free()
Free this object's cache.
bool Parse(FontObject *pFont, const char *pString, int iLength=-1, unsigned long iColor=0xFFFFFFFF, int iDestWidth=0)
Parse a string.
GUI_POINT mTotalSize
The total size of the text, including font changes, new lines, etc.
Definition: CSMAPI_drawing.h:400
A node for SpecialTextCache.
Definition: CSMAPI_drawing.h:340
int tab_group
Line position.
Definition: CSMAPI_drawing.h:387
int length
The length of this node's text.
Definition: CSMAPI_drawing.h:363
int caret_pos
Caret position.
Definition: CSMAPI_drawing.h:379
unsigned long color
The text color.
Definition: CSMAPI_drawing.h:355
int tab_num
The tab number for this node.
Definition: CSMAPI_drawing.h:347
char * start
A pointer to the start of the string.
Definition: CSMAPI_drawing.h:359
GUI_POINT draw_offset
The drawing offset for this node.
Definition: CSMAPI_drawing.h:343
int line_no
Line position.
Definition: CSMAPI_drawing.h:383
Surface_Ids surf_id
Bitmap surface ID.
Definition: CSMAPI_drawing.h:371
GUI_RECT src_rect
Bitmap rect.
Definition: CSMAPI_drawing.h:375
FontHandle FO
The font object to use.
Definition: CSMAPI_drawing.h:351
GUI_POINT bmp_offset
The drawing offset for this node's bitmap.
Definition: CSMAPI_drawing.h:367