From 6bf321999d6b39c0b5c02e2e35f40ab8ad7fc20e Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Tue, 29 Jul 2014 21:40:55 +0000 Subject: [PATCH] Added: Game/Admin password configuration --- source/model/Game.Chivalry.pas | 59 +++++++++++++++++++++++++++++++- source/model/Game.Intf.pas | 13 ++++++++ source/view/Forms.Main.dfm | 61 ++++++++++++++++++++++++++++++++++ source/view/Forms.Main.pas | 29 ++++++++++++++++ 4 files changed, 161 insertions(+), 1 deletion(-) diff --git a/source/model/Game.Chivalry.pas b/source/model/Game.Chivalry.pas index 5cfdc62..f7fbac6 100644 --- a/source/model/Game.Chivalry.pas +++ b/source/model/Game.Chivalry.pas @@ -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; FMapList: TObjectList; 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; function GetMapList: TEnumerable; @@ -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; begin Result := FPredefinedMapList; diff --git a/source/model/Game.Intf.pas b/source/model/Game.Intf.pas index a521a0d..fbbc401 100644 --- a/source/model/Game.Intf.pas +++ b/source/model/Game.Intf.pas @@ -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; diff --git a/source/view/Forms.Main.dfm b/source/view/Forms.Main.dfm index 00427a9..da0994f 100644 --- a/source/view/Forms.Main.dfm +++ b/source/view/Forms.Main.dfm @@ -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' diff --git a/source/view/Forms.Main.pas b/source/view/Forms.Main.pas index 89cc662..6077b62 100644 --- a/source/view/Forms.Main.pas +++ b/source/view/Forms.Main.pas @@ -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; TPageMenuDictionary = TDictionary; @@ -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;