palcfg.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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 49716
  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. PALCFG_ENABLEAVIPLAY,
  43. /* Booleans */
  44. PALCFG_BOOLEAN_MAX,
  45. PALCFG_INTEGER_MIN = PALCFG_BOOLEAN_MAX,
  46. /* Integers */
  47. PALCFG_SURROUNDOPLOFFSET = PALCFG_INTEGER_MIN,
  48. PALCFG_LOGLEVEL,
  49. /* Integers */
  50. PALCFG_INTEGER_MAX,
  51. PALCFG_UNSIGNED_MIN = PALCFG_INTEGER_MAX,
  52. /* Unsigneds */
  53. PALCFG_AUDIOBUFFERSIZE = PALCFG_UNSIGNED_MIN,
  54. PALCFG_OPLSAMPLERATE,
  55. PALCFG_RESAMPLEQUALITY,
  56. PALCFG_SAMPLERATE,
  57. PALCFG_MUSICVOLUME,
  58. PALCFG_SOUNDVOLUME,
  59. PALCFG_WINDOWHEIGHT,
  60. PALCFG_WINDOWWIDTH,
  61. /* Unsigneds */
  62. PALCFG_UNSIGNED_MAX,
  63. PALCFG_STRING_MIN = PALCFG_UNSIGNED_MAX,
  64. /* Strings */
  65. PALCFG_CD = PALCFG_STRING_MIN,
  66. PALCFG_GAMEPATH,
  67. PALCFG_SAVEPATH,
  68. PALCFG_MESSAGEFILE,
  69. PALCFG_FONTFILE,
  70. PALCFG_MUSIC,
  71. PALCFG_OPL,
  72. PALCFG_LOGFILE,
  73. PALCFG_RIXEXTRAINIT,
  74. PALCFG_CLIMIDIPLAYER,
  75. PALCFG_SCALEQUALITY,
  76. PALCFG_ASPECTRATIO,
  77. /* Strings */
  78. PALCFG_STRING_MAX,
  79. PALCFG_ALL_MAX = PALCFG_STRING_MAX
  80. } PALCFG_ITEM;
  81. typedef enum tagPALCFG_TYPE
  82. {
  83. PALCFG_STRING,
  84. PALCFG_BOOLEAN,
  85. PALCFG_INTEGER,
  86. PALCFG_UNSIGNED,
  87. } PALCFG_TYPE;
  88. typedef union tagConfigValue
  89. {
  90. LPCSTR sValue;
  91. DWORD uValue;
  92. INT iValue;
  93. BOOL bValue;
  94. } ConfigValue;
  95. typedef struct tagConfigItem
  96. {
  97. PALCFG_ITEM Item;
  98. PALCFG_TYPE Type;
  99. const char* Name;
  100. int NameLength;
  101. const ConfigValue DefaultValue;
  102. const ConfigValue MinValue;
  103. const ConfigValue MaxValue;
  104. } ConfigItem;
  105. typedef struct tagSCREENLAYOUT
  106. {
  107. PAL_POS EquipImageBox;
  108. PAL_POS EquipRoleListBox;
  109. PAL_POS EquipItemName;
  110. PAL_POS EquipItemAmount;
  111. PAL_POS EquipLabels[MAX_PLAYER_EQUIPMENTS];
  112. PAL_POS EquipNames[MAX_PLAYER_EQUIPMENTS];
  113. PAL_POS EquipStatusLabels[5];
  114. PAL_POS EquipStatusValues[5];
  115. PAL_POS RoleName;
  116. PAL_POS RoleImage;
  117. PAL_POS RoleExpLabel;
  118. PAL_POS RoleLevelLabel;
  119. PAL_POS RoleHPLabel;
  120. PAL_POS RoleMPLabel;
  121. PAL_POS RoleStatusLabels[5];
  122. PAL_POS RoleCurrExp;
  123. PAL_POS RoleNextExp;
  124. PAL_POS RoleExpSlash;
  125. PAL_POS RoleLevel;
  126. PAL_POS RoleCurHP;
  127. PAL_POS RoleMaxHP;
  128. PAL_POS RoleHPSlash;
  129. PAL_POS RoleCurMP;
  130. PAL_POS RoleMaxMP;
  131. PAL_POS RoleMPSlash;
  132. PAL_POS RoleStatusValues[5];
  133. PAL_POS RoleEquipImageBoxes[MAX_PLAYER_EQUIPMENTS];
  134. PAL_POS RoleEquipNames[MAX_PLAYER_EQUIPMENTS];
  135. PAL_POS RolePoisonNames[MAX_POISONS];
  136. PAL_POS ExtraItemDescLines;
  137. PAL_POS ExtraMagicDescLines;
  138. } SCREENLAYOUT;
  139. typedef struct tagCONFIGURATION
  140. {
  141. union {
  142. SCREENLAYOUT ScreenLayout;
  143. PAL_POS ScreenLayoutArray[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  144. };
  145. enum {
  146. USE_8x8_FONT = 1,
  147. DISABLE_SHADOW = 2,
  148. } ScreenLayoutFlag[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  149. /* Configurable options */
  150. char *pszGamePath;
  151. char *pszSavePath;
  152. char *pszMsgFile;
  153. char *pszFontFile;
  154. char *pszCLIMIDIPlayerPath;
  155. char *pszLogFile;
  156. char *pszScaleQuality;
  157. DWORD dwWordLength;
  158. DWORD dwScreenWidth;
  159. DWORD dwScreenHeight;
  160. DWORD dwAspectX;
  161. DWORD dwAspectY;
  162. INT iSurroundOPLOffset;
  163. INT iAudioChannels;
  164. INT iSampleRate;
  165. INT iOPLSampleRate;
  166. INT iResampleQuality;
  167. INT iMusicVolume;
  168. INT iSoundVolume;
  169. LOGLEVEL iLogLevel;
  170. MUSICTYPE eMusicType;
  171. MUSICTYPE eCDType;
  172. OPLTYPE eOPLType;
  173. WORD wAudioBufferSize;
  174. BOOL fIsWIN95;
  175. BOOL fUseSurroundOPL;
  176. BOOL fKeepAspectRatio;
  177. BOOL fFullScreen;
  178. BOOL fEnableJoyStick;
  179. BOOL fUseCustomScreenLayout;
  180. BOOL fLaunchSetting;
  181. BOOL fUseTouchOverlay;
  182. BOOL fEnableAviPlay;
  183. #if USE_RIX_EXTRA_INIT
  184. uint32_t *pExtraFMRegs;
  185. uint8_t *pExtraFMVals;
  186. uint32_t dwExtraLength;
  187. #endif
  188. } CONFIGURATION, *LPCONFIGURATION;
  189. PAL_C_LINKAGE_BEGIN
  190. extern CONFIGURATION gConfig;
  191. void
  192. PAL_LoadConfig(
  193. BOOL fFromFile
  194. );
  195. BOOL
  196. PAL_SaveConfig(
  197. void
  198. );
  199. void
  200. PAL_FreeConfig(
  201. void
  202. );
  203. BOOL
  204. PAL_ParseConfigLine(
  205. const char * line,
  206. const ConfigItem ** pItem,
  207. ConfigValue * pValue
  208. );
  209. const char *
  210. PAL_ConfigName(
  211. PALCFG_ITEM item
  212. );
  213. PALCFG_ITEM
  214. PAL_ConfigIndex(
  215. const char *name
  216. );
  217. PALCFG_TYPE
  218. PAL_ConfigType(
  219. PALCFG_ITEM item
  220. );
  221. BOOL
  222. PAL_LimitConfig(
  223. PALCFG_ITEM item,
  224. ConfigValue * pValue
  225. );
  226. ConfigValue
  227. PAL_GetConfigItem(
  228. PALCFG_ITEM item,
  229. BOOL default_value
  230. );
  231. void
  232. PAL_SetConfigItem(
  233. PALCFG_ITEM item,
  234. const ConfigValue value
  235. );
  236. BOOL
  237. PAL_GetConfigBoolean(
  238. PALCFG_ITEM item,
  239. BOOL default_value
  240. );
  241. long
  242. PAL_GetConfigNumber(
  243. PALCFG_ITEM item,
  244. BOOL default_value
  245. );
  246. int
  247. PAL_GetConfigInteger(
  248. PALCFG_ITEM item,
  249. BOOL default_value
  250. );
  251. unsigned int
  252. PAL_GetConfigUnsigned(
  253. PALCFG_ITEM item,
  254. BOOL default_value
  255. );
  256. const char *
  257. PAL_GetConfigString(
  258. PALCFG_ITEM item,
  259. BOOL default_value
  260. );
  261. BOOL
  262. PAL_SetConfigBoolean(
  263. PALCFG_ITEM item,
  264. BOOL value
  265. );
  266. BOOL
  267. PAL_SetConfigNumber(
  268. PALCFG_ITEM item,
  269. long value
  270. );
  271. BOOL
  272. PAL_SetConfigInteger(
  273. PALCFG_ITEM item,
  274. int value
  275. );
  276. BOOL
  277. PAL_SetConfigUnsigned(
  278. PALCFG_ITEM item,
  279. unsigned int value
  280. );
  281. BOOL
  282. PAL_SetConfigString(
  283. PALCFG_ITEM item,
  284. const char *value
  285. );
  286. PAL_C_LINKAGE_END
  287. #endif