Changeset 196 for trunk/Forms
- Timestamp:
- May 16, 2018, 9:56:24 AM (7 years ago)
- Location:
- trunk/Forms
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.pas
r192 r196 168 168 Core.PersistentForm.Save(Self); 169 169 SaveConfig(Core.XMLConfig1, 'FormMain'); 170 Core. XMLConfig1.Flush;170 Core.Done; 171 171 end; 172 172 -
trunk/Forms/UFormNew.lfm
r194 r196 21 21 Top = 4 22 22 Width = 1061 23 ActivePage = TabSheet 223 ActivePage = TabSheetMode 24 24 Align = alClient 25 25 BorderSpacing.Around = 4 26 TabIndex = 226 TabIndex = 0 27 27 TabOrder = 0 28 28 object TabSheetMode: TTabSheet 29 29 Caption = 'Mode' 30 ClientHeight = 29731 ClientWidth = 75930 ClientHeight = 523 31 ClientWidth = 1053 32 32 object RadioButtonModeLocal: TRadioButton 33 33 Left = 10 … … 90 90 object ListViewServers: TListView 91 91 Left = 26 92 Height = 9792 Height = 291 93 93 Top = 181 94 Width = 3 2694 Width = 334 95 95 Anchors = [akTop, akLeft, akBottom] 96 96 Columns = < … … 103 103 Width = 200 104 104 end> 105 MultiSelect = True 106 OwnerData = True 107 PopupMenu = PopupMenuServers 108 ReadOnly = True 109 RowSelect = True 105 110 TabOrder = 5 106 111 ViewStyle = vsReport 112 OnData = ListViewServersData 113 OnDblClick = AServerModifyExecute 114 OnKeyPress = ListViewServersKeyPress 115 OnSelectItem = ListViewServersSelectItem 116 end 117 object Button1: TButton 118 Left = 27 119 Height = 31 120 Top = 484 121 Width = 94 122 Action = AServerAdd 123 Anchors = [akLeft, akBottom] 124 TabOrder = 6 125 end 126 object Button2: TButton 127 Left = 240 128 Height = 31 129 Top = 484 130 Width = 94 131 Action = AServerRemove 132 Anchors = [akLeft, akBottom] 133 TabOrder = 7 134 end 135 object Button3: TButton 136 Left = 136 137 Height = 30 138 Top = 484 139 Width = 94 140 Action = AServerModify 141 Anchors = [akLeft, akBottom] 142 TabOrder = 8 107 143 end 108 144 end … … 137 173 end> 138 174 OwnerData = True 139 PopupMenu = PopupMenu 1175 PopupMenu = PopupMenuPlayers 140 176 ReadOnly = True 141 177 RowSelect = True … … 557 593 object ActionList1: TActionList 558 594 Images = Core.ImageListSmall 559 left = 256560 top = 440595 left = 568 596 top = 296 561 597 object APlayerModify: TAction 562 598 Caption = 'Modify player' … … 571 607 OnExecute = APlayerRemoveExecute 572 608 end 609 object AServerAdd: TAction 610 Caption = 'Add' 611 OnExecute = AServerAddExecute 612 end 613 object AServerRemove: TAction 614 Caption = 'Remove' 615 OnExecute = AServerRemoveExecute 616 end 617 object AServerModify: TAction 618 Caption = 'Modify' 619 OnExecute = AServerModifyExecute 620 end 573 621 end 574 622 object OpenPictureDialog1: TOpenPictureDialog 575 left = 424576 top = 440577 end 578 object PopupMenu 1: TPopupMenu579 left = 128580 top = 440623 left = 568 624 top = 360 625 end 626 object PopupMenuPlayers: TPopupMenu 627 left = 568 628 top = 232 581 629 object MenuItem1: TMenuItem 582 630 Action = APlayerAdd … … 590 638 end 591 639 end 640 object PopupMenuServers: TPopupMenu 641 left = 121 642 top = 317 643 object MenuItem4: TMenuItem 644 Action = AServerAdd 645 end 646 object MenuItem6: TMenuItem 647 Action = AServerModify 648 end 649 object MenuItem5: TMenuItem 650 Action = AServerRemove 651 end 652 end 592 653 end -
trunk/Forms/UFormNew.pas
r194 r196 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 9 ComCtrls, Spin, ExtCtrls, ActnList, ExtDlgs, Menus, UGame, UGeometry, 10 UGameServer ;10 UGameServer, UServerList; 11 11 12 12 type … … 15 15 16 16 TFormNew = class(TForm) 17 AServerModify: TAction; 18 AServerAdd: TAction; 19 AServerRemove: TAction; 17 20 APlayerAdd: TAction; 18 21 APlayerRemove: TAction; 19 22 APlayerModify: TAction; 20 23 ActionList1: TActionList; 24 Button1: TButton; 25 Button2: TButton; 26 Button3: TButton; 21 27 ButtonCancel: TButton; 22 28 ButtonImageBrowse: TButton; … … 52 58 MenuItem2: TMenuItem; 53 59 MenuItem3: TMenuItem; 60 MenuItem4: TMenuItem; 61 MenuItem5: TMenuItem; 62 MenuItem6: TMenuItem; 54 63 OpenPictureDialog1: TOpenPictureDialog; 55 64 PageControl1: TPageControl; 56 65 PanelButtons: TPanel; 57 66 PanelChat: TPanel; 58 PopupMenu1: TPopupMenu; 67 PopupMenuPlayers: TPopupMenu; 68 PopupMenuServers: TPopupMenu; 59 69 RadioButtonModeNetworkServer: TRadioButton; 60 70 RadioButtonModeNetworkClient: TRadioButton; … … 79 89 procedure APlayerModifyExecute(Sender: TObject); 80 90 procedure APlayerRemoveExecute(Sender: TObject); 91 procedure AServerAddExecute(Sender: TObject); 92 procedure AServerModifyExecute(Sender: TObject); 93 procedure AServerRemoveExecute(Sender: TObject); 81 94 procedure ButtonImageBrowseClick(Sender: TObject); 82 95 procedure CheckBoxCityChange(Sender: TObject); … … 97 110 procedure ListViewPlayersSelectItem(Sender: TObject; Item: TListItem; 98 111 Selected: Boolean); 112 procedure ListViewServersData(Sender: TObject; Item: TListItem); 113 procedure ListViewServersKeyPress(Sender: TObject; var Key: char); 114 procedure ListViewServersSelectItem(Sender: TObject; Item: TListItem; 115 Selected: Boolean); 99 116 procedure RadioButtonModeLocalChange(Sender: TObject); 100 117 procedure SpinEditMapSizeXChange(Sender: TObject); … … 106 123 Players: TPlayers; 107 124 public 125 ServerList: TServerList; 108 126 procedure Translate; 109 127 procedure ReloadView; … … 121 139 122 140 uses 123 UFormPlayer, UFormChat, UCore ;141 UFormPlayer, UFormChat, UCore, UFormServer; 124 142 125 143 resourcestring … … 141 159 SRounded = 'Rounded'; 142 160 SFromImageFile = 'From image file'; 161 SRemoveServer = 'Remove server'; 162 SRemoveServerQuery = 'Do you want to remove server?'; 143 163 144 164 { TFormNew } … … 177 197 begin 178 198 ReloadView; 199 end; 200 201 procedure TFormNew.ListViewServersData(Sender: TObject; Item: TListItem); 202 begin 203 if Item.Index < ServerList.Items.Count then 204 with TServerInfo(ServerList.Items[Item.Index]) do begin 205 Item.Caption := Name; 206 Item.Data := ServerList.Items[Item.Index]; 207 Item.SubItems.Add(Address + ':' + IntToStr(Port)); 208 end; 209 end; 210 211 procedure TFormNew.ListViewServersKeyPress(Sender: TObject; var Key: char); 212 begin 213 if Key = #13 then AServerModify.Execute; 214 end; 215 216 procedure TFormNew.ListViewServersSelectItem(Sender: TObject; Item: TListItem; 217 Selected: Boolean); 218 begin 219 UpdateInterface; 179 220 end; 180 221 … … 262 303 ListViewPlayers.Items.Count := Players.Count; 263 304 ListViewPlayers.Refresh; 305 ListViewServers.Items.Count := ServerList.Items.Count; 306 ListViewServers.Refresh; 264 307 Translate; 265 308 UpdateInterface; … … 278 321 PanelChat.Visible := RadioButtonModeNetworkClient.Checked or RadioButtonModeNetworkServer.Checked; 279 322 SpinEditNeutralUnits.MaxValue := SpinEditMaxPower.Value; 323 AServerRemove.Enabled := RadioButtonModeNetworkClient.Checked and Assigned(ListViewServers.Selected); 324 AServerAdd.Enabled := RadioButtonModeNetworkClient.Checked; 325 AServerModify.Enabled := RadioButtonModeNetworkClient.Checked; 280 326 end; 281 327 … … 350 396 if Assigned(ListViewPlayers.Selected) then begin 351 397 Players.Remove(ListViewPlayers.Selected.Data); 398 ReloadView; 399 end; 400 end; 401 402 procedure TFormNew.AServerAddExecute(Sender: TObject); 403 var 404 NewServer: TServerInfo; 405 begin 406 FormServer := TFormServer.Create(nil); 407 NewServer := TServerInfo.Create; 408 FormServer.Load(NewServer); 409 if FormServer.ShowModal = mrOK then begin 410 FormServer.Save(NewServer); 411 ServerList.Items.Add(NewServer); 412 ReloadView; 413 end else NewServer.Free; 414 FormServer.Free; 415 end; 416 417 procedure TFormNew.AServerModifyExecute(Sender: TObject); 418 var 419 Server: TServerInfo; 420 begin 421 FormServer := TFormServer.Create(nil); 422 Server := TServerInfo(ListViewServers.Selected.Data); 423 FormServer.Load(Server); 424 if FormServer.ShowModal = mrOK then begin 425 FormServer.Save(Server); 426 ReloadView; 427 end; 428 FormServer.Free; 429 end; 430 431 procedure TFormNew.AServerRemoveExecute(Sender: TObject); 432 var 433 I: Integer; 434 begin 435 if MessageDlg(SRemoveServer, SRemoveServerQuery, 436 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin 437 for I := ListViewServers.Items.Count - 1 downto 0 do 438 if ListViewServers.Items[I].Selected then 439 ServerList.Items.Delete(I); 352 440 ReloadView; 353 441 end; … … 424 512 LocalNetworkAddress := EditServerAddress.Text; 425 513 LocalNetworkPort := SpinEditServerPort.Value; 514 if Assigned(ListViewServers.Selected) then begin 515 RemoteNetworkAddress := TServerInfo(ListViewServers.Selected.Data).Address; 516 RemoteNetworkPort := TServerInfo(ListViewServers.Selected.Data).Port; 517 end else begin 518 RemoteNetworkAddress := ''; 519 RemoteNetworkPort := 0; 520 end; 426 521 Game.PlayersSetting.Assign(Players); 427 522 Game.SymetricMap := CheckBoxSymetricMap.Checked;
Note:
See TracChangeset
for help on using the changeset viewer.