Changeset 41 for trunk/Forms/UFormNew.pas
- Timestamp:
- Mar 12, 2014, 8:40:53 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormNew.pas
r40 r41 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, Spin, ExtCtrls, UGame;9 ComCtrls, Spin, ExtCtrls, ActnList, UGame; 10 10 11 11 type … … 14 14 15 15 TFormNew = class(TForm) 16 ButtonPlayerAdd: TButton; 16 APlayerAdd: TAction; 17 APlayerRemove: TAction; 18 APlayerModify: TAction; 19 ActionList1: TActionList; 17 20 ButtonCancel: TButton; 18 21 ButtonOk: TButton; 22 ButtonPlayerAdd: TButton; 23 ButtonPlayerModify: TButton; 19 24 ButtonPlayerRemove: TButton; 20 ButtonPlayerModify: TButton;25 CheckBoxCity: TCheckBox; 21 26 CheckBoxVoid: TCheckBox; 22 CheckBoxCity: TCheckBox;23 27 ComboBoxGridType: TComboBox; 24 28 Label1: TLabel; … … 28 32 Label5: TLabel; 29 33 ListView1: TListView; 34 Panel1: TPanel; 35 Panel2: TPanel; 36 RadioGroupGrowAmount: TRadioGroup; 30 37 RadioGroupGrowCells: TRadioGroup; 31 RadioGroupGrowAmount: TRadioGroup; 32 SpinEditVoidPercent: TSpinEdit; 38 SpinEditCityPercent: TSpinEdit; 33 39 SpinEditMapSizeX: TSpinEdit; 34 40 SpinEditMapSizeY: TSpinEdit; 35 SpinEditCityPercent: TSpinEdit; 41 SpinEditVoidPercent: TSpinEdit; 42 Splitter1: TSplitter; 36 43 TrackBarSizeX: TTrackBar; 37 44 TrackBarSizeY: TTrackBar; 38 procedure ButtonPlayerAddClick(Sender: TObject); 39 procedure ButtonPlayerModifyChangeBounds(Sender: TObject); 40 procedure ButtonPlayerModifyClick(Sender: TObject); 41 procedure ButtonPlayerRemoveClick(Sender: TObject); 45 procedure APlayerAddExecute(Sender: TObject); 46 procedure APlayerModifyExecute(Sender: TObject); 47 procedure APlayerRemoveExecute(Sender: TObject); 42 48 procedure CheckBoxCityChange(Sender: TObject); 43 49 procedure CheckBoxVoidChange(Sender: TObject); … … 46 52 procedure FormShow(Sender: TObject); 47 53 procedure ListView1Data(Sender: TObject; Item: TListItem); 54 procedure ListView1DblClick(Sender: TObject); 55 procedure ListView1KeyPress(Sender: TObject; var Key: char); 56 procedure ListView1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState 57 ); 48 58 procedure ListView1SelectItem(Sender: TObject; Item: TListItem; 49 59 Selected: Boolean); … … 84 94 end; 85 95 96 procedure TFormNew.ListView1DblClick(Sender: TObject); 97 begin 98 APlayerModify.Execute; 99 end; 100 101 procedure TFormNew.ListView1KeyPress(Sender: TObject; var Key: char); 102 begin 103 if (Key = #13) then APlayerModify.Execute; 104 end; 105 106 procedure TFormNew.ListView1KeyUp(Sender: TObject; var Key: Word; 107 Shift: TShiftState); 108 begin 109 if Key = 45 then APlayerAdd.Execute; 110 if Key = 46 then APlayerRemove.Execute; 111 end; 112 86 113 procedure TFormNew.ListView1SelectItem(Sender: TObject; Item: TListItem; 87 114 Selected: Boolean); … … 116 143 ButtonPlayerRemove.Enabled := Assigned(ListView1.Selected); 117 144 ButtonPlayerAdd.Enabled := Players.Count < MaxPlayerCount; 118 ButtonPlayerModify.Enabled := Assigned(ListView1.Selected);145 APlayerModify.Enabled := Assigned(ListView1.Selected); 119 146 end; 120 147 … … 129 156 end; 130 157 131 procedure TFormNew.ButtonPlayerRemoveClick(Sender: TObject); 132 begin 133 if Assigned(ListView1.Selected) then 158 procedure TFormNew.CheckBoxCityChange(Sender: TObject); 159 begin 160 SpinEditCityPercent.Enabled := CheckBoxCity.Checked; 161 end; 162 163 procedure TFormNew.CheckBoxVoidChange(Sender: TObject); 164 begin 165 SpinEditVoidPercent.Enabled := CheckBoxVoid.Checked; 166 end; 167 168 procedure TFormNew.APlayerModifyExecute(Sender: TObject); 169 begin 170 if Assigned(ListView1.Selected) then begin 171 FormPlayer.Load(TPlayer(ListView1.Selected.Data)); 172 if FormPlayer.ShowModal = mrOk then begin 173 FormPlayer.Save(TPlayer(ListView1.Selected.Data)); 174 ReloadView; 175 end; 176 end; 177 end; 178 179 procedure TFormNew.APlayerRemoveExecute(Sender: TObject); 180 begin 181 if Assigned(ListView1.Selected) then begin 134 182 Players.Remove(ListView1.Selected.Data); 135 ReloadView; 136 end; 137 138 procedure TFormNew.CheckBoxCityChange(Sender: TObject); 139 begin 140 SpinEditCityPercent.Enabled := CheckBoxCity.Checked; 141 end; 142 143 procedure TFormNew.CheckBoxVoidChange(Sender: TObject); 144 begin 145 SpinEditVoidPercent.Enabled := CheckBoxVoid.Checked; 146 end; 147 148 procedure TFormNew.ButtonPlayerAddClick(Sender: TObject); 183 ReloadView; 184 end; 185 end; 186 187 procedure TFormNew.APlayerAddExecute(Sender: TObject); 149 188 var 150 189 NewPlayer: TPlayer; 151 190 begin 152 NewPlayer := TPlayer.Create; 153 NewPlayer.Name := 'Player ' + IntToStr(Players.Count + 1); 154 NewPlayer.Color := PlayerColors[Players.Count]; 155 NewPlayer.Mode := pmComputer; 156 Players.Add(NewPlayer); 157 ReloadView; 158 end; 159 160 procedure TFormNew.ButtonPlayerModifyChangeBounds(Sender: TObject); 161 begin 162 163 end; 164 165 procedure TFormNew.ButtonPlayerModifyClick(Sender: TObject); 166 begin 167 FormPlayer.Load(TPlayer(ListView1.Selected.Data)); 168 if FormPlayer.ShowModal = mrOk then 169 FormPlayer.Save(TPlayer(ListView1.Selected.Data)); 191 if Players.Count <= (MaxPlayerCount - 1) then begin 192 NewPlayer := TPlayer.Create; 193 NewPlayer.Name := 'Player ' + IntToStr(Players.Count + 1); 194 NewPlayer.Color := PlayerColors[Players.Count]; 195 NewPlayer.Mode := pmComputer; 196 Players.Add(NewPlayer); 197 ReloadView; 198 end; 170 199 end; 171 200
Note:
See TracChangeset
for help on using the changeset viewer.