ConditionConfig.pas 4.9 KB

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