Skip to content

Commit 445548d

Browse files
committed
fix: Menu optimization, better performance
1 parent 69e9c30 commit 445548d

7 files changed

Lines changed: 23 additions & 24 deletions

File tree

CS2ScreenMenuAPI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1111
<Configuration>Release</Configuration>
1212
<DebugType>none</DebugType>
13-
<Version>2.6.0</Version>
1413
</PropertyGroup>
1514

1615
<ItemGroup>
1716
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.305" />
17+
<PackageReference Include="Newtonsoft.json" Version="13.0.3" />
1818
<PackageReference Include="System.Drawing.Common" Version="9.0.2" />
1919
</ItemGroup>
2020

Extensions/Extensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,10 @@ public static QAngle GetAngles(this CPointWorldText entity)
9494
}
9595
return new QAngle();
9696
}
97+
public static void SetColor(this CPointWorldText worldText, string color)
98+
{
99+
worldText.AcceptInput("SetColor", worldText, worldText, $"{color}");
100+
Utilities.SetStateChanged(worldText, "CPointWorldText", "m_Color");
101+
}
97102
}
98103
}

Interfaces/IMenuInstance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CounterStrikeSharp.API.Core;
1+
using CounterStrikeSharp.API.Core;
22

33
namespace CS2ScreenMenuAPI.Interfaces
44
{

Interfaces/IMenuOption.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using CounterStrikeSharp.API.Core;
1+
using CounterStrikeSharp.API.Core;
2+
using CS2ScreenMenuAPI.Internal;
23

34
namespace CS2ScreenMenuAPI
45
{

Interfaces/IScreenMenu.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +0,0 @@
1-
using System.Drawing;
2-
using CounterStrikeSharp.API.Core;
3-
4-
namespace CS2ScreenMenuAPI.Interfaces
5-
{
6-
public interface IScreenMenu
7-
{
8-
string Title { get; set; }
9-
Color TextColor { get; set; }
10-
string FontName { get; set; }
11-
bool IsSubMenu { get; set; }
12-
bool HasExitOption { get; set; }
13-
IScreenMenu? ParentMenu { get; set; }
14-
void AddOption(string text, Action<CCSPlayerController, IMenuOption> callback, bool disabled);
15-
void Open(CCSPlayerController player);
16-
}
17-
}

Internal/MenuOption.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
using CounterStrikeSharp.API.Core;
2+
using CS2ScreenMenuAPI.Interfaces;
23

34
namespace CS2ScreenMenuAPI.Internal
45
{
5-
internal class MenuOption(string text, Action<CCSPlayerController, IMenuOption> onSelect, bool disabled = false) : IMenuOption
6+
internal class MenuOption : IMenuOption
67
{
7-
public string Text { get; set; } = text;
8-
public bool Disabled { get; set; } = disabled;
9-
public Action<CCSPlayerController, IMenuOption> OnSelect { get; set; } = onSelect;
8+
public string Text { get; set; }
9+
public bool Disabled { get; set; }
10+
public Action<CCSPlayerController, IMenuOption> OnSelect { get; set; }
11+
public ScreenMenu? SubMenu { get; set; }
12+
13+
public MenuOption(string text, Action<CCSPlayerController, IMenuOption> onSelect, bool disabled = false)
14+
{
15+
Text = text;
16+
OnSelect = onSelect;
17+
Disabled = disabled;
18+
SubMenu = null;
19+
}
1020
}
1121
}

Newtonsoft.Json.dll

696 KB
Binary file not shown.

0 commit comments

Comments
 (0)