Changeset 155
- Timestamp:
- Nov 10, 2018, 7:47:29 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Components/ScreenTools.pas
r144 r155 920 920 begin 921 921 dst.BeginUpdate; 922 DstPtr.Init(dst, x0, y0); 922 923 for y := -GlowRange + 1 to Height - 1 + GlowRange - 1 do 923 924 begin 924 925 for x := -GlowRange + 1 to Width - 1 + GlowRange - 1 do 925 926 begin 926 DstPtr. Init(dst, x0 + x, y0 +y);927 DstPtr.SetXY(x, y); 927 928 if x < 0 then 928 929 if y < 0 then -
trunk/LocalPlayer/BaseWin.pas
r118 r155 9 9 10 10 type 11 12 { TBufferedDrawDlg } 13 11 14 TBufferedDrawDlg = class(TDrawDlg) 12 15 public 13 16 UserLeft, UserTop: integer; 14 17 constructor Create(AOwner: TComponent); override; 18 destructor Destroy; override; 15 19 procedure FormClose(Sender: TObject; var Action: TCloseAction); 16 20 procedure FormPaint(Sender: TObject); … … 27 31 procedure VPaint; virtual; 28 32 public 33 UsedOffscreenWidth, UsedOffscreenHeight: integer; 34 Offscreen: TBitmap; 35 OffscreenUser: TForm; 29 36 property WindowMode: integer read FWindowMode; 30 37 end; … … 55 62 SideFrame = 9; 56 63 57 var 58 UsedOffscreenWidth, UsedOffscreenHeight: integer; 59 Offscreen: TBitmap; 60 OffscreenUser: TForm; 61 62 procedure CreateOffscreen; 64 procedure CreateOffscreen(var Offscreen: TBitmap); 63 65 64 66 implementation … … 67 69 Term, Help, ButtonBase, Area; 68 70 69 constructor TBufferedDrawDlg.Create; 70 begin 71 constructor TBufferedDrawDlg.Create(AOwner: TComponent); 72 begin 73 BaseWin.CreateOffscreen(Offscreen); 71 74 OnClose := FormClose; 72 75 OnPaint := FormPaint; … … 80 83 UserLeft := (Screen.Width - Width) div 2; 81 84 UserTop := (Screen.Height - Height) div 2; 85 end; 86 87 destructor TBufferedDrawDlg.Destroy; 88 begin 89 Offscreen.Free; 90 inherited Destroy; 82 91 end; 83 92 … … 464 473 end; 465 474 466 procedure CreateOffscreen ;475 procedure CreateOffscreen(var Offscreen: TBitmap); 467 476 begin 468 477 if Offscreen <> nil then … … 480 489 initialization 481 490 482 Offscreen := nil;483 OffscreenUser := nil;484 485 491 finalization 486 492 487 Offscreen.Free;488 489 493 end. -
trunk/LocalPlayer/LocalPlayer.pas
r66 r155 24 24 begin 25 25 FormsCreated := true; 26 BaseWin.CreateOffscreen;27 26 // TODO: Changing application name in runtime will cause change of Linux XML registry file path 28 27 // Application.MainForm := MainScreen; -
trunk/LocalPlayer/Term.pas
r152 r155 275 275 procedure OnEOT(var Msg: TMessage); message WM_EOT; 276 276 public 277 UsedOffscreenWidth, UsedOffscreenHeight: integer; 278 Offscreen: TBitmap; 279 OffscreenUser: TForm; 277 280 procedure CreateParams(var p: TCreateParams); override; 278 281 procedure Client(Command, NewPlayer: integer; var Data); … … 3405 3408 i, j: integer; 3406 3409 begin 3410 BaseWin.CreateOffscreen(Offscreen); 3411 3407 3412 // define which menu settings to save 3408 3413 SaveOption[0] := mAlEffectiveMovesOnly.Tag; … … 3541 3546 if AILogo[i] <> nil then 3542 3547 FreeAndNil(AILogo[i]); 3548 FreeAndNil(Offscreen); 3543 3549 end; 3544 3550 -
trunk/LocalPlayer/Wonders.pas
r72 r155 9 9 10 10 type 11 12 { TWondersDlg } 13 11 14 TWondersDlg = class(TBufferedDrawDlg) 12 15 CloseBtn: TButtonB; … … 17 20 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; 18 21 Shift: TShiftState; X, Y: Integer); 19 22 private 23 xm, ym, Selection: Integer; 24 procedure DarkIcon(i: Integer); 25 procedure Glow(i, GlowColor: Integer); 26 procedure PaintBackgroundShape; 20 27 public 21 28 procedure OffscreenPaint; override; 22 29 procedure ShowNewContent(NewMode: Integer); 23 24 private25 xm, ym, Selection: Integer;26 30 end; 27 31 … … 77 81 end; 78 82 79 procedure TWondersDlg.OffscreenPaint; 80 81 procedure DarkIcon(i: Integer); 82 var 83 X, Y, ch, x0Dst, y0Dst, x0Src, y0Src, darken, c: Integer; 84 Src, Dst: TPixelPointer; 85 begin 86 x0Dst := ClientWidth div 2 - xSizeBig div 2 + RingPosition[i, 0]; 87 y0Dst := ClientHeight div 2 - ySizeBig div 2 + RingPosition[i, 1]; 88 x0Src := (i mod 7) * xSizeBig; 89 y0Src := (i div 7 + SystemIconLines) * ySizeBig; 90 Src.Init(BigImp, x0Src, y0Src); 91 Dst.Init(Offscreen, x0Dst, y0Dst); 92 for Y := 0 to ySizeBig - 1 do begin 93 for X := 0 to xSizeBig - 1 do begin 94 Darken := ((255 - Src.Pixel^.B) * 3 + (255 - Src.Pixel^.G) * 95 15 + (255 - Src.Pixel^.R) * 9) div 128; 96 for ch := 0 to 2 do begin 97 c := Dst.Pixel^.Planes[ch] - Darken; 98 if c < 0 then Dst.Pixel^.Planes[ch] := 0 99 else Dst.Pixel^.Planes[ch] := c; 100 end; 101 Src.NextPixel; 102 Dst.NextPixel; 103 end; 104 Src.NextLine; 105 Dst.NextLine; 106 end; 107 end; 108 109 procedure Glow(i, GlowColor: Integer); 110 begin 111 GlowFrame(Offscreen, ClientWidth div 2 - xSizeBig div 2 + RingPosition[i, 112 0], ClientHeight div 2 - ySizeBig div 2 + RingPosition[i, 1], xSizeBig, 113 ySizeBig, GlowColor); 114 end; 115 83 procedure TWondersDlg.PaintBackgroundShape; 116 84 const 117 85 darken = 24; … … 124 92 amin3 = 272977; // 1 shl 16*tan(5*pi/12+space); 125 93 var 126 i, X, Y, r, ax, ch, c: Integer; 127 HaveWonder: boolean; 94 X: Integer; 95 Y: Integer; 96 ax: Integer; 97 R: Integer; 98 I: Integer; 99 C: Integer; 100 Ch: Integer; 128 101 Line: array [0..1] of TPixelPointer; 129 s: string; 130 begin 131 if (OffscreenUser <> nil) and (OffscreenUser <> self) then 132 OffscreenUser.Update; 133 // complete working with old owner to prevent rebound 134 OffscreenUser := self; 135 136 Fill(Offscreen.Canvas, 3, 3, ClientWidth - 6, ClientHeight - 6, 137 (wMaintexture - ClientWidth) div 2, (hMaintexture - ClientHeight) div 2); 138 Frame(Offscreen.Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, 0, 0); 139 Frame(Offscreen.Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2, 140 MainTexture.clBevelLight, MainTexture.clBevelShade); 141 Frame(Offscreen.Canvas, 2, 2, ClientWidth - 3, ClientHeight - 3, 142 MainTexture.clBevelLight, MainTexture.clBevelShade); 143 Corner(Offscreen.Canvas, 1, 1, 0, MainTexture); 144 Corner(Offscreen.Canvas, ClientWidth - 9, 1, 1, MainTexture); 145 Corner(Offscreen.Canvas, 1, ClientHeight - 9, 2, MainTexture); 146 Corner(Offscreen.Canvas, ClientWidth - 9, ClientHeight - 9, 3, MainTexture); 147 148 BtnFrame(Offscreen.Canvas, CloseBtn.BoundsRect, MainTexture); 149 150 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]); 151 s := Phrases.Lookup('TITLE_WONDERS'); 152 RisedTextOut(Offscreen.Canvas, 153 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s)) div 2 - 1, 7, s); 154 Offscreen.Canvas.Font.Assign(UniFont[ftNormal]); 155 102 begin 156 103 Offscreen.BeginUpdate; 157 xm := ClientWidth div 2;158 ym := ClientHeight div 2;159 104 Line[0].Init(Offscreen); 160 105 Line[1].Init(Offscreen); … … 183 128 end; 184 129 Offscreen.EndUpdate; 130 end; 131 132 procedure TWondersDlg.DarkIcon(i: Integer); 133 var 134 X, Y, ch, x0Dst, y0Dst, x0Src, y0Src, darken, c: Integer; 135 Src, Dst: TPixelPointer; 136 begin 137 Offscreen.BeginUpdate; 138 x0Dst := ClientWidth div 2 - xSizeBig div 2 + RingPosition[i, 0]; 139 y0Dst := ClientHeight div 2 - ySizeBig div 2 + RingPosition[i, 1]; 140 x0Src := (i mod 7) * xSizeBig; 141 y0Src := (i div 7 + SystemIconLines) * ySizeBig; 142 Src.Init(BigImp, x0Src, y0Src); 143 Dst.Init(Offscreen, x0Dst, y0Dst); 144 for Y := 0 to ySizeBig - 1 do begin 145 for X := 0 to xSizeBig - 1 do begin 146 Darken := ((255 - Src.Pixel^.B) * 3 + (255 - Src.Pixel^.G) * 147 15 + (255 - Src.Pixel^.R) * 9) div 128; 148 for ch := 0 to 2 do begin 149 c := Dst.Pixel^.Planes[ch] - Darken; 150 if c < 0 then Dst.Pixel^.Planes[ch] := 0 151 else Dst.Pixel^.Planes[ch] := c; 152 end; 153 Src.NextPixel; 154 Dst.NextPixel; 155 end; 156 Src.NextLine; 157 Dst.NextLine; 158 end; 159 Offscreen.EndUpdate; 160 end; 161 162 procedure TWondersDlg.Glow(i, GlowColor: Integer); 163 begin 164 GlowFrame(Offscreen, ClientWidth div 2 - xSizeBig div 2 + RingPosition[i, 165 0], ClientHeight div 2 - ySizeBig div 2 + RingPosition[i, 1], xSizeBig, 166 ySizeBig, GlowColor); 167 end; 168 169 procedure TWondersDlg.OffscreenPaint; 170 var 171 i: Integer; 172 HaveWonder: boolean; 173 s: string; 174 begin 175 if (OffscreenUser <> nil) and (OffscreenUser <> self) then 176 OffscreenUser.Update; 177 // complete working with old owner to prevent rebound 178 OffscreenUser := self; 179 180 Fill(Offscreen.Canvas, 3, 3, ClientWidth - 6, ClientHeight - 6, 181 (wMaintexture - ClientWidth) div 2, (hMaintexture - ClientHeight) div 2); 182 Frame(Offscreen.Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, 0, 0); 183 Frame(Offscreen.Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2, 184 MainTexture.clBevelLight, MainTexture.clBevelShade); 185 Frame(Offscreen.Canvas, 2, 2, ClientWidth - 3, ClientHeight - 3, 186 MainTexture.clBevelLight, MainTexture.clBevelShade); 187 Corner(Offscreen.Canvas, 1, 1, 0, MainTexture); 188 Corner(Offscreen.Canvas, ClientWidth - 9, 1, 1, MainTexture); 189 Corner(Offscreen.Canvas, 1, ClientHeight - 9, 2, MainTexture); 190 Corner(Offscreen.Canvas, ClientWidth - 9, ClientHeight - 9, 3, MainTexture); 191 192 BtnFrame(Offscreen.Canvas, CloseBtn.BoundsRect, MainTexture); 193 194 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]); 195 s := Phrases.Lookup('TITLE_WONDERS'); 196 RisedTextOut(Offscreen.Canvas, 197 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s)) div 2 - 1, 7, s); 198 Offscreen.Canvas.Font.Assign(UniFont[ftNormal]); 199 200 xm := ClientWidth div 2; 201 ym := ClientHeight div 2; 202 203 PaintBackgroundShape; 204 205 for i := 0 to 20 do 206 if Imp[i].Preq <> preNA then 207 begin 208 case MyRO.Wonder[i].CityID of 209 - 1: // not built yet 210 begin 211 Fill(Offscreen.Canvas, xm - xSizeBig div 2 + RingPosition[i, 0] - 3, 212 ym - ySizeBig div 2 + RingPosition[i, 1] - 3, xSizeBig + 6, 213 ySizeBig + 6, (wMaintexture - ClientWidth) div 2, 214 (hMaintexture - ClientHeight) div 2); 215 DarkIcon(i); 216 end; 217 -2: // destroyed 218 begin 219 Glow(i, $000000); 220 end; 221 else 222 begin 223 if MyRO.Wonder[i].EffectiveOwner >= 0 then 224 Glow(i, Tribe[MyRO.Wonder[i].EffectiveOwner].Color) 225 else 226 Glow(i, $000000); 227 end 228 end 229 end; 185 230 186 231 HaveWonder := false; … … 200 245 begin 201 246 HaveWonder := true; 202 Glow(i, $000000);203 247 BitBlt(Offscreen.Canvas.Handle, xm - xSizeBig div 2 + RingPosition 204 248 [i, 0], ym - ySizeBig div 2 + RingPosition[i, 1], xSizeBig, … … 209 253 begin 210 254 HaveWonder := true; 211 if MyRO.Wonder[i].EffectiveOwner >= 0 then212 Glow(i, Tribe[MyRO.Wonder[i].EffectiveOwner].Color)213 else214 Glow(i, $000000);215 255 BitBlt(Offscreen.Canvas.Handle, xm - xSizeBig div 2 + RingPosition[i, 216 256 0], ym - ySizeBig div 2 + RingPosition[i, 1], xSizeBig, ySizeBig,
Note:
See TracChangeset
for help on using the changeset viewer.