source: tags/1.3.0/LocalPlayer/Draft.pas

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