Changeset 105 for trunk/Board.pas
- Timestamp:
- Dec 9, 2024, 4:40:34 PM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Board.pas
r104 r105 69 69 for Y := 0 to Size.Y - 1 do 70 70 for X := 0 to Size.X - 1 do 71 if Tiles[Y, X].Value = 0then71 if (Tiles[Y, X].Value = 0) and not Tiles[Y, X].Disabled then 72 72 EmptyTiles.Add(Tiles[Y, X]); 73 73 end; … … 76 76 var 77 77 X, Y: Integer; 78 Value: string;79 78 begin 80 79 with Reg do begin … … 83 82 WriteInteger('SizeX', Size.X); 84 83 WriteInteger('SizeY', Size.Y); 85 Value := '';86 84 for Y := 0 to Size.Y - 1 do begin 87 85 for X := 0 to Size.X - 1 do begin 88 Value := Value + IntToStr(Tiles[Y, X].Value); 89 if X < Size.X - 1 then Value := Value + ','; 86 Tiles[Y, X].SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\Tile' + IntToStr(X) + 'x' + IntToStr(Y))); 90 87 end; 91 if Y < Size.Y - 1 then Value := Value + ';'92 88 end; 93 WriteString('TileValues', Value);94 89 end; 95 90 end; … … 98 93 var 99 94 X, Y: Integer; 100 Items: TStringList;101 Lines: TStringList;102 Number: Integer;103 95 begin 104 96 with Reg do begin 105 97 CurrentContext := RegContext; 106 98 107 Size := Point(ReadIntegerWithDefault('SizeX', 4), ReadIntegerWithDefault('SizeY', 4)); 108 Items := TStringList.Create; 109 Items.Delimiter := ','; 110 Lines := TStringList.Create; 111 Lines.Delimiter := ';'; 112 Lines.DelimitedText := ReadStringWithDefault('TileValues', ''); 113 for Y := 0 to Lines.Count - 1 do begin 114 Items.DelimitedText := Lines[Y]; 115 for X := 0 to Items.Count - 1 do begin 116 if TryStrToInt(Items[X], Number) and (X < Size.X) and (Y < Size.Y) then 117 Tiles[Y, X].Value := Number; 99 Size := Point(ReadIntegerWithDefault('SizeX', 4), 100 ReadIntegerWithDefault('SizeY', 4)); 101 for Y := 0 to Size.Y - 1 do begin 102 for X := 0 to Size.X - 1 do begin 103 Tiles[Y, X].LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\Tile' + IntToStr(X) + 'x' + IntToStr(Y))); 118 104 end; 119 105 end; 120 Lines.Free;121 Items.Free;122 106 end; 123 107 end; … … 155 139 for Y := 0 to Size.Y - 1 do 156 140 for X := 0 to Size.X - 1 do 157 if Tiles[Y, X].Value = 0then141 if (Tiles[Y, X].Value = 0) and not Tiles[Y, X].Disabled then 158 142 Inc(Result); 159 143 end; … … 175 159 for Y := 0 to Size.Y - 1 do 176 160 for X := 0 to Size.X - 1 do 177 Tiles[Y, X]. Value := 0;161 Tiles[Y, X].Clear; 178 162 end; 179 163
Note:
See TracChangeset
for help on using the changeset viewer.