Skip to content

Commit

Permalink
编辑器功能优化: 1. 增加BTVector3f的初始化代码 2. 禁用行为树调试时页签不断切换的功能,改成只停留在当前打开的页签上 3.…
Browse files Browse the repository at this point in the history
… 增加通过调试堆栈窗口直接打开行为树的功能

contributed by summerhou@tencent
  • Loading branch information
summerhou authored and berniebwang committed Jul 4, 2022
1 parent c14297c commit c3ad935
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 10 deletions.
19 changes: 19 additions & 0 deletions tools/designer/BehaviacDesigner/BehaviorTreeViewDock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Behaviac.Design.Nodes;

namespace Behaviac.Design
{
Expand Down Expand Up @@ -161,6 +163,23 @@ internal static BehaviorTreeViewDock GetBehaviorTreeViewDock(Nodes.BehaviorNode
return null;
}

internal static BehaviorTreeViewDock GetBehaviorTreeViewDockByName(string behaviorFilename)
{
if (!Path.IsPathRooted(behaviorFilename))
{
behaviorFilename = FileManagers.FileManager.GetFullPath(behaviorFilename);
}

BehaviorTreeViewDock dock = null;
BehaviorNode behaviornode = BehaviorManager.Instance.GetBehavior(behaviorFilename);
if (behaviornode != null)
{
dock = GetBehaviorTreeViewDock(behaviornode);
}

return dock;
}

internal static BehaviorTreeView GetBehaviorTreeView(Nodes.BehaviorNode node)
{
foreach (BehaviorTreeViewDock dock in __instances)
Expand Down
1 change: 1 addition & 0 deletions tools/designer/BehaviacDesigner/CallStackDock.Designer.cs

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

24 changes: 24 additions & 0 deletions tools/designer/BehaviacDesigner/CallStackDock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Behaviac.Design.Nodes;
using Behaviac.Design.Properties;


namespace Behaviac.Design
{
internal partial class CallStackDock : WeifenLuo.WinFormsUI.Docking.DockContent
Expand Down Expand Up @@ -122,14 +123,18 @@ private void UpdateStackCb(string tree, bool bAdd)
}
}

/*
if (callstackListBox.Items.Count > 0)
{
//callstackListBox.SelectedIndex = -1;
callstackListBox.SelectedIndex = 0;
string currentBt = (string)callstackListBox.Items[0];
UIUtilities.ShowBehaviorTree(currentBt);
}
*/
}

private void copyMenuItem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -184,5 +189,24 @@ private void logListBox_KeyDown(object sender, KeyEventArgs e)
callstackListBox.EndUpdate();
}
}

private void logListBox_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (callstackListBox.SelectedItem != null)
{
String behaviorFilename = callstackListBox.SelectedItem.ToString();
BehaviorTreeView behaviorTreeView = UIUtilities.ShowBehaviorTree(behaviorFilename, true);
if (behaviorTreeView != null)
{
BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDockByName(behaviorFilename);
if (dock != null)
{
dock.Focus();
dock.MakeFocused();
}
}
}
}
}
}

7 changes: 5 additions & 2 deletions tools/designer/BehaviacDesigner/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,8 +1129,11 @@ private BehaviorTreeViewDock behaviorTreeList_ShowBehavior(BehaviorNode node)

if (dock != null)
{
dock.Focus();
dock.MakeFocused();
if (Plugin.EditMode == EditModes.Design)
{
dock.Focus();
dock.MakeFocused();
}
}
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion tools/designer/BehaviacDesigner/TimelineDock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private void updateParameters(AgentType agentType, string agentName, int frame)

if (agentFullname == Plugin.DebugAgentInstance)
{
behavior = UIUtilities.ShowBehavior(behaviorFilename);
behavior = UIUtilities.ShowBehavior(behaviorFilename, false);
}

List<AgentDataPool.ValueMark> values = AgentDataPool.GetValidValues(agentType, agentFullname, frame);
Expand Down
23 changes: 16 additions & 7 deletions tools/designer/BehaviacDesigner/UIUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class UIUtilities
/// Show the behavior tree view.
/// </summary>
/// <param name="behaviorFilename">The behavior filename in the workspace folder.</param>
public static BehaviorNode ShowBehavior(string behaviorFilename)
public static BehaviorNode ShowBehavior(string behaviorFilename, bool forceshowFlag = true)
{
if (string.IsNullOrEmpty(behaviorFilename))
{
Expand Down Expand Up @@ -81,16 +81,19 @@ public static BehaviorNode ShowBehavior(string behaviorFilename)

if (behaviorTreeList != null)
{
behaviorTreeList.ShowNode(behavior as Node);
if (forceshowFlag)
{
behaviorTreeList.ShowNode(behavior as Node);
}
}
}

return behavior;
}

public static BehaviorTreeView ShowBehaviorTree(string behaviorFilename)
public static BehaviorTreeView ShowBehaviorTree(string behaviorFilename, bool forceshowFlag = true)
{
BehaviorNode behavior = ShowBehavior(behaviorFilename);
BehaviorNode behavior = ShowBehavior(behaviorFilename, forceshowFlag);
return BehaviorTreeViewDock.GetBehaviorTreeView(behavior);
}

Expand All @@ -105,7 +108,7 @@ public static BehaviorNode ShowBehaviorTree(string agentFullname, int frame, Lis

if (!string.IsNullOrEmpty(behaviorFilename))
{
BehaviorTreeView behaviorTreeView = ShowBehaviorTree(behaviorFilename);
BehaviorTreeView behaviorTreeView = ShowBehaviorTree(behaviorFilename, false);

if (behaviorTreeView != null)
{
Expand All @@ -114,8 +117,14 @@ public static BehaviorNode ShowBehaviorTree(string agentFullname, int frame, Lis
profileInfos = null;
}

behaviorTreeView.SetHighlights(highlightedTransitionIds, highlightNodeIds, updatedNodeIds, highlightBreakPoint, profileInfos);
//behaviorTreeView.Focus();
// check if there is a tab for the behaviour, add by j2 server start
BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDockByName(behaviorFilename);
if (dock != null && dock == BehaviorTreeViewDock.LastFocused)
{
behaviorTreeView.SetHighlights(highlightedTransitionIds, highlightNodeIds, updatedNodeIds, highlightBreakPoint, profileInfos);
}

// behaviorTreeView.SetHighlights(highlightedTransitionIds, highlightNodeIds, updatedNodeIds, highlightBreakPoint, profileInfos);

return behaviorTreeView.RootNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ public static string GetGeneratedDefaultValue(Type type, string typename, string
{
value = "NULL";
}
else if(typename.Equals("BTVector3f"))
{
value = "{0, 0, 0}";
}
else
{
value = null;
Expand Down

0 comments on commit c3ad935

Please sign in to comment.