Changeset 20 for trunk/Start.pas
- Timestamp:
- Jan 8, 2017, 12:23:55 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Start.pas
r17 r20 194 194 195 195 if FirstStart then 196 begin196 with Reg do begin 197 197 // initialize AI assignment 198 Reg.OpenKey('SOFTWARE\cevo\RegVer9\Start', true);199 for i:= 0 to nPlOffered - 1 do198 OpenKey('SOFTWARE\cevo\RegVer9\Start', true); 199 for I := 0 to nPlOffered - 1 do 200 200 begin 201 201 if i = 0 then … … 203 203 else 204 204 s := 'StdAI'; 205 Reg.WriteString('Control' + IntToStr(i), s);206 Reg.WriteInteger('Diff' + IntToStr(i), 2);205 WriteString('Control' + IntToStr(i), s); 206 WriteInteger('Diff' + IntToStr(i), 2); 207 207 end; 208 Reg.WriteInteger('MultiControl', 0); 209 Reg.closekey; 210 end 211 else 212 begin 213 Reg.OpenKey('SOFTWARE\cevo\RegVer9\Start', false); 214 try 215 WorldSize := Reg.ReadInteger('WorldSize'); 216 StartLandMass := Reg.ReadInteger('LandMass'); 217 MaxTurn := Reg.ReadInteger('MaxTurn'); 218 DefaultAI := Reg.ReadString('DefaultAI'); 219 AutoEnemies := Reg.ReadInteger('AutoEnemies'); 220 AutoDiff := Reg.ReadInteger('AutoDiff'); 221 except 222 FirstStart := true; 223 end; 224 Reg.closekey; 208 WriteInteger('MultiControl', 0); 209 CloseKey; 210 end; 211 212 with Reg do begin 213 OpenKey('SOFTWARE\cevo\RegVer9\Start', False); 214 if ValueExists('WorldSize') then WorldSize := Reg.ReadInteger('WorldSize') 215 else WorldSize := DefaultWorldSize; 216 if ValueExists('LandMass') then StartLandMass := Reg.ReadInteger('LandMass') 217 else StartLandMass := DefaultLandMass; 218 if ValueExists('MaxTurn') then MaxTurn := Reg.ReadInteger('MaxTurn') 219 else MaxTurn := 800; 220 if ValueExists('DefaultAI') then DefaultAI := Reg.ReadString('DefaultAI') 221 else DefaultAI := 'StdAI'; 222 if ValueExists('AutoEnemies') then AutoEnemies := Reg.ReadInteger('AutoEnemies') 223 else AutoEnemies := 8; 224 if ValueExists('AutoDiff') then AutoDiff := Reg.ReadInteger('AutoDiff') 225 else AutoDiff := 1; 226 CloseKey; 225 227 end; 226 228 227 229 FullScreen := true; 228 if FirstStart then 229 begin 230 WorldSize := DefaultWorldSize; 231 StartLandMass := DefaultLandMass; 232 MaxTurn := 800; 233 DefaultAI := 'StdAI'; 234 AutoEnemies := 8; 235 AutoDiff := 1; 236 end 237 else 238 begin 239 Reg.OpenKey('SOFTWARE\cevo\RegVer9', false); 240 if Reg.ValueExists('ScreenMode') then 241 ScreenMode := Reg.ReadInteger('ScreenMode'); 230 with Reg do begin 231 OpenKey('SOFTWARE\cevo\RegVer9', False); 232 if ValueExists('ScreenMode') then 233 ScreenMode := ReadInteger('ScreenMode') 234 else ScreenMode := 1; 242 235 FullScreen := ScreenMode > 0; 243 if Reg.ValueExists('ResolutionX') then244 ResolutionX := Re g.ReadInteger('ResolutionX');245 if Reg.ValueExists('ResolutionY') then246 ResolutionY := Re g.ReadInteger('ResolutionY');247 if Reg.ValueExists('ResolutionBPP') then248 ResolutionBPP := Re g.ReadInteger('ResolutionBPP');249 if Reg.ValueExists('ResolutionFreq') then250 ResolutionFreq := Re g.ReadInteger('ResolutionFreq');236 if ValueExists('ResolutionX') then 237 ResolutionX := ReadInteger('ResolutionX'); 238 if ValueExists('ResolutionY') then 239 ResolutionY := ReadInteger('ResolutionY'); 240 if ValueExists('ResolutionBPP') then 241 ResolutionBPP := ReadInteger('ResolutionBPP'); 242 if ValueExists('ResolutionFreq') then 243 ResolutionFreq := ReadInteger('ResolutionFreq'); 251 244 {$IFDEF WINDOWS} 252 245 if ScreenMode = 2 then … … 254 247 ResolutionFreq); 255 248 {$ENDIF} 256 Reg.closekey;249 CloseKey; 257 250 end; 258 251 Reg.Free; … … 260 253 ActionsOffered := [maManual, maCredits, maWeb]; 261 254 if FileExists(HomeDir + 'Configurator.exe') then 262 include(ActionsOffered, maConfig);263 if FileExists(HomeDir + 'AI Template \AI development manual.html') then264 include(ActionsOffered, maAIDev);255 Include(ActionsOffered, maConfig); 256 if FileExists(HomeDir + 'AI Template' + DirectorySeparator + 'AI development manual.html') then 257 Include(ActionsOffered, maAIDev); 265 258 266 259 bixDefault := -1; … … 887 880 begin // load 888 881 FileName := List.Items[List.ItemIndex]; 889 if LoadGame(DataDir + 'Saved \', FileName + '.cevo', LoadTurn, false)882 if LoadGame(DataDir + 'Saved' + DirectorySeparator, FileName + '.cevo', LoadTurn, false) 890 883 then 891 884 UnlistBackupFile(FileName) … … 907 900 Reg := TRegistry.Create; 908 901 Reg.OpenKey('SOFTWARE\cevo\RegVer9\Start', true); 909 try 910 GameCount := Reg.ReadInteger('GameCount'); 911 except 912 GameCount := 0; 913 end; 902 if Reg.ValueExists('GameCount') then GameCount := Reg.ReadInteger('GameCount') 903 else GameCount := 0; 914 904 915 905 if (AutoDiff < 0) and (bixView[0] = bixNoTerm) then … … 983 973 Reg.Free; 984 974 985 StartNewGame(DataDir + 'Saved \', FileName + '.cevo', MapFileName,975 StartNewGame(DataDir + 'Saved' + DirectorySeparator, FileName + '.cevo', MapFileName, 986 976 lxpre[WorldSize], lypre[WorldSize], StartLandMass, MaxTurn); 987 977 UnlistBackupFile(FileName); … … 1125 1115 pgLoad: 1126 1116 begin 1127 AssignFile(LogFile, DataDir + 'Saved \'+ List.Items[List.ItemIndex]1117 AssignFile(LogFile, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex] 1128 1118 + '.cevo'); 1129 1119 try … … 1180 1170 if Page = pgEditMap then 1181 1171 MapFileName := List.Items[List.ItemIndex] + '.cevo map'; 1182 if LoadGraphicFile(Mini, DataDir + 'Maps \'+ Copy(MapFileName, 1,1172 if LoadGraphicFile(Mini, DataDir + 'Maps' + DirectorySeparator + Copy(MapFileName, 1, 1183 1173 Length(MapFileName) - 9), gfNoError) then 1184 1174 begin … … 1197 1187 end; 1198 1188 1199 AssignFile(MapFile, DataDir + 'Maps \'+ MapFileName);1189 AssignFile(MapFile, DataDir + 'Maps' + DirectorySeparator + MapFileName); 1200 1190 try 1201 1191 Reset(MapFile, 4); … … 1372 1362 begin 1373 1363 FormerGames.Clear; 1374 if FindFirst(DataDir + 'Saved \*.cevo', $21, f) = 0 then1364 if FindFirst(DataDir + 'Saved' + DirectorySeparator + '*.cevo', $21, f) = 0 then 1375 1365 repeat 1376 1366 i := FormerGames.Count; … … 1391 1381 begin 1392 1382 Maps.Clear; 1393 if FindFirst(DataDir + 'Maps \*.cevo map', $21, f) = 0 then1383 if FindFirst(DataDir + 'Maps' + DirectorySeparator + '*.cevo map', $21, f) = 0 then 1394 1384 repeat 1395 1385 Maps.Add(Copy(f.Name, 1, Length(f.Name) - 9)); … … 1589 1579 DirectHelp(cStartCredits); 1590 1580 maAIDev: 1591 OpenDocument(pchar(HomeDir + 'AI Template \AI development manual.html'));{ *Převedeno z ShellExecute* }1581 OpenDocument(pchar(HomeDir + 'AI Template' + DirectorySeparator + 'AI development manual.html'));{ *Převedeno z ShellExecute* } 1592 1582 maWeb: 1593 1583 OpenURL('http://c-evo.org'){ *Převedeno z ShellExecute* } … … 1756 1746 end; 1757 1747 if Page = pgLoad then 1758 AssignFile(f, DataDir + 'Saved \'+ List.Items[List.ItemIndex] + '.cevo')1748 AssignFile(f, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex] + '.cevo') 1759 1749 else 1760 AssignFile(f, DataDir + 'Maps \'+ List.Items[List.ItemIndex] +1750 AssignFile(f, DataDir + 'Maps'+ DirectorySeparator + List.Items[List.ItemIndex] + 1761 1751 '.cevo map'); 1762 1752 ok := true; 1763 1753 try 1764 1754 if Page = pgLoad then 1765 Rename(f, DataDir + 'Saved \'+ NewName + '.cevo')1755 Rename(f, DataDir + 'Saved'+ DirectorySeparator + NewName + '.cevo') 1766 1756 else 1767 Rename(f, DataDir + 'Maps \'+ NewName + '.cevo map');1757 Rename(f, DataDir + 'Maps'+ DirectorySeparator + NewName + '.cevo map'); 1768 1758 except 1769 1759 // Play('INVALID'); … … 1772 1762 if Page <> pgLoad then 1773 1763 try // rename map picture 1774 AssignFile(f, DataDir + 'Maps \'+ List.Items[List.ItemIndex]1764 AssignFile(f, DataDir + 'Maps'+ DirectorySeparator + List.Items[List.ItemIndex] 1775 1765 + '.bmp'); 1776 Rename(f, DataDir + 'Maps \'+ NewName + '.bmp');1766 Rename(f, DataDir + 'Maps'+ DirectorySeparator + NewName + '.bmp'); 1777 1767 except 1778 1768 end; … … 1808 1798 begin 1809 1799 if Page = pgLoad then 1810 AssignFile(f, DataDir + 'Saved \'+ List.Items[List.ItemIndex] + '.cevo')1800 AssignFile(f, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex] + '.cevo') 1811 1801 else 1812 AssignFile(f, DataDir + 'Maps \'+ List.Items[List.ItemIndex] +1802 AssignFile(f, DataDir + 'Maps' + DirectorySeparator + List.Items[List.ItemIndex] + 1813 1803 '.cevo map'); 1814 1804 Erase(f); … … 2002 1992 procedure TStartDlg.ReplayBtnClick(Sender: TObject); 2003 1993 begin 2004 LoadGame(DataDir + 'Saved \', List.Items[List.ItemIndex] + '.cevo',1994 LoadGame(DataDir + 'Saved' + DirectorySeparator, List.Items[List.ItemIndex] + '.cevo', 2005 1995 LastTurn, true); 2006 1996 SlotAvailable := -1;
Note:
See TracChangeset
for help on using the changeset viewer.