Skip to content

Commit

Permalink
Merge branch 'dev' into robb-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
budak7273 committed Jul 31, 2024
2 parents 6b28a00 + 5d08f79 commit e2022aa
Show file tree
Hide file tree
Showing 23 changed files with 511 additions and 110 deletions.
Binary file modified Content/FactoryGame/PostProcess/MF_ApplyPaniniProjection.uasset
Binary file not shown.
Binary file modified Content/FactoryGame/PostProcess/MF_PaniniProjection.uasset
Binary file not shown.
6 changes: 5 additions & 1 deletion Mods/Alpakit/Alpakit.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
{
"Name": "PluginBrowser",
"Enabled": true
},
{
"Name": "SML",
"Enabled": true
}
]
}
}
6 changes: 5 additions & 1 deletion Mods/Alpakit/Source/Alpakit/Alpakit.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public Alpakit(ReadOnlyTargetRules Target) : base(Target)
"DesktopPlatform",
});

PublicDependencyModuleNames.AddRange(new[] {
"SML",
});

PrivateDependencyModuleNames.AddRange(new[] {
"ApplicationCore",
"Json",
Expand All @@ -29,7 +33,7 @@ public Alpakit(ReadOnlyTargetRules Target) : base(Target)
"EditorStyle",
"PluginBrowser",
"LauncherServices",
"TargetDeviceServices"
"TargetDeviceServices",
});
}
}
43 changes: 34 additions & 9 deletions Mods/Alpakit/Source/Alpakit/Private/AlpakitEditModDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "ISourceControlState.h"
#include "ModMetadataObject.h"
#include "SourceControlOperations.h"
#include "Util/SemVersion.h"

#define LOCTEXT_NAMESPACE "AlpakitEditMod"

Expand All @@ -24,9 +25,13 @@ void SAlpakitEditModDialog::Construct(const FArguments& InArgs, TSharedRef<IPlug
EditModule.RegisterCustomClassLayout(UModMetadataObject::StaticClass()->GetFName(), FOnGetDetailCustomizationInstance::CreateStatic(&FModMetadataCustomization::MakeInstance));
TSharedRef<IDetailsView> PropertyView = EditModule.CreateDetailView(FDetailsViewArgs(false, false, false, FDetailsViewArgs::ActorsUseNameArea, true));
PropertyView->SetObject(MetadataObject, true);
PropertyView->OnFinishedChangingProperties().AddLambda([this](const FPropertyChangedEvent&){
UpdateGameVersionTarget();
});

FString TargetSMLVersion = TEXT("^") + FAlpakitModule::GetCurrentSMLVersion();
FString TargetGameVersion = FAlpakitModule::GetCurrentGameVersion();

UpdateGameVersionTarget();

SWindow::Construct(SWindow::FArguments()
.ClientSize(FVector2D(800.0f, 700.0f))
Expand Down Expand Up @@ -65,21 +70,22 @@ void SAlpakitEditModDialog::Construct(const FArguments& InArgs, TSharedRef<IPlug
+SVerticalBox::Slot().AutoHeight().HAlign(HAlign_Fill)
[
SNew(SBox)
.Visibility_Lambda([this, TargetGameVersion]
.Visibility_Lambda([this]
{
if (MetadataObject->GameVersion == TargetGameVersion)
if (FormatGameVersionRange(ModGameVersionRange) == FormatGameVersionRange(TargetGameVersionRange))
return EVisibility::Collapsed;
return EVisibility::Visible;
})
.Content()
[
SNew(SButton)
.ButtonColorAndOpacity(FLinearColor::Red)
.Text(FText::Format(LOCTEXT("UpdateGameVersionButtonLabel", "Update Game Version to {0}"), FText::FromString(TargetGameVersion)))
.Text_Lambda([this]{ return FText::Format(LOCTEXT("UpdateGameVersionButtonLabel", "Click to update Game Version to {0}"), FText::FromString(FormatGameVersionRange(TargetGameVersionRange))); })
.HAlign(HAlign_Center)
.OnClicked_Lambda([this, TargetGameVersion]
.OnClicked_Lambda([this]
{
MetadataObject->GameVersion = TargetGameVersion;
MetadataObject->GameVersion = FormatGameVersionRange(TargetGameVersionRange);
UpdateGameVersionTarget();
return FReply::Handled();
})
]
Expand Down Expand Up @@ -129,9 +135,28 @@ void SAlpakitEditModDialog::SetSMLDependencyVersion(FString Version) const
SMLDependency->SemVersion = Version;
}

FString SAlpakitEditModDialog::GetGameVersion() const
{
return MetadataObject->GameVersion;
void SAlpakitEditModDialog::UpdateGameVersionTarget() {
FString _;
GameVersion.ParseVersion(FString::Printf(TEXT("%s.0.0"), *FAlpakitModule::GetCurrentGameVersion()), _);
if (!MetadataObject->GameVersion.IsEmpty()) {
ModGameVersionRange.ParseVersionRange(MetadataObject->GameVersion, _);

TargetGameVersionRange.ParseVersionRange(MetadataObject->GameVersion, _);
for (FVersionComparatorCollection& ComparatorCollection : TargetGameVersionRange.Collections) {
ComparatorCollection.Comparators.Add(FVersionComparator(EVersionComparisonOp::GREATER_EQUALS, GameVersion));
}

if (!TargetGameVersionRange.Matches(GameVersion)) {
TargetGameVersionRange = FVersionRange::CreateRangeWithMinVersion(GameVersion);
}
} else {
ModGameVersionRange = FVersionRange();
TargetGameVersionRange = FVersionRange::CreateRangeWithMinVersion(GameVersion);
}
}

FString SAlpakitEditModDialog::FormatGameVersionRange(const FVersionRange& Range) {
return Range.ToString().Replace(TEXT(".0.0"), TEXT(""));
}

FReply SAlpakitEditModDialog::OnOkClicked() {
Expand Down
61 changes: 49 additions & 12 deletions Mods/Alpakit/Source/Alpakit/Private/AlpakitReleaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include "AlpakitSettings.h"
#include "AlpakitStyle.h"
#include "ModTargetsConfig.h"
#include "Util/SemVersion.h"

#define LOCTEXT_NAMESPACE "AlpakitWidget"

void SAlpakitReleaseWidget::Construct(const FArguments& InArgs) {
const float TargetColumnWidth = 90;

FString TargetSMLVersion = TEXT("^") + FAlpakitModule::GetCurrentSMLVersion();
FString TargetGameVersion = FAlpakitModule::GetCurrentGameVersion();

ChildSlot[
SNew(SVerticalBox)
Expand Down Expand Up @@ -84,7 +84,7 @@ void SAlpakitReleaseWidget::Construct(const FArguments& InArgs) {
return !FAlpakitModule::Get().IsPackaging();
});
})
.ModEntryTrail_Lambda([this, TargetColumnWidth, TargetSMLVersion, TargetGameVersion] (const TSharedRef<IPlugin>& Mod) {
.ModEntryTrail_Lambda([this, TargetColumnWidth, TargetSMLVersion] (const TSharedRef<IPlugin>& Mod) {
TSharedRef<FModTargetsConfig> ModTargetsConfig = ModTargetsConfigs.FindOrAdd(Mod->GetName(), MakeShared<FModTargetsConfig>(Mod));

return SNew(SBox)
Expand Down Expand Up @@ -122,10 +122,12 @@ void SAlpakitReleaseWidget::Construct(const FArguments& InArgs) {
+ SHorizontalBox::Slot().AutoWidth().Padding(5,0)[
SNew(SBox)
.HAlign(HAlign_Center)
.Visibility_Lambda([this, Mod, TargetGameVersion]
.Visibility_Lambda([this, Mod]
{
FString GameVersion = GetModGameVersion(Mod);
if (GameVersion == TargetGameVersion)
FVersion GameVersion;
FVersionRange ModGameVersionRange, TargetGameVersionRange;
GetModGameVersionFields(Mod, GameVersion, ModGameVersionRange, TargetGameVersionRange);
if (FormatGameVersionRange(ModGameVersionRange) == FormatGameVersionRange(TargetGameVersionRange))
return EVisibility::Hidden;
return EVisibility::Visible;
})
Expand All @@ -136,17 +138,25 @@ void SAlpakitReleaseWidget::Construct(const FArguments& InArgs) {
SNew(SImage)
.Image(FAlpakitStyle::Get().GetBrush("Alpakit.Warning"))
]
.ToolTipText_Lambda([Mod, TargetGameVersion]
.ToolTipText_Lambda([Mod]
{
FString CurrentGameVersion = GetModGameVersion(Mod);
if (CurrentGameVersion.IsEmpty()) {
CurrentGameVersion = "(unspecified)";
FString GameVersionRaw = GetModGameVersion(Mod);
FVersion GameVersion;
FVersionRange ModGameVersionRange, TargetGameVersionRange;
GetModGameVersionFields(Mod, GameVersion, ModGameVersionRange, TargetGameVersionRange);
if (GameVersionRaw.IsEmpty()) {
GameVersionRaw = "(unspecified)";
} else {
GameVersionRaw = FormatGameVersionRange(ModGameVersionRange);
}
return FText::Format(LOCTEXT("UpdateGameVersionTooltip", "This mod uses game version {0}, but the project is {1}. Click to update"), FText::FromString(CurrentGameVersion), FText::FromString(TargetGameVersion));
return FText::Format(LOCTEXT("UpdateGameVersionTooltip", "This mod uses game version {0}, but the project is {1}. Click to update"), FText::FromString(GameVersionRaw), FText::FromString(FormatGameVersionRange(TargetGameVersionRange)));
})
.OnClicked_Lambda([this, Mod, TargetGameVersion]
.OnClicked_Lambda([this, Mod]
{
SetModGameVersion(Mod, TargetGameVersion);
FVersion GameVersion;
FVersionRange ModGameVersionRange, TargetGameVersionRange;
GetModGameVersionFields(Mod, GameVersion, ModGameVersionRange, TargetGameVersionRange);
SetModGameVersion(Mod, FormatGameVersionRange(TargetGameVersionRange));
return FReply::Handled();
})
]
Expand Down Expand Up @@ -241,6 +251,33 @@ FString SAlpakitReleaseWidget::GetModGameVersion(TSharedRef<IPlugin> Mod)
return GameVersion;
}

void SAlpakitReleaseWidget::GetModGameVersionFields(TSharedRef<IPlugin> Mod, FVersion& GameVersion, FVersionRange& ModGameVersionRange, FVersionRange& TargetGameVersionRange) {
FString ModGameVersion = GetModGameVersion(Mod);

FString _;
GameVersion.ParseVersion(FString::Printf(TEXT("%s.0.0"), *FAlpakitModule::GetCurrentGameVersion()), _);
if (!ModGameVersion.IsEmpty()) {
ModGameVersionRange.ParseVersionRange(ModGameVersion, _);

TargetGameVersionRange.ParseVersionRange(ModGameVersion, _);
for (FVersionComparatorCollection& ComparatorCollection : TargetGameVersionRange.Collections) {
ComparatorCollection.Comparators.Add(FVersionComparator(EVersionComparisonOp::GREATER_EQUALS, GameVersion));
}

if (!TargetGameVersionRange.Matches(GameVersion)) {
TargetGameVersionRange = FVersionRange::CreateRangeWithMinVersion(GameVersion);
}
} else {
ModGameVersionRange = FVersionRange();
TargetGameVersionRange = FVersionRange::CreateRangeWithMinVersion(GameVersion);
}
}

FString SAlpakitReleaseWidget::FormatGameVersionRange(const FVersionRange& TargetGameVersionRange) {
return TargetGameVersionRange.ToString().Replace(TEXT(".0.0"), TEXT(""));
}


void SAlpakitReleaseWidget::SetModGameVersion(TSharedRef<IPlugin> Mod, FString Version)
{
FPluginDescriptor Descriptor = Mod->GetDescriptor();
Expand Down
2 changes: 1 addition & 1 deletion Mods/Alpakit/Source/Alpakit/Private/ModMetadataObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
UModMetadataObject::UModMetadataObject(const FObjectInitializer& ObjectInitializer)
{
Category = TEXT("Modding"); // Group all mods in this category
GameVersion = FAlpakitModule::GetCurrentGameVersion();
GameVersion = FString::Printf(TEXT(">=%s"), *FAlpakitModule::GetCurrentGameVersion());
}

void UModMetadataObject::PopulateFromDescriptor(const FPluginDescriptor& InDescriptor)
Expand Down
9 changes: 8 additions & 1 deletion Mods/Alpakit/Source/Alpakit/Public/AlpakitEditModDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "ModMetadataObject.h"
#include "Slate.h"
#include "Interfaces/IPluginManager.h"
#include "Util/SemVersion.h"

class SAlpakitEditModDialog : public SWindow
{
Expand All @@ -14,10 +15,16 @@ class SAlpakitEditModDialog : public SWindow

FString GetSMLDependencyVersion() const;
void SetSMLDependencyVersion(FString Version) const;
FString GetGameVersion() const;
void UpdateGameVersionTarget();

static FString FormatGameVersionRange(const FVersionRange& Range);

private:
TSharedPtr<IPlugin> Mod;
UModMetadataObject* MetadataObject = nullptr;
FVersion GameVersion;
FVersionRange ModGameVersionRange;
FVersionRange TargetGameVersionRange;

FReply OnOkClicked();
};
4 changes: 4 additions & 0 deletions Mods/Alpakit/Source/Alpakit/Public/AlpakitReleaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "AlpakitModEntryList.h"
#include "ModTargetsConfig.h"
#include "Slate.h"
#include "Util/SemVersion.h"

class SAlpakitReleaseWidget : public SCompoundWidget {
public:
Expand All @@ -15,6 +16,9 @@ class SAlpakitReleaseWidget : public SCompoundWidget {
static void SetModSMLDependencyVersion(TSharedRef<IPlugin> Mod, FString Version);
static FString GetModGameVersion(TSharedRef<IPlugin> Mod);
static void SetModGameVersion(TSharedRef<IPlugin> Mod, FString Version);
static void GetModGameVersionFields(TSharedRef<IPlugin> Mod, FVersion& GameVersion, FVersionRange& ModGameVersionRange, FVersionRange& TargetGameVersionRange);
static FString FormatGameVersionRange(const FVersionRange& TargetGameVersionRange);

private:
TSharedPtr<SAlpakitModEntryList> ModList;
TMap<FString, TSharedRef<FModTargetsConfig>> ModTargetsConfigs;
Expand Down
20 changes: 15 additions & 5 deletions Mods/SML/Source/SML/Private/ModLoading/ModLoadingLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void FSMLPluginDescriptorMetadata::SetupDefaults(const FPluginDescriptor& Plugin
this->Version = FVersion(PluginDescriptor.Version, 0, 0);
this->bAcceptsAnyRemoteVersion = false;
this->RemoteVersionRange = FVersionRange::CreateRangeWithMinVersion(Version);
this->GameVersion = 0;
this->GameVersion = FVersionRange::CreateAnyVersionRange();
}

void FSMLPluginDescriptorMetadata::Load(const FString& PluginName, const TSharedPtr<FJsonObject> Source) {
Expand Down Expand Up @@ -59,7 +59,17 @@ void FSMLPluginDescriptorMetadata::Load(const FString& PluginName, const TShared
}
}

if (!Source->TryGetNumberField(TEXT("GameVersion"), GameVersion)) {
FString GameVersionRangeString;
if (Source->TryGetStringField(TEXT("GameVersion"), GameVersionRangeString)) {
FVersionRange GameVersionRange;
FString GameVersionRangeError;

if (GameVersionRange.ParseVersionRange(GameVersionRangeString, GameVersionRangeError)) {
this->GameVersion = GameVersionRange;
} else {
UE_LOG(LogSatisfactoryModLoader, Error, TEXT("Plugin %s has invalid Game Version value: %s: %s"), *PluginName, *GameVersionRangeString, *GameVersionRangeError);
}
} else {
UE_LOG(LogSatisfactoryModLoader, Warning, TEXT("Plugin %s does not specify 'GameVersion' field, unable to check for game compatibility"), *PluginName);
}

Expand Down Expand Up @@ -242,9 +252,9 @@ void UModLoadingLibrary::VerifyPluginDependencies(IPlugin& Plugin, TArray<FStrin

const uint32 CurrentChangelist = FEngineVersion::Current().GetChangelist();

if (PluginDescriptorMetadata.GameVersion > CurrentChangelist) {
const FString Message = FString::Printf(TEXT("Plugin %s requires game version %d or higher (current: %d)"),
*Plugin.GetName(), PluginDescriptorMetadata.GameVersion, CurrentChangelist);
if (!PluginDescriptorMetadata.GameVersion.Matches(FVersion(CurrentChangelist, 0, 0))) {
const FString Message = FString::Printf(TEXT("Plugin %s requires game version %s (current: %d)"),
*Plugin.GetName(), *PluginDescriptorMetadata.GameVersion.ToString().Replace(TEXT(".0.0"), TEXT("")), CurrentChangelist);
MismatchedDependencies.Add(Message);
}
}
Expand Down
Loading

0 comments on commit e2022aa

Please sign in to comment.