Skip to content

Commit

Permalink
Merge branch 'master' into log-console
Browse files Browse the repository at this point in the history
  • Loading branch information
xen-42 committed Dec 26, 2023
2 parents ec438e8 + 4bfdf8b commit bbba7e8
Show file tree
Hide file tree
Showing 23 changed files with 439 additions and 139 deletions.
51 changes: 20 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
name: Build artifacts

env:
PROJ_NAME: Winch
MODS_DIR: Winch.Examples
DISASTER_BUTTON: DisasterButton
EXAMPLE_ITEMS: ExampleItems
INTRO_SKIPPER: IntroSkipper

on:
workflow_call:
inputs:
Expand All @@ -19,40 +12,36 @@ on:
jobs:
build:
name: Create artifacts
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: "actions/checkout@v3"
uses: actions/checkout@v3

- name: Setup .NET
uses: "actions/setup-dotnet@v3"
uses: actions/setup-dotnet@v3

- name: Build Winch
run: dotnet build -c ${{ inputs.build_type }}

- name: Check
run: ls

- name: Upload Winch Artifact
uses: "actions/upload-artifact@v3"
uses: actions/upload-artifact@v3
with:
name: "${{ env.PROJ_NAME }}"
path: "${{ env.PROJ_NAME }}/bin"
name: Winch
path: Winch/bin

- name: Upload DisasterButton Artifact
uses: "actions/upload-artifact@v3"
with:
name: "${{ env.DISASTER_BUTTON }}"
path: "${{ env.MODS_DIR }}/${{ env.DISASTER_BUTTON }}/bin"

- name: Upload ExampleItems Artifact
uses: "actions/upload-artifact@v3"
with:
name: "${{ env.EXAMPLE_ITEMS }}"
path: "${{ env.MODS_DIR }}/${{ env.EXAMPLE_ITEMS }}/bin"
- name: Move Example Mods
run: |
for mod in DisasterButton ExampleItems IntroSkipper
do
mkdir -p Examples/$mod
mv Winch.Examples/$mod/bin/* Examples/$mod/
done
- name: Upload IntroSkipper Artifact
uses: "actions/upload-artifact@v3"
- name: Upload Example Mod Artifact
uses: actions/upload-artifact@v3
with:
name: "${{ env.INTRO_SKIPPER }}"
path: "${{ env.MODS_DIR }}/${{ env.INTRO_SKIPPER }}/bin"
name: Winch Examples
path: |
Examples/DisasterButton
Examples/ExampleItems
Examples/IntroSkipper
98 changes: 98 additions & 0 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Release Build

on:
push:
branches: [master]
paths-ignore:
- "*.md"
- "LICENSE"
- ".gitignore"
pull_request:
branches: [master]
types:
- synchronize
- labeled
paths-ignore:
- "*.md"
- "LICENSE"
- ".gitignore"

jobs:
Build:
if: ${{ github.ref == 'refs/heads/master' || contains(github.event.pull_request.labels.*.name, 'update-pr') }}
uses: ./.github/workflows/build.yml
with:
build_type: Release
Update_Release:
name: 'Create/Update Release Asset'
needs: Build
outputs:
version: ${{ steps.version.outputs.prop }}
if: ${{ github.ref != 'refs/heads/master' && contains(github.event.pull_request.labels.*.name, 'update-pr') }}
runs-on: ubuntu-latest
steps:
- name: Download Winch Asset
uses: actions/download-artifact@v3
with:
name: Winch
path: Winch

- name: Zip Winch Asset
run: |
cd Winch/
zip -r Winch.zip *
mv Winch.zip ..
cd ..
- name: Download Example Mods
uses: actions/download-artifact@v3
with:
name: Winch Examples
path: Examples

- name: Zip Example Mods
run: |
for mod in DisasterButton ExampleItems IntroSkipper
do
cd Examples/$mod/
zip -r $mod.zip *
mv $mod.zip ../..
cd ../..
done
- name: Upload Asset
uses: ncipollo/release-action@v1
with:
allowUpdates: true
commit: master
tag: v${{ github.event.pull_request.title }}
name: Version ${{ github.event.pull_request.title }}
omitBodyDuringUpdate: true
artifacts: Winch.zip, DisasterButton.zip, ExampleItems.zip, IntroSkipper.zip
draft: true
prerelease: false
Pack_Nuget:
name: Pack nuget
needs: Update_Release
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get version
id: version
uses: notiz-dev/github-action-json-property@release
with:
path: Winch/mod_meta.json
prop_path: Version
- name: Set up nuget
uses: NuGet/[email protected]
- name: Download Winch Asset
uses: actions/download-artifact@v3
with:
name: Winch
path: Winch/bin
- name: Pack nuget
run: nuget pack Winch/Winch.nuspec -Properties "version=${{ steps.version.outputs.prop }}"
- run: dir
- name: Publish nuget
run: nuget push "Winch.*.nupkg" -ApiKey ${{ secrets.NUGET_KEY }} -Source https://api.nuget.org/v3/index.json

Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: Debug artifact

on:
[push, pull_request]
push:
branches-ignore: [master]
paths-ignore:
- "*.md"
- "LICENSE"
- ".gitignore"
workflow_dispatch:

jobs:
build:
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/update_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Create/Update Release

on:
pull_request:
branches: [master]
types:
- ready_for_review
- edited
- labeled

jobs:
Update_Release:
name: Create/Update Release
if: contains(github.event.pull_request.labels.*.name, 'update-pr')
runs-on: ubuntu-latest
steps:
- name: Create/Update Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
name: Version ${{ github.event.pull_request.title }}
tag: ${{ github.event.pull_request.title }}
commit: master
body: |
${{ github.event.pull_request.body }}
**Generated From PR: ${{ github.event.pull_request.html_url }}**
draft: true
prerelease: false
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
![Winch](./banner.png)

[![Discord](https://img.shields.io/discord/1097191320935735346?style=for-the-badge)](https://discord.gg/qFqPuTUAmD)
[![GitHub issues](https://img.shields.io/github/issues/Hacktix/Winch?style=for-the-badge)](https://github.com/Hacktix/Winch/issues)
[![GitHub all releases](https://img.shields.io/github/downloads/Hacktix/Winch/total?style=for-the-badge)](https://github.com/Hacktix/Winch/releases)
[![GitHub all releases](https://img.shields.io/github/downloads/Hacktix/Winch/total?style=for-the-badge)](https://github.com/DREDGE-Mods/Winch/releases)

**Winch** is intended to be a Mod Loader for the game DREDGE. It is currently heavily under development and there are many improvements to come. As of right now, it's not considered ready for use and there will not be any documentation or instructions until this changes.
Winch is a mod loader for Dredge made by Hacktix. This is a modified version for use with the Dredge mod manager.

## Roadmap
This repo has a few example mods as well:

- [x] Code Execution when booting DREDGE
- [x] Basic Configuration Options for Winch
- [x] Loading separate Mod Assemblies at runtime
- [x] Standardized Mod Format (Metadata JSON File)
- [ ] Provide API to Mod Assemblies to interface with the game
- [ ] Documentation & Examples
### Disaster button

Press the delete key to trigger a random world event.

### Example Items

An example of using Winch to add items to the game, adds a cod and diamonds from Minecraft.

### Intro Skipper

Self explanatory. Skips the intro cutscene.
2 changes: 1 addition & 1 deletion Winch.Examples/DisasterButton/DisasterButton.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DredgeGameLibs" Version="1.1.0" />
<PackageReference Include="DredgeGameLibs" Version="1.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 10 additions & 7 deletions Winch.Examples/DisasterButton/mod_meta.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"Version": "1.0",
"ModAssembly": "DisasterButton.dll",
"Entrypoint": "DisasterButton.Loader/Initialize",
"DefaultConfig": {
"DisasterButtonKey": "delete"
},
"MinWinchVersion": "alpha-1.0"
"Name": "Disaster Button",
"Author": "Hacktix",
"ModGUID": "hacktix.disasterbutton",
"Version": "1.0",
"ModAssembly": "DisasterButton.dll",
"Entrypoint": "DisasterButton.Loader/Initialize",
"DefaultConfig": {
"DisasterButtonKey": "delete"
},
"MinWinchVersion": "alpha-1.0"
}
2 changes: 1 addition & 1 deletion Winch.Examples/ExampleItems/ExampleItems.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DredgeGameLibs" Version="1.1.0" />
<PackageReference Include="DredgeGameLibs" Version="1.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions Winch.Examples/ExampleItems/mod_meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"Version": "1.0",
"ModAssembly": "ExampleItems.dll",
"Entrypoint": "ExampleItems.Loader/Initialize",
"MinWinchVersion": "alpha-1.1"
"Name": "Example Items",
"Author": "Hacktix",
"ModGUID": "hacktix.exampleitems",
"Version": "1.0",
"ModAssembly": "ExampleItems.dll",
"Entrypoint": "ExampleItems.Loader/Initialize",
"MinWinchVersion": "alpha-1.1"
}
2 changes: 1 addition & 1 deletion Winch.Examples/IntroSkipper/IntroSkipper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DredgeGameLibs" Version="1.1.0" />
<PackageReference Include="DredgeGameLibs" Version="1.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 6 additions & 4 deletions Winch.Examples/IntroSkipper/mod_meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"Version": "1.0",
"ModAssembly": "IntroSkipper.dll",
"MinWinchVersion": "alpha-1.4",
"ApplyPatches": true
"Name": "Intro Skipper",
"ModGUID": "hacktix.introskipper",
"Version": "1.0",
"ModAssembly": "IntroSkipper.dll",
"MinWinchVersion": "alpha-1.4",
"ApplyPatches": true
}
43 changes: 12 additions & 31 deletions Winch/Core/Initializer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CommandTerminal;
using System;
using System.Net.Http;
using System.Text.RegularExpressions;
using UnityEngine;
Expand All @@ -15,20 +16,24 @@ internal static void Initialize()
{
WinchCore.Log.Debug("Initializer started.");

InitializeAssetLoader();
try
{
InitializeAssetLoader();

if(WinchConfig.GetProperty("EnableDeveloperConsole", false))
InitializeDevConsole();
if (WinchConfig.GetProperty("EnableDeveloperConsole", false))
InitializeDevConsole();

DredgeEvent.TriggerManagersLoaded();
DredgeEvent.TriggerManagersLoaded();
}
catch (Exception e)
{
WinchCore.Log.Error($"Failed to initialize mods {e}");
}
}

internal static void InitializePostUnityLoad()
{
InitializeVersionLabel();

if (WinchConfig.GetProperty("CheckForUpdates", true))
CheckForUpdate();
}

private static void InitializeAssetLoader()
Expand Down Expand Up @@ -57,29 +62,5 @@ private static void InitializeDevConsole()
term.AddComponent<Terminal>();
UnityEngine.Object.DontDestroyOnLoad(term);
}

private static readonly HttpClient client = new HttpClient();
private static async void CheckForUpdate()
{
string latestPath = "https://github.com/Hacktix/Winch/releases/latest";
string content = await client.GetStringAsync(latestPath);

Regex titleRegex = new Regex("(?<=<title>)(.*)(?= · Hacktix)");
Match match = titleRegex.Match(content);

string latest = match.Value.Split(' ')[2];

string updateAvailableString;
if (VersionUtil.IsSameOrNewer(VersionUtil.GetComparableVersion(), latest))
{
updateAvailableString = $"Latest version installed";
}
else
{
updateAvailableString = $"Update {latest} available";
}

GameManager.Instance.BuildInfo.BuildNumber += $"\n{updateAvailableString}";
}
}
}
Loading

0 comments on commit bbba7e8

Please sign in to comment.