commit c7f5bd93262011ef96cb0a2437a521921a32244d Author: Kyrium Date: Thu Oct 24 18:06:58 2024 +0200 feat: wip diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml new file mode 100644 index 0000000..808ad29 --- /dev/null +++ b/.gitea/workflows/main.yaml @@ -0,0 +1,140 @@ +name: Mod Build +on: + push: + tags: + - "*" +env: + MOD_NAME: "RefinedRDLib" + MOD_ID: "B24emzbs6xVZQr" + SML_DIR: "E:/SF/SML" + ENGINE_DIR: "F:/5.2.1-CSS" + BUILT_MODS_DIR: "${{ gitea.workspace }}/BuiltMods" + DEV_BUILDS_DIR: "${{ gitea.workspace }}/DevBuilds" +jobs: + Setup: + runs-on: windows-2022 + defaults: + run: + shell: pwsh + steps: + - name: Setup SML + run: | + if (!(Test-Path ${{env.SML_DIR}} -PathType Container)) {git clone --branch master https://github.com/satisfactorymodding/SatisfactoryModLoader.git ${{env.SML_DIR}}} + - name: Install WWise + run: | + cd ${{env.SML_DIR}} + if ((Test-Path ${{env.SML_DIR}}/Plugins/Wwise) -eq $true){ echo "WWise already Installed Skipping.."; exit 0 } + E:/SF/Scripts/wwise-cli.exe integrate-ue --integration-version "2022.1.5.2714" --project "${{env.SML_DIR}}/FactoryGame.uproject" + - name: "SML Headers" + run: | + cd E:/SF/Scripts/sml-fixer + ./sml-fixer.exe + PullMods: + needs: Setup + strategy: + matrix: + value: ["RefinedRDLib"] + runs-on: windows-2022 + defaults: + run: + shell: pwsh + steps: + - name: "Clone Mod" + run: | + echo "Cloning Mod ${{matrix.value}}" + cd ${{env.SML_DIR}}/Mods + if (!(Test-Path ${{env.SML_DIR}}/Mods/${{matrix.value}} -PathType Container)) {git clone --branch main git@10.10.10.14:RefinedRD/sf_mod_${{matrix.value}}.git ${{env.SML_DIR}}/Mods/${{matrix.value}}} + cd ${{env.SML_DIR}}/Mods/${{matrix.value}} + git fetch --all + git reset --hard origin/main + echo "Done" + UpdateUPlugins: + needs: PullMods + strategy: + matrix: + value: ["RefinedRDLib"] + runs-on: windows-2022 + defaults: + run: + shell: pwsh + steps: + - name: "Update Mod UPlugin Version" + run: | + echo "Updating ${{env.SML_DIR}}/Mods/${{matrix.value}}/${{matrix.value}}.uplugin" + $Uplugin = (Get-Content ${{env.SML_DIR}}/Mods/${{matrix.value}}/${{matrix.value}}.uplugin | convertfrom-json) + $UPlugin.SemVersion = $(Get-Content "${{env.SML_DIR}}/Mods/${{matrix.value}}/VERSION") + $UPlugin.VersionName = $(Get-Content "${{env.SML_DIR}}/Mods/${{matrix.value}}/VERSION") + $Version = $Uplugin.SemVersion + ($UPlugin | convertto-json -Depth 100) -replace '\\u0026', '&' | Set-Content ${{env.SML_DIR}}/Mods/${{matrix.value}}/${{matrix.value}}.uplugin + echo "Done" + CompileEditor: + needs: UpdateModUPluginDependencies + runs-on: windows-2022 + outputs: + version: ${{steps.getversion.outputs.version}} + defaults: + run: + shell: pwsh + env: + BUILD_TOOL_EXE: ${{env.ENGINE_DIR}}/Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.exe + steps: + - name: Get Version + id: getversion + run: | + $Version = $(Get-Content "${{env.SML_DIR}}/Mods/${{env.MOD_NAME}}/VERSION") + Write-Output "version=$($Version)" >> $Env:GITHUB_OUTPUT + - name: "Gen-VS-Files" + run: | + cd ${{env.SML_DIR}} + ${{env.BUILD_TOOL_EXE}} -projectfiles -project="${{env.SML_DIR}}/FactoryGame.uproject" -game -rocket -progress + - name: Compile Editor + run: | + cd ${{env.SML_DIR}} + ${{env.BUILD_TOOL_EXE}} Development Win64 -project="${{env.SML_DIR}}/FactoryGame.uproject" -TargetType="Editor" -progress + BuildMods: + needs: CompileEditor + strategy: + matrix: + value: ["RefinedRDLib"] + runs-on: windows-2022 + defaults: + run: + shell: pwsh + steps: + - name: "Build Mod" + run: | + $Version = $(Get-Content "${{env.SML_DIR}}/Mods/${{matrix.value}}/VERSION") + & "${{env.ENGINE_DIR}}/Engine/Build/BatchFiles/RunUAT.bat" -ScriptsForProject="${{env.SML_DIR}}/FactoryGame.uproject" PackagePlugin -Project="${{env.SML_DIR}}/FactoryGame.uproject" -dlcname="${{matrix.value}}" -build -server -clientconfig=Shipping -serverconfig=Shipping -platform=Win64 -serverplatform=Win64+Linux -nocompileeditor -installed -merge + if (!(Test-Path ${{env.BUILT_MODS_DIR}})) {New-Item -ItemType Directory -Force -Path ${{env.BUILT_MODS_DIR}}} + Copy-Item ${{env.SML_DIR}}/Saved/ArchivedPlugins/${{matrix.value}}/${{matrix.value}}.zip ${{env.BUILT_MODS_DIR}}/${{matrix.value}}.$Version.zip -Force + - uses: actions/upload-artifact@v3 + with: + name: built-mods + path: ${{env.BUILT_MODS_DIR}}/${{matrix.value}}.*.zip + overwrite: true + SMRDeploy: + if: ${{ vars.DEPLOY != 'false' }} + needs: BuildMods + runs-on: windows-2022 + defaults: + run: + shell: pwsh + steps: + - name: Download a artifact + uses: actions/download-artifact@v3 + with: + name: built-mods + path: ${{env.BUILT_MODS_DIR}} + - name: "Deploy to SMR" + run: | + echo "Deploying to SMR" + $Version = $(Get-Content "${{env.SML_DIR}}/Mods/${{env.MOD_NAME}}/VERSION") + $query = '{ "query": "query { getModByReference(modReference:\"${{env.MOD_NAME}}\"){ versions(filter:{limit: 1}){ version } }}"}' + echo $query + $SMRVersion = (Invoke-RestMethod -Method POST -uri "https://api.ficsit.app/v2/query" -body $query -ContentType "application/json").data.getModByReference.versions[0].version + if($Version -eq $SMRVersion) { echo "SMR Mod Version Already Exists.. Skip"; exit 0 } + $File = (Get-ChildItem "${{env.BUILT_MODS_DIR}}/${{env.MOD_NAME}}*").FullName + $APIURL="https://api.ficsit.app" + write-host "$File, $APIURL" + & "E:/SF/Scripts/ficsit_windows_amd64.exe" smr upload --api-base "$APIURL" --api-key "${{secrets.FICSIT_TOKEN}}" "${{env.MOD_ID}}" "$File" "${{vars.CHANGELOG}}" + echo "Done" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b337069 --- /dev/null +++ b/.gitignore @@ -0,0 +1,101 @@ +# Visual Studio 2015 user specific files +.vs/ + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +# *.dll + +!*.pdb + +# Fortran module files +*.mod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app +*.ipa + +# These project files can be generated by the engine +*.xcodeproj +*.xcworkspace +*.sln +*.suo +*.opensdf +*.sdf +*.VC.db +*.VC.opendb + +# Precompiled Assets +SourceArt/**/*.png +SourceArt/**/*.tga + +# Binary Files +Binaries/* + +# Binaries/* +Plugins/*/Binaries/* + +# Builds +Build/* + +# Whitelist PakBlacklist-.txt files +!Build/*/ +Build/*/** +!Build/*/PakBlacklist*.txt + +# Don't ignore icon files in Build +!Build/**/*.ico + +# Built data for maps +*_BuiltData.uasset + +# Configuration files generated by the Editor +Saved/* + +# Compiled source files for the engine to use +Intermediate/* +Plugins/*/Intermediate/* + +# Cache files for the editor to use +DerivedDataCache/* + +# Wwise +*_WwiseProject/* +Plugins/Wwise/* + +# ModLoader-Solution +!ModLoader/*.sln + +# ModLoader-Binaries +ModLoader/x64 +ModLoader/*/x64 + +Plugins/* + + + +# Mod Zip Files +ZipDir +PreZipDir + +GitNoCommit +SF_ModProject/Plugins/RefinedRDLib/Metadata/Crypto.json +Metadata/Crypto.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..296cad8 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,96 @@ +workflow: + rules: + - if: $CI_COMMIT_TAG + when: always + - when: never + +variables: + GIT_STRATEGY: none + GIT_CHECKOUT: "false" + ErrorActionPreference: STOP + GIT_TEST_DEBUG_UNSAFE_DIRECTORIES: "true" + + # Unreal Engine 4 Project Settings + MOD_NAME: "RefinedRDApi" + MOD_REPO: "refined-rd/sf_mod_refinedrdapi.git" + MOD_ID: "B24emzbs6xVZQr" + SML_DIR: "E:/SF/SML" + ENGINE_DIR: "F:/5.2.1-CSS" + BUILT_MODS_DIR: "$CI_PROJECT_DIR/BuiltMods" + DEV_BUILDS_DIR: "$CI_PROJECT_DIR/DevBuilds" + +stages: + - setup + - compile + - build + - package + - deploy + +1-pull-sml: + stage: setup + script: + - "if (!(Test-Path $BUILT_MODS_DIR)) {New-Item -ItemType Directory -Force -Path $BUILT_MODS_DIR}" + - "if (!(Test-Path $DEV_BUILDS_DIR)) {New-Item -ItemType Directory -Force -Path $DEV_BUILDS_DIR}" + - "Remove-Item $BUILT_MODS_DIR/*" + - "Remove-Item $DEV_BUILDS_DIR/*" + - "if (!(Test-Path $SML_DIR -PathType Container)) {git clone --branch master https://github.com/satisfactorymodding/SatisfactoryModLoader.git $SML_DIR}" + +2-install-wwise: + stage: setup + variables: + WWISE_VERSION: "2022.1.5.8242" + script: + - "cd $SML_DIR" + - "if ((Test-Path $SML_DIR/Plugins/Wwise) -eq $true){ exit 0 }" + - 'E:/SF/Scripts/wwise-cli.exe integrate-ue --integration-version "2022.1.5.2714" --project "$SML_DIR/FactoryGame.uproject"' + +3-pull-mod: + stage: setup + script: + - "cd $SML_DIR/Mods" + - "if (!(Test-Path $SML_DIR/Mods/$MOD_NAME -PathType Container)) {git clone --branch ue5 git@10.10.10.6:$MOD_REPO $SML_DIR/Mods/$MOD_NAME}" + - "cd $SML_DIR/Mods/$MOD_NAME" + - "git fetch --all" + - "git reset --hard origin/ue5" + +4-header-update: + stage: setup + script: + - "cd E:/SF/Scripts/sml-fixer" + - "./sml-fixer.exe" + +1-gen-vs-files: + stage: compile + script: + - "cd $SML_DIR" + - '& "$ENGINE_DIR/Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.exe" -projectfiles -project="$SML_DIR/FactoryGame.uproject" -game -rocket -progress' + +2-compile-editor: + stage: compile + script: + - '& "$ENGINE_DIR/Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.exe" Development Win64 -project="$SML_DIR/FactoryGame.uproject" -TargetType="Editor" -progress' + +1-build-mod: + stage: build + script: + - "$UPlugin = (Get-Content $SML_DIR/Mods/$MOD_NAME/$MOD_NAME.uplugin | convertfrom-json)" + - '$UPlugin.SemVersion = $(Get-Content "$SML_DIR/Mods/$MOD_NAME/VERSION")' + - '$UPlugin.VersionName = $(Get-Content "$SML_DIR/Mods/$MOD_NAME/VERSION")' + - '$Version="$($UPlugin.SemVersion)"' + - "($UPlugin | convertto-json -Depth 100) -replace '\\u0026', '&' | Set-Content $SML_DIR/Mods/$MOD_NAME/$MOD_NAME.uplugin" + - 'Write-Host "Building $MOD_NAME $($Version)"' + - '& "$ENGINE_DIR/Engine/Build/BatchFiles/RunUAT.bat" -ScriptsForProject="$SML_DIR/FactoryGame.uproject" PackagePlugin -Project="$SML_DIR/FactoryGame.uproject" -dlcname="$MOD_NAME" -build -server -clientconfig=Shipping -serverconfig=Shipping -platform=Win64 -serverplatform=Win64+Linux -nocompileeditor -installed -merge' + - 'Copy-Item "$SML_DIR/Saved/ArchivedPlugins/$MOD_NAME/$MOD_NAME.zip" "$BUILT_MODS_DIR/$MOD_NAME.$Version.zip" -Force' + artifacts: + paths: + - ./BuiltMods/*.zip + expire_in: 1 month + +deploy-live: + stage: deploy + script: + - 'cd "$CI_PROJECT_DIR"' + - '$File = (Get-ChildItem "./BuiltMods/$MOD_NAME*").FullName' + - '$APIURL="https://api.ficsit.app"' + - '& "E:/SF/Scripts/ficsit_windows_amd64.exe" smr upload --api-base $APIURL --api-key $FICSIT_TOKEN "$MOD_ID" "$File" "$CHANGELOG"' + when: manual diff --git a/.gitlab-ci.yml.old b/.gitlab-ci.yml.old new file mode 100644 index 0000000..dd94ec0 --- /dev/null +++ b/.gitlab-ci.yml.old @@ -0,0 +1,73 @@ +workflow: + rules: + - when: always + + +variables: + GIT_STRATEGY: none + GIT_CHECKOUT: "false" + ErrorActionPreference: STOP + + # Unreal Engine 4 Project Settings + MOD_NAME: "RefinedRDLib" + MOD_VERSION: "1.0.18" + GIT_TEST_DEBUG_UNSAFE_DIRECTORIES: "true" + +stages: + - setupenv + - compile + - package + - deploy + +setup_env: + stage: setupenv + script: + - "C:\\BuildScripts\\SF\\01-SetupEnv.ps1" + +setup_plugins: + stage: setupenv + script: + - "C:\\BuildScripts\\SF\\02-SetupPlugins.ps1" + +compile-dev: + variables: + BuildConfig: "Development Editor" + BuildPlatform: "Win64" + stage: compile + script: + - "C:\\BuildScripts\\SF\\03-CompileMod.ps1" + +compile-client: + variables: + BuildConfig: "Shipping" + BuildPlatform: "Win64" + stage: compile + script: + - "C:\\BuildScripts\\SF\\03-CompileMod.ps1" + +compile-winserver: + variables: + BuildConfig: "Shipping Server" + BuildPlatform: "Win64" + stage: compile + script: + - "C:\\BuildScripts\\SF\\03-CompileMod.ps1" + +compile-linuxserver: + variables: + BuildConfig: "Shipping Server" + BuildPlatform: "Linux" + stage: compile + script: + - "C:\\BuildScripts\\SF\\03-CompileMod.ps1" + +package: + stage: package + script: + - "C:\\BuildScripts\\SF\\04-PackageMod.ps1" + +deploy-live: + stage: deploy + script: + - "C:\\BuildScripts\\SF\\06-DeployLive.ps1" + when: manual \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9d942f2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,85 @@ +## 1.1.18 (April 15, 2024) + - feat: New config management subsystem + - feat: Updated Icon generation code + +## 1.1.17 (March 17, 2024) + - fix: More fixes to sound manager + - fix: Fixes to config manager + - ci: Gitea Workflow + - chore: Update uplugin + +## 1.1.16 (March 07, 2024) + - fix: Fixed infinite loop crash + +## 1.1.15 (February 27, 2024) + - fix: Fixed major bug with Item storage functions + - fix: Fixed config delegates + +## 1.1.14 (February 20, 2024) + - feat: Mod Icons + - feat: Updated fonts + - feat: remove check + - fix: Fixed slot size is 0 + - feat: New icon descriptors + +## 1.1.13 (January 18, 2024) + - feat: Serverside hologram replication + +## 1.1.12 (January 13, 2024) + - fix: More attempts to fix Modular buildings + +## 1.1.11 (January 13, 2024) + - fix: Hopefully fixes the FF platform issues + +## 1.1.10 (January 12, 2024) + - feat: Debug for modular buildings + +## 1.1.9 (January 09, 2024) + - feat: Updated http response validation + - feat: Accessors for http component + +## 1.1.8 (January 07, 2024) + - ci: Updates to build pipeline + - fix: Compile Errors for linux build + - ci: Bump SML Version + - Merge branch 'ue5' of git.hostxtra.co.uk:refined-rd/sf_mod_refinedrdlib into ue5 + - fix(sub-level-subsystem): clear level refs on deinitialize since is cause some weired issues + +## 1.1.7 (December 05, 2023) + - ci: Updated Pipeline + - feat: Updated SML Version + +## 1.1.6 (November 28, 2023) + - feat: updated Icons + - feat: New Icon creation system + - fix: ensure modular building can place if the build effect is finished or not played + +## 1.1.5 (November 21, 2023) + - fix(patreon): fix patreon content registry + - ci: Fix mod id for upload + - feat: Updated IconMap + +## 1.1.4 (November 17, 2023) + - fix: More fixes for resource wells + - fix: More fixes for resource wells + - fix: Fixed resource well descriptor loading + - bump version + +## 1.1.3 (November 15, 2023) + + +## 1.1.2 (November 15, 2023) + - ci: Updated pipeline + - fix: Fixes to Sublevel Spawning + - ci: Update UE + - fix: Removed sub level spawning configs + - fix: Removal of sub level spawning + - feat: Removal of Sub level spawning + - feat: Icon map updates + - feat: Updated Icon Map + - ci: Moved token to gitlab vars + - ci: Added Depoy Stage + +## 1.1.1 (October 13, 2023) + + diff --git a/Config/AccessTransformers.ini b/Config/AccessTransformers.ini new file mode 100644 index 0000000..99e638a --- /dev/null +++ b/Config/AccessTransformers.ini @@ -0,0 +1 @@ +[AccessTransformers] \ No newline at end of file diff --git a/Config/Alpakit.ini b/Config/Alpakit.ini new file mode 100644 index 0000000..5d52841 --- /dev/null +++ b/Config/Alpakit.ini @@ -0,0 +1,4 @@ +[ModTargets] +Targets=Windows +Targets=WindowsServer + diff --git a/Config/DefaultGame.ini b/Config/DefaultGame.ini new file mode 100644 index 0000000..3db982d --- /dev/null +++ b/Config/DefaultGame.ini @@ -0,0 +1,2 @@ +[/Script/Engine.AssetManagerSettings] ++PrimaryAssetTypesToScan=(PrimaryAssetType="RRDADataAsset",AssetBaseClass="/Script/RefinedRDApi.RRDADataAssetBase",bHasBlueprintClasses=True,bIsEditorOnly=False,Directories=((Path="/")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=AlwaysCook)) diff --git a/Config/Engine.ini b/Config/Engine.ini new file mode 100644 index 0000000..87de056 --- /dev/null +++ b/Config/Engine.ini @@ -0,0 +1,2 @@ +[AssetManagerSettings] ++PrimaryAssetTypesToScan=(PrimaryAssetType="RRDADataAsset",AssetBaseClass="/Script/RefinedRDApi.RRDADataAssetBase",bHasBlueprintClasses=True,bIsEditorOnly=False,Directories=((Path="/")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=AlwaysCook)) diff --git a/Config/Game.ini b/Config/Game.ini new file mode 100644 index 0000000..3db982d --- /dev/null +++ b/Config/Game.ini @@ -0,0 +1,2 @@ +[/Script/Engine.AssetManagerSettings] ++PrimaryAssetTypesToScan=(PrimaryAssetType="RRDADataAsset",AssetBaseClass="/Script/RefinedRDApi.RRDADataAssetBase",bHasBlueprintClasses=True,bIsEditorOnly=False,Directories=((Path="/")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=AlwaysCook)) diff --git a/Config/PluginSettings.ini b/Config/PluginSettings.ini new file mode 100644 index 0000000..13b0331 --- /dev/null +++ b/Config/PluginSettings.ini @@ -0,0 +1,3 @@ +[StageSettings] ++AdditionalNonUSFDirectories=Resources ++AdditionalNonUSFDirectories=Config \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9f634c6 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# SF_Mod_ModularUI diff --git a/RefinedRDApi.uplugin b/RefinedRDApi.uplugin new file mode 100644 index 0000000..c9d6a2e --- /dev/null +++ b/RefinedRDApi.uplugin @@ -0,0 +1,33 @@ +{ + "FileVersion": 3, + "Version": 1, + "VersionName": "1.0.0", + "SemVersion": "1.0.0", + "FriendlyName": "Refined R&D Api", + "Description": "This Lib can be used to create Mod Compatability with Refined R&D Mods", + "Category": "Modding", + "CreatedBy": "Refined R&D", + "CreatedByURL": "https://github.com/mrhid6", + "DocsURL": "https://docs.ficsit.app", + "MarketplaceURL": "", + "SupportURL": "", + "CanContainContent": true, + "IsBetaVersion": false, + "IsExperimentalVersion": false, + "Installed": true, + "Modules": [ + { + "Name": "RefinedRDApi", + "Type": "Runtime", + "LoadingPhase": "PostDefault" + } + ], + "Plugins": [ + { + "Name": "SML", + "Enabled": true, + "SemVersion": "^3.8.0" + } + ], + "GameVersion": ">=365306" +} \ No newline at end of file diff --git a/Resources/Icon128.png b/Resources/Icon128.png new file mode 100644 index 0000000..4d61e2c Binary files /dev/null and b/Resources/Icon128.png differ diff --git a/Source/RefinedRDApi/Private/DataAssets/RRDABoilerDataAsset.cpp b/Source/RefinedRDApi/Private/DataAssets/RRDABoilerDataAsset.cpp new file mode 100644 index 0000000..236c461 --- /dev/null +++ b/Source/RefinedRDApi/Private/DataAssets/RRDABoilerDataAsset.cpp @@ -0,0 +1,3 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#include "DataAssets/RRDABoilerDataAsset.h" \ No newline at end of file diff --git a/Source/RefinedRDApi/Private/DataAssets/RRDACoolerDataAsset.cpp b/Source/RefinedRDApi/Private/DataAssets/RRDACoolerDataAsset.cpp new file mode 100644 index 0000000..5b09b83 --- /dev/null +++ b/Source/RefinedRDApi/Private/DataAssets/RRDACoolerDataAsset.cpp @@ -0,0 +1,3 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#include "DataAssets/RRDACoolerDataAsset.h" \ No newline at end of file diff --git a/Source/RefinedRDApi/Private/DataAssets/RRDADirtDataAsset.cpp b/Source/RefinedRDApi/Private/DataAssets/RRDADirtDataAsset.cpp new file mode 100644 index 0000000..b044acc --- /dev/null +++ b/Source/RefinedRDApi/Private/DataAssets/RRDADirtDataAsset.cpp @@ -0,0 +1,30 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#include "DataAssets/RRDADirtDataAsset.h" + +#include "RefinedRDApi.h" + +TArray URRDADirtDataAsset::GetExtractableSeed(URRDADirtDataAsset* Asset) +{ + if(!Asset) + { + return TArray(); + } + return Asset->mExtractableSeed; +} + +float URRDADirtDataAsset::GetExtractionCycleTime(URRDADirtDataAsset* Asset) { + if(!Asset) + { + return 0.f; + } + return Asset->mExtractionCycleTime; +} + +int32 URRDADirtDataAsset::GetDirtConsume(URRDADirtDataAsset* Asset) { + if(!Asset) + { + return 0; + } + return Asset->mDirtConsume; +} \ No newline at end of file diff --git a/Source/RefinedRDApi/Private/DataAssets/RRDAHeaterDataAsset.cpp b/Source/RefinedRDApi/Private/DataAssets/RRDAHeaterDataAsset.cpp new file mode 100644 index 0000000..1867a66 --- /dev/null +++ b/Source/RefinedRDApi/Private/DataAssets/RRDAHeaterDataAsset.cpp @@ -0,0 +1,3 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#include "DataAssets/RRDAHeaterDataAsset.h" \ No newline at end of file diff --git a/Source/RefinedRDApi/Private/DataAssets/RRDATurbineDataAsset.cpp b/Source/RefinedRDApi/Private/DataAssets/RRDATurbineDataAsset.cpp new file mode 100644 index 0000000..5ce1b30 --- /dev/null +++ b/Source/RefinedRDApi/Private/DataAssets/RRDATurbineDataAsset.cpp @@ -0,0 +1,3 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#include "DataAssets/RRDATurbineDataAsset.h" \ No newline at end of file diff --git a/Source/RefinedRDApi/Private/RefinedRDApi.cpp b/Source/RefinedRDApi/Private/RefinedRDApi.cpp new file mode 100644 index 0000000..7ef8aea --- /dev/null +++ b/Source/RefinedRDApi/Private/RefinedRDApi.cpp @@ -0,0 +1,14 @@ +#include "RefinedRDApi.h" + +DEFINE_LOG_CATEGORY(LogRRDApi); + + +void FRefinedRDApiModule::StartupModule() { + // Nothing here... yet +} + +void FRefinedRDApiModule::ShutdownModule() { + // Nothing here... yet +} + +IMPLEMENT_MODULE(FRefinedRDApiModule, RefinedRDApi); diff --git a/Source/RefinedRDApi/Private/Structs/.gitkeep b/Source/RefinedRDApi/Private/Structs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Source/RefinedRDApi/Private/Subsystems/RRDADataAssetSubsystem.cpp b/Source/RefinedRDApi/Private/Subsystems/RRDADataAssetSubsystem.cpp new file mode 100644 index 0000000..819965c --- /dev/null +++ b/Source/RefinedRDApi/Private/Subsystems/RRDADataAssetSubsystem.cpp @@ -0,0 +1,93 @@ +#include "Subsystems/RRDADataAssetSubsystem.h" + +#include "RefinedRDApi.h" +#include "DataAssets/RRDADirtDataAsset.h" +#include "Engine/AssetManager.h" + +URRDADataAssetSubsystem::URRDADataAssetSubsystem() {} + +URRDADataAssetSubsystem* URRDADataAssetSubsystem::Get(UObject* Context) +{ + if (IsValid(Context)) + { + return Context->GetWorld()->GetSubsystem(); + } + return nullptr; +} + +URRDADataAssetSubsystem* URRDADataAssetSubsystem::GetChecked(UObject* Context) +{ + URRDADataAssetSubsystem* Subsystem = Get(Context); + fgcheck(Subsystem); + return Subsystem; +} + +void URRDADataAssetSubsystem::Initialize(FSubsystemCollectionBase& Collection) +{ + Super::Initialize(Collection); + + StartScanForDataAssets(); +} + +void URRDADataAssetSubsystem::Deinitialize() +{ + Super::Deinitialize(); +} + +void URRDADataAssetSubsystem::StartScanForDataAssets() +{ + UAssetManager& Manager = UAssetManager::Get(); + Manager.LoadPrimaryAssetsWithType(FPrimaryAssetType("RRDADataAsset")); + + mDisabledDataAssets.Empty(); + mAllDataAssets.Empty(); + + ReCacheBoilerDataAssets(); + ReCacheCoolerDataAssets(); + ReCacheDirtDataAssets(); + ReCacheHeaterDataAssets(); + ReCacheTurbineDataAssets(); +} + +void URRDADataAssetSubsystem::ReCacheDirtDataAssets() +{ + mDirtAssets.Empty(); + TSet DirtDataAssets; + if(FindAllDataAssetsOfClass(DirtDataAssets)) + { + for (URRDADirtDataAsset* DirtDataAsset : DirtDataAssets) + { + mDirtAssets.Add(DirtDataAsset->mItem, DirtDataAsset); + } + } + UE_LOG(LogRRDApi, Log, TEXT("ReCacheDirtDataAssets: %d"), mDirtAssets.Num()); +} + +void URRDADataAssetSubsystem::ReCacheTurbineDataAssets() +{ + UE_LOG(LogRRDApi, Log, TEXT("ReCacheTurbineDataAssets")); +} + +void URRDADataAssetSubsystem::ReCacheBoilerDataAssets() { + UE_LOG(LogRRDApi, Log, TEXT("ReCacheBoilerDataAssets")); +} + +void URRDADataAssetSubsystem::ReCacheCoolerDataAssets() { + UE_LOG(LogRRDApi, Log, TEXT("ReCacheCoolerDataAssets")); +} + +void URRDADataAssetSubsystem::ReCacheHeaterDataAssets() { + UE_LOG(LogRRDApi, Log, TEXT("ReCacheHeaterDataAssets")); +} + +int32 URRDADataAssetSubsystem::GetAllDirtItems(TArray>& Items) const +{ + return mDirtAssets.GetKeys(Items); +} + +URRDADirtDataAsset* URRDADataAssetSubsystem::GetDataForDirtItem(TSubclassOf Item) const +{ + if(!Item) return nullptr; + return *mDirtAssets.Find(Item); +} + diff --git a/Source/RefinedRDApi/Public/DataAssets/RRDABoilerDataAsset.h b/Source/RefinedRDApi/Public/DataAssets/RRDABoilerDataAsset.h new file mode 100644 index 0000000..8b7673a --- /dev/null +++ b/Source/RefinedRDApi/Public/DataAssets/RRDABoilerDataAsset.h @@ -0,0 +1,28 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "RRDADataAssetBase.h" +#include "ItemAmount.h" + +#include "RRDABoilerDataAsset.generated.h" + +UCLASS( BlueprintType ) +class REFINEDRDAPI_API URRDABoilerDataAsset : public URRDADataAssetBase +{ + GENERATED_BODY() + +public: + /** + * Fuel item that this heater uses + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Boiler") + FItemAmount mItem; + + /** + * What this boiler produces + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Boiler") + FItemAmount mOutputItem; +}; \ No newline at end of file diff --git a/Source/RefinedRDApi/Public/DataAssets/RRDACoolerDataAsset.h b/Source/RefinedRDApi/Public/DataAssets/RRDACoolerDataAsset.h new file mode 100644 index 0000000..ae02739 --- /dev/null +++ b/Source/RefinedRDApi/Public/DataAssets/RRDACoolerDataAsset.h @@ -0,0 +1,22 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "ItemAmount.h" +#include "RRDADataAssetBase.h" + +#include "RRDACoolerDataAsset.generated.h" + +UCLASS( BlueprintType ) +class REFINEDRDAPI_API URRDACoolerDataAsset : public URRDADataAssetBase +{ + GENERATED_BODY() + +public: + /** + * Fuel item that this heater uses + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cooler") + FItemAmount mItem; +}; \ No newline at end of file diff --git a/Source/RefinedRDApi/Public/DataAssets/RRDADataAssetBase.h b/Source/RefinedRDApi/Public/DataAssets/RRDADataAssetBase.h new file mode 100644 index 0000000..dcb8f6b --- /dev/null +++ b/Source/RefinedRDApi/Public/DataAssets/RRDADataAssetBase.h @@ -0,0 +1,42 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" + +#include "RRDADataAssetBase.generated.h" + +UCLASS( BlueprintType ) +class REFINEDRDAPI_API URRDADataAssetBase : public UPrimaryDataAsset +{ + GENERATED_BODY() + +protected: + /** + * Can be overridden to disable the asset or make some other checks + */ + virtual bool IsEnabled_Internal(UObject* WorldContextObject) const + { + return !mIsDisabled; + } + + virtual FPrimaryAssetId GetPrimaryAssetId() const override + { + return FPrimaryAssetId(FPrimaryAssetType("RRDADataAsset"), GetFName()); + } + +public: + UFUNCTION( BlueprintPure, Category="FicsitFarming|Dirt" ) + static bool IsEnabled(URRDADataAssetBase* Asset, UObject* WorldContextObject) + { + if(!Asset) return false; + return Asset->IsEnabled_Internal(WorldContextObject); + }; + + /** + * Disable this asset from being used in the game + * For example if a mod is disabling some content from another mod + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Asset") + bool mIsDisabled; +}; \ No newline at end of file diff --git a/Source/RefinedRDApi/Public/DataAssets/RRDADirtDataAsset.h b/Source/RefinedRDApi/Public/DataAssets/RRDADirtDataAsset.h new file mode 100644 index 0000000..94a2799 --- /dev/null +++ b/Source/RefinedRDApi/Public/DataAssets/RRDADirtDataAsset.h @@ -0,0 +1,51 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "RRDADataAssetBase.h" +#include "ItemAmount.h" + +#include "RRDADirtDataAsset.generated.h" + +UCLASS( BlueprintType ) +class REFINEDRDAPI_API URRDADirtDataAsset : public URRDADataAssetBase +{ + GENERATED_BODY() + +public: + UFUNCTION( BlueprintPure, Category="FicsitFarming|Dirt" ) + static TArray GetExtractableSeed(URRDADirtDataAsset* Asset); + + UFUNCTION( BlueprintPure, Category="FicsitFarming|Dirt" ) + static float GetExtractionCycleTime(URRDADirtDataAsset* Asset); + + UFUNCTION( BlueprintPure, Category="FicsitFarming|Dirt" ) + static int32 GetDirtConsume(URRDADirtDataAsset* Asset); + +public: + /** + * What Item should be a Dirt? + * @warning - If 2 DirtDataAssets have the same Item, the game will use the last one which was loaded + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FicsitFarming") + TSubclassOf mItem; + + /** + * Seeds that can be extracted from this dirt every cycle + */ + UPROPERTY( EditAnywhere, BlueprintReadWrite, Category="FicsitFarming" ) + TArray mExtractableSeed; + + /** + * Production time for the extraction of seeds + */ + UPROPERTY( EditAnywhere, BlueprintReadWrite, Category="FicsitFarming" ) + float mExtractionCycleTime = 6.0f; + + /** + * How much dirt should be consumed? + */ + UPROPERTY( EditAnywhere, BlueprintReadWrite, Category="FicsitFarming" ) + int32 mDirtConsume = 2; +}; \ No newline at end of file diff --git a/Source/RefinedRDApi/Public/DataAssets/RRDAHeaterDataAsset.h b/Source/RefinedRDApi/Public/DataAssets/RRDAHeaterDataAsset.h new file mode 100644 index 0000000..d565c3f --- /dev/null +++ b/Source/RefinedRDApi/Public/DataAssets/RRDAHeaterDataAsset.h @@ -0,0 +1,36 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "RRDADataAssetBase.h" +#include "ItemAmount.h" +#include "Enums/RRDARPEnums.h" + +#include "RRDAHeaterDataAsset.generated.h" + +UCLASS( BlueprintType ) +class REFINEDRDAPI_API URRDAHeaterDataAsset : public URRDADataAssetBase +{ + GENERATED_BODY() + +public: + /** + * What type of heater this is + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Heater") + ERRDAHeaterType mHeaterType; + + /** + * Fuel item that this heater uses + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Heater") + FItemAmount mInput; + + /** + * Item that this turbine produces + * @Note - Can be nullptr + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Heater") + FItemAmount mOutput; +}; \ No newline at end of file diff --git a/Source/RefinedRDApi/Public/DataAssets/RRDATurbineDataAsset.h b/Source/RefinedRDApi/Public/DataAssets/RRDATurbineDataAsset.h new file mode 100644 index 0000000..38ef9c6 --- /dev/null +++ b/Source/RefinedRDApi/Public/DataAssets/RRDATurbineDataAsset.h @@ -0,0 +1,29 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "RRDADataAssetBase.h" +#include "ItemAmount.h" + +#include "RRDATurbineDataAsset.generated.h" + +UCLASS( BlueprintType ) +class REFINEDRDAPI_API URRDATurbineDataAsset : public URRDADataAssetBase +{ + GENERATED_BODY() + +public: + /** + * Fuel item that this heater uses + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Turbine") + FItemAmount mItem; + + /** + * Item that this turbine produces + * @Note - Can be nullptr so that the turbine doesn't produce anything + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Turbine") + FItemAmount mWasteItem; +}; \ No newline at end of file diff --git a/Source/RefinedRDApi/Public/Enums/RRDARPEnums.h b/Source/RefinedRDApi/Public/Enums/RRDARPEnums.h new file mode 100644 index 0000000..5500bd6 --- /dev/null +++ b/Source/RefinedRDApi/Public/Enums/RRDARPEnums.h @@ -0,0 +1,19 @@ +#pragma once + +#include "CoreMinimal.h" + +UENUM(BlueprintType) +enum class ERRDAHeaterType : uint8 +{ + Biomass, + Coal, + Solution, + Nuclear +}; + +UENUM(BlueprintType) +enum class ERRDACoolerType : uint8 +{ + Chemical, + Steam +}; \ No newline at end of file diff --git a/Source/RefinedRDApi/Public/RefinedRDApi.h b/Source/RefinedRDApi/Public/RefinedRDApi.h new file mode 100644 index 0000000..5c6b9cd --- /dev/null +++ b/Source/RefinedRDApi/Public/RefinedRDApi.h @@ -0,0 +1,11 @@ +#pragma once + +DECLARE_LOG_CATEGORY_EXTERN(LogRRDApi, Log, All) + +class FRefinedRDApiModule : public IModuleInterface +{ +public: + /** IModuleInterface implementation */ + virtual void StartupModule() override; + virtual void ShutdownModule() override; +}; \ No newline at end of file diff --git a/Source/RefinedRDApi/Public/Structs/.gitkeep b/Source/RefinedRDApi/Public/Structs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Source/RefinedRDApi/Public/Subsystems/RRDADataAssetSubsystem.h b/Source/RefinedRDApi/Public/Subsystems/RRDADataAssetSubsystem.h new file mode 100644 index 0000000..a7d75ed --- /dev/null +++ b/Source/RefinedRDApi/Public/Subsystems/RRDADataAssetSubsystem.h @@ -0,0 +1,132 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "RefinedRDApi.h" +#include "AssetRegistry/AssetRegistryModule.h" +#include "DataAssets/RRDADataAssetBase.h" +#include "DataAssets/RRDADirtDataAsset.h" +#include "Engine/AssetManager.h" +#include "Enums/RRDARPEnums.h" +#include "Resources/FGItemDescriptor.h" + +#include "RRDADataAssetSubsystem.generated.h" + +class IAssetRegistry; + +UCLASS() +class REFINEDRDAPI_API URRDADataAssetSubsystem : public UWorldSubsystem +{ + GENERATED_BODY() + +public: + URRDADataAssetSubsystem(); + + static URRDADataAssetSubsystem* Get(UObject* Context); + static URRDADataAssetSubsystem* GetChecked(UObject* Context); + + /** Implement this for initialization of instances of the system */ + virtual void Initialize(FSubsystemCollectionBase& Collection) override; + + virtual void Deinitialize() override; + + /** + * Note: call this function only in the constructor of the subsystem OR if you change some mDisabled value in runtime to refresh cached data + */ + UFUNCTION(BlueprintCallable, Category = "RRDA|DataAsset") + void StartScanForDataAssets(); + + void ReCacheDirtDataAssets(); + void ReCacheTurbineDataAssets(); + void ReCacheBoilerDataAssets(); + void ReCacheCoolerDataAssets(); + void ReCacheHeaterDataAssets(); + +public: + UFUNCTION(BlueprintPure, Category = "RRDA|DataAsset|FF") + int32 GetAllDirtItems(TArray>& Items) const; + + UFUNCTION(BlueprintCallable, Category = "RRDA|DataAsset|FF") + URRDADirtDataAsset* GetDataForDirtItem(TSubclassOf Item) const; + +public: + /** + * Find all data assets of a specific class + * @param OutDataAssets - Set of data assets + * @return true if found any data assets + */ + template + bool FindAllDataAssetsOfClass(TSet& OutDataAssets); + +private: + UPROPERTY() + TMap, class URRDADirtDataAsset*> mDirtAssets; + + TMap, class URRDATurbineDataAsset*>> mTurbineAssets; + TMap, class URRDABoilerDataAsset*>> mBoilerAssets; + TMap, class URRDACoolerDataAsset*>> mCoolerAssets; + TMap, class URRDAHeaterDataAsset*>> mHeaterAssets; + +public: + UPROPERTY(BlueprintReadOnly, Transient, Category = "RRDA|DataAsset") + TSet mDisabledDataAssets; + + UPROPERTY(BlueprintReadOnly, Transient, Category = "RRDA|DataAsset") + TSet mAllDataAssets; +}; + +template +bool URRDADataAssetSubsystem::FindAllDataAssetsOfClass(TSet& OutDataAssets) +{ + OutDataAssets.Empty(); + + // This doesn't work the AssetDatas are always invalid + /*UAssetManager& Manager = UAssetManager::Get(); + + TArray AssetDatas; + Manager.GetPrimaryAssetDataList(FPrimaryAssetType("RRDADataAsset"), AssetDatas); + + for (FAssetData AssetData : AssetDatas) + { + if(AssetData.IsValid()) + { + if(URRDADataAssetBase* Asset = Cast(AssetData.GetAsset())) + { + if(!URRDADataAssetBase::IsEnabled(Asset, GetWorld())) + { + UE_LOG(LogRRDApi, Error, TEXT("Asset Disabled: %s"), *AssetData.AssetName.ToString()); + continue; + } + + OutDataAssets.Add(Cast(Asset)); + UE_LOG(LogRRDApi, Log, TEXT("Found %s"), *AssetData.GetAsset()->GetPathName()); + } + } else + { + UE_LOG(LogRRDApi, Error, TEXT("Invalid AssetData: %s"), *AssetData.AssetName.ToString()); + return false; + } + }*/ + + TArray FoundClasses; + GetDerivedClasses(T::StaticClass(), FoundClasses, true); + + for (UClass* FoundClass : FoundClasses) + { + if(FoundClass->IsNative()) continue; + + if(URRDADataAssetBase* Asset = FoundClass->GetDefaultObject()) + { + if(!URRDADataAssetBase::IsEnabled(Asset, GetWorld())) + { + UE_LOG(LogRRDApi, Error, TEXT("Asset Disabled: %s"), *FoundClass->GetPathName()); + continue; + } + OutDataAssets.Add(FoundClass->GetDefaultObject()); + UE_LOG(LogRRDApi, Log, TEXT("Found %s"), *FoundClass->GetPathName()); + } + } + + return OutDataAssets.Num() > 0; +} diff --git a/Source/RefinedRDApi/RefinedRDApi.Build.cs b/Source/RefinedRDApi/RefinedRDApi.Build.cs new file mode 100644 index 0000000..607dba9 --- /dev/null +++ b/Source/RefinedRDApi/RefinedRDApi.Build.cs @@ -0,0 +1,65 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +using UnrealBuildTool; + +public class RefinedRDApi : ModuleRules +{ + public RefinedRDApi(ReadOnlyTargetRules Target) : base(Target) + { + CppStandard = CppStandardVersion.Cpp20; + PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; + bLegacyPublicIncludePaths = false; + + PublicDependencyModuleNames.AddRange( + new[] + { + "Json", + "Core", + "CoreUObject", + "Engine", + "DeveloperSettings", + "PhysicsCore", + "InputCore", + "OnlineSubsystem", "OnlineSubsystemNull", "OnlineSubsystemUtils", + "SignificanceManager", + "GeometryCollectionEngine", + "ChaosVehiclesCore", "ChaosVehicles", "ChaosSolverEngine", + "AnimGraphRuntime", + "AkAudio", "HTTP", + "AssetRegistry", + "NavigationSystem", + "ReplicationGraph", + "AIModule", + "GameplayTasks", + "SlateCore", "Slate", "UMG", + "RenderCore", + "CinematicCamera", + "Foliage", + "Niagara", + "EnhancedInput", + "GameplayCameras", + "TemplateSequence", + "NetCore", + "GameplayTags" + }); + + // FactoryGame plugins + PublicDependencyModuleNames.AddRange(new[] + { + "AbstractInstance", + "InstancedSplinesComponent", + "SignificanceISPC" + }); + + // Header stubs + PublicDependencyModuleNames.AddRange(new[] + { + "DummyHeaders" + }); + + if (Target.Type == TargetRules.TargetType.Editor) + PublicDependencyModuleNames.AddRange(new[] { "OnlineBlueprintSupport", "AnimGraph" }); + + PublicDependencyModuleNames.AddRange(new[] { "FactoryGame", "SML" }); + } +} \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..b0c8928 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.1.18 \ No newline at end of file diff --git a/bump.sh b/bump.sh new file mode 100644 index 0000000..2282a7f --- /dev/null +++ b/bump.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +# Thanks goes to @pete-otaqui for the initial gist: +# https://gist.github.com/pete-otaqui/4188238 +# +# Original version modified by Marek Suscak +# +# works with a file called VERSION in the current directory, +# the contents of which should be a semantic version number +# such as "1.2.3" or even "1.2.3-beta+001.ab" + +# this script will display the current version, automatically +# suggest a "minor" version update, and ask for input to use +# the suggestion, or a newly entered value. + +# once the new version number is determined, the script will +# pull a list of changes from git history, prepend this to +# a file called CHANGELOG.md (under the title of the new version +# number), give user a chance to review and update the changelist +# manually if needed and create a GIT tag. + +NOW="$(date +'%B %d, %Y')" +RED="\033[1;31m" +GREEN="\033[0;32m" +YELLOW="\033[1;33m" +BLUE="\033[1;34m" +PURPLE="\033[1;35m" +CYAN="\033[1;36m" +WHITE="\033[1;37m" +RESET="\033[0m" + +LATEST_HASH=$(git log --pretty=format:'%h' -n 1) + +QUESTION_FLAG="${GREEN}?" +WARNING_FLAG="${YELLOW}!" +NOTICE_FLAG="${CYAN}❯" + +ADJUSTMENTS_MSG="${QUESTION_FLAG} ${CYAN}Now you can make adjustments to ${WHITE}CHANGELOG.md${CYAN}. Then press enter to continue.${RESET}" +PUSHING_MSG="${NOTICE_FLAG} Pushing new version to the ${WHITE}origin${CYAN}...${RESET}" + +if [ -f VERSION ]; then + BASE_STRING=$(cat VERSION) + BASE_LIST=($(echo $BASE_STRING | tr '.' ' ')) + V_MAJOR=${BASE_LIST[0]} + V_MINOR=${BASE_LIST[1]} + V_PATCH=${BASE_LIST[2]} + echo -e "${NOTICE_FLAG} Current version: ${WHITE}$BASE_STRING${RESET}" + echo -e "${NOTICE_FLAG} Latest commit hash: ${WHITE}$LATEST_HASH${RESET}" + V_PATCH=$((V_PATCH + 1)) + SUGGESTED_VERSION="$V_MAJOR.$V_MINOR.$V_PATCH" + echo -ne "${QUESTION_FLAG} ${CYAN}Enter a version number [${WHITE}$SUGGESTED_VERSION${CYAN}]:${RESET} " + read INPUT_STRING + if [ "$INPUT_STRING" = "" ]; then + INPUT_STRING=$SUGGESTED_VERSION + fi + echo -e "${NOTICE_FLAG} Will set new version to be ${WHITE}$INPUT_STRING${RESET}" + echo -en $INPUT_STRING >VERSION + echo "## $INPUT_STRING ($NOW)" >tmpfile + git log --pretty=format:" - %s" "v$BASE_STRING"...HEAD >>tmpfile + echo "" >>tmpfile + echo "" >>tmpfile + cat CHANGELOG.md >>tmpfile + mv tmpfile CHANGELOG.md + echo -e "$ADJUSTMENTS_MSG" + read + echo -e "$PUSHING_MSG" + git add CHANGELOG.md VERSION + git commit -m "Bump version to ${INPUT_STRING}." + git push + git tag -a -m "Tag version ${INPUT_STRING}." "v$INPUT_STRING" + git push origin --tags +else + echo -e "${WARNING_FLAG} Could not find a VERSION file.${RESET}" + echo -ne "${QUESTION_FLAG} ${CYAN}Do you want to create a version file and start from scratch? [${WHITE}y${CYAN}]:${RESET} " + read RESPONSE + if [ "$RESPONSE" = "" ]; then RESPONSE="y"; fi + if [ "$RESPONSE" = "Y" ]; then RESPONSE="y"; fi + if [ "$RESPONSE" = "Yes" ]; then RESPONSE="y"; fi + if [ "$RESPONSE" = "yes" ]; then RESPONSE="y"; fi + if [ "$RESPONSE" = "YES" ]; then RESPONSE="y"; fi + if [ "$RESPONSE" = "y" ]; then + echo -en "1.0.0" >VERSION + echo "## 1.0.0 ($NOW)" >CHANGELOG.md + git log --pretty=format:" - %s" >>CHANGELOG.md + echo "" >>CHANGELOG.md + echo "" >>CHANGELOG.md + echo -e "$ADJUSTMENTS_MSG" + read + echo -e "$PUSHING_MSG" + git add VERSION CHANGELOG.md + git commit -m "Add VERSION and CHANGELOG.md files, Bump version to v1.0.0." + git push + git tag -a -m "Tag version 1.0.0." "v1.0.0" + git push origin --tags + fi +fi + +echo -e "${NOTICE_FLAG} Finished.${RESET}"