From 3bc7e84af4cc73f27c326ecbdf5b92a2bdd963a7 Mon Sep 17 00:00:00 2001
From: GeWuYou <95328647+GeWuYou@users.noreply.github.com>
Date: Sat, 17 Jan 2026 19:40:24 +0800
Subject: [PATCH] =?UTF-8?q?feat(template):=20=E6=B7=BB=E5=8A=A0UI=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=E6=8E=A7=E5=88=B6=E5=99=A8=E7=B1=BB=E6=A8=A1=E6=9D=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 创建PageControllerTemplate.cs模板文件
- 实现IController、IUiPageBehaviorProvider和IUiPage接口
- 添加页面生命周期管理方法(OnEnter、OnExit、OnPause、OnResume、OnShow、OnHide)
- 集成CanvasItemUiPageBehavior页面行为实现
- 添加ContextAware和Log注解支持
- 提供页面行为实例的懒加载获取功能
---
.../Node/PageControllerTemplate.cs | 87 +++++++++++++++++++
1 file changed, 87 insertions(+)
create mode 100644 Godot/script_templates/Node/PageControllerTemplate.cs
diff --git a/Godot/script_templates/Node/PageControllerTemplate.cs b/Godot/script_templates/Node/PageControllerTemplate.cs
new file mode 100644
index 0000000..808c1d1
--- /dev/null
+++ b/Godot/script_templates/Node/PageControllerTemplate.cs
@@ -0,0 +1,87 @@
+// meta-name: UI页面控制器类模板
+// meta-description: 负责管理UI页面场景的生命周期和架构关联
+using Godot;
+using GFramework.Core.Abstractions.controller;
+using GFramework.Core.extensions;
+using GFramework.Game.Abstractions.ui;
+using GFramework.Godot.ui;
+using GFramework.SourceGenerators.Abstractions.logging;
+using GFramework.SourceGenerators.Abstractions.rule;
+
+
+[ContextAware]
+[Log]
+public partial class _CLASS_ :_BASE_,IController,IUiPageBehaviorProvider,IUiPage
+{
+ ///
+ /// 节点准备就绪时的回调方法
+ /// 在节点添加到场景树后调用
+ ///
+ public override void _Ready()
+ {
+
+ }
+ ///
+ /// 页面行为实例的私有字段
+ ///
+ private IUiPageBehavior? _page;
+
+ ///
+ /// 获取页面行为实例,如果不存在则创建新的CanvasItemUiPageBehavior实例
+ ///
+ /// 返回IUiPageBehavior类型的页面行为实例
+ public IUiPageBehavior GetPage()
+ {
+ _page ??= new CanvasItemUiPageBehavior<_BASE_>(this);
+ return _page;
+ }
+
+ ///
+ /// 页面进入时调用的方法
+ ///
+ /// 页面进入参数,可能为空
+ public void OnEnter(IUiPageEnterParam? param)
+ {
+ _log.Info("测试主菜单 OnEnter");
+ }
+ ///
+ /// 页面退出时调用的方法
+ ///
+ public void IUiPage.OnExit()
+ {
+
+ }
+
+
+ ///
+ /// 页面暂停时调用的方法
+ ///
+ public void IUiPage.OnPause()
+ {
+
+ }
+
+ ///
+ /// 页面恢复时调用的方法
+ ///
+ public void IUiPage.OnResume()
+ {
+
+ }
+
+ ///
+ /// 页面显示时调用的方法
+ ///
+ public void IUiPage.OnShow()
+ {
+
+ }
+
+ ///
+ /// 页面隐藏时调用的方法
+ ///
+ public void IUiPage.OnHide()
+ {
+
+ }
+}
\ No newline at end of file