ui.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. #include "common.h"
  26. #define CHUNKNUM_SPRITEUI 9
  27. #define MENUITEM_COLOR 0x4F
  28. #define MENUITEM_COLOR_INACTIVE 0x1C
  29. #define MENUITEM_COLOR_CONFIRMED 0x2C
  30. #define MENUITEM_COLOR_SELECTED_INACTIVE 0x1F
  31. #define MENUITEM_COLOR_SELECTED_FIRST 0xF9
  32. #define MENUITEM_COLOR_SELECTED_TOTALNUM 6
  33. #define MENUITEM_COLOR_SELECTED \
  34. (MENUITEM_COLOR_SELECTED_FIRST + \
  35. SDL_GetTicks() / (600 / MENUITEM_COLOR_SELECTED_TOTALNUM) \
  36. % MENUITEM_COLOR_SELECTED_TOTALNUM)
  37. #define MENUITEM_COLOR_EQUIPPEDITEM 0xC8
  38. #define DESCTEXT_COLOR 0x2E
  39. #define MAINMENU_BACKGROUND_FBPNUM (gConfig.fIsWIN95 ? 2 :60)
  40. #define RIX_NUM_OPENINGMENU 4
  41. #define MAINMENU_LABEL_NEWGAME 7
  42. #define MAINMENU_LABEL_LOADGAME 8
  43. #define LOADMENU_LABEL_SLOT_FIRST 43
  44. #define CONFIRMMENU_LABEL_NO 19
  45. #define CONFIRMMENU_LABEL_YES 20
  46. #define CASH_LABEL 21
  47. #define SWITCHMENU_LABEL_DISABLE 17
  48. #define SWITCHMENU_LABEL_ENABLE 18
  49. #define GAMEMENU_LABEL_STATUS 3
  50. #define GAMEMENU_LABEL_MAGIC 4
  51. #define GAMEMENU_LABEL_INVENTORY 5
  52. #define GAMEMENU_LABEL_SYSTEM 6
  53. #define SYSMENU_LABEL_SAVE 11
  54. #define SYSMENU_LABEL_LOAD 12
  55. #define SYSMENU_LABEL_MUSIC 13
  56. #define SYSMENU_LABEL_SOUND 14
  57. #define SYSMENU_LABEL_QUIT 15
  58. #define SYSMENU_LABEL_BATTLEMODE 606
  59. #define SYSMENU_LABEL_LAUNCHSETTING 612
  60. #define BATTLESPEEDMENU_LABEL_1 (SYSMENU_LABEL_BATTLEMODE + 1)
  61. #define BATTLESPEEDMENU_LABEL_2 (SYSMENU_LABEL_BATTLEMODE + 2)
  62. #define BATTLESPEEDMENU_LABEL_3 (SYSMENU_LABEL_BATTLEMODE + 3)
  63. #define BATTLESPEEDMENU_LABEL_4 (SYSMENU_LABEL_BATTLEMODE + 4)
  64. #define BATTLESPEEDMENU_LABEL_5 (SYSMENU_LABEL_BATTLEMODE + 5)
  65. #define INVMENU_LABEL_USE 23
  66. #define INVMENU_LABEL_EQUIP 22
  67. #define STATUS_BACKGROUND_FBPNUM 0
  68. #define STATUS_LABEL_EXP 2
  69. #define STATUS_LABEL_LEVEL 48
  70. #define STATUS_LABEL_HP 49
  71. #define STATUS_LABEL_MP 50
  72. #define STATUS_LABEL_EXP_LAYOUT 29
  73. #define STATUS_LABEL_LEVEL_LAYOUT 30
  74. #define STATUS_LABEL_HP_LAYOUT 31
  75. #define STATUS_LABEL_MP_LAYOUT 32
  76. #define STATUS_LABEL_ATTACKPOWER 51
  77. #define STATUS_LABEL_MAGICPOWER 52
  78. #define STATUS_LABEL_RESISTANCE 53
  79. #define STATUS_LABEL_DEXTERITY 54
  80. #define STATUS_LABEL_FLEERATE 55
  81. #define STATUS_COLOR_EQUIPMENT 0xBE
  82. #define EQUIP_LABEL_HEAD 600
  83. #define EQUIP_LABEL_SHOULDER 601
  84. #define EQUIP_LABEL_BODY 602
  85. #define EQUIP_LABEL_HAND 603
  86. #define EQUIP_LABEL_FOOT 604
  87. #define EQUIP_LABEL_NECK 605
  88. #define BUYMENU_LABEL_CURRENT 35
  89. #define SELLMENU_LABEL_PRICE 25
  90. #define SPRITENUM_SLASH 39
  91. #define SPRITENUM_ITEMBOX 70
  92. #define SPRITENUM_CURSOR_YELLOW 68
  93. #define SPRITENUM_CURSOR 69
  94. #define SPRITENUM_PLAYERINFOBOX 18
  95. #define SPRITENUM_PLAYERFACE_FIRST 48
  96. #define EQUIPMENU_BACKGROUND_FBPNUM 1
  97. #define ITEMUSEMENU_COLOR_STATLABEL 0xBB
  98. #define BATTLEWIN_GETEXP_LABEL 30
  99. #define BATTLEWIN_BEATENEMY_LABEL 9
  100. #define BATTLEWIN_DOLLAR_LABEL 10
  101. #define BATTLEWIN_LEVELUP_LABEL 32
  102. #define BATTLEWIN_ADDMAGIC_LABEL 33
  103. #define BATTLEWIN_LEVELUP_LABEL_COLOR 0xBB
  104. #define SPRITENUM_ARROW 47
  105. #define BATTLE_LABEL_ESCAPEFAIL 31
  106. typedef struct tagBOX
  107. {
  108. PAL_POS pos;
  109. WORD wWidth, wHeight;
  110. SDL_Surface *lpSavedArea;
  111. } BOX, *LPBOX;
  112. typedef struct tagMENUITEM
  113. {
  114. WORD wValue;
  115. WORD wNumWord;
  116. BOOL fEnabled;
  117. PAL_POS pos;
  118. } MENUITEM, *LPMENUITEM;
  119. typedef const MENUITEM* LPCMENUITEM;
  120. typedef struct tagOBJECTDESC
  121. {
  122. WORD wObjectID;
  123. LPWSTR lpDesc;
  124. struct tagOBJECTDESC *next;
  125. } OBJECTDESC, *LPOBJECTDESC;
  126. typedef VOID (*LPITEMCHANGED_CALLBACK)(WORD);
  127. #define MENUITEM_VALUE_CANCELLED 0xFFFF
  128. typedef enum tagNUMCOLOR
  129. {
  130. kNumColorYellow,
  131. kNumColorBlue,
  132. kNumColorCyan
  133. } NUMCOLOR;
  134. typedef enum tagNUMALIGN
  135. {
  136. kNumAlignLeft,
  137. kNumAlignMid,
  138. kNumAlignRight
  139. } NUMALIGN;
  140. PAL_C_LINKAGE_BEGIN
  141. INT
  142. PAL_InitUI(
  143. VOID
  144. );
  145. VOID
  146. PAL_FreeUI(
  147. VOID
  148. );
  149. LPBOX
  150. PAL_CreateBox(
  151. PAL_POS pos,
  152. INT nRows,
  153. INT nColumns,
  154. INT iStyle,
  155. BOOL fSaveScreen
  156. );
  157. LPBOX
  158. PAL_CreateBoxWithShadow(
  159. PAL_POS pos,
  160. INT nRows,
  161. INT nColumns,
  162. INT iStyle,
  163. BOOL fSaveScreen,
  164. INT nShadowOffset
  165. );
  166. LPBOX
  167. PAL_CreateSingleLineBox(
  168. PAL_POS pos,
  169. INT nLen,
  170. BOOL fSaveScreen
  171. );
  172. LPBOX
  173. PAL_CreateSingleLineBoxWithShadow(
  174. PAL_POS pos,
  175. INT nLen,
  176. BOOL fSaveScreen,
  177. INT nShadowOffset
  178. );
  179. VOID
  180. PAL_DeleteBox(
  181. LPBOX lpBox
  182. );
  183. WORD
  184. PAL_ReadMenu(
  185. LPITEMCHANGED_CALLBACK lpfnMenuItemChanged,
  186. LPCMENUITEM rgMenuItem,
  187. INT nMenuItem,
  188. WORD wDefaultItem,
  189. BYTE bLabelColor
  190. );
  191. VOID
  192. PAL_DrawNumber(
  193. UINT iNum,
  194. UINT nLength,
  195. PAL_POS pos,
  196. NUMCOLOR color,
  197. NUMALIGN align
  198. );
  199. INT
  200. PAL_TextWidth(
  201. LPCWSTR lpszItemText
  202. );
  203. INT
  204. PAL_MenuTextMaxWidth(
  205. LPCMENUITEM rgMenuItem,
  206. INT nMenuItem
  207. );
  208. INT
  209. PAL_WordMaxWidth(
  210. INT nFirstWord,
  211. INT nWordNum
  212. );
  213. INT
  214. PAL_WordWidth(
  215. INT nWordIndex
  216. );
  217. LPOBJECTDESC
  218. PAL_LoadObjectDesc(
  219. LPCSTR lpszFileName
  220. );
  221. VOID
  222. PAL_FreeObjectDesc(
  223. LPOBJECTDESC lpObjectDesc
  224. );
  225. LPCWSTR
  226. PAL_GetObjectDesc(
  227. LPOBJECTDESC lpObjectDesc,
  228. WORD wObjectID
  229. );
  230. extern LPSPRITE gpSpriteUI;
  231. PAL_C_LINKAGE_END
  232. #endif