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