ui.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. #ifdef PAL_WIN95
  44. #define MAINMENU_BACKGROUND_FBPNUM 2
  45. #else
  46. #define MAINMENU_BACKGROUND_FBPNUM 60
  47. #endif
  48. #define RIX_NUM_OPENINGMENU 4
  49. #define MAINMENU_LABEL_NEWGAME 7
  50. #define MAINMENU_LABEL_LOADGAME 8
  51. #define LOADMENU_LABEL_SLOT_FIRST 43
  52. #define CONFIRMMENU_LABEL_NO 19
  53. #define CONFIRMMENU_LABEL_YES 20
  54. #define CASH_LABEL 21
  55. #define SWITCHMENU_LABEL_DISABLE 17
  56. #define SWITCHMENU_LABEL_ENABLE 18
  57. #define GAMEMENU_LABEL_STATUS 3
  58. #define GAMEMENU_LABEL_MAGIC 4
  59. #define GAMEMENU_LABEL_INVENTORY 5
  60. #define GAMEMENU_LABEL_SYSTEM 6
  61. #define SYSMENU_LABEL_SAVE 11
  62. #define SYSMENU_LABEL_LOAD 12
  63. #define SYSMENU_LABEL_MUSIC 13
  64. #define SYSMENU_LABEL_SOUND 14
  65. #define SYSMENU_LABEL_QUIT 15
  66. #define SYSMENU_LABEL_BATTLEMODE (PAL_ADDITIONAL_WORD_FIRST)
  67. #define BATTLESPEEDMENU_LABEL_1 (PAL_ADDITIONAL_WORD_FIRST + 1)
  68. #define BATTLESPEEDMENU_LABEL_2 (PAL_ADDITIONAL_WORD_FIRST + 2)
  69. #define BATTLESPEEDMENU_LABEL_3 (PAL_ADDITIONAL_WORD_FIRST + 3)
  70. #define BATTLESPEEDMENU_LABEL_4 (PAL_ADDITIONAL_WORD_FIRST + 4)
  71. #define BATTLESPEEDMENU_LABEL_5 (PAL_ADDITIONAL_WORD_FIRST + 5)
  72. #define INVMENU_LABEL_USE 23
  73. #define INVMENU_LABEL_EQUIP 22
  74. #define STATUS_BACKGROUND_FBPNUM 0
  75. #define STATUS_LABEL_EXP 2
  76. #define STATUS_LABEL_LEVEL 48
  77. #define STATUS_LABEL_HP 49
  78. #define STATUS_LABEL_MP 50
  79. #define STATUS_LABEL_ATTACKPOWER 51
  80. #define STATUS_LABEL_MAGICPOWER 52
  81. #define STATUS_LABEL_RESISTANCE 53
  82. #define STATUS_LABEL_DEXTERITY 54
  83. #define STATUS_LABEL_FLEERATE 55
  84. #define STATUS_COLOR_EQUIPMENT 0xBE
  85. #define BUYMENU_LABEL_CURRENT 35
  86. #define SELLMENU_LABEL_PRICE 25
  87. #define SPRITENUM_SLASH 39
  88. #define SPRITENUM_ITEMBOX 70
  89. #define SPRITENUM_CURSOR_YELLOW 68
  90. #define SPRITENUM_CURSOR 69
  91. #define SPRITENUM_PLAYERINFOBOX 18
  92. #define SPRITENUM_PLAYERFACE_FIRST 48
  93. #define EQUIPMENU_BACKGROUND_FBPNUM 1
  94. #define ITEMUSEMENU_COLOR_STATLABEL 0xBB
  95. #define BATTLEWIN_GETEXP_LABEL 30
  96. #define BATTLEWIN_BEATENEMY_LABEL 9
  97. #define BATTLEWIN_DOLLAR_LABEL 10
  98. #define BATTLEWIN_LEVELUP_LABEL 32
  99. #define BATTLEWIN_ADDMAGIC_LABEL 33
  100. #define BATTLEWIN_LEVELUP_LABEL_COLOR 0x39
  101. #define SPRITENUM_ARROW 47
  102. #define BATTLE_LABEL_ESCAPEFAIL 31
  103. typedef struct tagBOX
  104. {
  105. PAL_POS pos;
  106. WORD wWidth, wHeight;
  107. SDL_Surface *lpSavedArea;
  108. } BOX, *LPBOX;
  109. typedef struct tagMENUITEM
  110. {
  111. WORD wValue;
  112. WORD wNumWord;
  113. BOOL fEnabled;
  114. PAL_POS pos;
  115. } MENUITEM, *LPMENUITEM;
  116. typedef struct tagOBJECTDESC
  117. {
  118. WORD wObjectID;
  119. #ifdef PAL_UNICODE
  120. LPWSTR lpDesc;
  121. #else
  122. LPSTR lpDesc;
  123. #endif
  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. INT
  141. PAL_InitUI(
  142. VOID
  143. );
  144. VOID
  145. PAL_FreeUI(
  146. VOID
  147. );
  148. LPBOX
  149. PAL_CreateBox(
  150. PAL_POS pos,
  151. INT nRows,
  152. INT nColumns,
  153. INT iStyle,
  154. BOOL fSaveScreen
  155. );
  156. LPBOX
  157. PAL_CreateSingleLineBox(
  158. PAL_POS pos,
  159. INT nLen,
  160. BOOL fSaveScreen
  161. );
  162. VOID
  163. PAL_DeleteBox(
  164. LPBOX lpBox
  165. );
  166. WORD
  167. PAL_ReadMenu(
  168. LPITEMCHANGED_CALLBACK lpfnMenuItemChanged,
  169. LPMENUITEM rgMenuItem,
  170. INT nMenuItem,
  171. WORD wDefaultItem,
  172. BYTE bLabelColor
  173. );
  174. VOID
  175. PAL_DrawNumber(
  176. UINT iNum,
  177. UINT nLength,
  178. PAL_POS pos,
  179. NUMCOLOR color,
  180. NUMALIGN align
  181. );
  182. LPOBJECTDESC
  183. PAL_LoadObjectDesc(
  184. LPCSTR lpszFileName
  185. );
  186. VOID
  187. PAL_FreeObjectDesc(
  188. LPOBJECTDESC lpObjectDesc
  189. );
  190. #ifdef PAL_UNICODE
  191. LPCWSTR
  192. #else
  193. LPCSTR
  194. #endif
  195. PAL_GetObjectDesc(
  196. LPOBJECTDESC lpObjectDesc,
  197. WORD wObjectID
  198. );
  199. extern LPSPRITE gpSpriteUI;
  200. #ifdef __cplusplus
  201. }
  202. #endif
  203. #endif