Changeset 298 for trunk/Forms
- Timestamp:
- Jul 10, 2019, 5:35:15 PM (5 years ago)
- Location:
- trunk/Forms
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormItem.pas
r296 r298 91 91 J: Integer; 92 92 Control: TControl; 93 ReferenceList: TItemList; 94 ReferenceItem: TItem; 93 95 begin 94 96 Fields := Item.GetFields; … … 111 113 end; 112 114 end 115 else if DataType = dtReference then begin 116 TComboBox(Control).Items.BeginUpdate; 117 try 118 TComboBox(Control).Items.Clear; 119 ReferenceList := Item.GetReferenceList(Index); 120 if Assigned(ReferenceList) then 121 for J := 0 to ReferenceList.Count - 1 do 122 TComboBox(Control).Items.AddObject(TItem(ReferenceList[J]).Name, ReferenceList[J]); 123 ReferenceItem := TItem(Item.GetValueReference(Index)); 124 TComboBox(Control).ItemIndex := TComboBox(Control).Items.IndexOfObject(ReferenceItem); 125 finally 126 TComboBox(Control).Items.EndUpdate; 127 end; 128 end 113 129 else raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[DataType]])); 114 130 end; … … 131 147 else if DataType = dtBoolean then Item.SetValueBoolean(Index, TCheckBox(Control).Checked) 132 148 else if DataType = dtEnumeration then Item.SetValueEnumeration(Index, TUndefinedEnum(TComboBox(Control).ItemIndex)) 149 else if DataType = dtReference then begin 150 if TComboBox(Control).ItemIndex <> -1 then 151 Item.SetValueReference(Index, TItem(TComboBox(Control).Items.Objects[TComboBox(Control).ItemIndex])) 152 else Item.SetValueReference(Index, nil); 153 end 133 154 else raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[DataType]])); 134 155 end; … … 173 194 TComboBox(NewControl).Style := csDropDownList; 174 195 end else 196 if DataType = dtReference then begin 197 NewControl := TComboBox.Create(nil); 198 NewControl.Width := 200; 199 TComboBox(NewControl).Style := csDropDownList; 200 end else 175 201 if DataType = dtBoolean then begin 176 202 NewControl := TCheckBox.Create(nil); -
trunk/Forms/UFormList.lfm
r295 r298 11 11 OnCreate = FormCreate 12 12 OnShow = FormShow 13 LCLVersion = '2.0. 0.4'13 LCLVersion = '2.0.2.0' 14 14 object ListView1: TListView 15 15 Left = 0 -
trunk/Forms/UFormList.pas
r290 r298 51 51 procedure UpdateListViewColumns; 52 52 public 53 MinItemCount: Integer; 54 MaxItemCount: Integer; 53 55 procedure UpdateInterface; 54 56 procedure UpdateList; … … 70 72 SRemoveItems = 'Remove items'; 71 73 SRemoveItemsQuery = 'Do you want to remove selected items?'; 72 SNew Item = 'New item';74 SNew = 'New'; 73 75 74 76 { TFormList } … … 83 85 for I := ListView1.Items.Count - 1 downto 0 do 84 86 if ListView1.Items[I].Selected then begin 87 if List.Count <= MinItemCount then Break; 85 88 ListView1.Items[I].Selected := False; 86 89 List.Remove(TItem(ListView1.Items[I].Data)); … … 99 102 if Assigned(ListView1.Selected) then 100 103 with TItem(ListView1.Selected.Data) do begin 101 TempEntry := List. GetItemClass.Create;104 TempEntry := List.CreateItem; 102 105 TempEntry.Assign(TItem(ListView1.Selected.Data)); 103 106 FormItem := TFormItem.Create(Self); … … 121 124 FormItem: TFormItem; 122 125 begin 123 TempEntry := List.GetItemClass.Create; 126 if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit; 127 128 TempEntry := List.CreateItem; 124 129 FormItem := TFormItem.Create(Self); 125 130 try 126 TempEntry.Name := SNew Item;131 TempEntry.Name := SNew + ' ' + LowerCase(List.GetItemClass.GetClassName); 127 132 FormItem.Item := TempEntry; 128 133 if FormItem.ShowModal = mrOk then begin … … 143 148 FormItem: TFormItem; 144 149 begin 145 TempEntry := List.GetItemClass.Create; 150 if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit; 151 152 TempEntry := List.CreateItem; 146 153 TempEntry.Assign(TItem(ListView1.Selected.Data)); 147 154 FormItem := TFormItem.Create(Self); … … 183 190 for I := 0 to ToolBar1.ButtonCount - 1 do 184 191 ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption; 192 MinItemCount := 0; 193 MaxItemCount := -1; 185 194 end; 186 195 … … 197 206 var DefaultDraw: Boolean); 198 207 var 208 ItemFields: TItemFields; 199 209 ItemField: TItemField; 200 210 begin 201 ItemField := TItem(Item.Data).GetField(SubItem); 202 if ItemField.DataType = dtColor then 203 with ListView1.Canvas do begin 204 Brush.Color := TItem(Item.Data).GetValueColor(ItemField.Index); 205 Brush.Style := bsSolid; 206 FillRect(Item.DisplayRectSubItem(1, drBounds)); 207 end; 208 ItemField.Free; 211 ItemFields := TItem(Item.Data).GetFields; 212 try 213 ItemField := ItemFields[SubItem]; 214 if ItemField.DataType = dtColor then 215 with ListView1.Canvas do begin 216 Brush.Color := TItem(Item.Data).GetValueColor(ItemField.Index); 217 Brush.Style := bsSolid; 218 FillRect(Item.DisplayRectSubItem(SubItem, drBounds)); 219 end; 220 finally 221 ItemFields.Free; 222 end; 209 223 end; 210 224 … … 272 286 procedure TFormList.UpdateInterface; 273 287 begin 274 ARemove.Enabled := Assigned(FList) and Assigned(ListView1.Selected) ;288 ARemove.Enabled := Assigned(FList) and Assigned(ListView1.Selected) and (List.Count > MinItemCount); 275 289 AModify.Enabled := Assigned(FList) and Assigned(ListView1.Selected); 276 AAdd.Enabled := Assigned(FList); 290 AAdd.Enabled := Assigned(FList) and ((MaxItemCount = -1) or ((MaxItemCount <> -1) and (List.Count < MaxItemCount))); 291 AClone.Enabled := Assigned(FList) and ((MaxItemCount = -1) or ((MaxItemCount <> -1) and (List.Count < MaxItemCount))); 277 292 ASelectAll.Enabled := ListView1.Items.Count > 0; 278 293 end; -
trunk/Forms/UFormNew.pas
r288 r298 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 9 ComCtrls, Spin, ExtCtrls, ActnList, ExtDlgs, Menus, UGame, UGeometry, UPlayer, 10 UGameServer, UServerList, UMap, U FormPlayers, UGameSystem;10 UGameServer, UServerList, UMap, UGameSystem, UFormList; 11 11 12 12 type … … 144 144 MapPreviewRedrawPending: Boolean; 145 145 NewRandSeed: Cardinal; 146 FormPlayers: TForm Players;146 FormPlayers: TFormList; 147 147 procedure LoadGame(Game: TGame); 148 148 procedure SaveGame(Game: TGame); … … 385 385 if Assigned(FServer) then begin 386 386 Load(FServer); 387 FormPlayers. Players:= FServer.Game.Players;387 FormPlayers.List := FServer.Game.Players; 388 388 end else begin 389 FormPlayers. Players:= nil;389 FormPlayers.List := nil; 390 390 end; 391 391 end; … … 402 402 GamePreview.GeneratePlayers := False; 403 403 GamePreview.New; 404 GamePreview.CurrentPlayer := GamePreview.Players.First;404 GamePreview.CurrentPlayer := TPlayer(GamePreview.Players.First); 405 405 Bitmap := Image1.Picture.Bitmap; 406 406 Bitmap.SetSize(Image1.Width, Image1.Height); … … 534 534 FormChat.Align := alClient; 535 535 FormChat.Show; 536 FormPlayers := TForm Players.Create(nil);536 FormPlayers := TFormList.Create(nil); 537 537 FormPlayers.MinItemCount := MinPlayerCount; 538 538 FormPlayers.MaxItemCount := MaxPlayerCount; -
trunk/Forms/UFormPlayer.lfm
r295 r298 1 1 object FormPlayer: TFormPlayer 2 Left = 4702 Left = 1304 3 3 Height = 338 4 Top = 1574 Top = 318 5 5 Width = 543 6 6 Caption = 'Player' … … 14 14 OnShow = FormShow 15 15 Position = poMainFormCenter 16 LCLVersion = '2.0. 0.4'16 LCLVersion = '2.0.2.0' 17 17 object Label1: TLabel 18 18 Left = 20
Note:
See TracChangeset
for help on using the changeset viewer.