Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3c2b225
refactor: ModEvent.cs
LuLu-ling Jun 12, 2026
72d51bd
rename
LuLu-ling Jun 12, 2026
cd97c11
refactor: simplify array initialization and method calls in CustomEve…
LuLu-ling Jun 12, 2026
bd4888e
refactor: remove unused using directives in event-related files
LuLu-ling Jun 12, 2026
ac1e00f
refactor: remove null-coalescing operator and simplify array initiali…
LuLu-ling Jun 12, 2026
80e1238
refactor: enhance CustomEvent.cs with additional action methods and i…
LuLu-ling Jun 12, 2026
08ac9fc
apply
LuLu-ling Jun 12, 2026
f0fe05e
apply
LuLu-ling Jun 12, 2026
0bb741f
apply
LuLu-ling Jun 12, 2026
c30c7db
Merge branch 'dev' into refactor/ModEvent
LuLu-ling Jun 13, 2026
a5164bc
refactor: standardize terminology and improve method signatures in ev…
LuLu-ling Jun 13, 2026
2c86884
use ModMain.HintType.Critical
LuLu-ling Jun 13, 2026
030d371
refactor: improve event handling and terminology consistency
LuLu-ling Jun 13, 2026
346695b
apply
LuLu-ling Jun 13, 2026
58471f7
apply
LuLu-ling Jun 13, 2026
0353394
apply
LuLu-ling Jun 13, 2026
6119d3c
apply
LuLu-ling Jun 13, 2026
db3bad4
apply
LuLu-ling Jun 13, 2026
f7a98a3
refactor: simplify action execution and update ActionMap to use deleg…
LuLu-ling Jun 13, 2026
2a60298
apply
LuLu-ling Jun 13, 2026
fa47227
apply
LuLu-ling Jun 13, 2026
5e153ae
apply
LuLu-ling Jun 13, 2026
3234309
add "是"
LuLu-ling Jun 13, 2026
ebd6555
apply
LuLu-ling Jun 13, 2026
3cffb57
rename
LuLu-ling Jun 14, 2026
5695edf
apply
LuLu-ling Jun 14, 2026
097c76f
apply
LuLu-ling Jun 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions PCL.Core/App/Localization/Languages/en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3031,4 +3031,27 @@
<sys:String x:Key="Link.Mod.Task.InitLobbyUi">Initialize lobby UI</sys:String>
<sys:String x:Key="Link.Mod.Task.FetchAnnouncement">Fetch lobby announcement</sys:String>

<!-- Event -->

<sys:String x:Key="Event.Error.Title">Event execution failed</sys:String>
<sys:String x:Key="Event.Error.UrlRequired">EventData must be a URL.&#x0a;If you want to launch a program, change EventType to OpenFile.</sys:String>
<sys:String x:Key="Event.Error.DownloadUrlRequired">EventData must be a URL starting with http:// or https://.&#x0a;PCL does not support other download protocols.</sys:String>
<sys:String x:Key="Event.Error.UnknownType">Unknown event type: {0}&#x0a;Please check if the EventType is correct, or if PCL is up to date.</sys:String>
<sys:String x:Key="Event.Error.MissingArgs">EventType {0} requires at least 2 parameters separated by |, e.g. {1}</sys:String>
<sys:String x:Key="Event.Error.ExecutionFailed">Event execution failed ({0}, {1})</sys:String>
<sys:String x:Key="Event.Error.FileNotFound">Local file not found for EventData: {0}</sys:String>
<sys:String x:Key="Event.OpenUrl.Opening">Opening, please wait: {0}</sys:String>
<sys:String x:Key="Event.LaunchGame.SelectVersion">Please select a Minecraft version first!</sys:String>
<sys:String x:Key="Event.LaunchGame.Starting">Starting {0}...</sys:String>
<sys:String x:Key="Event.Refresh.Success">Refreshed!</sys:String>
<sys:String x:Key="Event.Refresh.NotSupported">The current page does not support refresh!</sys:String>
<sys:String x:Key="Event.Download.Confirm">About to download from this URL:&#x0a;{0}</sys:String>
<sys:String x:Key="Event.Setting.Written">Setting written: {0} → {1}</sys:String>
<sys:String x:Key="Event.Variable.Written">Variable written: {0} → {1}</sys:String>
<sys:String x:Key="Event.Safety.Title">Confirm execution</sys:String>
<sys:String x:Key="Event.Safety.ConfirmMessage">About to execute: {0}&#x0a;Please confirm there are no security risks before continuing.</sys:String>
<sys:String x:Key="Event.Safety.ContinueAlways">Continue and do not ask again</sys:String>
<sys:String x:Key="Event.Sanitize.UnsupportedTypeHint">is the unsupported official PCL EventType, which has been removed from the homepage.</sys:String>
<sys:String x:Key="Event.Sanitize.UnknownTypeHint">Unrecognized EventType, removed from homepage.</sys:String>

</ResourceDictionary>
23 changes: 23 additions & 0 deletions PCL.Core/App/Localization/Languages/zh-CN.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3031,4 +3031,27 @@
<sys:String x:Key="Link.Mod.Task.InitLobbyUi">大厅界面初始化</sys:String>
<sys:String x:Key="Link.Mod.Task.FetchAnnouncement">大厅公告获取</sys:String>

<!-- Event -->

<sys:String x:Key="Event.Error.Title">事件执行失败</sys:String>
<sys:String x:Key="Event.Error.UrlRequired">EventData 必须为一个网址。&#x0a;如果想要启动程序,请将 EventType 改为 OpenFile。</sys:String>
<sys:String x:Key="Event.Error.DownloadUrlRequired">EventData 必须为以 http:// 或 https:// 开头的网址。&#x0a;PCL 不支持其他下载协议。</sys:String>
<sys:String x:Key="Event.Error.UnknownType">未知的事件类型:{0}&#x0a;请检查事件类型填写是否正确,或者 PCL 是否为最新版本。</sys:String>
<sys:String x:Key="Event.Error.MissingArgs">EventType {0} 需要至少 2 个以 | 分割的参数,例如 {1}</sys:String>
<sys:String x:Key="Event.Error.ExecutionFailed">事件执行失败({0}, {1})</sys:String>
<sys:String x:Key="Event.Error.FileNotFound">未找到 EventData 指向的本地文件:{0}</sys:String>
<sys:String x:Key="Event.OpenUrl.Opening">正在开启中,请稍候:{0}</sys:String>
<sys:String x:Key="Event.LaunchGame.SelectVersion">请先选择一个 Minecraft 版本!</sys:String>
<sys:String x:Key="Event.LaunchGame.Starting">正在启动 {0}……</sys:String>
<sys:String x:Key="Event.Refresh.Success">已刷新!</sys:String>
<sys:String x:Key="Event.Refresh.NotSupported">当前页面不支持刷新操作!</sys:String>
<sys:String x:Key="Event.Download.Confirm">即将从该网址下载文件:&#x0a;{0}</sys:String>
<sys:String x:Key="Event.Setting.Written">已写入设置:{0} → {1}</sys:String>
<sys:String x:Key="Event.Variable.Written">已写入变量:{0} → {1}</sys:String>
<sys:String x:Key="Event.Safety.Title">执行确认</sys:String>
<sys:String x:Key="Event.Safety.ConfirmMessage">即将执行:{0}&#x0a;请在确认没有安全隐患后再继续。</sys:String>
<sys:String x:Key="Event.Safety.ContinueAlways">继续且今后不再要求确认</sys:String>
<sys:String x:Key="Event.Sanitize.UnsupportedTypeHint">是不受支持的 PCL 官方版 EventType,已从主页中移除。</sys:String>
<sys:String x:Key="Event.Sanitize.UnknownTypeHint">无法解析的 EventType,已从主页中移除。</sys:String>

</ResourceDictionary>
2 changes: 1 addition & 1 deletion Plain Craft Launcher 2/Controls/MyListItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ private void Button_MouseUp(object sender, MouseButtonEventArgs e)
return;
// 触发自定义事件
var dependencyObject = (DependencyObject)sender;
if (CustomEventService.GetEventType(dependencyObject) != CustomEvent.EventType.None)
if (CustomEventService.GetEventType(dependencyObject) != EventType.None)
{
ModMain.RaiseCustomEvent(this);
e.Handled = true;
Expand Down
13 changes: 12 additions & 1 deletion Plain Craft Launcher 2/Modules/Base/ModBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3195,7 +3195,7 @@ public static void ControlFreeze(Border uI)
}

/// <summary>
/// 将 XML 转换为对应 UI 对象。
/// 将 XElement 转换为对应 UI 对象(不返回 XAML 清理结果)
/// </summary>
public static object GetObjectFromXML(XElement str)
{
Expand All @@ -3206,12 +3206,23 @@ public static object GetObjectFromXML(XElement str)
/// 将 XML 转换为对应 UI 对象。
/// </summary>
public static object GetObjectFromXML(string str)
{
return GetObjectFromXML(str, out _);
}

/// <summary>
/// 将 XML 转换为对应 UI 对象,并输出 XAML 清理结果。
/// </summary>
public static object GetObjectFromXML(string str, out XamlEventSanitizer.SanitizeResult sanitizeResult)
{
str = str. // 兼容旧版自定义事件写法
Replace("EventType=\"", "local:CustomEventService.EventType=\"").
Replace("EventData=\"", "local:CustomEventService.EventData=\"").
Replace("Property=\"EventType\"", "Property=\"local:CustomEventService.EventType\"").
Replace("Property=\"EventData\"", "Property=\"local:CustomEventService.EventData\"");

sanitizeResult = XamlEventSanitizer.Sanitize(str);
Comment thread
LuLu-ling marked this conversation as resolved.
str = sanitizeResult.SanitizedXaml;
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(str)))
{
// 类型检查
Expand Down
4 changes: 2 additions & 2 deletions Plain Craft Launcher 2/Modules/Base/ModSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public static void UiCustomType(int value)
States.Hint.UntrustedHomepage ? Visibility.Collapsed : Visibility.Visible;
ModMain.frmSetupUI.HintCustom.Text =
"从 PCL 文件夹下的 Custom.xaml 读取主页内容。\r\n你可以手动编辑该文件,向主页添加文本、图片、常用网站、快捷启动等功能。";
CustomEventService.SetEventType(ModMain.frmSetupUI.HintCustom, CustomEvent.EventType.None);
CustomEventService.SetEventType(ModMain.frmSetupUI.HintCustom, EventType.None);
break;
}
case 2: // 联网
Expand All @@ -416,7 +416,7 @@ public static void UiCustomType(int value)
States.Hint.UntrustedHomepage ? Visibility.Collapsed : Visibility.Visible;
ModMain.frmSetupUI.HintCustom.Text =
"从指定网址联网获取主页内容。服主也可以用于动态更新服务器公告。\r\n如果你制作了稳定运行的联网主页,可以点击这条提示投稿,若合格即可加入预设!";
CustomEventService.SetEventType(ModMain.frmSetupUI.HintCustom, CustomEvent.EventType.打开网页);
CustomEventService.SetEventType(ModMain.frmSetupUI.HintCustom, EventType.OpenUrl);
CustomEventService.SetEventData(ModMain.frmSetupUI.HintCustom,
"https://github.com/PCL-Community/PCL-CE/discussions");
break;
Expand Down
Loading
Loading