Changeset 269
- Timestamp:
- Jan 21, 2019, 12:38:20 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormClient.pas
r268 r269 106 106 FormClient: TFormClient; 107 107 108 const 109 MapBackgroundColor = $404040; 110 108 111 implementation 109 112 … … 180 183 X, Y: Integer; 181 184 TempView: TView; 182 const183 BackgroundColor = $404040;184 185 begin 185 186 DrawStart := Now; … … 189 190 if csOpaque in PaintBox1.ControlStyle then begin 190 191 TempBitmap.SetSize(PaintBox1.Width, PaintBox1.Height); 191 TempBitmap.Canvas.Brush.Color := BackGroundColor; //clBackground; //PaintBox1.GetColorResolvingParent;192 TempBitmap.Canvas.Brush.Color := MapBackGroundColor; //clBackground; //PaintBox1.GetColorResolvingParent; 192 193 TempBitmap.Canvas.FillRect(0, 0, PaintBox1.Width, PaintBox1.Height); 193 194 Client.Paint(TempBitmap.Canvas, View); … … 238 239 ) 239 240 ); 240 Client. Paint(PaintBox1.Canvas, TempView);241 Client.DrawCells(PaintBox1.Canvas, TempView); 241 242 end; 242 243 end; … … 291 292 end; 292 293 end else begin 293 Client.DrawCellLinks(PaintBox1.Canvas, View);294 294 Client.Paint(PaintBox1.Canvas, View); 295 Client.DrawCities(PaintBox1.Canvas, View);296 Client.DrawSelection(PaintBox1.Canvas, View);297 Client.DrawArrows(PaintBox1.Canvas, View);298 295 end; 299 296 end; … … 436 433 437 434 procedure TFormClient.AZoomAllExecute(Sender: TObject); 438 var439 Factor: TPointF;440 MapRect: TRect;441 NewZoom: Single;442 435 begin 443 436 with Core, Game, Client, View do begin 444 MapRect := Map.CalculatePixelRect; 445 Factor := TPointF.Create(DestRect.Size.X / MapRect.Size.X, 446 DestRect.Size.Y / MapRect.Size.Y); 447 if Factor.X < Factor.Y then NewZoom := Factor.X 448 else NewZoom := Factor.Y; 449 if NewZoom = 0 then NewZoom := 1; 450 Zoom := NewZoom; 451 CenterMap; 437 ZoomAll; 452 438 end; 453 439 Redraw; -
trunk/Forms/UFormNew.lfm
r268 r269 1 1 object FormNew: TFormNew 2 2 Left = 546 3 Height = 74 84 Top = 18 15 Width = 1 1543 Height = 745 4 Top = 184 5 Width = 1211 6 6 Caption = 'New game' 7 ClientHeight = 74 88 ClientWidth = 1 1547 ClientHeight = 745 8 ClientWidth = 1211 9 9 Constraints.MinHeight = 501 10 10 Constraints.MinWidth = 667 … … 18 18 object PageControl1: TPageControl 19 19 Left = 4 20 Height = 69 520 Height = 692 21 21 Top = 4 22 Width = 74923 ActivePage = TabSheetM ode22 Width = 806 23 ActivePage = TabSheetMap 24 24 Align = alClient 25 25 BorderSpacing.Around = 4 26 TabIndex = 026 TabIndex = 2 27 27 TabOrder = 0 28 OnChange = PageControl1Change 28 29 object TabSheetMode: TTabSheet 29 30 Caption = 'Mode' 30 ClientHeight = 65 531 ClientWidth = 7 3931 ClientHeight = 652 32 ClientWidth = 796 32 33 object Panel3: TPanel 33 34 Left = 0 … … 158 159 object TabSheetPlayers: TTabSheet 159 160 Caption = 'Players' 160 ClientHeight = 65 5161 ClientWidth = 7 39161 ClientHeight = 652 162 ClientWidth = 796 162 163 object Panel2: TPanel 163 164 Left = 0 164 Height = 65 5165 Height = 652 165 166 Top = 0 166 Width = 7 39167 Width = 796 167 168 Align = alClient 168 169 BevelOuter = bvNone 169 ClientHeight = 65 5170 ClientWidth = 7 39170 ClientHeight = 652 171 ClientWidth = 796 171 172 TabOrder = 0 172 173 object ListViewPlayers: TListView 173 174 Left = 4 174 Height = 60 5175 Height = 602 175 176 Top = 4 176 Width = 7 31177 Width = 788 177 178 Align = alTop 178 179 Anchors = [akTop, akLeft, akRight, akBottom] … … 212 213 Left = 16 213 214 Height = 25 214 Top = 61 7215 Top = 614 215 216 Width = 83 216 217 Action = APlayerAdd … … 221 222 Left = 120 222 223 Height = 25 223 Top = 61 7224 Top = 614 224 225 Width = 83 225 226 Action = APlayerModify … … 230 231 Left = 224 231 232 Height = 25 232 Top = 61 7233 Top = 614 233 234 Width = 83 234 235 Action = APlayerRemove … … 240 241 object TabSheetMap: TTabSheet 241 242 Caption = 'Map' 242 ClientHeight = 655 243 ClientWidth = 739 243 ClientHeight = 652 244 ClientWidth = 796 245 OnShow = TabSheetMapShow 244 246 object Panel1: TPanel 245 247 Left = 0 246 Height = 65 5248 Height = 652 247 249 Top = 0 248 Width = 7 39250 Width = 796 249 251 Align = alClient 250 252 BevelOuter = bvNone 251 ClientHeight = 65 5252 ClientWidth = 7 39253 ClientHeight = 652 254 ClientWidth = 796 253 255 TabOrder = 0 254 256 object Label1: TLabel … … 292 294 Height = 58 293 295 Top = 8 294 Width = 488296 Width = 545 295 297 Max = 100 296 298 Min = 2 … … 305 307 Height = 58 306 308 Top = 49 307 Width = 488309 Width = 545 308 310 Max = 100 309 311 Min = 2 … … 335 337 'Isometric' 336 338 ) 339 OnChange = ComboBoxGridTypeChange 337 340 Style = csDropDownList 338 341 TabOrder = 4 … … 362 365 end 363 366 object CheckBoxSymetricMap: TCheckBox 364 Left = 472367 Left = 8 365 368 Height = 27 366 Top = 110367 Width = 251369 Top = 248 370 Width = 308 368 371 Anchors = [akTop, akLeft, akRight] 369 372 AutoSize = False 370 373 Caption = 'Symetric map' 374 OnChange = CheckBoxSymetricMapChange 371 375 TabOrder = 6 372 376 end … … 374 378 Left = 216 375 379 Height = 43 376 Top = 224380 Top = 315 377 381 Width = 106 378 382 MinValue = 1 383 OnChange = SpinEditVoidPercentChange 379 384 TabOrder = 7 380 385 Value = 1 … … 383 388 Left = 8 384 389 Height = 30 385 Top = 232390 Top = 324 386 391 Width = 189 387 392 Caption = 'Inaccessible places' … … 392 397 Left = 8 393 398 Height = 30 394 Top = 272399 Top = 368 395 400 Width = 73 396 401 Caption = 'Cities' … … 401 406 Left = 216 402 407 Height = 43 403 Top = 272408 Top = 360 404 409 Width = 106 405 410 MinValue = 1 411 OnChange = SpinEditCityPercentChange 406 412 TabOrder = 10 407 413 Value = 1 … … 410 416 Left = 331 411 417 Height = 26 412 Top = 272418 Top = 368 413 419 Width = 15 414 420 Caption = '%' … … 418 424 Left = 331 419 425 Height = 26 420 Top = 232426 Top = 324 421 427 Width = 15 422 428 Caption = '%' … … 424 430 end 425 431 object SpinEditNeutralUnits: TSpinEdit 426 Left = 408432 Left = 312 427 433 Height = 43 428 Top = 384434 Top = 488 429 435 Width = 98 430 436 MaxValue = 99 437 OnChange = SpinEditNeutralUnitsChange 431 438 TabOrder = 11 432 439 Value = 12 … … 435 442 Left = 8 436 443 Height = 26 437 Top = 384444 Top = 496 438 445 Width = 227 439 446 Caption = 'Max random neutral units:' … … 444 451 Height = 43 445 452 Top = 184 446 Width = 472453 Width = 529 447 454 Anchors = [akTop, akLeft, akRight] 455 OnChange = EditImageFileChange 448 456 TabOrder = 12 449 457 end 450 458 object ButtonImageBrowse: TButton 451 Left = 6 24452 Height = 25453 Top = 1 92459 Left = 680 460 Height = 38 461 Top = 189 454 462 Width = 99 455 463 Anchors = [akTop, akRight] … … 461 469 Left = 8 462 470 Height = 26 463 Top = 1 84471 Top = 191 464 472 Width = 90 465 473 Caption = 'Image file:' … … 469 477 Left = 8 470 478 Height = 30 471 Top = 310479 Top = 408 472 480 Width = 212 473 481 Caption = 'Bridges between cells' 482 OnChange = CheckBoxBridgesChange 474 483 TabOrder = 14 475 484 end 476 485 object SpinEditMaxPower: TSpinEdit 477 Left = 408486 Left = 312 478 487 Height = 43 479 Top = 344488 Top = 440 480 489 Width = 98 481 490 MaxValue = 1000000 … … 488 497 Left = 8 489 498 Height = 26 490 Top = 344499 Top = 448 491 500 Width = 156 492 501 Caption = 'Max units per cell:' … … 494 503 end 495 504 object CheckBoxCyclicMap: TCheckBox 496 Left = 472505 Left = 8 497 506 Height = 27 498 Top = 137499 Width = 251507 Top = 283 508 Width = 308 500 509 Anchors = [akTop, akLeft, akRight] 501 510 AutoSize = False 502 511 Caption = 'Cyclic map' 512 OnChange = CheckBoxCyclicMapChange 503 513 TabOrder = 16 514 end 515 object Image1: TImage 516 Left = 419 517 Height = 316 518 Top = 272 519 Width = 359 520 end 521 object Label15: TLabel 522 Left = 419 523 Height = 26 524 Top = 240 525 Width = 147 526 Caption = 'Random preview:' 527 ParentColor = False 504 528 end 505 529 end … … 507 531 object TabSheetRules: TTabSheet 508 532 Caption = 'Rules' 509 ClientHeight = 65 5510 ClientWidth = 7 39533 ClientHeight = 652 534 ClientWidth = 796 511 535 object Panel4: TPanel 512 536 Left = 0 … … 612 636 object TabSheetCaptureCells: TTabSheet 613 637 ClientHeight = 74 614 ClientWidth = 7 06638 ClientWidth = 712 615 639 object Label14: TLabel 616 640 Left = 8 … … 634 658 object TabSheetStayAliveTurns: TTabSheet 635 659 ClientHeight = 74 636 ClientWidth = 7 06660 ClientWidth = 712 637 661 object Label13: TLabel 638 662 Left = 8 … … 673 697 Left = 0 674 698 Height = 45 675 Top = 70 3676 Width = 1 154699 Top = 700 700 Width = 1211 677 701 Align = alBottom 678 702 BevelOuter = bvNone 679 703 ClientHeight = 45 680 ClientWidth = 1 154704 ClientWidth = 1211 681 705 TabOrder = 1 682 706 object ButtonOk: TButton 683 Left = 966707 Left = 1023 684 708 Height = 25 685 709 Top = 6 … … 691 715 end 692 716 object ButtonCancel: TButton 693 Left = 1 070717 Left = 1127 694 718 Height = 25 695 719 Top = 6 … … 702 726 end 703 727 object PanelChat: TPanel 704 Left = 763705 Height = 70 3728 Left = 820 729 Height = 700 706 730 Top = 0 707 731 Width = 391 … … 711 735 end 712 736 object Splitter1: TSplitter 713 Left = 757714 Height = 70 3737 Left = 814 738 Height = 700 715 739 Top = 0 716 740 Width = 6 … … 720 744 object ActionList1: TActionList 721 745 Images = Core.ImageListSmall 722 left = 464723 top = 464746 left = 864 747 top = 216 724 748 object APlayerModify: TAction 725 749 Caption = 'Modify' … … 748 772 end 749 773 object OpenPictureDialog1: TOpenPictureDialog 750 left = 602751 top = 464774 left = 864 775 top = 360 752 776 end 753 777 object PopupMenuPlayers: TPopupMenu 754 left = 312755 top = 464778 left = 864 779 top = 288 756 780 object MenuItem1: TMenuItem 757 781 Action = APlayerAdd … … 766 790 end 767 791 object PopupMenuServers: TPopupMenu 768 left = 176769 top = 464792 left = 864 793 top = 136 770 794 object MenuItem4: TMenuItem 771 795 Action = AServerAdd … … 778 802 end 779 803 end 804 object TimerMapPreview: TTimer 805 Interval = 500 806 OnTimer = TimerMapPreviewTimer 807 left = 864 808 top = 446 809 end 780 810 end -
trunk/Forms/UFormNew.pas
r266 r269 43 43 EditImageFile: TEdit; 44 44 EditServerAddress: TEdit; 45 Image1: TImage; 45 46 Label1: TLabel; 46 47 Label10: TLabel; … … 49 50 Label13: TLabel; 50 51 Label14: TLabel; 52 Label15: TLabel; 51 53 Label2: TLabel; 52 54 Label3: TLabel; … … 72 74 Panel3: TPanel; 73 75 Panel4: TPanel; 76 Panel5: TPanel; 74 77 PanelButtons: TPanel; 75 78 PanelChat: TPanel; … … 91 94 SpinEditVoidPercent: TSpinEdit; 92 95 Splitter1: TSplitter; 96 TabSheetUnits: TTabSheet; 93 97 TabSheetCaptureEntireMap: TTabSheet; 94 98 TabSheetNone: TTabSheet; … … 101 105 TabSheetMode: TTabSheet; 102 106 TabSheetStayAliveTurns: TTabSheet; 107 TimerMapPreview: TTimer; 103 108 TrackBarSizeX: TTrackBar; 104 109 TrackBarSizeY: TTrackBar; … … 110 115 procedure AServerRemoveExecute(Sender: TObject); 111 116 procedure ButtonImageBrowseClick(Sender: TObject); 117 procedure CheckBoxBridgesChange(Sender: TObject); 112 118 procedure CheckBoxCityChange(Sender: TObject); 119 procedure CheckBoxCyclicMapChange(Sender: TObject); 120 procedure CheckBoxSymetricMapChange(Sender: TObject); 113 121 procedure CheckBoxVoidChange(Sender: TObject); 122 procedure ComboBoxGridTypeChange(Sender: TObject); 114 123 procedure ComboBoxMapShapeChange(Sender: TObject); 115 124 procedure ComboBoxWinObjectiveChange(Sender: TObject); 125 procedure EditImageFileChange(Sender: TObject); 116 126 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 117 127 procedure FormCreate(Sender: TObject); … … 132 142 procedure ListViewServersSelectItem(Sender: TObject; Item: TListItem; 133 143 Selected: Boolean); 144 procedure PageControl1Change(Sender: TObject); 134 145 procedure RadioButtonModeLocalChange(Sender: TObject); 146 procedure SpinEditCityPercentChange(Sender: TObject); 135 147 procedure SpinEditMapSizeXChange(Sender: TObject); 136 148 procedure SpinEditMapSizeYChange(Sender: TObject); 137 149 procedure SpinEditMaxPowerChange(Sender: TObject); 150 procedure SpinEditNeutralUnitsChange(Sender: TObject); 151 procedure SpinEditVoidPercentChange(Sender: TObject); 152 procedure TabSheetMapShow(Sender: TObject); 153 procedure TimerMapPreviewTimer(Sender: TObject); 138 154 procedure TrackBarSizeYChange(Sender: TObject); 139 155 procedure TrackBarSizeXChange(Sender: TObject); … … 141 157 Players: TPlayers; 142 158 ServerList: TServerList; 159 GamePreview: TGame; 160 MapPreviewRedrawPending: Boolean; 161 procedure LoadGame(Game: TGame); 162 procedure SaveGame(Game: TGame); 163 procedure MapPreviewPaint; 164 procedure MapPreviewRedraw; 143 165 public 144 166 procedure Translate; … … 152 174 FormNew: TFormNew; 153 175 176 154 177 implementation 155 178 … … 157 180 158 181 uses 159 UFormPlayer, UFormChat, UCore, UFormServer ;182 UFormPlayer, UFormChat, UCore, UFormServer, UClientGUI, UFormClient; 160 183 161 184 resourcestring … … 240 263 end; 241 264 265 procedure TFormNew.PageControl1Change(Sender: TObject); 266 begin 267 MapPreviewRedraw; 268 end; 269 242 270 procedure TFormNew.RadioButtonModeLocalChange(Sender: TObject); 243 271 begin … … 245 273 end; 246 274 275 procedure TFormNew.SpinEditCityPercentChange(Sender: TObject); 276 begin 277 MapPreviewRedraw; 278 end; 279 247 280 procedure TFormNew.SpinEditMapSizeXChange(Sender: TObject); 248 281 begin 249 282 TrackBarSizeX.Position := SpinEditMapSizeX.Value; 283 MapPreviewRedraw; 250 284 end; 251 285 … … 253 287 begin 254 288 TrackBarSizeY.Position := SpinEditMapSizeY.Value; 289 MapPreviewRedraw; 255 290 end; 256 291 … … 260 295 end; 261 296 297 procedure TFormNew.SpinEditNeutralUnitsChange(Sender: TObject); 298 begin 299 MapPreviewRedraw; 300 end; 301 302 procedure TFormNew.SpinEditVoidPercentChange(Sender: TObject); 303 begin 304 MapPreviewRedraw; 305 end; 306 307 procedure TFormNew.TabSheetMapShow(Sender: TObject); 308 begin 309 MapPreviewRedraw; 310 end; 311 312 procedure TFormNew.TimerMapPreviewTimer(Sender: TObject); 313 begin 314 if MapPreviewRedrawPending then begin 315 MapPreviewPaint; 316 MapPreviewRedrawPending := False; 317 end; 318 end; 319 262 320 procedure TFormNew.TrackBarSizeYChange(Sender: TObject); 263 321 begin … … 270 328 end; 271 329 272 procedure TFormNew.Translate; 273 var 274 LastIndex: Integer; 275 begin 276 with ComboBoxGridType do begin 277 LastIndex := ItemIndex; 278 Clear; 279 Items.Add(SGridTypeHexagon); 280 Items.Add(SGridTypeSquare); 281 Items.Add(SGridTypeTriangle); 282 Items.Add(SGridTypeRandom); 283 Items.Add(SGridTypeIsometric); 284 ItemIndex := LastIndex; 285 end; 286 with ComboBoxWinObjective do begin 287 LastIndex := ItemIndex; 288 Clear; 289 Items.Add(SWinObjectiveNone); 290 Items.Add(SWinObjectiveDefeatAllOponents); 291 Items.Add(SWinObjectiveDefeatAllCities); 292 Items.Add(SWinObjectiveCapturePosition); 293 Items.Add(SWinObjectiveStayAliveForTurns); 294 Items.Add(SWinObjectiveCaptureEntireMap); 295 ItemIndex := LastIndex; 296 end; 297 with ComboBoxMapShape do begin 298 LastIndex := ItemIndex; 299 Clear; 300 Items.Add(SRectangular); 301 Items.Add(SFromImageFile); 302 Items.Add(SRounded); 303 ItemIndex := LastIndex; 304 end; 305 with RadioGroupGrowCells do begin 306 LastIndex := ItemIndex; 307 Items.Clear; 308 Items.Add(SGrowNone); 309 Items.Add(SGrowPlayerCities); 310 Items.Add(SGrowPlayerAllCells); 311 ItemIndex := LastIndex; 312 end; 313 with RadioGroupGrowAmount do begin 314 LastIndex := ItemIndex; 315 Items.Clear; 316 Items.Add(SGrowAmountByOne); 317 Items.Add(SGrowAmountBySquareRoot); 318 ItemIndex := LastIndex; 319 end; 320 Core.CoolTranslator1.TranslateComponentRecursive(Self); 321 end; 322 323 procedure TFormNew.ReloadView; 324 begin 325 ListViewPlayers.Items.Count := Players.Count; 326 ListViewPlayers.Refresh; 327 ListViewServers.Items.Count := ServerList.Items.Count; 328 ListViewServers.Refresh; 329 Translate; 330 UpdateInterface; 331 end; 332 333 procedure TFormNew.UpdateInterface; 334 var 335 WinObjective: TWinObjective; 336 begin 337 APlayerRemove.Enabled := Assigned(ListViewPlayers.Selected) and (Players.Count > MinPlayerCount); 338 APlayerAdd.Enabled := Players.Count < MaxPlayerCount; 339 APlayerModify.Enabled := Assigned(ListViewPlayers.Selected); 340 EditImageFile.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage); 341 ButtonImageBrowse.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage); 342 EditServerAddress.Enabled := RadioButtonModeNetworkServer.Checked; 343 SpinEditServerPort.Enabled := RadioButtonModeNetworkServer.Checked; 344 ListViewServers.Enabled := RadioButtonModeNetworkClient.Checked; 345 PanelChat.Visible := RadioButtonModeNetworkClient.Checked or RadioButtonModeNetworkServer.Checked; 346 SpinEditNeutralUnits.MaxValue := SpinEditMaxPower.Value; 347 AServerRemove.Enabled := RadioButtonModeNetworkClient.Checked and Assigned(ListViewServers.Selected); 348 AServerAdd.Enabled := RadioButtonModeNetworkClient.Checked; 349 AServerModify.Enabled := RadioButtonModeNetworkClient.Checked; 350 WinObjective := TWinObjective(ComboBoxWinObjective.ItemIndex); 351 case WinObjective of 352 woNone: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetNone); 353 woDefeatAllOponents: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetDefeatEnemies); 354 woDefeatAllOponentsCities: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetCaptureCities); 355 woSpecialCaptureCell: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetCaptureCells); 356 woStayAliveForDefinedTurns: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetStayAliveTurns); 357 woCaptureEntireMap: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetCaptureEntireMap); 358 end; 359 end; 360 361 procedure TFormNew.FormShow(Sender: TObject); 362 begin 363 Core.PersistentForm.Load(Self); 364 Core.ThemeManager1.UseTheme(Self); 365 ReloadView; 366 //Height := Trunc(1.5 * Height); 367 //PageControl1.TabIndex := 0; 368 {$IFNDEF DEBUG} 369 TabSheetMode.TabVisible := False; 370 TabSheetMode.Enabled := False; 371 {$ENDIF} 372 end; 373 374 procedure TFormNew.ListViewPlayersCustomDrawSubItem(Sender: TCustomListView; 375 Item: TListItem; SubItem: Integer; State: TCustomDrawState; 376 var DefaultDraw: Boolean); 377 begin 378 if SubItem = 2 then 379 with ListViewPlayers.Canvas do begin 380 Brush.Color := TPlayer(Item.Data).Color; 381 Brush.Style := bsSolid; 382 FillRect(Item.DisplayRectSubItem(2, drBounds)); 383 end; 384 end; 385 386 procedure TFormNew.FormCreate(Sender: TObject); 387 begin 388 Players := TPlayers.Create; 389 ServerList := TServerList.Create; 390 FormChat := TFormChat.Create(nil); 391 FormChat.ManualDock(PanelChat, nil, alClient); 392 FormChat.Align := alClient; 393 FormChat.Show; 394 Translate; 395 end; 396 397 procedure TFormNew.CheckBoxCityChange(Sender: TObject); 398 begin 399 SpinEditCityPercent.Enabled := CheckBoxCity.Checked; 400 end; 401 402 procedure TFormNew.CheckBoxVoidChange(Sender: TObject); 403 begin 404 SpinEditVoidPercent.Enabled := CheckBoxVoid.Checked; 405 end; 406 407 procedure TFormNew.ComboBoxMapShapeChange(Sender: TObject); 408 begin 409 ReloadView; 410 end; 411 412 procedure TFormNew.ComboBoxWinObjectiveChange(Sender: TObject); 413 begin 414 UpdateInterface; 415 end; 416 417 procedure TFormNew.FormClose(Sender: TObject; var CloseAction: TCloseAction); 418 begin 419 Core.PersistentForm.Save(Self); 420 end; 421 422 procedure TFormNew.APlayerModifyExecute(Sender: TObject); 423 begin 424 FormPlayer := TFormPlayer.Create(nil); 425 try 426 if Assigned(ListViewPlayers.Selected) then begin 427 FormPlayer.Load(TPlayer(ListViewPlayers.Selected.Data)); 428 if FormPlayer.ShowModal = mrOk then begin 429 FormPlayer.Save(TPlayer(ListViewPlayers.Selected.Data)); 430 ReloadView; 431 end; 432 end; 433 finally 434 FormPlayer.Free; 435 end; 436 end; 437 438 procedure TFormNew.APlayerRemoveExecute(Sender: TObject); 439 var 440 I: Integer; 441 begin 442 for I := ListViewPlayers.Items.Count - 1 downto 0 do 443 if ListViewPlayers.Items[I].Selected then begin 444 Players.Remove(ListViewPlayers.Items[I].Data); 445 if Players.Count <= MinPlayerCount then Break; 446 end; 447 ReloadView; 448 end; 449 450 procedure TFormNew.AServerAddExecute(Sender: TObject); 451 var 452 NewServer: TServerInfo; 453 begin 454 FormServer := TFormServer.Create(nil); 455 NewServer := TServerInfo.Create; 456 FormServer.Load(NewServer); 457 if FormServer.ShowModal = mrOK then begin 458 FormServer.Save(NewServer); 459 ServerList.Items.Add(NewServer); 460 ReloadView; 461 end else NewServer.Free; 462 FormServer.Free; 463 end; 464 465 procedure TFormNew.AServerModifyExecute(Sender: TObject); 466 var 467 Server: TServerInfo; 468 begin 469 FormServer := TFormServer.Create(nil); 470 Server := TServerInfo(ListViewServers.Selected.Data); 471 FormServer.Load(Server); 472 if FormServer.ShowModal = mrOK then begin 473 FormServer.Save(Server); 474 ReloadView; 475 end; 476 FormServer.Free; 477 end; 478 479 procedure TFormNew.AServerRemoveExecute(Sender: TObject); 480 var 481 I: Integer; 482 begin 483 if MessageDlg(SRemoveServer, SRemoveServerQuery, 484 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin 485 for I := ListViewServers.Items.Count - 1 downto 0 do 486 if ListViewServers.Items[I].Selected then 487 ServerList.Items.Delete(I); 488 ReloadView; 489 end; 490 end; 491 492 procedure TFormNew.ButtonImageBrowseClick(Sender: TObject); 493 begin 494 OpenPictureDialog1.FileName := EditImageFile.Text; 495 if OpenPictureDialog1.Execute then begin 496 EditImageFile.Text := OpenPictureDialog1.FileName; 497 end; 498 end; 499 500 procedure TFormNew.APlayerAddExecute(Sender: TObject); 501 var 502 NewPlayer: TPlayer; 503 begin 504 if Players.Count <= (MaxPlayerCount - 1) then begin 505 NewPlayer := TPlayer.Create; 506 NewPlayer.Id := Players.GetNewId; 507 NewPlayer.Name := SPlayer + ' ' + IntToStr(NewPlayer.Id); 508 NewPlayer.Color := PlayerColors[Players.Count]; 509 NewPlayer.Mode := pmComputer; 510 NewPlayer.Agressivity := caMedium; 511 Players.Add(NewPlayer); 512 ReloadView; 513 end; 514 end; 515 516 procedure TFormNew.FormDestroy(Sender: TObject); 517 begin 518 FreeAndNil(ServerList); 519 FreeAndNil(Players); 520 FreeAndNil(FormChat); 521 end; 522 523 procedure TFormNew.Load(Server: TServer); 524 begin 525 with Server do begin 526 RadioButtonModeLocal.Checked := Mode = smLocal; 527 RadioButtonModeNetworkClient.Checked := Mode = smNetworkClient; 528 RadioButtonModeNetworkServer.Checked := Mode = smNetworkServer; 529 EditServerAddress.Text := LocalNetworkAddress; 530 SpinEditServerPort.Value := LocalNetworkPort; 531 end; 532 ServerList.Assign(Core.ServerList); 533 Players.Assign(Core.GameSettings.Players); 534 with Core.GameSettings do begin 330 procedure TFormNew.LoadGame(Game: TGame); 331 begin 332 Players.Assign(Game.Players); 333 with Game do begin 535 334 CheckBoxSymetricMap.Checked := SymetricMap; 536 335 CheckBoxCyclicMap.Checked := CyclicMap; … … 560 359 end; 561 360 562 procedure TFormNew.Save(Server: TServer); 563 begin 564 with Server do begin 565 if RadioButtonModeLocal.Checked then Mode := smLocal 566 else if RadioButtonModeNetworkClient.Checked then Mode := smNetworkClient 567 else if RadioButtonModeNetworkServer.Checked then Mode := smNetworkServer; 568 LocalNetworkAddress := EditServerAddress.Text; 569 LocalNetworkPort := SpinEditServerPort.Value; 570 if Assigned(ListViewServers.Selected) then begin 571 RemoteNetworkAddress := TServerInfo(ListViewServers.Selected.Data).Address; 572 RemoteNetworkPort := TServerInfo(ListViewServers.Selected.Data).Port; 573 end else begin 574 RemoteNetworkAddress := ''; 575 RemoteNetworkPort := 0; 576 end; 577 end; 578 Core.GameSettings.Players.Assign(Players); 579 Core.ServerList.Assign(ServerList); 580 with Core.GameSettings do begin 361 procedure TFormNew.SaveGame(Game: TGame); 362 begin 363 Game.Players.Assign(Players); 364 with Game do begin 581 365 SymetricMap := CheckBoxSymetricMap.Checked; 582 366 CyclicMap := CheckBoxCyclicMap.Checked; … … 603 387 end; 604 388 389 procedure TFormNew.MapPreviewRedraw; 390 begin 391 MapPreviewRedrawPending := True; 392 end; 393 394 procedure TFormNew.MapPreviewPaint; 395 var 396 Client: TClientGUI; 397 Bitmap: TBitmap; 398 begin 399 GamePreview.GameSystem := Core.GameSystems.First; 400 SaveGame(GamePreview); 401 GamePreview.PostConfig; 402 GamePreview.New; 403 GamePreview.CurrentPlayer := GamePreview.Players.First; 404 Bitmap := Image1.Picture.Bitmap; 405 Bitmap.SetSize(Image1.Width, Image1.Height); 406 Client := TClientGUI.Create; 407 Client.Game := GamePreview; 408 Client.View.Game := GamePreview; 409 Client.View.DestRect := TRect.Create(TPoint.Create(0, 0), TPoint.Create(Image1.Width, Image1.Height)); 410 Client.View.ZoomAll; 411 Client.ControlPlayer := GamePreview.Players.First; 412 Client.ShowCellGrid := True; 413 Bitmap.Canvas.Brush.Color := MapBackgroundColor; //clBackground; //PaintBox1.GetColorResolvingParent; 414 Bitmap.Canvas.FillRect(0, 0, Bitmap.Width, Bitmap.Height); 415 Client.Paint(Bitmap.Canvas, Client.View); 416 Client.Free; 417 end; 418 419 procedure TFormNew.Translate; 420 var 421 LastIndex: Integer; 422 begin 423 with ComboBoxGridType do begin 424 LastIndex := ItemIndex; 425 Clear; 426 Items.Add(SGridTypeHexagon); 427 Items.Add(SGridTypeSquare); 428 Items.Add(SGridTypeTriangle); 429 Items.Add(SGridTypeRandom); 430 Items.Add(SGridTypeIsometric); 431 ItemIndex := LastIndex; 432 end; 433 with ComboBoxWinObjective do begin 434 LastIndex := ItemIndex; 435 Clear; 436 Items.Add(SWinObjectiveNone); 437 Items.Add(SWinObjectiveDefeatAllOponents); 438 Items.Add(SWinObjectiveDefeatAllCities); 439 Items.Add(SWinObjectiveCapturePosition); 440 Items.Add(SWinObjectiveStayAliveForTurns); 441 Items.Add(SWinObjectiveCaptureEntireMap); 442 ItemIndex := LastIndex; 443 end; 444 with ComboBoxMapShape do begin 445 LastIndex := ItemIndex; 446 Clear; 447 Items.Add(SRectangular); 448 Items.Add(SFromImageFile); 449 Items.Add(SRounded); 450 ItemIndex := LastIndex; 451 end; 452 with RadioGroupGrowCells do begin 453 LastIndex := ItemIndex; 454 Items.Clear; 455 Items.Add(SGrowNone); 456 Items.Add(SGrowPlayerCities); 457 Items.Add(SGrowPlayerAllCells); 458 ItemIndex := LastIndex; 459 end; 460 with RadioGroupGrowAmount do begin 461 LastIndex := ItemIndex; 462 Items.Clear; 463 Items.Add(SGrowAmountByOne); 464 Items.Add(SGrowAmountBySquareRoot); 465 ItemIndex := LastIndex; 466 end; 467 Core.CoolTranslator1.TranslateComponentRecursive(Self); 468 end; 469 470 procedure TFormNew.ReloadView; 471 begin 472 ListViewPlayers.Items.Count := Players.Count; 473 ListViewPlayers.Refresh; 474 ListViewServers.Items.Count := ServerList.Items.Count; 475 ListViewServers.Refresh; 476 Translate; 477 UpdateInterface; 478 end; 479 480 procedure TFormNew.UpdateInterface; 481 var 482 WinObjective: TWinObjective; 483 begin 484 APlayerRemove.Enabled := Assigned(ListViewPlayers.Selected) and (Players.Count > MinPlayerCount); 485 APlayerAdd.Enabled := Players.Count < MaxPlayerCount; 486 APlayerModify.Enabled := Assigned(ListViewPlayers.Selected); 487 EditImageFile.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage); 488 ButtonImageBrowse.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage); 489 EditServerAddress.Enabled := RadioButtonModeNetworkServer.Checked; 490 SpinEditServerPort.Enabled := RadioButtonModeNetworkServer.Checked; 491 ListViewServers.Enabled := RadioButtonModeNetworkClient.Checked; 492 PanelChat.Visible := RadioButtonModeNetworkClient.Checked or RadioButtonModeNetworkServer.Checked; 493 SpinEditNeutralUnits.MaxValue := SpinEditMaxPower.Value; 494 AServerRemove.Enabled := RadioButtonModeNetworkClient.Checked and Assigned(ListViewServers.Selected); 495 AServerAdd.Enabled := RadioButtonModeNetworkClient.Checked; 496 AServerModify.Enabled := RadioButtonModeNetworkClient.Checked; 497 WinObjective := TWinObjective(ComboBoxWinObjective.ItemIndex); 498 case WinObjective of 499 woNone: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetNone); 500 woDefeatAllOponents: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetDefeatEnemies); 501 woDefeatAllOponentsCities: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetCaptureCities); 502 woSpecialCaptureCell: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetCaptureCells); 503 woStayAliveForDefinedTurns: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetStayAliveTurns); 504 woCaptureEntireMap: PageControlWinObjective.TabIndex := PageControlWinObjective.IndexOf(TabSheetCaptureEntireMap); 505 end; 506 end; 507 508 procedure TFormNew.FormShow(Sender: TObject); 509 begin 510 Core.PersistentForm.Load(Self); 511 Core.ThemeManager1.UseTheme(Self); 512 ReloadView; 513 //Height := Trunc(1.5 * Height); 514 //PageControl1.TabIndex := 0; 515 {$IFNDEF DEBUG} 516 TabSheetMode.TabVisible := False; 517 TabSheetMode.Enabled := False; 518 {$ENDIF} 519 end; 520 521 procedure TFormNew.ListViewPlayersCustomDrawSubItem(Sender: TCustomListView; 522 Item: TListItem; SubItem: Integer; State: TCustomDrawState; 523 var DefaultDraw: Boolean); 524 begin 525 if SubItem = 2 then 526 with ListViewPlayers.Canvas do begin 527 Brush.Color := TPlayer(Item.Data).Color; 528 Brush.Style := bsSolid; 529 FillRect(Item.DisplayRectSubItem(2, drBounds)); 530 end; 531 end; 532 533 procedure TFormNew.FormCreate(Sender: TObject); 534 begin 535 GamePreview := TGame.Create; 536 Players := TPlayers.Create; 537 ServerList := TServerList.Create; 538 FormChat := TFormChat.Create(nil); 539 FormChat.ManualDock(PanelChat, nil, alClient); 540 FormChat.Align := alClient; 541 FormChat.Show; 542 Translate; 543 end; 544 545 procedure TFormNew.CheckBoxCityChange(Sender: TObject); 546 begin 547 SpinEditCityPercent.Enabled := CheckBoxCity.Checked; 548 MapPreviewRedraw; 549 end; 550 551 procedure TFormNew.CheckBoxCyclicMapChange(Sender: TObject); 552 begin 553 MapPreviewRedraw; 554 end; 555 556 procedure TFormNew.CheckBoxSymetricMapChange(Sender: TObject); 557 begin 558 MapPreviewRedraw; 559 end; 560 561 procedure TFormNew.CheckBoxVoidChange(Sender: TObject); 562 begin 563 SpinEditVoidPercent.Enabled := CheckBoxVoid.Checked; 564 MapPreviewRedraw; 565 end; 566 567 procedure TFormNew.ComboBoxGridTypeChange(Sender: TObject); 568 begin 569 MapPreviewRedraw; 570 end; 571 572 procedure TFormNew.ComboBoxMapShapeChange(Sender: TObject); 573 begin 574 ReloadView; 575 MapPreviewRedraw; 576 end; 577 578 procedure TFormNew.ComboBoxWinObjectiveChange(Sender: TObject); 579 begin 580 UpdateInterface; 581 end; 582 583 procedure TFormNew.EditImageFileChange(Sender: TObject); 584 begin 585 MapPreviewRedraw; 586 end; 587 588 procedure TFormNew.FormClose(Sender: TObject; var CloseAction: TCloseAction); 589 begin 590 Core.PersistentForm.Save(Self); 591 end; 592 593 procedure TFormNew.APlayerModifyExecute(Sender: TObject); 594 begin 595 FormPlayer := TFormPlayer.Create(nil); 596 try 597 if Assigned(ListViewPlayers.Selected) then begin 598 FormPlayer.Load(TPlayer(ListViewPlayers.Selected.Data)); 599 if FormPlayer.ShowModal = mrOk then begin 600 FormPlayer.Save(TPlayer(ListViewPlayers.Selected.Data)); 601 ReloadView; 602 end; 603 end; 604 finally 605 FormPlayer.Free; 606 end; 607 end; 608 609 procedure TFormNew.APlayerRemoveExecute(Sender: TObject); 610 var 611 I: Integer; 612 begin 613 for I := ListViewPlayers.Items.Count - 1 downto 0 do 614 if ListViewPlayers.Items[I].Selected then begin 615 Players.Remove(ListViewPlayers.Items[I].Data); 616 if Players.Count <= MinPlayerCount then Break; 617 end; 618 ReloadView; 619 end; 620 621 procedure TFormNew.AServerAddExecute(Sender: TObject); 622 var 623 NewServer: TServerInfo; 624 begin 625 FormServer := TFormServer.Create(nil); 626 NewServer := TServerInfo.Create; 627 FormServer.Load(NewServer); 628 if FormServer.ShowModal = mrOK then begin 629 FormServer.Save(NewServer); 630 ServerList.Items.Add(NewServer); 631 ReloadView; 632 end else NewServer.Free; 633 FormServer.Free; 634 end; 635 636 procedure TFormNew.AServerModifyExecute(Sender: TObject); 637 var 638 Server: TServerInfo; 639 begin 640 FormServer := TFormServer.Create(nil); 641 Server := TServerInfo(ListViewServers.Selected.Data); 642 FormServer.Load(Server); 643 if FormServer.ShowModal = mrOK then begin 644 FormServer.Save(Server); 645 ReloadView; 646 end; 647 FormServer.Free; 648 end; 649 650 procedure TFormNew.AServerRemoveExecute(Sender: TObject); 651 var 652 I: Integer; 653 begin 654 if MessageDlg(SRemoveServer, SRemoveServerQuery, 655 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin 656 for I := ListViewServers.Items.Count - 1 downto 0 do 657 if ListViewServers.Items[I].Selected then 658 ServerList.Items.Delete(I); 659 ReloadView; 660 end; 661 end; 662 663 procedure TFormNew.ButtonImageBrowseClick(Sender: TObject); 664 begin 665 OpenPictureDialog1.FileName := EditImageFile.Text; 666 if OpenPictureDialog1.Execute then begin 667 EditImageFile.Text := OpenPictureDialog1.FileName; 668 end; 669 end; 670 671 procedure TFormNew.CheckBoxBridgesChange(Sender: TObject); 672 begin 673 MapPreviewRedraw; 674 end; 675 676 procedure TFormNew.APlayerAddExecute(Sender: TObject); 677 var 678 NewPlayer: TPlayer; 679 begin 680 if Players.Count <= (MaxPlayerCount - 1) then begin 681 NewPlayer := TPlayer.Create; 682 NewPlayer.Id := Players.GetNewId; 683 NewPlayer.Name := SPlayer + ' ' + IntToStr(NewPlayer.Id); 684 NewPlayer.Color := PlayerColors[Players.Count]; 685 NewPlayer.Mode := pmComputer; 686 NewPlayer.Agressivity := caMedium; 687 Players.Add(NewPlayer); 688 ReloadView; 689 end; 690 end; 691 692 procedure TFormNew.FormDestroy(Sender: TObject); 693 begin 694 FreeAndNil(ServerList); 695 FreeAndNil(Players); 696 FreeAndNil(FormChat); 697 FreeAndNil(GamePreview); 698 end; 699 700 procedure TFormNew.Load(Server: TServer); 701 begin 702 with Server do begin 703 RadioButtonModeLocal.Checked := Mode = smLocal; 704 RadioButtonModeNetworkClient.Checked := Mode = smNetworkClient; 705 RadioButtonModeNetworkServer.Checked := Mode = smNetworkServer; 706 EditServerAddress.Text := LocalNetworkAddress; 707 SpinEditServerPort.Value := LocalNetworkPort; 708 end; 709 ServerList.Assign(Core.ServerList); 710 LoadGame(Core.GameSettings); 711 end; 712 713 procedure TFormNew.Save(Server: TServer); 714 begin 715 with Server do begin 716 if RadioButtonModeLocal.Checked then Mode := smLocal 717 else if RadioButtonModeNetworkClient.Checked then Mode := smNetworkClient 718 else if RadioButtonModeNetworkServer.Checked then Mode := smNetworkServer; 719 LocalNetworkAddress := EditServerAddress.Text; 720 LocalNetworkPort := SpinEditServerPort.Value; 721 if Assigned(ListViewServers.Selected) then begin 722 RemoteNetworkAddress := TServerInfo(ListViewServers.Selected.Data).Address; 723 RemoteNetworkPort := TServerInfo(ListViewServers.Selected.Data).Port; 724 end else begin 725 RemoteNetworkAddress := ''; 726 RemoteNetworkPort := 0; 727 end; 728 end; 729 Core.ServerList.Assign(ServerList); 730 SaveGame(Core.GameSettings); 731 end; 732 605 733 end. 606 734 -
trunk/Languages/xtactics.cs.po
r268 r269 457 457 msgid "Special cells count:" 458 458 msgstr "Počet speciálních buněk:" 459 460 #: tformnew.label15.caption 461 msgid "Random preview:" 462 msgstr "Náhodný náhled:" 459 463 460 464 #: tformnew.label2.caption -
trunk/Languages/xtactics.po
r268 r269 442 442 #: tformnew.label14.caption 443 443 msgid "Special cells count:" 444 msgstr "" 445 446 #: tformnew.label15.caption 447 msgid "Random preview:" 444 448 msgstr "" 445 449 -
trunk/UClientGUI.pas
r268 r269 30 30 procedure CenterMap; 31 31 procedure CenterPlayerCity(Player: TPlayer); 32 procedure ZoomAll; 32 33 function CanvasToCellPos(Pos: TPoint): TPoint; 33 34 function CellToCanvasPos(Pos: TPoint): TPoint; … … 76 77 procedure TClientGUI.Paint(Canvas: TCanvas; View: TView); 77 78 begin 79 DrawCellLinks(Canvas, View); 78 80 DrawCells(Canvas, View); 81 DrawCities(Canvas, View); 82 DrawSelection(Canvas, View); 83 DrawArrows(Canvas, View); 79 84 if TGame(Game).DevelMode then DrawNeighborLinks(Canvas, View); 80 85 end; … … 305 310 MapCell: TCell; 306 311 CellText: string; 307 Points: array of Classes.TPoint;308 I: Integer;309 312 begin 310 313 with Canvas, View do begin … … 403 406 Cell: TPlayerCell; 404 407 MapCell: TCell; 405 CellText: string;406 408 Points: array of Classes.TPoint; 407 409 I: Integer; … … 454 456 procedure TClientGUI.DrawSelection(Canvas: TCanvas; View: TView); 455 457 var 456 Cell: TPlayerCell;457 MapCell: TCell;458 CellText: string;459 458 Points: array of Classes.TPoint; 460 459 I: Integer; … … 641 640 end; 642 641 642 procedure TView.ZoomAll; 643 var 644 Factor: TPointF; 645 MapRect: TRect; 646 NewZoom: Single; 647 begin 648 MapRect := TGame(Game).Map.CalculatePixelRect; 649 Factor := TPointF.Create(DestRect.Size.X / MapRect.Size.X, 650 DestRect.Size.Y / MapRect.Size.Y); 651 if Factor.X < Factor.Y then NewZoom := Factor.X 652 else NewZoom := Factor.Y; 653 if NewZoom = 0 then NewZoom := 1; 654 Zoom := NewZoom; 655 CenterMap; 656 end; 657 643 658 function TView.IsCellVisible(Cell: TCell): Boolean; 644 659 var
Note:
See TracChangeset
for help on using the changeset viewer.