Mark van Renswoude
12eba2e832
Added: saving / reverting changes Fixed: access violation on preview with an empty map list
105 lines
2.8 KiB
ObjectPascal
105 lines
2.8 KiB
ObjectPascal
unit Game.Intf;
|
|
|
|
interface
|
|
uses
|
|
System.Generics.Collections;
|
|
|
|
|
|
type
|
|
IGameNetwork = interface
|
|
['{0B1445D2-E6B7-45FD-98CB-A76F01B9D4B8}']
|
|
function GetServerPort: Integer;
|
|
function GetPeerPort: Integer;
|
|
function GetQueryPort: Integer;
|
|
|
|
procedure SetServerPort(const Value: Integer);
|
|
procedure SetPeerPort(const Value: Integer);
|
|
procedure SetQueryPort(const Value: Integer);
|
|
|
|
property ServerPort: Integer read GetServerPort write SetServerPort;
|
|
property PeerPort: Integer read GetPeerPort write SetPeerPort;
|
|
property QueryPort: Integer read GetQueryPort write SetQueryPort;
|
|
end;
|
|
|
|
|
|
IGameName = interface
|
|
['{44A04A0D-BE01-42B7-8EF1-7EC5CC431B66}']
|
|
function GetServerName: string;
|
|
function GetMessageOfTheDay: string;
|
|
|
|
procedure SetServerName(const Value: string);
|
|
procedure SetMessageOfTheDay(const Value: string);
|
|
|
|
property ServerName: string read GetServerName write SetServerName;
|
|
property MessageOfTheDay: string read GetMessageOfTheDay write SetMessageOfTheDay;
|
|
end;
|
|
|
|
|
|
TGameMap = class(TObject)
|
|
private
|
|
FCategory: string;
|
|
FName: string;
|
|
FDisplayName: string;
|
|
protected
|
|
function GetDisplayName: string; virtual;
|
|
public
|
|
constructor Create(const AName: string; const ADisplayName, ACategory: string); overload;
|
|
constructor Create(AClone: TGameMap); overload;
|
|
|
|
property Category: string read FCategory;
|
|
property Name: string read FName;
|
|
property DisplayName: string read GetDisplayName;
|
|
end;
|
|
|
|
|
|
IGameMapList = interface
|
|
['{E8552B4C-9447-4FAD-BB20-C5EB3AF07B0E}']
|
|
function GetPredefinedMapList: TEnumerable<TGameMap>;
|
|
function GetMapList: TEnumerable<TGameMap>;
|
|
|
|
function GetMapCount: Integer;
|
|
function GetMap(Index: Integer): TGameMap;
|
|
|
|
procedure AddMap(AMap: TGameMap);
|
|
procedure InsertMap(Index: Integer; AMap: TGameMap);
|
|
procedure DeleteMap(AIndex: Integer);
|
|
procedure RemoveMap(AMap: TGameMap);
|
|
procedure MoveMap(ASourceIndex, ATargetIndex: Integer);
|
|
|
|
property PredefinedMapList: TEnumerable<TGameMap> read GetPredefinedMapList;
|
|
property MapList: TEnumerable<TGameMap> read GetMapList;
|
|
|
|
property MapCount: Integer read GetMapCount;
|
|
property Map[Index: Integer]: TGameMap read GetMap;
|
|
end;
|
|
|
|
|
|
implementation
|
|
uses
|
|
System.StrUtils;
|
|
|
|
|
|
{ TGameMap }
|
|
constructor TGameMap.Create(const AName, ADisplayName, ACategory: string);
|
|
begin
|
|
inherited Create;
|
|
|
|
FName := AName;
|
|
FDisplayName := IfThen(Length(ADisplayName) > 0, ADisplayName, AName);
|
|
FCategory := ACategory;
|
|
end;
|
|
|
|
|
|
constructor TGameMap.Create(AClone: TGameMap);
|
|
begin
|
|
Create(AClone.Name, AClone.DisplayName, AClone.Category);
|
|
end;
|
|
|
|
|
|
function TGameMap.GetDisplayName: string;
|
|
begin
|
|
Result := FDisplayName;
|
|
end;
|
|
|
|
end.
|