unit ConditionConfig; interface uses Classes, SysUtils, superobject; type TConditionConfig = class private FFaceSize: Int64; FUserInfoController: Boolean; FSMSName: string; FOtherServersDisable: Boolean; FNewCenterServer: Boolean; FUserInfoCheck: Boolean; FGradeSystem: Boolean; FFirstLoginConfirm: Boolean; FDev: Boolean; FRemoteUIHost: string; FRemoteUI: Boolean; FMapHost: string; public constructor Create; class function Load: TConditionConfig; class function GetConfig: TConditionConfig; property FaceSize: Int64 read FFaceSize; property UserInfoController: Boolean read FUserInfoController; property OtherServersDisable: Boolean read FOtherServersDisable; property NewCenterServer: Boolean read FNewCenterServer; property UserInfoCheck: Boolean read FUserInfoCheck; property SMSName: string read FSMSName; property GradeSystem: Boolean read FGradeSystem; property FirstLoginConfirm: Boolean read FFirstLoginConfirm; property Dev: Boolean read FDev; property RemoteUI: Boolean read FRemoteUI; property RemoteUIHost: string read FRemoteUIHost; property MapHost: string read FMapHost; end; TCustomerConfig = class private FData: ISuperObject; FShowGuideViewBtn: Boolean; function GetShowGuideView: Boolean; procedure SetShowGuideView(const Value: Boolean); procedure Save; procedure SetShowGuideViewBtn(const Value: Boolean); function GetShowGuideViewBtn: Boolean; public constructor Create; class function GetConfig: TCustomerConfig; static; property ShowGuideView: Boolean read GetShowGuideView write SetShowGuideView; property ShowGuideViewBtn: Boolean read GetShowGuideViewBtn write SetShowGuideViewBtn; end; implementation uses Dialogs, TypInfo, Winsock2, LoggerImport; const CONDITION_CONFIG: string = 'Config\condition.config'; CUSTOMER_CONFIG: string = 'Config\customer.config'; var config: TConditionConfig; customerConfig: TCustomerConfig; constructor TConditionConfig.Create; begin FFaceSize := 20; //µ¥Î»M end; class function TConditionConfig.GetConfig: TConditionConfig; begin if config <> nil then Result := config else Result := TConditionConfig.Load; end; class function TConditionConfig.Load: TConditionConfig; var AFullFileName: string; jo, AServer: ISuperObject; AGroupServerAddresses: TSuperArray; iLoop: Integer; begin if config <> nil then FreeAndNil(config); config := TConditionConfig.Create; Result := config; AFullFileName := ExtractFilePath(ParamStr(0)) + CONDITION_CONFIG; if not FileExists(AFullFileName) then Exit; try jo := TSuperObject.ParseFile(AFullFileName, False); if jo.O['faceSize'] <> nil then Result.FFaceSize := jo['faceSize'].AsInteger; Result.FUserInfoController := jo.B['userInfoController']; Result.FOtherServersDisable := jo.B['otherServersDisable']; Result.FNewCenterServer := jo.B['newCenterServer']; Result.FSMSName := jo.S['smsName']; Result.FUserInfoCheck := jo.B['userInfoCheck']; Result.FGradeSystem := jo.B['grade']; Result.FFirstLoginConfirm := jo.B['firstLoginConfirm']; Result.FDev := jo.B['dev']; Result.FRemoteUI := jo.B['remoteUI']; Result.FRemoteUIHost := jo.S['remoteUIHost']; Result.FMapHost := jo.S['mapHost']; except on E: Exception do begin Error(E.Message, 'TConditionConfig.Load'); end; end; end; { TCustomerConfig } constructor TCustomerConfig.Create; var AFullFileName: string; begin AFullFileName := ExtractFilePath(ParamStr(0)) + CUSTOMER_CONFIG; if not FileExists(AFullFileName) then FData := SO() else FData := TSuperObject.ParseFile(AFullFileName, False); inherited Create; end; class function TCustomerConfig.GetConfig: TCustomerConfig; begin if customerConfig <> nil then Result := customerConfig else Result := TCustomerConfig.Create; end; function TCustomerConfig.GetShowGuideView: Boolean; begin Result := FData.B['showGuideView']; end; function TCustomerConfig.GetShowGuideViewBtn: Boolean; begin Result := FData.B['showGuideViewBtn']; end; procedure TCustomerConfig.Save; var AFullFileName: string; begin AFullFileName := ExtractFilePath(ParamStr(0)) + CUSTOMER_CONFIG; FData.SaveTo(AFullFileName); end; procedure TCustomerConfig.SetShowGuideView(const Value: Boolean); begin if FData.B['showGuideView'] = Value then Exit; FData.B['showGuideView'] := Value; Save; end; procedure TCustomerConfig.SetShowGuideViewBtn(const Value: Boolean); begin FShowGuideViewBtn := Value; end; initialization finalization if config <> nil then FreeAndNil(config); if customerConfig <> nil then FreeAndNil(customerConfig); end.