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

View File

@ -35,6 +35,19 @@ type
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)
private
FCategory: string;

View File

@ -267,6 +267,67 @@ object MainForm: TMainForm
OnChange = EditChange
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
object tsNetwork: TTabSheet
Caption = 'Server - Network'

View File

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