Changeset 156
- Timestamp:
- Nov 10, 2018, 8:00:53 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Wonders.pas
r155 r156 5 5 6 6 uses 7 ScreenTools, BaseWin, Protocol, 8 LCLIntf, LCLType, SysUtils, Classes, Graphics,Controls, Forms, ButtonB;7 ScreenTools, BaseWin, Protocol, LCLIntf, LCLType, SysUtils, Classes, Graphics, 8 Controls, Forms, ButtonB; 9 9 10 10 type … … 21 21 Shift: TShiftState; X, Y: Integer); 22 22 private 23 xm, ym, Selection: Integer; 23 Selection: Integer; 24 Center: TPoint; 24 25 procedure DarkIcon(i: Integer); 25 26 procedure Glow(i, GlowColor: Integer); … … 33 34 WondersDlg: TWondersDlg; 34 35 36 35 37 implementation 36 38 … … 41 43 42 44 const 43 RingPosition: array [0 .. 20, 0 .. 1] of Integer = ((-80, -32), // Pyramids 44 (80, -32), // Zeus 45 (0, -64), // Gardens 46 (0, 0), // Colossus 47 (0, 64), // Lighthouse 48 (-80, 32), // GrLibrary 49 (-90, 114), // Oracle 50 (80, 32), // Sun 51 (90, -114), // Leo 52 (-180, 0), // Magellan 53 (90, 114), // Mich 54 (0, 0), // {11;} 55 (180, 0), // Newton 56 (-90, -114), // Bach 57 (0, 0), // {14;} 58 (-160, -64), // Liberty 59 (0, 128), // Eiffel 60 (160, -64), // Hoover 61 (-160, 64), // Shinkansen 62 (0, -128), // Manhattan 63 (160, 64)); // Mir 45 RingPosition: array [0 .. 20] of TPoint = ( 46 (X: -80; Y: -32), // Pyramids 47 (X: 80; Y: -32), // Zeus 48 (X: 0; Y: -64), // Gardens 49 (X: 0; Y: 0), // Colossus 50 (X: 0; Y: 64), // Lighthouse 51 (X: -80; Y: 32), // GrLibrary 52 (X: -90; Y: 114), // Oracle 53 (X: 80; Y: 32), // Sun 54 (X: 90; Y: -114), // Leo 55 (X: -180; Y: 0), // Magellan 56 (X: 90; Y: 114), // Mich 57 (X: 0; Y: 0), // {11;} 58 (X: 180; Y: 0), // Newton 59 (X: -90; Y: -114), // Bach 60 (X: 0; Y: 0), // {14;} 61 (X: -160; Y: -64), // Liberty 62 (X: 0; Y: 128), // Eiffel 63 (X: 160; Y: -64), // Hoover 64 (X: -160; Y: 64), // Shinkansen 65 (X: 0; Y: -128), // Manhattan 66 (X: 160; Y: 64) // Mir 67 ); 64 68 65 69 procedure TWondersDlg.FormCreate(Sender: TObject); … … 67 71 Canvas.Font.Assign(UniFont[ftNormal]); 68 72 Canvas.Brush.Style := bsClear; 69 InitButtons ();73 InitButtons; 70 74 end; 71 75 … … 114 118 for i := 0 to 1 do 115 119 for ch := 0 to 2 do begin 116 Line[0].SetXY( xm + X, ym+ Y);117 Line[1].SetXY( xm + X, ym- 1 - Y);120 Line[0].SetXY(Center.X + X, Center.Y + Y); 121 Line[1].SetXY(Center.X + X, Center.Y - 1 - Y); 118 122 c := Line[i].Pixel^.Planes[ch] - darken; 119 123 if c < 0 then Line[i].Pixel^.Planes[ch] := 0 120 124 else Line[i].Pixel^.Planes[ch] := c; 121 Line[0].SetXY( xm - 1 - X, ym+ Y);122 Line[1].SetXY( xm - 1 - X, ym- 1 - Y);125 Line[0].SetXY(Center.X - 1 - X, Center.Y + Y); 126 Line[1].SetXY(Center.X - 1 - X, Center.Y - 1 - Y); 123 127 c := Line[i].Pixel^.Planes[ch] - darken; 124 128 if c < 0 then Line[i].Pixel^.Planes[ch] := 0 … … 136 140 begin 137 141 Offscreen.BeginUpdate; 138 x0Dst := ClientWidth div 2 - xSizeBig div 2 + RingPosition[i , 0];139 y0Dst := ClientHeight div 2 - ySizeBig div 2 + RingPosition[i , 1];142 x0Dst := ClientWidth div 2 - xSizeBig div 2 + RingPosition[i].X; 143 y0Dst := ClientHeight div 2 - ySizeBig div 2 + RingPosition[i].Y; 140 144 x0Src := (i mod 7) * xSizeBig; 141 145 y0Src := (i div 7 + SystemIconLines) * ySizeBig; … … 162 166 procedure TWondersDlg.Glow(i, GlowColor: Integer); 163 167 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); 168 GlowFrame(Offscreen, 169 ClientWidth div 2 - xSizeBig div 2 + RingPosition[i].X, 170 ClientHeight div 2 - ySizeBig div 2 + RingPosition[i].Y, 171 xSizeBig, ySizeBig, GlowColor); 167 172 end; 168 173 169 174 procedure TWondersDlg.OffscreenPaint; 170 175 var 171 i: Integer;172 HaveWonder: boolean;173 s: string;174 begin 175 if (OffscreenUser <> nil) and (OffscreenUser <> self) then176 I: Integer; 177 HaveWonder: Boolean; 178 S: string; 179 begin 180 if (OffscreenUser <> nil) and (OffscreenUser <> Self) then 176 181 OffscreenUser.Update; 177 182 // complete working with old owner to prevent rebound 178 OffscreenUser := self;183 OffscreenUser := Self; 179 184 180 185 Fill(Offscreen.Canvas, 3, 3, ClientWidth - 6, ClientHeight - 6, … … 193 198 194 199 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]); 195 s:= Phrases.Lookup('TITLE_WONDERS');200 S := Phrases.Lookup('TITLE_WONDERS'); 196 201 RisedTextOut(Offscreen.Canvas, 197 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s)) div 2 - 1, 7, s);202 (ClientWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2 - 1, 7, S); 198 203 Offscreen.Canvas.Font.Assign(UniFont[ftNormal]); 199 204 200 xm := ClientWidth div 2; 201 ym := ClientHeight div 2; 205 Center := Point(ClientWidth div 2, ClientHeight div 2); 202 206 203 207 PaintBackgroundShape; 204 208 205 for i:= 0 to 20 do206 if Imp[ i].Preq <> preNA then209 for I := 0 to 20 do 210 if Imp[I].Preq <> preNA then 207 211 begin 208 case MyRO.Wonder[ i].CityID of212 case MyRO.Wonder[I].CityID of 209 213 - 1: // not built yet 210 214 begin 211 Fill(Offscreen.Canvas, xm - xSizeBig div 2 + RingPosition[i, 0]- 3,212 ym - ySizeBig div 2 + RingPosition[i, 1]- 3, xSizeBig + 6,215 Fill(Offscreen.Canvas, Center.X - xSizeBig div 2 + RingPosition[I].X - 3, 216 Center.Y - ySizeBig div 2 + RingPosition[I].Y - 3, xSizeBig + 6, 213 217 ySizeBig + 6, (wMaintexture - ClientWidth) div 2, 214 218 (hMaintexture - ClientHeight) div 2); 215 DarkIcon( i);219 DarkIcon(I); 216 220 end; 217 221 -2: // destroyed 218 222 begin 219 Glow( i, $000000);223 Glow(I, $000000); 220 224 end; 221 225 else 222 226 begin 223 if MyRO.Wonder[ i].EffectiveOwner >= 0 then224 Glow( i, Tribe[MyRO.Wonder[i].EffectiveOwner].Color)227 if MyRO.Wonder[I].EffectiveOwner >= 0 then 228 Glow(I, Tribe[MyRO.Wonder[I].EffectiveOwner].Color) 225 229 else 226 Glow( i, $000000);227 end 228 end 229 end; 230 231 HaveWonder := false;232 for i:= 0 to 20 do233 if Imp[ i].Preq <> preNA then230 Glow(I, $000000); 231 end; 232 end; 233 end; 234 235 HaveWonder := False; 236 for I := 0 to 20 do 237 if Imp[I].Preq <> preNA then 234 238 begin 235 case MyRO.Wonder[ i].CityID of239 case MyRO.Wonder[I].CityID of 236 240 - 1: // not built yet 237 241 begin 238 Fill(Offscreen.Canvas, xm - xSizeBig div 2 + RingPosition[i, 0]- 3,239 ym - ySizeBig div 2 + RingPosition[i, 1]- 3, xSizeBig + 6,242 Fill(Offscreen.Canvas, Center.X - xSizeBig div 2 + RingPosition[I].X - 3, 243 Center.Y - ySizeBig div 2 + RingPosition[I].Y - 3, xSizeBig + 6, 240 244 ySizeBig + 6, (wMaintexture - ClientWidth) div 2, 241 245 (hMaintexture - ClientHeight) div 2); 242 DarkIcon( i);246 DarkIcon(I); 243 247 end; 244 248 -2: // destroyed 245 249 begin 246 HaveWonder := true; 247 BitBlt(Offscreen.Canvas.Handle, xm - xSizeBig div 2 + RingPosition 248 [i, 0], ym - ySizeBig div 2 + RingPosition[i, 1], xSizeBig, 250 HaveWonder := True; 251 BitBlt(Offscreen.Canvas.Handle, 252 Center.X - xSizeBig div 2 + RingPosition[I].X, 253 Center.Y - ySizeBig div 2 + RingPosition[I].Y, xSizeBig, 249 254 ySizeBig, BigImp.Canvas.Handle, 0, (SystemIconLines + 3) * 250 255 ySizeBig, SRCCOPY); … … 252 257 else 253 258 begin 254 HaveWonder := true; 255 BitBlt(Offscreen.Canvas.Handle, xm - xSizeBig div 2 + RingPosition[i, 256 0], ym - ySizeBig div 2 + RingPosition[i, 1], xSizeBig, ySizeBig, 257 BigImp.Canvas.Handle, (i mod 7) * xSizeBig, 258 (i div 7 + SystemIconLines) * ySizeBig, SRCCOPY); 259 end 260 end 259 HaveWonder := True; 260 BitBlt(Offscreen.Canvas.Handle, 261 Center.X - xSizeBig div 2 + RingPosition[I].X, 262 Center.Y - ySizeBig div 2 + RingPosition[I].Y, xSizeBig, ySizeBig, 263 BigImp.Canvas.Handle, (I mod 7) * xSizeBig, 264 (I div 7 + SystemIconLines) * ySizeBig, SRCCOPY); 265 end; 266 end; 261 267 end; 262 268 263 269 if not HaveWonder then 264 270 begin 265 s := Phrases.Lookup('NOWONDER'); 266 RisedTextOut(Offscreen.Canvas, xm - BiColorTextWidth(Offscreen.Canvas, s) 267 div 2, ym - Offscreen.Canvas.TextHeight(s) div 2, s); 271 S := Phrases.Lookup('NOWONDER'); 272 RisedTextOut(Offscreen.Canvas, 273 Center.X - BiColorTextWidth(Offscreen.Canvas, S) div 2, 274 Center.Y - Offscreen.Canvas.TextHeight(S) div 2, S); 268 275 end; 269 276 … … 273 280 procedure TWondersDlg.CloseBtnClick(Sender: TObject); 274 281 begin 275 Close 282 Close; 276 283 end; 277 284 … … 279 286 X, Y: Integer); 280 287 var 281 i, OldSelection: Integer;282 s: string;288 I, OldSelection: Integer; 289 S: string; 283 290 begin 284 291 OldSelection := Selection; 285 292 Selection := -1; 286 for i := 0 to 20 do 287 if (Imp[i].Preq <> preNA) and (X >= xm - xSizeBig div 2 + RingPosition[i, 0] 288 ) and (X < xm + xSizeBig div 2 + RingPosition[i, 0]) and 289 (Y >= ym - ySizeBig div 2 + RingPosition[i, 1]) and 290 (Y < ym + ySizeBig div 2 + RingPosition[i, 1]) then 293 for I := 0 to 20 do 294 if (Imp[I].Preq <> preNA) and 295 (X >= Center.X - xSizeBig div 2 + RingPosition[I].X) and 296 (X < Center.X + xSizeBig div 2 + RingPosition[I].X) and 297 (Y >= Center.Y - ySizeBig div 2 + RingPosition[I].Y) and 298 (Y < Center.Y + ySizeBig div 2 + RingPosition[I].Y) then 291 299 begin 292 Selection := i;293 break300 Selection := I; 301 Break; 294 302 end; 295 303 if Selection <> OldSelection then … … 301 309 if MyRO.Wonder[Selection].CityID = -1 then 302 310 begin // not built yet 303 { s:=Phrases.Lookup('IMPROVEMENTS',Selection);311 { S:=Phrases.Lookup('IMPROVEMENTS',Selection); 304 312 Canvas.Font.Color:=$000000; 305 313 Canvas.TextOut( 306 (ClientWidth-BiColorTextWidth(Canvas, s)) div 2+1,307 ClientHeight-3-36+1, s);314 (ClientWidth-BiColorTextWidth(Canvas,S)) div 2+1, 315 ClientHeight-3-36+1, S); 308 316 Canvas.Font.Color:=MainTexture.clBevelLight; 309 317 Canvas.TextOut( 310 (ClientWidth-BiColorTextWidth(Canvas, s)) div 2,311 ClientHeight-3-36, s); }318 (ClientWidth-BiColorTextWidth(Canvas,S)) div 2, 319 ClientHeight-3-36, S); } 312 320 end 313 321 else 314 322 begin 315 s:= Phrases.Lookup('IMPROVEMENTS', Selection);323 S := Phrases.Lookup('IMPROVEMENTS', Selection); 316 324 if MyRO.Wonder[Selection].CityID <> -2 then 317 s:= Format(Phrases.Lookup('WONDEROF'),318 [ s, CityName(MyRO.Wonder[Selection].CityID)]);325 S := Format(Phrases.Lookup('WONDEROF'), 326 [S, CityName(MyRO.Wonder[Selection].CityID)]); 319 327 LoweredTextOut(Canvas, -1, MainTexture, 320 (ClientWidth - BiColorTextWidth(Canvas, s)) div 2,321 ClientHeight - 3 - 36 - 10, s);328 (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 329 ClientHeight - 3 - 36 - 10, S); 322 330 if MyRO.Wonder[Selection].CityID = -2 then 323 s:= Phrases.Lookup('DESTROYED')331 S := Phrases.Lookup('DESTROYED') 324 332 else if MyRO.Wonder[Selection].EffectiveOwner < 0 then 325 s:= Phrases.Lookup('EXPIRED')333 S := Phrases.Lookup('EXPIRED') 326 334 else 327 s := Tribe[MyRO.Wonder[Selection].EffectiveOwner] 328 .TPhrase('WONDEROWNER'); 335 S := Tribe[MyRO.Wonder[Selection].EffectiveOwner].TPhrase('WONDEROWNER'); 329 336 LoweredTextOut(Canvas, -1, MainTexture, 330 (ClientWidth - BiColorTextWidth(Canvas, s)) div 2,331 ClientHeight - 3 - 36 + 10, s);332 end 333 end; 334 end 337 (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 338 ClientHeight - 3 - 36 + 10, S); 339 end; 340 end; 341 end; 335 342 end; 336 343
Note:
See TracChangeset
for help on using the changeset viewer.