Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit b6e4423f authored by g4m4's avatar g4m4
Browse files

[MISC] Minor formatting changes

parent c48551f1
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
*
* Copyright 2024 MachinMachines
*/
......@@ -13,33 +13,33 @@
UFixItCreateNewBugAsyncAction* UFixItCreateNewBugAsyncAction::CreateNewBug(const FFixItBugRequestData& data)
{
UFixItCreateNewBugAsyncAction* BlueprintNode = NewObject<UFixItCreateNewBugAsyncAction>();
BlueprintNode->BugRequestData_ = data;
return BlueprintNode;
UFixItCreateNewBugAsyncAction* BlueprintNode = NewObject<UFixItCreateNewBugAsyncAction>();
BlueprintNode->BugRequestData_ = data;
return BlueprintNode;
}
void UFixItCreateNewBugAsyncAction::Activate()
{
#if PLATFORM_WINDOWS
if (UFixItSubsystem* FixItSubsystem = GEngine->GetEngineSubsystem<UFixItSubsystem>())
{
FFixItBackend* backend = FixItSubsystem->GetBackend();
if (backend)
{
if (backend->CreateNewBug(
BugRequestData_,
[this](bool result, const FString& message) {
OnNewBugRequestComplete.Broadcast(result, message);
},
[this](bool result, const FString& message) {
OnNewBugRequestProgress.Broadcast(result, message);
}))
{
// Success so far, waiting for the result
return;
}
}
}
OnNewBugRequestComplete.Broadcast(false, TEXT("Bug could not be created!"));
if (UFixItSubsystem* FixItSubsystem = GEngine->GetEngineSubsystem<UFixItSubsystem>())
{
FFixItBackend* backend = FixItSubsystem->GetBackend();
if (backend)
{
if (backend->CreateNewBug(
BugRequestData_,
[this](bool result, const FString& message) {
OnNewBugRequestComplete.Broadcast(result, message);
},
[this](bool result, const FString& message) {
OnNewBugRequestProgress.Broadcast(result, message);
}))
{
// Success so far, waiting for the result
return;
}
}
}
OnNewBugRequestComplete.Broadcast(false, TEXT("Bug could not be created!"));
#endif
}
......@@ -22,28 +22,28 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FNewBugRequestProgressPin, bool, Su
UCLASS()
class UFixItCreateNewBugAsyncAction : public UBlueprintAsyncActionBase
{
GENERATED_BODY()
GENERATED_BODY()
public:
// Simple BP-ready bug creation with no UI
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"), Category = "FixIt")
static UFixItCreateNewBugAsyncAction* CreateNewBug(const FFixItBugRequestData& data);
// Simple BP-ready bug creation with no UI
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"), Category = "FixIt")
static UFixItCreateNewBugAsyncAction* CreateNewBug(const FFixItBugRequestData& data);
// Invoked possibly multiple times:
// - at the bug creation
// - at every update (file attached, etc.)
UPROPERTY(BlueprintAssignable)
FNewBugRequestProgressPin OnNewBugRequestProgress;
// Invoked possibly multiple times:
// - at the bug creation
// - at every update (file attached, etc.)
UPROPERTY(BlueprintAssignable)
FNewBugRequestProgressPin OnNewBugRequestProgress;
// Invoked once the bug request has been fully processed - be it successful or not
UPROPERTY(BlueprintAssignable)
FNewBugRequestCompletePin OnNewBugRequestComplete;
// Invoked once the bug request has been fully processed - be it successful or not
UPROPERTY(BlueprintAssignable)
FNewBugRequestCompletePin OnNewBugRequestComplete;
// Begin UBlueprintAsyncActionBase interface
virtual void Activate() override;
// End UBlueprintAsyncActionBase interface
// Begin UBlueprintAsyncActionBase interface
virtual void Activate() override;
// End UBlueprintAsyncActionBase interface
private:
UPROPERTY()
FFixItBugRequestData BugRequestData_;
UPROPERTY()
FFixItBugRequestData BugRequestData_;
};
......@@ -19,36 +19,37 @@ THIRD_PARTY_INCLUDES_START
#include "fixit/data/player_data.h"
THIRD_PARTY_INCLUDES_END
namespace {
// These methods are implemetned only here with internal linkage
// so they do not require exposing fixit internal library types
std::unique_ptr<fixit::PlayerDataItem> UFixItPlayerDataItemConvertTo(const UFixItPlayerDataItem* Item) {
std::unique_ptr<char[]> DataCopy = std::make_unique<char[]>(Item->GetSize());
if (!DataCopy) {
UE_LOG(LogFixItCore, Error, TEXT("Could not allocate data for player data item %s"), *Item->Description);
}
// TODO(gama) this makes two copies actually, it could be way better
auto DataPtr = Item->GetData();
std::memcpy(DataCopy.get(), DataPtr.Get()->GetData(), Item->GetSize());
return std::make_unique<fixit::PlayerDataItem>(
FFixItTranslationLayer::ToStd(Item->Description),
FFixItTranslationLayer::ToStd(Item->GetType()),
std::move(DataCopy),
Item->GetSize()
);
}
namespace {
// These methods are implemented only here with internal linkage
// so they do not require exposing fixit internal library types
std::unique_ptr<fixit::PlayerDataItem> UFixItPlayerDataItemConvertTo(const UFixItPlayerDataItem* Item) {
std::unique_ptr<char[]> DataCopy = std::make_unique<char[]>(Item->GetSize());
if (!DataCopy) {
UE_LOG(LogFixItCore, Error, TEXT("Could not allocate data for player data item %s"), *Item->Description);
}
// TODO(gama) this makes two copies actually, it could be way better
auto DataPtr = Item->GetData();
std::memcpy(DataCopy.get(), DataPtr.Get()->GetData(), Item->GetSize());
return std::make_unique<fixit::PlayerDataItem>(
FFixItTranslationLayer::ToStd(Item->Description),
FFixItTranslationLayer::ToStd(Item->GetType()),
std::move(DataCopy),
Item->GetSize()
);
}
fixit::PlayerData UFixItPlayerDataBaseConvertTo(const UFixItPlayerDataBase* PlayerData)
{
fixit::PlayerData Out = fixit::PlayerData(FFixItTranslationLayer::ToStd(PlayerData->PrefilledStr));
for (const auto* Item : PlayerData->Items) {
Out.Items.emplace_back(UFixItPlayerDataItemConvertTo(Item));
}
return Out;
}
}
fixit::PlayerData UFixItPlayerDataBaseConvertTo(const UFixItPlayerDataBase* PlayerData)
{
fixit::PlayerData Out = fixit::PlayerData(FFixItTranslationLayer::ToStd(PlayerData->PrefilledStr));
for (const auto* Item : PlayerData->Items) {
Out.Items.emplace_back(UFixItPlayerDataItemConvertTo(Item));
}
return Out;
}
bool FFixItBugRequestData::IsValid() const
{
......@@ -58,10 +59,10 @@ bool FFixItBugRequestData::IsValid() const
fixit::BugRequestData FFixItBugRequestData::ConvertTo() const
{
return fixit::BugRequestData{
FFixItTranslationLayer::ToStd(Title),
FFixItTranslationLayer::ToStd(Content),
FFixItTranslationLayer::ToStd(Labels),
std::make_unique<fixit::PlayerData>(UFixItPlayerDataBaseConvertTo(PlayerData))
};
return fixit::BugRequestData{
FFixItTranslationLayer::ToStd(Title),
FFixItTranslationLayer::ToStd(Content),
FFixItTranslationLayer::ToStd(Labels),
std::make_unique<fixit::PlayerData>(UFixItPlayerDataBaseConvertTo(PlayerData))
};
}
......@@ -18,9 +18,9 @@ THIRD_PARTY_INCLUDES_END
DEFINE_LOG_CATEGORY(LogFixItCore);
namespace {
void AssertToUnreal(const char* Data, unsigned /*length*/) {
UE_LOG(LogFixItCore, Warning, TEXT("FixItLib: %s"), UTF8_TO_TCHAR(Data));
}
void AssertToUnreal(const char* Data, unsigned /*length*/) {
UE_LOG(LogFixItCore, Warning, TEXT("FixItLib: %s"), UTF8_TO_TCHAR(Data));
}
}
void FFixItCoreModule::StartupModule()
......
......@@ -18,80 +18,80 @@
FString UFixItPlayerDataItem::GetType() const
{
return "";
return "";
}
bool UFixItPlayerDataBlobItem::IsValid() const
{
return Data.Num() > 0;
return Data.Num() > 0;
}
uint32 UFixItPlayerDataBlobItem::GetSize() const
{
return Data.Num();
return Data.Num();
}
TSharedPtr<TArray<uint8>> UFixItPlayerDataBlobItem::GetData() const
{
TSharedPtr<TArray<uint8>> result = MakeShareable(new TArray<uint8>);
// Explicit copy here
*result = Data;
return result;
TSharedPtr<TArray<uint8>> result = MakeShareable(new TArray<uint8>);
// Explicit copy here
*result = Data;
return result;
}
bool UFixItPlayerDataFileItem::IsValid() const
{
return GetSize() > 0;
return GetSize() > 0;
}
uint32 UFixItPlayerDataFileItem::GetSize() const
{
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
if (PlatformFile.FileExists(*Path))
{
return PlatformFile.FileSize(*Path);
}
return 0;
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
if (PlatformFile.FileExists(*Path))
{
return PlatformFile.FileSize(*Path);
}
return 0;
}
FString UFixItPlayerDataFileItem::GetType() const
{
return FPaths::GetExtension(Path);
return FPaths::GetExtension(Path);
}
TSharedPtr<TArray<uint8>> UFixItPlayerDataFileItem::GetData() const
{
TSharedPtr<TArray<uint8>> result = MakeShareable(new TArray<uint8>);
if (FFileHelper::LoadFileToArray(*result, *Path))
{
return result;
}
return nullptr;
TSharedPtr<TArray<uint8>> result = MakeShareable(new TArray<uint8>);
if (FFileHelper::LoadFileToArray(*result, *Path))
{
return result;
}
return nullptr;
}
void UFixItPlayerDataBase::CollectAsync(TFunction<void(void)>&& completionCallback)
{
OnDataCollected.BindLambda(completionCallback);
OnDataCollected.BindLambda(completionCallback);
// ID
PrefilledStr.Append(FString::Format(TEXT("User {0}\n"),
{ FPlatformProcess::UserName(true) }));
// ID
PrefilledStr.Append(FString::Format(TEXT("User {0}\n"),
{ FPlatformProcess::UserName(true) }));
CollectAsyncImpl();
CollectAsyncImpl();
}
TArray<FString> UFixItPlayerDataBase::GetItemDescriptions() const
{
TArray<FString> result;
result.Reserve(Items.Num());
for (const auto* item : Items)
{
result.Add(item->Description);
}
return result;
TArray<FString> result;
result.Reserve(Items.Num());
for (const auto* item : Items)
{
result.Add(item->Description);
}
return result;
}
void UFixItPlayerDataBase::CollectAsyncImpl()
{
// Nothing here
// Nothing here
}
......@@ -30,78 +30,78 @@ UFixItSettings::UFixItSettings()
const UFixItSettings* UFixItSettings::GetSettings()
{
return GetDefault<UFixItSettings>();
return GetDefault<UFixItSettings>();
}
bool UFixItSettings::SaveCredentials(const FString& NewLogin, const FString& NewToken)
{
UFixItSettings* Instance = GetMutableDefault<UFixItSettings>();
if (Instance == nullptr)
{
UE_LOG(LogFixItCore, Error, TEXT("Could not save the new credentials: mutable default settings could not be grabbed"));
return false;
}
Instance->Login = NewLogin;
Instance->Token = NewToken;
UFixItSettings* Instance = GetMutableDefault<UFixItSettings>();
if (Instance == nullptr)
{
UE_LOG(LogFixItCore, Error, TEXT("Could not save the new credentials: mutable default settings could not be grabbed"));
return false;
}
Instance->Login = NewLogin;
Instance->Token = NewToken;
#if WITH_EDITOR
Instance->PostEditChange();
Instance->PostEditChange();
#endif // WITH_EDITOR
Instance->SaveConfig();
Instance->SaveConfig();
#if ENGINE_MAJOR_VERSION <= 4
// In UE < 5.0 TryUpdateDefaultConfigFile() does not exist
Instance->UpdateDefaultConfigFile();
// In UE < 5.0 TryUpdateDefaultConfigFile() does not exist
Instance->UpdateDefaultConfigFile();
#else // ENGINE_MAJOR_VERSION <= 4
Instance->TryUpdateDefaultConfigFile();
Instance->TryUpdateDefaultConfigFile();
#endif // ENGINE_MAJOR_VERSION <= 4
return true;
return true;
}
#if WITH_EDITOR
void UFixItSettings::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
{
UFixItSettings* Instance = GetMutableDefault<UFixItSettings>();
if (Instance == nullptr)
{
UE_LOG(LogFixItCore, Error, TEXT("Could not save settings to the internal struct: mutable default settings could not be grabbed"));
return;
}
UFixItSettings::CopyToInternal(Instance);
UFixItSettings* Instance = GetMutableDefault<UFixItSettings>();
if (Instance == nullptr)
{
UE_LOG(LogFixItCore, Error, TEXT("Could not save settings to the internal struct: mutable default settings could not be grabbed"));
return;
}
UFixItSettings::CopyToInternal(Instance);
}
#endif // WITH_EDITOR
void UFixItSettings::SetInternal(fixit::Settings* InternalSettings)
{
if (InternalSettings == nullptr)
{
UE_LOG(LogFixItCore, Error, TEXT("Could not set the internal settings struct: null pointer"));
return;
}
Settings = InternalSettings;
CopyToInternal(this);
if (InternalSettings == nullptr)
{
UE_LOG(LogFixItCore, Error, TEXT("Could not set the internal settings struct: null pointer"));
return;
}
Settings = InternalSettings;
CopyToInternal(this);
}
void UFixItSettings::CopyToInternal(UFixItSettings* Instance) {
if (Instance->Settings == nullptr)
{
UE_LOG(LogFixItCore, Error, TEXT("Could not save settings to the internal struct: null internal settings"));
return;
}
Instance->Settings->DefaultLogin = FFixItTranslationLayer::ToStd(TEXT(kDefaultCredentialsLogin));
Instance->Settings->DefaultToken = FFixItTranslationLayer::ToStd(TEXT(kDefaultCredentialsToken));
Instance->Settings->Login = FFixItTranslationLayer::ToStd(Instance->Login);
Instance->Settings->Token = FFixItTranslationLayer::ToStd(Instance->Token);
Instance->Settings->ProjectName = FFixItTranslationLayer::ToStd(Instance->ProjectName);
Instance->Settings->URL = FFixItTranslationLayer::ToStd(Instance->URL);
Instance->Settings->Backend = FFixItBackend::GetMatchingBackendType(Instance->Backend);
Instance->Settings->DefaultLabels = FFixItTranslationLayer::ToStd(Instance->DefaultLabels);
Instance->Settings->MaxTitleLength = Instance->MaxTitleLength;
if (Instance->Settings == nullptr)
{
UE_LOG(LogFixItCore, Error, TEXT("Could not save settings to the internal struct: null internal settings"));
return;
}
Instance->Settings->DefaultLogin = FFixItTranslationLayer::ToStd(kDefaultCredentialsLogin);
Instance->Settings->DefaultToken = FFixItTranslationLayer::ToStd(kDefaultCredentialsToken);
Instance->Settings->Login = FFixItTranslationLayer::ToStd(Instance->Login);
Instance->Settings->Token = FFixItTranslationLayer::ToStd(Instance->Token);
Instance->Settings->ProjectName = FFixItTranslationLayer::ToStd(Instance->ProjectName);
Instance->Settings->URL = FFixItTranslationLayer::ToStd(Instance->URL);
Instance->Settings->Backend = FFixItBackend::GetMatchingBackendType(Instance->Backend);
Instance->Settings->DefaultLabels = FFixItTranslationLayer::ToStd(Instance->DefaultLabels);
Instance->Settings->MaxTitleLength = Instance->MaxTitleLength;
}
void UFixItSettings::GetFromInternal(UFixItSettings* Instance) {
(void)Instance;
UE_LOG(LogFixItCore, Error, TEXT("Not implemented for now"));
(void)Instance;
UE_LOG(LogFixItCore, Error, TEXT("Not implemented for now"));
}
......@@ -74,8 +74,8 @@ public:
UPROPERTY(config, EditAnywhere, BlueprintReadOnly, AdvancedDisplay, Category = "UI", meta = (ToolTip = "Display labels customisation in the reporter UI"))
uint32 bAllowCustomisingLabels : 1;
UPROPERTY(config, EditAnywhere, BlueprintReadOnly, AdvancedDisplay, Category = "UI", meta = (ToolTip = "Max issue title length, make sure your backend supports it!"))
int32 MaxTitleLength = 64;
UPROPERTY(config, EditAnywhere, BlueprintReadOnly, AdvancedDisplay, Category = "UI", meta = (ToolTip = "Max issue title length, make sure your backend supports it!"))
int32 MaxTitleLength = 64;
// Begin UDeveloperSettings interface
virtual FName GetContainerName() const override { return FName("Project"); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment