From fbad77acc1289702c9997686e45bba4104acdf19 Mon Sep 17 00:00:00 2001 From: siimav Date: Sun, 25 Jun 2023 23:56:10 +0300 Subject: [PATCH 1/3] Properly enforce NoStdLib --- Source/ProceduralFairings/ProceduralFairings.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/ProceduralFairings/ProceduralFairings.csproj b/Source/ProceduralFairings/ProceduralFairings.csproj index 8440e53..b0c415f 100644 --- a/Source/ProceduralFairings/ProceduralFairings.csproj +++ b/Source/ProceduralFairings/ProceduralFairings.csproj @@ -8,6 +8,7 @@ ProceduralFairings ProceduralFairings v4.7.2 + true OnBuildSuccess False ..\Builds\$(Configuration)\ @@ -65,6 +66,7 @@ + From b12de50a32462c2af6602898d93db6148d5625bc Mon Sep 17 00:00:00 2001 From: ryanc55 <54254625+ryanc55@users.noreply.github.com> Date: Fri, 28 Jul 2023 16:25:07 -0700 Subject: [PATCH 2/3] Add Petal Option to Fairing Sides (#47) Add petal hinge option to fairing sides Add hinge transform to fairing model Add cost and weight multipliers for hinge Support custom hinge opening from 0-90 degrees Remove Stray Comment Halve the speed of petal animation 0-90 degrees now takes 8 seconds --- GameData/ProceduralFairings/Assets/fairing.mu | Bin 3534 -> 6386 bytes .../Parts/Payload/fairing_sides.cfg | 16 ++- Source/ProceduralFairings/FairingSide.cs | 107 +++++++++++++++--- 3 files changed, 109 insertions(+), 14 deletions(-) diff --git a/GameData/ProceduralFairings/Assets/fairing.mu b/GameData/ProceduralFairings/Assets/fairing.mu index 0cff8456ba30b409b3adc045a99cabebb051216a..5e9e05e83b990a23ffafe7c6f3157aaee0f0c279 100644 GIT binary patch literal 6386 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 diff --git a/GameData/ProceduralFairings/Parts/Payload/fairing_sides.cfg b/GameData/ProceduralFairings/Parts/Payload/fairing_sides.cfg index f0db86a..12aefc3 100644 --- a/GameData/ProceduralFairings/Parts/Payload/fairing_sides.cfg +++ b/GameData/ProceduralFairings/Parts/Payload/fairing_sides.cfg @@ -7,7 +7,7 @@ PART MODEL { model = ProceduralFairings/Assets/fairing - } + } scale = 1.0 rescaleFactor = 1.0 @@ -74,6 +74,20 @@ PART name = ProceduralFairingDecoupler } + MODULE + { + name = ModuleAnimateGeneric + animationName = Actuate + startEventGUIName = Open Petal + endEventGUIName = Close Petal + actionGUIName = Toggle Petal + allowDeployLimit = true + revClampDirection = true + revClampSpeed = false + revClampPercent = false + deployPercent = 50 + } + MODULE { name = ModulePartVariants diff --git a/Source/ProceduralFairings/FairingSide.cs b/Source/ProceduralFairings/FairingSide.cs index 3dae12f..0870b30 100644 --- a/Source/ProceduralFairings/FairingSide.cs +++ b/Source/ProceduralFairings/FairingSide.cs @@ -48,6 +48,7 @@ public class ProceduralFairingSide : PartModule, IPartCostModifier, IPartMassMod [KSPField(isPersistant = true)] public float sideThickness = 0.05f; [KSPField(isPersistant = true)] public Vector3 meshPos = Vector3.zero; [KSPField(isPersistant = true)] public Quaternion meshRot = Quaternion.identity; + [KSPField(isPersistant = true)] public Vector3 hingeOffset = Vector3.zero; [KSPField(isPersistant = true, guiActiveEditor = true, guiName = "Density", groupName = PFUtils.PAWGroup, groupDisplayName = PFUtils.PAWName)] [UI_FloatRange(minValue = 0.01f, maxValue = 1.0f, stepIncrement = 0.01f)] @@ -57,6 +58,7 @@ public class ProceduralFairingSide : PartModule, IPartCostModifier, IPartMassMod [KSPField] public float maxDensity = 1.0f; [KSPField] public float stepDensity = 0.01f; + public ModuleAnimateGeneric HingeAnimation; [KSPField(guiActiveEditor = true, guiName = "Mass", groupName = PFUtils.PAWGroup)] public string massDisplay; @@ -120,20 +122,30 @@ public class ProceduralFairingSide : PartModule, IPartCostModifier, IPartMassMod [UI_Toggle(disabledText = "Unlocked", enabledText = "Locked")] public bool shapeLock; + [KSPField(isPersistant = true, guiActiveEditor = true, guiName = "Petal Hinge", groupName = PFUtils.PAWGroup)] + [UI_Toggle(disabledText = "Disabled", enabledText = "Enabled", affectSymCounterparts = UI_Scene.All)] + public bool hingeEnabled = false; + [KSPField] public float decouplerCostMult = 1; // Mult to costPerTonne when decoupler is enabled [KSPField] public float decouplerCostBase = 0; // Flat additional cost when decoupler is enabled [KSPField] public float decouplerMassMult = 1; // Mass multiplier [KSPField] public float decouplerMassBase = 0.0001f; // Flat additional mass (0.001 = 1kg) - + [KSPField] public float hingeCostMult = 1; // Mult to costPerTonne when hinge is enabled + [KSPField] public float hingeCostBase = 0; // Flat additional cost when hinge is enabled + [KSPField] public float hingeMassMult = 1; // Mass multiplier + [KSPField] public float hingeMassBase = 0.0001f; // Flat additional mass (0.001 = 1kg) public ModifierChangeWhen GetModuleCostChangeWhen() => ModifierChangeWhen.FIXED; public ModifierChangeWhen GetModuleMassChangeWhen() => ModifierChangeWhen.FIXED; - public float GetModuleCost(float defcost, ModifierStagingSituation sit) => ApplyDecouplerCostModifier(fairingMass * costPerTonne) - defcost; - public float GetModuleMass(float defmass, ModifierStagingSituation sit) => ApplyDecouplerMassModifier(fairingMass) - defmass; - private float ApplyDecouplerCostModifier(float baseCost) => DecouplerEnabled ? (baseCost * decouplerCostMult) + decouplerCostBase : baseCost; - private float ApplyDecouplerMassModifier(float baseMass) => DecouplerEnabled ? (baseMass * decouplerMassMult) + decouplerMassBase : baseMass; + public float GetModuleCost(float defcost, ModifierStagingSituation sit) => ApplyModuleCostModifier(fairingMass * costPerTonne) - defcost; + public float GetModuleMass(float defmass, ModifierStagingSituation sit) => ApplyModuleMassModifier(fairingMass) - defmass; + private float ApplyModuleCostModifier(float baseCost) => (baseCost * totalCostMult) + totalCostBase; + private float ApplyModuleMassModifier(float baseMass) => (baseMass * totalMassMult) + totalMassBase; private bool DecouplerEnabled => part.FindModuleImplementing() is ProceduralFairingDecoupler d && d.fairingStaged; public override string GetInfo() => "Attach to a procedural fairing base to reshape. Right-click it to set its parameters."; - + private float totalCostMult => 1 + (float)Math.Sqrt(Math.Pow(DecouplerEnabled ? decouplerCostMult : 0,2) + Math.Pow(hingeEnabled ? hingeCostMult : 0,2)); + private float totalCostBase => (DecouplerEnabled ? decouplerCostBase : 0) + (hingeEnabled ? hingeCostBase : 0); + private float totalMassMult => (DecouplerEnabled ? decouplerMassMult : 1) * (hingeEnabled ? hingeMassMult : 1); + private float totalMassBase => (DecouplerEnabled ? decouplerMassBase : 0) + (hingeEnabled ? hingeMassBase : 0); private static readonly Dictionary AllPresets = new Dictionary(); [KSPEvent(active = true, guiActiveEditor = true, groupName = PFUtils.PAWGroup, guiName = "Toggle Open/Closed")] @@ -148,12 +160,26 @@ public void ToggleOpenClosed() } } + [KSPEvent(active = true, guiActiveEditor = true, guiActive = true, groupName = PFUtils.PAWGroup, guiName = "Toggle Petals")] + public void TogglePetals() + { + HingeAnimation.Events["Toggle"].Invoke(); + + foreach (Part p in part.symmetryCounterparts) + { + if (p.FindModuleImplementing() is ProceduralFairingSide side) + { + side.HingeAnimation.Events["Toggle"].Invoke(); + } + } + } + public void Start() { - if (part.mass != ApplyDecouplerMassModifier(fairingMass)) + if (part.mass != ApplyModuleMassModifier(fairingMass)) { - Debug.LogWarning($"[PF] FairingSide Start(): Expected part mass {ApplyDecouplerMassModifier(fairingMass)} but discovered {part.mass}!"); - part.mass = ApplyDecouplerMassModifier(fairingMass); + Debug.LogWarning($"[PF] FairingSide Start(): Expected part mass {ApplyModuleMassModifier(fairingMass)} but discovered {part.mass}!"); + part.mass = ApplyModuleMassModifier(fairingMass); } } @@ -173,6 +199,8 @@ public override void OnLoad(ConfigNode node) public override void OnStart(StartState state) { + HingeAnimation = part.FindModuleImplementing(); + colliderPool = new ColliderPool(part.FindModelComponent("model")); if (AllPresets.Count == 0) LoadPresets(AllPresets); @@ -200,7 +228,17 @@ public override void OnStart(StartState state) SetDensityField(); } + public override void OnStartFinished(StartState state) + { + base.OnStartFinished(state); + HingeAnimation.Events["Toggle"].guiActiveEditor = false; + HingeAnimation.Events["Toggle"].guiActive = false; + HingeAnimation.Events["Toggle"].guiActiveUnfocused = false; + HingeAnimation.Events["Toggle"].guiActiveUncommand = false; + SetHingeToggles(); + + } private void SetDensityField() { var floatRange = Fields[nameof(density)].uiControlEditor as UI_FloatRange; @@ -262,6 +300,9 @@ void SetUICallbacks() decoupler.Fields[nameof(decoupler.fairingStaged)].uiControlEditor.onFieldChanged += OnChangeDecouplerUI; decoupler.Fields[nameof(decoupler.fairingStaged)].uiControlEditor.onSymmetryFieldChanged += OnChangeDecouplerUI; } + + Fields[nameof(hingeEnabled)].uiControlEditor.onFieldChanged += OnHingeEnabledChanged; + Fields[nameof(hingeEnabled)].uiControlEditor.onSymmetryFieldChanged += OnHingeEnabledChanged; } void OnShapePresetChanged(BaseField field, object obj) => ApplySelectedPreset(); @@ -348,7 +389,7 @@ public void UpdateMassAndCostDisplay() int nsym = part.symmetryCounterparts.Count; string s = (nsym == 0) ? string.Empty : (nsym == 1) ? " (both)" : $" (all {nsym + 1})"; float perPartCost = part.partInfo.cost + GetModuleCost(part.partInfo.cost, ModifierStagingSituation.CURRENT); - massDisplay = PFUtils.FormatMass(ApplyDecouplerMassModifier(fairingMass) * (nsym + 1)) + s; + massDisplay = PFUtils.FormatMass(ApplyModuleMassModifier(fairingMass) * (nsym + 1)) + s; costDisplay = $"{perPartCost * (nsym + 1):N0}{s}"; } @@ -473,7 +514,7 @@ private void UpdatePartParameters(double area) { float volume = Convert.ToSingle(area * sideThickness); fairingMass = volume * density; - float totalMass = ApplyDecouplerMassModifier(fairingMass); + float totalMass = ApplyModuleMassModifier(fairingMass); part.breakingForce = totalMass * specificBreakingForce; part.breakingTorque = totalMass * specificBreakingTorque; } @@ -496,7 +537,9 @@ public void rebuildMesh(bool updateDragCubes = true) Profiler.BeginSample("PF.FairingSide.RebuildMesh"); Profiler.BeginSample("PF.FairingSide.RebuildMesh.BuildShape"); - mf.transform.localPosition = meshPos; + OffsetHinge(mf); + + mf.transform.localPosition = meshPos - hingeOffset; mf.transform.localRotation = meshRot; UpdateNodeSize(); @@ -923,13 +966,40 @@ public void rebuildMesh(bool updateDragCubes = true) Profiler.EndSample(); } + public void OnHingeEnabledChanged(BaseField f, object obj) + { + UpdateMassAndCostDisplay(); + SetHingeToggles(); + } + + private void SetHingeToggles() + { + if (HingeAnimation is null) + return; + + Events["TogglePetals"].guiActiveEditor = hingeEnabled; + Events["TogglePetals"].guiActive = hingeEnabled; + Events["TogglePetals"].guiActiveUnfocused = hingeEnabled; + Events["TogglePetals"].guiActiveUncommand = hingeEnabled; + HingeAnimation.Fields["deployPercent"].guiActiveEditor = hingeEnabled; + HingeAnimation.Fields["deployPercent"].guiActive = (hingeEnabled && HighLogic.LoadedSceneIsEditor); + HingeAnimation.Fields["deployPercent"].guiActiveUnfocused = false; + + if (!hingeEnabled && HighLogic.LoadedSceneIsFlight) + HingeAnimation.deployPercent = 0f; //disabling still allows action groups to activate + + MonoUtilities.RefreshPartContextWindow(part); + + } public IEnumerator SetOffset(Vector3 offset, float time = 0.3f) { var mf = part.FindModelComponent("model"); var lp = mf.transform.localPosition; float elapsedTime = 0f; + offset -= hingeOffset; + while (elapsedTime < time) { mf.transform.localPosition = Vector3.Lerp(lp, offset, (elapsedTime / time)); @@ -943,7 +1013,18 @@ public IEnumerator SetOffset(Vector3 offset, float time = 0.3f) public void SetOffset(Vector3 offset) { var mf = part.FindModelComponent("model"); - mf.transform.localPosition = offset; + mf.transform.localPosition = offset - hingeOffset; + } + + private void OffsetHinge(UnityEngine.MeshFilter mf) + { + var mh = part.FindModelTransform("Hinge"); + + if (mh != null) + { + hingeOffset = new Vector3(-1 * sideThickness, meshPos.y, 0f); + mh.localPosition = hingeOffset; + } } } From c7e79c8a156fb1b2f5df49d9f5b7322ea3eca797 Mon Sep 17 00:00:00 2001 From: Stonesmile <62522391+StonesmileGit@users.noreply.github.com> Date: Wed, 16 Aug 2023 03:17:31 +0200 Subject: [PATCH 3/3] Add CI (#49) * Add CI * Fix build artifact name --- .github/workflows/attachReleaseArtifacts.yml | 96 +++++++++++++++++++ .github/workflows/build.yml | 74 ++++++++++++++ .github/workflows/pr-comment.yml | 61 ++++++++++++ GameData/ProceduralFairings/changelog.cfg | 7 ++ .../Properties/AssemblyInfo.cs | 12 ++- 5 files changed, 246 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/attachReleaseArtifacts.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/pr-comment.yml create mode 100644 GameData/ProceduralFairings/changelog.cfg diff --git a/.github/workflows/attachReleaseArtifacts.yml b/.github/workflows/attachReleaseArtifacts.yml new file mode 100644 index 0000000..da5e51a --- /dev/null +++ b/.github/workflows/attachReleaseArtifacts.yml @@ -0,0 +1,96 @@ +name: "Attach Release Artifacts" + +# Controls when the action will run. +on: + release: + types: [published] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + attach-release-artifacts: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Get Branch + shell: bash + run: | + releaseBranch=${{ github.event.release.target_commitish }} + echo "Found branch ${releaseBranch}" + echo "tagged_branch=${releaseBranch}" >> $GITHUB_ENV + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ env.tagged_branch }} + + - name: Download required assemblies + id: download-assemblies + uses: KSP-RO/BuildTools/download-assemblies@master + with: + KSP_ZIP_PASSWORD: ${{ secrets.KSP_ZIP_PASSWORD }} + + - name: Update AssemblyInfo + uses: KSP-RO/BuildTools/update-assembly-info@master + with: + path: ${GITHUB_WORKSPACE}/Source/ProceduralFairings/Properties/AssemblyInfo.cs + tag: ${{ github.event.release.tag_name }} + + - name: Build mod solution + run: msbuild ${GITHUB_WORKSPACE}/Source/ProceduralFairings.sln /t:build /restore /p:RestorePackagesConfig=true /p:Configuration=Release /p:ReferencePath="${{ steps.download-assemblies.outputs.ksp-dll-path }}" + + - name: Update version file + uses: KSP-RO/BuildTools/update-version-file@master + with: + tag: ${{ github.event.release.tag_name }} + path: ${GITHUB_WORKSPACE}/GameData/ProceduralFairings/ProceduralFairings.version + + - name: Update changelog file + uses: KSP-RO/BuildTools/process-changelog@master + with: + tag: ${{ github.event.release.tag_name }} + body: ${{ github.event.release.body }} + path: ${GITHUB_WORKSPACE}/GameData/ProceduralFairings/changelog.cfg + + - name: Assemble release + id: assemble-release + run: | + RELEASE_DIR="${RUNNER_TEMP}/release" + echo "Release dir: ${RELEASE_DIR}" + echo "Release zip: ${RELEASE_DIR}/ProceduralFairings-${{ github.event.release.tag_name }}.zip" + mkdir -v "${RELEASE_DIR}" + echo "::set-output name=release-dir::${RELEASE_DIR}" + cp -v -R "${GITHUB_WORKSPACE}/GameData" "${RELEASE_DIR}" + cp -v -R "${GITHUB_WORKSPACE}/LICENSE.md" "${RELEASE_DIR}/GameData/ProceduralFairings/LICENSE.md" + cd ${RELEASE_DIR} + zip -r ProceduralFairings-${{ github.event.release.tag_name }}.zip GameData + + - name: Upload package to release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ${{ steps.assemble-release.outputs.release-dir }}/ProceduralFairings-${{ github.event.release.tag_name }}.zip + asset_name: ProceduralFairings-${{ github.event.release.tag_name }}.zip + asset_content_type: application/zip + + - name: Setup git config + run: | + git config user.name "GitHub Actions Bot" + git config user.email "<>" + + - name: Commit changes + shell: bash + env: + TAG_STRING: ${{ github.event.release.tag_name }} + run: | + RELEASEBRANCH=${{ env.tagged_branch }} + git add "${GITHUB_WORKSPACE}/GameData/ProceduralFairings/ProceduralFairings.version" + git add "${GITHUB_WORKSPACE}/GameData/ProceduralFairings/changelog.cfg" + git commit -m "Update version to $TAG_STRING" + git push origin $RELEASEBRANCH + git tag $TAG_STRING $RELEASEBRANCH --force + git push origin $TAG_STRING --force diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2f997a9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,74 @@ +# This is a basic workflow to help you get started with Actions + +name: build + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ master ] + pull_request: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + check-secret: + uses: KSP-RO/BuildTools/.github/workflows/check-secret.yml@master + secrets: + KSP_ZIP_PASSWORD: ${{ secrets.KSP_ZIP_PASSWORD }} + + validate-cfg-files: + uses: KSP-RO/BuildTools/.github/workflows/validate-cfg-files.yml@master + + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + needs: [check-secret] + if: needs.check-secret.outputs.has-password == 'true' + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 100 + + - name: Download required assemblies + id: download-assemblies + uses: KSP-RO/BuildTools/download-assemblies@master + with: + KSP_ZIP_PASSWORD: ${{ secrets.KSP_ZIP_PASSWORD }} + + - name: Update AssemblyInfo + uses: KSP-RO/BuildTools/update-assembly-info@master + with: + path: ${GITHUB_WORKSPACE}/Source/ProceduralFairings/Properties/AssemblyInfo.cs + tag: "7.0.0.0" + + - name: Build mod solution + run: msbuild ${GITHUB_WORKSPACE}/Source/ProceduralFairings.sln /t:build /restore /p:RestorePackagesConfig=true /p:Configuration=Release /p:ReferencePath="${{ steps.download-assemblies.outputs.ksp-dll-path }}" + + - name: Build metadata + uses: KSP-RO/BuildTools/update-version-file@master + with: + path: ${GITHUB_WORKSPACE}/GameData/ProceduralFairings/ProceduralFairings.version + tag: "v2.0.0.0" + + - name: Assemble release + id: assemble-release + run: | + RELEASE_DIR="${RUNNER_TEMP}/release" + echo "Release dir: ${RELEASE_DIR}" + mkdir -v "${RELEASE_DIR}" + echo "::set-output name=release-dir::${RELEASE_DIR}" + cp -v -R "${GITHUB_WORKSPACE}/GameData" "${RELEASE_DIR}" + cp -v -R "${GITHUB_WORKSPACE}/LICENSE.md" "${RELEASE_DIR}/GameData/ProceduralFairings/LICENSE.md" + + - name: Upload artifacts + uses: actions/upload-artifact@v1 + with: + name: ProceduralFairings + path: ${{ steps.assemble-release.outputs.release-dir }} diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml new file mode 100644 index 0000000..708503c --- /dev/null +++ b/.github/workflows/pr-comment.yml @@ -0,0 +1,61 @@ +name: Comment on pull request +on: + workflow_run: + workflows: ['build'] + types: [completed] +jobs: + pr_comment: + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v5 + with: + # This snippet is public-domain, taken from + # https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml + script: | + async function upsertComment(owner, repo, issue_number, purpose, body) { + const {data: comments} = await github.rest.issues.listComments( + {owner, repo, issue_number}); + + const marker = ``; + body = marker + "\n" + body; + + const existing = comments.filter((c) => c.body.includes(marker)); + if (existing.length > 0) { + const last = existing[existing.length - 1]; + core.info(`Updating comment ${last.id}`); + await github.rest.issues.updateComment({ + owner, repo, + body, + comment_id: last.id, + }); + } else { + core.info(`Creating a comment in issue / PR #${issue_number}`); + await github.rest.issues.createComment({issue_number, body, owner, repo}); + } + } + + const {owner, repo} = context.repo; + const run_id = ${{github.event.workflow_run.id}}; + + const pull_requests = ${{ toJSON(github.event.workflow_run.pull_requests) }}; + if (!pull_requests.length) { + return core.error("This workflow doesn't match any pull requests!"); + } + + const artifacts = await github.paginate( + github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id}); + if (!artifacts.length) { + return core.error(`No artifacts found`); + } + let body = `Download the artifacts for this pull request:\n`; + for (const art of artifacts) { + body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`; + } + + core.info("Review thread message body:", body); + + for (const pr of pull_requests) { + await upsertComment(owner, repo, pr.number, + "nightly-link", body); + } \ No newline at end of file diff --git a/GameData/ProceduralFairings/changelog.cfg b/GameData/ProceduralFairings/changelog.cfg new file mode 100644 index 0000000..50464d5 --- /dev/null +++ b/GameData/ProceduralFairings/changelog.cfg @@ -0,0 +1,7 @@ +KERBALCHANGELOG +{ + modName = Procedural Fairings + license = CC-BY 4.0 + author = KSP-RO team + website = github.com/KSP-RO/ProceduralFairings +} diff --git a/Source/ProceduralFairings/Properties/AssemblyInfo.cs b/Source/ProceduralFairings/Properties/AssemblyInfo.cs index eed9a9c..908d39c 100644 --- a/Source/ProceduralFairings/Properties/AssemblyInfo.cs +++ b/Source/ProceduralFairings/Properties/AssemblyInfo.cs @@ -1,3 +1,4 @@ +#define CIBUILD_disabled using System; using System.Reflection; using System.Runtime.InteropServices; @@ -25,11 +26,14 @@ // • Build Number // • Revision -[assembly: AssemblyVersion ("6.0.0.0")] -[assembly: AssemblyFileVersion ("6.3.0.0")] - // The KSPAssembly attribute can be used to ensure that the plugin assemblies // are loaded in the correct order. // This attribute is not currently used but it is included here for completeness. - +[assembly: AssemblyVersion ("6.0.0.0")] +#if CIBUILD +[assembly: AssemblyFileVersion ("@MAJOR@.@MINOR@.@PATCH@.@BUILD@")] +[assembly: KSPAssembly ("ProceduralFairings", @MAJOR@, @MINOR@)] +#else +[assembly: AssemblyFileVersion ("6.3.0.0")] [assembly: KSPAssembly ("ProceduralFairings", 6, 3)] +#endif