Changeset 69 for trunk/UGame.pas
- Timestamp:
- Feb 3, 2020, 12:24:17 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r68 r69 195 195 196 196 uses 197 UCore ;197 UCore, UMetaCanvas; 198 198 199 199 procedure Translate; … … 618 618 TileCenter: TPoint; 619 619 S: TPoint; 620 begin 620 MetaCanvas: TMetaCanvas; 621 begin 622 MetaCanvas := TMetaCanvas.Create; 623 621 624 TopBarHeight := ScaleY(24, 96); 622 Canvas.Brush.Style := bsSolid;623 Canvas.Brush.Color := Core.ThemeManager1.Theme.ColorControl;624 Canvas.FillRect(0, 0, Canvas.Width,Canvas.Height);625 MetaCanvas.Brush.Style := bsSolid; 626 MetaCanvas.Brush.Color := Core.ThemeManager1.Theme.ColorControl; 627 MetaCanvas.FillRect(0, 0, MetaCanvas.Width, MetaCanvas.Height); 625 628 626 629 ValueStr := SScore + ': ' + IntToStr(Score); 627 Canvas.Font.Color := Core.ThemeManager1.Theme.ColorControlText;628 Canvas.Font.Height := Trunc(TopBarHeight * 0.7);629 Canvas.TextOut(ScaleY(16, 96), (TopBarHeight -Canvas.TextHeight(ValueStr)) div 2, ValueStr);630 MetaCanvas.Font.Color := Core.ThemeManager1.Theme.ColorControlText; 631 MetaCanvas.Font.Height := Trunc(TopBarHeight * 0.7); 632 MetaCanvas.TextOut(ScaleY(16, 96), (TopBarHeight - MetaCanvas.TextHeight(ValueStr)) div 2, ValueStr); 630 633 631 634 ValueStr := STopScore + ': ' + IntToStr(TopScore); 632 Canvas.Font.Color := Core.ThemeManager1.Theme.ColorControlText;633 Canvas.Font.Height := Trunc(TopBarHeight * 0.7);634 Canvas.TextOut(ScaleY(136, 96), (TopBarHeight -Canvas.TextHeight(ValueStr)) div 2, ValueStr);635 MetaCanvas.Font.Color := Core.ThemeManager1.Theme.ColorControlText; 636 MetaCanvas.Font.Height := Trunc(TopBarHeight * 0.7); 637 MetaCanvas.TextOut(ScaleY(136, 96), (TopBarHeight - MetaCanvas.TextHeight(ValueStr)) div 2, ValueStr); 635 638 636 639 // Form.Canvas.Width and Form.Canvas.Height is not working correctly under Windows. … … 647 650 TileMargin := Round(Frame.Width / Board.Size.X * 0.03); 648 651 649 Canvas.Brush.Style := bsSolid;650 Canvas.Brush.Color := clGray;651 Canvas.Pen.Style := psClear;652 Canvas.RoundRect(Frame, ScaleX(Frame.Width div (20 * Board.Size.X), 96),652 MetaCanvas.Brush.Style := bsSolid; 653 MetaCanvas.Brush.Color := clGray; 654 MetaCanvas.Pen.Style := psClear; 655 MetaCanvas.RoundRect(Frame, ScaleX(Frame.Width div (20 * Board.Size.X), 96), 653 656 ScaleY(Frame.Height div (20 * Board.Size.Y), 96)); 654 657 … … 657 660 TileSize := Point(Frame.Width div Board.Size.X, Frame.Height div Board.Size.Y); 658 661 659 Canvas.Font.Color := clBlack;662 MetaCanvas.Font.Color := clBlack; 660 663 661 664 // Draw static tiles 662 665 for Y := 0 to Board.Size.Y - 1 do 663 666 for X := 0 to Board.Size.X - 1 do begin 664 if (Board.Tiles[Y, X].Action <> taNone) then Canvas.Brush.Color := GetTileColor(0)665 else Canvas.Brush.Color := GetTileColor(Board.Tiles[Y, X].Value);666 Canvas.Brush.Style := bsSolid;667 if (Board.Tiles[Y, X].Action <> taNone) then MetaCanvas.Brush.Color := GetTileColor(0) 668 else MetaCanvas.Brush.Color := GetTileColor(Board.Tiles[Y, X].Value); 669 MetaCanvas.Brush.Style := bsSolid; 667 670 TileRect := Bounds( 668 671 Frame.Left + X * TileSize.X + TileMargin, 669 672 Frame.Top + Y * TileSize.Y + TileMargin, 670 673 TileSize.X - 2 * TileMargin, TileSize.Y - 2 * TileMargin); 671 RenderTile( Canvas, Board.Tiles[Y, X], TileRect, Board.Tiles[Y, X].Action = taNone);674 RenderTile(MetaCanvas, Board.Tiles[Y, X], TileRect, Board.Tiles[Y, X].Action = taNone); 672 675 end; 673 676 … … 676 679 for X := 0 to Board.Size.X - 1 do 677 680 if Board.Tiles[Y, X].Action = taMove then begin 678 Canvas.Brush.Color := GetTileColor(Board.Tiles[Y, X].Value);679 Canvas.Brush.Style := bsSolid;681 MetaCanvas.Brush.Color := GetTileColor(Board.Tiles[Y, X].Value); 682 MetaCanvas.Brush.Style := bsSolid; 680 683 TileRect := Bounds( 681 684 Frame.Left + X * TileSize.X + Trunc(Board.Tiles[Y, X].Shift.X / 100 * TileSize.X + TileMargin), 682 685 Frame.Top + Y * TileSize.Y + Trunc(Board.Tiles[Y, X].Shift.Y / 100 * TileSize.Y + TileMargin), 683 686 TileSize.X - 2 * TileMargin, TileSize.Y - 2 * TileMargin); 684 RenderTile( Canvas, Board.Tiles[Y, X], TileRect, True);687 RenderTile(MetaCanvas, Board.Tiles[Y, X], TileRect, True); 685 688 end; 686 689 … … 689 692 for X := 0 to Board.Size.X - 1 do 690 693 if Board.Tiles[Y, X].Action = taAppear then begin 691 Canvas.Brush.Color := GetTileColor(Board.Tiles[Y, X].Value);692 Canvas.Brush.Style := bsSolid;694 MetaCanvas.Brush.Color := GetTileColor(Board.Tiles[Y, X].Value); 695 MetaCanvas.Brush.Style := bsSolid; 693 696 TileRect := Bounds( 694 697 Frame.Left + X * TileSize.X + TileMargin, … … 703 706 TileRect := Rect(TileCenter.X - S.X div 2, TileCenter.Y - S.Y div 2, 704 707 TileCenter.X + S.X div 2, TileCenter.Y + S.Y div 2); 705 RenderTile( Canvas, Board.Tiles[Y, X], TileRect, True);708 RenderTile(MetaCanvas, Board.Tiles[Y, X], TileRect, True); 706 709 end; 707 710 … … 710 713 for X := 0 to Board.Size.X - 1 do 711 714 if Board.Tiles[Y, X].Action = taMerge then begin 712 Canvas.Brush.Color := GetTileColor(Board.Tiles[Y, X].Value);713 Canvas.Brush.Style := bsSolid;715 MetaCanvas.Brush.Color := GetTileColor(Board.Tiles[Y, X].Value); 716 MetaCanvas.Brush.Style := bsSolid; 714 717 TileRect := Bounds( 715 718 Frame.Left + X * TileSize.X + TileMargin, … … 723 726 TileRect := Rect(TileRect.Left - S.X, TileRect.Top - S.Y, 724 727 TileRect.Right + S.X, TileRect.Bottom + S.Y); 725 RenderTile(Canvas, Board.Tiles[Y, X], TileRect, True); 726 end; 728 RenderTile(MetaCanvas, Board.Tiles[Y, X], TileRect, True); 729 end; 730 731 MetaCanvas.DrawTo(Canvas); 732 MetaCanvas.Free; 727 733 end; 728 734
Note:
See TracChangeset
for help on using the changeset viewer.