This commit is contained in:
MuHua-123
2025-06-23 14:38:10 +08:00
parent 39d9db9c6d
commit 0cc63a7314
51 changed files with 2032 additions and 68 deletions
+3 -2
View File
@@ -20,11 +20,12 @@ public class ModuleUI : ModuleSingle<ModuleUI> {
protected override void Awake() => NoReplace();
/// <summary> 跳转页面 </summary>
public static void Jump(EnumPage pageType) => OnJumpPage?.Invoke(pageType);
public static void Settings(EnumPage pageType) => OnJumpPage?.Invoke(pageType);
}
/// <summary>
/// 页面
/// </summary>
public enum EnumPage {
None,
Login,
}
@@ -0,0 +1,96 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using MuHua;
/// <summary>
/// 登录页面
/// </summary>
public class UILoginPage : ModuleUIPage {
private UILoginPanel loginPanel;
private UIRegisterPanel registerPanel;
public override VisualElement Element => root.Q<VisualElement>("LoginPage");
public VisualElement LoginPanel => Q<VisualElement>("LoginPanel");
public VisualElement RegisterPanel => Q<VisualElement>("RegisterPanel");
private void Awake() {
loginPanel = new UILoginPanel(LoginPanel, this);
registerPanel = new UIRegisterPanel(RegisterPanel, this);
ModuleUI.OnJumpPage += ModuleUI_OnJumpPage;
}
private void ModuleUI_OnJumpPage(EnumPage page) {
Element.EnableInClassList("document-page-hide", page != EnumPage.Login);
if (page != EnumPage.Login) { return; }
OpenLoginPanel();
}
public void OpenLoginPanel() {
loginPanel.Resetting(false);
registerPanel.Resetting(true);
}
public void OpenRegisterPanel() {
loginPanel.Resetting(true);
registerPanel.Resetting(false);
}
}
/// <summary>
/// 登录面板
/// </summary>
public class UILoginPanel : ModuleUIPanel {
private string username;
private string password;
public Label Title => Q<Label>("Title");
public UITextField InputField1 => Q<UITextField>("InputField1");
public UITextField InputField2 => Q<UITextField>("InputField2");
public Button Button1 => Q<Button>("Button1");
public Button Button2 => Q<Button>("Button2");
public UILoginPanel(VisualElement element, UILoginPage parent) : base(element) {
InputField1.RegisterCallback<ChangeEvent<string>>(evt => { username = evt.newValue; });
InputField2.RegisterCallback<ChangeEvent<string>>(evt => { password = evt.newValue; });
Button1.clicked += () => parent.OpenRegisterPanel();
Button2.clicked += () => ManagerRequest.I.Login(username, password, (s) => {
ModuleUI.Settings(EnumPage.None);
Debug.Log(s);
});
}
public void Resetting(bool isHide) {
InputField1.value = username = "";
InputField2.value = password = "";
element.EnableInClassList("login-hide", isHide);
}
}
/// <summary>
/// 注册面板
/// </summary>
public class UIRegisterPanel : ModuleUIPanel {
private string username;
private string password;
public Label Title => Q<Label>("Title");
public UITextField InputField1 => Q<UITextField>("InputField1");
public UITextField InputField2 => Q<UITextField>("InputField2");
public Button Button1 => Q<Button>("Button1");
public Button Button2 => Q<Button>("Button2");
public UIRegisterPanel(VisualElement element, UILoginPage parent) : base(element) {
InputField1.RegisterCallback<ChangeEvent<string>>(evt => { username = evt.newValue; });
InputField2.RegisterCallback<ChangeEvent<string>>(evt => { password = evt.newValue; });
Button1.clicked += () => parent.OpenLoginPanel();
Button2.clicked += () => { };
}
public void Resetting(bool isHide) {
InputField1.value = "";
InputField2.value = "";
element.EnableInClassList("login-hide", isHide);
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 202f1c0d7338943458d837082537020b
guid: 71f4d873d8595a04b9f0e23ece70c12f
MonoImporter:
externalObjects: {}
serializedVersion: 2
@@ -1,41 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using MuHua;
/// <summary>
/// 滚动视图 - 测试页面
/// </summary>
public class UIScrollViewTestPage : ModuleUIPage {
private UIScrollViewV scrollView1;
private UIScrollViewV scrollView2;
private UIScrollViewH scrollView3;
private UIScrollViewH scrollView4;
private UIScrollView scrollView5;
public VisualElement ScrollView1 => Q<VisualElement>("ScrollView1");
public VisualElement ScrollView2 => Q<VisualElement>("ScrollView2");
public VisualElement ScrollView3 => Q<VisualElement>("ScrollView3");
public VisualElement ScrollView4 => Q<VisualElement>("ScrollView4");
public VisualElement ScrollView5 => Q<VisualElement>("ScrollView5");
public override VisualElement Element => root;
private void Awake() {
scrollView1 = new UIScrollViewV(ScrollView1, root, UIScrollViewV.UIDirection.FromTopToBottom);
scrollView2 = new UIScrollViewV(ScrollView2, root, UIScrollViewV.UIDirection.FromBottomToTop);
scrollView3 = new UIScrollViewH(ScrollView3, root, UIScrollViewH.UIDirection.FromLeftToRight);
scrollView4 = new UIScrollViewH(ScrollView4, root, UIScrollViewH.UIDirection.FromRightToLeft);
scrollView5 = new UIScrollView(ScrollView5, root);
}
private void Update() {
scrollView1.Update();
scrollView2.Update();
scrollView3.Update();
scrollView4.Update();
scrollView5.Update();
}
}
@@ -1,36 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using MuHua;
/// <summary>
/// 滑动条 - 测试页面
/// </summary>
public class UISliderTestPage : ModuleUIPage {
private UISliderH sliderH1;
private UISliderH sliderH2;
private UISliderV sliderV1;
private UISliderV sliderV2;
public VisualElement SliderH1 => Q<VisualElement>("SliderH1");
public VisualElement SliderH2 => Q<VisualElement>("SliderH2");
public VisualElement SliderV1 => Q<VisualElement>("SliderV1");
public VisualElement SliderV2 => Q<VisualElement>("SliderV2");
public override VisualElement Element => root;
private void Awake() {
sliderH1 = new UISliderH(SliderH1, root, UISliderH.UIDirection.FromLeftToRight);
sliderH2 = new UISliderH(SliderH2, root, UISliderH.UIDirection.FromRightToLeft);
sliderV1 = new UISliderV(SliderV1, root, UISliderV.UIDirection.FromTopToBottom);
sliderV2 = new UISliderV(SliderV2, root, UISliderV.UIDirection.FromBottomToTop);
}
private void Update() {
sliderH1.Update();
sliderH2.Update();
sliderV1.Update();
sliderV2.Update();
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 545cbb8d4e1482749bc6b9ae168407c4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: