ConditionConfig.pas 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. unit ConditionConfig;
  2. interface
  3. uses
  4. Classes, SysUtils, superobject;
  5. type
  6. TConditionConfig = class
  7. private
  8. FFaceSize: Int64;
  9. FUserInfoController: Boolean;
  10. FSMSName: string;
  11. FOtherServersDisable: Boolean;
  12. FNewCenterServer: Boolean;
  13. FUserInfoCheck: Boolean;
  14. FGradeSystem: Boolean;
  15. FFirstLoginConfirm: Boolean;
  16. FDev: Boolean;
  17. FRemoteUIHost: string;
  18. FRemoteUI: Boolean;
  19. FMapHost: string;
  20. FArm2Mp3Host: string;
  21. procedure SetArm2Mp3Host(const Value: string);
  22. public
  23. constructor Create;
  24. class function Load: TConditionConfig;
  25. class function GetConfig: TConditionConfig;
  26. property FaceSize: Int64 read FFaceSize;
  27. property UserInfoController: Boolean read FUserInfoController;
  28. property OtherServersDisable: Boolean read FOtherServersDisable;
  29. property NewCenterServer: Boolean read FNewCenterServer;
  30. property UserInfoCheck: Boolean read FUserInfoCheck;
  31. property SMSName: string read FSMSName;
  32. property GradeSystem: Boolean read FGradeSystem;
  33. property FirstLoginConfirm: Boolean read FFirstLoginConfirm;
  34. property Dev: Boolean read FDev;
  35. property RemoteUI: Boolean read FRemoteUI;
  36. property RemoteUIHost: string read FRemoteUIHost;
  37. property MapHost: string read FMapHost;
  38. property Arm2Mp3Host: string read FArm2Mp3Host write SetArm2Mp3Host;
  39. end;
  40. TCustomerConfig = class
  41. private
  42. FData: ISuperObject;
  43. FShowGuideViewBtn: Boolean;
  44. function GetShowGuideView: Boolean;
  45. procedure SetShowGuideView(const Value: Boolean);
  46. procedure Save;
  47. procedure SetShowGuideViewBtn(const Value: Boolean);
  48. function GetShowGuideViewBtn: Boolean;
  49. public
  50. constructor Create;
  51. class function GetConfig: TCustomerConfig; static;
  52. property ShowGuideView: Boolean read GetShowGuideView write SetShowGuideView;
  53. property ShowGuideViewBtn: Boolean read GetShowGuideViewBtn write SetShowGuideViewBtn;
  54. end;
  55. implementation
  56. uses
  57. Dialogs, TypInfo, Winsock2, LoggerImport;
  58. const
  59. CONDITION_CONFIG: string = 'Config\condition.config';
  60. CUSTOMER_CONFIG: string = 'Config\customer.config';
  61. var
  62. config: TConditionConfig;
  63. customerConfig: TCustomerConfig;
  64. constructor TConditionConfig.Create;
  65. begin
  66. FFaceSize := 20; //µ¥Î»M
  67. end;
  68. class function TConditionConfig.GetConfig: TConditionConfig;
  69. begin
  70. if config <> nil then
  71. Result := config
  72. else
  73. Result := TConditionConfig.Load;
  74. end;
  75. class function TConditionConfig.Load: TConditionConfig;
  76. var
  77. AFullFileName: string;
  78. jo, AServer: ISuperObject;
  79. AGroupServerAddresses: TSuperArray;
  80. iLoop: Integer;
  81. begin
  82. if config <> nil then
  83. FreeAndNil(config);
  84. config := TConditionConfig.Create;
  85. Result := config;
  86. AFullFileName := ExtractFilePath(ParamStr(0)) + CONDITION_CONFIG;
  87. if not FileExists(AFullFileName) then
  88. Exit;
  89. try
  90. jo := TSuperObject.ParseFile(AFullFileName, False);
  91. if jo.O['faceSize'] <> nil then
  92. Result.FFaceSize := jo['faceSize'].AsInteger;
  93. Result.FUserInfoController := jo.B['userInfoController'];
  94. Result.FOtherServersDisable := jo.B['otherServersDisable'];
  95. Result.FNewCenterServer := jo.B['newCenterServer'];
  96. Result.FSMSName := jo.S['smsName'];
  97. Result.FUserInfoCheck := jo.B['userInfoCheck'];
  98. Result.FGradeSystem := jo.B['grade'];
  99. Result.FFirstLoginConfirm := jo.B['firstLoginConfirm'];
  100. Result.FDev := jo.B['dev'];
  101. Result.FRemoteUI := jo.B['remoteUI'];
  102. Result.FRemoteUIHost := jo.S['remoteUIHost'];
  103. Result.FMapHost := jo.S['mapHost'];
  104. Result.FArm2Mp3Host := jo.S['arm2mp3Host'];
  105. except
  106. on E: Exception do
  107. begin
  108. Error(E.Message, 'TConditionConfig.Load');
  109. end;
  110. end;
  111. end;
  112. procedure TConditionConfig.SetArm2Mp3Host(const Value: string);
  113. begin
  114. FArm2Mp3Host := Value;
  115. end;
  116. { TCustomerConfig }
  117. constructor TCustomerConfig.Create;
  118. var
  119. AFullFileName: string;
  120. begin
  121. AFullFileName := ExtractFilePath(ParamStr(0)) + CUSTOMER_CONFIG;
  122. if not FileExists(AFullFileName) then
  123. FData := SO()
  124. else
  125. FData := TSuperObject.ParseFile(AFullFileName, False);
  126. inherited Create;
  127. end;
  128. class function TCustomerConfig.GetConfig: TCustomerConfig;
  129. begin
  130. if customerConfig <> nil then
  131. Result := customerConfig
  132. else
  133. Result := TCustomerConfig.Create;
  134. end;
  135. function TCustomerConfig.GetShowGuideView: Boolean;
  136. begin
  137. Result := FData.B['showGuideView'];
  138. end;
  139. function TCustomerConfig.GetShowGuideViewBtn: Boolean;
  140. begin
  141. Result := FData.B['showGuideViewBtn'];
  142. end;
  143. procedure TCustomerConfig.Save;
  144. var
  145. AFullFileName: string;
  146. begin
  147. AFullFileName := ExtractFilePath(ParamStr(0)) + CUSTOMER_CONFIG;
  148. FData.SaveTo(AFullFileName);
  149. end;
  150. procedure TCustomerConfig.SetShowGuideView(const Value: Boolean);
  151. begin
  152. if FData.B['showGuideView'] = Value then
  153. Exit;
  154. FData.B['showGuideView'] := Value;
  155. Save;
  156. end;
  157. procedure TCustomerConfig.SetShowGuideViewBtn(const Value: Boolean);
  158. begin
  159. FShowGuideViewBtn := Value;
  160. end;
  161. initialization
  162. finalization
  163. if config <> nil then
  164. FreeAndNil(config);
  165. if customerConfig <> nil then
  166. FreeAndNil(customerConfig);
  167. end.