コード例 #1
0
ファイル: GuiController.cs プロジェクト: magcius/mchi
        public static Vector4?GetHighlightColor(JORNode jorNode)
        {
            if (MatchesSearchString(jorNode.Name, null))
            {
                return(new Vector4(0xFF, 0x00, 0xFF, 0xFF));
            }

            foreach (var jorControl in jorNode.Controls)
            {
                var controlHighlightColor = GetHighlightColor(jorControl);
                if (controlHighlightColor != null)
                {
                    return(controlHighlightColor);
                }
            }

            foreach (var childJorNode in jorNode.Children)
            {
                var childHighlightColor = GetHighlightColor(childJorNode);
                if (childHighlightColor != null)
                {
                    return(childHighlightColor);
                }
            }

            return(null);
        }
コード例 #2
0
ファイル: GuiController.cs プロジェクト: magcius/mchi
 private static void EnsureTranslation(JORNode jorNode)
 {
     if (jorNode.Name != null)
     {
         translationDictionary.EnsureKey(jorNode.Name);
     }
     foreach (var jorControl in jorNode.Controls)
     {
         EnsureTranslation(jorControl);
     }
     foreach (var childJorNode in jorNode.Children)
     {
         EnsureTranslation(childJorNode);
     }
 }
コード例 #3
0
ファイル: GuiController.cs プロジェクト: magcius/mchi
        private static void AllSlidersToMax(JORServer jorServer, JORNode jorNode)
        {
            foreach (var jorControl in jorNode.Controls)
            {
                if (jorControl is JORControlRangeInt)
                {
                    var jorRange = jorControl as JORControlRangeInt;
                    jorRange.SetValue(jorServer, jorRange.RangeMax);
                }

                if (jorControl is JORControlRangeFloat)
                {
                    var jorRange = jorControl as JORControlRangeFloat;
                    jorRange.SetValue(jorServer, jorRange.RangeMax);
                }
            }
        }
コード例 #4
0
ファイル: GuiController.cs プロジェクト: magcius/mchi
        private static void DrawTree(JORServer server, JORNode node)
        {
            if (node == null)
            {
                return;
            }
            if (node.Name == null)
            {
                return;
            }
            if (node.Status == JORNodeStatus.Invalid)
            {
                return;
            }
            if (node.Status == JORNodeStatus.GenRequestSent)
            {
                if (node.LastRequestTime == null || (DateTime.Now - node.LastRequestTime).Seconds > 2)
                {
                    server.SendGenObjectInfo(node);
                }
                return;
            }

            var nodeLabel      = GetText(node.Name, null);
            var highlightColor = GetHighlightColor(node);

            int styleColorPushCount = 0;

            var treeNodeFlags = ImGuiTreeNodeFlags.OpenOnDoubleClick | ImGuiTreeNodeFlags.OpenOnArrow | ImGuiTreeNodeFlags.SpanFullWidth;

            if (node == server.CurrentNode)
            {
                treeNodeFlags |= ImGuiTreeNodeFlags.Selected;
            }
            if (node.Children.Count == 0)
            {
                treeNodeFlags |= ImGuiTreeNodeFlags.Leaf;
                if (node.Controls.Count == 0)
                {
                    unsafe
                    {
                        var vector = ImGui.GetStyleColorVec4(ImGuiCol.TextDisabled);
                        ImGui.PushStyleColor(ImGuiCol.Text, *vector);
                    }
                    styleColorPushCount++;
                }
            }
            if (highlightColor.HasValue)
            {
                treeNodeFlags |= ImGuiTreeNodeFlags.Framed;
                ImGui.PushStyleColor(ImGuiCol.Header, highlightColor.Value);
                styleColorPushCount++;
            }
            bool treeNodeOpen = ImGui.TreeNodeEx(nodeLabel + "##" + node.NodePtr, treeNodeFlags);

            ImGui.PopStyleColor(styleColorPushCount);
            if (ImGui.IsItemClicked())
            {
                server.SetCurrentNode(node);
            }
            if (treeNodeOpen)
            {
                foreach (JORNode jorNode in node.Children)
                {
                    DrawTree(server, jorNode);
                }

                ImGui.TreePop();
            }
        }