source: tags/1.3.8/LocalPlayer/Draft.pas

Last change on this file was 684, checked in by chronos, 13 days ago
  • Modified: Improved forms painting if resized to bigger dimensions.
File size: 20.2 KB
Line 
1{$INCLUDE Switches.inc}
2unit Draft;
3
4interface
5
6uses
7 Protocol, ClientTools, ScreenTools, BaseWin, LCLIntf, LCLType, SysUtils,
8 Classes, ButtonA, ButtonB, Area,
9 {$IFDEF DPI}Dpi.Graphics, Dpi.Controls, Dpi.Forms, Dpi.ExtCtrls,
10 System.UITypes{$ELSE}
11 Graphics, Controls, Forms, ExtCtrls{$ENDIF};
12
13type
14
15 { TDraftDlg }
16
17 TDraftDlg = class(TBufferedDrawDlg)
18 OKBtn: TButtonA;
19 CloseBtn: TButtonB;
20 GroundArea: TArea;
21 SeaArea: TArea;
22 AirArea: TArea;
23 procedure FormCreate(Sender: TObject);
24 procedure FormDestroy(Sender: TObject);
25 procedure FormShow(Sender: TObject);
26 procedure CloseBtnClick(Sender: TObject);
27 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
28 Shift: TShiftState; X, Y: Integer);
29 procedure OKBtnClick(Sender: TObject);
30 procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
31 Shift: TShiftState; X, Y: Integer);
32 private
33 Domain, MaxLines, Lines, Cut, yDomain, yFeature, yWeight, yTotal, yView,
34 IncCap, DecCap: Integer;
35 Code: array [0 .. nFeature - 1] of Integer;
36 Template, Back: TBitmap;
37 function IsFeatureInList(D, I: Integer): Boolean;
38 procedure SetDomain(D: Integer);
39 protected
40 procedure OffscreenPaint; override;
41 procedure DoOnResize; override;
42 public
43 procedure ShowNewContent(NewMode: TWindowMode);
44 end;
45
46
47implementation
48
49uses
50 Term, Help, Tribes, Directories;
51
52{$R *.lfm}
53
54const
55 MaxLines0 = 11;
56 LinePitch = 20;
57 xDomain = 30;
58 yDomain0 = 464;
59 DomainPitch = 40;
60 xFeature = 38;
61 yFeature0 = 42;
62 xWeight = 100;
63 yWeight0 = 271;
64 xTotal = 20;
65 xTotal2 = 34;
66 yTotal0 = 354;
67 xView = 17;
68 yView0 = 283;
69
70procedure TDraftDlg.FormCreate(Sender: TObject);
71begin
72 inherited;
73 InitButtons;
74 HelpContext := 'CLASSES';
75 Caption := Phrases.Lookup('TITLE_DRAFT');
76 OKBtn.Caption := Phrases.Lookup('BTN_OK');
77
78 if not Phrases2FallenBackToEnglish then
79 begin
80 GroundArea.Hint := Phrases2.Lookup('DRAFTDOMAIN', 0);
81 SeaArea.Hint := Phrases2.Lookup('DRAFTDOMAIN', 1);
82 AirArea.Hint := Phrases2.Lookup('DRAFTDOMAIN', 2);
83 end
84 else
85 begin
86 GroundArea.Hint := Phrases.Lookup('DOMAIN', 0);
87 SeaArea.Hint := Phrases.Lookup('DOMAIN', 1);
88 AirArea.Hint := Phrases.Lookup('DOMAIN', 2);
89 end;
90
91 Back := TBitmap.Create;
92 Back.PixelFormat := TPixelFormat.pf24bit;
93 Back.SetSize(Width, Height);
94 Back.Canvas.FillRect(0, 0, Back.Width, Back.Height);
95 Template := TBitmap.Create;
96 Template.PixelFormat := TPixelFormat.pf24bit;
97 LoadGraphicFile(Template, GetGraphicsDir + DirectorySeparator + 'MiliRes.png',
98 [gfNoGamma]);
99end;
100
101procedure TDraftDlg.FormDestroy(Sender: TObject);
102begin
103 FreeAndNil(Template);
104 FreeAndNil(Back);
105end;
106
107procedure TDraftDlg.CloseBtnClick(Sender: TObject);
108begin
109 ModalResult := mrCancel;
110end;
111
112procedure TDraftDlg.OffscreenPaint;
113
114 function DomainAvailable(D: Integer): Boolean;
115 begin
116 Result := (upgrade[D, 0].Preq = preNone) or
117 (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable);
118 end;
119
120 procedure PaintTotalBars;
121 var
122 I, Y, dx, num, W: Integer;
123 S: string;
124 begin
125 with Offscreen.Canvas do
126 begin
127 // strength bar
128 Y := yTotal;
129 DarkGradient(Offscreen.Canvas, xTotal - 6, Y + 1, 184, 2);
130 DarkGradient(Offscreen.Canvas, xTotal2 + 172, Y + 1, 95, 2);
131 RisedTextOut(Offscreen.Canvas, xTotal - 2, Y,
132 Phrases.Lookup('UNITSTRENGTH'));
133 RisedTextOut(Offscreen.Canvas, xTotal + 112 + 30, Y,
134 'x' + IntToStr(MyRO.DevModel.MStrength));
135 RisedTextOut(Offscreen.Canvas, xTotal2 + 148 + 30, Y, '=');
136 S := IntToStr(MyRO.DevModel.Attack) + '/' +
137 IntToStr(MyRO.DevModel.Defense);
138 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 -
139 BiColorTextWidth(Offscreen.Canvas, S), Y, S);
140
141 // transport bar
142 if MyRO.DevModel.MTrans > 0 then
143 begin
144 Y := yTotal + 19;
145 DarkGradient(Offscreen.Canvas, xTotal - 6, Y + 1, 184, 1);
146 DarkGradient(Offscreen.Canvas, xTotal2 + 172, Y + 1, 95, 1);
147 RisedTextOut(Offscreen.Canvas, xTotal - 2, Y,
148 Phrases.Lookup('UNITTRANSPORT'));
149 RisedTextOut(Offscreen.Canvas, xTotal + 112 + 30, Y,
150 'x' + IntToStr(MyRO.DevModel.MTrans));
151 RisedTextOut(Offscreen.Canvas, xTotal2 + 148 + 30, Y, '=');
152
153 Font.Color := $000000;
154 dx := -237 - 30;
155 for I := mcFirstNonCap - 1 downto 3 do
156 if I in [mcSeaTrans, mcCarrier, mcAirTrans] then
157 begin
158 num := MyRO.DevModel.Cap[I] * MyRO.DevModel.MTrans;
159 if num > 0 then
160 begin
161 Inc(dx, 15);
162 Brush.Color := $C0C0C0;
163 FrameRect(Rect(xTotal2 - 3 - dx, Y + 2,
164 xTotal2 + 11 - dx, Y + 16));
165 Brush.Style := TBrushStyle.bsClear;
166 Sprite(Offscreen, HGrSystem, xTotal2 - 1 - dx, Y + 4, 10, 10,
167 66 + I mod 11 * 11, 137 + I div 11 * 11);
168 if num > 1 then
169 begin
170 S := IntToStr(num);
171 W := TextWidth(S);
172 Inc(dx, W + 1);
173 Brush.Color := $FFFFFF;
174 FillRect(Rect(xTotal2 - 3 - dx, Y + 2,
175 xTotal2 + W - 1 - dx, Y + 16));
176 Brush.Style := TBrushStyle.bsClear;
177 TextOut(xTotal2 - 3 - dx + 1, Y, S);
178 end;
179 end;
180 end;
181 end;
182
183 // speed bar
184 Y := yTotal + 38;
185 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y,
186 Phrases.Lookup('UNITSPEED'));
187 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16,
188 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
189 DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16,
190 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
191 S := MovementToString(MyRO.DevModel.Speed);
192 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 -
193 TextWidth(S), Y, S);
194
195 // cost bar
196 Y := yTotal + 57;
197 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y,
198 Phrases.Lookup('UNITCOST'));
199 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal + 112 + 30, Y,
200 'x' + IntToStr(MyRO.DevModel.MCost));
201 LoweredTextOut(Offscreen.Canvas, -1, MainTexture,
202 xTotal2 + 148 + 30, Y, '=');
203 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16,
204 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
205 DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16,
206 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
207 S := IntToStr(MyRO.DevModel.Cost);
208 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -
209 TextWidth(S), Y, S);
210 Sprite(Offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, Y + 4, 10,
211 10, 88, 115);
212
213 if G.Difficulty[Me] <> 2 then
214 begin // corrected cost bar
215 Y := yTotal + 76;
216 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y,
217 Phrases.Lookup('COSTDIFF' + Char(48 + G.Difficulty[Me])));
218 LoweredTextOut(Offscreen.Canvas, -1, MainTexture,
219 xTotal2 + 148 + 30, Y, '=');
220 DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16,
221 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
222 DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16,
223 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
224 S := IntToStr(MyRO.DevModel.Cost * BuildCostMod
225 [G.Difficulty[Me]] div 12);
226 RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -
227 TextWidth(S), Y, S);
228 Sprite(Offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, Y + 4, 10,
229 10, 88, 115);
230 end;
231 end;
232 end;
233
234var
235 I, J, X, D, N, TextColor, CapWeight, DomainCount: Integer;
236begin
237 inherited;
238 UnshareBitmap(Back);
239
240 Height := Template.Height - Cut;
241 if Height > MainTexture.Height then
242 // assemble background from 2 texture tiles
243 begin
244 BitBltBitmap(Back, 0, 0, Width, 64,
245 MainTexture.Image, (MainTexture.Width - Width) div 2,
246 MainTexture.Height - 64);
247 BitBltBitmap(Back, 0, 64, Width, Height - 64,
248 MainTexture.Image, (MainTexture.Width - Width) div 2,
249 0);
250 end
251 else
252 BitBltBitmap(Back, 0, 0, Width, Height,
253 MainTexture.Image, (MainTexture.Width - Width) div 2,
254 (MainTexture.Height - Height) div 2);
255 ImageOp_B(Back, Template, 0, 0, 0, 0, Template.Width, 64);
256 ImageOp_B(Back, Template, 0, 64, 0, 64 + Cut, Template.Width,
257 Template.Height - 64 - Cut);
258
259 BitBltBitmap(Offscreen, 0, 0, Width, Height, Back, 0, 0);
260
261 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
262 RisedTextOut(Offscreen.Canvas, 10, 7, Caption);
263 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
264
265 with MyRO.DevModel do
266 begin
267 DomainCount := 0;
268 for D := 0 to nDomains - 1 do
269 if DomainAvailable(D) then
270 Inc(DomainCount);
271 if DomainCount > 1 then
272 begin
273 for D := 0 to nDomains - 1 do
274 if DomainAvailable(D) then
275 begin
276 X := xDomain + D * DomainPitch;
277 if D = Domain then
278 ImageOp_BCC(Offscreen, Templates.Data, X, yDomain, 142, 246 + 37 * D, 36,
279 36, 0, $00C0FF)
280 else
281 ImageOp_BCC(Offscreen, Templates.Data, X, yDomain, 142, 246 + 37 * D, 36,
282 36, 0, $606060);
283 end;
284 Frame(Offscreen.Canvas, xDomain - 11, yDomain - 3,
285 xDomain + 2 * DomainPitch + 46, yDomain + 38, $B0B0B0, $FFFFFF);
286 RFrame(Offscreen.Canvas, xDomain - 12, yDomain - 4,
287 xDomain + 2 * DomainPitch + 47, yDomain + 39, $FFFFFF, $B0B0B0);
288 end;
289 GroundArea.Top := yDomain;
290 GroundArea.Visible := DomainAvailable(dGround);
291 SeaArea.Top := yDomain;
292 SeaArea.Visible := DomainAvailable(dSea);
293 AirArea.Top := yDomain;
294 AirArea.Visible := DomainAvailable(dAir);
295
296 PaintTotalBars;
297
298 // display weight
299 with Offscreen.Canvas do
300 begin
301 for I := 0 to MaxWeight - 1 do
302 if I < Weight then
303 ImageOp_BCC(Offscreen, Templates.Data, Point(xWeight + 20 * I, yWeight),
304 WeightOn.BoundsRect, 0, $949494)
305 else
306 ImageOp_BCC(Offscreen, Templates.Data, Point(xWeight + 20 * I, yWeight),
307 WeightOff.BoundsRect, 0, $949494);
308 end;
309
310 with Offscreen.Canvas do
311 for I := 0 to Lines - 1 do
312 begin
313 if not (Code[I] in AutoFeature) then
314 begin
315 // paint +/- butttons
316 if Code[I] < mcFirstNonCap then
317 begin
318 Dump(Offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *
319 I, 12, 12, 169, 172);
320 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
321 I, 12, 12, 169, 159);
322 RFrame(Offscreen.Canvas, xFeature - (21 + 1),
323 yFeature + 2 + LinePitch * I - 1, xFeature - (21 - 24),
324 yFeature + 2 + LinePitch * I + 12, MainTexture.ColorBevelShade,
325 MainTexture.ColorBevelLight);
326 end
327 else
328 begin
329 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
330 I, 12, 12, 169, 185 + 13 * MyRO.DevModel.Cap[Code[I]]);
331 RFrame(Offscreen.Canvas, xFeature - (9 + 1),
332 yFeature + 2 + LinePitch * I - 1, xFeature - (21 - 24),
333 yFeature + 2 + LinePitch * I + 12, MainTexture.ColorBevelShade,
334 MainTexture.ColorBevelLight);
335 end;
336
337 // paint cost
338 LightGradient(Offscreen.Canvas, xFeature + 34,
339 yFeature + LinePitch * I, 50, HGrSystem.Data.Canvas.Pixels
340 [187, 137]);
341 if (Domain = dGround) and (Code[I] = mcDefense) then
342 CapWeight := 2
343 else
344 CapWeight := Feature[Code[I]].Weight;
345 N := CapWeight + Feature[Code[I]].Cost;
346 D := 6;
347 while (N - 1) * D * 2 > 48 - 10 do
348 Dec(D);
349 for J := 0 to N - 1 do
350 if J < CapWeight then
351 Sprite(Offscreen, HGrSystem, xFeature + 54 + (J * 2 + 1 - N) * D,
352 yFeature + 2 + LinePitch * I + 1, 10, 10, 88, 126)
353 else
354 Sprite(Offscreen, HGrSystem, xFeature + 54 + (J * 2 + 1 - N) * D,
355 yFeature + 2 + LinePitch * I + 1, 10, 10, 88, 115);
356 end; // if not (code[i] in AutoFeature)
357 DarkGradient(Offscreen.Canvas, xFeature + 17,
358 yFeature + LinePitch * I, 16, 1);
359 ScreenTools.Frame(Offscreen.Canvas, xFeature + 18, yFeature + 1 + LinePitch * I,
360 xFeature + 20 - 2 + 13, yFeature + 2 + 1 - 2 + 13 + LinePitch * I,
361 $C0C0C0, $C0C0C0);
362 Sprite(Offscreen, HGrSystem, xFeature + 20, yFeature + 2 + 1 + LinePitch
363 * I, 10, 10, 66 + Code[I] mod 11 * 11, 137 + Code[I] div 11 * 11);
364
365 if MyRO.DevModel.Cap[Code[I]] > 0 then
366 TextColor := MainTexture.ColorLitText
367 else
368 TextColor := -1;
369
370 if Code[I] < mcFirstNonCap then
371 LoweredTextOut(Offscreen.Canvas, TextColor, MainTexture, xFeature + 7,
372 yFeature + LinePitch * I - 1, IntToStr(MyRO.DevModel.Cap[Code[I]]));
373 LoweredTextOut(Offscreen.Canvas, TextColor, MainTexture, xFeature + 88,
374 yFeature + LinePitch * I - 1, Phrases.Lookup('FEATURES', Code[I]));
375 end;
376 end;
377
378 // free features
379 J := 0;
380 for I := 0 to nFeature - 1 do
381 if (I in AutoFeature) and (1 shl Domain and Feature[I].Domains <> 0) and
382 (Feature[I].Preq <> preNA) and
383 ((Feature[I].Preq = preSun) and (MyRO.Wonder[woSun].EffectiveOwner = Me)
384 or (Feature[I].Preq >= 0) and (MyRO.Tech[Feature[I].Preq] >= tsApplicable)
385 ) and not ((Feature[I].Preq = adSteamEngine) and
386 (MyRO.Tech[adNuclearPower] >= tsApplicable)) then
387 begin
388 DarkGradient(Offscreen.Canvas, xWeight + 4, yWeight + 32 + LinePitch
389 * J, 16, 1);
390 Frame(Offscreen.Canvas, xWeight + 5, yWeight + 33 + LinePitch * J,
391 xWeight + 18, yWeight + 47 + LinePitch * J, $C0C0C0, $C0C0C0);
392 Sprite(Offscreen, HGrSystem, xWeight + 7, yWeight + 36 + LinePitch * J,
393 10, 10, 66 + I mod 11 * 11, 137 + I div 11 * 11);
394 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xWeight + 26,
395 yWeight + 31 + LinePitch * J, Phrases.Lookup('FEATURES', I));
396 Inc(J);
397 end;
398
399 with Tribe[Me].ModelPicture[MyRO.nModel] do
400 begin
401 FrameImage(Offscreen.Canvas, BigImp, xView + 4, yView + 4, xSizeBig,
402 ySizeBig, 0, 0);
403 Sprite(Offscreen, HGr, xView, yView, 64, 44, pix mod 10 * 65 + 1,
404 pix div 10 * 49 + 1);
405 end;
406 MarkUsedOffscreen(Width, Height);
407end;
408
409procedure TDraftDlg.DoOnResize;
410begin
411 inherited;
412 CloseBtn.Left := Width - 31;
413end;
414
415procedure TDraftDlg.SetDomain(D: Integer);
416
417 function Prio(fix: Integer): Integer;
418 var
419 FeaturePreq: Integer;
420 begin
421 FeaturePreq := Feature[fix].Preq;
422 Assert(FeaturePreq <> preNA);
423 if fix < mcFirstNonCap then
424 Result := 10000 + fix
425 else if FeaturePreq = preNone then
426 Result := 20000
427 else if FeaturePreq < 0 then
428 Result := 40000
429 else
430 Result := 30000 + AdvValue[FeaturePreq];
431 if not (fix in AutoFeature) then
432 Inc(Result, 90000);
433 end;
434
435var
436 I, J, X: Integer;
437begin
438 Domain := D;
439 Lines := 0;
440 for I := 0 to nFeature - 1 do
441 if IsFeatureInList(Domain, I) then
442 begin
443 Code[Lines] := I;
444 Inc(Lines);
445 end;
446 yFeature := yFeature0 + (MaxLines - Lines) * LinePitch div 2;
447
448 // sort features
449 for I := 0 to Lines - 2 do
450 for J := I + 1 to Lines - 1 do
451 if Prio(Code[I]) > Prio(Code[J]) then
452 begin // exchange
453 X := Code[I];
454 Code[I] := Code[J];
455 Code[J] := X;
456 end;
457end;
458
459function TDraftDlg.IsFeatureInList(D, I: Integer): Boolean;
460begin
461 Result := not (I in AutoFeature) and (1 shl D and Feature[I].Domains <> 0) and
462 (Feature[I].Preq <> preNA) and
463 ((Feature[I].Preq = preNone) or (Feature[I].Preq = preSun) and
464 (MyRO.Wonder[woSun].EffectiveOwner = Me) or (Feature[I].Preq >= 0) and
465 (MyRO.Tech[Feature[I].Preq] >= tsApplicable));
466end;
467
468procedure TDraftDlg.FormShow(Sender: TObject);
469var
470 Count, D, I: Integer;
471begin
472 Domain := dGround;
473 while (Domain < dAir) and (upgrade[Domain, 0].Preq <> preNone) and
474 (MyRO.Tech[upgrade[Domain, 0].Preq] < tsApplicable) do
475 Inc(Domain);
476
477 // Count max number of features in any domain
478 MaxLines := 0;
479 for D := 0 to nDomains - 1 do
480 if (upgrade[D, 0].Preq = preNone) or
481 (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable) then
482 begin
483 Count := 0;
484 for I := 0 to nFeature - 1 do
485 if IsFeatureInList(D, I) then
486 Inc(Count);
487 if Count > MaxLines then
488 MaxLines := Count;
489 end;
490 Cut := (MaxLines0 - MaxLines) * LinePitch;
491 OKBtn.Top := 477 - Cut;
492 yDomain := yDomain0 - Cut;
493 yWeight := yWeight0 - Cut;
494 yTotal := yTotal0 - Cut;
495 yView := yView0 - Cut;
496
497 if WindowMode = wmModal then CenterToScreen(Template.Width, Template.Height - Cut);
498
499 SetDomain(Domain);
500 Server(sCreateDevModel, Me, Domain, nil^);
501 MyModel[MyRO.nModel] := MyRO.DevModel;
502 InitMyModel(MyRO.nModel, False);
503 OffscreenPaint;
504 IncCap := -1;
505 DecCap := -1;
506end;
507
508procedure TDraftDlg.ShowNewContent(NewMode: TWindowMode);
509begin
510 inherited ShowNewContent(NewMode);
511end;
512
513procedure TDraftDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
514 Shift: TShiftState; X, Y: Integer);
515var
516 I, D: Integer;
517begin
518 if Button = TMouseButton.mbLeft then
519 begin
520 for D := 0 to nDomains - 1 do
521 if (D <> Domain) and ((upgrade[D, 0].Preq = preNone) or
522 (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable)) and
523 (X >= xDomain + D * DomainPitch) and
524 (X < xDomain + D * DomainPitch + 36) and (Y >= yDomain) and
525 (Y < yDomain + 36) then
526 begin
527 SetDomain(D);
528 Server(sCreateDevModel, Me, Domain, nil^);
529 MyModel[MyRO.nModel] := MyRO.DevModel;
530 InitMyModel(MyRO.nModel, False);
531 SmartUpdateContent;
532 end;
533
534 if (Y >= yFeature) and (Y < yFeature + LinePitch * Lines) then
535 begin
536 I := (Y - yFeature) div LinePitch;
537 if (X >= xFeature - 21) and (X < Width) and (ssShift in Shift) then
538 MainScreen.HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkFeature, Code[I])
539 else if not (Code[I] in AutoFeature) then
540 begin
541 if (Code[I] < mcFirstNonCap) and (X >= xFeature - 21) and
542 (X < xFeature - 21 + 12) then
543 begin
544 IncCap := Code[I];
545 Dump(Offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *
546 I, 12, 12, 182, 172);
547 SmartInvalidate;
548 end
549 else if (X >= xFeature - 9) and (X < xFeature - 9 + 12) then
550 begin
551 DecCap := Code[I];
552 if Code[I] < mcFirstNonCap then
553 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
554 I, 12, 12, 182, 159)
555 else
556 Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
557 I, 12, 12, 182, 185 + 13 * MyRO.DevModel.Cap[Code[I]]);
558 SmartInvalidate;
559 end;
560 end;
561 end;
562 end;
563end;
564
565procedure TDraftDlg.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
566 Shift: TShiftState; X, Y: Integer);
567var
568 NewValue: Integer;
569begin
570 if IncCap >= 0 then
571 begin
572 NewValue := MyRO.DevModel.Cap[IncCap] + 1;
573 Server(sSetDevModelCap + NewValue shl 4, Me, IncCap, nil^);
574 MyModel[MyRO.nModel] := MyRO.DevModel;
575 InitMyModel(MyRO.nModel, False);
576 SmartUpdateContent;
577 IncCap := -1;
578 end
579 else if DecCap >= 0 then
580 begin
581 if (DecCap >= mcFirstNonCap) or (MyRO.DevModel.Cap[DecCap] > 0) then
582 begin
583 NewValue := MyRO.DevModel.Cap[DecCap] - 1;
584 if DecCap >= mcFirstNonCap then
585 NewValue := -NewValue;
586 Server(sSetDevModelCap + NewValue shl 4, Me, DecCap, nil^);
587 MyModel[MyRO.nModel] := MyRO.DevModel;
588 InitMyModel(MyRO.nModel, False);
589 end;
590 SmartUpdateContent;
591 DecCap := -1;
592 end;
593end;
594
595procedure TDraftDlg.OKBtnClick(Sender: TObject);
596begin
597 ModalResult := mrOK;
598end;
599
600end.
Note: See TracBrowser for help on using the repository browser.