Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions .github/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ definitions:

build: &build
name: Build
run: dotnet build --configuration Release --no-restore
run: dotnet publish --configuration Release --no-restore

test: &test
name: Test
Expand Down Expand Up @@ -63,18 +63,11 @@ definitions:
run: dotnet nuget push 'artifacts/*.nupkg' -k ${{ secrets.GITHUB_TOKEN }} -s csgals --skip-duplicate --no-symbols

build-css-package: &build-css-package
name: 'Build CSS Package'
name: 'Build CSS Packages'
run: |
src="./src/CSSUniversalMenuAPI/bin/Release/net8.0"
dst="./artifacts/CSSUniversalMenuAPI"
dst_shared="$dst/addons/counterstrikesharp/shared/CSSUniversalMenuAPI"
mkdir -p "$dst_shared"
cp "$src/CSSUniversalMenuAPI.dll" "$dst_shared/"
cp "$src/CSSUniversalMenuAPI.deps.json" "$dst_shared/"
pushd "$dst"
7z a ../CSSUniversalMenuAPI.zip ./
popd
rm -rf "$dst"
bash package.sh



empty: "hi" # fixes the yml parser from messing the last value up

Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore
run: dotnet publish --configuration Release --no-restore

- name: Test
run: dotnet test --configuration Debug --logger GitHubActions -p:CollectCoverage=true
Expand All @@ -58,18 +58,11 @@ jobs:
run: dotnet pack -p:PackageOutputPath="$(pwd)/artifacts" --configuration Release
--no-restore

- name: Build CSS Package
- name: Build CSS Packages
run: |
src="./src/CSSUniversalMenuAPI/bin/Release/net8.0"
dst="./artifacts/CSSUniversalMenuAPI"
dst_shared="$dst/addons/counterstrikesharp/shared/CSSUniversalMenuAPI"
mkdir -p "$dst_shared"
cp "$src/CSSUniversalMenuAPI.dll" "$dst_shared/"
cp "$src/CSSUniversalMenuAPI.deps.json" "$dst_shared/"
pushd "$dst"
7z a ../CSSUniversalMenuAPI.zip ./
popd
rm -rf "$dst"
bash package.sh



- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore
run: dotnet publish --configuration Release --no-restore

- name: Test
run: dotnet test --configuration Debug --logger GitHubActions -p:CollectCoverage=true
Expand All @@ -56,18 +56,11 @@ jobs:
run: dotnet pack -p:PackageOutputPath="$(pwd)/artifacts" --configuration Release
--no-restore

- name: Build CSS Package
- name: Build CSS Packages
run: |
src="./src/CSSUniversalMenuAPI/bin/Release/net8.0"
dst="./artifacts/CSSUniversalMenuAPI"
dst_shared="$dst/addons/counterstrikesharp/shared/CSSUniversalMenuAPI"
mkdir -p "$dst_shared"
cp "$src/CSSUniversalMenuAPI.dll" "$dst_shared/"
cp "$src/CSSUniversalMenuAPI.deps.json" "$dst_shared/"
pushd "$dst"
7z a ../CSSUniversalMenuAPI.zip ./
popd
rm -rf "$dst"
bash package.sh



- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore
run: dotnet publish --configuration Release --no-restore

- name: Test
run: dotnet test --configuration Debug --logger GitHubActions -p:CollectCoverage=true
Expand All @@ -58,18 +58,11 @@ jobs:
run: dotnet pack -p:PackageOutputPath="$(pwd)/artifacts" --configuration Release
--no-restore

- name: Build CSS Package
- name: Build CSS Packages
run: |
src="./src/CSSUniversalMenuAPI/bin/Release/net8.0"
dst="./artifacts/CSSUniversalMenuAPI"
dst_shared="$dst/addons/counterstrikesharp/shared/CSSUniversalMenuAPI"
mkdir -p "$dst_shared"
cp "$src/CSSUniversalMenuAPI.dll" "$dst_shared/"
cp "$src/CSSUniversalMenuAPI.deps.json" "$dst_shared/"
pushd "$dst"
7z a ../CSSUniversalMenuAPI.zip ./
popd
rm -rf "$dst"
bash package.sh



- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand Down
28 changes: 28 additions & 0 deletions CSSUniversalMenuAPI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "tests\UnitTests\UnitTests.csproj", "{A605AB7A-AD18-4C24-B086-9678F071FE5B}"
ProjectSection(ProjectDependencies) = postProject
{2BB5D58A-F186-4B9C-8FE6-DDA31CC791C7} = {2BB5D58A-F186-4B9C-8FE6-DDA31CC791C7}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{12ADA386-60DF-4855-A3AD-D76CB1C3770F}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -20,6 +23,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSSUniversalMenuAPI", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProofOfConcepts", "tests\ProofOfConcepts\ProofOfConcepts.csproj", "{6BDB6BFA-284D-4C47-9095-4BBE83DB6B8A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalMenu.Compat.MenuManagerApi", "src\UniversalMenu.Compat.MenuManagerApi\UniversalMenu.Compat.MenuManagerApi.csproj", "{44AAF649-62D6-1CD8-3F16-028F4D262BE6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalMenu.Driver.ScreenMenuAPI", "src\UniversalMenu.Driver.ScreenMenuAPI\UniversalMenu.Driver.ScreenMenuAPI.csproj", "{E2FD83DD-D7EA-97CA-B6F4-DE2F92E5A00F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Actions", "GitHub Actions", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
ProjectSection(SolutionItems) = preProject
.github\continuous-delivery.yml = .github\continuous-delivery.yml
.github\continuous-integration.yml = .github\continuous-integration.yml
.github\dependabot.yml = .github\dependabot.yml
.github\deploy-release.yml = .github\deploy-release.yml
.github\regenerate-actions.sh = .github\regenerate-actions.sh
.github\shared.yml = .github\shared.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -38,10 +55,21 @@ Global
{6BDB6BFA-284D-4C47-9095-4BBE83DB6B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6BDB6BFA-284D-4C47-9095-4BBE83DB6B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6BDB6BFA-284D-4C47-9095-4BBE83DB6B8A}.Release|Any CPU.Build.0 = Release|Any CPU
{44AAF649-62D6-1CD8-3F16-028F4D262BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44AAF649-62D6-1CD8-3F16-028F4D262BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44AAF649-62D6-1CD8-3F16-028F4D262BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44AAF649-62D6-1CD8-3F16-028F4D262BE6}.Release|Any CPU.Build.0 = Release|Any CPU
{E2FD83DD-D7EA-97CA-B6F4-DE2F92E5A00F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2FD83DD-D7EA-97CA-B6F4-DE2F92E5A00F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2FD83DD-D7EA-97CA-B6F4-DE2F92E5A00F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2FD83DD-D7EA-97CA-B6F4-DE2F92E5A00F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {12ADA386-60DF-4855-A3AD-D76CB1C3770F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C275584F-B754-4C9D-9361-03D343B72607}
EndGlobalSection
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<!-- Meta info -->
<Authors>Ashleigh Adams</Authors>
<RootNamespace>UniversalMenuAPI</RootNamespace>
<IsPackable Condition="'$(IsPackable)' == ''">false</IsPackable>
<!--<PackageIcon>images/packageicon.png</PackageIcon>-->
</PropertyGroup>
<!--
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,19 @@ var menu = API.CreateMenu(player);
menu.AddItem("Test", (menuItem) => Console.WriteLine("Test"));
menu.Display();
```

```mermaid
classDiagram
MenuManagerImpl <-- MenuManagerApi
MenuManagerApi <-- UniversalMenu.Driver.MenuMangerApi
UniversalMenu.Driver.MenuMangerApi <-- CSSUniversalMenuAPI
ScreenMenuImpl <-- ScreenMenuAPI
ScreenMenuAPI <-- UniversalMenu.Driver.ScreenMenuAPI
UniversalMenu.Driver.ScreenMenuAPI <-- CSSUniversalMenuAPI
NativeMenuImpl <-- CSSUniversalMenuAPI
CSSUniversalMenuAPI <-- UniversalMenu.Compat.MenuMangerApi
UniversalMenu.Compat.MenuMangerApi <-- PluginUsingSomeMenuManager
CSSUniversalMenuAPI <-- UniversalMenu.Compat.ScreenMenuAPI
UniversalMenu.Compat.ScreenMenuAPI <-- PluginUsingSomeScreenMenu
CSSUniversalMenuAPI <-- PluginUsingUniversalAPI
```
39 changes: 39 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
set -euf -o pipefail

# build CSSUniversalMenuAPI.zip
dst="./artifacts/CSSUniversalMenuAPI"
dst_shared="$dst/addons/counterstrikesharp/shared"
dst_plugins="$dst/addons/counterstrikesharp/plugins"

# package CSSUniversalMenuAPI
mkdir -p "$dst_shared/CSSUniversalMenuAPI"
src="./src/CSSUniversalMenuAPI/bin/Release/net8.0/publish"
cp -r "$src/." "$dst_shared/CSSUniversalMenuAPI/"

# package UniversalMenu.Compat.MenuManagerApi
mkdir -p "$dst_plugins/UniversalMenu.Compat.MenuManagerApi"
src="./src/UniversalMenu.Compat.MenuManagerApi/bin/Release/net8.0/publish"
cp -r "$src/." "$dst_plugins/UniversalMenu.Compat.MenuManagerApi/"

# zip CSSUniversalMenuAPI.zip
pushd "$dst"
7z a ../CSSUniversalMenuAPI.zip ./
popd
rm -rf "$dst"

# build UniversalMenu.Driver.ScreenMenuAPI.zip
dst="./artifacts/UniversalMenu.Driver.ScreenMenuAPI"
dst_shared="$dst/addons/counterstrikesharp/shared"
dst_plugins="$dst/addons/counterstrikesharp/plugins"

# package UniversalMenu.Driver.ScreenMenuAPI
mkdir -p "$dst_plugins/UniversalMenu.Driver.ScreenMenuAPI"
src="./src/UniversalMenu.Driver.ScreenMenuAPI/bin/Release/net8.0/publish"
cp -r "$src/." "$dst_plugins/UniversalMenu.Driver.ScreenMenuAPI/"

# zip UniversalMenu.Driver.ScreenMenuAPI.zip
pushd "$dst"
7z a ../UniversalMenu.Driver.ScreenMenuAPI.zip ./
popd
rm -rf "$dst"
5 changes: 3 additions & 2 deletions src/CSSUniversalMenuAPI/CSSUniversalMenuAPI.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.316" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.316" ExcludeAssets="runtime" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions src/CSSUniversalMenuAPI/IMenuAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading;

using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Capabilities;

namespace CSSUniversalMenuAPI;

Expand Down Expand Up @@ -37,4 +38,9 @@ public interface IMenuAPI
/// <param name="player">The player of which to query.</param>
/// <returns>Whether the player has an active menu on their screen.</returns>
bool IsMenuOpen(CCSPlayerController player);

/// <summary>
/// Standard helper to get get or provide this implementation
/// </summary>
static readonly PluginCapability<IMenuAPI> PluginCapability = new("universalmenuapi");
}
5 changes: 4 additions & 1 deletion src/CSSUniversalMenuAPI/IMenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public interface IMenuItem
/// The menu that this item belongs to.
/// </summary>
IMenu Menu { get; }
/// <summary>
/// The player this menu item belongs to.
/// </summary>
CCSPlayerController Player => Menu.Player;
/// <summary>
/// The item text to show to the player.
Expand All @@ -21,7 +24,7 @@ public interface IMenuItem
/// <summary>
/// Event raised when this item has been selected.
/// </summary>
event ItemSelectedAction Selected;
event ItemSelectedAction? Selected;
object? Context { get; set; }
}

Expand Down
45 changes: 45 additions & 0 deletions src/UniversalMenu.Compat.MenuManagerApi/MenuManagerCompat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Threading;

using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Core.Capabilities;

using CSSUniversalMenuAPI;

using IMenuManagerAPI = MenuManager.IMenuApi;

namespace UniversalMenu.Compat.MenuManagerApi;

[MinimumApiVersion(314)]
public class MenuManagerCompat : BasePlugin
{
public override string ModuleName => "UniversalMenu.Compat.MenuManagerApi";
public override string ModuleDescription => "Translate MenuManagerApi to CSSUniversalMenuAPI";
public override string ModuleVersion => Verlite.Version.Full;

internal CancellationTokenSource Cts { get; set; } = null!;
private static readonly PluginCapability<IMenuManagerAPI> MenuCapability = new("menu:nfcore");
private MenuManagerTranslator? Instance { get; set; }

public override void Load(bool hotReload)
{
Cts = new CancellationTokenSource();
Capabilities.RegisterPluginCapability(MenuCapability, () =>
{
if (Instance is not null)
return Instance;

var universalAPI = IMenuAPI.PluginCapability.Get()
?? throw new Exception("Unable to find CSSUniversalAPI supporting menu or adapter");
Instance = new MenuManagerTranslator(this, universalAPI);

return Instance;
});
}

public override void Unload(bool hotReload)
{
Cts.Cancel();
}
}
Loading