Skip to content

Commit af5aa09

Browse files
authored
v1.2.1 (#7)
Initialise SteamLobbyMetadataHandler on mod init instead of lazy loading Add IsBepinexBuild info field to assembly
2 parents 8aba409 + 0115c23 commit af5aa09

File tree

6 files changed

+58
-9
lines changed

6 files changed

+58
-9
lines changed

ShopAPI.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
<PackagePath>\</PackagePath>
7878
</None>
7979
</ItemGroup>
80+
81+
<ItemGroup>
82+
<AdditionalThisAssemblyFields Condition="'$(Configuration)'=='Modman'" Include="IsBepinexBuild" Boolean="true" />
83+
<AdditionalThisAssemblyFields Condition="'$(Configuration)'!='Modman'" Include="IsBepinexBuild" Boolean="false" />
84+
</ItemGroup>
8085

8186
<ItemGroup>
8287
<!-- Mod Package assets -->
@@ -98,9 +103,8 @@
98103

99104
<!-- Deploy full Steam-Release build and files to vanilla local plugins dir for Workshop publish -->
100105
<Target Condition="'$(Configuration)'=='Release'" Name="CopyReleaseVanillaPlugin" AfterTargets="Build">
101-
<!--
102-
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).dll;@(SharedFiles);@(SteamFiles)" DestinationFolder="$(OutputPath)\Publish" />
103-
-->
106+
<!-- Create SteamCMD publish package -->
107+
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).dll;@(SharedFiles)" DestinationFolder="$(OutputPath)\Publish" />
104108
<!-- Clear Steam Workshop deploy folder -->
105109
<RemoveDir Directories="$(CWPluginOutputPath)" />
106110
<Message Text="Cleaned $(CWPluginOutputPath)" Importance="high" />

ShopApiPlugin.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ public class ShopApiPlugin
2222
#if STEAM
2323
static ShopApiPlugin()
2424
{
25+
SteamLobbyMetadataHandler.RegisterSteamworksCallbacks();
2526
Debug.Log($"{MOD_GUID} initialised via the vanilla mod loader.");
2627
}
2728
#elif MODMAN
2829
private Harmony harmony = new Harmony(MOD_GUID);
2930
void Awake()
3031
{
3132
harmony.PatchAll();
33+
SteamLobbyMetadataHandler.RegisterSteamworksCallbacks();
3234
Debug.Log($"{MOD_GUID} initialised via BepInEx mod loader.");
3335
}
3436
#endif

SteamLobbyMetadataHandler.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
using Steamworks;
2-
using UnityEngine;
32

43
namespace ContentWarningShop
54
{
65
internal static class SteamLobbyMetadataHandler
76
{
7+
private static bool _initialised = false;
8+
89
private static Callback<LobbyCreated_t> cb_onLobbyCreated;
910
private static Callback<LobbyEnter_t> cb_onLobbyEntered;
1011
private static Callback<LobbyDataUpdate_t> cb_onLobbyDataUpdate;
1112
//
1213
internal static event Action? OnLobbyJoined;
1314
internal static event Action? OnLobbyCreated;
1415
internal static event Action? OnLobbyDataUpdate;
15-
16+
/// <summary>
17+
/// The ID of the current lobby, if we are in one.
18+
/// </summary>
19+
/// <remarks>
20+
/// Cleared automatically in <see cref="ShopAPI.Patches.SteamLobbyHandlerPatch.LeaveLobby"/> patch whenever the player clicks Leave.
21+
/// </remarks>
1622
internal static CSteamID CurrentLobby = CSteamID.Nil;
17-
// GetLobbyOwner returns nil if the current lobby is invalid / we are not in it
18-
internal static bool InLobby => SteamMatchmaking.GetLobbyOwner(CurrentLobby) != CSteamID.Nil;
23+
24+
internal static bool InLobby => CurrentLobby != CSteamID.Nil;
1925
internal static bool IsHost => SteamMatchmaking.GetLobbyOwner(CurrentLobby) == SteamUser.GetSteamID();
2026

21-
static SteamLobbyMetadataHandler()
27+
internal static void RegisterSteamworksCallbacks()
2228
{
29+
if (_initialised) return;
30+
2331
cb_onLobbyCreated = Callback<LobbyCreated_t>.Create(Steam_LobbyCreated);
2432
cb_onLobbyEntered = Callback<LobbyEnter_t>.Create(Steam_LobbyEntered);
2533
cb_onLobbyDataUpdate = Callback<LobbyDataUpdate_t>.Create(Steam_LobbyDataUpdated);
34+
35+
_initialised = true;
2636
}
2737

2838
private static void Steam_LobbyCreated(LobbyCreated_t e)

publish/common/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes will be documented in this file.
44
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
7+
## 1.2.1
8+
- Steamworks events are now immediately subscribed on plugin initialisation, instead of on first item registration
9+
610
## 1.2.0
711
- DLLs are now correctly versioned
812
- Added default value constructor to SynchronisedMetadata

publish/thunderstore/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ShopAPI",
3-
"version_number": "1.2.0",
3+
"version_number": "1.2.1",
44
"website_url": "https://github.com/Xerren09/ContentWarningShopAPI",
55
"description": "Exposes an easy-to-use API to add custom items to the in-game shop.",
66
"dependencies": [

workshop.vdf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"workshopitem"
2+
{
3+
"appid" "2881650"
4+
"publishedfileid" "3408837293"
5+
"contentfolder" "D:\Code\GitHub\ContentWarningShopAPI\bin\Release\netstandard2.1\Publish"
6+
"previewfile" "D:\Code\GitHub\ContentWarningShopAPI\publish\steam\preview.png"
7+
"visibility" "0"
8+
"title" "ShopAPI"
9+
"description" "Exposes an easy-to-use API to add custom items to the in-game shop.
10+
11+
[i][b]This mod is meant for other mod developers, and does not add any extra content on its own.[/b][/i]
12+
13+
[h2]For players[/h2]
14+
[b] This mod needs to be first in your Load Order so other mods that depend on it will work.[/b]
15+
If you are experiencing issues:
16+
[list]
17+
[*]Go to your Steam Library
18+
[*]Right click Content Warning
19+
[*]Click "Properties"
20+
[*]Select "Workshop" on the right-hand side
21+
[*]Drag "ShopAPI" to the top of the list
22+
[/list]
23+
24+
[h2]For developers[/h2]
25+
Source and instructions are available at the mod's repository: [url=https://github.com/Xerren09/ContentWarningShopAPI] https://github.com/Xerren09/ContentWarningShopAPI [/url]
26+
27+
If you run into any problems, please open an new Issue on GitHub.
28+
"
29+
}

0 commit comments

Comments
 (0)