ConditionConfig.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. unit ConditionConfig;
  2. interface
  3. uses
  4. Classes, SysUtils;
  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. implementation
  38. uses
  39. superobject, Dialogs, TypInfo, Winsock2, LoggerImport;
  40. const
  41. CONDITION_CONFIG: string = 'Config\condition.config';
  42. var
  43. config: TConditionConfig;
  44. constructor TConditionConfig.Create;
  45. begin
  46. FFaceSize := 20;//µ¥Î»M
  47. end;
  48. class function TConditionConfig.GetConfig: TConditionConfig;
  49. begin
  50. if config <> nil then
  51. Result := config
  52. else
  53. Result := TConditionConfig.Load;
  54. end;
  55. class function TConditionConfig.Load: TConditionConfig;
  56. var
  57. AFullFileName: string;
  58. jo, AServer: ISuperObject;
  59. AGroupServerAddresses: TSuperArray;
  60. iLoop: Integer;
  61. begin
  62. if config <> nil then
  63. FreeAndNil(config);
  64. config := TConditionConfig.Create;
  65. Result := config;
  66. AFullFileName := ExtractFilePath(ParamStr(0)) + CONDITION_CONFIG;
  67. if not FileExists(AFullFileName) then
  68. Exit;
  69. try
  70. jo := TSuperObject.ParseFile(AFullFileName, False);
  71. if jo.O['faceSize'] <> nil then
  72. Result.FFaceSize := jo['faceSize'].AsInteger;
  73. Result.FUserInfoController := jo.B['userInfoController'];
  74. Result.FOtherServersDisable := jo.B['otherServersDisable'];
  75. Result.FNewCenterServer := jo.B['newCenterServer'];
  76. Result.FSMSName := jo.S['smsName'];
  77. Result.FUserInfoCheck := jo.B['userInfoCheck'];
  78. Result.FGradeSystem := jo.B['grade'];
  79. Result.FFirstLoginConfirm := jo.B['firstLoginConfirm'];
  80. Result.FDev := jo.B['dev'];
  81. Result.FRemoteUI := jo.B['remoteUI'];
  82. Result.FRemoteUIHost := jo.S['remoteUIHost'];
  83. Result.FMapHost := jo.S['mapHost'];
  84. except
  85. on E: Exception do
  86. begin
  87. Error(E.Message, 'TConditionConfig.Load');
  88. end;
  89. end;
  90. end;
  91. initialization
  92. finalization
  93. if config <> nil then
  94. FreeAndNil(config);
  95. end.