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