ui.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
  2. //
  3. // Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
  4. // All rights reserved.
  5. //
  6. // This file is part of SDLPAL.
  7. //
  8. // SDLPAL is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. //
  21. // Modified by Lou Yihua <louyihua@21cn.com> with Unicode support, 2015
  22. //
  23. #ifndef UI_H
  24. #define UI_H
  25. #ifdef __cplusplus
  26. extern "C"
  27. {
  28. #endif
  29. #include "common.h"
  30. #define CHUNKNUM_SPRITEUI 9
  31. #define MENUITEM_COLOR 0x4F
  32. #define MENUITEM_COLOR_INACTIVE 0x1C
  33. #define MENUITEM_COLOR_CONFIRMED 0x2C
  34. #define MENUITEM_COLOR_SELECTED_INACTIVE 0x1F
  35. #define MENUITEM_COLOR_SELECTED_FIRST 0xF9
  36. #define MENUITEM_COLOR_SELECTED_TOTALNUM 6
  37. #define MENUITEM_COLOR_SELECTED \
  38. (MENUITEM_COLOR_SELECTED_FIRST + \
  39. SDL_GetTicks() / (600 / MENUITEM_COLOR_SELECTED_TOTALNUM) \
  40. % MENUITEM_COLOR_SELECTED_TOTALNUM)
  41. #define MENUITEM_COLOR_EQUIPPEDITEM 0xC8
  42. #define DESCTEXT_COLOR 0x2E
  43. #define MAINMENU_BACKGROUND_FBPNUM (gConfig.fIsWIN95 ? 2 :60)
  44. #define RIX_NUM_OPENINGMENU 4
  45. #define MAINMENU_LABEL_NEWGAME 7
  46. #define MAINMENU_LABEL_LOADGAME 8
  47. #define LOADMENU_LABEL_SLOT_FIRST 43
  48. #define CONFIRMMENU_LABEL_NO 19
  49. #define CONFIRMMENU_LABEL_YES 20
  50. #define CASH_LABEL 21
  51. #define SWITCHMENU_LABEL_DISABLE 17
  52. #define SWITCHMENU_LABEL_ENABLE 18
  53. #define GAMEMENU_LABEL_STATUS 3
  54. #define GAMEMENU_LABEL_MAGIC 4
  55. #define GAMEMENU_LABEL_INVENTORY 5
  56. #define GAMEMENU_LABEL_SYSTEM 6
  57. #define SYSMENU_LABEL_SAVE 11
  58. #define SYSMENU_LABEL_LOAD 12
  59. #define SYSMENU_LABEL_MUSIC 13
  60. #define SYSMENU_LABEL_SOUND 14
  61. #define SYSMENU_LABEL_QUIT 15
  62. #define SYSMENU_LABEL_BATTLEMODE 606
  63. #define SYSMENU_LABEL_LAUNCHSETTING 612
  64. #define BATTLESPEEDMENU_LABEL_1 (SYSMENU_LABEL_BATTLEMODE + 1)
  65. #define BATTLESPEEDMENU_LABEL_2 (SYSMENU_LABEL_BATTLEMODE + 2)
  66. #define BATTLESPEEDMENU_LABEL_3 (SYSMENU_LABEL_BATTLEMODE + 3)
  67. #define BATTLESPEEDMENU_LABEL_4 (SYSMENU_LABEL_BATTLEMODE + 4)
  68. #define BATTLESPEEDMENU_LABEL_5 (SYSMENU_LABEL_BATTLEMODE + 5)
  69. #define INVMENU_LABEL_USE 23
  70. #define INVMENU_LABEL_EQUIP 22
  71. #define STATUS_BACKGROUND_FBPNUM 0
  72. #define STATUS_LABEL_EXP 2
  73. #define STATUS_LABEL_LEVEL 48
  74. #define STATUS_LABEL_HP 49
  75. #define STATUS_LABEL_MP 50
  76. #define STATUS_LABEL_EXP_LAYOUT 29
  77. #define STATUS_LABEL_LEVEL_LAYOUT 30
  78. #define STATUS_LABEL_HP_LAYOUT 31
  79. #define STATUS_LABEL_MP_LAYOUT 32
  80. #define STATUS_LABEL_ATTACKPOWER 51
  81. #define STATUS_LABEL_MAGICPOWER 52
  82. #define STATUS_LABEL_RESISTANCE 53
  83. #define STATUS_LABEL_DEXTERITY 54
  84. #define STATUS_LABEL_FLEERATE 55
  85. #define STATUS_COLOR_EQUIPMENT 0xBE
  86. #define EQUIP_LABEL_HEAD 600
  87. #define EQUIP_LABEL_SHOULDER 601
  88. #define EQUIP_LABEL_BODY 602
  89. #define EQUIP_LABEL_HAND 603
  90. #define EQUIP_LABEL_FOOT 604
  91. #define EQUIP_LABEL_NECK 605
  92. #define BUYMENU_LABEL_CURRENT 35
  93. #define SELLMENU_LABEL_PRICE 25
  94. #define SPRITENUM_SLASH 39
  95. #define SPRITENUM_ITEMBOX 70
  96. #define SPRITENUM_CURSOR_YELLOW 68
  97. #define SPRITENUM_CURSOR 69
  98. #define SPRITENUM_PLAYERINFOBOX 18
  99. #define SPRITENUM_PLAYERFACE_FIRST 48
  100. #define EQUIPMENU_BACKGROUND_FBPNUM 1
  101. #define ITEMUSEMENU_COLOR_STATLABEL 0xBB
  102. #define BATTLEWIN_GETEXP_LABEL 30
  103. #define BATTLEWIN_BEATENEMY_LABEL 9
  104. #define BATTLEWIN_DOLLAR_LABEL 10
  105. #define BATTLEWIN_LEVELUP_LABEL 32
  106. #define BATTLEWIN_ADDMAGIC_LABEL 33
  107. #define BATTLEWIN_LEVELUP_LABEL_COLOR 0xBB
  108. #define SPRITENUM_ARROW 47
  109. #define BATTLE_LABEL_ESCAPEFAIL 31
  110. typedef struct tagBOX
  111. {
  112. PAL_POS pos;
  113. WORD wWidth, wHeight;
  114. SDL_Surface *lpSavedArea;
  115. } BOX, *LPBOX;
  116. typedef struct tagMENUITEM
  117. {
  118. WORD wValue;
  119. WORD wNumWord;
  120. BOOL fEnabled;
  121. PAL_POS pos;
  122. } MENUITEM, *LPMENUITEM;
  123. typedef const MENUITEM* LPCMENUITEM;
  124. typedef struct tagOBJECTDESC
  125. {
  126. WORD wObjectID;
  127. LPWSTR lpDesc;
  128. struct tagOBJECTDESC *next;
  129. } OBJECTDESC, *LPOBJECTDESC;
  130. typedef VOID (*LPITEMCHANGED_CALLBACK)(WORD);
  131. #define MENUITEM_VALUE_CANCELLED 0xFFFF
  132. typedef enum tagNUMCOLOR
  133. {
  134. kNumColorYellow,
  135. kNumColorBlue,
  136. kNumColorCyan
  137. } NUMCOLOR;
  138. typedef enum tagNUMALIGN
  139. {
  140. kNumAlignLeft,
  141. kNumAlignMid,
  142. kNumAlignRight
  143. } NUMALIGN;
  144. INT
  145. PAL_InitUI(
  146. VOID
  147. );
  148. VOID
  149. PAL_FreeUI(
  150. VOID
  151. );
  152. LPBOX
  153. PAL_CreateBox(
  154. PAL_POS pos,
  155. INT nRows,
  156. INT nColumns,
  157. INT iStyle,
  158. BOOL fSaveScreen
  159. );
  160. LPBOX
  161. PAL_CreateBoxWithShadow(
  162. PAL_POS pos,
  163. INT nRows,
  164. INT nColumns,
  165. INT iStyle,
  166. BOOL fSaveScreen,
  167. INT nShadowOffset
  168. );
  169. LPBOX
  170. PAL_CreateSingleLineBox(
  171. PAL_POS pos,
  172. INT nLen,
  173. BOOL fSaveScreen
  174. );
  175. LPBOX
  176. PAL_CreateSingleLineBoxWithShadow(
  177. PAL_POS pos,
  178. INT nLen,
  179. BOOL fSaveScreen,
  180. INT nShadowOffset
  181. );
  182. VOID
  183. PAL_DeleteBox(
  184. LPBOX lpBox
  185. );
  186. WORD
  187. PAL_ReadMenu(
  188. LPITEMCHANGED_CALLBACK lpfnMenuItemChanged,
  189. LPCMENUITEM rgMenuItem,
  190. INT nMenuItem,
  191. WORD wDefaultItem,
  192. BYTE bLabelColor
  193. );
  194. VOID
  195. PAL_DrawNumber(
  196. UINT iNum,
  197. UINT nLength,
  198. PAL_POS pos,
  199. NUMCOLOR color,
  200. NUMALIGN align
  201. );
  202. INT
  203. PAL_TextWidth(
  204. LPCWSTR lpszItemText
  205. );
  206. INT
  207. PAL_MenuTextMaxWidth(
  208. LPCMENUITEM rgMenuItem,
  209. INT nMenuItem
  210. );
  211. INT
  212. PAL_WordMaxWidth(
  213. INT nFirstWord,
  214. INT nWordNum
  215. );
  216. INT
  217. PAL_WordWidth(
  218. INT nWordIndex
  219. );
  220. LPOBJECTDESC
  221. PAL_LoadObjectDesc(
  222. LPCSTR lpszFileName
  223. );
  224. VOID
  225. PAL_FreeObjectDesc(
  226. LPOBJECTDESC lpObjectDesc
  227. );
  228. LPCWSTR
  229. PAL_GetObjectDesc(
  230. LPOBJECTDESC lpObjectDesc,
  231. WORD wObjectID
  232. );
  233. extern LPSPRITE gpSpriteUI;
  234. #ifdef __cplusplus
  235. }
  236. #endif
  237. #endif