Changeset 447 for trunk/LocalPlayer/Draft.pas
- Timestamp:
- May 19, 2022, 10:39:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Draft.pas
r442 r447 20 20 procedure CloseBtnClick(Sender: TObject); 21 21 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 22 Shift: TShiftState; x, y: integer);22 Shift: TShiftState; X, Y: Integer); 23 23 procedure OKBtnClick(Sender: TObject); 24 24 procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; 25 Shift: TShiftState; x, y: integer);25 Shift: TShiftState; X, Y: Integer); 26 26 public 27 27 procedure ShowNewContent(NewMode: TWindowMode); … … 30 30 private 31 31 Domain, MaxLines, Lines, Cut, yDomain, yFeature, yWeight, yTotal, yView, 32 IncCap, DecCap: integer;33 code: array [0 .. nFeature - 1] of integer;32 IncCap, DecCap: Integer; 33 Code: array [0 .. nFeature - 1] of Integer; 34 34 Template, Back: TBitmap; 35 function IsFeatureInList( d, i: integer): boolean;36 procedure SetDomain( d: integer);35 function IsFeatureInList(D, I: Integer): Boolean; 36 procedure SetDomain(D: Integer); 37 37 end; 38 38 … … 108 108 procedure TDraftDlg.OffscreenPaint; 109 109 110 function DomainAvailable( d: integer): boolean;111 begin 112 result := (upgrade[d, 0].Preq = preNone) or113 (MyRO.Tech[upgrade[ d, 0].Preq] >= tsApplicable);110 function DomainAvailable(D: Integer): Boolean; 111 begin 112 Result := (upgrade[D, 0].Preq = preNone) or 113 (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable); 114 114 end; 115 115 116 116 procedure PaintTotalBars; 117 117 var 118 i, y, dx, num, w: integer;119 s: string;120 begin 121 with offscreen.Canvas do118 I, Y, dx, num, W: Integer; 119 S: string; 120 begin 121 with Offscreen.Canvas do 122 122 begin 123 123 // strength bar 124 y:= yTotal;125 DarkGradient( offscreen.Canvas, xTotal - 6, y+ 1, 184, 2);126 DarkGradient( offscreen.Canvas, xTotal2 + 172, y+ 1, 95, 2);127 RisedTextOut( offscreen.Canvas, xTotal - 2, y,124 Y := yTotal; 125 DarkGradient(Offscreen.Canvas, xTotal - 6, Y + 1, 184, 2); 126 DarkGradient(Offscreen.Canvas, xTotal2 + 172, Y + 1, 95, 2); 127 RisedTextOut(Offscreen.Canvas, xTotal - 2, Y, 128 128 Phrases.Lookup('UNITSTRENGTH')); 129 RisedTextOut( offscreen.Canvas, xTotal + 112 + 30, y,129 RisedTextOut(Offscreen.Canvas, xTotal + 112 + 30, Y, 130 130 'x' + IntToStr(MyRO.DevModel.MStrength)); 131 RisedTextOut( offscreen.Canvas, xTotal2 + 148 + 30, y, '=');132 s:= IntToStr(MyRO.DevModel.Attack) + '/' +131 RisedTextOut(Offscreen.Canvas, xTotal2 + 148 + 30, Y, '='); 132 S := IntToStr(MyRO.DevModel.Attack) + '/' + 133 133 IntToStr(MyRO.DevModel.Defense); 134 RisedTextOut( offscreen.Canvas, xTotal2 + 170 + 64 + 30 -135 BiColorTextWidth( offscreen.Canvas, s), y, s);134 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 135 BiColorTextWidth(Offscreen.Canvas, S), Y, S); 136 136 137 137 // transport bar 138 138 if MyRO.DevModel.MTrans > 0 then 139 139 begin 140 y:= yTotal + 19;141 DarkGradient( offscreen.Canvas, xTotal - 6, y+ 1, 184, 1);142 DarkGradient( offscreen.Canvas, xTotal2 + 172, y+ 1, 95, 1);143 RisedTextOut( offscreen.Canvas, xTotal - 2, y,140 Y := yTotal + 19; 141 DarkGradient(Offscreen.Canvas, xTotal - 6, Y + 1, 184, 1); 142 DarkGradient(Offscreen.Canvas, xTotal2 + 172, Y + 1, 95, 1); 143 RisedTextOut(Offscreen.Canvas, xTotal - 2, Y, 144 144 Phrases.Lookup('UNITTRANSPORT')); 145 RisedTextOut( offscreen.Canvas, xTotal + 112 + 30, y,145 RisedTextOut(Offscreen.Canvas, xTotal + 112 + 30, Y, 146 146 'x' + IntToStr(MyRO.DevModel.MTrans)); 147 RisedTextOut( offscreen.Canvas, xTotal2 + 148 + 30, y, '=');147 RisedTextOut(Offscreen.Canvas, xTotal2 + 148 + 30, Y, '='); 148 148 149 149 Font.Color := $000000; 150 150 dx := -237 - 30; 151 for i:= mcFirstNonCap - 1 downto 3 do152 if iin [mcSeaTrans, mcCarrier, mcAirTrans] then151 for I := mcFirstNonCap - 1 downto 3 do 152 if I in [mcSeaTrans, mcCarrier, mcAirTrans] then 153 153 begin 154 num := MyRO.DevModel.Cap[ i] * MyRO.DevModel.MTrans;154 num := MyRO.DevModel.Cap[I] * MyRO.DevModel.MTrans; 155 155 if num > 0 then 156 156 begin 157 inc(dx, 15);157 Inc(dx, 15); 158 158 Brush.Color := $C0C0C0; 159 FrameRect(Rect(xTotal2 - 3 - dx, y+ 2,160 xTotal2 + 11 - dx, y+ 16));159 FrameRect(Rect(xTotal2 - 3 - dx, Y + 2, 160 xTotal2 + 11 - dx, Y + 16)); 161 161 Brush.Style := bsClear; 162 Sprite( offscreen, HGrSystem, xTotal2 - 1 - dx, y+ 4, 10, 10,163 66 + i mod 11 * 11, 137 + idiv 11 * 11);162 Sprite(Offscreen, HGrSystem, xTotal2 - 1 - dx, Y + 4, 10, 10, 163 66 + I mod 11 * 11, 137 + I div 11 * 11); 164 164 if num > 1 then 165 165 begin 166 s:= IntToStr(num);167 w := TextWidth(s);168 inc(dx, w+ 1);166 S := IntToStr(num); 167 W := TextWidth(S); 168 Inc(dx, W + 1); 169 169 Brush.Color := $FFFFFF; 170 FillRect(Rect(xTotal2 - 3 - dx, y+ 2,171 xTotal2 + w - 1 - dx, y+ 16));170 FillRect(Rect(xTotal2 - 3 - dx, Y + 2, 171 xTotal2 + W - 1 - dx, Y + 16)); 172 172 Brush.Style := bsClear; 173 Textout(xTotal2 - 3 - dx + 1, y, s);173 Textout(xTotal2 - 3 - dx + 1, Y, S); 174 174 end; 175 175 end; … … 178 178 179 179 // speed bar 180 y:= yTotal + 38;181 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal - 2, y,180 Y := yTotal + 38; 181 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y, 182 182 Phrases.Lookup('UNITSPEED')); 183 DLine( offscreen.Canvas, xTotal - 2, xTotal + 174, y+ 16,183 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16, 184 184 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 185 DLine( offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y+ 16,185 DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16, 186 186 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 187 s:= MovementToString(MyRO.DevModel.Speed);188 RisedTextOut( offscreen.Canvas, xTotal2 + 170 + 64 + 30 -189 TextWidth( s), y, s);187 S := MovementToString(MyRO.DevModel.Speed); 188 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 189 TextWidth(S), Y, S); 190 190 191 191 // cost bar 192 y:= yTotal + 57;193 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal - 2, y,192 Y := yTotal + 57; 193 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y, 194 194 Phrases.Lookup('UNITCOST')); 195 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal + 112 + 30, y,195 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal + 112 + 30, Y, 196 196 'x' + IntToStr(MyRO.DevModel.MCost)); 197 LoweredTextOut( offscreen.Canvas, -1, MainTexture,198 xTotal2 + 148 + 30, y, '=');199 DLine( offscreen.Canvas, xTotal - 2, xTotal + 174, y+ 16,197 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, 198 xTotal2 + 148 + 30, Y, '='); 199 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16, 200 200 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 201 DLine( offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y+ 16,201 DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16, 202 202 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 203 s:= IntToStr(MyRO.DevModel.Cost);204 RisedTextOut( offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -205 TextWidth( s), y, s);206 Sprite( offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, y+ 4, 10,203 S := IntToStr(MyRO.DevModel.Cost); 204 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 - 205 TextWidth(S), Y, S); 206 Sprite(Offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, Y + 4, 10, 207 207 10, 88, 115); 208 208 209 if G.Difficulty[ me] <> 2 then209 if G.Difficulty[Me] <> 2 then 210 210 begin // corrected cost bar 211 y:= yTotal + 76;212 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xTotal - 2, y,213 Phrases.Lookup('COSTDIFF' + char(48 + G.Difficulty[ me])));214 LoweredTextOut( offscreen.Canvas, -1, MainTexture,215 xTotal2 + 148 + 30, y, '=');216 DLine( offscreen.Canvas, xTotal - 2, xTotal + 174, y+ 16,211 Y := yTotal + 76; 212 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y, 213 Phrases.Lookup('COSTDIFF' + char(48 + G.Difficulty[Me]))); 214 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, 215 xTotal2 + 148 + 30, Y, '='); 216 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16, 217 217 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 218 DLine( offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y+ 16,218 DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16, 219 219 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 220 s:= IntToStr(MyRO.DevModel.Cost * BuildCostMod221 [G.Difficulty[ me]] div 12);222 RisedTextOut( offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -223 TextWidth( s), y, s);224 Sprite( offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, y+ 4, 10,220 S := IntToStr(MyRO.DevModel.Cost * BuildCostMod 221 [G.Difficulty[Me]] div 12); 222 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 - 223 TextWidth(S), Y, S); 224 Sprite(Offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, Y + 4, 10, 225 225 10, 88, 115); 226 226 end; … … 229 229 230 230 var 231 i, j, x, d, n, TextColor, CapWeight, DomainCount: integer;231 I, J, X, D, N, TextColor, CapWeight, DomainCount: Integer; 232 232 begin 233 233 inherited; … … 253 253 Template.Height - 64 - Cut); 254 254 255 BitBltCanvas( offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,255 BitBltCanvas(Offscreen.Canvas, 0, 0, ClientWidth, ClientHeight, 256 256 Back.Canvas, 0, 0); 257 257 258 offscreen.Canvas.Font.Assign(UniFont[ftCaption]);259 RisedTextOut( offscreen.Canvas, 10, 7, Caption);260 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);258 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]); 259 RisedTextOut(Offscreen.Canvas, 10, 7, Caption); 260 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 261 261 262 262 with MyRO.DevModel do 263 263 begin 264 264 DomainCount := 0; 265 for d:= 0 to nDomains - 1 do266 if DomainAvailable( d) then267 inc(DomainCount);265 for D := 0 to nDomains - 1 do 266 if DomainAvailable(D) then 267 Inc(DomainCount); 268 268 if DomainCount > 1 then 269 269 begin 270 for d:= 0 to nDomains - 1 do271 if DomainAvailable( d) then270 for D := 0 to nDomains - 1 do 271 if DomainAvailable(D) then 272 272 begin 273 x := xDomain + d* DomainPitch;274 if d= Domain then275 ImageOp_BCC( offscreen, Templates.Data, x, yDomain, 142, 246 + 37 * d, 36,273 X := xDomain + D * DomainPitch; 274 if D = Domain then 275 ImageOp_BCC(Offscreen, Templates.Data, X, yDomain, 142, 246 + 37 * D, 36, 276 276 36, 0, $00C0FF) 277 277 else 278 ImageOp_BCC( offscreen, Templates.Data, x, yDomain, 142, 246 + 37 * d, 36,278 ImageOp_BCC(Offscreen, Templates.Data, X, yDomain, 142, 246 + 37 * D, 36, 279 279 36, 0, $606060); 280 280 end; 281 Frame( offscreen.Canvas, xDomain - 11, yDomain - 3,281 Frame(Offscreen.Canvas, xDomain - 11, yDomain - 3, 282 282 xDomain + 2 * DomainPitch + 46, yDomain + 38, $B0B0B0, $FFFFFF); 283 RFrame( offscreen.Canvas, xDomain - 12, yDomain - 4,283 RFrame(Offscreen.Canvas, xDomain - 12, yDomain - 4, 284 284 xDomain + 2 * DomainPitch + 47, yDomain + 39, $FFFFFF, $B0B0B0); 285 285 end; … … 294 294 295 295 // display weight 296 with offscreen.Canvas do297 begin 298 for i:= 0 to MaxWeight - 1 do299 if i< Weight then300 ImageOp_BCC( offscreen, Templates.Data, Point(xWeight + 20 * i, yWeight),296 with Offscreen.Canvas do 297 begin 298 for I := 0 to MaxWeight - 1 do 299 if I < Weight then 300 ImageOp_BCC(Offscreen, Templates.Data, Point(xWeight + 20 * I, yWeight), 301 301 WeightOn.BoundsRect, 0, $949494) 302 302 else 303 ImageOp_BCC( offscreen, Templates.Data, Point(xWeight + 20 * i, yWeight),303 ImageOp_BCC(Offscreen, Templates.Data, Point(xWeight + 20 * I, yWeight), 304 304 WeightOff.BoundsRect, 0, $949494); 305 305 end; 306 306 307 with offscreen.Canvas do308 for i:= 0 to Lines - 1 do307 with Offscreen.Canvas do 308 for I := 0 to Lines - 1 do 309 309 begin 310 if not( code[i] in AutoFeature) then310 if not(Code[I] in AutoFeature) then 311 311 begin 312 312 // paint +/- butttons 313 if code[i] < mcFirstNonCap then313 if Code[I] < mcFirstNonCap then 314 314 begin 315 Dump( offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *316 i, 12, 12, 169, 172);317 Dump( offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *318 i, 12, 12, 169, 159);319 RFrame( offscreen.Canvas, xFeature - (21 + 1),320 yFeature + 2 + LinePitch * i- 1, xFeature - (21 - 24),321 yFeature + 2 + LinePitch * i+ 12, MainTexture.ColorBevelShade,315 Dump(Offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch * 316 I, 12, 12, 169, 172); 317 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch * 318 I, 12, 12, 169, 159); 319 RFrame(Offscreen.Canvas, xFeature - (21 + 1), 320 yFeature + 2 + LinePitch * I - 1, xFeature - (21 - 24), 321 yFeature + 2 + LinePitch * I + 12, MainTexture.ColorBevelShade, 322 322 MainTexture.ColorBevelLight); 323 323 end 324 324 else 325 325 begin 326 Dump( offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *327 i, 12, 12, 169, 185 + 13 * MyRO.DevModel.Cap[code[i]]);328 RFrame( offscreen.Canvas, xFeature - (9 + 1),329 yFeature + 2 + LinePitch * i- 1, xFeature - (21 - 24),330 yFeature + 2 + LinePitch * i+ 12, MainTexture.ColorBevelShade,326 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch * 327 I, 12, 12, 169, 185 + 13 * MyRO.DevModel.Cap[Code[I]]); 328 RFrame(Offscreen.Canvas, xFeature - (9 + 1), 329 yFeature + 2 + LinePitch * I - 1, xFeature - (21 - 24), 330 yFeature + 2 + LinePitch * I + 12, MainTexture.ColorBevelShade, 331 331 MainTexture.ColorBevelLight); 332 332 end; 333 333 334 334 // paint cost 335 LightGradient( offscreen.Canvas, xFeature + 34,336 yFeature + LinePitch * i, 50, HGrSystem.Data.Canvas.Pixels335 LightGradient(Offscreen.Canvas, xFeature + 34, 336 yFeature + LinePitch * I, 50, HGrSystem.Data.Canvas.Pixels 337 337 [187, 137]); 338 if (Domain = dGround) and ( code[i] = mcDefense) then338 if (Domain = dGround) and (Code[I] = mcDefense) then 339 339 CapWeight := 2 340 340 else 341 CapWeight := Feature[ code[i]].Weight;342 n := CapWeight + Feature[code[i]].Cost;343 d:= 6;344 while ( n - 1) * d* 2 > 48 - 10 do345 dec(d);346 for j := 0 to n- 1 do347 if j< CapWeight then348 Sprite( offscreen, HGrSystem, xFeature + 54 + (j * 2 + 1 - n) * d,349 yFeature + 2 + LinePitch * i+ 1, 10, 10, 88, 126)341 CapWeight := Feature[Code[I]].Weight; 342 N := CapWeight + Feature[Code[I]].Cost; 343 D := 6; 344 while (N - 1) * D * 2 > 48 - 10 do 345 Dec(D); 346 for J := 0 to N - 1 do 347 if J < CapWeight then 348 Sprite(Offscreen, HGrSystem, xFeature + 54 + (J * 2 + 1 - N) * D, 349 yFeature + 2 + LinePitch * I + 1, 10, 10, 88, 126) 350 350 else 351 Sprite( offscreen, HGrSystem, xFeature + 54 + (j * 2 + 1 - n) * d,352 yFeature + 2 + LinePitch * i+ 1, 10, 10, 88, 115);351 Sprite(Offscreen, HGrSystem, xFeature + 54 + (J * 2 + 1 - N) * D, 352 yFeature + 2 + LinePitch * I + 1, 10, 10, 88, 115); 353 353 end; // if not (code[i] in AutoFeature) 354 DarkGradient( offscreen.Canvas, xFeature + 17,355 yFeature + LinePitch * i, 16, 1);356 ScreenTools.Frame( offscreen.Canvas, xFeature + 18, yFeature + 1 + LinePitch * i,357 xFeature + 20 - 2 + 13, yFeature + 2 + 1 - 2 + 13 + LinePitch * i,354 DarkGradient(Offscreen.Canvas, xFeature + 17, 355 yFeature + LinePitch * I, 16, 1); 356 ScreenTools.Frame(Offscreen.Canvas, xFeature + 18, yFeature + 1 + LinePitch * I, 357 xFeature + 20 - 2 + 13, yFeature + 2 + 1 - 2 + 13 + LinePitch * I, 358 358 $C0C0C0, $C0C0C0); 359 Sprite( offscreen, HGrSystem, xFeature + 20, yFeature + 2 + 1 + LinePitch360 * i, 10, 10, 66 + code[i] mod 11 * 11, 137 + code[i] div 11 * 11);361 362 if MyRO.DevModel.Cap[ code[i]] > 0 then359 Sprite(Offscreen, HGrSystem, xFeature + 20, yFeature + 2 + 1 + LinePitch 360 * I, 10, 10, 66 + Code[I] mod 11 * 11, 137 + Code[I] div 11 * 11); 361 362 if MyRO.DevModel.Cap[Code[I]] > 0 then 363 363 TextColor := MainTexture.ColorLitText 364 364 else 365 365 TextColor := -1; 366 366 367 if code[i] < mcFirstNonCap then368 LoweredTextOut( offscreen.Canvas, TextColor, MainTexture, xFeature + 7,369 yFeature + LinePitch * i - 1, IntToStr(MyRO.DevModel.Cap[code[i]]));370 LoweredTextOut( offscreen.Canvas, TextColor, MainTexture, xFeature + 88,371 yFeature + LinePitch * i - 1, Phrases.Lookup('FEATURES', code[i]));367 if Code[I] < mcFirstNonCap then 368 LoweredTextOut(Offscreen.Canvas, TextColor, MainTexture, xFeature + 7, 369 yFeature + LinePitch * I - 1, IntToStr(MyRO.DevModel.Cap[Code[I]])); 370 LoweredTextOut(Offscreen.Canvas, TextColor, MainTexture, xFeature + 88, 371 yFeature + LinePitch * I - 1, Phrases.Lookup('FEATURES', Code[I])); 372 372 end; 373 373 end; 374 374 375 375 // free features 376 j:= 0;377 for i:= 0 to nFeature - 1 do378 if ( i in AutoFeature) and (1 shl Domain and Feature[i].Domains <> 0) and379 (Feature[ i].Preq <> preNA) and380 ((Feature[ i].Preq = preSun) and (MyRO.Wonder[woSun].EffectiveOwner = me)381 or (Feature[ i].Preq >= 0) and (MyRO.Tech[Feature[i].Preq] >= tsApplicable)382 ) and not((Feature[ i].Preq = adSteamEngine) and376 J := 0; 377 for I := 0 to nFeature - 1 do 378 if (I in AutoFeature) and (1 shl Domain and Feature[I].Domains <> 0) and 379 (Feature[I].Preq <> preNA) and 380 ((Feature[I].Preq = preSun) and (MyRO.Wonder[woSun].EffectiveOwner = Me) 381 or (Feature[I].Preq >= 0) and (MyRO.Tech[Feature[I].Preq] >= tsApplicable) 382 ) and not((Feature[I].Preq = adSteamEngine) and 383 383 (MyRO.Tech[adNuclearPower] >= tsApplicable)) then 384 384 begin 385 DarkGradient( offscreen.Canvas, xWeight + 4, yWeight + 32 + LinePitch386 * j, 16, 1);387 Frame( offscreen.Canvas, xWeight + 5, yWeight + 33 + LinePitch * j,388 xWeight + 18, yWeight + 47 + LinePitch * j, $C0C0C0, $C0C0C0);389 Sprite( offscreen, HGrSystem, xWeight + 7, yWeight + 36 + LinePitch * j,390 10, 10, 66 + i mod 11 * 11, 137 + idiv 11 * 11);391 LoweredTextOut( offscreen.Canvas, -1, MainTexture, xWeight + 26,392 yWeight + 31 + LinePitch * j, Phrases.Lookup('FEATURES', i));393 inc(j);394 end; 395 396 with Tribe[ me].ModelPicture[MyRO.nModel] do397 begin 398 FrameImage( offscreen.Canvas, BigImp, xView + 4, yView + 4, xSizeBig,385 DarkGradient(Offscreen.Canvas, xWeight + 4, yWeight + 32 + LinePitch 386 * J, 16, 1); 387 Frame(Offscreen.Canvas, xWeight + 5, yWeight + 33 + LinePitch * J, 388 xWeight + 18, yWeight + 47 + LinePitch * J, $C0C0C0, $C0C0C0); 389 Sprite(Offscreen, HGrSystem, xWeight + 7, yWeight + 36 + LinePitch * J, 390 10, 10, 66 + I mod 11 * 11, 137 + I div 11 * 11); 391 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xWeight + 26, 392 yWeight + 31 + LinePitch * J, Phrases.Lookup('FEATURES', I)); 393 Inc(J); 394 end; 395 396 with Tribe[Me].ModelPicture[MyRO.nModel] do 397 begin 398 FrameImage(Offscreen.Canvas, BigImp, xView + 4, yView + 4, xSizeBig, 399 399 ySizeBig, 0, 0); 400 Sprite( offscreen, HGr, xView, yView, 64, 44, pix mod 10 * 65 + 1,400 Sprite(Offscreen, HGr, xView, yView, 64, 44, pix mod 10 * 65 + 1, 401 401 pix div 10 * 49 + 1); 402 402 end; … … 404 404 end; 405 405 406 procedure TDraftDlg.SetDomain( d: integer);407 408 function Prio(fix: integer): integer;406 procedure TDraftDlg.SetDomain(D: Integer); 407 408 function Prio(fix: Integer): Integer; 409 409 var 410 FeaturePreq: integer;410 FeaturePreq: Integer; 411 411 begin 412 412 FeaturePreq := Feature[fix].Preq; 413 assert(FeaturePreq <> preNA);413 Assert(FeaturePreq <> preNA); 414 414 if fix < mcFirstNonCap then 415 result := 10000 + fix415 Result := 10000 + fix 416 416 else if FeaturePreq = preNone then 417 result := 20000417 Result := 20000 418 418 else if FeaturePreq < 0 then 419 result := 40000419 Result := 40000 420 420 else 421 result := 30000 + AdvValue[FeaturePreq];421 Result := 30000 + AdvValue[FeaturePreq]; 422 422 if not(fix in AutoFeature) then 423 inc(result, 90000);423 Inc(Result, 90000); 424 424 end; 425 425 426 426 var 427 i, j, x: integer;428 begin 429 Domain := d;427 I, J, X: Integer; 428 begin 429 Domain := D; 430 430 Lines := 0; 431 for i:= 0 to nFeature - 1 do432 if IsFeatureInList(Domain, i) then433 begin 434 code[Lines] := i;435 inc(Lines);431 for I := 0 to nFeature - 1 do 432 if IsFeatureInList(Domain, I) then 433 begin 434 Code[Lines] := I; 435 Inc(Lines); 436 436 end; 437 437 yFeature := yFeature0 + (MaxLines - Lines) * LinePitch div 2; 438 438 439 439 // sort features 440 for i:= 0 to Lines - 2 do441 for j := i+ 1 to Lines - 1 do442 if Prio( code[i]) > Prio(code[j]) then440 for I := 0 to Lines - 2 do 441 for J := I + 1 to Lines - 1 do 442 if Prio(Code[I]) > Prio(Code[J]) then 443 443 begin // exchange 444 x := code[i];445 code[i] := code[j];446 code[j] := x;444 X := Code[I]; 445 Code[I] := Code[J]; 446 Code[J] := X; 447 447 end; 448 448 end; 449 449 450 function TDraftDlg.IsFeatureInList( d, i: integer): boolean;451 begin 452 result := not(i in AutoFeature) and (1 shl d and Feature[i].Domains <> 0) and453 (Feature[ i].Preq <> preNA) and454 ((Feature[ i].Preq = preNone) or (Feature[i].Preq = preSun) and455 (MyRO.Wonder[woSun].EffectiveOwner = me) or (Feature[i].Preq >= 0) and456 (MyRO.Tech[Feature[ i].Preq] >= tsApplicable));450 function TDraftDlg.IsFeatureInList(D, I: Integer): Boolean; 451 begin 452 Result := not(I in AutoFeature) and (1 shl D and Feature[I].Domains <> 0) and 453 (Feature[I].Preq <> preNA) and 454 ((Feature[I].Preq = preNone) or (Feature[I].Preq = preSun) and 455 (MyRO.Wonder[woSun].EffectiveOwner = Me) or (Feature[I].Preq >= 0) and 456 (MyRO.Tech[Feature[I].Preq] >= tsApplicable)); 457 457 end; 458 458 459 459 procedure TDraftDlg.FormShow(Sender: TObject); 460 460 var 461 count, d, i: integer;461 count, D, I: Integer; 462 462 begin 463 463 Domain := dGround; 464 464 while (Domain < dAir) and (upgrade[Domain, 0].Preq <> preNone) and 465 465 (MyRO.Tech[upgrade[Domain, 0].Preq] < tsApplicable) do 466 inc(Domain);466 Inc(Domain); 467 467 468 468 // count max number of features in any domain 469 469 MaxLines := 0; 470 for d:= 0 to nDomains - 1 do471 if (upgrade[ d, 0].Preq = preNone) or472 (MyRO.Tech[upgrade[ d, 0].Preq] >= tsApplicable) then470 for D := 0 to nDomains - 1 do 471 if (upgrade[D, 0].Preq = preNone) or 472 (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable) then 473 473 begin 474 474 count := 0; 475 for i:= 0 to nFeature - 1 do476 if IsFeatureInList( d, i) then477 inc(count);475 for I := 0 to nFeature - 1 do 476 if IsFeatureInList(D, I) then 477 Inc(count); 478 478 if count > MaxLines then 479 479 MaxLines := count; … … 493 493 494 494 SetDomain(Domain); 495 Server(sCreateDevModel, me, Domain, nil^);495 Server(sCreateDevModel, Me, Domain, nil^); 496 496 MyModel[MyRO.nModel] := MyRO.DevModel; 497 InitMyModel(MyRO.nModel, false);497 InitMyModel(MyRO.nModel, False); 498 498 OffscreenPaint; 499 499 IncCap := -1; … … 507 507 508 508 procedure TDraftDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 509 Shift: TShiftState; x, y: integer);509 Shift: TShiftState; X, Y: Integer); 510 510 var 511 i, d: integer;511 I, D: Integer; 512 512 begin 513 513 if Button = mbLeft then 514 514 begin 515 for d:= 0 to nDomains - 1 do516 if ( d <> Domain) and ((upgrade[d, 0].Preq = preNone) or517 (MyRO.Tech[upgrade[ d, 0].Preq] >= tsApplicable)) and518 ( x >= xDomain + d* DomainPitch) and519 ( x < xDomain + d * DomainPitch + 36) and (y>= yDomain) and520 ( y< yDomain + 36) then515 for D := 0 to nDomains - 1 do 516 if (D <> Domain) and ((upgrade[D, 0].Preq = preNone) or 517 (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable)) and 518 (X >= xDomain + D * DomainPitch) and 519 (X < xDomain + D * DomainPitch + 36) and (Y >= yDomain) and 520 (Y < yDomain + 36) then 521 521 begin 522 SetDomain( d);523 Server(sCreateDevModel, me, Domain, nil^);522 SetDomain(D); 523 Server(sCreateDevModel, Me, Domain, nil^); 524 524 MyModel[MyRO.nModel] := MyRO.DevModel; 525 InitMyModel(MyRO.nModel, false);525 InitMyModel(MyRO.nModel, False); 526 526 SmartUpdateContent; 527 527 end; 528 528 529 if ( y >= yFeature) and (y< yFeature + LinePitch * Lines) then530 begin 531 i := (y- yFeature) div LinePitch;532 if ( x >= xFeature - 21) and (x< ClientWidth) and (ssShift in Shift) then533 HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkFeature, code[i])534 else if not( code[i] in AutoFeature) then529 if (Y >= yFeature) and (Y < yFeature + LinePitch * Lines) then 530 begin 531 I := (Y - yFeature) div LinePitch; 532 if (X >= xFeature - 21) and (X < ClientWidth) and (ssShift in Shift) then 533 HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkFeature, Code[I]) 534 else if not(Code[I] in AutoFeature) then 535 535 begin 536 if ( code[i] < mcFirstNonCap) and (x>= xFeature - 21) and537 ( x< xFeature - 21 + 12) then536 if (Code[I] < mcFirstNonCap) and (X >= xFeature - 21) and 537 (X < xFeature - 21 + 12) then 538 538 begin 539 IncCap := code[i];540 Dump( offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *541 i, 12, 12, 182, 172);539 IncCap := Code[I]; 540 Dump(Offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch * 541 I, 12, 12, 182, 172); 542 542 SmartInvalidate; 543 543 end 544 else if ( x >= xFeature - 9) and (x< xFeature - 9 + 12) then544 else if (X >= xFeature - 9) and (X < xFeature - 9 + 12) then 545 545 begin 546 DecCap := code[i];547 if code[i] < mcFirstNonCap then548 Dump( offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *549 i, 12, 12, 182, 159)546 DecCap := Code[I]; 547 if Code[I] < mcFirstNonCap then 548 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch * 549 I, 12, 12, 182, 159) 550 550 else 551 Dump( offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *552 i, 12, 12, 182, 185 + 13 * MyRO.DevModel.Cap[code[i]]);551 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch * 552 I, 12, 12, 182, 185 + 13 * MyRO.DevModel.Cap[Code[I]]); 553 553 SmartInvalidate; 554 554 end; … … 559 559 560 560 procedure TDraftDlg.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; 561 Shift: TShiftState; x, y: integer);561 Shift: TShiftState; X, Y: Integer); 562 562 var 563 NewValue: integer;563 NewValue: Integer; 564 564 begin 565 565 if IncCap >= 0 then 566 566 begin 567 567 NewValue := MyRO.DevModel.Cap[IncCap] + 1; 568 Server(sSetDevModelCap + NewValue shl 4, me, IncCap, nil^);568 Server(sSetDevModelCap + NewValue shl 4, Me, IncCap, nil^); 569 569 MyModel[MyRO.nModel] := MyRO.DevModel; 570 InitMyModel(MyRO.nModel, false);570 InitMyModel(MyRO.nModel, False); 571 571 SmartUpdateContent; 572 572 IncCap := -1; … … 579 579 if DecCap >= mcFirstNonCap then 580 580 NewValue := -NewValue; 581 Server(sSetDevModelCap + NewValue shl 4, me, DecCap, nil^);581 Server(sSetDevModelCap + NewValue shl 4, Me, DecCap, nil^); 582 582 MyModel[MyRO.nModel] := MyRO.DevModel; 583 InitMyModel(MyRO.nModel, false);583 InitMyModel(MyRO.nModel, False); 584 584 end; 585 585 SmartUpdateContent;
Note:
See TracChangeset
for help on using the changeset viewer.