2015-03-05 00:11:00 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2015-01-27 16:31:40 -05:00
|
|
|
|
|
|
|
|
#include "LocalizationDashboardPrivatePCH.h"
|
|
|
|
|
#include "ILocalizationDashboardModule.h"
|
2015-01-29 17:59:14 -05:00
|
|
|
#include "LocalizationDashboard.h"
|
2015-03-04 22:31:03 -05:00
|
|
|
#include "LocalizationTarget.h"
|
2015-01-27 16:31:40 -05:00
|
|
|
#include "SDockTab.h"
|
|
|
|
|
#include "Features/IModularFeatures.h"
|
|
|
|
|
#include "ILocalizationServiceProvider.h"
|
2015-03-05 00:08:26 -05:00
|
|
|
#include "LocalizationTargetSetDetailCustomization.h"
|
|
|
|
|
#include "LocalizationTargetDetailCustomization.h"
|
2015-01-27 16:31:40 -05:00
|
|
|
|
2015-01-27 18:24:26 -05:00
|
|
|
#define LOCTEXT_NAMESPACE "LocalizationDashboard"
|
|
|
|
|
|
2015-01-27 16:31:40 -05:00
|
|
|
class FLocalizationDashboardModule
|
|
|
|
|
: public ILocalizationDashboardModule
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FLocalizationDashboardModule()
|
2015-03-04 22:31:03 -05:00
|
|
|
: Settings(GetMutableDefault<ULocalizationTargetSet>(ULocalizationTargetSet::StaticClass()))
|
2015-01-27 16:31:40 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
for (ULocalizationTarget*& Target : Settings->TargetObjects)
|
|
|
|
|
{
|
2015-03-09 15:09:46 -04:00
|
|
|
Target->UpdateStatusFromConflictReport();
|
|
|
|
|
Target->UpdateWordCountsFromCSV();
|
2015-01-27 16:31:40 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Begin IModuleInterface interface
|
|
|
|
|
virtual void StartupModule() override
|
|
|
|
|
{
|
|
|
|
|
ServiceProviders = IModularFeatures::Get().GetModularFeatureImplementations<ILocalizationServiceProvider>("LocalizationService");
|
|
|
|
|
ServiceProviders.Insert(nullptr, 0); // "None"
|
2015-03-05 00:08:26 -05:00
|
|
|
|
|
|
|
|
FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
|
|
|
|
|
PropertyModule.RegisterCustomClassLayout("LocalizationTargetSet", FOnGetDetailCustomizationInstance::CreateLambda(
|
|
|
|
|
[]() -> TSharedRef<IDetailCustomization>
|
|
|
|
|
{
|
|
|
|
|
return MakeShareable( new FLocalizationTargetSetDetailCustomization());
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
PropertyModule.RegisterCustomClassLayout("LocalizationTarget", FOnGetDetailCustomizationInstance::CreateLambda(
|
|
|
|
|
[]() -> TSharedRef<IDetailCustomization>
|
|
|
|
|
{
|
|
|
|
|
return MakeShareable( new FLocalizationTargetDetailCustomization());
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
FLocalizationDashboard::Initialize();
|
2015-01-27 16:31:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void ShutdownModule() override
|
|
|
|
|
{
|
2015-01-29 17:59:14 -05:00
|
|
|
FLocalizationDashboard::Terminate();
|
2015-03-05 00:08:26 -05:00
|
|
|
|
|
|
|
|
FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
|
|
|
|
|
PropertyModule.UnregisterCustomClassLayout("LocalizationTarget");
|
|
|
|
|
PropertyModule.UnregisterCustomClassLayout("LocalizationTargetSet");
|
2015-01-27 16:31:40 -05:00
|
|
|
}
|
|
|
|
|
// End IModuleInterface interface
|
|
|
|
|
|
|
|
|
|
virtual void Show()
|
|
|
|
|
{
|
2015-01-29 17:59:14 -05:00
|
|
|
FLocalizationDashboard* const LocalizationDashboard = FLocalizationDashboard::Get();
|
|
|
|
|
if (LocalizationDashboard)
|
|
|
|
|
{
|
|
|
|
|
LocalizationDashboard->Show();
|
|
|
|
|
}
|
2015-01-27 16:31:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual const TArray<ILocalizationServiceProvider*>& GetLocalizationServiceProviders() const
|
|
|
|
|
{
|
|
|
|
|
return ServiceProviders;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual ILocalizationServiceProvider* GetCurrentLocalizationServiceProvider() const
|
|
|
|
|
{
|
2015-03-04 22:31:03 -05:00
|
|
|
if(CurrentServiceProviderName == NAME_None)
|
2015-01-27 16:31:40 -05:00
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 22:31:03 -05:00
|
|
|
auto ServiceProviderNameComparator = [this](ILocalizationServiceProvider* const LSP) -> bool
|
2015-01-27 16:31:40 -05:00
|
|
|
{
|
2015-03-04 22:31:03 -05:00
|
|
|
return LSP ? LSP->GetName() == CurrentServiceProviderName : false;
|
2015-01-27 16:31:40 -05:00
|
|
|
};
|
|
|
|
|
ILocalizationServiceProvider* const * LSP = ServiceProviders.FindByPredicate(ServiceProviderNameComparator);
|
|
|
|
|
return LSP ? *LSP : nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2015-03-04 22:31:03 -05:00
|
|
|
TWeakObjectPtr<ULocalizationTargetSet> Settings;
|
2015-01-27 16:31:40 -05:00
|
|
|
TArray<ILocalizationServiceProvider*> ServiceProviders;
|
2015-03-04 22:31:03 -05:00
|
|
|
FName CurrentServiceProviderName;
|
2015-01-27 16:31:40 -05:00
|
|
|
};
|
|
|
|
|
|
2015-01-27 18:24:26 -05:00
|
|
|
IMPLEMENT_MODULE(FLocalizationDashboardModule, "LocalizationDashboard");
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|