Changeset 6 for trunk/LocalPlayer/UnitStat.pas
- Timestamp:
- Jan 7, 2017, 11:32:14 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/UnitStat.pas
r2 r6 1 1 {$INCLUDE switches} 2 3 2 unit UnitStat; 4 3 … … 6 5 7 6 uses 8 Protocol,ClientTools,Term,ScreenTools,BaseWin, 9 10 Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,ButtonA,ButtonB, 7 Protocol, ClientTools, Term, ScreenTools, BaseWin, 8 9 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, ButtonA, 10 ButtonB, 11 11 ButtonBase, ButtonC; 12 12 … … 38 38 protected 39 39 mixShow, // for dkOwnModel 40 uixShow, euixShow,ecixShow,41 UnitLoc,AgePrepared: integer;// for dkEnemyUnit, euixShow=-1 ->40 uixShow, euixShow, ecixShow, UnitLoc, AgePrepared: integer; 41 // for dkEnemyUnit, euixShow=-1 -> 42 42 mox: ^TModelInfo; // for dkEnemyModel 43 Kind:(dkOwnModel,dkOwnUnit,dkEnemyModel,dkEnemyUnit,dkEnemyCityDefense,dkEnemyCity); 43 Kind: (dkOwnModel, dkOwnUnit, dkEnemyModel, dkEnemyUnit, dkEnemyCityDefense, 44 dkEnemyCity); 44 45 Back, Template: TBitmap; 45 46 procedure OffscreenPaint; override; … … 56 57 57 58 const 58 xView=71; 59 xTotal=20; StatDown=112; 60 yImp=133; 61 62 // window size 63 wCommon=208; hOwnModel=293; hEnemyModel=236; hEnemyUnit=212; 64 hEnemyCityDefense=320; hEnemyCity=166; hMax=320; 65 59 xView = 71; 60 xTotal = 20; 61 StatDown = 112; 62 yImp = 133; 63 64 // window size 65 wCommon = 208; 66 hOwnModel = 293; 67 hEnemyModel = 236; 68 hEnemyUnit = 212; 69 hEnemyCityDefense = 320; 70 hEnemyCity = 166; 71 hMax = 320; 66 72 67 73 procedure TUnitStatDlg.FormCreate(Sender: TObject); 68 74 begin 69 inherited; 70 AgePrepared:=-2; 71 TitleHeight:=Screen.Height; 72 InitButtons(); 73 74 Back:=TBitmap.Create; 75 Back.PixelFormat:=pf24bit; 76 Back.Width:=5*wCommon; Back.Height:=hMax; 77 Template:=TBitmap.Create; 78 LoadGraphicFile(Template, HomeDir+'Graphics\Unit', gfNoGamma); 79 Template.PixelFormat:=pf8bit; 75 inherited; 76 AgePrepared := -2; 77 TitleHeight := Screen.Height; 78 InitButtons(); 79 80 Back := TBitmap.Create; 81 Back.PixelFormat := pf24bit; 82 Back.Width := 5 * wCommon; 83 Back.Height := hMax; 84 Template := TBitmap.Create; 85 LoadGraphicFile(Template, HomeDir + 'Graphics\Unit', gfNoGamma); 86 Template.PixelFormat := pf8bit; 80 87 end; 81 88 82 89 procedure TUnitStatDlg.FormDestroy(Sender: TObject); 83 90 begin 84 Template.Free;85 Back.Free;91 Template.Free; 92 Back.Free; 86 93 end; 87 94 88 95 procedure TUnitStatDlg.CheckAge; 89 96 begin 90 if MainTextureAge<>AgePrepared then91 begin 92 AgePrepared:=MainTextureAge;93 bitblt(Back.Canvas.Handle,0,0,wCommon,hOwnModel,94 MainTexture.Image.Canvas.Handle,(wMainTexture-wCommon) div 2,95 (hMainTexture-hOwnModel) div 2,SRCCOPY);96 bitblt(Back.Canvas.Handle,wCommon,0,wCommon,hEnemyModel,97 MainTexture.Image.Canvas.Handle,(wMainTexture-wCommon) div 2,98 (hMainTexture-hEnemyModel) div 2,SRCCOPY);99 bitblt(Back.Canvas.Handle,2*wCommon,0,wCommon,hEnemyUnit,100 MainTexture.Image.Canvas.Handle,(wMainTexture-wCommon) div 2,101 (hMainTexture-hEnemyUnit) div 2,SRCCOPY);102 bitblt(Back.Canvas.Handle,3*wCommon,0,wCommon,hEnemyCityDefense,103 MainTexture.Image.Canvas.Handle,(wMainTexture-wCommon) div 2,104 (hMainTexture-hEnemyCityDefense) div 2,SRCCOPY);105 bitblt(Back.Canvas.Handle,4*wCommon,0,wCommon,hEnemyCity,106 MainTexture.Image.Canvas.Handle,(wMainTexture-wCommon) div 2,107 (hMainTexture-hEnemyCity) div 2,SRCCOPY);108 ImageOp_B(Back,Template,0,0,0,0,5*wCommon,hMax);97 if MainTextureAge <> AgePrepared then 98 begin 99 AgePrepared := MainTextureAge; 100 bitblt(Back.Canvas.Handle, 0, 0, wCommon, hOwnModel, 101 MainTexture.Image.Canvas.Handle, (wMainTexture - wCommon) div 2, 102 (hMainTexture - hOwnModel) div 2, SRCCOPY); 103 bitblt(Back.Canvas.Handle, wCommon, 0, wCommon, hEnemyModel, 104 MainTexture.Image.Canvas.Handle, (wMainTexture - wCommon) div 2, 105 (hMainTexture - hEnemyModel) div 2, SRCCOPY); 106 bitblt(Back.Canvas.Handle, 2 * wCommon, 0, wCommon, hEnemyUnit, 107 MainTexture.Image.Canvas.Handle, (wMainTexture - wCommon) div 2, 108 (hMainTexture - hEnemyUnit) div 2, SRCCOPY); 109 bitblt(Back.Canvas.Handle, 3 * wCommon, 0, wCommon, hEnemyCityDefense, 110 MainTexture.Image.Canvas.Handle, (wMainTexture - wCommon) div 2, 111 (hMainTexture - hEnemyCityDefense) div 2, SRCCOPY); 112 bitblt(Back.Canvas.Handle, 4 * wCommon, 0, wCommon, hEnemyCity, 113 MainTexture.Image.Canvas.Handle, (wMainTexture - wCommon) div 2, 114 (hMainTexture - hEnemyCity) div 2, SRCCOPY); 115 ImageOp_B(Back, Template, 0, 0, 0, 0, 5 * wCommon, hMax); 109 116 end 110 117 end; … … 112 119 procedure TUnitStatDlg.FormShow(Sender: TObject); 113 120 var 114 owner, mix: integer;115 IsSpecialUnit: boolean;116 begin 117 if Kind in [dkEnemyUnit,dkEnemyCityDefense,dkEnemyCity] then118 begin 119 if MyMap[UnitLoc] and fUnit<>0 then121 owner, mix: integer; 122 IsSpecialUnit: boolean; 123 begin 124 if Kind in [dkEnemyUnit, dkEnemyCityDefense, dkEnemyCity] then 125 begin 126 if MyMap[UnitLoc] and fUnit <> 0 then 120 127 begin // find model 121 if euixShow<0 then 122 begin 123 euixShow:=MyRO.nEnemyUn-1; 124 while (euixShow>=0) and (MyRO.EnemyUn[euixShow].Loc<>UnitLoc) do dec(euixShow); 125 assert(euixShow>=0); 126 end; 127 with MyRO.EnemyUn[euixShow] do 128 begin 129 mox:=@MyRO.EnemyModel[emix]; 130 if Tribe[Owner].ModelPicture[mix].HGr=0 then 131 InitEnemyModel(emix); 128 if euixShow < 0 then 129 begin 130 euixShow := MyRO.nEnemyUn - 1; 131 while (euixShow >= 0) and (MyRO.EnemyUn[euixShow].Loc <> UnitLoc) do 132 dec(euixShow); 133 assert(euixShow >= 0); 134 end; 135 with MyRO.EnemyUn[euixShow] do 136 begin 137 mox := @MyRO.EnemyModel[emix]; 138 if Tribe[owner].ModelPicture[mix].HGr = 0 then 139 InitEnemyModel(emix); 132 140 end 133 141 end 134 else mox:=nil; 135 if Kind in [dkEnemyCityDefense,dkEnemyCity] then 142 else 143 mox := nil; 144 if Kind in [dkEnemyCityDefense, dkEnemyCity] then 136 145 begin 137 ecixShow:=MyRO.nEnemyCity-1; 138 while (ecixShow>=0) and (MyRO.EnemyCity[ecixShow].Loc<>UnitLoc) do dec(ecixShow); 139 assert(ecixShow>=0); 146 ecixShow := MyRO.nEnemyCity - 1; 147 while (ecixShow >= 0) and (MyRO.EnemyCity[ecixShow].Loc <> UnitLoc) do 148 dec(ecixShow); 149 assert(ecixShow >= 0); 140 150 end 141 151 end; 142 case Kind of143 dkOwnModel: ClientHeight:=hOwnModel;144 dkOwnUnit: ClientHeight:=hEnemyUnit;145 dkEnemyModel: ClientHeight:=hEnemyModel;146 dkEnemyUnit: ClientHeight:=hEnemyUnit;147 dkEnemyCityDefense: ClientHeight:=hEnemyCityDefense;148 dkEnemyCity: ClientHeight:=hEnemyCity;149 end;150 151 if Kind in [dkOwnModel,dkEnemyModel] then152 begin153 Left:=UserLeft;154 Top:=UserTop;155 end156 else157 begin158 Left:=(Screen.Width-Width) div 2;159 Top:=(Screen.Height-Height) div 2;160 end;161 162 SwitchBtn.Visible:= not supervising and (Kind=dkOwnModel);163 ConscriptsBtn.Visible:= not supervising and (Kind=dkOwnModel)164 and (MyRO.Tech[adConscription]>=tsApplicable)165 and (MyModel[mixShow].Domain=dGround) and (MyModel[mixShow].Kind<mkScout);166 IsSpecialUnit:=false;167 if Kind in [dkEnemyCity,dkEnemyCityDefense] then168 Caption:=CityName(MyRO.EnemyCity[ecixShow].ID)169 else170 begin171 152 case Kind of 172 153 dkOwnModel: 173 begin 174 owner:=me; 175 mix:=mixShow; 176 IsSpecialUnit:= MyModel[mix].Kind>=$10; 177 end; 154 ClientHeight := hOwnModel; 178 155 dkOwnUnit: 179 begin 180 owner:=me; 181 mix:=MyUn[uixShow].mix; 182 IsSpecialUnit:= MyModel[mix].Kind>=$10; 183 end 156 ClientHeight := hEnemyUnit; 157 dkEnemyModel: 158 ClientHeight := hEnemyModel; 159 dkEnemyUnit: 160 ClientHeight := hEnemyUnit; 161 dkEnemyCityDefense: 162 ClientHeight := hEnemyCityDefense; 163 dkEnemyCity: 164 ClientHeight := hEnemyCity; 165 end; 166 167 if Kind in [dkOwnModel, dkEnemyModel] then 168 begin 169 Left := UserLeft; 170 Top := UserTop; 171 end 172 else 173 begin 174 Left := (Screen.Width - Width) div 2; 175 Top := (Screen.Height - Height) div 2; 176 end; 177 178 SwitchBtn.Visible := not supervising and (Kind = dkOwnModel); 179 ConscriptsBtn.Visible := not supervising and (Kind = dkOwnModel) and 180 (MyRO.Tech[adConscription] >= tsApplicable) and 181 (MyModel[mixShow].Domain = dGround) and (MyModel[mixShow].Kind < mkScout); 182 IsSpecialUnit := false; 183 if Kind in [dkEnemyCity, dkEnemyCityDefense] then 184 Caption := CityName(MyRO.EnemyCity[ecixShow].ID) 185 else 186 begin 187 case Kind of 188 dkOwnModel: 189 begin 190 owner := me; 191 mix := mixShow; 192 IsSpecialUnit := MyModel[mix].Kind >= $10; 193 end; 194 dkOwnUnit: 195 begin 196 owner := me; 197 mix := MyUn[uixShow].mix; 198 IsSpecialUnit := MyModel[mix].Kind >= $10; 199 end 184 200 else 185 201 begin 186 owner:=mox.owner;187 mix:=mox.mix;188 IsSpecialUnit:= mox.Kind>=$10;202 owner := mox.owner; 203 mix := mox.mix; 204 IsSpecialUnit := mox.Kind >= $10; 189 205 end; 190 206 end; 191 if MainScreen.mNames.Checked then 192 Caption:=Tribe[Owner].ModelName[mix] 193 else Caption:=Format(Tribe[Owner].TPhrase('GENMODEL'),[mix]) 194 end; 195 if IsSpecialUnit then 196 HelpBtn.Hint:=Phrases.Lookup('CONTROLS',6); 197 HelpBtn.Visible:=IsSpecialUnit; 198 OffscreenPaint; 207 if MainScreen.mNames.Checked then 208 Caption := Tribe[owner].ModelName[mix] 209 else 210 Caption := Format(Tribe[owner].TPhrase('GENMODEL'), [mix]) 211 end; 212 if IsSpecialUnit then 213 HelpBtn.Hint := Phrases.Lookup('CONTROLS', 6); 214 HelpBtn.Visible := IsSpecialUnit; 215 OffscreenPaint; 199 216 end; 200 217 201 218 procedure TUnitStatDlg.ShowNewContent_OwnModel(NewMode, mix: integer); 202 219 begin 203 Kind:=dkOwnModel;204 mixShow:=mix;205 inherited ShowNewContent(NewMode);220 Kind := dkOwnModel; 221 mixShow := mix; 222 inherited ShowNewContent(NewMode); 206 223 end; 207 224 208 225 procedure TUnitStatDlg.ShowNewContent_OwnUnit(NewMode, uix: integer); 209 226 begin 210 Kind:=dkOwnUnit;211 uixShow:=uix;212 inherited ShowNewContent(NewMode);227 Kind := dkOwnUnit; 228 uixShow := uix; 229 inherited ShowNewContent(NewMode); 213 230 end; 214 231 215 232 procedure TUnitStatDlg.ShowNewContent_EnemyUnit(NewMode, euix: integer); 216 233 begin 217 Kind:=dkEnemyUnit;218 euixShow:=euix;219 UnitLoc:=MyRO.EnemyUn[euix].Loc;220 inherited ShowNewContent(NewMode);234 Kind := dkEnemyUnit; 235 euixShow := euix; 236 UnitLoc := MyRO.EnemyUn[euix].Loc; 237 inherited ShowNewContent(NewMode); 221 238 end; 222 239 223 240 procedure TUnitStatDlg.ShowNewContent_EnemyLoc(NewMode, Loc: integer); 224 241 begin 225 Kind:=dkEnemyUnit;226 UnitLoc:=Loc;227 euixShow:=-1;228 inherited ShowNewContent(NewMode);242 Kind := dkEnemyUnit; 243 UnitLoc := Loc; 244 euixShow := -1; 245 inherited ShowNewContent(NewMode); 229 246 end; 230 247 231 248 procedure TUnitStatDlg.ShowNewContent_EnemyModel(NewMode, emix: integer); 232 249 begin 233 Kind:=dkEnemyModel;234 mox:=@MyRO.EnemyModel[emix];235 inherited ShowNewContent(NewMode);250 Kind := dkEnemyModel; 251 mox := @MyRO.EnemyModel[emix]; 252 inherited ShowNewContent(NewMode); 236 253 end; 237 254 238 255 procedure TUnitStatDlg.ShowNewContent_EnemyCity(NewMode, Loc: integer); 239 256 begin 240 if MyMap[Loc] and fUnit<>0 then 241 Kind:=dkEnemyCityDefense 242 else Kind:=dkEnemyCity; 243 UnitLoc:=Loc; 244 euixShow:=-1; 245 inherited ShowNewContent(NewMode); 246 end; 247 248 procedure TUnitStatDlg.FormClose(Sender: TObject; 249 var Action: TCloseAction); 250 begin 251 if Kind in [dkOwnModel,dkEnemyModel] then 252 begin UserLeft:=Left; UserTop:=Top end; 253 if OffscreenUser=self then OffscreenUser:=nil; 257 if MyMap[Loc] and fUnit <> 0 then 258 Kind := dkEnemyCityDefense 259 else 260 Kind := dkEnemyCity; 261 UnitLoc := Loc; 262 euixShow := -1; 263 inherited ShowNewContent(NewMode); 264 end; 265 266 procedure TUnitStatDlg.FormClose(Sender: TObject; var Action: TCloseAction); 267 begin 268 if Kind in [dkOwnModel, dkEnemyModel] then 269 begin 270 UserLeft := Left; 271 UserTop := Top 272 end; 273 if OffscreenUser = self then 274 OffscreenUser := nil; 254 275 end; 255 276 256 277 procedure TUnitStatDlg.CloseBtnClick(Sender: TObject); 257 278 begin 258 Close279 Close 259 280 end; 260 281 261 282 procedure TUnitStatDlg.OffscreenPaint; 262 283 var 263 PPicture: ^TModelPicture;284 PPicture: ^TModelPicture; 264 285 265 286 function IsToCount(emix: integer): boolean; 266 287 var 267 PTestPicture: ^TModelPicture;268 begin 269 if MainScreen.mNames.Checked then288 PTestPicture: ^TModelPicture; 289 begin 290 if MainScreen.mNames.Checked then 270 291 begin 271 PTestPicture:=@Tribe[MyRO.EnemyModel[emix].Owner].ModelPicture[MyRO.EnemyModel[emix].mix]; 272 result:= (PPicture.HGr=PTestPicture.HGr) and (PPicture.pix=PTestPicture.pix) 273 and (ModelHash(mox^)=ModelHash(MyRO.EnemyModel[emix])) 292 PTestPicture := @Tribe[MyRO.EnemyModel[emix].owner].ModelPicture 293 [MyRO.EnemyModel[emix].mix]; 294 result := (PPicture.HGr = PTestPicture.HGr) and 295 (PPicture.pix = PTestPicture.pix) and 296 (ModelHash(mox^) = ModelHash(MyRO.EnemyModel[emix])) 274 297 end 275 else result:= (MyRO.EnemyModel[emix].Owner=mox.Owner) 276 and (MyRO.EnemyModel[emix].mix=mox.mix) 277 end; 278 279 procedure FeatureBar(dst: TBitmap; x,y: integer; const mi: TModelInfo; 298 else 299 result := (MyRO.EnemyModel[emix].owner = mox.owner) and 300 (MyRO.EnemyModel[emix].mix = mox.mix) 301 end; 302 303 procedure FeatureBar(dst: TBitmap; x, y: integer; const mi: TModelInfo; 280 304 const T: TTexture); 281 305 var 282 i,w,dx,num: integer;283 s: string;284 begin 285 DarkGradient(dst.Canvas,x-6,y+1,180,1);286 with dst.Canvas do287 if mi.Kind>=$10 then288 begin 289 s:=Phrases.Lookup('UNITSPECIAL');290 Font.Color:=$000000;291 Textout(x-1,y+1,s);292 Font.Color:=$B0B0B0;293 Textout(x-2,y,s);306 i, w, dx, num: integer; 307 s: string; 308 begin 309 DarkGradient(dst.Canvas, x - 6, y + 1, 180, 1); 310 with dst.Canvas do 311 if mi.Kind >= $10 then 312 begin 313 s := Phrases.Lookup('UNITSPECIAL'); 314 Font.Color := $000000; 315 Textout(x - 1, y + 1, s); 316 Font.Color := $B0B0B0; 317 Textout(x - 2, y, s); 294 318 end 295 else 296 begin 297 Font.Color:=$000000; 298 dx:=2; 299 for i:=3 to nFeature-1 do 300 begin 301 num:=0; 302 case i of 303 mcSeaTrans: if mi.Domain=dSea then num:=mi.TTrans; 304 mcCarrier: if mi.Domain=dSea then num:=mi.ATrans_Fuel; 305 mcBombs: num:=mi.Bombs; 306 mcFuel: if mi.Domain=dAir then num:=mi.ATrans_Fuel; 307 mcAirTrans: if mi.Domain=dAir then num:=mi.TTrans; 308 mcFirstNonCap..nFeature-1: 309 if mi.Cap and (1 shl (i-mcFirstNonCap))<>0 then num:=1 319 else 320 begin 321 Font.Color := $000000; 322 dx := 2; 323 for i := 3 to nFeature - 1 do 324 begin 325 num := 0; 326 case i of 327 mcSeaTrans: 328 if mi.Domain = dSea then 329 num := mi.TTrans; 330 mcCarrier: 331 if mi.Domain = dSea then 332 num := mi.ATrans_Fuel; 333 mcBombs: 334 num := mi.Bombs; 335 mcFuel: 336 if mi.Domain = dAir then 337 num := mi.ATrans_Fuel; 338 mcAirTrans: 339 if mi.Domain = dAir then 340 num := mi.TTrans; 341 mcFirstNonCap .. nFeature - 1: 342 if mi.Cap and (1 shl (i - mcFirstNonCap)) <> 0 then 343 num := 1 310 344 end; 311 if (num>0) and ((i<>mcSE) or (mi.Cap and (1 shl (mcNP-mcFirstNonCap))=0)) then 345 if (num > 0) and 346 ((i <> mcSE) or (mi.Cap and (1 shl (mcNP - mcFirstNonCap)) = 0)) 347 then 312 348 begin 313 if num>1 then349 if num > 1 then 314 350 begin 315 s:=IntToStr(num);316 w:=TextWidth(s);317 Brush.Color:=$FFFFFF;318 FillRect(Rect(x-3+dx,y+2,x+w-1+dx,y+16));319 Brush.Style:=bsClear;320 Textout(x-3+dx+1,y,s);321 inc(dx,w+1)351 s := IntToStr(num); 352 w := TextWidth(s); 353 Brush.Color := $FFFFFF; 354 FillRect(Rect(x - 3 + dx, y + 2, x + w - 1 + dx, y + 16)); 355 Brush.Style := bsClear; 356 Textout(x - 3 + dx + 1, y, s); 357 inc(dx, w + 1) 322 358 end; 323 Brush.Color:=$C0C0C0; 324 FrameRect(Rect(x-3+dx,y+2,x+11+dx,y+16)); 325 Brush.Style:=bsClear; 326 Sprite(dst,HGrSystem,x-1+dx,y+4,10,10,66+i mod 11 *11,137+i div 11 *11); 327 inc(dx,15) 359 Brush.Color := $C0C0C0; 360 FrameRect(Rect(x - 3 + dx, y + 2, x + 11 + dx, y + 16)); 361 Brush.Style := bsClear; 362 Sprite(dst, HGrSystem, x - 1 + dx, y + 4, 10, 10, 363 66 + i mod 11 * 11, 137 + i div 11 * 11); 364 inc(dx, 15) 328 365 end; 329 366 end 330 367 end 331 end; {featurebar}332 333 procedure NumberBarS(dst: TBitmap; x,y:integer;334 Cap,s: string;const T: TTexture);335 begin 336 DLine(dst.Canvas,x-2,x+170,y+16,T.clBevelShade,T.clBevelLight);337 LoweredTextOut(dst.Canvas,-1,T,x-2,y,Cap);338 RisedTextout(dst.canvas,x+170-BiColorTextWidth(dst.Canvas,s),y,s);368 end; { featurebar } 369 370 procedure NumberBarS(dst: TBitmap; x, y: integer; Cap, s: string; 371 const T: TTexture); 372 begin 373 DLine(dst.Canvas, x - 2, x + 170, y + 16, T.clBevelShade, T.clBevelLight); 374 LoweredTextOut(dst.Canvas, -1, T, x - 2, y, Cap); 375 RisedTextout(dst.Canvas, x + 170 - BiColorTextWidth(dst.Canvas, s), y, s); 339 376 end; 340 377 341 378 var 342 i,j,x,y,cix,uix,emix,InProd,Available,Destroyed,Loc,Cnt,yView,yTotal, 343 yCaption: integer; 344 s: string; 345 ui: TUnitInfo; 346 mi: TModelInfo; 347 begin 348 inherited; 349 350 case Kind of 351 dkOwnModel: 352 begin 353 bitblt(offscreen.canvas.handle,0,0,wCommon,hOwnModel,Back.Canvas.handle,0,0,SRCCOPY); 354 yView:=13; 355 yTotal:=92; 356 end; 357 dkEnemyModel: 358 begin 359 bitblt(offscreen.canvas.handle,0,0,wCommon,hEnemyModel,Back.Canvas.handle,wCommon,0,SRCCOPY); 360 yView:=13; 361 yTotal:=92; 362 end; 363 dkEnemyUnit,dkOwnUnit: 364 begin 365 bitblt(offscreen.canvas.handle,0,0,wCommon,hEnemyUnit,Back.Canvas.handle,2*wCommon,0,SRCCOPY); 366 yView:=13; 367 yTotal:=123; 368 end; 369 dkEnemyCityDefense: 370 begin 371 bitblt(offscreen.canvas.handle,0,0,wCommon,hEnemyCityDefense,Back.Canvas.handle,3*wCommon,0,SRCCOPY); 372 yView:=171; 373 yTotal:=231; 374 end; 375 dkEnemyCity: 376 begin 377 bitblt(offscreen.canvas.handle,0,0,wCommon,hEnemyCity,Back.Canvas.handle,4*wCommon,0,SRCCOPY); 378 end; 379 end; 380 MarkUsedOffscreen(ClientWidth,ClientHeight); 381 HelpBtn.Top:=yTotal+22; 382 383 if Kind in [dkEnemyCityDefense,dkEnemyCity] then 379 i, j, x, y, cix, uix, emix, InProd, Available, Destroyed, Loc, Cnt, yView, 380 yTotal, yCaption: integer; 381 s: string; 382 ui: TUnitInfo; 383 mi: TModelInfo; 384 begin 385 inherited; 386 387 case Kind of 388 dkOwnModel: 389 begin 390 bitblt(offscreen.Canvas.Handle, 0, 0, wCommon, hOwnModel, 391 Back.Canvas.Handle, 0, 0, SRCCOPY); 392 yView := 13; 393 yTotal := 92; 394 end; 395 dkEnemyModel: 396 begin 397 bitblt(offscreen.Canvas.Handle, 0, 0, wCommon, hEnemyModel, 398 Back.Canvas.Handle, wCommon, 0, SRCCOPY); 399 yView := 13; 400 yTotal := 92; 401 end; 402 dkEnemyUnit, dkOwnUnit: 403 begin 404 bitblt(offscreen.Canvas.Handle, 0, 0, wCommon, hEnemyUnit, 405 Back.Canvas.Handle, 2 * wCommon, 0, SRCCOPY); 406 yView := 13; 407 yTotal := 123; 408 end; 409 dkEnemyCityDefense: 410 begin 411 bitblt(offscreen.Canvas.Handle, 0, 0, wCommon, hEnemyCityDefense, 412 Back.Canvas.Handle, 3 * wCommon, 0, SRCCOPY); 413 yView := 171; 414 yTotal := 231; 415 end; 416 dkEnemyCity: 417 begin 418 bitblt(offscreen.Canvas.Handle, 0, 0, wCommon, hEnemyCity, 419 Back.Canvas.Handle, 4 * wCommon, 0, SRCCOPY); 420 end; 421 end; 422 MarkUsedOffscreen(ClientWidth, ClientHeight); 423 HelpBtn.Top := yTotal + 22; 424 425 if Kind in [dkEnemyCityDefense, dkEnemyCity] then 384 426 begin // show city defense facilities 385 cnt:=0; 386 for i:=0 to 3 do 387 if MyRO.EnemyCity[ecixShow].Flags and (2 shl i)<>0 then 388 inc(cnt); 389 x:=(wCommon-cnt*xSizeSmall) div 2 -(cnt-1)*2; 390 for i:=0 to 3 do 391 if MyRO.EnemyCity[ecixShow].Flags and (2 shl i)<>0 then 392 begin 393 case i of 394 0: j:=imWalls; 395 1: j:=imCoastalFort; 396 2: j:=imMissileBat; 397 3: j:=imBunker 427 Cnt := 0; 428 for i := 0 to 3 do 429 if MyRO.EnemyCity[ecixShow].Flags and (2 shl i) <> 0 then 430 inc(Cnt); 431 x := (wCommon - Cnt * xSizeSmall) div 2 - (Cnt - 1) * 2; 432 for i := 0 to 3 do 433 if MyRO.EnemyCity[ecixShow].Flags and (2 shl i) <> 0 then 434 begin 435 case i of 436 0: 437 j := imWalls; 438 1: 439 j := imCoastalFort; 440 2: 441 j := imMissileBat; 442 3: 443 j := imBunker 398 444 end; 399 Frame(offscreen.Canvas,x-1,yImp-1,x+xSizeSmall,yImp+ySizeSmall, 400 MainTexture.clBevelLight,MainTexture.clBevelShade); 401 BitBlt(offscreen.Canvas.Handle,x,yImp,xSizeSmall,ySizeSmall, 402 SmallImp.Canvas.Handle,j mod 7*xSizeSmall, 403 (j+SystemIconLines*7) div 7*ySizeSmall,SRCCOPY); 404 inc(x,xSizeSmall+4) 405 end; 406 end; 407 408 if Kind=dkEnemyModel then 409 begin 410 PPicture:=@Tribe[mox.Owner].ModelPicture[mox.mix]; 411 Available:=0; 412 if G.Difficulty[me]=0 then // supervisor -- count stacked units too 413 for Loc:=0 to G.lx*G.ly-1 do 414 begin 415 if MyMap[Loc] and fUnit<>0 then 416 begin 417 Server(sGetUnits,me,Loc,Cnt); 418 for uix:=0 to Cnt-1 do 419 if IsToCount(MyRO.EnemyUn[MyRO.nEnemyUn+uix].emix) then 420 inc(Available); 445 Frame(offscreen.Canvas, x - 1, yImp - 1, x + xSizeSmall, 446 yImp + ySizeSmall, MainTexture.clBevelLight, 447 MainTexture.clBevelShade); 448 bitblt(offscreen.Canvas.Handle, x, yImp, xSizeSmall, ySizeSmall, 449 SmallImp.Canvas.Handle, j mod 7 * xSizeSmall, 450 (j + SystemIconLines * 7) div 7 * ySizeSmall, SRCCOPY); 451 inc(x, xSizeSmall + 4) 452 end; 453 end; 454 455 if Kind = dkEnemyModel then 456 begin 457 PPicture := @Tribe[mox.owner].ModelPicture[mox.mix]; 458 Available := 0; 459 if G.Difficulty[me] = 0 then // supervisor -- count stacked units too 460 for Loc := 0 to G.lx * G.ly - 1 do 461 begin 462 if MyMap[Loc] and fUnit <> 0 then 463 begin 464 Server(sGetUnits, me, Loc, Cnt); 465 for uix := 0 to Cnt - 1 do 466 if IsToCount(MyRO.EnemyUn[MyRO.nEnemyUn + uix].emix) then 467 inc(Available); 421 468 end 422 469 end 423 else // no supervisor -- can only count stack top units 424 for uix:=0 to MyRO.nEnemyUn-1 do 425 if (MyRO.EnemyUn[uix].Loc>=0) and IsToCount(MyRO.EnemyUn[uix].emix) then 470 else // no supervisor -- can only count stack top units 471 for uix := 0 to MyRO.nEnemyUn - 1 do 472 if (MyRO.EnemyUn[uix].Loc >= 0) and IsToCount(MyRO.EnemyUn[uix].emix) 473 then 474 inc(Available); 475 Destroyed := 0; 476 for emix := 0 to MyRO.nEnemyModel - 1 do 477 if IsToCount(emix) then 478 inc(Destroyed, MyRO.EnemyModel[emix].Lost); 479 end 480 else 481 begin 482 Available := 0; 483 for uix := 0 to MyRO.nUn - 1 do 484 if (MyUn[uix].Loc >= 0) and (MyUn[uix].mix = mixShow) then 426 485 inc(Available); 427 Destroyed:=0; 428 for emix:=0 to MyRO.nEnemyModel-1 do if IsToCount(emix) then 429 inc(Destroyed,MyRO.EnemyModel[emix].Lost); 430 end 431 else 432 begin 433 Available:=0; 434 for uix:=0 to MyRO.nUn-1 do 435 if (MyUn[uix].Loc>=0) and (MyUn[uix].mix=mixShow) then inc(Available); 436 InProd:=0; 437 for cix:=0 to MyRO.nCity-1 do 438 if (MyCity[cix].Loc>=0) and (MyCity[cix].Project and (cpImp+cpIndex)=mixShow) then 439 inc(InProd); 440 end; 441 442 offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 443 if Kind in [dkEnemyCityDefense,dkEnemyCity] then 444 begin 445 NoMap.SetOutput(offscreen); 446 NoMap.PaintCity(ClientWidth div 2,53,MyRO.EnemyCity[ecixShow],false); 447 448 s:=Tribe[MyRO.EnemyCity[ecixShow].Owner].TPhrase('UNITOWNER'); 449 LoweredTextOut(offscreen.Canvas, -1, MainTexture, 450 (ClientWidth-BiColorTextWidth(offscreen.Canvas,s)) div 2, 105, s); 451 end; 452 453 if Kind<>dkEnemyCity then 486 InProd := 0; 487 for cix := 0 to MyRO.nCity - 1 do 488 if (MyCity[cix].Loc >= 0) and 489 (MyCity[cix].Project and (cpImp + cpIndex) = mixShow) then 490 inc(InProd); 491 end; 492 493 offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 494 if Kind in [dkEnemyCityDefense, dkEnemyCity] then 495 begin 496 NoMap.SetOutput(offscreen); 497 NoMap.PaintCity(ClientWidth div 2, 53, MyRO.EnemyCity[ecixShow], false); 498 499 s := Tribe[MyRO.EnemyCity[ecixShow].owner].TPhrase('UNITOWNER'); 500 LoweredTextOut(offscreen.Canvas, -1, MainTexture, 501 (ClientWidth - BiColorTextWidth(offscreen.Canvas, s)) div 2, 105, s); 502 end; 503 504 if Kind <> dkEnemyCity then 454 505 begin // show unit stats 455 if Kind=dkOwnModel then456 MakeModelInfo(me,mixShow,MyModel[mixShow],mi)457 else if Kind=dkOwnUnit then506 if Kind = dkOwnModel then 507 MakeModelInfo(me, mixShow, MyModel[mixShow], mi) 508 else if Kind = dkOwnUnit then 458 509 begin 459 MakeUnitInfo(me,MyUn[uixShow],ui);460 MakeModelInfo(me,MyUn[uixShow].mix,MyModel[MyUn[uixShow].mix],mi)510 MakeUnitInfo(me, MyUn[uixShow], ui); 511 MakeModelInfo(me, MyUn[uixShow].mix, MyModel[MyUn[uixShow].mix], mi) 461 512 end 462 else513 else 463 514 begin 464 mi:=mox^;465 if Kind in [dkEnemyUnit,dkEnemyCityDefense] then466 ui:=MyRO.EnemyUn[euixShow]515 mi := mox^; 516 if Kind in [dkEnemyUnit, dkEnemyCityDefense] then 517 ui := MyRO.EnemyUn[euixShow] 467 518 end; 468 519 469 with Tribe[mi.Owner].ModelPicture[mi.mix] do520 with Tribe[mi.owner].ModelPicture[mi.mix] do 470 521 begin 471 if Kind in [dkOwnUnit,dkEnemyUnit,dkEnemyCityDefense] then with ui do 472 begin 473 {Frame(offscreen.canvas,xView-1,yView-1,xView+64,yView+48, 474 MainTexture.clBevelShade,MainTexture.clBevelLight); 475 RFrame(offscreen.canvas,xView-2,yView-2,xView+65,yView+49, 476 MainTexture.clBevelShade,MainTexture.clBevelLight);} 477 with offscreen.canvas do 478 begin 479 Brush.Color:=GrExt[HGrSystem].Data.Canvas.Pixels[98,67]; 480 offscreen.canvas.FillRect(Rect(xView,yView,xView+64,yView+16)); 481 Brush.Style:=bsClear; 522 if Kind in [dkOwnUnit, dkEnemyUnit, dkEnemyCityDefense] then 523 with ui do 524 begin 525 { Frame(offscreen.canvas,xView-1,yView-1,xView+64,yView+48, 526 MainTexture.clBevelShade,MainTexture.clBevelLight); 527 RFrame(offscreen.canvas,xView-2,yView-2,xView+65,yView+49, 528 MainTexture.clBevelShade,MainTexture.clBevelLight); } 529 with offscreen.Canvas do 530 begin 531 Brush.Color := GrExt[HGrSystem].Data.Canvas.Pixels[98, 67]; 532 offscreen.Canvas.FillRect(Rect(xView, yView, xView + 64, 533 yView + 16)); 534 Brush.Style := bsClear; 535 end; 536 537 if MyMap[Loc] and fTerrain >= fForest then 538 begin 539 x := 1 + 2 * (xxt * 2 + 1); 540 y := 1 + yyt + 2 * (yyt * 3 + 1) 541 end 542 else 543 begin 544 x := integer(MyMap[Loc] and fTerrain) * (xxt * 2 + 1) + 1; 545 y := 1 + yyt 546 end; 547 for j := -1 to 1 do 548 for i := -1 to 1 do 549 if (i + j) and 1 = 0 then 550 begin 551 Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2, 552 yyt * 2, x, y); 553 if MyMap[Loc] and (fTerrain or fSpecial) = fGrass or fSpecial1 554 then 555 Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2, yyt * 2, 556 1 + 2 * (xxt * 2 + 1), 1 + yyt + 1 * (yyt * 3 + 1)) 557 else if (MyMap[Loc] and fTerrain = fForest) and 558 IsJungle(Loc div G.lx) then 559 Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2, yyt * 2, 560 1 + 7 * (xxt * 2 + 1), 1 + yyt + 19 * (yyt * 3 + 1)) 561 else if MyMap[Loc] and fTerrain >= fForest then 562 Sprite(Buffer, HGrTerrain, i * xxt, j * yyt, xxt * 2, yyt * 2, 563 1 + 7 * (xxt * 2 + 1), 564 1 + yyt + 2 * integer(2 + MyMap[Loc] and fTerrain - fForest) 565 * (yyt * 3 + 1)); 566 end; 567 bitblt(offscreen.Canvas.Handle, xView, yView + 16, 64, 32, 568 Buffer.Canvas.Handle, 1, 0, SRCCOPY); 569 570 // show unit, experience and health 571 Sprite(offscreen, HGr, xView, yView, 64, 48, pix mod 10 * 65 + 1, 572 pix div 10 * 49 + 1); 573 if Flags and unFortified <> 0 then 574 Sprite(offscreen, HGrStdUnits, xView, yView, xxu * 2, yyu * 2, 575 1 + 6 * (xxu * 2 + 1), 1); 576 FrameImage(offscreen.Canvas, GrExt[HGrSystem].Data, xView - 20, 577 yView + 5, 12, 14, 121 + Exp div ExpCost * 13, 28); 578 if Health < 100 then 579 begin 580 s := IntToStr(Health) + '%'; 581 LightGradient(offscreen.Canvas, xView - 45, yView + 24, 38, 582 (ColorOfHealth(Health) and $FEFEFE shr 2) * 3); 583 RisedTextout(offscreen.Canvas, xView - 45 + 20 - 584 BiColorTextWidth(offscreen.Canvas, s) div 2, yView + 23, s); 585 end; 586 587 if Kind = dkEnemyUnit then 588 begin 589 s := Tribe[mox.owner].TPhrase('UNITOWNER'); 590 LoweredTextOut(offscreen.Canvas, -1, MainTexture, 591 (ClientWidth - BiColorTextWidth(offscreen.Canvas, s)) div 2, 592 yView + 80, s); 593 end 594 end 595 else 596 begin 597 FrameImage(offscreen.Canvas, BigImp, xView + 4, yView, 56, 40, 0, 0); 598 Sprite(offscreen, HGr, xView, yView - 4, 64, 44, pix mod 10 * 65 + 1, 599 pix div 10 * 49 + 1); 600 end; 601 602 DarkGradient(offscreen.Canvas, xTotal - 6, yTotal + 1, 180, 2); 603 RisedTextout(offscreen.Canvas, xTotal - 2, yTotal, 604 Phrases.Lookup('UNITSTRENGTH')); 605 s := IntToStr(mi.Attack) + '/' + IntToStr(mi.Defense); 606 RisedTextout(offscreen.Canvas, 607 xTotal + 170 - BiColorTextWidth(offscreen.Canvas, s), yTotal, s); 608 FeatureBar(offscreen, xTotal, yTotal + 19, mi, MainTexture); 609 NumberBarS(offscreen, xTotal, yTotal + 38, Phrases.Lookup('UNITSPEED'), 610 MovementToString(mi.Speed), MainTexture); 611 LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, yTotal + 57, 612 Phrases.Lookup('UNITCOST')); 613 DLine(offscreen.Canvas, xTotal - 2, xTotal + 170, yTotal + 57 + 16, 614 MainTexture.clBevelShade, MainTexture.clBevelLight); 615 if G.Difficulty[me] = 0 then 616 s := IntToStr(mi.cost) 617 else 618 s := IntToStr(mi.cost * BuildCostMod[G.Difficulty[me]] div 12); 619 RisedTextout(offscreen.Canvas, 620 xTotal + 159 - BiColorTextWidth(offscreen.Canvas, s), yTotal + 57, s); 621 Sprite(offscreen, HGrSystem, xTotal + 160, yTotal + 57 + 5, 10, 622 10, 88, 115); 623 624 if Kind = dkOwnModel then 625 begin 626 if MyModel[mixShow].IntroTurn > 0 then 627 begin 628 if MyModel[mixShow].Kind = mkEnemyDeveloped then 629 LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, 630 (yTotal + StatDown - 19), Phrases.Lookup('UNITADOPT')) 631 else 632 LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, 633 (yTotal + StatDown - 19), Phrases.Lookup('UNITINTRO')); 634 DLine(offscreen.Canvas, xTotal - 2, xTotal + 170, 635 (yTotal + StatDown - 19) + 16, MainTexture.clTextShade, 636 MainTexture.clTextLight); 637 s := TurnToString(MyModel[mixShow].IntroTurn); 638 RisedTextout(offscreen.Canvas, 639 xTotal + 170 - BiColorTextWidth(offscreen.Canvas, s), 640 (yTotal + StatDown - 19), s); 482 641 end; 483 642 484 if MyMap[Loc] and fTerrain>=fForest then 485 begin x:=1+2*(xxt*2+1); y:=1+yyt+2*(yyt*3+1) end 486 else begin x:=integer(MyMap[Loc] and fTerrain) *(xxt*2+1)+1; y:=1+yyt end; 487 for j:=-1 to 1 do for i:=-1 to 1 do if (i+j) and 1=0 then 488 begin 489 Sprite(Buffer,HGrTerrain,i*xxt,j*yyt,xxt*2,yyt*2,x,y); 490 if MyMap[Loc] and (fTerrain or fSpecial)=fGrass or fSpecial1 then 491 Sprite(Buffer,HGrTerrain,i*xxt,j*yyt,xxt*2,yyt*2,1+2*(xxt*2+1), 492 1+yyt+1*(yyt*3+1)) 493 else if (MyMap[Loc] and fTerrain=fForest) 494 and IsJungle(Loc div G.lx) then 495 Sprite(Buffer,HGrTerrain,i*xxt,j*yyt,xxt*2,yyt*2,1+7*(xxt*2+1), 496 1+yyt+19*(yyt*3+1)) 497 else if MyMap[Loc] and fTerrain>=fForest then 498 Sprite(Buffer,HGrTerrain,i*xxt,j*yyt,xxt*2,yyt*2,1+7*(xxt*2+1), 499 1+yyt+2*integer(2+MyMap[Loc] and fTerrain-fForest)*(yyt*3+1)); 643 NumberBar(offscreen, xTotal, yTotal + StatDown, 644 Phrases.Lookup('UNITBUILT'), MyModel[mixShow].Built, MainTexture); 645 if MyModel[mixShow].Lost > 0 then 646 NumberBar(offscreen, xTotal, yTotal + StatDown + 19, 647 Phrases.Lookup('UNITLOST'), MyModel[mixShow].Lost, MainTexture); 648 if InProd > 0 then 649 NumberBar(offscreen, xTotal, yTotal + StatDown + 57, 650 Phrases.Lookup('UNITINPROD'), InProd, MainTexture); 651 if Available > 0 then 652 NumberBar(offscreen, xTotal, yTotal + StatDown + 38, 653 Phrases.Lookup('UNITAVAILABLE'), Available, MainTexture); 654 655 if MyModel[mixShow].Status and msObsolete <> 0 then 656 begin 657 SwitchBtn.ButtonIndex := 12; 658 SwitchBtn.Hint := Phrases.Lookup('BTN_OBSOLETE'); 659 end 660 else 661 begin 662 SwitchBtn.ButtonIndex := 11; 663 SwitchBtn.Hint := Phrases.Lookup('BTN_NONOBSOLETE'); 500 664 end; 501 BitBlt(offscreen.canvas.handle,xView,yView+16,64,32,Buffer.Canvas.Handle,1,0, 502 SRCCOPY); 503 504 // show unit, experience and health 505 Sprite(offscreen,HGr,xView,yView,64,48,pix mod 10 *65+1,pix div 10*49+1); 506 if Flags and unFortified<>0 then 507 Sprite(offscreen,HGrStdUnits,xView,yView,xxu*2,yyu*2,1+6*(xxu*2+1),1); 508 FrameImage(offscreen.canvas,GrExt[HGrSystem].Data,xView-20,yView+5,12,14, 509 121+Exp div ExpCost *13,28); 510 if Health<100 then 511 begin 512 s:=IntToStr(Health)+'%'; 513 LightGradient(offscreen.canvas,xView-45,yView+24,38, 514 (ColorOfHealth(Health) and $FEFEFE shr 2)*3); 515 RisedTextOut(offscreen.canvas,xView-45+20-BiColorTextWidth(offscreen.Canvas,s) div 2, 516 yView+23,s); 517 end; 518 519 if Kind=dkEnemyUnit then 520 begin 521 s:=Tribe[mox.Owner].TPhrase('UNITOWNER'); 522 LoweredTextOut(offscreen.Canvas, -1, MainTexture, 523 (ClientWidth-BiColorTextWidth(offscreen.Canvas,s)) div 2, yView+80, s); 665 if MyModel[mixShow].Status and msAllowConscripts = 0 then 666 begin 667 ConscriptsBtn.ButtonIndex := 30; 668 ConscriptsBtn.Hint := Phrases.Lookup('BTN_NOCONSCRIPTS'); 669 end 670 else 671 begin 672 ConscriptsBtn.ButtonIndex := 29; 673 ConscriptsBtn.Hint := Phrases.Lookup('BTN_ALLOWCONSCRIPTS'); 524 674 end 525 675 end 526 else 527 begin 528 FrameImage(offscreen.canvas,BigImp,xView+4,yView,56,40,0,0); 529 Sprite(offscreen,HGr,xView,yView-4,64,44,pix mod 10 *65+1,pix div 10*49+1); 530 end; 531 532 DarkGradient(offscreen.Canvas,xTotal-6,yTotal+1,180,2); 533 RisedTextOut(offscreen.Canvas,xTotal-2,yTotal,Phrases.Lookup('UNITSTRENGTH')); 534 s:=IntToStr(mi.Attack)+'/'+IntToStr(mi.Defense); 535 RisedTextOut(offscreen.Canvas,xTotal+170-BiColorTextWidth(Offscreen.Canvas,s),yTotal,s); 536 FeatureBar(offscreen,xTotal,yTotal+19,mi,MainTexture); 537 NumberBarS(offscreen,xTotal,yTotal+38,Phrases.Lookup('UNITSPEED'),MovementToString(mi.Speed),MainTexture); 538 LoweredTextOut(offscreen.Canvas,-1,MainTexture,xTotal-2,yTotal+57,Phrases.Lookup('UNITCOST')); 539 DLine(offscreen.Canvas,xTotal-2,xTotal+170,yTotal+57+16, 540 MainTexture.clBevelShade,MainTexture.clBevelLight); 541 if G.Difficulty[me]=0 then s:=IntToStr(mi.cost) 542 else s:=IntToStr(mi.cost*BuildCostMod[G.Difficulty[me]] div 12); 543 RisedTextout(offscreen.Canvas,xTotal+159-BiColorTextWidth(Offscreen.Canvas,s),yTotal+57,s); 544 Sprite(offscreen,HGrSystem,xTotal+160,yTotal+57+5,10,10,88,115); 545 546 if Kind=dkOwnModel then 547 begin 548 if MyModel[mixShow].IntroTurn>0 then 549 begin 550 if MyModel[mixShow].Kind=mkEnemyDeveloped then 551 LoweredTextOut(offscreen.Canvas,-1,MainTexture,xTotal-2,(yTotal+StatDown-19),Phrases.Lookup('UNITADOPT')) 552 else LoweredTextOut(offscreen.Canvas,-1,MainTexture,xTotal-2,(yTotal+StatDown-19),Phrases.Lookup('UNITINTRO')); 553 DLine(offscreen.Canvas,xTotal-2,xTotal+170,(yTotal+StatDown-19)+16, 554 MainTexture.clTextShade,MainTexture.clTextLight); 555 s:=TurnToString(MyModel[mixShow].IntroTurn); 556 RisedTextOut(offscreen.Canvas,xTotal+170-BiColorTextWidth(Offscreen.Canvas,s),(yTotal+StatDown-19),s); 557 end; 558 559 NumberBar(offscreen,xTotal,yTotal+StatDown,Phrases.Lookup('UNITBUILT'),MyModel[mixShow].Built,MainTexture); 560 if MyModel[mixShow].Lost>0 then 561 NumberBar(offscreen,xTotal,yTotal+StatDown+19,Phrases.Lookup('UNITLOST'),MyModel[mixShow].Lost,MainTexture); 562 if InProd>0 then 563 NumberBar(offscreen,xTotal,yTotal+StatDown+57,Phrases.Lookup('UNITINPROD'),InProd,MainTexture); 564 if Available>0 then 565 NumberBar(offscreen,xTotal,yTotal+StatDown+38,Phrases.Lookup('UNITAVAILABLE'),Available,MainTexture); 566 567 if MyModel[mixShow].Status and msObsolete<>0 then 568 begin 569 SwitchBtn.ButtonIndex:=12; 570 SwitchBtn.Hint:=Phrases.Lookup('BTN_OBSOLETE'); 571 end 572 else 573 begin 574 SwitchBtn.ButtonIndex:=11; 575 SwitchBtn.Hint:=Phrases.Lookup('BTN_NONOBSOLETE'); 576 end; 577 if MyModel[mixShow].Status and msAllowConscripts=0 then 578 begin 579 ConscriptsBtn.ButtonIndex:=30; 580 ConscriptsBtn.Hint:=Phrases.Lookup('BTN_NOCONSCRIPTS'); 581 end 582 else 583 begin 584 ConscriptsBtn.ButtonIndex:=29; 585 ConscriptsBtn.Hint:=Phrases.Lookup('BTN_ALLOWCONSCRIPTS'); 586 end 587 end 588 else if Kind=dkEnemyModel then 589 begin 590 if Destroyed>0 then 591 NumberBar(offscreen,xTotal,yTotal+StatDown-19,Phrases.Lookup('UNITDESTROYED'),Destroyed,MainTexture); 592 if Available>0 then 593 NumberBar(offscreen,xTotal,yTotal+StatDown,Phrases.Lookup('UNITKNOWN'),Available,MainTexture); 676 else if Kind = dkEnemyModel then 677 begin 678 if Destroyed > 0 then 679 NumberBar(offscreen, xTotal, yTotal + StatDown - 19, 680 Phrases.Lookup('UNITDESTROYED'), Destroyed, MainTexture); 681 if Available > 0 then 682 NumberBar(offscreen, xTotal, yTotal + StatDown, 683 Phrases.Lookup('UNITKNOWN'), Available, MainTexture); 594 684 end 595 685 end; 596 686 end; 597 687 598 offscreen.Canvas.Font.Assign(UniFont[ftNormal]); 599 case Kind of 600 dkOwnModel,dkEnemyModel: yCaption:=yView+46; 601 dkEnemyUnit,dkOwnUnit: yCaption:=yView+54; 602 dkEnemyCityDefense,dkEnemyCity: yCaption:=79; 603 end; 604 RisedTextOut(offscreen.Canvas, (ClientWidth-BiColorTextWidth(offscreen.Canvas,caption)) div 2, yCaption, caption); 605 end; {OffscreenPaint} 688 offscreen.Canvas.Font.Assign(UniFont[ftNormal]); 689 case Kind of 690 dkOwnModel, dkEnemyModel: 691 yCaption := yView + 46; 692 dkEnemyUnit, dkOwnUnit: 693 yCaption := yView + 54; 694 dkEnemyCityDefense, dkEnemyCity: 695 yCaption := 79; 696 end; 697 RisedTextout(offscreen.Canvas, 698 (ClientWidth - BiColorTextWidth(offscreen.Canvas, Caption)) div 2, 699 yCaption, Caption); 700 end; { OffscreenPaint } 606 701 607 702 procedure TUnitStatDlg.ModelBoxChange(Sender: TObject); 608 703 begin 609 SmartUpdateContent704 SmartUpdateContent 610 705 end; 611 706 612 707 procedure TUnitStatDlg.SwitchBtnClick(Sender: TObject); 613 708 begin 614 MyModel[mixShow].Status:=MyModel[mixShow].Status xor msObsolete;615 if MyModel[mixShow].Status and msObsolete<>0 then616 begin 617 SwitchBtn.ButtonIndex:=12;618 SwitchBtn.Hint:=Phrases.Lookup('BTN_OBSOLETE');709 MyModel[mixShow].Status := MyModel[mixShow].Status xor msObsolete; 710 if MyModel[mixShow].Status and msObsolete <> 0 then 711 begin 712 SwitchBtn.ButtonIndex := 12; 713 SwitchBtn.Hint := Phrases.Lookup('BTN_OBSOLETE'); 619 714 end 620 else621 begin 622 SwitchBtn.ButtonIndex:=11;623 SwitchBtn.Hint:=Phrases.Lookup('BTN_NONOBSOLETE');715 else 716 begin 717 SwitchBtn.ButtonIndex := 11; 718 SwitchBtn.Hint := Phrases.Lookup('BTN_NONOBSOLETE'); 624 719 end 625 720 end; … … 627 722 procedure TUnitStatDlg.ConscriptsBtnClick(Sender: TObject); 628 723 begin 629 MyModel[mixShow].Status:=MyModel[mixShow].Status xor msAllowConscripts;630 if MyModel[mixShow].Status and msAllowConscripts=0 then631 begin 632 ConscriptsBtn.ButtonIndex:=30;633 ConscriptsBtn.Hint:=Phrases.Lookup('BTN_NOCONSCRIPTS');724 MyModel[mixShow].Status := MyModel[mixShow].Status xor msAllowConscripts; 725 if MyModel[mixShow].Status and msAllowConscripts = 0 then 726 begin 727 ConscriptsBtn.ButtonIndex := 30; 728 ConscriptsBtn.Hint := Phrases.Lookup('BTN_NOCONSCRIPTS'); 634 729 end 635 else636 begin 637 ConscriptsBtn.ButtonIndex:=29;638 ConscriptsBtn.Hint:=Phrases.Lookup('BTN_ALLOWCONSCRIPTS');730 else 731 begin 732 ConscriptsBtn.ButtonIndex := 29; 733 ConscriptsBtn.Hint := Phrases.Lookup('BTN_ALLOWCONSCRIPTS'); 639 734 end 640 735 end; … … 642 737 procedure TUnitStatDlg.HelpBtnClick(Sender: TObject); 643 738 begin 644 HelpDlg.ShowNewContent(wmPersistent, hkModel, 0)739 HelpDlg.ShowNewContent(wmPersistent, hkModel, 0) 645 740 end; 646 741 647 742 end. 648
Note:
See TracChangeset
for help on using the changeset viewer.