Skip to content

Commit

Permalink
Merge pull request #31 from Bloodsucker/30-release-110
Browse files Browse the repository at this point in the history
30 release 110
  • Loading branch information
Bloodsucker authored Feb 13, 2024
2 parents 8d1801a + 6c52b90 commit feacab7
Show file tree
Hide file tree
Showing 26 changed files with 498 additions and 144 deletions.
7 changes: 5 additions & 2 deletions .github/actions/build-mod/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ description: 'Builds KSP mod'
inputs:
ksp_dlls_donwload_url:
required: true
ksp_dlls_password:
required: true
tmp_path:
required: true
outputs:
Expand All @@ -17,14 +19,15 @@ runs:
shell: bash
run: |
[[ "${{ inputs.ksp_dlls_donwload_url }}" ]] || { echo "ksp_dlls_donwload_url input is empty" ; exit 1; }
[[ "${{ inputs.ksp_dlls_password }}" ]] || { echo "ksp_dlls_password input is empty" ; exit 1; }
[[ "${{ inputs.tmp_path }}" ]] || { echo "tmp_path input is empty" ; exit 1; }
- name: Download KSP Assemblies (Dlls)
id: download-assemblies
shell: bash
run: |
curl "${{ inputs.ksp_dlls_donwload_url }}" -L --output ${{ inputs.tmp_path }}/dlls.zip
unzip ${{ inputs.tmp_path }}/dlls.zip -d ${{ inputs.tmp_path }}/dlls
echo "ksp_dlls_path=${{ inputs.tmp_path }}/dlls/ksp-assemblies" >> $GITHUB_OUTPUT
unzip -P ${{ inputs.ksp_dlls_password }} ${{ inputs.tmp_path }}/dlls.zip -d ${{ inputs.tmp_path }}/dlls
echo "ksp_dlls_path=${{ inputs.tmp_path }}/dlls" >> $GITHUB_OUTPUT
- id: building
shell: bash
run: |
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/canary-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Nightly Release

on:
push:
branches:
- develop

jobs:
nightly-release:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bump version (canary)
id: bump-version
run: |
SHORT_VERSION=$(python3 update-version.py get-version --short)
NEW_VERSION="${SHORT_VERSION}-SNAPSHOT-$(git rev-parse --short HEAD)"
NEW_ASSEMBLY_VERSION="${SHORT_VERSION}.0"
python3 update-version.py update-version --new-version "$NEW_VERSION" --new-assembly-version $NEW_ASSEMBLY_VERSION
git --no-pager diff
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- id: build-mod
uses: ./.github/actions/build-mod
with:
ksp_dlls_donwload_url: ${{ secrets.KSP_DLLS_DONWLOAD_URL }}
ksp_dlls_password: ${{ secrets.KSP_DLLS_PASSWORD }}
tmp_path: ${{ runner.temp }}
- name: Preparing Release files
id: release-files
run: |
mkdir -p $RUNNER_TEMP/release
ZIP_FILENAME="BetterRocketDesigns-v${{ steps.bump-version.outputs.new_version }}.zip"
mv ${{ steps.build-mod.outputs.zip_path }} $RUNNER_TEMP/release/$ZIP_FILENAME
echo "release_zip=$RUNNER_TEMP/release/$ZIP_FILENAME" >> $GITHUB_OUTPUT
- name: Delete latest canary release
run: gh release delete canary -y || true
- name: Release new canary
run: gh release create canary --prerelease --generate-notes --target develop --title 'Canary (v${{ steps.bump-version.outputs.new_version }})' '${{ steps.release-files.outputs.release_zip }}'
19 changes: 10 additions & 9 deletions .github/workflows/make-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
run: |
[[ "${{ inputs.new_version }}" ]] || { echo "new_version input is empty" ; exit 1; }
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bummping version
run: python3 update-version.py ${{ inputs.new_version }}
run: |
NEW_VERSION=${{ inputs.new_version }}
NEW_ASSEMBLY_VERSION="${SHORT_VERSION}.0"
python3 update-version.py update-version --new-version $NEW_VERSION --new-assembly-version $NEW_ASSEMBLY_VERSION
- run: git status
- id: build-mod
uses: ./.github/actions/build-mod
with:
ksp_dlls_donwload_url: ${{ secrets.KSP_DLLS_DONWLOAD_URL }}
tmp_path: ${{ runner.temp }}
- name: Setup git config
run: |
git config user.name "Github Actions Bot"
Expand All @@ -35,6 +35,7 @@ jobs:
git commit -m "New release BetterRocketDesigns v${{ inputs.new_version }}"
git checkout master
git merge --no-ff $RELEASE_BRANCH -m "Merge branch '$RELEASE_BRANCH' into master"
git tag -a v${{ inputs.new_version }} -m "New release BetterRocketDesigns v${{ inputs.new_version }}"
git log --oneline --graph -n 5
git push origin master --tags
git tag -a "v${{ inputs.new_version }}" -m "New release BetterRocketDesigns v${{ inputs.new_version }}"
git checkout develop
git merge master
git push origin master develop --tags
18 changes: 18 additions & 0 deletions .github/workflows/pr-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "PR to develop"

on:
pull_request:
branches:
- develop

jobs:
validate-dev-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: build-mod
uses: ./.github/actions/build-mod
with:
ksp_dlls_donwload_url: ${{ secrets.KSP_DLLS_DONWLOAD_URL }}
ksp_dlls_password: ${{ secrets.KSP_DLLS_PASSWORD }}
tmp_path: ${{ runner.temp }}
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: find .
- id: build-mod
uses: ./.github/actions/build-mod
with:
ksp_dlls_donwload_url: ${{ secrets.KSP_DLLS_DONWLOAD_URL }}
ksp_dlls_password: ${{ secrets.KSP_DLLS_PASSWORD }}
tmp_path: ${{ runner.temp }}
- name: Preparing Release files
id: release-files
Expand Down
9 changes: 8 additions & 1 deletion BetterRocketDesigns/BetterRocketDesigns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ enum ToolbarButtonMode
[KSPAddon(KSPAddon.Startup.EditorAny, false)]
public class BetterRocketDesigns : MonoBehaviour
{
public const string VERSION = "1.1.0";

private RocketDesignManager _rocketDesignManager;
private ApplicationLauncherButton _toolbarButton;
private Part detachedPart;
Expand All @@ -29,6 +31,11 @@ public class BetterRocketDesigns : MonoBehaviour
private Texture2D saveAsToolbarButtonIcon;
private ToolbarButtonMode _toolbarButtonMode;

private void Awake()
{
Debug.Log("BetterRocketDesigns version: " + VERSION);
}

private void Start()
{
loadToolbarButtonIcon = GameDatabase.Instance.GetTexture("BetterRocketDesigns/Textures/open-64p", false);
Expand Down Expand Up @@ -92,7 +99,7 @@ private void OpenSaveAsWindow()

ConfigNode cn = CraftTools.TransformAsConfigNode(detachedPart);
ConfigNodeAdapter configNode = new ConfigNodeAdapter(cn);
RocketDesign newRocketDesign = new RocketDesign(configNode);
UnsavedRocketDesign newRocketDesign = new UnsavedRocketDesign(configNode);

RocketDesignSaverUI rocketDesignSaverUI = new GameObject("RocketDesignSaverUI")
.AddComponent<RocketDesignSaverUI>();
Expand Down
6 changes: 5 additions & 1 deletion BetterRocketDesigns/BetterRocketDesigns.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>$(KSP_DEV)\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="ClickThroughBlocker">
<HintPath>$(KSP_DEV)\GameData\000_ClickThroughBlocker\Plugins\ClickThroughBlocker.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand Down Expand Up @@ -66,9 +69,10 @@
<Compile Include="BetterRocketDesigns.cs" />
<Compile Include="adapters\IConfigNodeAdapter.cs" />
<Compile Include="IRocketDesignLoader.cs" />
<Compile Include="models\RocketDesign.cs" />
<Compile Include="models\RocketDesignFilter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="models\RocketDesign.cs" />
<Compile Include="models\UnsavedRocketDesign.cs" />
<Compile Include="ksp\RocketDesignLoader.cs" />
<Compile Include="RocketDesignLoaderScreen\RocketDesignLoaderController.cs" />
<Compile Include="RocketDesignLoaderScreen\RocketDesignLoaderUI.cs" />
Expand Down
4 changes: 2 additions & 2 deletions BetterRocketDesigns/IRocketDesignLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace BetterRocketDesigns
{
internal interface IRocketDesignLoader
{
List<IConfigNodeAdapter> LoadAllRocketDesigns();
void SaveRocketDesign(string fileName, IConfigNodeAdapter configNode);
List<RocketDesign> LoadAllRocketDesigns();
RocketDesign SaveRocketDesign(UnsavedRocketDesign rocketDesign);
}
}
4 changes: 2 additions & 2 deletions BetterRocketDesigns/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void HandleLoadButtonClicked(RocketDesign design)
{
ConfigNode configNode = adapter.GetOriginalInstance();
ShipTemplate subassembly = new ShipTemplate();
subassembly.LoadShip(configNode);
subassembly.LoadShip(design.CraftPath, configNode);
EditorLogic.fetch.SpawnTemplate(subassembly);

MonoBehaviour.Destroy(_ui.gameObject);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using ClickThroughFix;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
Expand Down Expand Up @@ -138,7 +139,7 @@ private void HandleExistingRocketdesignButtonClick(RocketDesign rocketDesign)

private void OnGUI()
{
_windowPosition = GUILayout.Window(_windowId, _windowPosition, OnWindow, "Load Rocket Design as", rocketDesignSaverWindowStyle);
_windowPosition = ClickThruBlocker.GUILayoutWindow(_windowId, _windowPosition, OnWindow, "Load Rocket Design as", rocketDesignSaverWindowStyle);
}

private void OnWindow(int windowId)
Expand Down
14 changes: 3 additions & 11 deletions BetterRocketDesigns/RocketDesignManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,8 @@ public void LoadAllRocketDesigns()
{
_labels = new SortedSet<string>();
_capabilities = new SortedSet<string>();
_cachedRocketDesigns = new List<RocketDesign>();

List<IConfigNodeAdapter> configNodes = _rocketDesignLoader.LoadAllRocketDesigns();

foreach (var configNode in configNodes)
{
RocketDesign rocketDesign = new RocketDesign(configNode);

_cachedRocketDesigns.Add(rocketDesign);
}
_cachedRocketDesigns = _rocketDesignLoader.LoadAllRocketDesigns();

ReloadCachedRocketDesignMetadata();
}
Expand All @@ -56,9 +48,9 @@ public IReadOnlyCollection<string> getCachedCapabilities()
return _capabilities;
}

public RocketDesign SaveOrReplaceAsRocketDesign(RocketDesign rocketDesign)
public RocketDesign SaveOrReplaceAsRocketDesign(UnsavedRocketDesign unsavedRocketDesign)
{
_rocketDesignLoader.SaveRocketDesign(rocketDesign.Name, rocketDesign.ConfigNode);
RocketDesign rocketDesign = _rocketDesignLoader.SaveRocketDesign(unsavedRocketDesign);

int index = _cachedRocketDesigns.FindIndex(rd => rd.Name == rocketDesign.Name);
if (index != -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ namespace BetterRocketDesigns.RocketDesignSaverScreen
{
internal class RocketDesignSaverController
{
private readonly RocketDesign _newRocketDesign;
private readonly UnsavedRocketDesign _newRocketDesign;
private readonly RocketDesignSaverUI _ui;
private readonly RocketDesignManager _rocketDesignManager;
public event Action OnComplete;

private RocketDesignFilter _rocketDesignFilter = new RocketDesignFilter();

public RocketDesignSaverController(RocketDesign newRocketDesign, RocketDesignSaverUI ui, RocketDesignManager rocketDesignManager)
public RocketDesignSaverController(UnsavedRocketDesign newRocketDesign, RocketDesignSaverUI ui, RocketDesignManager rocketDesignManager)
{
_newRocketDesign = newRocketDesign;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using ClickThroughFix;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
Expand All @@ -18,7 +19,7 @@ internal class RocketDesignSaverUI : MonoBehaviour
public event Action<string> OnAddNewLabelButtonClicked;
public event Action<string> OnRemoveNewLabelButtonClicked;

private RocketDesign _newRocketDesign;
private UnsavedRocketDesign _newRocketDesign;
private List<RocketDesign> filteredRocketDesigns;
private IReadOnlyCollection<string> _cachedFilterLabels;
private IReadOnlyCollection<string> _cachedFilterCapabilities;
Expand Down Expand Up @@ -63,7 +64,7 @@ internal class RocketDesignSaverUI : MonoBehaviour
private GUIStyle newCapabilityScrollViewStyle;
private GUIStyle newCapabilityRemoveButtonStyle;

public void Init(RocketDesign newRocketDesign, IReadOnlyCollection<string> cachedLabels, IReadOnlyCollection<string> cachedCapabilities)
public void Init(UnsavedRocketDesign newRocketDesign, IReadOnlyCollection<string> cachedLabels, IReadOnlyCollection<string> cachedCapabilities)
{
_newRocketDesign = newRocketDesign;
_cachedFilterLabels = cachedLabels;
Expand Down Expand Up @@ -177,7 +178,7 @@ private void HandleExistingRocketdesignButtonClick(RocketDesign rocketDesign)

private void OnGUI()
{
_windowPosition = GUILayout.Window(_windowId, _windowPosition, OnWindow, "Save Rocket Design as", rocketDesignSaverWindowStyle);
_windowPosition = ClickThruBlocker.GUILayoutWindow(_windowId, _windowPosition, OnWindow, "Save Rocket Design as", rocketDesignSaverWindowStyle);
}

private void OnWindow(int windowId)
Expand Down
2 changes: 1 addition & 1 deletion BetterRocketDesigns/adapters/IConfigNodeAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal interface IConfigNodeAdapter
void GetValues(string name, out List<string> values);

void SetValue(string key, string value);
void SetValue(string key, IReadOnlyList<string> value);
void SetValue(string key, IReadOnlyCollection<string> value);
void SetValue(string key, IReadOnlyDictionary<string, float> value);

void AddValue(string key, string value);
Expand Down
20 changes: 10 additions & 10 deletions BetterRocketDesigns/ksp/ConfigNodeAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ public void SetValue(string key, string value)
configNode.SetValue(key, value);
}

public void SetValue(string key, IReadOnlyCollection<string> values)
{
configNode.RemoveValues(key);

foreach (string value in values)
{
configNode.AddValue("labels", value);
}
}

public void AddValue(string key, string value)
{
configNode.AddValue(key, value);
Expand All @@ -51,15 +61,5 @@ public void GetValues(string name, out List<string> values)
{
values = configNode.GetValuesList(name);
}

public void SetValue(string key, IReadOnlyList<string> values)
{
configNode.RemoveValue(key);

foreach (string value in values)
{
configNode.AddValue("labels", value);
}
}
}
}
Loading

0 comments on commit feacab7

Please sign in to comment.