1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59:
| public Surface : array of array of string; info: array[0..8] of string;
.... ....
procedure TFMainWindow.Load(ssource : string); var SavedMap : TInifile; ix, iy, sizex, sizey, loaderror : integer; smap : string;
begin loaderror:=0; SetLength(surface,0,0); SavedMap:=TInifile.create(ssource);
info[0]:=SavedMap.readstring('Map File','ProgramVersion','-1'); info[1]:=SavedMap.readstring('Map File','EditorVersion','-1'); info[2]:=SavedMap.readstring('Map File','Name','Unbenanntes Szenario'); info[3]:=SavedMap.readstring('Map File','ident','0'); info[4]:=SavedMap.readstring('Map File','Description','-'); info[5]:=SavedMap.readstring('Map File','Size','1x1'); info[6]:=SavedMap.readstring('Map File','tileset','Standard'); info[7]:=SavedMap.readstring('Map File','BGM','Standard'); info[8]:=SavedMap.readstring('Map File','BGG','Standard');
sizex:=StrToInt(copy(info[5],1,pos('x',info[5])-1)); sizey:=StrToInt(copy(info[5],pos('x',info[5])+1,length(info[5]))); SetLength(surface,sizex,sizey);
for iy:=0 to sizeY-1 do begin Application.processmessages; loadbar.position:=round(iy / (sizey-1)*100);
smap:=SavedMap.readstring('Surface',IntToStr(iy),'0'); memo1.lines.add('Line '+IntToStr(iy)+' : '+smap); for ix:=0 to sizeX-1 do begin if ix<=length(smap) then begin try Surface[ix,iy]:=smap[ix]; except loaderror:=loaderror+1; end; end else begin loaderror:=loaderror+1; Surface[ix,iy]:='0'; end; end; end; SavedMap.free; if loaderror>0 then MessageDlg('Beim Laden der Karte sind '+IntToStr(loaderror)+' Fehler aufgetreten!',mtError,[mbok],0); end; |