2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "FriendsAndChatPrivatePCH.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implements the FriendsAndChat module.
|
|
|
|
|
*/
|
|
|
|
|
class FFriendsAndChatModule
|
|
|
|
|
: public IFriendsAndChatModule
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2014-09-21 20:35:48 -04:00
|
|
|
// IFriendsAndChatModule interface
|
|
|
|
|
|
2015-08-05 21:54:43 -04:00
|
|
|
virtual TSharedRef<IFriendsAndChatManager> GetFriendsAndChatManager(FName MCPInstanceName, bool InGame) override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-06-03 08:55:45 -04:00
|
|
|
if(MCPInstanceName == TEXT(""))
|
|
|
|
|
{
|
|
|
|
|
if (!DefaultManager.IsValid())
|
|
|
|
|
{
|
|
|
|
|
DefaultManager = MakeShareable(new FFriendsAndChatManager());
|
2015-08-05 21:54:43 -04:00
|
|
|
DefaultManager->Initialize(InGame);
|
2015-06-03 08:55:45 -04:00
|
|
|
}
|
|
|
|
|
return DefaultManager.ToSharedRef();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TSharedRef<FFriendsAndChatManager>* FoundManager = ManagerMap.Find(MCPInstanceName);
|
|
|
|
|
if(FoundManager != nullptr)
|
|
|
|
|
{
|
|
|
|
|
return *FoundManager;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<FFriendsAndChatManager> NewManager = MakeShareable(new FFriendsAndChatManager());
|
2015-08-05 21:54:43 -04:00
|
|
|
NewManager->Initialize(InGame);
|
2015-06-03 08:55:45 -04:00
|
|
|
ManagerMap.Add(MCPInstanceName, NewManager);
|
|
|
|
|
return NewManager;
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2014-09-21 20:35:48 -04:00
|
|
|
// IModuleInterface interface
|
|
|
|
|
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual void StartupModule() override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-13 06:14:46 -04:00
|
|
|
virtual void ShutdownModule() override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-06-03 08:55:45 -04:00
|
|
|
if(DefaultManager.IsValid())
|
|
|
|
|
{
|
|
|
|
|
DefaultManager.Reset();
|
|
|
|
|
}
|
|
|
|
|
ManagerMap.Reset();
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2014-09-21 20:35:48 -04:00
|
|
|
|
2015-06-03 08:55:45 -04:00
|
|
|
TSharedPtr<FFriendsAndChatManager> DefaultManager;
|
|
|
|
|
TMap<FName, TSharedRef<FFriendsAndChatManager>> ManagerMap;
|
2014-03-14 14:13:41 -04:00
|
|
|
};
|
|
|
|
|
|
2014-09-21 20:35:48 -04:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
IMPLEMENT_MODULE( FFriendsAndChatModule, FriendsAndChat );
|