Rev 53 | Rev 65 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 53 | Rev 61 | ||
---|---|---|---|
Line 69... | Line 69... | ||
69 | procedure SaveToStrings(sl: TStrings); |
69 | procedure SaveToStrings(sl: TStrings); |
70 | procedure SaveToFile(filename: string); |
70 | procedure SaveToFile(filename: string); |
71 | destructor Destroy; override; |
71 | destructor Destroy; override; |
72 | end; |
72 | end; |
73 | 73 | ||
- | 74 | TLevelFile = record |
|
- | 75 | levelNumber: integer; |
|
- | 76 | fileLocation: string; |
|
- | 77 | isUser: boolean; |
|
- | 78 | found: boolean; |
|
- | 79 | end; |
|
- | 80 | ||
74 | function GetLevelFileName(lev: integer; forceuserdir: boolean): string; |
81 | function GetLevelFileName(lev: integer; forceuserdir: boolean): TLevelFile; |
75 | 82 | ||
76 | implementation |
83 | implementation |
77 | 84 | ||
78 | uses |
85 | uses |
79 | SysUtils, StrUtils, Global, Windows, System.Types; |
86 | SysUtils, StrUtils, Global, Windows, System.Types; |
Line 81... | Line 88... | ||
81 | const |
88 | const |
82 | // { iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 37476 products(2) spacemission(8) file-format(1) lev-sav-v12(1) } |
89 | // { iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 37476 products(2) spacemission(8) file-format(1) lev-sav-v12(1) } |
83 | // https://hosted.oidplus.com/viathinksoft/?goto=oid%3A1.3.6.1.4.1.37476.2.8.1.1 |
90 | // https://hosted.oidplus.com/viathinksoft/?goto=oid%3A1.3.6.1.4.1.37476.2.8.1.1 |
84 | OID_LEVSAV_VER12 = '1.3.6.1.4.1.37476.2.8.1.1'; |
91 | OID_LEVSAV_VER12 = '1.3.6.1.4.1.37476.2.8.1.1'; |
85 | 92 | ||
86 | function GetLevelFileName(lev: integer; forceuserdir: boolean): string; |
93 | function GetLevelFileName(lev: integer; forceuserdir: boolean): TLevelFile; |
87 | 94 | ||
88 | function _GetLevelVerzeichnisSystem: string; |
95 | function _GetLevelVerzeichnisSystem: string; |
89 | begin |
96 | begin |
90 | // Für die Auslieferungs-Levels |
97 | // Für die Auslieferungs-Levels |
91 | result := OwnDirectory + 'Levels'; |
98 | result := OwnDirectory + 'Levels'; |
Line 134... | Line 141... | ||
134 | exit(new); |
141 | exit(new); |
135 | end; |
142 | end; |
136 | 143 | ||
137 | var |
144 | var |
138 | usr, sys: string; |
145 | usr, sys: string; |
- | 146 | bfound: boolean; |
|
139 | begin |
147 | begin |
- | 148 | result.levelNumber := lev; |
|
140 | usr := _GetLevelFileNameUser(lev); |
149 | usr := _GetLevelFileNameUser(lev); |
141 | sys := _GetLevelFileNameSystem(lev); |
150 | sys := _GetLevelFileNameSystem(lev); |
- | 151 | bfound := fileexists(usr); |
|
142 | if fileexists(usr) or forceuserdir then exit(usr); |
152 | if bfound or forceuserdir then |
- | 153 | begin |
|
- | 154 | result.isUser := true; |
|
- | 155 | result.fileLocation := usr; |
|
- | 156 | result.found := bfound; |
|
- | 157 | exit; |
|
- | 158 | end; |
|
143 | if fileexists(sys) then exit(sys); |
159 | bfound := fileexists(sys); |
- | 160 | if bfound then |
|
- | 161 | begin |
|
- | 162 | result.isUser := false; |
|
- | 163 | result.fileLocation := sys; |
|
- | 164 | result.found := bfound; |
|
144 | exit(usr); |
165 | exit; |
- | 166 | end; |
|
- | 167 | result.isUser := true; |
|
- | 168 | result.fileLocation := usr; |
|
- | 169 | result.found := false; |
|
145 | end; |
170 | end; |
146 | 171 | ||
147 | // this is just an example, there are many |
172 | // this is just an example, there are many |
148 | // different ways you can implement this |
173 | // different ways you can implement this |
149 | // more efficiently, ie using a TStringBuilder, |
174 | // more efficiently, ie using a TStringBuilder, |