userpreferences.pas 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. unit userpreferences;
  2. {
  3. $Id: userpreferences.pas,v 1.1 2004/09/30 22:35:47 savage Exp $
  4. }
  5. {******************************************************************************}
  6. { }
  7. { JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
  8. { Base Class for User Preferences }
  9. { }
  10. { The initial developer of this Pascal code was : }
  11. { Dominqiue Louis <[email protected]> }
  12. { }
  13. { Portions created by Dominqiue Louis are }
  14. { Copyright (C) 2000 - 2001 Dominqiue Louis. }
  15. { }
  16. { }
  17. { Contributor(s) }
  18. { -------------- }
  19. { }
  20. { }
  21. { Obtained through: }
  22. { Joint Endeavour of Delphi Innovators ( Project JEDI ) }
  23. { }
  24. { You may retrieve the latest version of this file at the Project }
  25. { JEDI home page, located at http://delphi-jedi.org }
  26. { }
  27. { The contents of this file are used with permission, subject to }
  28. { the Mozilla Public License Version 1.1 (the "License"); you may }
  29. { not use this file except in compliance with the License. You may }
  30. { obtain a copy of the License at }
  31. { http://www.mozilla.org/MPL/MPL-1.1.html }
  32. { }
  33. { Software distributed under the License is distributed on an }
  34. { "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
  35. { implied. See the License for the specific language governing }
  36. { rights and limitations under the License. }
  37. { }
  38. { Description }
  39. { ----------- }
  40. { }
  41. { }
  42. { }
  43. { }
  44. { }
  45. { }
  46. { }
  47. { Requires }
  48. { -------- }
  49. { The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
  50. { They are available from... }
  51. { http://www.libsdl.org . }
  52. { }
  53. { Programming Notes }
  54. { ----------------- }
  55. { }
  56. { }
  57. { }
  58. { }
  59. { Revision History }
  60. { ---------------- }
  61. { September 23 2004 - DL : Initial Creation }
  62. {
  63. $Log: userpreferences.pas,v $
  64. Revision 1.1 2004/09/30 22:35:47 savage
  65. Changes, enhancements and additions as required to get SoAoS working.
  66. }
  67. {******************************************************************************}
  68. interface
  69. uses
  70. Classes;
  71. type
  72. TUserPreferences = class
  73. private
  74. FAutoSave: Boolean;
  75. procedure CheckAutoSave;
  76. protected
  77. function GetDefaultBoolean( const Index : Integer ) : Boolean; virtual; abstract;
  78. function GetBoolean( const Index : Integer ) : Boolean; virtual; abstract;
  79. procedure SetBoolean( const Index : Integer; const Value : Boolean ); virtual;
  80. function GetDefaultDateTime( const Index : Integer ) : TDateTime; virtual; abstract;
  81. function GetDateTime( const Index : Integer ) : TDateTime; virtual; abstract;
  82. procedure SetDateTime( const Index : Integer; const Value : TDateTime ); virtual;
  83. function GetDefaultInteger( const Index : Integer ) : Integer; virtual; abstract;
  84. function GetInteger( const Index : Integer ) : Integer; virtual; abstract;
  85. procedure SetInteger( const Index : Integer; const Value : Integer ); virtual;
  86. function GetDefaultFloat( const Index : Integer ) : single; virtual; abstract;
  87. function GetFloat( const Index : Integer ) : single; virtual; abstract;
  88. procedure SetFloat( const Index : Integer; const Value : single ); virtual;
  89. function GetDefaultString( const Index : Integer ) : string; virtual; abstract;
  90. function GetString( const Index : Integer ) : string; virtual; abstract;
  91. procedure SetString( const Index : Integer; const Value : string ); virtual;
  92. function GetDefaultBinaryStream( const Index : Integer ) : TStream; virtual; abstract;
  93. function GetBinaryStream( const Index : Integer ) : TStream; virtual; abstract;
  94. procedure SetBinaryStream( const Index : Integer; const Value : TStream ); virtual;
  95. public
  96. procedure Update; virtual; abstract;
  97. constructor Create; virtual;
  98. destructor Destroy; override;
  99. property AutoSave : Boolean read FAutoSave write FAutoSave;
  100. end;
  101. implementation
  102. { TUserPreferences }
  103. procedure TUserPreferences.CheckAutoSave;
  104. begin
  105. if FAutoSave then
  106. Update;
  107. end;
  108. constructor TUserPreferences.Create;
  109. begin
  110. inherited;
  111. FAutoSave := false;
  112. end;
  113. destructor TUserPreferences.Destroy;
  114. begin
  115. inherited;
  116. end;
  117. procedure TUserPreferences.SetBinaryStream( const Index : Integer; const Value : TStream );
  118. begin
  119. CheckAutoSave;
  120. end;
  121. procedure TUserPreferences.SetBoolean(const Index: Integer; const Value: Boolean);
  122. begin
  123. CheckAutoSave;
  124. end;
  125. procedure TUserPreferences.SetDateTime(const Index: Integer; const Value: TDateTime);
  126. begin
  127. CheckAutoSave;
  128. end;
  129. procedure TUserPreferences.SetFloat(const Index: Integer; const Value: single);
  130. begin
  131. CheckAutoSave;
  132. end;
  133. procedure TUserPreferences.SetInteger(const Index, Value: Integer);
  134. begin
  135. CheckAutoSave;
  136. end;
  137. procedure TUserPreferences.SetString(const Index: Integer; const Value: string);
  138. begin
  139. CheckAutoSave;
  140. end;
  141. end.