Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
610cca5ef6 | ||
|
|
d9e01bbf0f | ||
|
|
31cf778524 | ||
|
|
07d2320c71 | ||
|
|
ab0df1ee0d | ||
|
|
74f9e1cf1c | ||
|
|
007c093df4 | ||
|
|
fd208de2db |
@@ -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());
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
Text = "切换公开性",
|
||||
Action = () => PlayerManager.ToggleLobbyPublicity(),
|
||||
Width = 150f,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
Content = () => $"房间类型: {(PlayerManager.IsPublic ? "公开" : "好友可见")}",
|
||||
Width = 200f,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
/// 样式是否已初始化
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user