Changeset 34 for trunk/Forms/UNewGameForm.pas
- Timestamp:
- Nov 25, 2017, 12:27:33 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 backup 4 4 tunneler.exe 5 tunneler.dbg 6 tunneler.lps 5 7 heaptrclog.trc 6 tunneler.lps 8 Components/Common/Languages/*.mo 9 Components/CoolTranslator/Demo/lib
-
- Property svn:ignore
-
trunk/Forms/UNewGameForm.pas
r24 r34 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls ;9 ComCtrls, UCore; 10 10 11 11 type … … 16 16 ButtonStart: TButton; 17 17 ButtonCancel: TButton; 18 ColorButton1: TColorButton; 19 EditUp: TEdit; 20 EditDown: TEdit; 21 EditLeft: TEdit; 22 EditRight: TEdit; 23 EditShoot: TEdit; 24 EditName: TEdit; 25 GroupBox1: TGroupBox; 18 26 Label1: TLabel; 27 Label2: TLabel; 28 Label3: TLabel; 29 Label4: TLabel; 30 Label5: TLabel; 31 Label6: TLabel; 32 Label7: TLabel; 33 Label8: TLabel; 19 34 ListView1: TListView; 20 procedure ButtonStartClick(Sender: TObject); 35 procedure ColorButton1ColorChanged(Sender: TObject); 36 procedure EditDownChange(Sender: TObject); 37 procedure EditDownKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState 38 ); 39 procedure EditLeftChange(Sender: TObject); 40 procedure EditLeftKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState 41 ); 42 procedure EditNameChange(Sender: TObject); 43 procedure EditRightChange(Sender: TObject); 44 procedure EditRightKeyDown(Sender: TObject; var Key: Word; 45 Shift: TShiftState); 46 procedure EditShootChange(Sender: TObject); 47 procedure EditShootKeyDown(Sender: TObject; var Key: Word; 48 Shift: TShiftState); 49 procedure EditUpChange(Sender: TObject); 50 procedure EditUpKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 51 procedure FormCreate(Sender: TObject); 52 procedure FormDestroy(Sender: TObject); 21 53 procedure FormShow(Sender: TObject); 22 54 procedure ListView1Change(Sender: TObject; Item: TListItem; 23 55 Change: TItemChange); 56 procedure ListView1Data(Sender: TObject; Item: TListItem); 57 procedure ListView1SelectItem(Sender: TObject; Item: TListItem; 58 Selected: Boolean); 24 59 private 25 { private declarations } 60 Players: TPlayers; 61 procedure ReloadList; 26 62 public 27 { public declarations } 63 procedure LoadData(Engine: TEngine); 64 procedure SaveData(Engine: TEngine); 28 65 end; 29 66 … … 34 71 35 72 uses 36 U Core, UMainForm;73 UMainForm; 37 74 38 75 {$R *.lfm} … … 47 84 end; 48 85 49 procedure TNewGameForm.ButtonStartClick(Sender: TObject); 50 begin 51 86 procedure TNewGameForm.ListView1Data(Sender: TObject; Item: TListItem); 87 begin 88 if Item.Index < Players.Count then 89 with TPlayer(Players[Item.Index]) do begin 90 Item.Caption := Name; 91 Item.SubItems.Add(IntToHex(Color, 6)); 92 Item.SubItems.Add(''); 93 Item.Checked := Enabled; 94 Item.Data := Pointer(Players[Item.Index]); 95 end; 96 end; 97 98 procedure TNewGameForm.ListView1SelectItem(Sender: TObject; Item: TListItem; 99 Selected: Boolean); 100 begin 101 if Assigned(Item) and Selected then 102 with TPlayer(Item.Data) do begin 103 EditName.Text := Name; 104 ColorButton1.ButtonColor := Color; 105 EditDown.Text := IntToStr(Keys.Down); 106 EditUp.Text := IntToStr(Keys.Up); 107 EditLeft.Text := IntToStr(Keys.Left); 108 EditRight.Text := IntToStr(Keys.Right); 109 EditShoot.Text := IntToStr(Keys.Shoot); 110 end; 111 end; 112 113 procedure TNewGameForm.ReloadList; 114 begin 115 ListView1.Items.Count := Players.Count; 116 ListView1.Refresh; 117 end; 118 119 procedure TNewGameForm.LoadData(Engine: TEngine); 120 begin 121 Players.Assign(Engine.PlayerPool); 122 end; 123 124 procedure TNewGameForm.SaveData(Engine: TEngine); 125 begin 126 Engine.PlayerPool.Assign(Players); 127 end; 128 129 procedure TNewGameForm.ColorButton1ColorChanged(Sender: TObject); 130 begin 131 if Assigned(ListView1.Selected) then 132 with TPlayer(ListView1.Selected.Data) do begin 133 Color := ColorButton1.ButtonColor; 134 ReloadList; 135 end; 136 end; 137 138 procedure TNewGameForm.EditDownChange(Sender: TObject); 139 var 140 Value: Integer; 141 begin 142 if Assigned(ListView1.Selected) then 143 with TPlayer(ListView1.Selected.Data) do begin 144 if TryStrToInt(EditDown.Text, Value) then Keys.Down := Value; 145 ReloadList; 146 end; 147 end; 148 149 procedure TNewGameForm.EditDownKeyDown(Sender: TObject; var Key: Word; 150 Shift: TShiftState); 151 begin 152 EditDown.Text := IntToStr(Key); 153 end; 154 155 procedure TNewGameForm.EditLeftChange(Sender: TObject); 156 var 157 Value: Integer; 158 begin 159 if Assigned(ListView1.Selected) then 160 with TPlayer(ListView1.Selected.Data) do begin 161 if TryStrToInt(EditLeft.Text, Value) then Keys.Left := Value; 162 ReloadList; 163 end; 164 end; 165 166 procedure TNewGameForm.EditLeftKeyDown(Sender: TObject; var Key: Word; 167 Shift: TShiftState); 168 begin 169 EditLeft.Text := IntToStr(Key); 170 end; 171 172 procedure TNewGameForm.EditNameChange(Sender: TObject); 173 begin 174 if Assigned(ListView1.Selected) then 175 with TPlayer(ListView1.Selected.Data) do begin 176 Name := EditName.Text; 177 ReloadList; 178 end; 179 end; 180 181 procedure TNewGameForm.EditRightChange(Sender: TObject); 182 var 183 Value: Integer; 184 begin 185 if Assigned(ListView1.Selected) then 186 with TPlayer(ListView1.Selected.Data) do begin 187 if TryStrToInt(EditRight.Text, Value) then Keys.Right := Value; 188 ReloadList; 189 end; 190 end; 191 192 procedure TNewGameForm.EditRightKeyDown(Sender: TObject; var Key: Word; 193 Shift: TShiftState); 194 begin 195 EditRight.Text := IntToStr(Key); 196 end; 197 198 procedure TNewGameForm.EditShootChange(Sender: TObject); 199 var 200 Value: Integer; 201 begin 202 if Assigned(ListView1.Selected) then 203 with TPlayer(ListView1.Selected.Data) do begin 204 if TryStrToInt(EditShoot.Text, Value) then Keys.Shoot := Value; 205 ReloadList; 206 end; 207 end; 208 209 procedure TNewGameForm.EditShootKeyDown(Sender: TObject; var Key: Word; 210 Shift: TShiftState); 211 begin 212 EditShoot.Text := IntToStr(Key); 213 end; 214 215 procedure TNewGameForm.EditUpChange(Sender: TObject); 216 var 217 Value: Integer; 218 begin 219 if Assigned(ListView1.Selected) then 220 with TPlayer(ListView1.Selected.Data) do begin 221 if TryStrToInt(EditUp.Text, Value) then Keys.Up := Value; 222 ReloadList; 223 end; 224 end; 225 226 procedure TNewGameForm.EditUpKeyDown(Sender: TObject; var Key: Word; 227 Shift: TShiftState); 228 begin 229 EditUp.Text := IntToStr(Key); 230 end; 231 232 procedure TNewGameForm.FormCreate(Sender: TObject); 233 begin 234 Players := TPlayers.Create 235 end; 236 237 procedure TNewGameForm.FormDestroy(Sender: TObject); 238 begin 239 FreeAndNil(Players); 52 240 end; 53 241 54 242 procedure TNewGameForm.FormShow(Sender: TObject); 55 var 56 NewItem: TListItem; 57 I: Integer; 58 begin 59 with ListView1 do try 60 BeginUpdate; 61 Clear; 62 for I := 0 to MainForm.Engine.PlayerPool.Count - 1 do 63 with TPlayer(MainForm.Engine.PlayerPool[I]) do begin 64 NewItem := Items.Add; 65 NewItem.Caption := Name; 66 NewItem.SubItems.Add(IntToStr(Color)); 67 NewItem.SubItems.Add(''); 68 NewItem.Checked := Enabled; 69 NewItem.Data := Pointer(Engine.PlayerPool[I]); 70 end; 71 finally 72 EndUpdate; 73 end; 243 begin 244 ReloadList; 74 245 end; 75 246
Note:
See TracChangeset
for help on using the changeset viewer.