Skip to content

Commit

Permalink
v0.10.27 PackageKit 窗口使用新的布局,感谢 OnClick 的 MultyFramework
Browse files Browse the repository at this point in the history
  • Loading branch information
liangxiegame committed Aug 11, 2020
1 parent bd04ea8 commit c15b8e9
Show file tree
Hide file tree
Showing 21 changed files with 492 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public IDisposable Bind(Action<T> onValueChanged)
/// <returns></returns>
public IDisposable BindWithInitialValue(Action<T> onValueChanged)
{
onValueChanged.Invoke(mValue);
onValueChanged.Invoke(GetValue());
return Bind(onValueChanged);
}

Expand Down Expand Up @@ -286,5 +286,7 @@ protected override void SetValue(T value)
if (mValueSetter != null) mValueSetter(value);
}
}


}
}
8 changes: 2 additions & 6 deletions Framework/0.PackageKit/Editor/Advertise/AdvertisementView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ public void Init(IQFrameworkContainer container)
{
mRootLayout = new VerticalLayout();

var treeNode = new TreeNode(true, LocalText.TechSupport, autosaveSpreadState: true)
var verticalLayout = new VerticalLayout()
.AddTo(mRootLayout);


var verticalLayout = new VerticalLayout();

treeNode.Add2Spread(verticalLayout);

new LabelView("技术支持").FontBold().FontSize(12).AddTo(verticalLayout);

new AdvertisementItemView("官方文档:《QFramework 使用指南 2020》",
"https://qframework.cn/doc")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class PackageKitLoginState
() => !User.Logined && mInLoginView, (value) => mInLoginView = value
);

private static bool mInLoginView;
private static bool mInLoginView = true;

public static Property<bool> RegisterViewVisible = new CustomProperty<bool>(
() => !User.Logined && !mInLoginView,
Expand Down
10 changes: 5 additions & 5 deletions Framework/0.PackageKit/Editor/Login/View/PackageKitLoginView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public bool Enabled

public void Init(IQFrameworkContainer container)
{
var expendLayout = new TreeNode(false, LocaleText.UserInfo)
.AddTo(this);
new LabelView("账户信息").FontSize(12).AddTo(this);

var boxLayout = new VerticalLayout("box");
var boxLayout = new VerticalLayout("box").AddTo(this);

expendLayout.Add2Spread(boxLayout);

var logoutBtn = new ButtonView("注销").AddTo(boxLayout);
var logoutBtn = new ButtonView("注销")
.Do(btn=>btn.Visible = PackageKitLoginState.Logined.Value)
.AddTo(boxLayout);

var loginView = new LoginView()
.Do(self=>self.Visible = PackageKitLoginState.LoginViewVisible.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ public void Init(IQFrameworkContainer container)
PackageManagerApp.Send<PackageManagerInitCommand>();

mRootLayout = new VerticalLayout();
var treeNode = new TreeNode(true, LocaleText.FrameworkPackages).AddTo(mRootLayout);

var verticalLayout = new VerticalLayout("box");

treeNode.Add2Spread(verticalLayout);

new LabelView(LocaleText.FrameworkPackages).FontSize(12).AddTo(mRootLayout);

var verticalLayout = new VerticalLayout("box").AddTo(mRootLayout);

var searchView = new HorizontalLayout("box")
.AddTo(verticalLayout);

Expand Down Expand Up @@ -110,7 +109,7 @@ public void Init(IQFrameworkContainer container)
.AddTo(verticalLayout);

mRepositoryList = new ScrollLayout()
.Height(240)
.Height(600)
.AddTo(packageList);

PackageManagerState.Categories.Bind(value => { Categories = value; }).AddTo(mDisposableList);
Expand Down
77 changes: 1 addition & 76 deletions Framework/0.PackageKit/Editor/QFramework.PackageKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,82 +467,7 @@ public interface IPackageKitView
void OnDispose();
}

public class PackageKitWindow : IMGUIEditorWindow
{
class LocaleText
{
public static string QFrameworkSettings
{
get { return Language.IsChinese ? "QFramework 设置" : "QFramework Settings"; }
}
}

public static bool IsOpenening = false;

[MenuItem(FrameworkMenuItems.Preferences, false, FrameworkMenuItemsPriorities.Preferences)]
[MenuItem(FrameworkMenuItems.PackageKit, false, FrameworkMenuItemsPriorities.Preferences)]
private static void Open()
{
var packageKitWindow = Create<PackageKitWindow>(true);
packageKitWindow.titleContent = new GUIContent(LocaleText.QFrameworkSettings);
packageKitWindow.position = new Rect( 50, 100, 800, 800);
packageKitWindow.Show();
IsOpenening = true;
}

private const string URL_FEEDBACK = "http://feathub.com/liangxiegame/QFramework";

[MenuItem(FrameworkMenuItems.Feedback, false, FrameworkMenuItemsPriorities.Feedback)]
private static void Feedback()
{
Application.OpenURL(URL_FEEDBACK);
}

public override void OnUpdate()
{
mPackageKitViews.ForEach(view => view.OnUpdate());
}

public List<IPackageKitView> mPackageKitViews = null;

private int count = 0;

protected override void Init()
{
var label = GUI.skin.label;

PackageApplication.Container = null;
RemoveAllChidren();

mPackageKitViews = PackageApplication.Container
.ResolveAll<IPackageKitView>()
.OrderBy(view => view.RenderOrder)
.ToList();

PackageApplication.Container.RegisterInstance(this);
PackageApplication.Container.RegisterInstance<EditorWindow>(this);
}

public override void OnGUI()
{
base.OnGUI();
mPackageKitViews.ForEach(view => view.OnGUI());

RenderEndCommandExecuter.ExecuteCommand();
}

public override void OnClose()
{
if (mPackageKitViews != null)
{
mPackageKitViews.Where(view => view != null).ToList().ForEach(view => view.OnDispose());
}

RemoveAllChidren();

IsOpenening = false;
}
}




Expand Down
3 changes: 3 additions & 0 deletions Framework/0.PackageKit/Editor/Window.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Framework/0.PackageKit/Editor/Window/AnchorType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace QFramework.PackageKit
{
public enum AnchorType
{
UpperLeft = 0,
UpperCenter = 1,
UpperRight = 2,
MiddleLeft = 3,
MiddleCenter = 4,
MiddleRight = 5,
LowerLeft = 6,
LowerCenter = 7,
LowerRight = 8
}
}
3 changes: 3 additions & 0 deletions Framework/0.PackageKit/Editor/Window/AnchorType.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

164 changes: 164 additions & 0 deletions Framework/0.PackageKit/Editor/Window/PackageKitWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;

namespace QFramework.PackageKit
{
public class PackageKitWindow : IMGUIEditorWindow
{
class LocaleText
{
public static string QFrameworkSettings
{
get { return Language.IsChinese ? "QFramework 设置" : "QFramework Settings"; }
}
}

private const float toolbarHeight = 20;

class Styles
{
public static GUIStyle box = "box";
public static GUIStyle in_title = new GUIStyle("IN Title") { fixedHeight = toolbarHeight + 5 };
public static GUIStyle toolbarSeachTextFieldPopup = "ToolbarSeachTextFieldPopup";
public static GUIStyle searchCancelButton = "ToolbarSeachCancelButton";
public static GUIStyle searchCancelButtonEmpty = "ToolbarSeachCancelButtonEmpty";
public static GUIStyle foldout = "Foldout";
public static GUIStyle toolbarDropDown = "ToolbarDropDown";
public static GUIStyle selectionRect = "SelectionRect";

}

[MenuItem(FrameworkMenuItems.Preferences, false, FrameworkMenuItemsPriorities.Preferences)]
[MenuItem(FrameworkMenuItems.PackageKit, false, FrameworkMenuItemsPriorities.Preferences)]
private static void Open()
{
var packageKitWindow = Create<PackageKitWindow>(true);
packageKitWindow.titleContent = new GUIContent(LocaleText.QFrameworkSettings);
packageKitWindow.position = new Rect(50, 100, 1000, 800);
packageKitWindow.Show();
}

private const string URL_FEEDBACK = "http://feathub.com/liangxiegame/QFramework";

[MenuItem(FrameworkMenuItems.Feedback, false, FrameworkMenuItemsPriorities.Feedback)]
private static void Feedback()
{
Application.OpenURL(URL_FEEDBACK);
}

public override void OnUpdate()
{
mPackageKitViews.ForEach(view => view.OnUpdate());
}

public List<IPackageKitView> mPackageKitViews = null;

private int count = 0;

protected override void Init()
{
var label = GUI.skin.label;

PackageApplication.Container = null;
RemoveAllChidren();

mPackageKitViews = PackageApplication.Container
.ResolveAll<IPackageKitView>()
.OrderBy(view => view.RenderOrder)
.ToList();

mSelectedView = mPackageKitViews.FirstOrDefault();

PackageApplication.Container.RegisterInstance(this);
PackageApplication.Container.RegisterInstance<EditorWindow>(this);

// 创建双屏
mSplitView = new VerticalSplitView
{
fistPan = rect =>
{

GUILayout.BeginArea(rect);
GUILayout.BeginVertical();
GUILayout.Space(toolbarHeight);
GUILayout.EndVertical();
LeftSelectView("");
GUILayout.EndArea();
},
secondPan = rect =>
{
GUILayout.BeginArea(rect);
GUILayout.BeginVertical();
GUILayout.Space(toolbarHeight);
GUILayout.EndVertical();

if (mSelectedView != null)
{
mSelectedView.OnGUI();
}
GUILayout.EndArea();
}
};
}

private VerticalSplitView mSplitView;


public override void OnGUI()
{
base.OnGUI();

GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label(DateTime.Now.ToLongTimeString(), Styles.selectionRect);

GUILayout.EndHorizontal();

var r = GUILayoutUtility.GetLastRect();
mSplitView.OnGUI(new Rect(new Vector2(0, r.yMax),
new Vector2(position.width, position.height - r.height)));

RenderEndCommandExecuter.ExecuteCommand();
}

private IPackageKitView mSelectedView = null;
private void LeftSelectView(string search)
{
for (int i = 0; i < mPackageKitViews.Count; i++)
{
var drawer = mPackageKitViews[i];

GUILayout.BeginHorizontal(Styles.in_title);
GUILayout.Label(drawer.GetType().Name.Replace("View",string.Empty));
GUILayout.FlexibleSpace();
// GUILayout.Label("v0.0.1");
GUILayout.EndHorizontal();
Rect rect = GUILayoutUtility.GetLastRect();
if (mSelectedView == drawer)
{
GUI.Box(rect, "", Styles.selectionRect);
}
if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseUp)
{
mSelectedView = drawer;
Event.current.Use();
}
GUILayout.Label("", Styles.in_title, GUILayout.Height(0));
}
}


public override void OnClose()
{
if (mPackageKitViews != null)
{
mPackageKitViews.Where(view => view != null).ToList().ForEach(view => view.OnDispose());
}

RemoveAllChidren();
}
}
}
3 changes: 3 additions & 0 deletions Framework/0.PackageKit/Editor/Window/PackageKitWindow.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c15b8e9

Please sign in to comment.