Changeset 296 for trunk/UBuilding.pas


Ignore:
Timestamp:
Mar 29, 2019, 12:58:09 PM (6 years ago)
Author:
chronos
Message:
  • Added: New enumeration field type in generic TItem classes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UBuilding.pas

    r294 r296  
    5252  SCost = 'Cost';
    5353  SSpecialType = 'Special type';
     54  SNone = 'None';
     55  SCity = 'City';
    5456
    5557
     
    8385
    8486class function TBuildingKind.GetFields: TItemFields;
     87var
     88  Field: TItemField;
    8589begin
    8690  Result := inherited;
    8791  Result.AddField(2, 'Cost', SCost, dtInteger);
    88   Result.AddField(3, 'SpecialType', SSpecialType, dtInteger);
     92  Field := Result.AddField(3, 'SpecialType', SSpecialType, dtEnumeration);
     93  Field.EnumStates.Add(SNone);
     94  Field.EnumStates.Add(SCity);
    8995end;
    9096
     
    94100  else if Index = 2 then Integer(Value) := Cost
    95101  else if Index = 3 then TBuildingSpecialType(Value) := SpecialType
    96   else raise Exception.Create('Unsupported value index ' + IntToStr(Index));
     102  else inherited;
    97103end;
    98104
     
    102108  else if Index = 2 then Cost := Integer(Value)
    103109  else if Index = 3 then SpecialType := TBuildingSpecialType(Value)
    104   else raise Exception.Create('Unsupported value index ' + IntToStr(Index));
     110  else inherited;
    105111end;
    106112
Note: See TracChangeset for help on using the changeset viewer.