예제 #1
0
파일: Tool.cs 프로젝트: 0000duck/MiniRTS
        private void ChangeTool(Type type, Property property)
        {
            ImGui.OpenPopup("Tool Picker");
            if (ImGui.BeginPopup("Tool Picker"))
            {
                var allTools = this.ToolSelector.GetAllTools(type);
                var bestTool = this.ToolSelector.GetBestTool(type, this.changingState);

                var index = Array.IndexOf(allTools.Tools, bestTool);
                if (ImGui.Combo("Tools", ref index, allTools.Names, allTools.Names.Length))
                {
                    this.changingState.Name = allTools.Tools[index].Name;
                }

                ImGui.Separator();
                this.changingState = bestTool.Configure(this.changingState);
                ImGui.Separator();

                if (ImGui.Button("Save"))
                {
                    this.LinkedTools.Link(property, this.changingState);
                    this.Deactivate();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    this.Deactivate();
                }

                ImGui.EndPopup();
            }
        }
예제 #2
0
파일: Tool.cs 프로젝트: 0000duck/MiniRTS
 private void ToolRow(Property property, ToolState state, ITool tool, Type type)
 {
     if (ToolUtils.ButtonRowWithTooltip($"Tool: {tool.Name}", $"Type: {type.Name}, Path: {property.Path}", "change tool"))
     {
         this.Activate(property);
         this.changingState = state;
     }
 }
예제 #3
0
파일: ATool.cs 프로젝트: 0000duck/MiniRTS
        public bool Details(ref object value, ToolState tool, Property propertyPath)
        {
            var specific = (T)value;
            var changed  = this.Details(ref specific, tool);

            value = specific !;

            return(changed);
        }
예제 #4
0
파일: ATool.cs 프로젝트: 0000duck/MiniRTS
        public bool HeaderValue(ref object value, ToolState tool)
        {
            var specific = (T)value;
            var changed  = this.HeaderValue(ref specific, tool);

            value = specific !;

            return(changed);
        }
예제 #5
0
파일: ATool.cs 프로젝트: 0000duck/MiniRTS
 public virtual ToolState Configure(ToolState tool) => tool;
예제 #6
0
파일: ATool.cs 프로젝트: 0000duck/MiniRTS
 public virtual bool Details(ref T value, ToolState tool) => false;
예제 #7
0
파일: ATool.cs 프로젝트: 0000duck/MiniRTS
 public abstract bool HeaderValue(ref T value, ToolState tool);
예제 #8
0
        public ITool GetBestTool(Type type, ToolState toolState)
        {
            var tools = this.GetAllTools(type);

            return(tools.Tools.FirstOrDefault(t => t.Name == toolState.Name) ?? tools.Tools[0]);
        }
예제 #9
0
파일: Tool.cs 프로젝트: 0000duck/MiniRTS
        private static bool Header(ref object value, out bool open, Property property, ITool tool, ToolState toolState)
        {
            ImGui.AlignTextToFramePadding();
            open = ImGui.TreeNode(property.Name);

            ImGui.NextColumn();
            ImGui.AlignTextToFramePadding();
            var changed = false;

            if (value == null)
            {
                ImGui.Text("null");
            }
            else
            {
                changed = tool.HeaderValue(ref value, toolState);
            }

            ImGui.NextColumn();
            return(changed);
        }
예제 #10
0
 private void Link(string sortKey, ToolState tool)
 {
     this.KnownTools.Add(sortKey);
     this.Tools[sortKey] = tool;
 }
예제 #11
0
 public void Link(Property property, ToolState tool)
     => this.Link(property.SortKey, tool);
예제 #12
0
 private record ToolPair(string Key, ToolState Value);