Changeset 178 for branches/highdpi/Packages/CevoComponents/ScreenTools.pas
- Timestamp:
- Jun 23, 2019, 3:15:29 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/CevoComponents/ScreenTools.pas
r173 r178 8 8 {$ENDIF} 9 9 StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, 10 Forms, Menus, GraphType ;10 Forms, Menus, GraphType, UDpiControls; 11 11 12 12 type 13 13 TTexture = record 14 Image: T Bitmap;14 Image: TDpiBitmap; 15 15 clBevelLight, clBevelShade, clTextLight, clTextShade, clLitText, clMark, 16 16 clPage, clCover: TColor; 17 17 end; 18 19 TColor32 = type cardinal; 20 TColor32Component = (ccBlue, ccGreen, ccRed, ccAlpha); 21 TPixel32 = packed record 22 case integer of 23 0: (B, G, R, A: byte); 24 1: (ARGB: TColor32); 25 2: (Planes: array[0..3] of byte); 26 3: (Components: array[TColor32Component] of byte); 27 end; 28 PPixel32 = ^TPixel32; 29 30 { TPixelPointer } 31 32 TPixelPointer = record 33 Base: PPixel32; 34 Pixel: PPixel32; 35 Line: PPixel32; 36 RelLine: PPixel32; 37 BytesPerPixel: integer; 38 BytesPerLine: integer; 39 procedure NextLine; inline; // Move pointer to start of new base line 40 procedure NextPixel; inline; // Move pointer to next pixel 41 procedure SetXY(X, Y: integer); inline; // Set pixel position relative to base 42 procedure SetX(X: integer); inline; // Set horizontal pixel position relative to base 43 procedure Init(Bitmap: TDpiRasterImage; BaseX: integer = 0; BaseY: integer = 0); inline; 44 end; 45 PPixelPointer = ^TPixelPointer; 18 46 19 47 {$IFDEF WINDOWS} … … 21 49 {$ENDIF} 22 50 procedure RestoreResolution; 51 function Play(Item: string; Index: integer = -1): boolean; 52 procedure PreparePlay(Item: string; Index: integer = -1); 23 53 procedure EmptyMenu(MenuItems: TMenuItem; Keep: Integer = 0); 24 54 function TurnToYear(Turn: integer): integer; 25 55 function TurnToString(Turn: integer): string; 26 56 function MovementToString(Movement: integer): string; 27 procedure BtnFrame(ca: T Canvas; p: TRect; const T: TTexture);28 procedure EditFrame(ca: T Canvas; p: TRect; const T: TTexture);57 procedure BtnFrame(ca: TDpiCanvas; p: TRect; const T: TTexture); 58 procedure EditFrame(ca: TDpiCanvas; p: TRect; const T: TTexture); 29 59 function HexStringToColor(S: string): integer; 30 function LoadGraphicFile(bmp: T Bitmap; Path: string; Options: integer = 0): boolean;60 function LoadGraphicFile(bmp: TDpiBitmap; Path: string; Options: integer = 0): boolean; 31 61 function LoadGraphicSet(const Name: string): integer; 32 procedure Dump(dst: T Bitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);33 procedure Sprite(Canvas: T Canvas; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);62 procedure Dump(dst: TDpiBitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer); 63 procedure Sprite(Canvas: TDpiCanvas; HGr, xDst, yDst, Width, Height, xGr, yGr: integer); 34 64 overload; 35 procedure Sprite(dst: T Bitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);65 procedure Sprite(dst: TDpiBitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer); 36 66 overload; 37 procedure MakeBlue(dst: T Bitmap; x, y, w, h: integer);38 procedure ImageOp_B(dst, Src: T Bitmap; xDst, yDst, xSrc, ySrc, w, h: integer);39 procedure ImageOp_BCC(dst, Src: T Bitmap;67 procedure MakeBlue(dst: TDpiBitmap; x, y, w, h: integer); 68 procedure ImageOp_B(dst, Src: TDpiBitmap; xDst, yDst, xSrc, ySrc, w, h: integer); 69 procedure ImageOp_BCC(dst, Src: TDpiBitmap; 40 70 xDst, yDst, xSrc, ySrc, w, h, Color1, Color2: integer); 41 procedure ImageOp_CCC(bmp: T Bitmap; x, y, w, h, Color0, Color1, Color2: integer);42 function BitBltCanvas(DestCanvas: T Canvas; X, Y, Width, Height: integer;43 SrcCanvas: T Canvas; XSrc, YSrc: integer; Rop: DWORD): boolean;44 procedure SLine(ca: T Canvas; x0, x1, y: integer; cl: TColor);45 procedure DLine(ca: T Canvas; x0, x1, y: integer; cl0, cl1: TColor);46 procedure Frame(ca: T Canvas; x0, y0, x1, y1: integer; cl0, cl1: TColor);47 procedure RFrame(ca: T Canvas; x0, y0, x1, y1: integer; cl0, cl1: TColor);48 procedure CFrame(ca: T Canvas; x0, y0, x1, y1, Corner: integer; cl: TColor);49 procedure FrameImage(ca: T Canvas; Src: TBitmap;71 procedure ImageOp_CCC(bmp: TDpiBitmap; x, y, w, h, Color0, Color1, Color2: integer); 72 function BitBltCanvas(DestCanvas: TDpiCanvas; X, Y, Width, Height: integer; 73 SrcCanvas: TDpiCanvas; XSrc, YSrc: integer; Rop: DWORD): boolean; 74 procedure SLine(ca: TDpiCanvas; x0, x1, y: integer; cl: TColor); 75 procedure DLine(ca: TDpiCanvas; x0, x1, y: integer; cl0, cl1: TColor); 76 procedure Frame(ca: TDpiCanvas; x0, y0, x1, y1: integer; cl0, cl1: TColor); 77 procedure RFrame(ca: TDpiCanvas; x0, y0, x1, y1: integer; cl0, cl1: TColor); 78 procedure CFrame(ca: TDpiCanvas; x0, y0, x1, y1, Corner: integer; cl: TColor); 79 procedure FrameImage(ca: TDpiCanvas; Src: TDpiBitmap; 50 80 x, y, Width, Height, xSrc, ySrc: integer; IsControl: boolean = False); 51 procedure GlowFrame(dst: T Bitmap; x0, y0, Width, Height: integer; cl: TColor);81 procedure GlowFrame(dst: TDpiBitmap; x0, y0, Width, Height: integer; cl: TColor); 52 82 procedure InitOrnament; 53 83 procedure InitCityMark(const T: TTexture); 54 procedure Fill(ca: T Canvas; Left, Top, Width, Height, xOffset, yOffset: integer);55 procedure FillLarge(ca: T Canvas; x0, y0, x1, y1, xm: integer);56 procedure FillSeamless(ca: T Canvas; Left, Top, Width, Height, xOffset, yOffset: integer;57 const Texture: T Bitmap);58 procedure FillRectSeamless(ca: T Canvas; x0, y0, x1, y1, xOffset, yOffset: integer;59 const Texture: T Bitmap);60 procedure PaintBackground(Form: T Form; Left, Top, Width, Height: integer);61 procedure Corner(ca: T Canvas; x, y, Kind: integer; const T: TTexture);62 procedure BiColorTextOut(ca: T Canvas; clMain, clBack: TColor; x, y: integer; s: string);63 procedure LoweredTextOut(ca: T Canvas; cl: TColor; const T: TTexture;84 procedure Fill(ca: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: integer); 85 procedure FillLarge(ca: TDpiCanvas; x0, y0, x1, y1, xm: integer); 86 procedure FillSeamless(ca: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: integer; 87 const Texture: TDpiBitmap); 88 procedure FillRectSeamless(ca: TDpiCanvas; x0, y0, x1, y1, xOffset, yOffset: integer; 89 const Texture: TDpiBitmap); 90 procedure PaintBackground(Form: TDpiForm; Left, Top, Width, Height: Integer); 91 procedure Corner(ca: TDpiCanvas; x, y, Kind: integer; const T: TTexture); 92 procedure BiColorTextOut(ca: TDpiCanvas; clMain, clBack: TColor; x, y: integer; s: string); 93 procedure LoweredTextOut(ca: TDpiCanvas; cl: TColor; const T: TTexture; 64 94 x, y: integer; s: string); 65 function BiColorTextWidth(ca: T Canvas; s: string): integer;66 procedure RisedTextOut(ca: T Canvas; x, y: integer; s: string);67 procedure LightGradient(ca: T Canvas; x, y, Width, Color: integer);68 procedure DarkGradient(ca: T Canvas; x, y, Width, Kind: integer);69 procedure VLightGradient(ca: T Canvas; x, y, Height, Color: integer);70 procedure VDarkGradient(ca: T Canvas; x, y, Height, Kind: integer);71 procedure NumberBar(dst: T Bitmap; x, y: integer; Cap: string; val: integer;95 function BiColorTextWidth(ca: TDpiCanvas; s: string): integer; 96 procedure RisedTextOut(ca: TDpiCanvas; x, y: integer; s: string); 97 procedure LightGradient(ca: TDpiCanvas; x, y, Width, Color: integer); 98 procedure DarkGradient(ca: TDpiCanvas; x, y, Width, Kind: integer); 99 procedure VLightGradient(ca: TDpiCanvas; x, y, Height, Color: integer); 100 procedure VDarkGradient(ca: TDpiCanvas; x, y, Height, Kind: integer); 101 procedure NumberBar(dst: TDpiBitmap; x, y: integer; Cap: string; val: integer; 72 102 const T: TTexture); 73 procedure CountBar(dst: T Bitmap; x, y, w: integer; Kind: integer;103 procedure CountBar(dst: TDpiBitmap; x, y, w: integer; Kind: integer; 74 104 Cap: string; val: integer; const T: TTexture); 75 procedure PaintProgressBar(ca: T Canvas; Kind, x, y, pos, Growth, max: integer;105 procedure PaintProgressBar(ca: TDpiCanvas; Kind, x, y, pos, Growth, max: integer; 76 106 const T: TTexture); 77 procedure PaintRelativeProgressBar(ca: T Canvas;107 procedure PaintRelativeProgressBar(ca: TDpiCanvas; 78 108 Kind, x, y, size, pos, Growth, max: integer; IndicateComplete: boolean; 79 109 const T: TTexture); 80 procedure PaintLogo(ca: T Canvas; x, y, clLight, clShade: integer);110 procedure PaintLogo(ca: TDpiCanvas; x, y, clLight, clShade: integer); 81 111 function SetMainTextureByAge(Age: integer): boolean; 82 112 procedure LoadPhrases; … … 118 148 wOrna = 27; 119 149 hOrna = 26; // ornament 150 151 // sound modes 152 smOff = 0; 153 smOn = 1; 154 smOnAlt = 2; 120 155 121 156 // color matrix … … 153 188 TGrExtDescr = record { don't use dynamic strings here! } 154 189 Name: string[31]; 155 Data, Mask: T Bitmap;190 Data, Mask: TDpiBitmap; 156 191 pixUsed: array [byte] of byte; 157 192 end; … … 166 201 167 202 var 168 Phrases: TStringTable; 169 Phrases2: TStringTable; 170 nGrExt: Integer; 203 Phrases, Phrases2, Sounds: TStringTable; 204 nGrExt: integer; 171 205 GrExt: array [0 .. nGrExtmax - 1] of ^TGrExtDescr; 172 HGrSystem, HGrSystem2, ClickFrameColor, MainTextureAge: Integer;206 HGrSystem, HGrSystem2, ClickFrameColor, SoundMode, MainTextureAge: integer; 173 207 MainTexture: TTexture; 174 Templates, Colors, Paper, BigImp, LogoBuffer: T Bitmap;175 FullScreen, GenerateNames, InitOrnamentDone, Phrases2FallenBackToEnglish: Boolean;176 177 UniFont: array [TFontType] of T Font;208 Templates, Colors, Paper, BigImp, LogoBuffer: TDpiBitmap; 209 FullScreen, GenerateNames, InitOrnamentDone, Phrases2FallenBackToEnglish: boolean; 210 211 UniFont: array [TFontType] of TDpiFont; 178 212 AppRegistryKey: string = '\SOFTWARE\C-evo'; 179 213 … … 184 218 185 219 uses 186 Directories, Sound, Registry , PixelPointer;220 Directories, Sound, Registry; 187 221 188 222 var … … 221 255 ResolutionChanged := False; 222 256 {$ENDIF} 257 end; 258 259 function Play(Item: string; Index: integer = -1): boolean; 260 {$IFNDEF DEBUG} 261 var 262 WavFileName: string; 263 {$ENDIF} 264 begin 265 Result := False; 266 {$IFNDEF DEBUG} 267 if (Sounds = nil) or (SoundMode = smOff) or (Item = '') then 268 begin 269 Result := True; 270 Exit; 271 end; 272 WavFileName := Sounds.Lookup(Item, Index); 273 Assert(WavFileName[1] <> '['); 274 Result := (WavFileName <> '') and (WavFileName[1] <> '[') and (WavFileName <> '*'); 275 if Result then 276 // SndPlaySound(pchar(HomeDir+'Sounds' +DirectorySeparator+WavFileName+'.wav'),SND_ASYNC) 277 PlaySound(HomeDir + 'Sounds' + DirectorySeparator + WavFileName); 278 {$ENDIF} 279 end; 280 281 procedure PreparePlay(Item: string; Index: Integer = -1); 282 {$IFNDEF DEBUG} 283 var 284 WavFileName: string; 285 {$ENDIF} 286 begin 287 {$IFNDEF DEBUG} 288 if (Sounds = nil) or (SoundMode = smOff) or (Item = '') then 289 Exit; 290 WavFileName := Sounds.Lookup(Item, Index); 291 Assert(WavFileName[1] <> '['); 292 if (WavFileName <> '') and (WavFileName[1] <> '[') and (WavFileName <> '*') then 293 PrepareSound(HomeDir + 'Sounds' + DirectorySeparator + WavFileName); 294 {$ENDIF} 223 295 end; 224 296 … … 284 356 end; 285 357 286 procedure BtnFrame(ca: T Canvas; p: TRect; const T: TTexture);358 procedure BtnFrame(ca: TDpiCanvas; p: TRect; const T: TTexture); 287 359 begin 288 360 RFrame(ca, p.Left - 1, p.Top - 1, p.Right, p.Bottom, T.clBevelShade, … … 290 362 end; 291 363 292 procedure EditFrame(ca: T Canvas; p: TRect; const T: TTexture);364 procedure EditFrame(ca: TDpiCanvas; p: TRect; const T: TTexture); 293 365 begin 294 366 Frame(ca, p.Left - 1, p.Top - 1, p.Right, p.Bottom, $000000, $000000); … … 331 403 end; 332 404 333 procedure ApplyGammaToBitmap(Bitmap: T Bitmap);405 procedure ApplyGammaToBitmap(Bitmap: TDpiBitmap); 334 406 var 335 407 PixelPtr: TPixelPointer; … … 348 420 end; 349 421 350 procedure CopyGray8BitTo24bitBitmap(Dst, Src: T RasterImage);422 procedure CopyGray8BitTo24bitBitmap(Dst, Src: TDpiBitmap); 351 423 var 352 424 SrcPtr, DstPtr: TPixelPointer; … … 369 441 end; 370 442 371 function LoadGraphicFile(bmp: T Bitmap; Path: string; Options: Integer): Boolean;372 var 373 jtex: T JpegImage;374 Png: T PortableNetworkGraphic;443 function LoadGraphicFile(bmp: TDpiBitmap; Path: string; Options: Integer): Boolean; 444 var 445 jtex: TDpiJpegImage; 446 Png: TDpiPortableNetworkGraphic; 375 447 begin 376 448 Result := True; … … 378 450 Path := Path + '.png'; 379 451 if ExtractFileExt(Path) = '.jpg' then begin 380 jtex := tjpegimage.Create;452 jtex := TDpiJpegImage.Create; 381 453 try 382 454 jtex.LoadFromFile(Path); … … 395 467 else 396 468 if ExtractFileExt(Path) = '.png' then begin 397 Png := T PortableNetworkGraphic.Create;469 Png := TDpiPortableNetworkGraphic.Create; 398 470 Png.PixelFormat := Bmp.PixelFormat; 399 471 try … … 414 486 end 415 487 else 416 Bmp.Canvas. draw(0, 0, Png);488 Bmp.Canvas.Draw(0, 0, Png); 417 489 end; 418 490 Png.Free; … … 446 518 I, x, y, xmax, OriginalColor: Integer; 447 519 FileName: string; 448 Source: T Bitmap;520 Source: TDpiBitmap; 449 521 DataPixel, MaskPixel: TPixelPointer; 450 522 begin … … 454 526 Result := I; 455 527 if I = nGrExt then begin 456 Source := T Bitmap.Create;528 Source := TDpiBitmap.Create; 457 529 Source.PixelFormat := pf24bit; 458 530 FileName := HomeDir + 'Graphics' + DirectorySeparator + Name; … … 471 543 GrExt[nGrExt].Data := Source; 472 544 GrExt[nGrExt].Data.PixelFormat := pf24bit; 473 GrExt[nGrExt].Mask := T Bitmap.Create;545 GrExt[nGrExt].Mask := TDpiBitmap.Create; 474 546 GrExt[nGrExt].Mask.PixelFormat := pf24bit; 475 547 GrExt[nGrExt].Mask.SetSize(Source.Width, Source.Height); … … 506 578 end; 507 579 508 procedure Dump(dst: T Bitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);580 procedure Dump(dst: TDpiBitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer); 509 581 begin 510 582 BitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height, … … 512 584 end; 513 585 514 procedure MakeBlue(dst: T Bitmap; x, y, w, h: integer);586 procedure MakeBlue(dst: TDpiBitmap; x, y, w, h: integer); 515 587 var 516 588 XX, YY: integer; … … 531 603 end; 532 604 533 procedure ImageOp_B(dst, Src: T Bitmap; xDst, yDst, xSrc, ySrc, w, h: Integer);605 procedure ImageOp_B(dst, Src: TDpiBitmap; xDst, yDst, xSrc, ySrc, w, h: Integer); 534 606 // Src is template 535 607 // X channel = background amp (old Dst content), 128=original brightness … … 591 663 end; 592 664 593 procedure ImageOp_BCC(dst, Src: T Bitmap;665 procedure ImageOp_BCC(dst, Src: TDpiBitmap; 594 666 xDst, yDst, xSrc, ySrc, w, h, Color1, Color2: integer); 595 667 // Src is template … … 657 729 end; 658 730 659 procedure ImageOp_CCC(bmp: T Bitmap; x, y, w, h, Color0, Color1, Color2: Integer);731 procedure ImageOp_CCC(bmp: TDpiBitmap; x, y, w, h, Color0, Color1, Color2: Integer); 660 732 // Bmp is template 661 733 // B channel = Color0 amp, 128=original brightness … … 690 762 end; 691 763 692 procedure Sprite(Canvas: T Canvas; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);764 procedure Sprite(Canvas: TDpiCanvas; HGr, xDst, yDst, Width, Height, xGr, yGr: integer); 693 765 begin 694 766 BitBlt(Canvas.Handle, xDst, yDst, Width, Height, … … 698 770 end; 699 771 700 procedure Sprite(dst: T Bitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);772 procedure Sprite(dst: TDpiBitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer); 701 773 begin 702 774 BitBlt(dst.Canvas.Handle, xDst, yDst, Width, Height, … … 706 778 end; 707 779 708 function BitBltCanvas(DestCanvas: T Canvas; X, Y, Width, Height: integer;709 SrcCanvas: T Canvas; XSrc, YSrc: integer; Rop: DWORD): boolean;780 function BitBltCanvas(DestCanvas: TDpiCanvas; X, Y, Width, Height: integer; 781 SrcCanvas: TDpiCanvas; XSrc, YSrc: integer; Rop: DWORD): boolean; 710 782 begin 711 783 Assert(Rop = SRCCOPY); … … 715 787 end; 716 788 717 procedure SLine(ca: T Canvas; x0, x1, y: integer; cl: TColor);789 procedure SLine(ca: TDpiCanvas; x0, x1, y: integer; cl: TColor); 718 790 begin 719 791 with ca do begin … … 724 796 end; 725 797 726 procedure DLine(ca: T Canvas; x0, x1, y: integer; cl0, cl1: TColor);798 procedure DLine(ca: TDpiCanvas; x0, x1, y: integer; cl0, cl1: TColor); 727 799 begin 728 800 with ca do begin … … 738 810 end; 739 811 740 procedure Frame(ca: T Canvas; x0, y0, x1, y1: integer; cl0, cl1: TColor);812 procedure Frame(ca: TDpiCanvas; x0, y0, x1, y1: integer; cl0, cl1: TColor); 741 813 begin 742 814 with ca do begin … … 751 823 end; 752 824 753 procedure RFrame(ca: T Canvas; x0, y0, x1, y1: integer; cl0, cl1: TColor);825 procedure RFrame(ca: TDpiCanvas; x0, y0, x1, y1: integer; cl0, cl1: TColor); 754 826 begin 755 827 with ca do begin … … 767 839 end; 768 840 769 procedure CFrame(ca: T Canvas; x0, y0, x1, y1, Corner: integer; cl: TColor);841 procedure CFrame(ca: TDpiCanvas; x0, y0, x1, y1, Corner: integer; cl: TColor); 770 842 begin 771 843 with ca do begin … … 786 858 end; 787 859 788 procedure FrameImage(ca: T Canvas; Src: TBitmap;860 procedure FrameImage(ca: TDpiCanvas; Src: TDpiBitmap; 789 861 x, y, Width, Height, xSrc, ySrc: integer; IsControl: boolean = False); 790 862 begin … … 798 870 end; 799 871 800 procedure GlowFrame(dst: T Bitmap; x0, y0, Width, Height: Integer; cl: TColor);872 procedure GlowFrame(dst: TDpiBitmap; x0, y0, Width, Height: Integer; cl: TColor); 801 873 var 802 874 x, y, ch, r: Integer; … … 879 951 end; 880 952 881 procedure Fill(ca: T Canvas; Left, Top, Width, Height, xOffset, yOffset: Integer);953 procedure Fill(ca: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: Integer); 882 954 begin 883 955 Assert((Left + xOffset >= 0) and (Left + xOffset + Width <= wMainTexture) and … … 887 959 end; 888 960 889 procedure FillLarge(ca: T Canvas; x0, y0, x1, y1, xm: Integer);961 procedure FillLarge(ca: TDpiCanvas; x0, y0, x1, y1, xm: Integer); 890 962 891 963 function Band(I: Integer): Integer; … … 922 994 end; 923 995 924 procedure FillSeamless(ca: T Canvas; Left, Top, Width, Height, xOffset, yOffset: Integer;925 const Texture: T Bitmap);996 procedure FillSeamless(ca: TDpiCanvas; Left, Top, Width, Height, xOffset, yOffset: Integer; 997 const Texture: TDpiBitmap); 926 998 var 927 999 x, y, x0cut, y0cut, x1cut, y1cut: Integer; … … 957 1029 end; 958 1030 959 procedure FillRectSeamless(ca: T Canvas; x0, y0, x1, y1, xOffset, yOffset: Integer;960 const Texture: T Bitmap);1031 procedure FillRectSeamless(ca: TDpiCanvas; x0, y0, x1, y1, xOffset, yOffset: Integer; 1032 const Texture: TDpiBitmap); 961 1033 begin 962 1034 FillSeamless(ca, x0, y0, x1 - x0, y1 - y0, xOffset, yOffset, Texture); 963 1035 end; 964 1036 965 procedure PaintBackground(Form: T Form; Left, Top, Width, Height: Integer);1037 procedure PaintBackground(Form: TDpiForm; Left, Top, Width, Height: Integer); 966 1038 begin 967 1039 Fill(Form.Canvas, Left, Top, Width, Height, (wMainTexture - Form.ClientWidth) div … … 969 1041 end; 970 1042 971 procedure Corner(ca: T Canvas; x, y, Kind: Integer; const T: TTexture);1043 procedure Corner(ca: TDpiCanvas; x, y, Kind: Integer; const T: TTexture); 972 1044 begin 973 1045 { BitBlt(ca.Handle,x,y,8,8,GrExt[T.HGr].Mask.Canvas.Handle, … … 977 1049 end; 978 1050 979 procedure BiColorTextOut(ca: T Canvas; clMain, clBack: TColor; x, y: Integer; s: string);1051 procedure BiColorTextOut(ca: TDpiCanvas; clMain, clBack: TColor; x, y: Integer; s: string); 980 1052 981 1053 procedure PaintIcon(x, y, Kind: Integer); … … 1038 1110 end; 1039 1111 1040 function BiColorTextWidth(ca: T Canvas; s: string): Integer;1112 function BiColorTextWidth(ca: TDpiCanvas; s: string): Integer; 1041 1113 var 1042 1114 P: Integer; … … 1062 1134 end; 1063 1135 1064 procedure LoweredTextOut(ca: T Canvas; cl: TColor; const T: TTexture;1136 procedure LoweredTextOut(ca: TDpiCanvas; cl: TColor; const T: TTexture; 1065 1137 x, y: Integer; s: string); 1066 1138 begin … … 1074 1146 end; 1075 1147 1076 procedure RisedTextOut(ca: T Canvas; x, y: integer; s: string);1148 procedure RisedTextOut(ca: TDpiCanvas; x, y: integer; s: string); 1077 1149 begin 1078 1150 BiColorTextOut(ca, $FFFFFF, $000000, x, y, s); 1079 1151 end; 1080 1152 1081 procedure Gradient(ca: T Canvas; x, y, dx, dy, Width, Height, Color: Integer;1153 procedure Gradient(ca: TDpiCanvas; x, y, dx, dy, Width, Height, Color: Integer; 1082 1154 Brightness: array of integer); 1083 1155 var … … 1113 1185 end; 1114 1186 1115 procedure LightGradient(ca: T Canvas; x, y, Width, Color: Integer);1187 procedure LightGradient(ca: TDpiCanvas; x, y, Width, Color: Integer); 1116 1188 const 1117 1189 Brightness: array [0 .. 15] of integer = … … 1121 1193 end; 1122 1194 1123 procedure DarkGradient(ca: T Canvas; x, y, Width, Kind: Integer);1195 procedure DarkGradient(ca: TDpiCanvas; x, y, Width, Kind: Integer); 1124 1196 const 1125 1197 Brightness: array [0 .. 15] of integer = … … 1130 1202 end; 1131 1203 1132 procedure VLightGradient(ca: T Canvas; x, y, Height, Color: Integer);1204 procedure VLightGradient(ca: TDpiCanvas; x, y, Height, Color: Integer); 1133 1205 const 1134 1206 Brightness: array [0 .. 15] of integer = … … 1138 1210 end; 1139 1211 1140 procedure VDarkGradient(ca: T Canvas; x, y, Height, Kind: Integer);1212 procedure VDarkGradient(ca: TDpiCanvas; x, y, Height, Kind: Integer); 1141 1213 const 1142 1214 Brightness: array [0 .. 15] of integer = … … 1147 1219 end; 1148 1220 1149 procedure NumberBar(dst: T Bitmap; x, y: integer; Cap: string;1221 procedure NumberBar(dst: TDpiBitmap; x, y: integer; Cap: string; 1150 1222 val: Integer; const T: TTexture); 1151 1223 var … … 1163 1235 end; 1164 1236 1165 procedure CountBar(dst: T Bitmap; x, y, w: Integer; Kind: Integer;1237 procedure CountBar(dst: TDpiBitmap; x, y, w: Integer; Kind: Integer; 1166 1238 Cap: string; val: Integer; const T: TTexture); 1167 1239 var … … 1259 1331 end; 1260 1332 1261 procedure PaintProgressBar(ca: T Canvas; Kind, x, y, pos, Growth, max: Integer;1333 procedure PaintProgressBar(ca: TDpiCanvas; Kind, x, y, pos, Growth, max: Integer; 1262 1334 const T: TTexture); 1263 1335 var … … 1312 1384 1313 1385 // pos and growth are relative to max, set size independent 1314 procedure PaintRelativeProgressBar(ca: T Canvas;1386 procedure PaintRelativeProgressBar(ca: TDpiCanvas; 1315 1387 Kind, x, y, size, pos, Growth, max: Integer; IndicateComplete: Boolean; 1316 1388 const T: TTexture); … … 1326 1398 end; 1327 1399 1328 procedure PaintLogo(ca: T Canvas; x, y, clLight, clShade: Integer);1400 procedure PaintLogo(ca: TDpiCanvas; x, y, clLight, clShade: Integer); 1329 1401 begin 1330 1402 BitBltCanvas(LogoBuffer.Canvas, 0, 0, wLogo, hLogo, ca, x, … … 1357 1429 end; 1358 1430 1431 { TPixelPointer } 1432 1433 procedure TPixelPointer.NextLine; inline; 1434 begin 1435 Line := Pointer(Line) + BytesPerLine; 1436 Pixel := Line; 1437 end; 1438 1439 procedure TPixelPointer.NextPixel; inline; 1440 begin 1441 Pixel := Pointer(Pixel) + BytesPerPixel; 1442 end; 1443 1444 procedure TPixelPointer.SetXY(X, Y: Integer); inline; 1445 begin 1446 Line := Pointer(Base) + Y * BytesPerLine; 1447 SetX(X); 1448 end; 1449 1450 procedure TPixelPointer.SetX(X: Integer); inline; 1451 begin 1452 Pixel := Pointer(Line) + X * BytesPerPixel; 1453 end; 1454 1455 procedure TPixelPointer.Init(Bitmap: TDpiRasterImage; BaseX: Integer = 0; 1456 BaseY: integer = 0); inline; 1457 begin 1458 BytesPerLine := Bitmap.RawImage.Description.BytesPerLine; 1459 BytesPerPixel := Bitmap.RawImage.Description.BitsPerPixel shr 3; 1460 Base := PPixel32(Bitmap.RawImage.Data + BaseX * BytesPerPixel + BaseY * BytesPerLine); 1461 SetXY(0, 0); 1462 end; 1463 1359 1464 procedure LoadPhrases; 1360 1465 begin 1361 if Phrases = nil then Phrases := TStringTable.Create; 1362 if Phrases2 = nil then Phrases2 := TStringTable.Create; 1466 if Phrases = nil then 1467 Phrases := TStringTable.Create; 1468 if Phrases2 = nil then 1469 Phrases2 := TStringTable.Create; 1363 1470 Phrases2FallenBackToEnglish := False; 1364 1471 if FileExists(LocalizedFilePath('Language.txt')) then 1365 1472 begin 1366 Phrases. LoadFromFile(LocalizedFilePath('Language.txt'));1473 Phrases.loadfromfile(LocalizedFilePath('Language.txt')); 1367 1474 if FileExists(LocalizedFilePath('Language2.txt')) then 1368 Phrases2. LoadFromFile(LocalizedFilePath('Language2.txt'))1475 Phrases2.loadfromfile(LocalizedFilePath('Language2.txt')) 1369 1476 else 1370 1477 begin 1371 Phrases2. LoadFromFile(HomeDir + 'Language2.txt');1478 Phrases2.loadfromfile(HomeDir + 'Language2.txt'); 1372 1479 Phrases2FallenBackToEnglish := True; 1373 1480 end; … … 1375 1482 else 1376 1483 begin 1377 Phrases.LoadFromFile(HomeDir + 'Language.txt'); 1378 Phrases2.LoadFromFile(HomeDir + 'Language2.txt'); 1379 end; 1380 1381 if Sounds = nil then Sounds := TStringTable.Create; 1382 if not Sounds.LoadFromFile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.txt') then 1484 Phrases.loadfromfile(HomeDir + 'Language.txt'); 1485 Phrases2.loadfromfile(HomeDir + 'Language2.txt'); 1486 end; 1487 1488 if Sounds = nil then 1489 Sounds := TStringTable.Create; 1490 if not Sounds.loadfromfile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.txt') then 1383 1491 begin 1384 1492 FreeAndNil(Sounds); … … 1396 1504 begin 1397 1505 for Section := Low(TFontType) to High(TFontType) do 1398 UniFont[Section] := T Font.Create;1506 UniFont[Section] := TDpiFont.Create; 1399 1507 1400 1508 Section := ftNormal; … … 1407 1515 if s[1] = '#' then begin 1408 1516 s := TrimRight(s); 1409 if s = '#SMALL' then Section := ftSmall 1410 else if s = '#TINY' then Section := ftTiny 1411 else if s = '#CAPTION' then Section := ftCaption 1412 else if s = '#BUTTON' then Section := ftButton 1413 else Section := ftNormal; 1517 if s = '#SMALL' then 1518 Section := ftSmall 1519 else if s = '#TINY' then 1520 Section := ftTiny 1521 else if s = '#CAPTION' then 1522 Section := ftCaption 1523 else if s = '#BUTTON' then 1524 Section := ftButton 1525 else 1526 Section := ftNormal; 1414 1527 end else begin 1415 1528 p := Pos(',', s); 1416 1529 if p > 0 then begin 1417 UniFont[ section].Name := Trim(Copy(s, 1, p - 1));1530 UniFont[Section].Name := Trim(Copy(s, 1, p - 1)); 1418 1531 Size := 0; 1419 1532 for i := p + 1 to Length(s) do … … 1428 1541 // 0.8 constant is compensation for Lazarus as size of fonts against Delphi differs 1429 1542 UniFont[section].Size := 1430 Round( size * Screen.PixelsPerInch / UniFont[section].PixelsPerInch * 0.8);1543 Round(Size * Screen.PixelsPerInch / UniFont[section].PixelsPerInch * 0.8); 1431 1544 end; 1432 1545 end; … … 1490 1603 LoadPhrases; 1491 1604 1492 LogoBuffer := T Bitmap.Create;1605 LogoBuffer := TDpiBitmap.Create; 1493 1606 LogoBuffer.PixelFormat := pf24bit; 1494 1607 LogoBuffer.SetSize(wBBook, hBBook); … … 1499 1612 HGrSystem := LoadGraphicSet('System.png'); 1500 1613 HGrSystem2 := LoadGraphicSet('System2.png'); 1501 Templates := T Bitmap.Create;1614 Templates := TDpiBitmap.Create; 1502 1615 Templates.PixelFormat := pf24bit; 1503 1616 LoadGraphicFile(Templates, HomeDir + 'Graphics' + DirectorySeparator + 1504 1617 'Templates.png', gfNoGamma); 1505 Colors := T Bitmap.Create;1618 Colors := TDpiBitmap.Create; 1506 1619 Colors.PixelFormat := pf24bit; 1507 1620 LoadGraphicFile(Colors, HomeDir + 'Graphics' + DirectorySeparator + 'Colors.png'); 1508 Paper := T Bitmap.Create;1621 Paper := TDpiBitmap.Create; 1509 1622 Paper.PixelFormat := pf24bit; 1510 1623 LoadGraphicFile(Paper, HomeDir + 'Graphics' + DirectorySeparator + 'Paper.jpg'); 1511 BigImp := T Bitmap.Create;1624 BigImp := TDpiBitmap.Create; 1512 1625 BigImp.PixelFormat := pf24bit; 1513 1626 LoadGraphicFile(BigImp, HomeDir + 'Graphics' + DirectorySeparator + 'Icons.png'); 1514 MainTexture.Image := T Bitmap.Create;1627 MainTexture.Image := TDpiBitmap.Create; 1515 1628 MainTextureAge := -2; 1516 1629 ClickFrameColor := GrExt[HGrSystem].Data.Canvas.Pixels[187, 175]; … … 1530 1643 WriteString('Locale', LocaleCode); 1531 1644 WriteInteger('Gamma', Gamma); 1532 if FullScreen then WriteInteger('ScreenMode', 1)1533 else WriteInteger('ScreenMode', 0);1534 1645 finally 1535 1646 Free; … … 1547 1658 FreeAndNil(Phrases); 1548 1659 FreeAndNil(Phrases2); 1660 if Sounds <> nil then 1661 FreeAndNil(Sounds); 1549 1662 FreeAndNil(LogoBuffer); 1550 1663 FreeAndNil(BigImp);
Note:
See TracChangeset
for help on using the changeset viewer.