Ignore:
Timestamp:
Jul 10, 2019, 5:35:15 PM (5 years ago)
Author:
chronos
Message:
  • Added: New item list type reference. Used in players for reference to selected nation.
  • Modified: New game players selection migrated to dynamic item/list forms.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormItem.pas

    r296 r298  
    9191  J: Integer;
    9292  Control: TControl;
     93  ReferenceList: TItemList;
     94  ReferenceItem: TItem;
    9395begin
    9496  Fields := Item.GetFields;
     
    111113      end;
    112114    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
    113129    else raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[DataType]]));
    114130  end;
     
    131147    else if DataType = dtBoolean then Item.SetValueBoolean(Index, TCheckBox(Control).Checked)
    132148    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
    133154    else raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[DataType]]));
    134155  end;
     
    173194      TComboBox(NewControl).Style := csDropDownList;
    174195    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
    175201    if DataType = dtBoolean then begin
    176202      NewControl := TCheckBox.Create(nil);
Note: See TracChangeset for help on using the changeset viewer.