Skip to content

Commit b06cf7b

Browse files
committed
Add menu support
1 parent 7b4a9e3 commit b06cf7b

File tree

11 files changed

+305
-512
lines changed

11 files changed

+305
-512
lines changed

Store/cs2-store.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.305" />
14-
<PackageReference Include="CS2ScreenMenuAPI" Version="2.9.0" />
13+
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.307" />
14+
<PackageReference Include="CS2MenuManager" Version="1.0.5" />
1515
<PackageReference Include="Daffer" Version="1.0.3" />
1616
<PackageReference Include="MySqlConnector" Version="2.4.0" />
17-
<PackageReference Include="Tomlyn" Version="0.18.0" />
17+
<PackageReference Include="Tomlyn" Version="0.19.0" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

Store/src/command/command.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public static void Command_Credits(CCSPlayerController? player, CommandInfo comm
4545

4646
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)]
4747
public static void Command_Store(CCSPlayerController? player, CommandInfo command) =>
48-
Menu.DisplayStoreMenu(player, false);
48+
MenuBase.DisplayStoreMenu(player, false);
4949

5050
[CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)]
5151
public static void Command_Inv(CCSPlayerController? player, CommandInfo command) =>
52-
Menu.DisplayStoreMenu(player, true);
52+
MenuBase.DisplayStoreMenu(player, true);
5353

5454
[CommandHelper(minArgs: 2, "<name, #userid, all @ commands> <credits>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
5555
[RequiresPermissions("@css/root")]

Store/src/config/config.cs

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using CounterStrikeSharp.API;
22
using CounterStrikeSharp.API.Core;
33
using CounterStrikeSharp.API.Core.Translations;
4+
using CS2MenuManager.API.Menu;
45
using System.Reflection;
56
using System.Text.Json;
67
using System.Text.Json.Serialization;
@@ -216,4 +217,13 @@ public class Config_Settings
216217
public bool DefaultModelDisableLeg { get; set; } = false;
217218
public string Model0Model1Flag { get; set; } = "@css/root";
218219
}
220+
221+
public static readonly Dictionary<string, Type> MenuTypes = new()
222+
{
223+
{ "CenterHtmlMenu", typeof(CenterHtmlMenu) },
224+
{ "ConsoleMenu", typeof(ConsoleMenu) },
225+
{ "ChatMenu", typeof(ChatMenu) },
226+
{ "ScreenMenu", typeof(ScreenMenu) },
227+
{ "WasdMenu", typeof(WasdMenu) }
228+
};
219229
}

Store/src/cs2-store.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using CounterStrikeSharp.API;
22
using CounterStrikeSharp.API.Core;
33
using CounterStrikeSharp.API.Core.Capabilities;
4-
using CS2ScreenMenuAPI;
4+
using CS2MenuManager.API.Class;
55
using StoreApi;
66
using System.Text.Json;
77
using static StoreApi.Store;
@@ -11,7 +11,7 @@ namespace Store;
1111
public class Store : BasePlugin, IPluginConfig<Item_Config>
1212
{
1313
public override string ModuleName => "Store";
14-
public override string ModuleVersion => "2.2";
14+
public override string ModuleVersion => "2.3";
1515
public override string ModuleAuthor => "schwarper";
1616

1717
public Item_Config Config { get; set; } = new();
@@ -66,7 +66,7 @@ public override void Load(bool hotReload)
6666
Database.LoadPlayer(player);
6767

6868
if (screenMenuNames.Contains(Config_Config.Config.Menu.MenuType))
69-
MenuAPI.CloseActiveMenu(player);
69+
MenuManager.CloseActiveMenu(player, CS2MenuManager.API.Enum.CloseMenuAction.Close);
7070
});
7171
}
7272
}
@@ -78,7 +78,7 @@ public override void Unload(bool hotReload)
7878

7979
HashSet<string> screenMenuNames = ["worldtext", "screen", "screenmenu"];
8080
if (screenMenuNames.Contains(Config_Config.Config.Menu.MenuType))
81-
Utilities.GetPlayers().ForEach(MenuAPI.CloseActiveMenu);
81+
Utilities.GetPlayers().ForEach((player) => MenuManager.CloseActiveMenu(player, CS2MenuManager.API.Enum.CloseMenuAction.Close));
8282
}
8383

8484
public override void OnAllPluginsLoaded(bool hotReload)

Store/src/item/item.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public static bool PlayerHas(CCSPlayerController player, string type, string uni
213213
if (!ignoreVip && IsPlayerVip(player)) return true;
214214

215215
item.TryGetValue("flag", out string? flag);
216-
return Menu.CheckFlag(player, flag, false) || Instance.GlobalStorePlayerItems.Any(p => p.SteamID == player.SteamID && p.Type == type && p.UniqueId == uniqueId);
216+
return MenuBase.CheckFlag(player, flag, false) || Instance.GlobalStorePlayerItems.Any(p => p.SteamID == player.SteamID && p.Type == type && p.UniqueId == uniqueId);
217217
}
218218

219219
public static bool PlayerUsing(CCSPlayerController player, string type, string uniqueId) =>

Store/src/menu/centermenu.cs

-210
This file was deleted.

0 commit comments

Comments
 (0)