palcfg.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /* -*- mode: c; tab-width: 4; c-basic-offset: 4; c-file-style: "linux" -*- */
  2. //
  3. // Copyright (c) 2009-2011, Wei Mingzhi <whistler_wmz@users.sf.net>.
  4. // Copyright (c) 2011-2017, SDLPAL development team.
  5. // All rights reserved.
  6. //
  7. // This file is part of SDLPAL.
  8. //
  9. // SDLPAL is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU General Public License as published by
  11. // the Free Software Foundation, either version 3 of the License, or
  12. // (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. //
  22. // palcfg.h: Configuration definition.
  23. // @Author: Lou Yihua <louyihua@21cn.com>, 2016.
  24. //
  25. #ifndef CONFIG_H
  26. #define CONFIG_H
  27. #include "common.h"
  28. #include "palcommon.h"
  29. #define PAL_MAX_SAMPLERATE 48000
  30. #define PAL_MAX_VOLUME 100
  31. typedef enum tagPALCFG_ITEM
  32. {
  33. PALCFG_ALL_MIN = 0,
  34. PALCFG_BOOLEAN_MIN = PALCFG_ALL_MIN,
  35. /* Booleans */
  36. PALCFG_FULLSCREEN = PALCFG_BOOLEAN_MIN,
  37. PALCFG_KEEPASPECTRATIO,
  38. PALCFG_LAUNCHSETTING,
  39. PALCFG_STEREO,
  40. PALCFG_USESURROUNDOPL,
  41. PALCFG_USETOUCHOVERLAY,
  42. /* Booleans */
  43. PALCFG_BOOLEAN_MAX,
  44. PALCFG_INTEGER_MIN = PALCFG_BOOLEAN_MAX,
  45. /* Integers */
  46. PALCFG_SURROUNDOPLOFFSET = PALCFG_INTEGER_MIN,
  47. PALCFG_LOGLEVEL,
  48. /* Integers */
  49. PALCFG_INTEGER_MAX,
  50. PALCFG_UNSIGNED_MIN = PALCFG_INTEGER_MAX,
  51. /* Unsigneds */
  52. PALCFG_AUDIOBUFFERSIZE = PALCFG_UNSIGNED_MIN,
  53. PALCFG_OPLSAMPLERATE,
  54. PALCFG_RESAMPLEQUALITY,
  55. PALCFG_SAMPLERATE,
  56. PALCFG_MUSICVOLUME,
  57. PALCFG_SOUNDVOLUME,
  58. PALCFG_WINDOWHEIGHT,
  59. PALCFG_WINDOWWIDTH,
  60. /* Unsigneds */
  61. PALCFG_UNSIGNED_MAX,
  62. PALCFG_STRING_MIN = PALCFG_UNSIGNED_MAX,
  63. /* Strings */
  64. PALCFG_CD = PALCFG_STRING_MIN,
  65. PALCFG_GAMEPATH,
  66. PALCFG_SAVEPATH,
  67. PALCFG_MESSAGEFILE,
  68. PALCFG_FONTFILE,
  69. PALCFG_MUSIC,
  70. PALCFG_OPL,
  71. PALCFG_LOGFILE,
  72. PALCFG_RIXEXTRAINIT,
  73. PALCFG_CLIMIDIPLAYER,
  74. /* Strings */
  75. PALCFG_STRING_MAX,
  76. PALCFG_ALL_MAX = PALCFG_STRING_MAX
  77. } PALCFG_ITEM;
  78. typedef enum tagPALCFG_TYPE
  79. {
  80. PALCFG_STRING,
  81. PALCFG_BOOLEAN,
  82. PALCFG_INTEGER,
  83. PALCFG_UNSIGNED,
  84. } PALCFG_TYPE;
  85. typedef union tagConfigValue
  86. {
  87. LPCSTR sValue;
  88. DWORD uValue;
  89. INT iValue;
  90. BOOL bValue;
  91. } ConfigValue;
  92. typedef struct tagConfigItem
  93. {
  94. PALCFG_ITEM Item;
  95. PALCFG_TYPE Type;
  96. const char* Name;
  97. int NameLength;
  98. const ConfigValue DefaultValue;
  99. const ConfigValue MinValue;
  100. const ConfigValue MaxValue;
  101. } ConfigItem;
  102. typedef struct tagSCREENLAYOUT
  103. {
  104. PAL_POS EquipImageBox;
  105. PAL_POS EquipRoleListBox;
  106. PAL_POS EquipItemName;
  107. PAL_POS EquipItemAmount;
  108. PAL_POS EquipLabels[MAX_PLAYER_EQUIPMENTS];
  109. PAL_POS EquipNames[MAX_PLAYER_EQUIPMENTS];
  110. PAL_POS EquipStatusLabels[5];
  111. PAL_POS EquipStatusValues[5];
  112. PAL_POS RoleName;
  113. PAL_POS RoleImage;
  114. PAL_POS RoleExpLabel;
  115. PAL_POS RoleLevelLabel;
  116. PAL_POS RoleHPLabel;
  117. PAL_POS RoleMPLabel;
  118. PAL_POS RoleStatusLabels[5];
  119. PAL_POS RoleCurrExp;
  120. PAL_POS RoleNextExp;
  121. PAL_POS RoleExpSlash;
  122. PAL_POS RoleLevel;
  123. PAL_POS RoleCurHP;
  124. PAL_POS RoleMaxHP;
  125. PAL_POS RoleHPSlash;
  126. PAL_POS RoleCurMP;
  127. PAL_POS RoleMaxMP;
  128. PAL_POS RoleMPSlash;
  129. PAL_POS RoleStatusValues[5];
  130. PAL_POS RoleEquipImageBoxes[MAX_PLAYER_EQUIPMENTS];
  131. PAL_POS RoleEquipNames[MAX_PLAYER_EQUIPMENTS];
  132. PAL_POS RolePoisonNames[MAX_POISONS];
  133. PAL_POS ExtraItemDescLines;
  134. PAL_POS ExtraMagicDescLines;
  135. } SCREENLAYOUT;
  136. typedef struct tagCONFIGURATION
  137. {
  138. union {
  139. SCREENLAYOUT ScreenLayout;
  140. PAL_POS ScreenLayoutArray[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  141. };
  142. enum {
  143. USE_8x8_FONT = 1,
  144. DISABLE_SHADOW = 2,
  145. } ScreenLayoutFlag[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  146. /* Configurable options */
  147. char *pszGamePath;
  148. char *pszSavePath;
  149. char *pszMsgFile;
  150. char *pszFontFile;
  151. char *pszCLIMIDIPlayerPath;
  152. char *pszLogFile;
  153. DWORD dwWordLength;
  154. DWORD dwScreenWidth;
  155. DWORD dwScreenHeight;
  156. INT iSurroundOPLOffset;
  157. INT iAudioChannels;
  158. INT iSampleRate;
  159. INT iOPLSampleRate;
  160. INT iResampleQuality;
  161. INT iMusicVolume;
  162. INT iSoundVolume;
  163. LOGLEVEL iLogLevel;
  164. MUSICTYPE eMusicType;
  165. MUSICTYPE eCDType;
  166. OPLTYPE eOPLType;
  167. WORD wAudioBufferSize;
  168. BOOL fIsWIN95;
  169. BOOL fUseSurroundOPL;
  170. BOOL fKeepAspectRatio;
  171. BOOL fFullScreen;
  172. BOOL fEnableJoyStick;
  173. BOOL fUseCustomScreenLayout;
  174. BOOL fLaunchSetting;
  175. BOOL fUseTouchOverlay;
  176. #if USE_RIX_EXTRA_INIT
  177. uint32_t *pExtraFMRegs;
  178. uint8_t *pExtraFMVals;
  179. uint32_t dwExtraLength;
  180. #endif
  181. } CONFIGURATION, *LPCONFIGURATION;
  182. PAL_C_LINKAGE_BEGIN
  183. extern CONFIGURATION gConfig;
  184. void
  185. PAL_LoadConfig(
  186. BOOL fFromFile
  187. );
  188. BOOL
  189. PAL_SaveConfig(
  190. void
  191. );
  192. void
  193. PAL_FreeConfig(
  194. void
  195. );
  196. BOOL
  197. PAL_ParseConfigLine(
  198. const char * line,
  199. const ConfigItem ** pItem,
  200. ConfigValue * pValue
  201. );
  202. const char *
  203. PAL_ConfigName(
  204. PALCFG_ITEM item
  205. );
  206. PALCFG_ITEM
  207. PAL_ConfigIndex(
  208. const char *name
  209. );
  210. PALCFG_TYPE
  211. PAL_ConfigType(
  212. PALCFG_ITEM item
  213. );
  214. BOOL
  215. PAL_LimitConfig(
  216. PALCFG_ITEM item,
  217. ConfigValue * pValue
  218. );
  219. ConfigValue
  220. PAL_GetConfigItem(
  221. PALCFG_ITEM item,
  222. BOOL default_value
  223. );
  224. void
  225. PAL_SetConfigItem(
  226. PALCFG_ITEM item,
  227. const ConfigValue value
  228. );
  229. BOOL
  230. PAL_GetConfigBoolean(
  231. PALCFG_ITEM item,
  232. BOOL default_value
  233. );
  234. long
  235. PAL_GetConfigNumber(
  236. PALCFG_ITEM item,
  237. BOOL default_value
  238. );
  239. int
  240. PAL_GetConfigInteger(
  241. PALCFG_ITEM item,
  242. BOOL default_value
  243. );
  244. unsigned int
  245. PAL_GetConfigUnsigned(
  246. PALCFG_ITEM item,
  247. BOOL default_value
  248. );
  249. const char *
  250. PAL_GetConfigString(
  251. PALCFG_ITEM item,
  252. BOOL default_value
  253. );
  254. BOOL
  255. PAL_SetConfigBoolean(
  256. PALCFG_ITEM item,
  257. BOOL value
  258. );
  259. BOOL
  260. PAL_SetConfigNumber(
  261. PALCFG_ITEM item,
  262. long value
  263. );
  264. BOOL
  265. PAL_SetConfigInteger(
  266. PALCFG_ITEM item,
  267. int value
  268. );
  269. BOOL
  270. PAL_SetConfigUnsigned(
  271. PALCFG_ITEM item,
  272. unsigned int value
  273. );
  274. BOOL
  275. PAL_SetConfigString(
  276. PALCFG_ITEM item,
  277. const char *value
  278. );
  279. PAL_C_LINKAGE_END
  280. #endif