y_text.inc 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /**
  2. * <library name="y_text">
  3. * <section>
  4. * Description
  5. * </section>
  6. * Provides interfaces for displaying text from anywhere by way of native like
  7. * functions using text indexes rather than text. Due to a compile problem a
  8. * number of the stock functions should be static but can't be.
  9. * <section>
  10. * Version
  11. * </section>
  12. * 0.1.1
  13. * <section>
  14. * Functions
  15. * </section>
  16. * <subsection>
  17. * Public
  18. * </subsection><ul>
  19. * <symbol name="Text_ResetAll">Resets the entire text system.</symbol>
  20. * <symbol name="Text_NewLanguage">Sets up to parse a new language.</symbol>
  21. * <symbol name="Text_Parse">Sorts loaded text into a binary tree.</symbol>
  22. * <symbol name="Text_DataSave_data">Saves text appearence data.</symbol>
  23. * <symbol name="Text_DataSave_colours">Saves file colour defines.</symbol>
  24. * <symbol name="Text_DataSave_colors">Wrapper for above function.</symbol>
  25. * </ul><subsection>
  26. * Stock
  27. * </subsection><ul>
  28. * <symbol name="Text_FindTextPointers">Should be static but can't be :(.</symbol>
  29. * <symbol name="Text_AddToBuffer">Saves all passed text for processing.</symbol>
  30. * <symbol name="Text_GetTextFromIndex">Gets text from an array pointer and language.</symbol>
  31. * <symbol name="Text_GetErrorMessage">Gets an unfound message.</symbol>
  32. * <symbol name="Text_GetTextStyle">Gets text's style.</symbol>
  33. * <symbol name="Text_GetTextColour">Gets text's colour.</symbol>
  34. * <symbol name="Text_GetTextTime">Gets text's time.</symbol>
  35. * <symbol name="Text_Send">Sends a message to a player.</symbol>
  36. * <symbol name="Text_SendToAll">Sends a message to all players.</symbol>
  37. * <symbol name="Text_SendToGroup">Sends a message to a defined group.</symbol>
  38. * <symbol name="Text_SendToPlayers">Sends a message to a passed group.</symbol>
  39. * <symbol name="Text_Display">Display an actual string to a player in a given style.</symbol>
  40. * </ul><subsection>
  41. * Static
  42. * </subsection><ul>
  43. * <symbol name="Text_AddText">Adds text to the tree after sorting.</symbol>
  44. * </ul><subsection>
  45. * Inline
  46. * </subsection><ul>
  47. * <symbol name="Text_Text">Constructor - Calls Text_ResetAll.</symbol>
  48. * <symbol name="Text_SetLangPointer">Sets the pointer for a language to a position.</symbol>
  49. * <symbol name="Text_ResetLangPointers">Resets all the pointers for one language.</symbol>
  50. * <symbol name="Text_GetPlayerLanguage">Gets a players language.</symbol>
  51. * <symbol name="Text_GetText">Gets text from an identifier and language.</symbol>
  52. * <symbol name="Text_GetPlayerText">Gets text from an identifier and playerid.</symbol>
  53. * <symbol name="Text_SendFormat">Sends a formatted message to a player.</symbol>
  54. * <symbol name="Text_SendToAllFormat">Sends a formatted message to all players.</symbol>
  55. * <symbol name="Text_SendToGroupFormat">Sends a formatted message to a defined group.</symbol>
  56. * <symbol name="Text_SendToPlayersFormat">Sends a formatted message to a passed group.</symbol>
  57. * </ul><section>
  58. * Definitions
  59. * </section><ul>
  60. * <symbol name="MAX_TEXT_NAME">Maximum length of a text identifier.</symbol>
  61. * <symbol name="MAX_TEXT_ENTRY">Maximum length of a text string.</symbol>
  62. * <symbol name="TEXT_NO_TEXT">Value for no text for that language.</symbol>
  63. * <symbol name="TEXT_NO_POINTERS">Value for no text found.</symbol>
  64. * <symbol name="TEXT_TYPE_CLIENT">Flag for sending a client formatted message (unused).</symbol>
  65. * <symbol name="TEXT_TYPE_GAME">Flag for sending a game text formatted message (unused).</symbol>
  66. * <symbol name="MAX_TEXT_COLOURS">Max number of defined colours in an ini file.</symbol>
  67. * </ul><section>
  68. * Enums
  69. * </section><ul>
  70. * <symbol name="E_TEXT_POINTERS">Structure of the language pointer array.</symbol>
  71. * </ul><section>
  72. * Macros
  73. * </section><ul>
  74. * <symbol name="Text_RegisterTag">Placed as a function, calls Text_AddToBuffer for tags.</symbol>
  75. * </ul><section>
  76. * Variables
  77. * </section>
  78. * <subsection>
  79. * Static
  80. * </subsection><ul>
  81. * <symbol name="YSI_g_sTextTable">Array of all text entries.</symbol>
  82. * <symbol name="YSI_g_sNameTable">Array of all text names and language pointers.</symbol>
  83. * <symbol name="YSI_g_sSearchTree">Binary tree of text hashes.</symbol>
  84. * <symbol name="YSI_g_sTextInited">Flag for text binary sorted.</symbol>
  85. * <symbol name="YSI_g_sBufferIndex">Index of next text slot for the current language.</symbol>
  86. * <symbol name="YSI_g_sTextCount">Count of largest number of texts in one language.</symbol>
  87. * <symbol name="YSI_g_sBufferLang">Current language being loaded.</symbol>
  88. * <symbol name="YSI_g_sLangBuffer">Saves the current position of each language.</symbol>
  89. * <symbol name="YSI_g_sColours">Saves defined colours for use.</symbol>
  90. * </ul>
  91. * </library>
  92. *//** *//*
  93. Legal:
  94. Version: MPL 1.1
  95. The contents of this file are subject to the Mozilla Public License Version
  96. 1.1 the "License"; you may not use this file except in compliance with
  97. the License. You may obtain a copy of the License at
  98. http://www.mozilla.org/MPL/
  99. Software distributed under the License is distributed on an "AS IS" basis,
  100. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  101. for the specific language governing rights and limitations under the
  102. License.
  103. The Original Code is the YSI framework.
  104. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  105. Portions created by the Initial Developer are Copyright C 2011
  106. the Initial Developer. All Rights Reserved.
  107. Contributors:
  108. Y_Less
  109. koolk
  110. JoeBullet/Google63
  111. g_aSlice/Slice
  112. Misiur
  113. samphunter
  114. tianmeta
  115. maddinat0r
  116. spacemud
  117. Crayder
  118. Dayvison
  119. Ahmad45123
  120. Zeex
  121. irinel1996
  122. Yiin-
  123. Chaprnks
  124. Konstantinos
  125. Masterchen09
  126. Southclaws
  127. PatchwerkQWER
  128. m0k1
  129. paulommu
  130. udan111
  131. Thanks:
  132. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  133. ZeeX - Very productive conversations.
  134. koolk - IsPlayerinAreaEx code.
  135. TheAlpha - Danish translation.
  136. breadfish - German translation.
  137. Fireburn - Dutch translation.
  138. yom - French translation.
  139. 50p - Polish translation.
  140. Zamaroht - Spanish translation.
  141. Los - Portuguese translation.
  142. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  143. me to strive to better.
  144. Pixels^ - Running XScripters where the idea was born.
  145. Matite - Pestering me to release it and using it.
  146. Very special thanks to:
  147. Thiadmer - PAWN, whose limits continue to amaze me!
  148. Kye/Kalcor - SA:MP.
  149. SA:MP Team past, present and future - SA:MP.
  150. Optional plugins:
  151. Gamer_Z - GPS.
  152. Incognito - Streamer.
  153. Me - sscanf2, fixes2, Whirlpool.
  154. */
  155. #if defined _inc_y_text
  156. #undef _inc_y_text
  157. #endif
  158. #if !defined _Y_UNIQUE_INCLUDED
  159. #tryinclude "..\YSI_Coding\y_unique\y_unique_entry"
  160. #endif
  161. #if !defined _Y_UNIQUE_INCLUDED
  162. #tryinclude "YSI_Coding\y_unique\y_unique_entry"
  163. #endif
  164. #if !defined _Y_UNIQUE_INCLUDED
  165. #tryinclude "YSI\YSI_Coding\y_unique\y_unique_entry"
  166. #endif
  167. #if !defined _Y_UNIQUE_INCLUDED
  168. #tryinclude <YSI_Coding\y_unique\y_unique_entry>
  169. #endif
  170. #if !defined _Y_UNIQUE_INCLUDED
  171. #tryinclude <YSI\YSI_Coding\y_unique\y_unique_entry>
  172. #endif
  173. #if defined _Y_UNIQUE_INCLUDED
  174. #undef _Y_UNIQUE_INCLUDED
  175. #else
  176. #error Did you use `YSI/y_text` instead of `YSI\y_text`?
  177. #endif
  178. #if !defined _INC_y_text
  179. #tryinclude "y_text\y_text_entry"
  180. #endif
  181. #if !defined _INC_y_text
  182. #tryinclude "YSI_Players\y_text\y_text_entry"
  183. #endif
  184. #if !defined _INC_y_text
  185. #tryinclude "YSI\YSI_Players\y_text\y_text_entry"
  186. #endif
  187. #if !defined _INC_y_text
  188. #tryinclude <YSI_Players\y_text\y_text_entry>
  189. #endif
  190. #if !defined _INC_y_text
  191. #tryinclude <YSI\YSI_Players\y_text\y_text_entry>
  192. #endif
  193. #if !defined _INC_y_text
  194. #error Could not find y_text
  195. #endif