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
64 changes: 64 additions & 0 deletions samples/HelloMenu/HelloMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;

using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;

using CSSUniversalMenuAPI;

namespace HelloMenu;

[MinimumApiVersion(314)]
public sealed class TeamDeathmatchPlugin : BasePlugin
{
public override string ModuleName => "CsGals.TeamDeathmatch";
public override string ModuleDescription => "Team Deathmatch gamemode plugin";
public override string ModuleVersion => Verlite.Version.Full;


[ConsoleCommand("css_hello")]
public void HelloMenu(CCSPlayerController player, CommandInfo info)
{
var menu = UniversalMenu.CreateMenu(player);
menu.Title = "Hello";

var playerItem = menu.CreateItem();
playerItem.Title = "Player";
playerItem.Selected += PlayerItem_Selected;

var aboutItem = menu.CreateItem();
aboutItem.Title = "About";
aboutItem.Selected += AboutItem_Selected;

menu.Display();
}

private void PlayerItem_Selected(IMenuItem menuItem)
{
var player = menuItem.Menu.Player;
player.PrintToChat($"Hello {player.PlayerName}");

// close does not happen implicitly, you need to tell it to close
menuItem.Menu.Close();
}

private void AboutItem_Selected(IMenuItem menuItem)
{
var childMenu = UniversalMenu.CreateMenu(menuItem.Menu);

var authorItem = childMenu.CreateItem();
authorItem.Title = $"Author: Ashleigh Adams";
authorItem.Enabled = false;

var versionItem = childMenu.CreateItem();
versionItem.Title = $"Version: {Verlite.Version.Full}";
versionItem.Enabled = false;

var revItem = childMenu.CreateItem();
revItem.Title = $"Revision: {Verlite.Version.Commit[..8]}";
revItem.Enabled = false;

childMenu.Display();
}
}
10 changes: 10 additions & 0 deletions samples/HelloMenu/HelloMenu.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CSSUniversalMenuApi" Version="0.4.0" ExcludeAssets="runtime" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions samples/HelloMenu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Menu usage sample

Example menu showing usage of CSSUniversalMenuAPI

![](docs/MainMenu.png)
![](docs/ChildMenu.png)

## Build instructions

```sh
dotnet publish -c Release -o artifacts/HelloMenu
```

Binary file added samples/HelloMenu/docs/ChildMenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/HelloMenu/docs/MainMenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.