Settings.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. using Client.MirSounds;
  2. namespace Client
  3. {
  4. class Settings
  5. {
  6. public const long CleanDelay = 600000;
  7. public static int ScreenWidth = 1024, ScreenHeight = 768;
  8. private static InIReader Reader = new InIReader(@".\Mir2Config.ini");
  9. private static InIReader QuestTrackingReader = new InIReader(Path.Combine(UserDataPath, @".\QuestTracking.ini"));
  10. private static bool _useTestConfig;
  11. public static bool UseTestConfig
  12. {
  13. get
  14. {
  15. return _useTestConfig;
  16. }
  17. set
  18. {
  19. if (value == true)
  20. {
  21. Reader = new InIReader(@".\Mir2Test.ini");
  22. }
  23. _useTestConfig = value;
  24. }
  25. }
  26. public const string DataPath = @".\Data\",
  27. MapPath = @".\Map\",
  28. SoundPath = @".\Sound\",
  29. ExtraDataPath = @".\Data\Extra\",
  30. ShadersPath = @".\Data\Shaders\",
  31. MonsterPath = @".\Data\Monster\",
  32. GatePath = @".\Data\Gate\",
  33. FlagPath = @".\Data\Flag\",
  34. SiegePath = @".\Data\Siege\",
  35. NPCPath = @".\Data\NPC\",
  36. CArmourPath = @".\Data\CArmour\",
  37. CWeaponPath = @".\Data\CWeapon\",
  38. CWeaponEffectPath = @".\Data\CWeaponEffect\",
  39. CHairPath = @".\Data\CHair\",
  40. AArmourPath = @".\Data\AArmour\",
  41. AWeaponPath = @".\Data\AWeapon\",
  42. AHairPath = @".\Data\AHair\",
  43. ARArmourPath = @".\Data\ARArmour\",
  44. ARWeaponPath = @".\Data\ARWeapon\",
  45. ARHairPath = @".\Data\ARHair\",
  46. CHumEffectPath = @".\Data\CHumEffect\",
  47. AHumEffectPath = @".\Data\AHumEffect\",
  48. ARHumEffectPath = @".\Data\ARHumEffect\",
  49. MountPath = @".\Data\Mount\",
  50. FishingPath = @".\Data\Fishing\",
  51. PetsPath = @".\Data\Pet\",
  52. TransformPath = @".\Data\Transform\",
  53. TransformMountsPath = @".\Data\TransformRide2\",
  54. TransformEffectPath = @".\Data\TransformEffect\",
  55. TransformWeaponEffectPath = @".\Data\TransformWeaponEffect\",
  56. MouseCursorPath = @".\Data\Cursors\",
  57. ResourcePath = @".\DirectX\",
  58. UserDataPath = @".\Data\UserData\",
  59. DbLanguageJsonPath = @".\DbLanguage.json";
  60. //Logs
  61. public static bool LogErrors = true;
  62. public static bool LogChat = true;
  63. public static int RemainingErrorLogs = 100;
  64. //Graphics
  65. public static bool FullScreen = true, Borderless = true, TopMost = true, MouseClip = false;
  66. public static string FontName = "Arial"; //"MS Sans Serif"
  67. public static float FontSize = 8F;
  68. public static bool UseMouseCursors = true;
  69. public static bool FPSCap = true;
  70. public static int MaxFPS = 100;
  71. public static int Resolution = 1024;
  72. public static bool DebugMode = false;
  73. //Network
  74. public static bool UseConfig = false;
  75. public static string IPAddress = "127.0.0.1";
  76. public static int Port = 7000;
  77. public const int TimeOut = 5000;
  78. //Sound
  79. public static int SoundOverLap = 3;
  80. private static byte _volume = 100;
  81. public static int SoundCleanMinutes = 5;
  82. public static byte Volume
  83. {
  84. get { return _volume; }
  85. set
  86. {
  87. switch (value)
  88. {
  89. case > 100:
  90. _volume = (byte)100;
  91. break;
  92. case <= 0:
  93. _volume = (byte)0;
  94. break;
  95. default:
  96. _volume = value;
  97. break;
  98. }
  99. SoundManager.Vol = Convert.ToInt32(_volume);
  100. }
  101. }
  102. private static byte _musicVolume = 100;
  103. public static byte MusicVolume
  104. {
  105. get { return _musicVolume; }
  106. set
  107. {
  108. switch (value)
  109. {
  110. case > 100:
  111. _musicVolume = (byte)100;
  112. break;
  113. case <= 0:
  114. _musicVolume = (byte)0;
  115. break;
  116. default:
  117. _musicVolume = value;
  118. break;
  119. }
  120. SoundManager.MusicVol = Convert.ToInt32(_musicVolume);
  121. }
  122. }
  123. //Game
  124. public static string AccountID = "",
  125. Password = "";
  126. public static bool
  127. SkillMode = false,
  128. SkillBar = true,
  129. //SkillSet = true,
  130. Effect = true,
  131. LevelEffect = true,
  132. DropView = true,
  133. NameView = true,
  134. HPView = true,
  135. TransparentChat = false,
  136. ModeView = false,
  137. DuraView = false,
  138. DisplayDamage = true,
  139. TargetDead = false,
  140. HighlightTarget = true,
  141. ExpandedBuffWindow = true,
  142. ExpandedHeroBuffWindow = true,
  143. DisplayBodyName = false,
  144. NewMove = false;
  145. public static string Language = "English";
  146. public static int[,] SkillbarLocation = new int[2, 2] { { 0, 0 }, { 216, 0 } };
  147. //Quests
  148. public static int[] TrackedQuests = new int[5];
  149. //Chat
  150. public static bool
  151. ShowNormalChat = true,
  152. ShowYellChat = true,
  153. ShowWhisperChat = true,
  154. ShowLoverChat = true,
  155. ShowMentorChat = true,
  156. ShowGroupChat = true,
  157. ShowGuildChat = true;
  158. //Filters
  159. public static bool
  160. FilterNormalChat = false,
  161. FilterWhisperChat = false,
  162. FilterShoutChat = false,
  163. FilterSystemChat = false,
  164. FilterLoverChat = false,
  165. FilterMentorChat = false,
  166. FilterGroupChat = false,
  167. FilterGuildChat = false;
  168. //AutoPatcher
  169. public static bool P_Patcher = true;
  170. public static string P_Host = @"http://mirfiles.com/mir2/cmir/patch/";
  171. public static string P_PatchFileName = @"PList.gz";
  172. public static bool P_NeedLogin = false;
  173. public static string P_Login = string.Empty;
  174. public static string P_Password = string.Empty;
  175. public static string P_ServerName = string.Empty;
  176. public static string P_BrowserAddress = "https://www.lomcn.org/mir2-patchsite/";
  177. public static string P_Client = Application.StartupPath + "\\";
  178. public static bool P_AutoStart = false;
  179. public static int P_Concurrency = 1;
  180. public static void Load()
  181. {
  182. if (!Directory.Exists(DataPath)) Directory.CreateDirectory(DataPath);
  183. if (!Directory.Exists(MapPath)) Directory.CreateDirectory(MapPath);
  184. if (!Directory.Exists(SoundPath)) Directory.CreateDirectory(SoundPath);
  185. //Graphics
  186. FullScreen = Reader.ReadBoolean("Graphics", "FullScreen", FullScreen);
  187. Borderless = Reader.ReadBoolean("Graphics", "Borderless", Borderless);
  188. MouseClip = Reader.ReadBoolean("Graphics", "MouseClip", MouseClip);
  189. TopMost = Reader.ReadBoolean("Graphics", "AlwaysOnTop", TopMost);
  190. FPSCap = Reader.ReadBoolean("Graphics", "FPSCap", FPSCap);
  191. Resolution = Reader.ReadInt32("Graphics", "Resolution", Resolution);
  192. DebugMode = Reader.ReadBoolean("Graphics", "DebugMode", DebugMode);
  193. UseMouseCursors = Reader.ReadBoolean("Graphics", "UseMouseCursors", UseMouseCursors);
  194. //Network
  195. UseConfig = Reader.ReadBoolean("Network", "UseConfig", UseConfig);
  196. if (UseConfig)
  197. {
  198. IPAddress = Reader.ReadString("Network", "IPAddress", IPAddress);
  199. Port = Reader.ReadInt32("Network", "Port", Port);
  200. }
  201. //Logs
  202. LogErrors = Reader.ReadBoolean("Logs", "LogErrors", LogErrors);
  203. LogChat = Reader.ReadBoolean("Logs", "LogChat", LogChat);
  204. //Sound
  205. Volume = Reader.ReadByte("Sound", "Volume", Volume);
  206. SoundOverLap = Reader.ReadInt32("Sound", "SoundOverLap", SoundOverLap);
  207. MusicVolume = Reader.ReadByte("Sound", "Music", MusicVolume);
  208. var n = Reader.ReadInt32("Sound", "CleanMinutes", SoundCleanMinutes);
  209. if (n < 1 || n > 60 * 3) n = SoundCleanMinutes;
  210. SoundCleanMinutes = n;
  211. //Game
  212. AccountID = Reader.ReadString("Game", "AccountID", AccountID);
  213. Password = Reader.ReadString("Game", "Password", Password);
  214. SkillMode = Reader.ReadBoolean("Game", "SkillMode", SkillMode);
  215. SkillBar = Reader.ReadBoolean("Game", "SkillBar", SkillBar);
  216. //SkillSet = Reader.ReadBoolean("Game", "SkillSet", SkillSet);
  217. Effect = Reader.ReadBoolean("Game", "Effect", Effect);
  218. LevelEffect = Reader.ReadBoolean("Game", "LevelEffect", Effect);
  219. DropView = Reader.ReadBoolean("Game", "DropView", DropView);
  220. NameView = Reader.ReadBoolean("Game", "NameView", NameView);
  221. HPView = Reader.ReadBoolean("Game", "HPMPView", HPView);
  222. ModeView = Reader.ReadBoolean("Game", "ModeView", ModeView);
  223. FontName = Reader.ReadString("Game", "FontName", FontName);
  224. TransparentChat = Reader.ReadBoolean("Game", "TransparentChat", TransparentChat);
  225. DisplayDamage = Reader.ReadBoolean("Game", "DisplayDamage", DisplayDamage);
  226. TargetDead = Reader.ReadBoolean("Game", "TargetDead", TargetDead);
  227. HighlightTarget = Reader.ReadBoolean("Game", "HighlightTarget", HighlightTarget);
  228. ExpandedBuffWindow = Reader.ReadBoolean("Game", "ExpandedBuffWindow", ExpandedBuffWindow);
  229. ExpandedHeroBuffWindow = Reader.ReadBoolean("Game", "ExpandedHeroBuffWindow", ExpandedHeroBuffWindow);
  230. DuraView = Reader.ReadBoolean("Game", "DuraWindow", DuraView);
  231. DisplayBodyName = Reader.ReadBoolean("Game", "DisplayBodyName", DisplayBodyName);
  232. NewMove = Reader.ReadBoolean("Game", "NewMove", NewMove);
  233. Language = Reader.ReadString("Game", "Language", Language);
  234. for (int i = 0; i < SkillbarLocation.Length / 2; i++)
  235. {
  236. SkillbarLocation[i, 0] = Reader.ReadInt32("Game", "Skillbar" + i.ToString() + "X", SkillbarLocation[i, 0]);
  237. SkillbarLocation[i, 1] = Reader.ReadInt32("Game", "Skillbar" + i.ToString() + "Y", SkillbarLocation[i, 1]);
  238. }
  239. //Chat
  240. ShowNormalChat = Reader.ReadBoolean("Chat", "ShowNormalChat", ShowNormalChat);
  241. ShowYellChat = Reader.ReadBoolean("Chat", "ShowYellChat", ShowYellChat);
  242. ShowWhisperChat = Reader.ReadBoolean("Chat", "ShowWhisperChat", ShowWhisperChat);
  243. ShowLoverChat = Reader.ReadBoolean("Chat", "ShowLoverChat", ShowLoverChat);
  244. ShowMentorChat = Reader.ReadBoolean("Chat", "ShowMentorChat", ShowMentorChat);
  245. ShowGroupChat = Reader.ReadBoolean("Chat", "ShowGroupChat", ShowGroupChat);
  246. ShowGuildChat = Reader.ReadBoolean("Chat", "ShowGuildChat", ShowGuildChat);
  247. //Filters
  248. FilterNormalChat = Reader.ReadBoolean("Filter", "FilterNormalChat", FilterNormalChat);
  249. FilterWhisperChat = Reader.ReadBoolean("Filter", "FilterWhisperChat", FilterWhisperChat);
  250. FilterShoutChat = Reader.ReadBoolean("Filter", "FilterShoutChat", FilterShoutChat);
  251. FilterSystemChat = Reader.ReadBoolean("Filter", "FilterSystemChat", FilterSystemChat);
  252. FilterLoverChat = Reader.ReadBoolean("Filter", "FilterLoverChat", FilterLoverChat);
  253. FilterMentorChat = Reader.ReadBoolean("Filter", "FilterMentorChat", FilterMentorChat);
  254. FilterGroupChat = Reader.ReadBoolean("Filter", "FilterGroupChat", FilterGroupChat);
  255. FilterGuildChat = Reader.ReadBoolean("Filter", "FilterGuildChat", FilterGuildChat);
  256. //AutoPatcher
  257. P_Patcher = Reader.ReadBoolean("Launcher", "Enabled", P_Patcher);
  258. P_Host = Reader.ReadString("Launcher", "Host", P_Host);
  259. P_PatchFileName = Reader.ReadString("Launcher", "PatchFile", P_PatchFileName);
  260. P_NeedLogin = Reader.ReadBoolean("Launcher", "NeedLogin", P_NeedLogin);
  261. P_Login = Reader.ReadString("Launcher", "Login", P_Login);
  262. P_Password = Reader.ReadString("Launcher", "Password", P_Password);
  263. P_AutoStart = Reader.ReadBoolean("Launcher", "AutoStart", P_AutoStart);
  264. P_ServerName = Reader.ReadString("Launcher", "ServerName", P_ServerName);
  265. P_BrowserAddress = Reader.ReadString("Launcher", "Browser", P_BrowserAddress);
  266. P_Concurrency = Reader.ReadInt32("Launcher", "ConcurrentDownloads", P_Concurrency);
  267. if (!P_Host.EndsWith("/")) P_Host += "/";
  268. if (P_Host.StartsWith("www.", StringComparison.OrdinalIgnoreCase)) P_Host = P_Host.Insert(0, "http://");
  269. if (P_BrowserAddress.StartsWith("www.", StringComparison.OrdinalIgnoreCase)) P_BrowserAddress = P_BrowserAddress.Insert(0, "http://");
  270. //Temp check to update everyones address
  271. if (P_Host.ToLower() == "http://mirfiles.co.uk/mir2/cmir/patch/")
  272. {
  273. P_Host = "http://mirfiles.com/mir2/cmir/patch/";
  274. }
  275. if (P_Concurrency < 1) P_Concurrency = 1;
  276. if (P_Concurrency > 100) P_Concurrency = 100;
  277. try
  278. {
  279. string languageDirectory = @".\Localization\";
  280. if (!Directory.Exists(languageDirectory))
  281. {
  282. Directory.CreateDirectory(languageDirectory);
  283. }
  284. string settingLanguageFile = Path.Combine(languageDirectory, Language + ".json");
  285. GameLanguage.LoadClientLanguage(settingLanguageFile);
  286. }
  287. catch (Exception ex)
  288. {
  289. CMain.SaveError($"Load Client Language Error:{ex.Message}");
  290. }
  291. }
  292. public static void Save()
  293. {
  294. //Graphics
  295. Reader.Write("Graphics", "FullScreen", FullScreen);
  296. Reader.Write("Graphics", "Borderless", Borderless);
  297. Reader.Write("Graphics", "MouseClip", MouseClip);
  298. Reader.Write("Graphics", "AlwaysOnTop", TopMost);
  299. Reader.Write("Graphics", "FPSCap", FPSCap);
  300. Reader.Write("Graphics", "Resolution", Resolution);
  301. Reader.Write("Graphics", "DebugMode", DebugMode);
  302. Reader.Write("Graphics", "UseMouseCursors", UseMouseCursors);
  303. //Sound
  304. Reader.Write("Sound", "Volume", Volume);
  305. Reader.Write("Sound", "SoundOverLap", SoundOverLap);
  306. Reader.Write("Sound", "Music", MusicVolume);
  307. Reader.Write("Sound", "CleanMinutes", SoundCleanMinutes);
  308. //Game
  309. Reader.Write("Game", "AccountID", AccountID);
  310. Reader.Write("Game", "Password", Password);
  311. Reader.Write("Game", "SkillMode", SkillMode);
  312. Reader.Write("Game", "SkillBar", SkillBar);
  313. //Reader.Write("Game", "SkillSet", SkillSet);
  314. Reader.Write("Game", "Effect", Effect);
  315. Reader.Write("Game", "LevelEffect", LevelEffect);
  316. Reader.Write("Game", "DropView", DropView);
  317. Reader.Write("Game", "NameView", NameView);
  318. Reader.Write("Game", "HPMPView", HPView);
  319. Reader.Write("Game", "ModeView", ModeView);
  320. Reader.Write("Game", "FontName", FontName);
  321. Reader.Write("Game", "TransparentChat", TransparentChat);
  322. Reader.Write("Game", "DisplayDamage", DisplayDamage);
  323. Reader.Write("Game", "TargetDead", TargetDead);
  324. Reader.Write("Game", "HighlightTarget", HighlightTarget);
  325. Reader.Write("Game", "ExpandedBuffWindow", ExpandedBuffWindow);
  326. Reader.Write("Game", "ExpandedHeroBuffWindow", ExpandedBuffWindow);
  327. Reader.Write("Game", "DuraWindow", DuraView);
  328. Reader.Write("Game", "DisplayBodyName", DisplayBodyName);
  329. Reader.Write("Game", "NewMove", NewMove);
  330. Reader.Write("Game", "Language", Language);
  331. for (int i = 0; i < SkillbarLocation.Length / 2; i++)
  332. {
  333. Reader.Write("Game", "Skillbar" + i.ToString() + "X", SkillbarLocation[i, 0]);
  334. Reader.Write("Game", "Skillbar" + i.ToString() + "Y", SkillbarLocation[i, 1]);
  335. }
  336. //Chat
  337. Reader.Write("Chat", "ShowNormalChat", ShowNormalChat);
  338. Reader.Write("Chat", "ShowYellChat", ShowYellChat);
  339. Reader.Write("Chat", "ShowWhisperChat", ShowWhisperChat);
  340. Reader.Write("Chat", "ShowLoverChat", ShowLoverChat);
  341. Reader.Write("Chat", "ShowMentorChat", ShowMentorChat);
  342. Reader.Write("Chat", "ShowGroupChat", ShowGroupChat);
  343. Reader.Write("Chat", "ShowGuildChat", ShowGuildChat);
  344. //Filters
  345. Reader.Write("Filter", "FilterNormalChat", FilterNormalChat);
  346. Reader.Write("Filter", "FilterWhisperChat", FilterWhisperChat);
  347. Reader.Write("Filter", "FilterShoutChat", FilterShoutChat);
  348. Reader.Write("Filter", "FilterSystemChat", FilterSystemChat);
  349. Reader.Write("Filter", "FilterLoverChat", FilterLoverChat);
  350. Reader.Write("Filter", "FilterMentorChat", FilterMentorChat);
  351. Reader.Write("Filter", "FilterGroupChat", FilterGroupChat);
  352. Reader.Write("Filter", "FilterGuildChat", FilterGuildChat);
  353. //AutoPatcher
  354. Reader.Write("Launcher", "Enabled", P_Patcher);
  355. Reader.Write("Launcher", "Host", P_Host);
  356. Reader.Write("Launcher", "PatchFile", P_PatchFileName);
  357. Reader.Write("Launcher", "NeedLogin", P_NeedLogin);
  358. Reader.Write("Launcher", "Login", P_Login);
  359. Reader.Write("Launcher", "Password", P_Password);
  360. Reader.Write("Launcher", "ServerName", P_ServerName);
  361. Reader.Write("Launcher", "Browser", P_BrowserAddress);
  362. Reader.Write("Launcher", "AutoStart", P_AutoStart);
  363. Reader.Write("Launcher", "ConcurrentDownloads", P_Concurrency);
  364. }
  365. public static void LoadTrackedQuests(string charName)
  366. {
  367. //Quests
  368. for (int i = 0; i < TrackedQuests.Length; i++)
  369. {
  370. TrackedQuests[i] = QuestTrackingReader.ReadInt32(charName, "Quest-" + i.ToString(), -1);
  371. }
  372. }
  373. public static void SaveTrackedQuests(string charName)
  374. {
  375. //Quests
  376. for (int i = 0; i < TrackedQuests.Length; i++)
  377. {
  378. QuestTrackingReader.Write(charName, "Quest-" + i.ToString(), TrackedQuests[i]);
  379. }
  380. }
  381. }
  382. }