6 Commits

Author SHA1 Message Date
Yue-bin
8b5e3c33d2 chore(PlayerManager): 更新版本号从4.0.7到4.0.8
All checks were successful
Publish Release / build (push) Successful in 36s
- 将项目版本号从4.0.7升级至4.0.8
- 保持其他配置不变
2026-06-22 05:44:30 +08:00
Yue-bin
079716cc85 docs: 添加4.0.8更新说明 2026-06-22 05:44:17 +08:00
Yue-bin
04337028b3 fix(PlayerManagerGUI): 修复空SteamId导致的异常
当玩家列表中的成员SteamId无效时跳过绘制,
避免因空值引起的运行时错误。
2026-06-22 05:41:14 +08:00
Yue-bin
6b9910486b feat(Gui): 添加玩家管理界面的widget绘制优化功能
- 引入HashSet来记录需要忽略的widget,避免不必要的绘制操作
- 实现widget可见性检查逻辑,当widget对所有玩家都不需要绘制时将其加入忽略列表
- 修改玩家行绘制循环,跳过被标记为忽略的widget以提升性能
- 优化列位置推进逻辑,仅在widget未被忽略时才进行占位推进
2026-06-22 05:36:59 +08:00
Yue-bin
c320a07370 fix(PlayerManager): 修复大厅成员变更时未触发更新的问题
当请求大厅列表后,添加调用OnLobbyMembersChanged()方法来确保
大厅成员信息能够正确更新和显示。
2026-06-22 05:26:30 +08:00
Yue-bin
a0d1386712 feat(PlayerManager): 添加房间所有权转让功能
添加了转让房主按钮,允许房主将房间所有权转移给其他玩家。
- 在GUI中新增TransButton组件,用于转让房主功能
- 添加ShowTransButton配置项控制按钮显示
- 实现TransferLobbyOwnership方法处理房主转让逻辑
- 默认启用转让按钮显示
2026-06-22 05:02:26 +08:00
6 changed files with 90 additions and 8 deletions

View File

@@ -41,6 +41,9 @@ public static class DefaultWidgets
if (PlayerManager.ShowNameToggleButton.Value)
RegisterManager.RegisterPlayerRow(InternalWidgets.NameToggleButton.Create());
if (PlayerManager.ShowTransButton.Value)
RegisterManager.RegisterPlayerRow(InternalWidgets.TransButton.Create());
if (PlayerManager.ShowMuteButton.Value)
RegisterManager.RegisterPlayerRow(InternalWidgets.MuteButton.Create());
if (PlayerManager.ShowAddFriendButton.Value)

View File

@@ -0,0 +1,21 @@
using MultiplayerBasicExample;
namespace stick.plugins.playermanager.Gui.InternalWidgets;
public static class TransButton
{
public static IPlayerRowWidget Create()
{
return new PlayerRowButtonWidget
{
Name = "Trans Host",
Condition = player =>
PlayerManager.IsHost(PlayerManager.LocalPlayer)
&& !PlayerManager.IsLocalPlayer(player),
GetText = _ => "转让",
OnClick = player =>
PlayerManager.TransferLobbyOwnership(player),
Width = 100f,
};
}
}

View File

@@ -3,6 +3,7 @@ using MultiplayerBasicExample;
using Steamworks;
using UnityEngine;
using stick.plugins.playermanager.Recorder;
using System.Collections.Generic;
namespace stick.plugins.playermanager.Gui;
@@ -30,6 +31,11 @@ public static class PlayerManagerGUI
/// </summary>
private static readonly LayoutCursor Cursor = new();
/// <summary>
/// 记录该行widget是否该绘制
/// </summary>
private static readonly HashSet<IPlayerRowWidget> IgnoreWidgets = [];
#endregion
#region
@@ -89,10 +95,29 @@ public static class PlayerManagerGUI
Cursor.EndRow();
}
// 玩家行区域:每玩家一行,行内横向迭代注册的 PlayerRowWidget
for (int i = 0; i < PlayerManager.lobbyMemberList.Count; i++)
IgnoreWidgets.Clear();
// 如果一个widget对所有玩家都不需要绘制则忽略
foreach (var widget in RegisterManager.PlayerRowWidgets)
{
bool shouldDraw = false;
foreach (var member in PlayerManager.lobbyMemberList)
{
if (!member.SteamId.IsValid()) continue;
if (widget.ShouldDraw(member))
{
shouldDraw = true;
break;
}
}
if (!shouldDraw)
IgnoreWidgets.Add(widget);
}
// 玩家行区域:每玩家一行,行内横向迭代注册的 PlayerRowWidget
foreach (var member in PlayerManager.lobbyMemberList)
{
PlayerInfo member = PlayerManager.lobbyMemberList[i];
if (!member.SteamId.IsValid()) continue;
Cursor.BeginRow();
@@ -101,7 +126,8 @@ public static class PlayerManagerGUI
if (widget.ShouldDraw(member))
widget.Draw(Cursor.NextColumn(widget.Width, 40f), member);
else
Cursor.NextColumn(widget.Width, 40f); // 占位推进列位置
if (!IgnoreWidgets.Contains(widget))
Cursor.NextColumn(widget.Width, 40f); // 占位推进列位置对齐
}
Cursor.EndRow();
}

View File

@@ -39,6 +39,11 @@ public class PlayerManager : BaseUnityPlugin
/// </summary>
internal static ConfigEntry<bool> ShowKickButton;
/// <summary>
/// 是否显示转让按钮
/// </summary>
internal static ConfigEntry<bool> ShowTransButton;
/// <summary>
/// 是否显示记录/拉黑按钮
/// </summary>
@@ -244,6 +249,13 @@ public class PlayerManager : BaseUnityPlugin
"是否显示踢人按钮"
);
ShowTransButton = Config.Bind(
"GUI",
"ShowTransButton",
true,
"是否显示转让按钮"
);
ShowRecordButton = Config.Bind(
"GUI",
"ShowRecordButton",
@@ -326,6 +338,7 @@ public class PlayerManager : BaseUnityPlugin
else
{
RequestLobbyList();
OnLobbyMembersChanged();
PlayerManagerGUI.ShowLobbyInfo = true;
Debug.Log("大厅信息界面已打开");
}
@@ -334,6 +347,19 @@ public class PlayerManager : BaseUnityPlugin
#region
/// <summary>
/// 转让房主
/// </summary>
/// <param name="targetPlayer">目标玩家</param>
/// <returns></returns>
public static void TransferLobbyOwnership(PlayerInfo targetPlayer)
{
if (targetPlayer != null && targetPlayer != LocalPlayer)
{
SteamMatchmaking.SetLobbyOwner(CurrentLobbyID, targetPlayer.SteamId);
}
}
/// <summary>
/// 通过SteamID获取NetworkSpawnID
/// </summary>

View File

@@ -5,6 +5,7 @@
## 功能
- 房间查找
- 转让房主
- 玩家记录
- 被记录的玩家显示为黄名
- 是steam好友的玩家显示为绿名优先级更高
@@ -23,6 +24,11 @@
## 更新日志
### v4.0.8
1. 添加了转让房主功能
2. 现在如果某个按钮(行组件)对所有人都不显示,则不留空
### v4.0.7
1. 现在点击大厅列表中的按钮进入大厅会在列表中将该大厅用灰色样式标识,标记已进入过

View File

@@ -4,7 +4,7 @@
<TargetFramework>net35</TargetFramework>
<AssemblyName>stick.plugins.playermanager</AssemblyName>
<Product>PlayerManager</Product>
<Version>4.0.7</Version>
<Version>4.0.8</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>