8 Commits

Author SHA1 Message Date
Yue-bin
610cca5ef6 chore(PlayerManager): 更新插件版本号从4.0.1到4.0.2
Some checks failed
Publish Release / build (push) Failing after 5m16s
- 将stick.plugins.playermanager.csproj中的版本号从4.0.1升级到4.0.2
2026-05-07 04:54:19 +08:00
Yue-bin
d9e01bbf0f fix(PlayerManager): 修复房间公开性判断逻辑
- 移除HostLeverHandler依赖,直接通过MatchmakingHandler.LobbyType判断房间是否公开
- 修复LobbyType切换时的目标类型逻辑错误,现在正确地将公开房间设为ELobbyType.k_ELobbyTypePublic,
  私有房间设为ELobbyType.k_ELobbyTypeFriendsOnly
- 移除PlayerManagerGUI.InitializeStyles()调用,该方法已被默认组件注册替代
2026-05-07 04:53:36 +08:00
Yue-bin
31cf778524 refactor(Gui): 移除废弃样式引用并优化玩家信息按钮样式处理
移除了多个内部组件中的废弃XML文档注释和未使用的CommonButtonStyle引用,
为PlayerInfoButton添加了动态样式管理机制以替代静态样式引用。
2026-05-07 04:53:22 +08:00
Yue-bin
07d2320c71 refactor(gui): 将公开的GUI样式字段改为私有并优化样式管理
将PlayerManagerGUI中的公开静态样式字段改为私有访问修饰符,
同时为Widget组件添加默认样式属性,统一管理UI控件的外观,
提高代码封装性和样式的一致性
2026-05-07 04:53:09 +08:00
Yue-bin
ab0df1ee0d chore(playermanager): 更新版本号
All checks were successful
Publish Release / build (push) Successful in 2m3s
更新 stick.plugins.playermanager.csproj 中的版本号从 4.0.0 到 4.0.1,
以反映最新的发布版本。
2026-05-07 04:32:01 +08:00
Yue-bin
74f9e1cf1c fix(Gui): 修正LayoutCursor行进逻辑
BeginRow方法现在正确地推进到下一行,并重置列位置到OffsetX,
对齐原来的GetNewYPosition()行为。EndRow方法仅重置列位置而不行进,
下一行由BeginRow方法推进,使行进逻辑更加清晰明确。
2026-05-07 04:31:25 +08:00
Yue-bin
007c093df4 fix(Gui): 房间公开性组件不显示在同一行
- 创建List集合管理房间公开性相关的widgets
- 将房间公开性标签和按钮合并到同一个HeaderRow中
- 添加条件判断只在有相关widgets时才注册HeaderRow
- 使label和button可以在同一行独立配置显示
2026-05-07 04:31:17 +08:00
Yue-bin
fd208de2db fix(PlayerManager): 样式未被正确初始化
将PlayerManagerGUI.InitializeStyles()方法的访问修饰符从private改为internal,
并在插件启动时调用此方法来初始化GUI样式。
2026-05-07 04:30:39 +08:00
12 changed files with 110 additions and 76 deletions

View File

@@ -1,3 +1,5 @@
using System.Collections.Generic;
namespace stick.plugins.playermanager.Gui;
/// <summary>
@@ -9,12 +11,22 @@ public static class DefaultWidgets
{
public static void RegisterAll()
{
// Header 组件
// Header房间公开性行label + button 在同一行,各自独立可配置)
var publicityWidgets = new List<IHeaderWidget>();
if (PlayerManager.ShowRoomPublicityLabel.Value)
RegisterManager.RegisterHeaderRow(InternalWidgets.RoomPublicityLabel.Create());
publicityWidgets.Add(InternalWidgets.RoomPublicityLabel.Create());
if (PlayerManager.ShowRoomPublicityButton.Value)
RegisterManager.RegisterHeaderRow(InternalWidgets.RoomPublicityButton.Create());
publicityWidgets.Add(InternalWidgets.RoomPublicityButton.Create());
if (publicityWidgets.Count > 0)
{
RegisterManager.RegisterHeaderRow(new HeaderRow
{
Name = "RoomPublicity",
Condition = () => PlayerManager.IsHost(PlayerManager.LocalPlayer),
Children = publicityWidgets,
});
}
// 玩家行组件(始终注册)
RegisterManager.RegisterPlayerRow(InternalWidgets.PlayerInfoButton.Create());

View File

@@ -2,9 +2,6 @@ using MultiplayerBasicExample;
namespace stick.plugins.playermanager.Gui.InternalWidgets;
/// <summary>
/// 踢人按钮的纯工厂
/// </summary>
public static class KickButton
{
public static IPlayerRowWidget Create()
@@ -19,7 +16,6 @@ public static class KickButton
OnClick = player =>
PlayerManager.KickPlayer(player.SteamId, MultiplayerManager.KickResponse.DidNotRecievePackages),
Width = 100f,
Style = PlayerManagerGUI.CommonButtonStyle,
};
}
}

View File

@@ -1,8 +1,5 @@
namespace stick.plugins.playermanager.Gui.InternalWidgets;
/// <summary>
/// 曾用名切换按钮的纯工厂
/// </summary>
public static class NameToggleButton
{
public static IPlayerRowWidget Create()
@@ -14,7 +11,6 @@ public static class NameToggleButton
GetText = player => player.DisplayNameRecorded ? "显示现用名" : "显示曾用名",
OnClick = player => player.DisplayNameRecorded = !player.DisplayNameRecorded,
Width = 120f,
Style = PlayerManagerGUI.CommonButtonStyle,
};
}
}

View File

@@ -1,15 +1,28 @@
using Steamworks;
using UnityEngine;
using stick.plugins.playermanager.Recorder;
using static stick.plugins.playermanager.Gui.PlayerManagerGUI;
namespace stick.plugins.playermanager.Gui.InternalWidgets;
/// <summary>
/// 玩家信息按钮的纯工厂
/// </summary>
public static class PlayerInfoButton
{
private static GUIStyle _redStyle;
private static GUIStyle _yellowStyle;
private static GUIStyle _greenStyle;
private static GUIStyle _normalStyle;
private static void EnsureStyles()
{
if (_normalStyle != null) return;
_normalStyle = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
_yellowStyle = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
_yellowStyle.normal.textColor = Color.yellow;
_redStyle = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
_redStyle.normal.textColor = Color.red;
_greenStyle = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
_greenStyle.normal.textColor = Color.green;
}
public static IPlayerRowWidget Create()
{
return new PlayerRowButtonWidget
@@ -22,11 +35,15 @@ public static class PlayerInfoButton
SteamFriends.ActivateGameOverlayToUser("steamid", player.SteamId);
},
Width = 500f,
GetStyle = player => player.RecordStatus switch
GetStyle = player =>
{
PlayerRecordStatus.Blacklisted => RedButtonStyle,
PlayerRecordStatus.Recorded => YellowButtonStyle,
_ => player.IsFriend ? GreenButtonStyle : CommonButtonStyle,
EnsureStyles();
return player.RecordStatus switch
{
PlayerRecordStatus.Blacklisted => _redStyle,
PlayerRecordStatus.Recorded => _yellowStyle,
_ => player.IsFriend ? _greenStyle : _normalStyle,
};
},
};
}

View File

@@ -3,9 +3,6 @@ using stick.plugins.playermanager.Recorder;
namespace stick.plugins.playermanager.Gui.InternalWidgets;
/// <summary>
/// 记录/拉黑按钮的纯工厂
/// </summary>
public static class RecordButton
{
public static IPlayerRowWidget Create()
@@ -41,7 +38,6 @@ public static class RecordButton
PlayerManager.OnLobbyMembersChanged();
},
Width = 100f,
Style = PlayerManagerGUI.CommonButtonStyle,
};
}
}

View File

@@ -1,29 +1,15 @@
using static stick.plugins.playermanager.Gui.PlayerManagerGUI;
namespace stick.plugins.playermanager.Gui.InternalWidgets;
/// <summary>
/// 切换公开性按钮的纯工厂
/// </summary>
public static class RoomPublicityButton
{
public static IHeaderRow Create()
public static IHeaderWidget Create()
{
return new HeaderRow
return new HeaderButtonWidget
{
Name = "RoomPublicityButton",
Condition = () => PlayerManager.IsHost(PlayerManager.LocalPlayer),
Children =
{
new HeaderButtonWidget
{
Name = "RoomPublicityButton.Content",
Text = "切换公开性",
Action = () => PlayerManager.ToggleLobbyPublicity(),
Width = 150f,
Style = CommonButtonStyle,
},
},
};
}
}

View File

@@ -1,28 +1,14 @@
using static stick.plugins.playermanager.Gui.PlayerManagerGUI;
namespace stick.plugins.playermanager.Gui.InternalWidgets;
/// <summary>
/// 房间类型标签的纯工厂
/// </summary>
public static class RoomPublicityLabel
{
public static IHeaderRow Create()
public static IHeaderWidget Create()
{
return new HeaderRow
return new HeaderLabelWidget
{
Name = "RoomPublicityLabel",
Condition = () => PlayerManager.IsHost(PlayerManager.LocalPlayer),
Children =
{
new HeaderLabelWidget
{
Name = "RoomPublicityLabel.Content",
Content = () => $"房间类型: {(PlayerManager.IsPublic ? "" : "")}",
Width = 200f,
Style = TitleStyle,
},
},
};
}
}

View File

@@ -42,10 +42,12 @@ public class LayoutCursor
}
/// <summary>
/// 开始新的一行,重置列位置到 OffsetX
/// 开始新的一行,推进到下一行并重置列位置到 OffsetX
/// 对齐原来的 GetNewYPosition() 行为
/// </summary>
public void BeginRow()
{
_currentLine++;
_currentX = OffsetX;
}
@@ -62,11 +64,10 @@ public class LayoutCursor
}
/// <summary>
/// 结束当前行,移动到下一行
/// 结束当前行,仅重置列位置(不行进,下一行由 BeginRow 推进)
/// </summary>
public void EndRow()
{
_currentLine++;
_currentX = OffsetX;
}

View File

@@ -37,27 +37,27 @@ public static class PlayerManagerGUI
/// <summary>
/// 标题样式
/// </summary>
internal static GUIStyle TitleStyle;
private static GUIStyle TitleStyle;
/// <summary>
/// 普通按钮样式
/// </summary>
internal static GUIStyle CommonButtonStyle;
private static GUIStyle CommonButtonStyle;
/// <summary>
/// 黄色按钮样式(已记录玩家)
/// </summary>
internal static GUIStyle YellowButtonStyle;
private static GUIStyle YellowButtonStyle;
/// <summary>
/// 红色按钮样式(黑名单玩家)
/// </summary>
internal static GUIStyle RedButtonStyle;
private static GUIStyle RedButtonStyle;
/// <summary>
/// 绿色按钮样式(好友)
/// </summary>
internal static GUIStyle GreenButtonStyle;
private static GUIStyle GreenButtonStyle;
/// <summary>
/// 样式是否已初始化

View File

@@ -96,6 +96,17 @@ public interface IPlayerRowWidget
/// </summary>
public class HeaderLabelWidget : IHeaderWidget
{
private static GUIStyle _defaultStyle;
private static GUIStyle DefaultStyle
{
get
{
if (_defaultStyle == null)
_defaultStyle = new GUIStyle(GUI.skin.label) { fontSize = 22 };
return _defaultStyle;
}
}
public string Name { get; set; }
public Func<bool> Condition { get; set; }
public Func<string> Content { get; set; }
@@ -106,7 +117,7 @@ public class HeaderLabelWidget : IHeaderWidget
public void Draw(Rect rect)
{
GUI.Label(rect, Content?.Invoke() ?? string.Empty, Style ?? GUI.skin.label);
GUI.Label(rect, Content?.Invoke() ?? string.Empty, Style ?? DefaultStyle);
}
}
@@ -115,6 +126,17 @@ public class HeaderLabelWidget : IHeaderWidget
/// </summary>
public class HeaderButtonWidget : IHeaderWidget
{
private static GUIStyle _defaultStyle;
private static GUIStyle DefaultStyle
{
get
{
if (_defaultStyle == null)
_defaultStyle = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
return _defaultStyle;
}
}
public string Name { get; set; }
public Func<bool> Condition { get; set; }
public string Text { get; set; }
@@ -126,7 +148,7 @@ public class HeaderButtonWidget : IHeaderWidget
public void Draw(Rect rect)
{
if (GUI.Button(rect, Text ?? string.Empty, Style ?? GUI.skin.button))
if (GUI.Button(rect, Text ?? string.Empty, Style ?? DefaultStyle))
Action?.Invoke();
}
}
@@ -159,6 +181,17 @@ public class HeaderRow : IHeaderRow
/// </summary>
public class PlayerRowButtonWidget : IPlayerRowWidget
{
private static GUIStyle _defaultStyle;
private static GUIStyle DefaultStyle
{
get
{
if (_defaultStyle == null)
_defaultStyle = new GUIStyle(GUI.skin.button) { fontSize = 22, richText = false };
return _defaultStyle;
}
}
public string Name { get; set; }
public Func<PlayerInfo, bool> Condition { get; set; }
public Func<PlayerInfo, string> GetText { get; set; }
@@ -179,7 +212,7 @@ public class PlayerRowButtonWidget : IPlayerRowWidget
public void Draw(Rect rect, PlayerInfo player)
{
GUIStyle style = GetStyle?.Invoke(player) ?? Style ?? GUI.skin.button;
GUIStyle style = GetStyle?.Invoke(player) ?? Style ?? DefaultStyle;
if (GUI.Button(rect, GetText?.Invoke(player) ?? string.Empty, style))
OnClick?.Invoke(player);
}
@@ -190,6 +223,17 @@ public class PlayerRowButtonWidget : IPlayerRowWidget
/// </summary>
public class PlayerRowLabelWidget : IPlayerRowWidget
{
private static GUIStyle _defaultStyle;
private static GUIStyle DefaultStyle
{
get
{
if (_defaultStyle == null)
_defaultStyle = new GUIStyle(GUI.skin.label) { fontSize = 22 };
return _defaultStyle;
}
}
public string Name { get; set; }
public Func<PlayerInfo, bool> Condition { get; set; }
public Func<PlayerInfo, string> GetText { get; set; }
@@ -200,7 +244,7 @@ public class PlayerRowLabelWidget : IPlayerRowWidget
public void Draw(Rect rect, PlayerInfo player)
{
GUI.Label(rect, GetText?.Invoke(player) ?? string.Empty, Style ?? GUI.skin.label);
GUI.Label(rect, GetText?.Invoke(player) ?? string.Empty, Style ?? DefaultStyle);
}
}

View File

@@ -125,7 +125,7 @@ public class PlayerManager : BaseUnityPlugin
/// <summary>
/// 房间公开性
/// </summary>
public static bool IsPublic => HostLeverHandler?.isOn ?? MatchmakingHandler.LobbyType == ELobbyType.k_ELobbyTypePublic;
public static bool IsPublic => MatchmakingHandler.LobbyType == ELobbyType.k_ELobbyTypePublic;
/// <summary>
/// 当前大厅ID
@@ -297,7 +297,7 @@ public class PlayerManager : BaseUnityPlugin
{
if (MultiplayerManager.IsServer)
{
var targetType = IsPublic ? ELobbyType.k_ELobbyTypePublic : ELobbyType.k_ELobbyTypeFriendsOnly;
var targetType = IsPublic ? ELobbyType.k_ELobbyTypeFriendsOnly : ELobbyType.k_ELobbyTypePublic;
MatchmakingHandler.SetNewLobbyType(targetType);
RawChangeLobbyTypeMI.Invoke(MatchmakingHandler, [targetType]);
}

View File

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