Changeset 89 for trunk/Game.pas
- Timestamp:
- Jun 7, 2024, 4:35:46 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Game.pas
r86 r89 11 11 TMoveDirection = (drNone, drLeft, drUp, drRight, drDown); 12 12 TTileAction = (taNone, taMove, taMerge, taAppear); 13 TColorPalette = (cpOrangeYellow, cpGreenYellow, cpPinkBlue, cpBlueCyan, 14 cpGreenCyan, cpPinkRed); 13 15 14 16 { TTile } … … 109 111 FCanUndo: Boolean; 110 112 FBoardUndo: TBoard; 113 FColorPalette: TColorPalette; 111 114 FSkin: TTileSkin; 112 115 function GetTileColor(Value: Integer): TColor; … … 117 120 procedure RenderTile(Canvas: TCanvas; Tile: TTile; TileRect: TRect; WithText: Boolean); 118 121 procedure GameOver; 122 procedure SetColorPalette(AValue: TColorPalette); 119 123 procedure SetSkin(AValue: TTileSkin); 120 124 procedure Win; … … 162 166 property RecordHistory: Boolean read FRecordHistory write SetRecordHistory; 163 167 property Skin: TTileSkin read FSkin write SetSkin; 168 property ColorPalette: TColorPalette read FColorPalette write SetColorPalette; 164 169 end; 165 170 … … 169 174 var 170 175 SkinText: array[TTileSkin] of string; 176 ColorPaletteText: array[TColorPalette] of string; 171 177 172 178 const … … 187 193 STileShouldBeEmpty = 'Tile should be empty'; 188 194 195 // Color palette 196 SOrangeYellow = 'Orange - yellow'; 197 SGreenYellow = 'Green - yellow'; 198 SPinkBlue = 'Pink - blue'; 199 SBlueCyan = 'Blue - cyan'; 200 SGreenCyan = 'Green - cyan'; 201 SPinkRed = 'Pink - red'; 189 202 190 203 procedure Translate; … … 194 207 195 208 uses 196 Core, MetaCanvas ;209 Core, MetaCanvas, PixelPointer; 197 210 198 211 procedure Translate; … … 203 216 SkinText[tsRoman] := SSkinRoman; 204 217 SkinText[tsBinary] := SSkinBinary; 218 219 ColorPaletteText[cpOrangeYellow] := SOrangeYellow; 220 ColorPaletteText[cpGreenYellow] := SGreenYellow; 221 ColorPaletteText[cpPinkBlue] := SPinkBlue; 222 ColorPaletteText[cpBlueCyan] := SBlueCyan; 223 ColorPaletteText[cpGreenCyan] := SGreenCyan; 224 ColorPaletteText[cpPinkRed] := SPinkRed; 205 225 end; 206 226 … … 267 287 GameStep.Board.Clear; 268 288 GameStep.Skin := Game.Skin; 289 GameStep.ColorPalette := Game.ColorPalette; 269 290 GameStep.Score := 0; 270 291 for I := 0 to Length(InitialTiles) - 1 do … … 293 314 begin 294 315 FreeAndNil(Moves); 295 inherited Destroy;316 inherited; 296 317 end; 297 318 … … 442 463 begin 443 464 Size := Point(0, 0); 444 inherited Destroy;465 inherited; 445 466 end; 446 467 … … 519 540 if Running and Assigned(FOnGameOver) then FOnGameOver(Self); 520 541 Running := False; 542 end; 543 544 procedure TGame.SetColorPalette(AValue: TColorPalette); 545 begin 546 if FColorPalette = AValue then Exit; 547 FColorPalette := AValue; 548 DoPaint; 521 549 end; 522 550 … … 579 607 FRunning := Source.FRunning; 580 608 Skin := Source.Skin; 609 ColorPalette := Source.ColorPalette; 581 610 end; 582 611 … … 1174 1203 WriteBool('RecordHistory', RecordHistory); 1175 1204 WriteInteger('Skin', Integer(Skin)); 1205 WriteInteger('ColorPalette', Integer(ColorPalette)); 1176 1206 FBoardUndo.SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\BoardUndo')); 1177 1207 Board.SaveToRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\Board')); … … 1198 1228 RecordHistory := ReadBoolWithDefault('RecordHistory', False); 1199 1229 Skin := TTileSkin(ReadIntegerWithDefault('Skin', Integer(tsPowerOfTwo))); 1230 ColorPalette := TColorPalette(ReadIntegerWithDefault('ColorPalette', Integer(cpOrangeYellow))); 1200 1231 FBoardUndo.LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\BoardUndo')); 1201 1232 Board.LoadFromRegistry(Reg, TRegistryContext.Create(RegContext.RootKey, RegContext.Key + '\Board')); … … 1229 1260 1230 1261 function TGame.GetTileColor(Value: Integer): TColor; 1262 var 1263 Color: TPixel32; 1231 1264 begin 1232 1265 if Core.Core.ThemeManager1.Theme.Name = 'Dark' then begin … … 1263 1296 end; 1264 1297 end; 1298 1299 Color.RGB := Result; 1300 case ColorPalette of 1301 cpOrangeYellow: Result := TColor(TPixel32.CreateRGB(Color.R, Color.G, Color.B)); 1302 cpGreenYellow: Result := TColor(TPixel32.CreateRGB(Color.R, Color.B, Color.G)); 1303 cpPinkBlue: Result := TColor(TPixel32.CreateRGB(Color.B, Color.R, Color.G)); 1304 cpBlueCyan: Result := TColor(TPixel32.CreateRGB(Color.B, Color.G, Color.R)); 1305 cpGreenCyan: Result := TColor(TPixel32.CreateRGB(Color.G, Color.B, Color.R)); 1306 cpPinkRed: Result := TColor(TPixel32.CreateRGB(Color.G, Color.R, Color.B)); 1307 end; 1265 1308 end; 1266 1309
Note:
See TracChangeset
for help on using the changeset viewer.