26 #ifndef CAVESTORY_MOD_API_H_
27 #error "Please include CavestoryModAPI.h before including sub-classes."
40 #define PXLANG_MAGIC "PXLANG"
41 #define PXLANG_VERSION 2
42 #define PXLANG_VALID_CRC 0x1F5F1F44
43 #define PXLANG_SYMBOL_MAGIC "PXLNGS"
44 #define PXLANG_SYMBOL_VERSION 1
51 #define __VA_NARGS_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
53 #define __VA_NARGS(...) __EXPAND(__VA_NARGS_IMPL(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1))
54 #define _LOC(x, ...) x
56 #define USE_LOCALE_NAME_AS_DEFAULT NULL
59 #define UseGlobalLocaleBuffer(x) CSM_PxLang_GetGlobalBuffer(x), -1
60 #define UseStaticLocaleBuffer(BUFFER) BUFFER, sizeof(BUFFER)
61 #define UseDynamicLocaleBuffer(BUFFER, BUFFERSIZE) BUFFER, BUFFERSIZE
64 #define GetLocaleStringWithArgumentsA(LOCALE_NAME, ARG_FORMAT, DEFAULT_STRING, ...) CSM_PxLang_GetString(LOCALE_NAME, NULL, -1, DEFAULT_STRING, NULL, ARG_FORMAT, __VA_NARGS(__VA_ARGS__), ## __VA_ARGS__)
65 #define GetLocaleStringA(LOCALE_NAME, DEFAULT_STRING) CSM_PxLang_GetString(LOCALE_NAME, NULL, -1, DEFAULT_STRING, NULL, NULL, 0)
69 #define CopyLocaleStringWithArgumentsA(BUFFERINFO, LOCALE_NAME, ARG_FORMAT, DEFAULT_STRING, ...) CSM_PxLang_GetString(LOCALE_NAME, BUFFERINFO, DEFAULT_STRING, NULL, ARG_FORMAT, __VA_NARGS(__VA_ARGS__), ## __VA_ARGS__)
70 #define CopyLocaleStringA(BUFFERINFO, LOCALE_NAME, DEFAULT_STRING) CSM_PxLang_GetString(LOCALE_NAME, BUFFERINFO, DEFAULT_STRING, NULL, NULL, 0)
75 #define BuildLocaleString(STRING) CSM_PxLang_BuildFormat(STRING)
76 #define LoadNonLocaleFont(FONTNAME, FONTW, FONTH) (CSM_PxLang_IsLoaded(&gCurrentLocalization) && strcmpi(gCurrentLocalization.font_name, "Courier New") ? FontHandle(NULL, (gCurrentLocalization.font_width / 1.1), (gCurrentLocalization.font_height / 1.1)) : FontHandle(FONTNAME, FONTW, FONTH))
77 #define LoadNonLocaleFontWithSubstitue(FONTNAME, FONTNAME2, FONTW, FONTH) (CSM_PxLang_IsLoaded(&gCurrentLocalization) && strcmpi(gCurrentLocalization.font_name, "Courier New") ? FontHandle(FONTNAME2, (gCurrentLocalization.font_width / 1.1), (gCurrentLocalization.font_height / 1.1)) : FontHandle(FONTNAME, FONTW, FONTH))
78 #define LoadNonLocaleFontCustomMag(INPUT_MAG, FONTNAME, FONTW, FONTH) (CSM_PxLang_IsLoaded(&gCurrentLocalization) && strcmpi(gCurrentLocalization.font_name, "Courier New") ? FontHandle(NULL, (gCurrentLocalization.font_width / 1.1), (gCurrentLocalization.font_height / 1.1), INPUT_MAG) : FontHandle(FONTNAME, FONTW, FONTH, INPUT_MAG))
79 #define LoadNonLocaleFontWithSubstitueCustomMag(INPUT_MAG, FONTNAME, FONTNAME2, FONTW, FONTH) (CSM_PxLang_IsLoaded(&gCurrentLocalization) && strcmpi(gCurrentLocalization.font_name, "Courier New") ? FontHandle(FONTNAME2, (gCurrentLocalization.font_width / 1.1), (gCurrentLocalization.font_height / 1.1), INPUT_MAG) : FontHandle(FONTNAME, FONTW, FONTH, INPUT_MAG))
87 PXLANG_TYPE_STRING = 0,
95 PXLANG_SYMBOL_TYPE_GROUP = 0,
96 PXLANG_SYMBOL_TYPE_STRING = 1,
98 MAX_PXLANG_SYMBOL_COUNT
187 unsigned int valid_crc;
298 const char* pFileName,
299 bool bForceDebugSymbols =
false
318 const char* pFileName,
319 const char* pGroupName = NULL,
320 bool bRecompile =
true,
321 bool bForceDebugSymbols =
false
354 const char* pStringName,
370 const char* pStringName,
371 char* pBuffer = NULL,
372 int iBufferSize = -1,
373 const char* pDefaultValue = NULL,
375 const char* pArgFormat = NULL,
388 unsigned int iBufferID
415 const char* pLanguageName,
416 bool bUseData =
false
425 const char* pGroupName,
CAVESTORY_MOD_API int CSM_PxLang_Load(PXLANG_RESOURCE_STRUCT *pLangObj, const char *pFileName, const char *pGroupName=NULL, bool bRecompile=true, bool bForceDebugSymbols=false)
Load a language resource file.
CAVESTORY_MOD_API bool CSM_PxLang_LoadDebugSymbols(PXLANG_RESOURCE_STRUCT *pLangObj)
Load debug symbols for a PxLang object.
CAVESTORY_MOD_API char * CSM_PxLang_GetGlobalBuffer(unsigned int iBufferID)
Get a global PxLang buffer.
CAVESTORY_MOD_API BOOL CSM_PxLang_SetCurrentLocalization(const char *pLanguageName, bool bUseData=false)
Set the current localization object.
CAVESTORY_MOD_API void CSM_PxLang_SetGroup(const char *pGroupName, PXLANG_RESOURCE_STRUCT *pLangObj=NULL)
Set the current localization object.
PXLANG_SymbolType
Type of debug symbol for pxlang symbol file.
Definition: LanguageResource.h:94
CAVESTORY_MOD_API BOOL CSM_PxLang_IsLoaded(PXLANG_RESOURCE_STRUCT *pLangObj)
Check to see if a language object is loaded.
CAVESTORY_MOD_API const char * CSM_PxLang_GetString(const char *pStringName, char *pBuffer=NULL, int iBufferSize=-1, const char *pDefaultValue=NULL, PXLANG_RESOURCE_STRUCT *pLangObj=NULL, const char *pArgFormat=NULL, int iArgCount=0,...)
Get a string from a language object.
CAVESTORY_MOD_API PXLANG_RESOURCE_STRUCT gCurrentLocalization
This global variable holds the currently loaded localization file.
CAVESTORY_MOD_API const char * CSM_PxLang_BuildFormat(const char *pFormat)
Build an argumentitive string.
CAVESTORY_MOD_API BOOL CSM_PxLang_Free(PXLANG_RESOURCE_STRUCT *pLangObj)
Free up a language resource object.
CAVESTORY_MOD_API int CSM_PxLang_Compile(const char *pFileName, bool bForceDebugSymbols=false)
Compile a language resource file.
CAVESTORY_MOD_API BOOL CSM_PxLang_HasString(const char *pStringName, PXLANG_RESOURCE_STRUCT *pLangObj=NULL)
Check to see if a language object has a localization string.
PXLANG_ArgType
Argument types for compiled pxlang files.
Definition: LanguageResource.h:86
#define CAVESTORY_MOD_API
Exports / imports Cavestory Mod API functions & classes.
Definition: CSMAPI_begincode.h:30
Holds information about a specific debug symbol.
Definition: LanguageResource.h:106
int line
The line number for this symbol.
Definition: LanguageResource.h:121
PXLANG_SymbolType type
The type of symbol this is.
Definition: LanguageResource.h:109
char * name
The actual name of this localization string.
Definition: LanguageResource.h:117
unsigned int crc
The CRC checksum of the name for this localization string.
Definition: LanguageResource.h:113
Holds information about a localization group.
Definition: LanguageResource.h:152
int symbol
The debug symbol assigned to this string.
Definition: LanguageResource.h:175
unsigned int string_count
The amount of loaded strings in this group.
Definition: LanguageResource.h:163
unsigned int crc
The CRC checksum of this group's name.
Definition: LanguageResource.h:155
bool loaded
Whether this group's strings are loaded or not.
Definition: LanguageResource.h:171
unsigned int string_size
The amount of localized strings in this group.
Definition: LanguageResource.h:159
PXLANG_STRING_STRUCT * string_list
The string list.
Definition: LanguageResource.h:167
Holds information for a compiled pixel language file (.pxclang).
Definition: LanguageResource.h:181
unsigned int font_height
This localization resource's desired font height.
Definition: LanguageResource.h:201
PXLANG_RESOURCE_STRUCT * prev
The previous language resource.
Definition: LanguageResource.h:269
unsigned char char_travel
Used to compare against the uncompiled file's CRC, and if they are different, then it will be re-comp...
Definition: LanguageResource.h:255
unsigned int selected_group_crc
The selected group CRC.
Definition: LanguageResource.h:231
char * file_name
The file name of this resource.
Definition: LanguageResource.h:209
char * font_name
The font name of this resource.
Definition: LanguageResource.h:213
unsigned int symbol_count
The amount of symbols.
Definition: LanguageResource.h:275
unsigned int file_crc
Used to compare against the uncompiled file's CRC, and if they are different, then it will be re-comp...
Definition: LanguageResource.h:205
PXLANG_GROUP_STRUCT * group_list
The group list.
Definition: LanguageResource.h:239
int encoding_type
The encoding type.
Definition: LanguageResource.h:219
wchar_t ** string_table
The string list.
Definition: LanguageResource.h:247
char * display_name
The display name of this localization file.
Definition: LanguageResource.h:227
unsigned int font_width
This localization resource's desired font width.
Definition: LanguageResource.h:197
PXLANG_DEBUG_SYMBOL_STRUCT * symbol_list
The string list.
Definition: LanguageResource.h:279
bool hidden
Whether this resource is hidden or not.
Definition: LanguageResource.h:251
int charset_type
The charset type.
Definition: LanguageResource.h:223
static PXLANG_RESOURCE_STRUCT * first
The first language resource.
Definition: LanguageResource.h:261
unsigned int string_table_size
The amount of localized strings.
Definition: LanguageResource.h:243
char * path_name
The path name of this resource.
Definition: LanguageResource.h:193
PXLANG_RESOURCE_STRUCT * next
The next language resource.
Definition: LanguageResource.h:265
unsigned int group_count
The amount of groups in this resource.
Definition: LanguageResource.h:235
Holds information about a specific localization string.
Definition: LanguageResource.h:127
unsigned int crc
The CRC checksum of the name for this localization string.
Definition: LanguageResource.h:130
int symbol
The debug symbol assigned to this string.
Definition: LanguageResource.h:142
bool special_content
The debug symbol assigned to this string.
Definition: LanguageResource.h:146
wchar_t * content
The content of this string.
Definition: LanguageResource.h:134
char * content_ascii
The ASCII content of this string.
Definition: LanguageResource.h:138