Added: Game/Admin password configuration

This commit is contained in:
Mark van Renswoude 2014-07-29 21:40:55 +00:00
parent 406e6e037a
commit 6bf321999d
4 changed files with 161 additions and 1 deletions

View File

@ -9,7 +9,7 @@ uses
type type
TChivalryGame = class(TCustomGame, IGameNetwork, IGameName, IGameMapList) TChivalryGame = class(TCustomGame, IGameNetwork, IGameName, IGamePassword, IGameMapList)
private private
FServerPort: Integer; FServerPort: Integer;
FPeerPort: Integer; FPeerPort: Integer;
@ -18,6 +18,9 @@ type
FServerName: string; FServerName: string;
FMessageOfTheDay: string; FMessageOfTheDay: string;
FGamePassword: string;
FAdminPassword: string;
FPredefinedMapList: TObjectList<TGameMap>; FPredefinedMapList: TObjectList<TGameMap>;
FMapList: TObjectList<TGameMap>; FMapList: TObjectList<TGameMap>;
protected protected
@ -57,6 +60,16 @@ type
property ServerName: string read GetServerName write SetServerName; property ServerName: string read GetServerName write SetServerName;
property MessageOfTheDay: string read GetMessageOfTheDay write SetMessageOfTheDay; property MessageOfTheDay: string read GetMessageOfTheDay write SetMessageOfTheDay;
{ IGamePassword }
function GetGamePassword: string;
function GetAdminPassword: string;
procedure SetGamePassword(const Value: string);
procedure SetAdminPassword(const Value: string);
property GamePassword: string read GetGamePassword write SetGamePassword;
property AdminPassword: string read GetAdminPassword write SetAdminPassword;
{ IGameMapList } { IGameMapList }
function GetPredefinedMapList: TEnumerable<TGameMap>; function GetPredefinedMapList: TEnumerable<TGameMap>;
function GetMapList: TEnumerable<TGameMap>; function GetMapList: TEnumerable<TGameMap>;
@ -101,6 +114,10 @@ const
GameAOCGame = 'AOC.AOCGame'; GameAOCGame = 'AOC.AOCGame';
GameAOCGameMapList = 'Maplist'; GameAOCGameMapList = 'Maplist';
GameAccessControl = 'Engine.AccessControl';
GameAccessControlGamePassword = 'GamePassword';
GameAccessControlAdminPassword = 'AdminPassword';
EngineSettingsFileName = 'UDKGame\Config\PCServer-UDKEngine.ini'; EngineSettingsFileName = 'UDKGame\Config\PCServer-UDKEngine.ini';
EngineSteam = 'OnlineSubsystemSteamworks.OnlineSubsystemSteamworks'; EngineSteam = 'OnlineSubsystemSteamworks.OnlineSubsystemSteamworks';
@ -132,7 +149,9 @@ end;
function TChivalryGame.GetExecutable: string; function TChivalryGame.GetExecutable: string;
var var
{$IFNDEF WIN64}
isWow64: BOOL; isWow64: BOOL;
{$ENDIF}
bits: string; bits: string;
begin begin
@ -179,6 +198,9 @@ begin
SetServerName(gameSettings.ReadString(GameReplicationInfo, GameReplicationInfoServerName, '')); SetServerName(gameSettings.ReadString(GameReplicationInfo, GameReplicationInfoServerName, ''));
SetMessageOfTheDay(gameSettings.ReadString(GameReplicationInfo, GameReplicationInfoMessageOfTheDay, '')); SetMessageOfTheDay(gameSettings.ReadString(GameReplicationInfo, GameReplicationInfoMessageOfTheDay, ''));
SetGamePassword(gameSettings.ReadString(GameAccessControl, GameAccessControlGamePassword, ''));
SetAdminPassword(gameSettings.ReadString(GameAccessControl, GameAccessControlAdminPassword, ''));
mapListChanged := (FMapList.Count > 0); mapListChanged := (FMapList.Count > 0);
FMapList.Clear; FMapList.Clear;
@ -225,6 +247,9 @@ begin
gameSettings.WriteString(GameReplicationInfo, GameReplicationInfoServerName, ServerName); gameSettings.WriteString(GameReplicationInfo, GameReplicationInfoServerName, ServerName);
gameSettings.WriteString(GameReplicationInfo, GameReplicationInfoMessageOfTheDay, MessageOfTheDay); gameSettings.WriteString(GameReplicationInfo, GameReplicationInfoMessageOfTheDay, MessageOfTheDay);
gameSettings.WriteString(GameAccessControl, GameAccessControlGamePassword, GamePassword);
gameSettings.WriteString(GameAccessControl, GameAccessControlAdminPassword, AdminPassword);
{ Remove all Maplist references before rewriting the list } { Remove all Maplist references before rewriting the list }
gameSettings.DeleteDuplicateKeys(GameAOCGame, GameAOCGameMapList); gameSettings.DeleteDuplicateKeys(GameAOCGame, GameAOCGameMapList);
@ -347,6 +372,38 @@ begin
end; end;
function TChivalryGame.GetGamePassword: string;
begin
Result := FGamePassword;
end;
function TChivalryGame.GetAdminPassword: string;
begin
Result := FAdminPassword;
end;
procedure TChivalryGame.SetGamePassword(const Value: string);
begin
if Value <> FGamePassword then
begin
FGamePassword := Value;
PropertyChanged('GamePassword');
end;
end;
procedure TChivalryGame.SetAdminPassword(const Value: string);
begin
if Value <> FAdminPassword then
begin
FAdminPassword := Value;
PropertyChanged('AdminPassword');
end;
end;
function TChivalryGame.GetPredefinedMapList: TEnumerable<TGameMap>; function TChivalryGame.GetPredefinedMapList: TEnumerable<TGameMap>;
begin begin
Result := FPredefinedMapList; Result := FPredefinedMapList;

View File

@ -35,6 +35,19 @@ type
end; end;
IGamePassword = interface
['{30BD2D9D-4249-4D49-8376-E8A2E4809CBA}']
function GetGamePassword: string;
function GetAdminPassword: string;
procedure SetGamePassword(const Value: string);
procedure SetAdminPassword(const Value: string);
property GamePassword: string read GetGamePassword write SetGamePassword;
property AdminPassword: string read GetAdminPassword write SetAdminPassword;
end;
TGameMap = class(TObject) TGameMap = class(TObject)
private private
FCategory: string; FCategory: string;

View File

@ -267,6 +267,67 @@ object MainForm: TMainForm
OnChange = EditChange OnChange = EditChange
end end
end end
object gbPassword: TGroupBox
AlignWithMargins = True
Left = 9
Top = 93
Width = 539
Height = 96
Margins.Left = 9
Margins.Top = 0
Margins.Right = 9
Margins.Bottom = 8
Align = alTop
TabOrder = 1
DesignSize = (
539
96)
object lblGamePassword: TLabel
Left = 12
Top = 15
Width = 80
Height = 13
Caption = 'Game password:'
end
object lblAdminPassword: TLabel
Left = 11
Top = 42
Width = 82
Height = 13
Caption = 'Admin password:'
end
object edtGamePassword: TEdit
Left = 132
Top = 12
Width = 401
Height = 21
Hint = 'INI:Engine.AccessControl>GamePassword'
Anchors = [akLeft, akTop, akRight]
PasswordChar = '*'
TabOrder = 0
OnChange = EditChange
end
object edtAdminPassword: TEdit
Left = 131
Top = 39
Width = 401
Height = 21
Hint = 'INI:Engine.AccessControl>AdminPassword'
Anchors = [akLeft, akTop, akRight]
PasswordChar = '*'
TabOrder = 1
OnChange = EditChange
end
object cbShowPasswords: TCheckBox
Left = 131
Top = 66
Width = 402
Height = 17
Caption = ' &Show passwords'
TabOrder = 2
OnClick = cbShowPasswordsClick
end
end
end end
object tsNetwork: TTabSheet object tsNetwork: TTabSheet
Caption = 'Server - Network' Caption = 'Server - Network'

View File

@ -139,6 +139,12 @@ type
llWebsite: TLinkLabel; llWebsite: TLinkLabel;
lblProductName: TLabel; lblProductName: TLabel;
lblCopyright: TLabel; lblCopyright: TLabel;
gbPassword: TGroupBox;
lblGamePassword: TLabel;
edtGamePassword: TEdit;
lblAdminPassword: TLabel;
edtAdminPassword: TEdit;
cbShowPasswords: TCheckBox;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
@ -169,6 +175,7 @@ type
procedure actMapRemoveExecute(Sender: TObject); procedure actMapRemoveExecute(Sender: TObject);
procedure actMapUpExecute(Sender: TObject); procedure actMapUpExecute(Sender: TObject);
procedure actMapDownExecute(Sender: TObject); procedure actMapDownExecute(Sender: TObject);
procedure cbShowPasswordsClick(Sender: TObject);
private type private type
TBindingExpressionList = TList<TBindingExpression>; TBindingExpressionList = TList<TBindingExpression>;
TPageMenuDictionary = TDictionary<TTabSheet, TX2MenuBarItem>; TPageMenuDictionary = TDictionary<TTabSheet, TX2MenuBarItem>;
@ -190,6 +197,7 @@ type
procedure Bind(const APropertyName: string; ADestObject: TObject; const ADestPropertyName: string); procedure Bind(const APropertyName: string; ADestObject: TObject; const ADestPropertyName: string);
procedure BindGameNetwork; procedure BindGameNetwork;
procedure BindGameName; procedure BindGameName;
procedure BindGamePassword;
procedure UpdateMenu; procedure UpdateMenu;
procedure UpdateGameList; procedure UpdateGameList;
@ -374,6 +382,9 @@ begin
if Supports(ActiveGame, IGameName) then if Supports(ActiveGame, IGameName) then
BindGameName; BindGameName;
if Supports(ActiveGame, IGamePassword) then
BindGamePassword;
if Supports(ActiveGame, IGameMapList) then if Supports(ActiveGame, IGameMapList) then
UpdateMapList; UpdateMapList;
@ -452,6 +463,22 @@ begin
end; end;
procedure TMainForm.BindGamePassword;
begin
Bind('GamePassword', edtGamePassword, 'Text');
Bind('AdminPassword', edtAdminPassword, 'Text');
end;
procedure TMainForm.cbShowPasswordsClick(Sender: TObject);
const
PasswordChar: array[Boolean] of Char = ('*', #0);
begin
edtGamePassword.PasswordChar := PasswordChar[cbShowPasswords.Checked];
edtAdminPassword.PasswordChar := PasswordChar[cbShowPasswords.Checked];
end;
procedure TMainForm.UpdateMenu; procedure TMainForm.UpdateMenu;
procedure EnablePageByInterface(APage: TTabSheet; AInterface: TGUID); procedure EnablePageByInterface(APage: TTabSheet; AInterface: TGUID);
@ -464,6 +491,8 @@ begin
EnablePageByInterface(tsConfiguration, IGameName); EnablePageByInterface(tsConfiguration, IGameName);
EnablePageByInterface(tsMapList, IGameMapList); EnablePageByInterface(tsMapList, IGameMapList);
gbPassword.Visible := Supports(ActiveGame, IGamePassword);
if Assigned(mbMenu.SelectedItem) and (not mbMenu.SelectedItem.Enabled) then if Assigned(mbMenu.SelectedItem) and (not mbMenu.SelectedItem.Enabled) then
mbMenu.SelectFirst; mbMenu.SelectFirst;
end; end;