Exemple #1
0
 private void RefreshOverview()
 {
     Controls.Clear();
     AxisList.Clear();
     foreach (KeyValuePair <Guid, List <Control> > entry in ControlManager.Blocks)
     {
         foreach (Control c in entry.Value)
         {
             try { BlockHandlerController.GetID(c.BlockGUID); } catch { continue; }
             if (c.Axis == null)
             {
                 continue;
             }
             if (!Controls.ContainsKey(c.Axis))
             {
                 Controls[c.Axis] = new List <Control>();
             }
             if (!AxisList.Contains(c.Axis))
             {
                 AxisList.Add(c.Axis);
             }
             if (!Controls[c.Axis].Contains(c))
             {
                 Controls[c.Axis].Add(c);
             }
         }
     }
 }
Exemple #2
0
        private void DoWindow(int id)
        {
            // Draw close button
            if (GUI.Button(new Rect(windowRect.width - 38, 8, 30, 30),
                           "×", Elements.Buttons.Red))
            {
                Visible = false;
            }

            string sequential_id;

            try
            {
                sequential_id = BlockHandlerController.GetID(block.Guid);
            }
            catch (KeyNotFoundException)
            {
                Visible = false;
                return;
            }
            // Sequential identifier field
            GUILayout.BeginHorizontal();

            GUILayout.TextField(sequential_id);
            if (GUILayout.Button("✂", Elements.Buttons.Red, GUILayout.Width(30)))
            {
                Clipboard = sequential_id;
            }

            GUILayout.EndHorizontal();

            // GUID field
            GUILayout.BeginHorizontal();

            GUILayout.TextField(block.Guid.ToString());
            if (GUILayout.Button("✂", Elements.Buttons.Red, GUILayout.Width(30)))
            {
                Clipboard = block.Guid.ToString();
            }

            GUILayout.EndHorizontal();

            GUI.DragWindow(new Rect(0, 0, windowRect.width, GUI.skin.window.padding.top));
        }
Exemple #3
0
        private void DrawAxis(string axis)
        {
            GUILayout.BeginHorizontal();

            var buttonRect = GUILayoutUtility.GetRect(new GUIContent(" "), Elements.Buttons.Default);
            var a          = AxisManager.Get(axis);

            if (GUI.Button(buttonRect, axis, a != null ? a.Saveable ? Elements.Buttons.Default : Elements.Buttons.Disabled : Elements.Buttons.Red))
            {
                var callback = new SelectAxisDelegate((InputAxis new_axis) => { AssignAxis(axis, new_axis.Name); });
                if (popup == null)
                {
                    popup = AxisSelector.Open(callback, true);
                }
                else
                {
                    popup.Callback = callback;
                }
                popup.windowRect.x = windowRect.x + buttonRect.x - 8;
                popup.windowRect.y = windowRect.y + GUI.skin.window.padding.top + buttonRect.y - scrollPosition.y - 8;
            }

            if (a != null && GUILayout.Button("✎", new GUIStyle(Elements.Buttons.Default)
            {
                fontSize = 20, padding = new RectOffset(-3, 0, 0, 0)
            }, GUILayout.Width(30), GUILayout.MaxHeight(28)))
            {
                var Editor = ACM.Instance.gameObject.AddComponent <AxisEditorWindow>();
                Editor.windowRect.x = Mathf.Clamp(windowRect.x + windowRect.width,
                                                  -320 + GUI.skin.window.padding.top, Screen.width - GUI.skin.window.padding.top);
                Editor.windowRect.y = Mathf.Clamp(windowRect.y, 0, Screen.height - GUI.skin.window.padding.top);
                Editor.EditAxis(a, new SelectAxisDelegate((InputAxis new_axis) => { AssignAxis(axis, new_axis.Name); }));
            }

            GUILayout.EndHorizontal();

            // Draw graph
            string text;

            if (a == null)
            {
                text = "NOT FOUND";
            }
            else if (a.Status != AxisStatus.OK)
            {
                text = InputAxis.GetStatusString(a.Status);
            }
            else
            {
                text = "";
            }

            GUILayout.Label("  <color=#808080><b>" + text + "</b></color>",
                            new GUIStyle(Elements.Labels.Default)
            {
                richText = true, alignment = TextAnchor.MiddleLeft, margin = new RectOffset(8, 8, 8, 8)
            },
                            GUILayout.Height(20));

            var graphRect = GUILayoutUtility.GetLastRect();

            Util.DrawRect(graphRect, Color.gray);
            Util.FillRect(new Rect(
                              graphRect.x + graphRect.width / 2,
                              graphRect.y,
                              1,
                              graphRect.height),
                          Color.gray);

            if (a != null && a.Status == AxisStatus.OK)
            {
                Util.FillRect(new Rect(
                                  graphRect.x + graphRect.width / 2 + graphRect.width / 2 * a.OutputValue,
                                  graphRect.y,
                                  1,
                                  graphRect.height),
                              Color.yellow);
            }

            // Draw assigned controls list
            foreach (Control c in Controls[axis])
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("×", new GUIStyle(Elements.Buttons.Red)
                {
                    margin = new RectOffset(8, 8, 0, 0)
                }, GUILayout.Width(20), GUILayout.Height(20)))
                {
                    c.Axis    = null;
                    c.Enabled = false;
                }
                string block_name;
                try
                {
                    block_name = BlockHandlerController.GetID(c.BlockGUID);
                }
                catch
                {
                    block_name = "...";
                }
                GUILayout.Label("<b>" + c.Name + "</b> for " + block_name, Elements.Labels.LogEntry);
                GUILayout.EndHorizontal();
            }

            GUILayout.Box(GUIContent.none, GUILayout.Height(8));
        }