| 1 | {$INCLUDE Switches.inc}
|
|---|
| 2 | unit Select;
|
|---|
| 3 |
|
|---|
| 4 | interface
|
|---|
| 5 |
|
|---|
| 6 | uses
|
|---|
| 7 | Protocol, ClientTools, Term, ScreenTools, IsoEngine, PVSB, BaseWin,
|
|---|
| 8 | LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms,
|
|---|
| 9 | ExtCtrls, ButtonB, ButtonBase, Menus, Types;
|
|---|
| 10 |
|
|---|
| 11 | const
|
|---|
| 12 | MaxLayer = 3;
|
|---|
| 13 |
|
|---|
| 14 | type
|
|---|
| 15 | TListKind = (kProject, kAdvance, kFarAdvance, kCities, kCityEvents, kModels,
|
|---|
| 16 | kEModels, kAllEModels, kTribe, kScience, kShipPart, kEShipPart, kChooseTech,
|
|---|
| 17 | kChooseETech, kChooseModel, kChooseEModel, kChooseCity, kChooseECity,
|
|---|
| 18 | kStealTech, kGov, kMission);
|
|---|
| 19 |
|
|---|
| 20 | { TListDlg }
|
|---|
| 21 |
|
|---|
| 22 | TListDlg = class(TFramedDlg)
|
|---|
| 23 | CloseBtn: TButtonB;
|
|---|
| 24 | Layer2Btn: TButtonB;
|
|---|
| 25 | Layer1Btn: TButtonB;
|
|---|
| 26 | Layer0Btn: TButtonB;
|
|---|
| 27 | ToggleBtn: TButtonB;
|
|---|
| 28 | Popup: TPopupMenu;
|
|---|
| 29 | procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
|
|---|
| 30 | WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
|---|
| 31 | procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
|
|---|
| 32 | x, y: integer);
|
|---|
| 33 | procedure FormCreate(Sender: TObject);
|
|---|
| 34 | procedure FormDestroy(Sender: TObject);
|
|---|
| 35 | procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
|
|---|
| 36 | Shift: TShiftState; x, y: integer);
|
|---|
| 37 | procedure FormPaint(Sender: TObject);
|
|---|
| 38 | procedure CloseBtnClick(Sender: TObject);
|
|---|
| 39 | procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
|---|
| 40 | procedure FormShow(Sender: TObject);
|
|---|
| 41 | procedure ModeBtnClick(Sender: TObject);
|
|---|
| 42 | procedure ToggleBtnClick(Sender: TObject);
|
|---|
| 43 | procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
|
|---|
| 44 | procedure PlayerClick(Sender: TObject);
|
|---|
| 45 | private
|
|---|
| 46 | Kind: TListKind;
|
|---|
| 47 | LineDistance: Integer;
|
|---|
| 48 | MaxLines: Integer;
|
|---|
| 49 | cixProject: Integer;
|
|---|
| 50 | pView: Integer;
|
|---|
| 51 | Sel: Integer;
|
|---|
| 52 | DispLines: Integer;
|
|---|
| 53 | Layer: Integer;
|
|---|
| 54 | nColumn: Integer;
|
|---|
| 55 | TechNameSpace: Integer;
|
|---|
| 56 | ScienceNation: Integer;
|
|---|
| 57 | sb: TPVScrollbar;
|
|---|
| 58 | Lines, FirstShrinkedLine: array [0 .. MaxLayer - 1] of integer;
|
|---|
| 59 | code: array [0 .. MaxLayer - 1, 0 .. 4095] of integer;
|
|---|
| 60 | Column: array [0 .. nPl - 1] of integer;
|
|---|
| 61 | Closable: Boolean;
|
|---|
| 62 | MultiPage: Boolean;
|
|---|
| 63 | ScienceNationDotBuffer: TBitmap;
|
|---|
| 64 | procedure ScrollBarUpdate(Sender: TObject);
|
|---|
| 65 | procedure InitLines;
|
|---|
| 66 | procedure line(ca: TCanvas; l: integer; NonText, lit: boolean);
|
|---|
| 67 | function RenameCity(cix: integer): boolean;
|
|---|
| 68 | function RenameModel(mix: integer): boolean;
|
|---|
| 69 | procedure OnScroll(var Msg: TMessage); message WM_VSCROLL;
|
|---|
| 70 | procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
|
|---|
| 71 | public
|
|---|
| 72 | result: integer;
|
|---|
| 73 | function OnlyChoice(TestKind: TListKind): integer;
|
|---|
| 74 | // -2=empty, -1=ambiguous, other=only choice
|
|---|
| 75 | procedure OffscreenPaint; override;
|
|---|
| 76 | procedure ShowNewContent(NewMode: integer; ListKind: TListKind);
|
|---|
| 77 | procedure ShowNewContent_CityProject(NewMode, cix: integer);
|
|---|
| 78 | procedure ShowNewContent_MilReport(NewMode, p: integer);
|
|---|
| 79 | procedure EcoChange;
|
|---|
| 80 | procedure TechChange;
|
|---|
| 81 | procedure AddCity;
|
|---|
| 82 | procedure RemoveUnit;
|
|---|
| 83 | end;
|
|---|
| 84 |
|
|---|
| 85 | TModalSelectDlg = TListDlg;
|
|---|
| 86 |
|
|---|
| 87 | const
|
|---|
| 88 | cpType = $10000;
|
|---|
| 89 | mixAll = $10000;
|
|---|
| 90 | adAll = $10000;
|
|---|
| 91 |
|
|---|
| 92 | var
|
|---|
| 93 | ListDlg: TListDlg;
|
|---|
| 94 | ModalSelectDlg: TModalSelectDlg;
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | implementation
|
|---|
| 98 |
|
|---|
| 99 | uses
|
|---|
| 100 | CityScreen, Help, UnitStat, Tribes, Inp;
|
|---|
| 101 |
|
|---|
| 102 | {$R *.lfm}
|
|---|
| 103 |
|
|---|
| 104 | const
|
|---|
| 105 | CityNameSpace = 127;
|
|---|
| 106 |
|
|---|
| 107 | MustChooseKind = [kTribe, kStealTech, kGov];
|
|---|
| 108 |
|
|---|
| 109 | procedure TListDlg.FormCreate(Sender: TObject);
|
|---|
| 110 | begin
|
|---|
| 111 | inherited;
|
|---|
| 112 | Canvas.Font.Assign(UniFont[ftNormal]);
|
|---|
| 113 | sb := TPVScrollbar.Create(Self);
|
|---|
| 114 | sb.SetBorderSpacing(36, 10, 36);
|
|---|
| 115 | sb.OnUpdate := ScrollBarUpdate;
|
|---|
| 116 | InitButtons;
|
|---|
| 117 | Kind := kMission;
|
|---|
| 118 | Layer0Btn.Hint := Phrases.Lookup('BTN_IMPRS');
|
|---|
| 119 | Layer1Btn.Hint := Phrases.Lookup('BTN_WONDERS');
|
|---|
| 120 | Layer2Btn.Hint := Phrases.Lookup('BTN_CLASSES');
|
|---|
| 121 | ScienceNationDotBuffer := TBitmap.Create;
|
|---|
| 122 | ScienceNationDotBuffer.PixelFormat := pf24bit;
|
|---|
| 123 | ScienceNationDotBuffer.SetSize(17, 17);
|
|---|
| 124 | ScienceNationDotBuffer.Canvas.FillRect(0, 0, ScienceNationDotBuffer.Width, ScienceNationDotBuffer.Height);
|
|---|
| 125 | end;
|
|---|
| 126 |
|
|---|
| 127 | procedure TListDlg.FormDestroy(Sender: TObject);
|
|---|
| 128 | begin
|
|---|
| 129 | FreeAndNil(sb);
|
|---|
| 130 | FreeAndNil(ScienceNationDotBuffer);
|
|---|
| 131 | end;
|
|---|
| 132 |
|
|---|
| 133 | procedure TListDlg.CloseBtnClick(Sender: TObject);
|
|---|
| 134 | begin
|
|---|
| 135 | Closable := true;
|
|---|
| 136 | Close;
|
|---|
| 137 | end;
|
|---|
| 138 |
|
|---|
| 139 | procedure TListDlg.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
|---|
| 140 | begin
|
|---|
| 141 | CanClose := Closable or not(Kind in MustChooseKind);
|
|---|
| 142 | end;
|
|---|
| 143 |
|
|---|
| 144 | procedure TListDlg.OnScroll(var Msg: TMessage);
|
|---|
| 145 | begin
|
|---|
| 146 | { TODO: Handled by MouseWheel event
|
|---|
| 147 | if sb.Process(Msg) then begin
|
|---|
| 148 | Sel := -2;
|
|---|
| 149 | SmartUpdateContent(true);
|
|---|
| 150 | end;
|
|---|
| 151 | }
|
|---|
| 152 | end;
|
|---|
| 153 |
|
|---|
| 154 | procedure TListDlg.OnMouseLeave(var Msg: TMessage);
|
|---|
| 155 | begin
|
|---|
| 156 | if not Closable and (Sel <> -2) then
|
|---|
| 157 | begin
|
|---|
| 158 | line(Canvas, Sel, false, false);
|
|---|
| 159 | Sel := -2;
|
|---|
| 160 | end;
|
|---|
| 161 | end;
|
|---|
| 162 |
|
|---|
| 163 | procedure TListDlg.FormPaint(Sender: TObject);
|
|---|
| 164 | var
|
|---|
| 165 | s: string;
|
|---|
| 166 | begin
|
|---|
| 167 | inherited;
|
|---|
| 168 | Canvas.Font.Assign(UniFont[ftNormal]);
|
|---|
| 169 | if Sel <> -2 then
|
|---|
| 170 | line(Canvas, Sel, false, true);
|
|---|
| 171 | s := '';
|
|---|
| 172 | if (Kind = kAdvance) and (MyData.FarTech <> adNone) then
|
|---|
| 173 | s := Format(Phrases.Lookup('TECHFOCUS'),
|
|---|
| 174 | [Phrases.Lookup('ADVANCES', MyData.FarTech)])
|
|---|
| 175 | else if Kind = kModels then
|
|---|
| 176 | s := Tribe[me].TPhrase('SHORTNAME')
|
|---|
| 177 | else if Kind = kEModels then
|
|---|
| 178 | s := Tribe[pView].TPhrase('SHORTNAME') + ' (' +
|
|---|
| 179 | TurnToString(MyRO.EnemyReport[pView].TurnOfMilReport) + ')';
|
|---|
| 180 | if s <> '' then
|
|---|
| 181 | LoweredTextOut(Canvas, -1, MainTexture,
|
|---|
| 182 | (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, 31, s);
|
|---|
| 183 | if not MultiPage and (Kind in [kProject, kAdvance, kFarAdvance]) and not Phrases2FallenBackToEnglish
|
|---|
| 184 | then
|
|---|
| 185 | begin
|
|---|
| 186 | s := Phrases2.Lookup('SHIFTCLICK');
|
|---|
| 187 | LoweredTextOut(Canvas, -2, MainTexture,
|
|---|
| 188 | (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, ClientHeight - 29, s);
|
|---|
| 189 | end;
|
|---|
| 190 | end;
|
|---|
| 191 |
|
|---|
| 192 | procedure TListDlg.line(ca: TCanvas; l: integer; NonText, lit: boolean);
|
|---|
| 193 | // paint a line
|
|---|
| 194 |
|
|---|
| 195 | procedure DisplayProject(x, y, pix: integer);
|
|---|
| 196 | begin
|
|---|
| 197 | if pix and (cpType or cpImp) = 0 then
|
|---|
| 198 | with Tribe[me].ModelPicture[pix and cpIndex] do
|
|---|
| 199 | Sprite(offscreen, HGr, x, y, 64, 48, pix mod 10 * 65 + 1,
|
|---|
| 200 | pix div 10 * 49 + 1)
|
|---|
| 201 | else
|
|---|
| 202 | begin
|
|---|
| 203 | Frame(offscreen.Canvas, x + (16 - 1), y + (16 - 2), x + (16 + xSizeSmall),
|
|---|
| 204 | y + (16 - 1 + ySizeSmall), MainTexture.ColorBevelLight,
|
|---|
| 205 | MainTexture.ColorBevelShade);
|
|---|
| 206 | if pix and cpType = 0 then
|
|---|
| 207 | if (pix and cpIndex = imPalace) and (MyRO.Government <> gAnarchy) then
|
|---|
| 208 | BitBltCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
|
|---|
| 209 | ySizeSmall, SmallImp.Canvas, (MyRO.Government - 1) *
|
|---|
| 210 | xSizeSmall, ySizeSmall)
|
|---|
| 211 | else
|
|---|
| 212 | BitBltCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
|
|---|
| 213 | ySizeSmall, SmallImp.Canvas, pix and cpIndex mod 7 *
|
|---|
| 214 | xSizeSmall, (pix and cpIndex + SystemIconLines * 7) div 7 *
|
|---|
| 215 | ySizeSmall)
|
|---|
| 216 | else
|
|---|
| 217 | BitBltCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
|
|---|
| 218 | ySizeSmall, SmallImp.Canvas, (3 + pix and cpIndex) *
|
|---|
| 219 | xSizeSmall, 0);
|
|---|
| 220 | end;
|
|---|
| 221 | end;
|
|---|
| 222 |
|
|---|
| 223 | procedure ReplaceText(x, y, Color: integer; s: string);
|
|---|
| 224 | var
|
|---|
| 225 | TextSize: TSize;
|
|---|
| 226 | begin
|
|---|
| 227 | if ca = Canvas then
|
|---|
| 228 | begin
|
|---|
| 229 | TextSize.cx := BiColorTextWidth(ca, s);
|
|---|
| 230 | TextSize.cy := ca.TextHeight(s);
|
|---|
| 231 | if y + TextSize.cy >= TitleHeight + InnerHeight then
|
|---|
| 232 | TextSize.cy := TitleHeight + InnerHeight - y;
|
|---|
| 233 | Fill(ca, x, y, TextSize.cx, TextSize.cy, (Maintexture.Width - ClientWidth)
|
|---|
| 234 | div 2, (Maintexture.Height - ClientHeight) div 2);
|
|---|
| 235 | end;
|
|---|
| 236 | LoweredTextOut(ca, Color, MainTexture, x, y, s);
|
|---|
| 237 | end;
|
|---|
| 238 |
|
|---|
| 239 | var
|
|---|
| 240 | icon, ofs, x, y, y0, lix, i, j, TextColor, Available, first, test,
|
|---|
| 241 | FutureCount, growth, TrueFood, TrueProd: integer;
|
|---|
| 242 | CityReport: TCityReportNew;
|
|---|
| 243 | mox: ^TModelInfo;
|
|---|
| 244 | s, number: string;
|
|---|
| 245 | CanGrow: boolean;
|
|---|
| 246 | begin
|
|---|
| 247 | lix := code[Layer, sb.Position + l];
|
|---|
| 248 | y0 := 2 + (l + 1) * LineDistance;
|
|---|
| 249 | if sb.Position + l >= FirstShrinkedLine[Layer] then
|
|---|
| 250 | ofs := (sb.Position + l - FirstShrinkedLine[Layer]) and 1 * 33
|
|---|
| 251 | else { if FirstShrinkedLine[Layer]<Lines[Layer] then }
|
|---|
| 252 | ofs := 33;
|
|---|
| 253 |
|
|---|
| 254 | if Kind in [kCities, kCityEvents] then
|
|---|
| 255 | with MyCity[lix] do
|
|---|
| 256 | begin
|
|---|
| 257 | x := 104 - 76;
|
|---|
| 258 | y := y0;
|
|---|
| 259 | if ca = Canvas then
|
|---|
| 260 | begin
|
|---|
| 261 | x := x + SideFrame;
|
|---|
| 262 | y := y + TitleHeight;
|
|---|
| 263 | end;
|
|---|
| 264 | if lit then
|
|---|
| 265 | TextColor := MainTexture.ColorLitText
|
|---|
| 266 | else
|
|---|
| 267 | TextColor := -1;
|
|---|
| 268 | s := CityName(ID);
|
|---|
| 269 | while BiColorTextWidth(ca, s) > CityNameSpace do
|
|---|
| 270 | delete(s, length(s), 1);
|
|---|
| 271 | ReplaceText(x + 15, y, TextColor, s);
|
|---|
| 272 |
|
|---|
| 273 | if NonText then
|
|---|
| 274 | with offscreen.Canvas do
|
|---|
| 275 | begin // city size
|
|---|
| 276 | brush.Color := $000000;
|
|---|
| 277 | fillrect(rect(x - 4 - 11, y + 1, x - 4 + 13, y + 21));
|
|---|
| 278 | brush.Color := $FFFFFF;
|
|---|
| 279 | fillrect(rect(x - 4 - 12, y, x - 4 + 12, y + 20));
|
|---|
| 280 | brush.style := bsClear;
|
|---|
| 281 | Font.Color := $000000;
|
|---|
| 282 | s := inttostr(MyCity[lix].Size);
|
|---|
| 283 | TextOut(x - 4 - textwidth(s) div 2, y, s);
|
|---|
| 284 | end;
|
|---|
| 285 |
|
|---|
| 286 | if Kind = kCityEvents then
|
|---|
| 287 | begin
|
|---|
| 288 | first := -1;
|
|---|
| 289 | for j := 0 to nCityEventPriority - 1 do
|
|---|
| 290 | if (Flags and CityRepMask and CityEventPriority[j] <> 0) then
|
|---|
| 291 | begin
|
|---|
| 292 | first := j;
|
|---|
| 293 | Break
|
|---|
| 294 | end;
|
|---|
| 295 | if first >= 0 then
|
|---|
| 296 | begin
|
|---|
| 297 | i := 0;
|
|---|
| 298 | test := 1;
|
|---|
| 299 | while test < CityEventPriority[first] do
|
|---|
| 300 | begin
|
|---|
| 301 | inc(i);
|
|---|
| 302 | inc(test, test)
|
|---|
| 303 | end;
|
|---|
| 304 | s := CityEventName(i);
|
|---|
| 305 | { if CityEventPriority[first]=chNoGrowthWarning then
|
|---|
| 306 | if Built[imAqueduct]=0 then
|
|---|
| 307 | s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
|
|---|
| 308 | else begin s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); i:=17 end; }
|
|---|
| 309 | ReplaceText(x + (CityNameSpace + 4 + 40 + 18 + 8), y, TextColor, s);
|
|---|
| 310 | if NonText then
|
|---|
| 311 | begin
|
|---|
| 312 | Sprite(offscreen, HGrSystem, 105 - 76 + CityNameSpace + 4 + 40,
|
|---|
| 313 | y0 + 1, 18, 18, 1 + i mod 3 * 19, 1 + i div 3 * 19);
|
|---|
| 314 | x := InnerWidth - 26;
|
|---|
| 315 | for j := nCityEventPriority - 1 downto first + 1 do
|
|---|
| 316 | if (Flags and CityRepMask and CityEventPriority[j] <> 0) then
|
|---|
| 317 | begin
|
|---|
| 318 | i := 0;
|
|---|
| 319 | test := 1;
|
|---|
| 320 | while test < CityEventPriority[j] do
|
|---|
| 321 | begin
|
|---|
| 322 | inc(i);
|
|---|
| 323 | inc(test, test)
|
|---|
| 324 | end;
|
|---|
| 325 | if (CityEventPriority[j] = chNoGrowthWarning) and
|
|---|
| 326 | (Built[imAqueduct] > 0) then
|
|---|
| 327 | i := 17;
|
|---|
| 328 | Sprite(offscreen, HGrSystem, x, y0 + 1, 18, 18,
|
|---|
| 329 | 1 + i mod 3 * 19, 1 + i div 3 * 19);
|
|---|
| 330 | dec(x, 20)
|
|---|
| 331 | end
|
|---|
| 332 | end
|
|---|
| 333 | end
|
|---|
| 334 | end
|
|---|
| 335 | else
|
|---|
| 336 | begin
|
|---|
| 337 | CityReport.HypoTiles := -1;
|
|---|
| 338 | CityReport.HypoTaxRate := -1;
|
|---|
| 339 | CityReport.HypoLuxuryRate := -1;
|
|---|
| 340 | Server(sGetCityReportNew, me, lix, CityReport);
|
|---|
| 341 | TrueFood := Food;
|
|---|
| 342 | TrueProd := Prod;
|
|---|
| 343 | if supervising then
|
|---|
| 344 | begin // normalize city from after-turn state
|
|---|
| 345 | dec(TrueFood, CityReport.FoodSurplus);
|
|---|
| 346 | if TrueFood < 0 then
|
|---|
| 347 | TrueFood := 0; // shouldn't happen
|
|---|
| 348 | dec(TrueProd, CityReport.Production);
|
|---|
| 349 | if TrueProd < 0 then
|
|---|
| 350 | TrueProd := 0; // shouldn't happen
|
|---|
| 351 | end;
|
|---|
| 352 |
|
|---|
| 353 | s := ''; // disorder info
|
|---|
| 354 | if Flags and chCaptured <> 0 then
|
|---|
| 355 | s := Phrases.Lookup('CITYEVENTS', 14)
|
|---|
| 356 | else if CityReport.HappinessBalance < 0 then
|
|---|
| 357 | s := Phrases.Lookup('CITYEVENTS', 0);
|
|---|
| 358 | if s <> '' then
|
|---|
| 359 | begin { disorder }
|
|---|
| 360 | if NonText then
|
|---|
| 361 | begin
|
|---|
| 362 | DarkGradient(offscreen.Canvas, 99 + 31 + CityNameSpace + 4,
|
|---|
| 363 | y0 + 2, 131, 3);
|
|---|
| 364 | ca.Font.Assign(UniFont[ftSmall]);
|
|---|
| 365 | RisedTextout(offscreen.Canvas, 103 + CityNameSpace + 4 + 31,
|
|---|
| 366 | y0 + 1, s);
|
|---|
| 367 | ca.Font.Assign(UniFont[ftNormal]);
|
|---|
| 368 | end
|
|---|
| 369 | end
|
|---|
| 370 | else
|
|---|
| 371 | begin
|
|---|
| 372 | { s:=IntToStr(CityReport.FoodSurplus);
|
|---|
| 373 | ReplaceText(x+(CityNameSpace+4+48)-BiColorTextWidth(ca,s),y,TextColor,s); }
|
|---|
| 374 | s := inttostr(CityReport.Science);
|
|---|
| 375 | ReplaceText(x + CityNameSpace + 4 + 370 + 48 - BiColorTextWidth(ca,
|
|---|
| 376 | s), y, TextColor, s);
|
|---|
| 377 | s := inttostr(CityReport.Production);
|
|---|
| 378 | ReplaceText(x + CityNameSpace + 4 + 132 - BiColorTextWidth(ca, s), y,
|
|---|
| 379 | TextColor, s);
|
|---|
| 380 | if NonText then
|
|---|
| 381 | begin
|
|---|
| 382 | // Sprite(offscreen,HGrSystem,x+CityNameSpace+4+333+1,y+6,10,10,66,115);
|
|---|
| 383 | Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 370 + 48 + 1,
|
|---|
| 384 | y + 6, 10, 10, 77, 126);
|
|---|
| 385 | Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 132 + 1, y + 6,
|
|---|
| 386 | 10, 10, 88, 115);
|
|---|
| 387 | end
|
|---|
| 388 | end;
|
|---|
| 389 | s := inttostr(CityTaxBalance(lix, CityReport));
|
|---|
| 390 | ReplaceText(x + CityNameSpace + 4 + 370 - BiColorTextWidth(ca, s), y,
|
|---|
| 391 | TextColor, s);
|
|---|
| 392 | // if Project and (cpImp+cpIndex)<>cpImp+imTrGoods then
|
|---|
| 393 | // ReplaceText(x+CityNameSpace+4+333+1,y,TextColor,Format('%d/%d',[TrueProd,CityReport.ProjectCost]));
|
|---|
| 394 | if NonText then
|
|---|
| 395 | begin
|
|---|
| 396 | Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 370 + 1, y + 6,
|
|---|
| 397 | 10, 10, 132, 115);
|
|---|
| 398 |
|
|---|
| 399 | // food progress
|
|---|
| 400 | CanGrow := (Size < MaxCitySize) and (MyRO.Government <> gFuture) and
|
|---|
| 401 | (CityReport.FoodSurplus > 0) and
|
|---|
| 402 | ((Size < NeedAqueductSize) or (Built[imAqueduct] = 1) and
|
|---|
| 403 | (Size < NeedSewerSize) or (Built[imSewer] = 1));
|
|---|
| 404 | PaintRelativeProgressBar(offscreen.Canvas, 1, x + 15 + CityNameSpace +
|
|---|
| 405 | 4, y + 7, 68, TrueFood, CutCityFoodSurplus(CityReport.FoodSurplus,
|
|---|
| 406 | (MyRO.Government <> gAnarchy) and (Flags and chCaptured = 0),
|
|---|
| 407 | MyRO.Government, Size), CityReport.Storage, CanGrow, MainTexture);
|
|---|
| 408 |
|
|---|
| 409 | if Project <> cpImp + imTrGoods then
|
|---|
| 410 | begin
|
|---|
| 411 | DisplayProject(ofs + 104 - 76 + x - 28 + CityNameSpace + 4 + 206 -
|
|---|
| 412 | 60, y0 - 15, Project);
|
|---|
| 413 |
|
|---|
| 414 | // production progress
|
|---|
| 415 | growth := CityReport.Production;
|
|---|
| 416 | if (growth < 0) or (MyRO.Government = gAnarchy) or
|
|---|
| 417 | (Flags and chCaptured <> 0) then
|
|---|
| 418 | growth := 0;
|
|---|
| 419 | PaintRelativeProgressBar(offscreen.Canvas, 4,
|
|---|
| 420 | x + CityNameSpace + 4 + 304 - 60 + 9, y + 7, 68, TrueProd, growth,
|
|---|
| 421 | CityReport.ProjectCost, true, MainTexture);
|
|---|
| 422 | end;
|
|---|
| 423 | end
|
|---|
| 424 | end;
|
|---|
| 425 | end
|
|---|
| 426 | else if Kind in [kModels, kEModels] then
|
|---|
| 427 | begin
|
|---|
| 428 | x := 104;
|
|---|
| 429 | y := y0;
|
|---|
| 430 | if ca = Canvas then
|
|---|
| 431 | begin
|
|---|
| 432 | x := x + SideFrame;
|
|---|
| 433 | y := y + TitleHeight
|
|---|
| 434 | end;
|
|---|
| 435 | if lit then
|
|---|
| 436 | TextColor := MainTexture.ColorLitText
|
|---|
| 437 | else
|
|---|
| 438 | TextColor := -1;
|
|---|
| 439 | if Kind = kModels then
|
|---|
| 440 | begin
|
|---|
| 441 | Available := 0;
|
|---|
| 442 | for j := 0 to MyRO.nUn - 1 do
|
|---|
| 443 | if (MyUn[j].Loc >= 0) and (MyUn[j].mix = lix) then
|
|---|
| 444 | inc(Available);
|
|---|
| 445 | if MainScreen.mNames.Checked then
|
|---|
| 446 | s := Tribe[me].ModelName[lix]
|
|---|
| 447 | else
|
|---|
| 448 | s := Format(Tribe[me].TPhrase('GENMODEL'), [lix]);
|
|---|
| 449 | if NonText then
|
|---|
| 450 | DisplayProject(8 + ofs, y0 - 15, lix);
|
|---|
| 451 | end
|
|---|
| 452 | else
|
|---|
| 453 | begin
|
|---|
| 454 | Available := MyRO.EnemyReport[pView].UnCount[lix];
|
|---|
| 455 | if MainScreen.mNames.Checked then
|
|---|
| 456 | s := Tribe[pView].ModelName[lix]
|
|---|
| 457 | else
|
|---|
| 458 | s := Format(Tribe[pView].TPhrase('GENMODEL'), [lix]);
|
|---|
| 459 | if NonText then
|
|---|
| 460 | with Tribe[pView].ModelPicture[lix] do
|
|---|
| 461 | Sprite(offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, pix mod 10 * 65 + 1,
|
|---|
| 462 | pix div 10 * 49 + 1);
|
|---|
| 463 | end;
|
|---|
| 464 | if Available > 0 then
|
|---|
| 465 | ReplaceText(x + 32 - BiColorTextWidth(ca, inttostr(Available)), y,
|
|---|
| 466 | TextColor, inttostr(Available));
|
|---|
| 467 | ReplaceText(x + 40, y, TextColor, s);
|
|---|
| 468 | end
|
|---|
| 469 | else
|
|---|
| 470 | begin
|
|---|
| 471 | case Kind of
|
|---|
| 472 | kAllEModels, kChooseEModel:
|
|---|
| 473 | if lix = mixAll then
|
|---|
| 474 | s := Phrases.Lookup('PRICECAT_ALLMODEL')
|
|---|
| 475 | else
|
|---|
| 476 | begin
|
|---|
| 477 | mox := @MyRO.EnemyModel[lix];
|
|---|
| 478 | if MainScreen.mNames.Checked then
|
|---|
| 479 | begin
|
|---|
| 480 | s := Tribe[mox.Owner].ModelName[mox.mix];
|
|---|
| 481 | if (Kind = kAllEModels) and (code[1, sb.Position + l] = 0) then
|
|---|
| 482 | s := Format(Tribe[mox.Owner].TPhrase('OWNED'), [s]);
|
|---|
| 483 | end
|
|---|
| 484 | else
|
|---|
| 485 | s := Format(Tribe[mox.Owner].TPhrase('GENMODEL'), [mox.mix]);
|
|---|
| 486 | if NonText then
|
|---|
| 487 | with Tribe[mox.Owner].ModelPicture[mox.mix] do
|
|---|
| 488 | Sprite(offscreen, HGr, 8 + ofs, y0 - 15, 64, 48,
|
|---|
| 489 | pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
|
|---|
| 490 | end;
|
|---|
| 491 | kChooseModel:
|
|---|
| 492 | if lix = mixAll then
|
|---|
| 493 | s := Phrases.Lookup('PRICECAT_ALLMODEL')
|
|---|
| 494 | else
|
|---|
| 495 | begin
|
|---|
| 496 | s := Tribe[me].ModelName[lix];
|
|---|
| 497 | if NonText then
|
|---|
| 498 | DisplayProject(8 + ofs, y0 - 15, lix);
|
|---|
| 499 | end;
|
|---|
| 500 | kProject:
|
|---|
| 501 | begin
|
|---|
| 502 | if lix and cpType <> 0 then
|
|---|
| 503 | s := Phrases.Lookup('CITYTYPE', lix and cpIndex)
|
|---|
| 504 | else if lix and cpImp = 0 then
|
|---|
| 505 | with MyModel[lix and cpIndex] do
|
|---|
| 506 | begin
|
|---|
| 507 | s := Tribe[me].ModelName[lix and cpIndex];
|
|---|
| 508 | if lix and cpConscripts <> 0 then
|
|---|
| 509 | s := Format(Phrases.Lookup('CONSCRIPTS'), [s]);
|
|---|
| 510 | end
|
|---|
| 511 | else
|
|---|
| 512 | begin
|
|---|
| 513 | s := Phrases.Lookup('IMPROVEMENTS', lix and cpIndex);
|
|---|
| 514 | if (Imp[lix and cpIndex].Kind in [ikNatLocal, ikNatGlobal]) and
|
|---|
| 515 | (MyRO.NatBuilt[lix and cpIndex] > 0) or
|
|---|
| 516 | (lix and cpIndex in [imPower, imHydro, imNuclear]) and
|
|---|
| 517 | (MyCity[cixProject].Built[imPower] + MyCity[cixProject].Built
|
|---|
| 518 | [imHydro] + MyCity[cixProject].Built[imNuclear] > 0) then
|
|---|
| 519 | s := Format(Phrases.Lookup('NATEXISTS'), [s]);
|
|---|
| 520 | end;
|
|---|
| 521 | if NonText then
|
|---|
| 522 | DisplayProject(8 + ofs, y0 - 15, lix);
|
|---|
| 523 | end;
|
|---|
| 524 | kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech:
|
|---|
| 525 | begin
|
|---|
| 526 | if lix = adAll then
|
|---|
| 527 | s := Phrases.Lookup('PRICECAT_ALLTECH')
|
|---|
| 528 | else
|
|---|
| 529 | begin
|
|---|
| 530 | if lix = adNexus then
|
|---|
| 531 | s := Phrases.Lookup('NEXUS')
|
|---|
| 532 | else if lix = adNone then
|
|---|
| 533 | s := Phrases.Lookup('NOFARTECH')
|
|---|
| 534 | else if lix = adMilitary then
|
|---|
| 535 | s := Phrases.Lookup('INITUNIT')
|
|---|
| 536 | else
|
|---|
| 537 | begin
|
|---|
| 538 | s := Phrases.Lookup('ADVANCES', lix);
|
|---|
| 539 | if (Kind = kAdvance) and (lix in FutureTech) then
|
|---|
| 540 | if MyRO.Tech[lix] < tsApplicable then
|
|---|
| 541 | s := s + ' 1'
|
|---|
| 542 | else
|
|---|
| 543 | s := s + ' ' + inttostr(MyRO.Tech[lix] + 1);
|
|---|
| 544 | end;
|
|---|
| 545 | if BiColorTextWidth(ca, s) > TechNameSpace + 8 then
|
|---|
| 546 | begin
|
|---|
| 547 | repeat
|
|---|
| 548 | delete(s, length(s), 1);
|
|---|
| 549 | until BiColorTextWidth(ca, s) <= TechNameSpace + 5;
|
|---|
| 550 | s := s + '.';
|
|---|
| 551 | end;
|
|---|
| 552 |
|
|---|
| 553 | if NonText then
|
|---|
| 554 | begin // show tech icon
|
|---|
| 555 | if lix = adNexus then
|
|---|
| 556 | begin
|
|---|
| 557 | Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
|
|---|
| 558 | y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
|---|
| 559 | Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 223, 295)
|
|---|
| 560 | end
|
|---|
| 561 | else if lix = adNone then
|
|---|
| 562 | begin
|
|---|
| 563 | Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
|
|---|
| 564 | y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
|---|
| 565 | Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 260, 295)
|
|---|
| 566 | end
|
|---|
| 567 | else if lix = adMilitary then
|
|---|
| 568 | begin
|
|---|
| 569 | Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
|
|---|
| 570 | y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
|---|
| 571 | Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 38, 295)
|
|---|
| 572 | end
|
|---|
| 573 | else
|
|---|
| 574 | begin
|
|---|
| 575 | Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1,
|
|---|
| 576 | (8 + 16 + xSizeSmall), y0 + ySizeSmall,
|
|---|
| 577 | MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
|---|
| 578 | if AdvIcon[lix] < 84 then
|
|---|
| 579 | BitBltCanvas(offscreen.Canvas, (8 + 16), y0, xSizeSmall,
|
|---|
| 580 | ySizeSmall, SmallImp.Canvas,
|
|---|
| 581 | (AdvIcon[lix] + SystemIconLines * 7) mod 7 * xSizeSmall,
|
|---|
| 582 | (AdvIcon[lix] + SystemIconLines * 7) div 7 *
|
|---|
| 583 | ySizeSmall)
|
|---|
| 584 | else
|
|---|
| 585 | Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20,
|
|---|
| 586 | 1 + (AdvIcon[lix] - 84) mod 8 * 37,
|
|---|
| 587 | 295 + (AdvIcon[lix] - 84) div 8 * 21);
|
|---|
| 588 | j := AdvValue[lix] div 1000;
|
|---|
| 589 | BitBltCanvas(offscreen.Canvas, (8 + 16 - 4), y0 + 2, 14, 14,
|
|---|
| 590 | HGrSystem.Mask.Canvas, 127 + j * 15,
|
|---|
| 591 | 85, SRCAND);
|
|---|
| 592 | Sprite(offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14,
|
|---|
| 593 | 127 + j * 15, 85);
|
|---|
| 594 | end;
|
|---|
| 595 | end;
|
|---|
| 596 | end;
|
|---|
| 597 |
|
|---|
| 598 | if NonText and (Kind in [kAdvance, kScience]) then
|
|---|
| 599 | begin // show research state
|
|---|
| 600 | for j := 0 to nColumn - 1 do
|
|---|
| 601 | begin
|
|---|
| 602 | FutureCount := 0;
|
|---|
| 603 | if j = 0 then // own science
|
|---|
| 604 | if lix = MyRO.ResearchTech then
|
|---|
| 605 | begin
|
|---|
| 606 | Server(sGetTechCost, me, 0, icon);
|
|---|
| 607 | icon := 4 + MyRO.Research * 4 div icon;
|
|---|
| 608 | if icon > 4 + 3 then
|
|---|
| 609 | icon := 4 + 3
|
|---|
| 610 | end
|
|---|
| 611 | else if (lix >= adMilitary) then
|
|---|
| 612 | icon := -1
|
|---|
| 613 | else if lix in FutureTech then
|
|---|
| 614 | begin
|
|---|
| 615 | icon := -1;
|
|---|
| 616 | FutureCount := MyRO.Tech[lix];
|
|---|
| 617 | end
|
|---|
| 618 | else if MyRO.Tech[lix] = tsSeen then
|
|---|
| 619 | icon := 1
|
|---|
| 620 | else if MyRO.Tech[lix] >= tsApplicable then
|
|---|
| 621 | icon := 2
|
|---|
| 622 | else
|
|---|
| 623 | icon := -1
|
|---|
| 624 | else
|
|---|
| 625 | with MyRO.EnemyReport[Column[j]]^ do // enemy science
|
|---|
| 626 | if (MyRO.Alive and (1 shl Column[j]) <> 0) and
|
|---|
| 627 | (TurnOfCivilReport >= 0) and (lix = ResearchTech) and
|
|---|
| 628 | ((lix = adMilitary) or (lix in FutureTech) or
|
|---|
| 629 | (Tech[lix] < tsApplicable)) then
|
|---|
| 630 | begin
|
|---|
| 631 | icon := 4 + ResearchDone div 25;
|
|---|
| 632 | if icon > 4 + 3 then
|
|---|
| 633 | icon := 4 + 3
|
|---|
| 634 | end
|
|---|
| 635 | else if lix = adMilitary then
|
|---|
| 636 | icon := -1
|
|---|
| 637 | else if lix in FutureTech then
|
|---|
| 638 | begin
|
|---|
| 639 | icon := -1;
|
|---|
| 640 | FutureCount := Tech[lix]
|
|---|
| 641 | end
|
|---|
| 642 | else if Tech[lix] >= tsApplicable then
|
|---|
| 643 | icon := 2
|
|---|
| 644 | else if Tech[lix] = tsSeen then
|
|---|
| 645 | icon := 1
|
|---|
| 646 | else
|
|---|
| 647 | icon := -1;
|
|---|
| 648 | if icon >= 0 then
|
|---|
| 649 | Sprite(offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace +
|
|---|
| 650 | 24 * j, y0 + 3, 14, 14, 67 + icon * 15, 85)
|
|---|
| 651 | else if (Kind = kScience) and (FutureCount > 0) then
|
|---|
| 652 | begin
|
|---|
| 653 | number := inttostr(FutureCount);
|
|---|
| 654 | RisedTextout(ca, 104 - 33 + 15 + 10 + TechNameSpace + 24 * j -
|
|---|
| 655 | BiColorTextWidth(ca, number) div 2, y0, number);
|
|---|
| 656 | end
|
|---|
| 657 | end
|
|---|
| 658 | end;
|
|---|
| 659 | end; // kAdvance, kScience
|
|---|
| 660 | kTribe:
|
|---|
| 661 | s := TribeNames[lix];
|
|---|
| 662 | kShipPart:
|
|---|
| 663 | begin
|
|---|
| 664 | s := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
|
|---|
| 665 | inttostr(MyRO.Ship[me].Parts[lix]) + ')';
|
|---|
| 666 | if NonText then
|
|---|
| 667 | DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
|
|---|
| 668 | end;
|
|---|
| 669 | kEShipPart:
|
|---|
| 670 | begin
|
|---|
| 671 | s := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
|
|---|
| 672 | inttostr(MyRO.Ship[DipMem[me].pContact].Parts[lix]) + ')';
|
|---|
| 673 | if NonText then
|
|---|
| 674 | DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
|
|---|
| 675 | end;
|
|---|
| 676 | kGov:
|
|---|
| 677 | begin
|
|---|
| 678 | s := Phrases.Lookup('GOVERNMENT', lix);
|
|---|
| 679 | if NonText then
|
|---|
| 680 | begin
|
|---|
| 681 | Frame(offscreen.Canvas, 8 + 16 - 1, y0 - 15 + (16 - 2),
|
|---|
| 682 | 8 + 16 + xSizeSmall, y0 - 15 + (16 - 1 + ySizeSmall),
|
|---|
| 683 | MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
|---|
| 684 | BitBltCanvas(offscreen.Canvas, 8 + 16, y0 - 15 + (16 - 1),
|
|---|
| 685 | xSizeSmall, ySizeSmall, SmallImp.Canvas,
|
|---|
| 686 | (lix - 1) * xSizeSmall, ySizeSmall);
|
|---|
| 687 | end
|
|---|
| 688 | end;
|
|---|
| 689 | kMission:
|
|---|
| 690 | s := Phrases.Lookup('SPYMISSION', lix);
|
|---|
| 691 | end;
|
|---|
| 692 | case Kind of
|
|---|
| 693 | kTribe, kMission: // center text
|
|---|
| 694 | if Lines[0] > MaxLines then
|
|---|
| 695 | x := (InnerWidth - GetSystemMetrics(SM_CXVSCROLL)) div 2 -
|
|---|
| 696 | BiColorTextWidth(ca, s) div 2
|
|---|
| 697 | else
|
|---|
| 698 | x := InnerWidth div 2 - BiColorTextWidth(ca, s) div 2;
|
|---|
| 699 | kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech,
|
|---|
| 700 | kStealTech, kGov:
|
|---|
| 701 | x := 104 - 33;
|
|---|
| 702 | kAllEModels:
|
|---|
| 703 | x := 104;
|
|---|
| 704 | else
|
|---|
| 705 | x := 104 + 15;
|
|---|
| 706 | end;
|
|---|
| 707 | y := y0;
|
|---|
| 708 | if ca = Canvas then
|
|---|
| 709 | begin
|
|---|
| 710 | x := x + SideFrame;
|
|---|
| 711 | y := y + TitleHeight
|
|---|
| 712 | end;
|
|---|
| 713 | if lit then
|
|---|
| 714 | TextColor := MainTexture.ColorLitText
|
|---|
| 715 | else
|
|---|
| 716 | TextColor := -1;
|
|---|
| 717 | { if Kind=kTribe then ReplaceText_Tribe(x,y,TextColor,
|
|---|
| 718 | integer(TribeNames.Objects[lix]),s)
|
|---|
| 719 | else } ReplaceText(x, y, TextColor, s);
|
|---|
| 720 | end
|
|---|
| 721 | end;
|
|---|
| 722 |
|
|---|
| 723 | procedure TListDlg.OffscreenPaint;
|
|---|
| 724 | var
|
|---|
| 725 | i, j: integer;
|
|---|
| 726 | begin
|
|---|
| 727 | case Kind of
|
|---|
| 728 | kCities:
|
|---|
| 729 | Caption := Tribe[me].TPhrase('TITLE_CITIES');
|
|---|
| 730 | kCityEvents:
|
|---|
| 731 | Caption := Format(Phrases.Lookup('TITLE_EVENTS'),
|
|---|
| 732 | [TurnToString(MyRO.Turn)]);
|
|---|
| 733 | end;
|
|---|
| 734 |
|
|---|
| 735 | inherited;
|
|---|
| 736 | offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
|
|---|
| 737 | FillOffscreen(0, 0, InnerWidth, InnerHeight);
|
|---|
| 738 | with offscreen.Canvas do
|
|---|
| 739 | begin
|
|---|
| 740 | if Kind = kScience then
|
|---|
| 741 | for i := 1 to nColumn - 1 do
|
|---|
| 742 | begin
|
|---|
| 743 | Pen.Color := $000000;
|
|---|
| 744 | MoveTo(104 - 33 + 15 + TechNameSpace + 24 * i, 0);
|
|---|
| 745 | LineTo(104 - 33 + 15 + TechNameSpace + 24 * i, InnerHeight);
|
|---|
| 746 | MoveTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * i, 0);
|
|---|
| 747 | LineTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * i, InnerHeight);
|
|---|
| 748 | if MyRO.EnemyReport[Column[i]].TurnOfCivilReport >= MyRO.Turn - 1 then
|
|---|
| 749 | begin
|
|---|
| 750 | brush.Color := Tribe[Column[i]].Color;
|
|---|
| 751 | fillrect(rect(104 - 33 + 14 + TechNameSpace + 24 * i + 1 * 2, 0,
|
|---|
| 752 | 104 - 33 + 17 + TechNameSpace + 24 * i + 8 * 2, InnerHeight));
|
|---|
| 753 | brush.style := bsClear;
|
|---|
| 754 | end
|
|---|
| 755 | else
|
|---|
| 756 | begin // colored player columns
|
|---|
| 757 | Pen.Color := Tribe[Column[i]].Color;
|
|---|
| 758 | for j := 1 to 8 do
|
|---|
| 759 | begin
|
|---|
| 760 | MoveTo(104 - 33 + 15 + TechNameSpace + 24 * i + j * 2, 0);
|
|---|
| 761 | LineTo(104 - 33 + 15 + TechNameSpace + 24 * i + j * 2, InnerHeight);
|
|---|
| 762 | end
|
|---|
| 763 | end;
|
|---|
| 764 | end;
|
|---|
| 765 |
|
|---|
| 766 | for i := -1 to DispLines do
|
|---|
| 767 | if (i + sb.Position >= 0) and (i + sb.Position < Lines[Layer]) then
|
|---|
| 768 | Self.line(offscreen.Canvas, i, true, false)
|
|---|
| 769 | end;
|
|---|
| 770 | MarkUsedOffscreen(InnerWidth, 8 + 48 + DispLines * LineDistance);
|
|---|
| 771 | end;
|
|---|
| 772 |
|
|---|
| 773 | procedure TListDlg.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
|
|---|
| 774 | x, y: integer);
|
|---|
| 775 | var
|
|---|
| 776 | i0, Sel0, iColumn, OldScienceNation, xScreen: integer;
|
|---|
| 777 | s: string;
|
|---|
| 778 | begin
|
|---|
| 779 | y := y - TitleHeight;
|
|---|
| 780 | i0 := sb.Position;
|
|---|
| 781 | Sel0 := Sel;
|
|---|
| 782 | if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and
|
|---|
| 783 | (y < InnerHeight) and (y mod LineDistance >= 4) and (y mod LineDistance < 20)
|
|---|
| 784 | then
|
|---|
| 785 | Sel := y div LineDistance - 1
|
|---|
| 786 | else
|
|---|
| 787 | Sel := -2;
|
|---|
| 788 | if (Sel < -1) or (Sel > DispLines) or (Sel + i0 < 0) or
|
|---|
| 789 | (Sel + i0 >= Lines[Layer]) then
|
|---|
| 790 | Sel := -2;
|
|---|
| 791 | if Sel <> Sel0 then
|
|---|
| 792 | begin
|
|---|
| 793 | if Sel0 <> -2 then
|
|---|
| 794 | line(Canvas, Sel0, false, false);
|
|---|
| 795 | if Sel <> -2 then
|
|---|
| 796 | line(Canvas, Sel, false, true)
|
|---|
| 797 | end;
|
|---|
| 798 |
|
|---|
| 799 | if Kind = kScience then
|
|---|
| 800 | begin // show nation under cursor position
|
|---|
| 801 | OldScienceNation := ScienceNation;
|
|---|
| 802 | ScienceNation := -1;
|
|---|
| 803 | if (x >= SideFrame + (104 - 33 + 15 + TechNameSpace)) and
|
|---|
| 804 | ((x - SideFrame - (104 - 33 + 15 + TechNameSpace)) mod 24 <= 18) and
|
|---|
| 805 | (y >= 0) and (y < InnerHeight) then
|
|---|
| 806 | begin
|
|---|
| 807 | iColumn := (x - SideFrame - (104 - 33 + 15 + TechNameSpace)) div 24;
|
|---|
| 808 | if (iColumn >= 1) and (iColumn < nColumn) then
|
|---|
| 809 | ScienceNation := Column[iColumn];
|
|---|
| 810 | end;
|
|---|
| 811 | if ScienceNation <> OldScienceNation then
|
|---|
| 812 | begin
|
|---|
| 813 | Fill(Canvas, 9, ClientHeight - 29, ClientWidth - 18, 24,
|
|---|
| 814 | (Maintexture.Width - ClientWidth) div 2,
|
|---|
| 815 | (Maintexture.Height - ClientHeight) div 2);
|
|---|
| 816 | if ScienceNation >= 0 then
|
|---|
| 817 | begin
|
|---|
| 818 | s := Tribe[ScienceNation].TPhrase('SHORTNAME');
|
|---|
| 819 | if MyRO.Alive and (1 shl ScienceNation) = 0 then
|
|---|
| 820 | s := Format(Phrases.Lookup('SCIENCEREPORT_EXTINCT'), [s]) // extinct
|
|---|
| 821 | else if MyRO.EnemyReport[ScienceNation].TurnOfCivilReport < MyRO.Turn - 1
|
|---|
| 822 | then
|
|---|
| 823 | s := s + ' (' + TurnToString(MyRO.EnemyReport[ScienceNation]
|
|---|
| 824 | .TurnOfCivilReport) + ')'; // old report
|
|---|
| 825 | xScreen := (ClientWidth - BiColorTextWidth(Canvas, s)) div 2;
|
|---|
| 826 | LoweredTextOut(Canvas, -1, MainTexture, xScreen + 10,
|
|---|
| 827 | ClientHeight - 29, s);
|
|---|
| 828 | BitBltCanvas(ScienceNationDotBuffer.Canvas, 0, 0, ScienceNationDot.Width,
|
|---|
| 829 | ScienceNationDot.Height, Canvas, xScreen - 10, ClientHeight - 27);
|
|---|
| 830 | ImageOp_BCC(ScienceNationDotBuffer, Templates.Data, Point(0, 0),
|
|---|
| 831 | ScienceNationDot.BoundsRect, MainTexture.ColorBevelShade, Tribe[ScienceNation].Color);
|
|---|
| 832 | BitBltCanvas(Canvas, xScreen - 10, ClientHeight - 27, ScienceNationDot.Width,
|
|---|
| 833 | ScienceNationDot.Height, ScienceNationDotBuffer.Canvas, 0, 0);
|
|---|
| 834 | end;
|
|---|
| 835 | end;
|
|---|
| 836 | end;
|
|---|
| 837 | end;
|
|---|
| 838 |
|
|---|
| 839 | procedure TListDlg.FormMouseWheel(Sender: TObject; Shift: TShiftState;
|
|---|
| 840 | WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
|---|
| 841 | begin
|
|---|
| 842 | if sb.ProcessMouseWheel(WheelDelta) then begin
|
|---|
| 843 | PaintBox1MouseMove(nil, [], MousePos.X - Left,
|
|---|
| 844 | MousePos.Y - Top);
|
|---|
| 845 | end;
|
|---|
| 846 | end;
|
|---|
| 847 |
|
|---|
| 848 | function TListDlg.RenameCity(cix: integer): boolean;
|
|---|
| 849 | var
|
|---|
| 850 | CityNameInfo: TCityNameInfo;
|
|---|
| 851 | begin
|
|---|
| 852 | InputDlg.Caption := Phrases.Lookup('TITLE_CITYNAME');
|
|---|
| 853 | InputDlg.EInput.Text := CityName(MyCity[cix].ID);
|
|---|
| 854 | InputDlg.CenterToRect(BoundsRect);
|
|---|
| 855 | InputDlg.ShowModal;
|
|---|
| 856 | if (InputDlg.ModalResult = mrOK) and (InputDlg.EInput.Text <> '') and
|
|---|
| 857 | (InputDlg.EInput.Text <> CityName(MyCity[cix].ID)) then
|
|---|
| 858 | begin
|
|---|
| 859 | CityNameInfo.ID := MyCity[cix].ID;
|
|---|
| 860 | CityNameInfo.NewName := InputDlg.EInput.Text;
|
|---|
| 861 | Server(cSetCityName + (length(CityNameInfo.NewName) + 8) div 4, me, 0,
|
|---|
| 862 | CityNameInfo);
|
|---|
| 863 | if CityDlg.Visible then
|
|---|
| 864 | begin
|
|---|
| 865 | CityDlg.FormShow(nil);
|
|---|
| 866 | CityDlg.Invalidate;
|
|---|
| 867 | end;
|
|---|
| 868 | result := true;
|
|---|
| 869 | end
|
|---|
| 870 | else
|
|---|
| 871 | result := false;
|
|---|
| 872 | end;
|
|---|
| 873 |
|
|---|
| 874 | function TListDlg.RenameModel(mix: integer): boolean;
|
|---|
| 875 | var
|
|---|
| 876 | ModelNameInfo: TModelNameInfo;
|
|---|
| 877 | begin
|
|---|
| 878 | InputDlg.Caption := Phrases.Lookup('TITLE_MODELNAME');
|
|---|
| 879 | InputDlg.EInput.Text := Tribe[me].ModelName[mix];
|
|---|
| 880 | InputDlg.CenterToRect(BoundsRect);
|
|---|
| 881 | InputDlg.ShowModal;
|
|---|
| 882 | if (InputDlg.ModalResult = mrOK) and (InputDlg.EInput.Text <> '') and
|
|---|
| 883 | (InputDlg.EInput.Text <> Tribe[me].ModelName[mix]) then
|
|---|
| 884 | begin
|
|---|
| 885 | ModelNameInfo.mix := mix;
|
|---|
| 886 | ModelNameInfo.NewName := InputDlg.EInput.Text;
|
|---|
| 887 | Server(cSetModelName + (length(ModelNameInfo.NewName) + 1 + 4 + 3) div 4,
|
|---|
| 888 | me, 0, ModelNameInfo);
|
|---|
| 889 | if UnitStatDlg.Visible then
|
|---|
| 890 | begin
|
|---|
| 891 | UnitStatDlg.FormShow(nil);
|
|---|
| 892 | UnitStatDlg.Invalidate;
|
|---|
| 893 | end;
|
|---|
| 894 | result := true;
|
|---|
| 895 | end
|
|---|
| 896 | else
|
|---|
| 897 | result := false;
|
|---|
| 898 | end;
|
|---|
| 899 |
|
|---|
| 900 | procedure TListDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
|
|---|
| 901 | Shift: TShiftState; x, y: integer);
|
|---|
| 902 | var
|
|---|
| 903 | lix: integer;
|
|---|
| 904 | begin
|
|---|
| 905 | if sb.Position + Sel >= 0 then
|
|---|
| 906 | lix := code[Layer, sb.Position + Sel];
|
|---|
| 907 | if Kind in [kScience, kCities, kCityEvents, kModels, kEModels, kAllEModels]
|
|---|
| 908 | then
|
|---|
| 909 | include(Shift, ssShift); // don't close list window
|
|---|
| 910 | if (ssLeft in Shift) and not(ssShift in Shift) then
|
|---|
| 911 | begin
|
|---|
| 912 | if Sel <> -2 then
|
|---|
| 913 | begin
|
|---|
| 914 | result := lix;
|
|---|
| 915 | Closable := true;
|
|---|
| 916 | Close;
|
|---|
| 917 | end;
|
|---|
| 918 | end
|
|---|
| 919 | else if (ssLeft in Shift) and (ssShift in Shift) then
|
|---|
| 920 | begin // show help/info popup
|
|---|
| 921 | if Sel <> -2 then
|
|---|
| 922 | case Kind of
|
|---|
| 923 | kCities:
|
|---|
| 924 | MainScreen.ZoomToCity(MyCity[lix].Loc);
|
|---|
| 925 | kCityEvents:
|
|---|
| 926 | MainScreen.ZoomToCity(MyCity[lix].Loc, false, MyCity[lix].Flags and
|
|---|
| 927 | CityRepMask);
|
|---|
| 928 | kModels, kChooseModel:
|
|---|
| 929 | if lix <> mixAll then
|
|---|
| 930 | UnitStatDlg.ShowNewContent_OwnModel(FWindowMode or
|
|---|
| 931 | wmPersistent, lix);
|
|---|
| 932 | kEModels:
|
|---|
| 933 | UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode or wmPersistent,
|
|---|
| 934 | code[1, sb.Position + Sel]);
|
|---|
| 935 | kAllEModels, kChooseEModel:
|
|---|
| 936 | if lix <> mixAll then
|
|---|
| 937 | UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode or
|
|---|
| 938 | wmPersistent, lix);
|
|---|
| 939 | kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech:
|
|---|
| 940 | if lix = adMilitary then
|
|---|
| 941 | HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,
|
|---|
| 942 | HelpDlg.TextIndex('MILRES'))
|
|---|
| 943 | else if lix < adMilitary then
|
|---|
| 944 | HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkAdv, lix);
|
|---|
| 945 | kProject:
|
|---|
| 946 | if lix = cpImp + imTrGoods then
|
|---|
| 947 | HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,
|
|---|
| 948 | HelpDlg.TextIndex('TRADINGGOODS'))
|
|---|
| 949 | else if lix and (cpImp + cpType) = 0 then
|
|---|
| 950 | UnitStatDlg.ShowNewContent_OwnModel(FWindowMode or wmPersistent,
|
|---|
| 951 | lix and cpIndex)
|
|---|
| 952 | else if (lix and cpType = 0) and (lix <> cpImp + imTrGoods) then
|
|---|
| 953 | HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkImp,
|
|---|
| 954 | lix and cpIndex);
|
|---|
| 955 | kGov:
|
|---|
| 956 | HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkMisc,
|
|---|
| 957 | miscGovList);
|
|---|
| 958 | kShipPart, kEShipPart:
|
|---|
| 959 | ;
|
|---|
| 960 | end;
|
|---|
| 961 | end
|
|---|
| 962 | else if ssRight in Shift then
|
|---|
| 963 | begin
|
|---|
| 964 | if Sel <> -2 then
|
|---|
| 965 | case Kind of
|
|---|
| 966 | kCities, kCityEvents:
|
|---|
| 967 | if RenameCity(lix) then
|
|---|
| 968 | SmartUpdateContent;
|
|---|
| 969 | kModels:
|
|---|
| 970 | if RenameModel(lix) then
|
|---|
| 971 | SmartUpdateContent;
|
|---|
| 972 | end;
|
|---|
| 973 | end;
|
|---|
| 974 | end;
|
|---|
| 975 |
|
|---|
| 976 | procedure TListDlg.InitLines;
|
|---|
| 977 | var
|
|---|
| 978 | required: array [0 .. nAdv - 1] of integer;
|
|---|
| 979 |
|
|---|
| 980 | procedure TryAddImpLine(Layer, Project: integer);
|
|---|
| 981 | begin
|
|---|
| 982 | if Server(sSetCityProject - sExecute, me, cixProject, Project) >= rExecuted
|
|---|
| 983 | then
|
|---|
| 984 | begin
|
|---|
| 985 | code[Layer, Lines[Layer]] := Project;
|
|---|
| 986 | inc(Lines[Layer]);
|
|---|
| 987 | end;
|
|---|
| 988 | end;
|
|---|
| 989 |
|
|---|
| 990 | procedure SortTechs;
|
|---|
| 991 | var
|
|---|
| 992 | i, j, swap: integer;
|
|---|
| 993 | begin // sort by advancedness
|
|---|
| 994 | for i := 0 to Lines[0] - 2 do
|
|---|
| 995 | if code[0, i] < adMilitary then
|
|---|
| 996 | for j := i + 1 to Lines[0] - 1 do
|
|---|
| 997 | if AdvValue[code[0, i]] * nAdv + code[0, i] < AdvValue[code[0, j]] *
|
|---|
| 998 | nAdv + code[0, j] then
|
|---|
| 999 | begin
|
|---|
| 1000 | swap := code[0, i];
|
|---|
| 1001 | code[0, i] := code[0, j];
|
|---|
| 1002 | code[0, j] := swap;
|
|---|
| 1003 | end;
|
|---|
| 1004 | end;
|
|---|
| 1005 |
|
|---|
| 1006 | procedure SortCities;
|
|---|
| 1007 | var
|
|---|
| 1008 | i, j, swap: integer;
|
|---|
| 1009 | begin
|
|---|
| 1010 | for i := 0 to Lines[0] - 2 do
|
|---|
| 1011 | for j := i + 1 to Lines[0] - 1 do
|
|---|
| 1012 | if CityName(MyCity[code[0, i]].ID) > CityName(MyCity[code[0, j]].ID)
|
|---|
| 1013 | then
|
|---|
| 1014 | begin
|
|---|
| 1015 | swap := code[0, i];
|
|---|
| 1016 | code[0, i] := code[0, j];
|
|---|
| 1017 | code[0, j] := swap;
|
|---|
| 1018 | end;
|
|---|
| 1019 | end;
|
|---|
| 1020 |
|
|---|
| 1021 | function ModelSortValue(const mi: TModelInfo;
|
|---|
| 1022 | MixPlayers: boolean = false): integer;
|
|---|
| 1023 | begin
|
|---|
| 1024 | result := (mi.Domain + 1) shl 28 - mi.mix;
|
|---|
| 1025 | if MixPlayers then
|
|---|
| 1026 | dec(result, ModelCode(mi) shl 16);
|
|---|
| 1027 | end;
|
|---|
| 1028 |
|
|---|
| 1029 | procedure SortModels;
|
|---|
| 1030 | var
|
|---|
| 1031 | i, j, swap: integer;
|
|---|
| 1032 | begin // sort by code[2]
|
|---|
| 1033 | for i := 0 to Lines[0] - 2 do
|
|---|
| 1034 | for j := i + 1 to Lines[0] - 1 do
|
|---|
| 1035 | if code[2, i] > code[2, j] then
|
|---|
| 1036 | begin
|
|---|
| 1037 | swap := code[0, i];
|
|---|
| 1038 | code[0, i] := code[0, j];
|
|---|
| 1039 | code[0, j] := swap;
|
|---|
| 1040 | swap := code[1, i];
|
|---|
| 1041 | code[1, i] := code[1, j];
|
|---|
| 1042 | code[1, j] := swap;
|
|---|
| 1043 | swap := code[2, i];
|
|---|
| 1044 | code[2, i] := code[2, j];
|
|---|
| 1045 | code[2, j] := swap;
|
|---|
| 1046 | end;
|
|---|
| 1047 | end;
|
|---|
| 1048 |
|
|---|
| 1049 | procedure MarkPreqs(i: integer);
|
|---|
| 1050 | begin
|
|---|
| 1051 | required[i] := 1;
|
|---|
| 1052 | if MyRO.Tech[i] < tsSeen then
|
|---|
| 1053 | begin
|
|---|
| 1054 | if (AdvPreq[i, 0] >= 0) then
|
|---|
| 1055 | MarkPreqs(AdvPreq[i, 0]);
|
|---|
| 1056 | if (AdvPreq[i, 1] >= 0) then
|
|---|
| 1057 | MarkPreqs(AdvPreq[i, 1]);
|
|---|
| 1058 | end;
|
|---|
| 1059 | end;
|
|---|
| 1060 |
|
|---|
| 1061 | var
|
|---|
| 1062 | Loc1, i, j, p1, dx, dy, mix, emix, EnemyType, TestEnemyType: integer;
|
|---|
| 1063 | mi: TModelInfo;
|
|---|
| 1064 | PPicture, PTestPicture: ^TModelPicture;
|
|---|
| 1065 | ModelOk: array [0 .. 4095] of boolean;
|
|---|
| 1066 | ok: boolean;
|
|---|
| 1067 | begin
|
|---|
| 1068 | for i := 0 to MaxLayer - 1 do
|
|---|
| 1069 | begin
|
|---|
| 1070 | Lines[i] := 0;
|
|---|
| 1071 | FirstShrinkedLine[i] := MaxInt;
|
|---|
| 1072 | end;
|
|---|
| 1073 | case Kind of
|
|---|
| 1074 | kProject:
|
|---|
| 1075 | begin
|
|---|
| 1076 | // improvements
|
|---|
| 1077 | code[0, 0] := cpImp + imTrGoods;
|
|---|
| 1078 | Lines[0] := 1;
|
|---|
| 1079 | for i := nWonder to nImp - 1 do
|
|---|
| 1080 | if Imp[i].Kind = ikCommon then
|
|---|
| 1081 | TryAddImpLine(0, i + cpImp);
|
|---|
| 1082 | for i := nWonder to nImp - 1 do
|
|---|
| 1083 | if not(Imp[i].Kind in [ikCommon, ikTrGoods]) and
|
|---|
| 1084 | ((MyRO.NatBuilt[i] = 0) or (Imp[i].Kind = ikNatLocal)) then
|
|---|
| 1085 | TryAddImpLine(0, i + cpImp);
|
|---|
| 1086 | for i := 0 to nCityType - 1 do
|
|---|
| 1087 | if MyData.ImpOrder[i, 0] >= 0 then
|
|---|
| 1088 | begin
|
|---|
| 1089 | code[0, Lines[0]] := cpType + i;
|
|---|
| 1090 | inc(Lines[0]);
|
|---|
| 1091 | end;
|
|---|
| 1092 |
|
|---|
| 1093 | // wonders
|
|---|
| 1094 | for i := 0 to nWonder - 1 do
|
|---|
| 1095 | TryAddImpLine(1, i + cpImp);
|
|---|
| 1096 |
|
|---|
| 1097 | // units
|
|---|
| 1098 | for i := 0 to MyRO.nModel - 1 do
|
|---|
| 1099 | begin
|
|---|
| 1100 | { if MyModel[i].Kind=mkSlaves then
|
|---|
| 1101 | ok:= MyRO.Wonder[woPyramids].EffectiveOwner=me
|
|---|
| 1102 | else } if MyModel[i].Domain = dSea then
|
|---|
| 1103 | begin
|
|---|
| 1104 | ok := false;
|
|---|
| 1105 | for dx := -2 to 2 do
|
|---|
| 1106 | for dy := -2 to 2 do
|
|---|
| 1107 | if abs(dx) + abs(dy) = 2 then
|
|---|
| 1108 | begin
|
|---|
| 1109 | Loc1 := dLoc(MyCity[cixProject].Loc, dx, dy);
|
|---|
| 1110 | if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) and
|
|---|
| 1111 | ((MyMap[Loc1] and fTerrain = fShore) or
|
|---|
| 1112 | (MyMap[Loc1] and fCanal > 0)) then
|
|---|
| 1113 | ok := true;
|
|---|
| 1114 | end;
|
|---|
| 1115 | end
|
|---|
| 1116 | else
|
|---|
| 1117 | ok := true;
|
|---|
| 1118 | if ok then
|
|---|
| 1119 | begin
|
|---|
| 1120 | if MyModel[i].Status and msObsolete = 0 then
|
|---|
| 1121 | begin
|
|---|
| 1122 | code[2, Lines[2]] := i;
|
|---|
| 1123 | inc(Lines[2]);
|
|---|
| 1124 | end;
|
|---|
| 1125 | if MyModel[i].Status and msAllowConscripts <> 0 then
|
|---|
| 1126 | begin
|
|---|
| 1127 | code[2, Lines[2]] := i + cpConscripts;
|
|---|
| 1128 | inc(Lines[2]);
|
|---|
| 1129 | end;
|
|---|
| 1130 | end;
|
|---|
| 1131 | end;
|
|---|
| 1132 | FirstShrinkedLine[2] := 0;
|
|---|
| 1133 | end;
|
|---|
| 1134 | kAdvance:
|
|---|
| 1135 | begin
|
|---|
| 1136 | nColumn := 1;
|
|---|
| 1137 | if MyData.FarTech <> adNone then
|
|---|
| 1138 | begin
|
|---|
| 1139 | FillChar(required, SizeOf(required), 0);
|
|---|
| 1140 | MarkPreqs(MyData.FarTech);
|
|---|
| 1141 | end;
|
|---|
| 1142 | for i := 0 to nAdv - 1 do
|
|---|
| 1143 | if ((i in FutureTech) or (MyRO.Tech[i] < tsApplicable)) and
|
|---|
| 1144 | (Server(sSetResearch - sExecute, me, i, nil^) >= rExecuted) and
|
|---|
| 1145 | ((MyData.FarTech = adNone) or (required[i] > 0)) then
|
|---|
| 1146 | begin
|
|---|
| 1147 | code[0, Lines[0]] := i;
|
|---|
| 1148 | inc(Lines[0]);
|
|---|
| 1149 | end;
|
|---|
| 1150 | SortTechs;
|
|---|
| 1151 | if Lines[0] = 0 then // no more techs -- offer nexus
|
|---|
| 1152 | begin
|
|---|
| 1153 | code[0, Lines[0]] := adNexus;
|
|---|
| 1154 | inc(Lines[0]);
|
|---|
| 1155 | end;
|
|---|
| 1156 | ok := false;
|
|---|
| 1157 | for i := 0 to nDomains - 1 do
|
|---|
| 1158 | if (upgrade[i, 0].Preq = preNone) or
|
|---|
| 1159 | (MyRO.Tech[upgrade[i, 0].Preq] >= tsApplicable) then
|
|---|
| 1160 | ok := true;
|
|---|
| 1161 | if ok then { new unit class }
|
|---|
| 1162 | begin
|
|---|
| 1163 | code[0, Lines[0]] := adMilitary;
|
|---|
| 1164 | inc(Lines[0]);
|
|---|
| 1165 | end;
|
|---|
| 1166 | end;
|
|---|
| 1167 | kFarAdvance:
|
|---|
| 1168 | begin
|
|---|
| 1169 | code[0, Lines[0]] := adNone;
|
|---|
| 1170 | inc(Lines[0]);
|
|---|
| 1171 | for i := 0 to nAdv - 1 do
|
|---|
| 1172 | if not(i in FutureTech) and (MyRO.Tech[i] < tsApplicable) and
|
|---|
| 1173 | ((AdvValue[i] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
|
|---|
| 1174 | ((AdvValue[i] < 1000) or (MyRO.Tech[adScience] > tsNA)) then
|
|---|
| 1175 | begin
|
|---|
| 1176 | code[0, Lines[0]] := i;
|
|---|
| 1177 | inc(Lines[0]);
|
|---|
| 1178 | end;
|
|---|
| 1179 | SortTechs;
|
|---|
| 1180 | end;
|
|---|
| 1181 | kChooseTech:
|
|---|
| 1182 | begin
|
|---|
| 1183 | for i := 0 to nAdv - 1 do
|
|---|
| 1184 | if not(i in FutureTech) and (MyRO.Tech[i] >= tsApplicable) and
|
|---|
| 1185 | (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] < tsSeen) then
|
|---|
| 1186 | begin
|
|---|
| 1187 | code[0, Lines[0]] := i;
|
|---|
| 1188 | inc(Lines[0]);
|
|---|
| 1189 | end;
|
|---|
| 1190 | SortTechs;
|
|---|
| 1191 | // if Lines[0]>1 then
|
|---|
| 1192 | begin
|
|---|
| 1193 | code[0, Lines[0]] := adAll;
|
|---|
| 1194 | inc(Lines[0]);
|
|---|
| 1195 | end;
|
|---|
| 1196 | end;
|
|---|
| 1197 | kChooseETech:
|
|---|
| 1198 | begin
|
|---|
| 1199 | for i := 0 to nAdv - 1 do
|
|---|
| 1200 | if not(i in FutureTech) and (MyRO.Tech[i] < tsSeen) and
|
|---|
| 1201 | (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] >= tsApplicable) then
|
|---|
| 1202 | begin
|
|---|
| 1203 | code[0, Lines[0]] := i;
|
|---|
| 1204 | inc(Lines[0]);
|
|---|
| 1205 | end;
|
|---|
| 1206 | SortTechs;
|
|---|
| 1207 | // if Lines[0]>1 then
|
|---|
| 1208 | begin
|
|---|
| 1209 | code[0, Lines[0]] := adAll;
|
|---|
| 1210 | inc(Lines[0]);
|
|---|
| 1211 | end;
|
|---|
| 1212 | end;
|
|---|
| 1213 | kStealTech:
|
|---|
| 1214 | begin
|
|---|
| 1215 | for i := 0 to nAdv - 1 do
|
|---|
| 1216 | if Server(sStealTech - sExecute, me, i, nil^) >= rExecuted then
|
|---|
| 1217 | begin
|
|---|
| 1218 | code[0, Lines[0]] := i;
|
|---|
| 1219 | inc(Lines[0]);
|
|---|
| 1220 | end;
|
|---|
| 1221 | SortTechs;
|
|---|
| 1222 | end;
|
|---|
| 1223 | kScience:
|
|---|
| 1224 | begin
|
|---|
| 1225 | Column[0] := me;
|
|---|
| 1226 | nColumn := 1;
|
|---|
| 1227 | for EnemyType := 0 to 2 do
|
|---|
| 1228 | for p1 := 0 to nPl - 1 do
|
|---|
| 1229 | if (MyRO.EnemyReport[p1] <> nil) and
|
|---|
| 1230 | ((MyRO.EnemyReport[p1].TurnOfContact >= 0) or
|
|---|
| 1231 | (MyRO.EnemyReport[p1].TurnOfCivilReport >= 0)) then
|
|---|
| 1232 | begin
|
|---|
| 1233 | if MyRO.Alive and (1 shl p1) = 0 then
|
|---|
| 1234 | TestEnemyType := 2 // extinct enemy -- move to right end
|
|---|
| 1235 | else if MyRO.EnemyReport[p1].TurnOfCivilReport >= MyRO.Turn - 1
|
|---|
| 1236 | then
|
|---|
| 1237 | TestEnemyType := 0 // current report -- move to left end
|
|---|
| 1238 | else
|
|---|
| 1239 | TestEnemyType := 1;
|
|---|
| 1240 | if TestEnemyType = EnemyType then
|
|---|
| 1241 | begin
|
|---|
| 1242 | Column[nColumn] := p1;
|
|---|
| 1243 | inc(nColumn);
|
|---|
| 1244 | end;
|
|---|
| 1245 | end;
|
|---|
| 1246 | for i := 0 to nAdv - 1 do
|
|---|
| 1247 | begin
|
|---|
| 1248 | ok := (MyRO.Tech[i] <> tsNA) or (MyRO.ResearchTech = i);
|
|---|
| 1249 | for j := 1 to nColumn - 1 do
|
|---|
| 1250 | with MyRO.EnemyReport[Column[j]]^ do
|
|---|
| 1251 | if (Tech[i] <> tsNA) or (TurnOfCivilReport >= 0) and
|
|---|
| 1252 | (ResearchTech = i) then
|
|---|
| 1253 | ok := true;
|
|---|
| 1254 | if ok then
|
|---|
| 1255 | begin
|
|---|
| 1256 | code[0, Lines[0]] := i;
|
|---|
| 1257 | inc(Lines[0]);
|
|---|
| 1258 | end;
|
|---|
| 1259 | end;
|
|---|
| 1260 | SortTechs;
|
|---|
| 1261 |
|
|---|
| 1262 | ok := MyRO.ResearchTech = adMilitary;
|
|---|
| 1263 | for j := 1 to nColumn - 1 do
|
|---|
| 1264 | with MyRO.EnemyReport[Column[j]]^ do
|
|---|
| 1265 | if (MyRO.Alive and (1 shl Column[j]) <> 0) and
|
|---|
| 1266 | (TurnOfCivilReport >= 0) and (ResearchTech = adMilitary) then
|
|---|
| 1267 | ok := true;
|
|---|
| 1268 | if ok then
|
|---|
| 1269 | begin
|
|---|
| 1270 | code[0, Lines[0]] := adMilitary;
|
|---|
| 1271 | inc(Lines[0]);
|
|---|
| 1272 | end
|
|---|
| 1273 | end;
|
|---|
| 1274 | kCities { , kChooseCity } :
|
|---|
| 1275 | begin
|
|---|
| 1276 | if ClientMode < scContact then
|
|---|
| 1277 | for i := 0 to MyRO.nCity - 1 do
|
|---|
| 1278 | if MyCity[i].Loc >= 0 then
|
|---|
| 1279 | begin
|
|---|
| 1280 | code[0, Lines[0]] := i;
|
|---|
| 1281 | inc(Lines[0]);
|
|---|
| 1282 | end;
|
|---|
| 1283 | SortCities;
|
|---|
| 1284 | FirstShrinkedLine[0] := 0
|
|---|
| 1285 | end;
|
|---|
| 1286 | kCityEvents:
|
|---|
| 1287 | begin
|
|---|
| 1288 | for i := 0 to MyRO.nCity - 1 do
|
|---|
| 1289 | if (MyCity[i].Loc >= 0) and (MyCity[i].Flags and CityRepMask <> 0)
|
|---|
| 1290 | then
|
|---|
| 1291 | begin
|
|---|
| 1292 | code[0, Lines[0]] := i;
|
|---|
| 1293 | inc(Lines[0]);
|
|---|
| 1294 | end;
|
|---|
| 1295 | SortCities;
|
|---|
| 1296 | FirstShrinkedLine[0] := 0;
|
|---|
| 1297 | end;
|
|---|
| 1298 | { kChooseECity:
|
|---|
| 1299 | begin
|
|---|
| 1300 | for i:=0 to MyRO.nEnemyCity-1 do
|
|---|
| 1301 | if (MyRO.EnemyCity[i].Loc>=0)
|
|---|
| 1302 | and (MyRO.EnemyCity[i].owner=DipMem[me].pContact) then
|
|---|
| 1303 | begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
|
|---|
| 1304 | FirstShrinkedLine:=0
|
|---|
| 1305 | end; }
|
|---|
| 1306 | kModels:
|
|---|
| 1307 | begin
|
|---|
| 1308 | for mix := 0 to MyRO.nModel - 1 do
|
|---|
| 1309 | begin
|
|---|
| 1310 | code[0, mix] := mix;
|
|---|
| 1311 | MakeModelInfo(me, mix, MyModel[mix], mi);
|
|---|
| 1312 | code[2, mix] := ModelSortValue(mi);
|
|---|
| 1313 | end;
|
|---|
| 1314 | Lines[0] := MyRO.nModel;
|
|---|
| 1315 | SortModels;
|
|---|
| 1316 | FirstShrinkedLine[0] := 0;
|
|---|
| 1317 | end;
|
|---|
| 1318 | kChooseModel:
|
|---|
| 1319 | begin
|
|---|
| 1320 | for mix := 3 to MyRO.nModel - 1 do
|
|---|
| 1321 | begin // check if opponent already has this model
|
|---|
| 1322 | MakeModelInfo(me, mix, MyModel[mix], mi);
|
|---|
| 1323 | ok := true;
|
|---|
| 1324 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
|---|
| 1325 | if (MyRO.EnemyModel[emix].Owner = DipMem[me].pContact) and
|
|---|
| 1326 | IsSameModel(MyRO.EnemyModel[emix], mi) then
|
|---|
| 1327 | ok := false;
|
|---|
| 1328 | if ok then
|
|---|
| 1329 | begin
|
|---|
| 1330 | code[0, Lines[0]] := mix;
|
|---|
| 1331 | MakeModelInfo(me, mix, MyModel[mix], mi);
|
|---|
| 1332 | code[2, Lines[0]] := ModelSortValue(mi);
|
|---|
| 1333 | inc(Lines[0]);
|
|---|
| 1334 | end;
|
|---|
| 1335 | end;
|
|---|
| 1336 | SortModels;
|
|---|
| 1337 | // if Lines[0]>1 then
|
|---|
| 1338 | begin
|
|---|
| 1339 | code[0, Lines[0]] := mixAll;
|
|---|
| 1340 | inc(Lines[0]);;
|
|---|
| 1341 | end;
|
|---|
| 1342 | FirstShrinkedLine[0] := 0;
|
|---|
| 1343 | end;
|
|---|
| 1344 | kChooseEModel:
|
|---|
| 1345 | begin
|
|---|
| 1346 | if MyRO.TestFlags and tfUncover <> 0 then
|
|---|
| 1347 | Server(sGetModels, me, 0, nil^);
|
|---|
| 1348 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
|---|
| 1349 | ModelOk[emix] := MyRO.EnemyModel[emix].Owner = DipMem[me].pContact;
|
|---|
| 1350 | for mix := 0 to MyRO.nModel - 1 do
|
|---|
| 1351 | begin // don't list models I already have
|
|---|
| 1352 | MakeModelInfo(me, mix, MyModel[mix], mi);
|
|---|
| 1353 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
|---|
| 1354 | ModelOk[emix] := ModelOk[emix] and
|
|---|
| 1355 | not IsSameModel(MyRO.EnemyModel[emix], mi);
|
|---|
| 1356 | end;
|
|---|
| 1357 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
|---|
| 1358 | if ModelOk[emix] then
|
|---|
| 1359 | begin
|
|---|
| 1360 | if not Assigned(Tribe[DipMem[me].pContact].ModelPicture
|
|---|
| 1361 | [MyRO.EnemyModel[emix].mix].HGr) then
|
|---|
| 1362 | InitEnemyModel(emix);
|
|---|
| 1363 | code[0, Lines[0]] := emix;
|
|---|
| 1364 | code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix]);
|
|---|
| 1365 | inc(Lines[0]);
|
|---|
| 1366 | end;
|
|---|
| 1367 | SortModels;
|
|---|
| 1368 | // if not IsMilReportNew(DipMem[me].pContact) or (Lines[0]>1) then
|
|---|
| 1369 | begin
|
|---|
| 1370 | code[0, Lines[0]] := mixAll;
|
|---|
| 1371 | inc(Lines[0]);
|
|---|
| 1372 | end;
|
|---|
| 1373 | FirstShrinkedLine[0] := 0;
|
|---|
| 1374 | end;
|
|---|
| 1375 | kEModels:
|
|---|
| 1376 | begin
|
|---|
| 1377 | for i := 0 to MyRO.EnemyReport[pView].nModelCounted - 1 do
|
|---|
| 1378 | begin
|
|---|
| 1379 | code[1, Lines[0]] := MyRO.nEnemyModel - 1;
|
|---|
| 1380 | while (code[1, Lines[0]] >= 0) and
|
|---|
| 1381 | not((MyRO.EnemyModel[code[1, Lines[0]]].Owner = pView) and
|
|---|
| 1382 | (MyRO.EnemyModel[code[1, Lines[0]]].mix = i)) do
|
|---|
| 1383 | dec(code[1, Lines[0]]);
|
|---|
| 1384 | if not Assigned(Tribe[pView].ModelPicture[i].HGr) then
|
|---|
| 1385 | InitEnemyModel(code[1, Lines[0]]);
|
|---|
| 1386 | code[0, Lines[0]] := i;
|
|---|
| 1387 | code[2, Lines[0]] :=
|
|---|
| 1388 | ModelSortValue(MyRO.EnemyModel[code[1, Lines[0]]]);
|
|---|
| 1389 | inc(Lines[0]);
|
|---|
| 1390 | end;
|
|---|
| 1391 | SortModels;
|
|---|
| 1392 | FirstShrinkedLine[0] := 0;
|
|---|
| 1393 | end;
|
|---|
| 1394 | kAllEModels:
|
|---|
| 1395 | begin
|
|---|
| 1396 | if (MyRO.TestFlags and tfUncover <> 0) or (G.Difficulty[me] = 0) then
|
|---|
| 1397 | Server(sGetModels, me, 0, nil^);
|
|---|
| 1398 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
|---|
| 1399 | if (MyRO.EnemyModel[emix].mix >= 3) and
|
|---|
| 1400 | (MyRO.EnemyModel[emix].Kind in [mkSelfDeveloped, mkEnemyDeveloped])
|
|---|
| 1401 | then
|
|---|
| 1402 | begin
|
|---|
| 1403 | PPicture := @Tribe[MyRO.EnemyModel[emix].Owner].ModelPicture
|
|---|
| 1404 | [MyRO.EnemyModel[emix].mix];
|
|---|
| 1405 | if not Assigned(PPicture.HGr) then
|
|---|
| 1406 | InitEnemyModel(emix);
|
|---|
| 1407 | ok := true;
|
|---|
| 1408 | if MainScreen.mNames.Checked then
|
|---|
| 1409 | for j := 0 to Lines[0] - 1 do
|
|---|
| 1410 | begin
|
|---|
| 1411 | PTestPicture := @Tribe[MyRO.EnemyModel[code[0, j]].Owner]
|
|---|
| 1412 | .ModelPicture[MyRO.EnemyModel[code[0, j]].mix];
|
|---|
| 1413 | if (PPicture.HGr = PTestPicture.HGr) and
|
|---|
| 1414 | (PPicture.pix = PTestPicture.pix) and
|
|---|
| 1415 | (ModelHash(MyRO.EnemyModel[emix])
|
|---|
| 1416 | = ModelHash(MyRO.EnemyModel[code[0, j]])) then
|
|---|
| 1417 | begin
|
|---|
| 1418 | code[1, j] := 1;
|
|---|
| 1419 | ok := false;
|
|---|
| 1420 | Break;
|
|---|
| 1421 | end;
|
|---|
| 1422 | end;
|
|---|
| 1423 | if ok then
|
|---|
| 1424 | begin
|
|---|
| 1425 | code[0, Lines[0]] := emix;
|
|---|
| 1426 | code[1, Lines[0]] := 0;
|
|---|
| 1427 | code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix], true);
|
|---|
| 1428 | inc(Lines[0]);
|
|---|
| 1429 | end;
|
|---|
| 1430 | end;
|
|---|
| 1431 | SortModels;
|
|---|
| 1432 | FirstShrinkedLine[0] := 0
|
|---|
| 1433 | end;
|
|---|
| 1434 | kTribe:
|
|---|
| 1435 | for i := 0 to TribeNames.Count - 1 do
|
|---|
| 1436 | begin
|
|---|
| 1437 | code[0, Lines[0]] := i;
|
|---|
| 1438 | inc(Lines[0]);
|
|---|
| 1439 | end;
|
|---|
| 1440 | (* kDeliver:
|
|---|
| 1441 | if MyRO.Treaty[DipMem[me].pContact]<trAlliance then
|
|---|
| 1442 | begin // suggest next treaty level
|
|---|
| 1443 | code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[me].pContact]+1;
|
|---|
| 1444 | inc(Lines[0]);
|
|---|
| 1445 | end;
|
|---|
| 1446 | if MyRO.Treaty[DipMem[me].pContact]=trNone then
|
|---|
| 1447 | begin // suggest peace
|
|---|
| 1448 | code[0,Lines[0]]:=opTreaty+trPeace;
|
|---|
| 1449 | inc(Lines[0]);
|
|---|
| 1450 | end;
|
|---|
| 1451 | if MyRO.Treaty[DipMem[me].pContact]>trNone then
|
|---|
| 1452 | begin // suggest next treaty level
|
|---|
| 1453 | code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
|
|---|
| 1454 | inc(Lines[0]);
|
|---|
| 1455 | end; *)
|
|---|
| 1456 | kShipPart:
|
|---|
| 1457 | begin
|
|---|
| 1458 | Lines[0] := 0;
|
|---|
| 1459 | for i := 0 to nShipPart - 1 do
|
|---|
| 1460 | if MyRO.Ship[me].Parts[i] > 0 then
|
|---|
| 1461 | begin
|
|---|
| 1462 | code[0, Lines[0]] := i;
|
|---|
| 1463 | inc(Lines[0]);
|
|---|
| 1464 | end;
|
|---|
| 1465 | end;
|
|---|
| 1466 | kEShipPart:
|
|---|
| 1467 | begin
|
|---|
| 1468 | Lines[0] := 0;
|
|---|
| 1469 | for i := 0 to nShipPart - 1 do
|
|---|
| 1470 | if MyRO.Ship[DipMem[me].pContact].Parts[i] > 0 then
|
|---|
| 1471 | begin
|
|---|
| 1472 | code[0, Lines[0]] := i;
|
|---|
| 1473 | inc(Lines[0]);
|
|---|
| 1474 | end;
|
|---|
| 1475 | end;
|
|---|
| 1476 | kGov:
|
|---|
| 1477 | for i := 1 to nGov - 1 do
|
|---|
| 1478 | if (GovPreq[i] <> preNA) and
|
|---|
| 1479 | ((GovPreq[i] = preNone) or (MyRO.Tech[GovPreq[i]] >= tsApplicable))
|
|---|
| 1480 | then
|
|---|
| 1481 | begin
|
|---|
| 1482 | code[0, Lines[0]] := i;
|
|---|
| 1483 | inc(Lines[0]);
|
|---|
| 1484 | end;
|
|---|
| 1485 | kMission:
|
|---|
| 1486 | for i := 0 to nSpyMission - 1 do
|
|---|
| 1487 | begin
|
|---|
| 1488 | code[0, Lines[0]] := i;
|
|---|
| 1489 | inc(Lines[0]);
|
|---|
| 1490 | end;
|
|---|
| 1491 | end;
|
|---|
| 1492 |
|
|---|
| 1493 | if Kind = kProject then // test if choice fitting to one screen
|
|---|
| 1494 | if Lines[0] + Lines[1] + Lines[2] <= MaxLines then
|
|---|
| 1495 | begin
|
|---|
| 1496 | for i := 0 to Lines[1] - 1 do // add wonders to first page
|
|---|
| 1497 | begin
|
|---|
| 1498 | code[0, Lines[0]] := code[1, i];
|
|---|
| 1499 | inc(Lines[0]);
|
|---|
| 1500 | end;
|
|---|
| 1501 | Lines[1] := 0;
|
|---|
| 1502 | FirstShrinkedLine[0] := Lines[0];
|
|---|
| 1503 | for i := 0 to Lines[2] - 1 do // add models to first page
|
|---|
| 1504 | begin
|
|---|
| 1505 | code[0, Lines[0]] := code[2, i];
|
|---|
| 1506 | inc(Lines[0]);
|
|---|
| 1507 | end;
|
|---|
| 1508 | Lines[2] := 0;
|
|---|
| 1509 | end;
|
|---|
| 1510 | end; // InitLines
|
|---|
| 1511 |
|
|---|
| 1512 | function TListDlg.OnlyChoice(TestKind: TListKind): integer;
|
|---|
| 1513 | begin
|
|---|
| 1514 | Kind := TestKind;
|
|---|
| 1515 | InitLines;
|
|---|
| 1516 | if Lines[0] = 0 then
|
|---|
| 1517 | result := -2
|
|---|
| 1518 | else if Lines[0] > 1 then
|
|---|
| 1519 | result := -1
|
|---|
| 1520 | else
|
|---|
| 1521 | result := code[0, 0];
|
|---|
| 1522 | end;
|
|---|
| 1523 |
|
|---|
| 1524 | procedure TListDlg.FormShow(Sender: TObject);
|
|---|
| 1525 | var
|
|---|
| 1526 | i: integer;
|
|---|
| 1527 | begin
|
|---|
| 1528 | result := -1;
|
|---|
| 1529 | Closable := false;
|
|---|
| 1530 |
|
|---|
| 1531 | if Kind = kTribe then
|
|---|
| 1532 | begin
|
|---|
| 1533 | LineDistance := 21; // looks ugly with scrollbar
|
|---|
| 1534 | MaxLines := (Maintexture.Height - (24 + TitleHeight + NarrowFrame))
|
|---|
| 1535 | div LineDistance - 1;
|
|---|
| 1536 | end
|
|---|
| 1537 | else
|
|---|
| 1538 | begin
|
|---|
| 1539 | LineDistance := 24;
|
|---|
| 1540 | MaxLines := (Maintexture.Height - (24 + TitleHeight + WideFrame))
|
|---|
| 1541 | div LineDistance - 1;
|
|---|
| 1542 | end;
|
|---|
| 1543 | InitLines;
|
|---|
| 1544 |
|
|---|
| 1545 | MultiPage := false;
|
|---|
| 1546 | for i := 1 to MaxLayer - 1 do
|
|---|
| 1547 | if Lines[i] > 0 then
|
|---|
| 1548 | MultiPage := true;
|
|---|
| 1549 | WideBottom := MultiPage or (Kind = kScience) or
|
|---|
| 1550 | not Phrases2FallenBackToEnglish and
|
|---|
| 1551 | (Kind in [kProject, kAdvance, kFarAdvance]);
|
|---|
| 1552 | if (Kind = kAdvance) and (MyData.FarTech <> adNone) or (Kind = kModels) or
|
|---|
| 1553 | (Kind = kEModels) then begin
|
|---|
| 1554 | sb.SetBorderSpacing(56, 10, 10);
|
|---|
| 1555 | TitleHeight := WideFrame + 20;
|
|---|
| 1556 | end else begin
|
|---|
| 1557 | sb.SetBorderSpacing(36, 10, 34);
|
|---|
| 1558 | TitleHeight := WideFrame;
|
|---|
| 1559 | end;
|
|---|
| 1560 |
|
|---|
| 1561 | DispLines := Lines[0];
|
|---|
| 1562 | for i := 0 to MaxLayer - 1 do
|
|---|
| 1563 | if Lines[i] > DispLines then
|
|---|
| 1564 | DispLines := Lines[i];
|
|---|
| 1565 | if WideBottom then
|
|---|
| 1566 | begin
|
|---|
| 1567 | if DispLines > MaxLines then
|
|---|
| 1568 | DispLines := MaxLines;
|
|---|
| 1569 | InnerHeight := LineDistance * (DispLines + 1) + 24;
|
|---|
| 1570 | ClientHeight := InnerHeight + TitleHeight + WideFrame;
|
|---|
| 1571 | end
|
|---|
| 1572 | else
|
|---|
| 1573 | begin
|
|---|
| 1574 | if DispLines > MaxLines then
|
|---|
| 1575 | DispLines := MaxLines;
|
|---|
| 1576 | InnerHeight := LineDistance * (DispLines + 1) + 24;
|
|---|
| 1577 | ClientHeight := InnerHeight + TitleHeight + NarrowFrame;
|
|---|
| 1578 | end;
|
|---|
| 1579 | assert(ClientHeight <= Maintexture.Height);
|
|---|
| 1580 |
|
|---|
| 1581 | TechNameSpace := 224;
|
|---|
| 1582 | case Kind of
|
|---|
| 1583 | kGov:
|
|---|
| 1584 | InnerWidth := 272;
|
|---|
| 1585 | kCities, kCityEvents:
|
|---|
| 1586 | InnerWidth := 640 - 18;
|
|---|
| 1587 | kTribe:
|
|---|
| 1588 | if Lines[0] > MaxLines then
|
|---|
| 1589 | InnerWidth := 280 + GetSystemMetrics(SM_CXVSCROLL)
|
|---|
| 1590 | else
|
|---|
| 1591 | InnerWidth := 280;
|
|---|
| 1592 | kScience:
|
|---|
| 1593 | begin
|
|---|
| 1594 | InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace + 24 * nColumn +
|
|---|
| 1595 | GetSystemMetrics(SM_CXVSCROLL);
|
|---|
| 1596 | if InnerWidth + 2 * SideFrame > 640 then
|
|---|
| 1597 | begin
|
|---|
| 1598 | TechNameSpace := TechNameSpace + 640 - InnerWidth - 2 * SideFrame;
|
|---|
| 1599 | InnerWidth := 640 - 2 * SideFrame
|
|---|
| 1600 | end;
|
|---|
| 1601 | end;
|
|---|
| 1602 | kAdvance, kFarAdvance:
|
|---|
| 1603 | InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace + 24 +
|
|---|
| 1604 | GetSystemMetrics(SM_CXVSCROLL);
|
|---|
| 1605 | kChooseTech, kChooseETech, kStealTech:
|
|---|
| 1606 | InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace +
|
|---|
| 1607 | GetSystemMetrics(SM_CXVSCROLL);
|
|---|
| 1608 | else
|
|---|
| 1609 | InnerWidth := 363;
|
|---|
| 1610 | end;
|
|---|
| 1611 | ClientWidth := InnerWidth + 2 * SideFrame;
|
|---|
| 1612 |
|
|---|
| 1613 | CloseBtn.Left := ClientWidth - 38;
|
|---|
| 1614 | CaptionLeft := ToggleBtn.Left + ToggleBtn.Width;
|
|---|
| 1615 | CaptionRight := CloseBtn.Left;
|
|---|
| 1616 | { TODO:
|
|---|
| 1617 | SetWindowPos(sb.ScrollBar.Handle, 0, SideFrame + InnerWidth - GetSystemMetrics(SM_CXVSCROLL),
|
|---|
| 1618 | TitleHeight, GetSystemMetrics(SM_CXVSCROLL), LineDistance * DispLines + 48,
|
|---|
| 1619 | SWP_NOZORDER or SWP_NOREDRAW);
|
|---|
| 1620 | }
|
|---|
| 1621 |
|
|---|
| 1622 | if WindowMode = wmModal then
|
|---|
| 1623 | begin { center on screen }
|
|---|
| 1624 | if Kind = kTribe then
|
|---|
| 1625 | Left := (Screen.Width - 800) * 3 div 8 + 130
|
|---|
| 1626 | else
|
|---|
| 1627 | Left := (Screen.Width - Width) div 2;
|
|---|
| 1628 | Top := (Screen.Height - Height) div 2;
|
|---|
| 1629 | if Kind = kProject then
|
|---|
| 1630 | Top := Top + 48;
|
|---|
| 1631 | end;
|
|---|
| 1632 |
|
|---|
| 1633 | Layer0Btn.Visible := MultiPage and (Lines[0] > 0);
|
|---|
| 1634 | Layer1Btn.Visible := MultiPage and (Lines[1] > 0);
|
|---|
| 1635 | Layer2Btn.Visible := MultiPage and (Lines[2] > 0);
|
|---|
| 1636 | if Kind = kProject then
|
|---|
| 1637 | begin
|
|---|
| 1638 | Layer0Btn.Top := ClientHeight - 31;
|
|---|
| 1639 | Layer0Btn.Left := ClientWidth div 2 - (12 + 29);
|
|---|
| 1640 | Layer0Btn.Down := true;
|
|---|
| 1641 | Layer1Btn.Top := ClientHeight - 31;
|
|---|
| 1642 | Layer1Btn.Left := ClientWidth div 2 - (12 - 29);
|
|---|
| 1643 | Layer1Btn.Down := false;
|
|---|
| 1644 | Layer2Btn.Top := ClientHeight - 31;
|
|---|
| 1645 | Layer2Btn.Left := ClientWidth div 2 - 12;
|
|---|
| 1646 | Layer2Btn.Down := false;
|
|---|
| 1647 | end;
|
|---|
| 1648 |
|
|---|
| 1649 | Layer := 0;
|
|---|
| 1650 | Sel := -2;
|
|---|
| 1651 | ScienceNation := -1;
|
|---|
| 1652 | sb.Init(Lines[Layer] - 1, DispLines);
|
|---|
| 1653 |
|
|---|
| 1654 | OffscreenPaint;
|
|---|
| 1655 | end;
|
|---|
| 1656 |
|
|---|
| 1657 | procedure TListDlg.ShowNewContent(NewMode: integer; ListKind: TListKind);
|
|---|
| 1658 | var
|
|---|
| 1659 | i: integer;
|
|---|
| 1660 | ShowFocus, forceclose: boolean;
|
|---|
| 1661 | begin
|
|---|
| 1662 | forceclose := (ListKind <> Kind) and
|
|---|
| 1663 | not((Kind = kCities) and (ListKind = kCityEvents)) and
|
|---|
| 1664 | not((Kind = kCityEvents) and (ListKind = kCities)) and
|
|---|
| 1665 | not((Kind = kModels) and (ListKind = kEModels)) and
|
|---|
| 1666 | not((Kind = kEModels) and (ListKind = kModels));
|
|---|
| 1667 |
|
|---|
| 1668 | Kind := ListKind;
|
|---|
| 1669 | ModalIndication := not(Kind in MustChooseKind);
|
|---|
| 1670 | case Kind of
|
|---|
| 1671 | kProject:
|
|---|
| 1672 | Caption := Phrases.Lookup('TITLE_PROJECT');
|
|---|
| 1673 | kAdvance:
|
|---|
| 1674 | Caption := Phrases.Lookup('TITLE_TECHSELECT');
|
|---|
| 1675 | kFarAdvance:
|
|---|
| 1676 | Caption := Phrases.Lookup('TITLE_FARTECH');
|
|---|
| 1677 | kModels, kEModels:
|
|---|
| 1678 | Caption := Phrases.Lookup('FRMILREP');
|
|---|
| 1679 | kAllEModels:
|
|---|
| 1680 | Caption := Phrases.Lookup('TITLE_EMODELS');
|
|---|
| 1681 | kTribe:
|
|---|
| 1682 | Caption := Phrases.Lookup('TITLE_TRIBE');
|
|---|
| 1683 | kScience:
|
|---|
| 1684 | Caption := Phrases.Lookup('TITLE_SCIENCE');
|
|---|
| 1685 | kShipPart, kEShipPart:
|
|---|
| 1686 | Caption := Phrases.Lookup('TITLE_CHOOSESHIPPART');
|
|---|
| 1687 | kChooseTech, kChooseETech:
|
|---|
| 1688 | Caption := Phrases.Lookup('TITLE_CHOOSETECH');
|
|---|
| 1689 | kChooseModel, kChooseEModel:
|
|---|
| 1690 | Caption := Phrases.Lookup('TITLE_CHOOSEMODEL');
|
|---|
| 1691 | kStealTech:
|
|---|
| 1692 | Caption := Phrases.Lookup('TITLE_CHOOSETECH');
|
|---|
| 1693 | kGov:
|
|---|
| 1694 | Caption := Phrases.Lookup('TITLE_GOV');
|
|---|
| 1695 | kMission:
|
|---|
| 1696 | Caption := Phrases.Lookup('TITLE_SPYMISSION');
|
|---|
| 1697 | end;
|
|---|
| 1698 |
|
|---|
| 1699 | case Kind of
|
|---|
| 1700 | kMission:
|
|---|
| 1701 | HelpContext := 'SPYMISSIONS';
|
|---|
| 1702 | else
|
|---|
| 1703 | HelpContext := 'CONCEPTS'
|
|---|
| 1704 | end;
|
|---|
| 1705 |
|
|---|
| 1706 | if Kind = kAdvance then
|
|---|
| 1707 | begin
|
|---|
| 1708 | ToggleBtn.ButtonIndex := 13;
|
|---|
| 1709 | ToggleBtn.Hint := Phrases.Lookup('FARTECH');
|
|---|
| 1710 | end
|
|---|
| 1711 | else if Kind = kCities then
|
|---|
| 1712 | begin
|
|---|
| 1713 | ToggleBtn.ButtonIndex := 15;
|
|---|
| 1714 | ToggleBtn.Hint := Phrases.Lookup('BTN_PAGE');
|
|---|
| 1715 | end
|
|---|
| 1716 | else
|
|---|
| 1717 | begin
|
|---|
| 1718 | ToggleBtn.ButtonIndex := 28;
|
|---|
| 1719 | ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT');
|
|---|
| 1720 | end;
|
|---|
| 1721 |
|
|---|
| 1722 | if Kind = kAdvance then // show focus button?
|
|---|
| 1723 | if MyData.FarTech <> adNone then
|
|---|
| 1724 | ShowFocus := true
|
|---|
| 1725 | else
|
|---|
| 1726 | begin
|
|---|
| 1727 | ShowFocus := false;
|
|---|
| 1728 | for i := 0 to nAdv - 1 do
|
|---|
| 1729 | if not(i in FutureTech) and (MyRO.Tech[i] < tsApplicable) and
|
|---|
| 1730 | ((AdvValue[i] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
|
|---|
| 1731 | ((AdvValue[i] < 1000) or (MyRO.Tech[adScience] > tsNA)) and
|
|---|
| 1732 | (Server(sSetResearch - sExecute, me, i, nil^) < rExecuted) then
|
|---|
| 1733 | ShowFocus := true;
|
|---|
| 1734 | end;
|
|---|
| 1735 | ToggleBtn.Visible := (Kind = kCities) and not supervising or (Kind = kAdvance)
|
|---|
| 1736 | and ShowFocus or (Kind = kModels) or (Kind = kEModels);
|
|---|
| 1737 | CloseBtn.Visible := not(Kind in MustChooseKind);
|
|---|
| 1738 |
|
|---|
| 1739 | inherited ShowNewContent(NewMode, forceclose);
|
|---|
| 1740 | end; // ShowNewContent
|
|---|
| 1741 |
|
|---|
| 1742 | procedure TListDlg.ShowNewContent_CityProject(NewMode, cix: integer);
|
|---|
| 1743 | begin
|
|---|
| 1744 | cixProject := cix;
|
|---|
| 1745 | ShowNewContent(NewMode, kProject);
|
|---|
| 1746 | end;
|
|---|
| 1747 |
|
|---|
| 1748 | procedure TListDlg.ShowNewContent_MilReport(NewMode, p: integer);
|
|---|
| 1749 | begin
|
|---|
| 1750 | pView := p;
|
|---|
| 1751 | if p = me then
|
|---|
| 1752 | ShowNewContent(NewMode, kModels)
|
|---|
| 1753 | else
|
|---|
| 1754 | ShowNewContent(NewMode, kEModels);
|
|---|
| 1755 | end;
|
|---|
| 1756 |
|
|---|
| 1757 | procedure TListDlg.PlayerClick(Sender: TObject);
|
|---|
| 1758 | begin
|
|---|
| 1759 | if TComponent(Sender).Tag = me then
|
|---|
| 1760 | Kind := kModels
|
|---|
| 1761 | else
|
|---|
| 1762 | begin
|
|---|
| 1763 | Kind := kEModels;
|
|---|
| 1764 | pView := TComponent(Sender).Tag;
|
|---|
| 1765 | end;
|
|---|
| 1766 | InitLines;
|
|---|
| 1767 | Sel := -2;
|
|---|
| 1768 | sb.Init(Lines[Layer] - 1, DispLines);
|
|---|
| 1769 | OffscreenPaint;
|
|---|
| 1770 | Invalidate;
|
|---|
| 1771 | end;
|
|---|
| 1772 |
|
|---|
| 1773 | procedure TListDlg.ModeBtnClick(Sender: TObject);
|
|---|
| 1774 | begin
|
|---|
| 1775 | Layer0Btn.Down := Sender = Layer0Btn;
|
|---|
| 1776 | Layer1Btn.Down := Sender = Layer1Btn;
|
|---|
| 1777 | Layer2Btn.Down := Sender = Layer2Btn;
|
|---|
| 1778 | Layer := TComponent(Sender).Tag;
|
|---|
| 1779 |
|
|---|
| 1780 | Sel := -2;
|
|---|
| 1781 | sb.Init(Lines[Layer] - 1, DispLines);
|
|---|
| 1782 | SmartUpdateContent;
|
|---|
| 1783 | end;
|
|---|
| 1784 |
|
|---|
| 1785 | procedure TListDlg.ToggleBtnClick(Sender: TObject);
|
|---|
| 1786 | var
|
|---|
| 1787 | p1: integer;
|
|---|
| 1788 | m: TMenuItem;
|
|---|
| 1789 | begin
|
|---|
| 1790 | case Kind of
|
|---|
| 1791 | kAdvance:
|
|---|
| 1792 | begin
|
|---|
| 1793 | result := adFar;
|
|---|
| 1794 | Closable := true;
|
|---|
| 1795 | Close;
|
|---|
| 1796 | end;
|
|---|
| 1797 | kCities, kCityEvents:
|
|---|
| 1798 | begin
|
|---|
| 1799 | if Kind = kCities then
|
|---|
| 1800 | Kind := kCityEvents
|
|---|
| 1801 | else
|
|---|
| 1802 | Kind := kCities;
|
|---|
| 1803 | OffscreenPaint;
|
|---|
| 1804 | Invalidate;
|
|---|
| 1805 | end;
|
|---|
| 1806 | kModels, kEModels:
|
|---|
| 1807 | begin
|
|---|
| 1808 | EmptyMenu(Popup.Items);
|
|---|
| 1809 | if G.Difficulty[me] > 0 then
|
|---|
| 1810 | begin
|
|---|
| 1811 | m := TMenuItem.Create(Popup);
|
|---|
| 1812 | m.RadioItem := true;
|
|---|
| 1813 | m.Caption := Tribe[me].TPhrase('SHORTNAME');
|
|---|
| 1814 | m.Tag := me;
|
|---|
| 1815 | m.OnClick := PlayerClick;
|
|---|
| 1816 | if Kind = kModels then
|
|---|
| 1817 | m.Checked := true;
|
|---|
| 1818 | Popup.Items.Add(m);
|
|---|
| 1819 | end;
|
|---|
| 1820 | for p1 := 0 to nPl - 1 do
|
|---|
| 1821 | if (p1 <> me) and (MyRO.EnemyReport[p1] <> nil) and
|
|---|
| 1822 | (MyRO.EnemyReport[p1].TurnOfMilReport >= 0) then
|
|---|
| 1823 | begin
|
|---|
| 1824 | m := TMenuItem.Create(Popup);
|
|---|
| 1825 | m.RadioItem := true;
|
|---|
| 1826 | m.Caption := Tribe[p1].TPhrase('SHORTNAME');
|
|---|
| 1827 | m.Tag := p1;
|
|---|
| 1828 | m.OnClick := PlayerClick;
|
|---|
| 1829 | if (Kind = kEModels) and (p1 = pView) then
|
|---|
| 1830 | m.Checked := true;
|
|---|
| 1831 | Popup.Items.Add(m);
|
|---|
| 1832 | end;
|
|---|
| 1833 | Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top +
|
|---|
| 1834 | ToggleBtn.Height);
|
|---|
| 1835 | end;
|
|---|
| 1836 | end;
|
|---|
| 1837 | end;
|
|---|
| 1838 |
|
|---|
| 1839 | procedure TListDlg.FormKeyDown(Sender: TObject; var Key: word;
|
|---|
| 1840 | Shift: TShiftState);
|
|---|
| 1841 | begin
|
|---|
| 1842 | if (Key = VK_F2) and (Kind in [kModels, kEModels]) then // my key
|
|---|
| 1843 | // !!! toggle
|
|---|
| 1844 | else if (Key = VK_F3) and (Kind in [kCities, kCityEvents]) then // my key
|
|---|
| 1845 | ToggleBtnClick(nil)
|
|---|
| 1846 | else if ((Key = VK_ESCAPE) or (Key = VK_RETURN)) and not CloseBtn.Visible then
|
|---|
| 1847 | // prevent closing
|
|---|
| 1848 | else
|
|---|
| 1849 | inherited;
|
|---|
| 1850 | end;
|
|---|
| 1851 |
|
|---|
| 1852 | procedure TListDlg.EcoChange;
|
|---|
| 1853 | begin
|
|---|
| 1854 | if Visible and (Kind = kCities) then
|
|---|
| 1855 | SmartUpdateContent;
|
|---|
| 1856 | end;
|
|---|
| 1857 |
|
|---|
| 1858 | procedure TListDlg.TechChange;
|
|---|
| 1859 | begin
|
|---|
| 1860 | if Visible and (Kind = kScience) then
|
|---|
| 1861 | begin
|
|---|
| 1862 | FormShow(nil);
|
|---|
| 1863 | Invalidate;
|
|---|
| 1864 | end;
|
|---|
| 1865 | end;
|
|---|
| 1866 |
|
|---|
| 1867 | procedure TListDlg.AddCity;
|
|---|
| 1868 | begin
|
|---|
| 1869 | if Visible and (Kind = kCities) then
|
|---|
| 1870 | begin
|
|---|
| 1871 | FormShow(nil);
|
|---|
| 1872 | Invalidate;
|
|---|
| 1873 | end;
|
|---|
| 1874 | end;
|
|---|
| 1875 |
|
|---|
| 1876 | procedure TListDlg.RemoveUnit;
|
|---|
| 1877 | begin
|
|---|
| 1878 | if ListDlg.Visible and (Kind = kModels) then
|
|---|
| 1879 | SmartUpdateContent;
|
|---|
| 1880 | end;
|
|---|
| 1881 |
|
|---|
| 1882 | procedure TListDlg.ScrollBarUpdate(Sender: TObject);
|
|---|
| 1883 | begin
|
|---|
| 1884 | Sel := -2;
|
|---|
| 1885 | SmartUpdateContent(true);
|
|---|
| 1886 | end;
|
|---|
| 1887 |
|
|---|
| 1888 | end.
|
|---|