Example #1
0
    private void DrawTodoItem(TodoItem item)
    {
        CustomGUIUtils.BeginGroup();
        {
            switch (item.status)
            {
            case Status.PENDING:
                statusStyle = lightRed;
                break;

            case Status.IN_PROGRESS:
                statusStyle = lightYellow;
                break;

            case Status.DONE:
                statusStyle = lightGreen;
                break;

            default:
                statusStyle = GUIStyle.none;
                break;
            }
            EditorGUILayout.BeginHorizontal(statusStyle);
            EditorGUILayout.LabelField("" + item.name, GUILayout.Width(80f));
            EditorGUILayout.EndHorizontal();

            foreach (string todo in item.childTodos)
            {
                CustomGUIUtils.BeginGroup();
                DrawTodoItem(item.childDict[todo]);
                CustomGUIUtils.EndGroup();
            }
        }
        CustomGUIUtils.EndGroup();
    }
Example #2
0
    public override void OnInspectorGUI()
    {
        if (GUILayout.Button("Delete Edge"))
        {
            //Node oldFromNode = edgeBehaviour.Edge.From;
            //Node oldToNode = edgeBehaviour.Edge.To;
            edgeBehaviour.Delete();
            //oldFromNode.OnNodeChanged();
            //oldToNode.OnNodeChanged();
        }



        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        if (advancedGizmoSettings = EditorGUILayout.Foldout(advancedGizmoSettings, "Edge-Advanced-Gizmo-Settings"))
        {
            CustomGUIUtils.BeginGroup();
            Edge_Behaviour.NodeGizmoSize = (Edge_Behaviour.GizmoSize)EditorGUILayout.EnumPopup("GizmoSize", Edge_Behaviour.NodeGizmoSize);
            Edge_Behaviour.DrawLabel     = EditorGUILayout.Toggle("Show Label", Edge_Behaviour.DrawLabel);
            Edge_Behaviour.DrawLength    = EditorGUILayout.Toggle("Show Length", Edge_Behaviour.DrawLength);

            CustomGUIUtils.EndGroup();
        }

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        // Draw the DefaultInspector for this Behvaiour
        showDefaultInspector = this.DrawDefaultInspectorFoldout(edgeBehaviour, showDefaultInspector);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(edgeBehaviour);
        }
    }
Example #3
0
    private void DrawSearchResults()
    {
        Rect resultLine = new Rect(0, 0, 300, 40);

        if (locationQuery != null)
        {
            if (locationQuery.searchResults.Count > 0)
            {
                if (lightGreen == null)
                {
                    lightGreen = CustomGUIUtils.GetColorBackgroundStyle(XKCDColors.LightGreen);
                }
                for (int i = 0; i < locationQuery.searchResults.Count; i++)
                {
                    Location location = locationQuery.searchResults[i];
                    resultLine.y = (resultLine.height * (i + 1));
                    GUILayout.BeginArea(resultLine);
                    GUILayout.Label(location.ToString(), lightGreen);
                    GUILayout.EndArea();
                    if (resultLine.Contains(Event.current.mousePosition))
                    {
                        Debug.Log("mouseOver " + location);
                        if (Event.current.type == EventType.MouseUp)
                        {
                            TileManager.OriginLatitude  = location.lat;
                            TileManager.OriginLongitude = location.lon;
                            Debug.Log("Set YouAreHere to " + location.ToString());
                            SetDirty();
                        }
                    }
                }
            }
        }
    }
Example #4
0
    private void OnEnable()
    {
        // Reference the selected client
        client = (SimpleClient)target;

        // Get a reference to the serialized connection property
        connection = serializedObject.FindProperty("Connection");

        // Load configuration data
        AmqpConfigurationEditor.LoadConfiguration();

        // Restore the connection index
        var connectionNames = AmqpConfigurationEditor.GetConnectionNames();

        for (var i = 0; i < connectionNames.Length; i++)
        {
            var cName = connectionNames[i];
            if (connection.stringValue == cName)
            {
                index = i;
                break;
            }
        }

        lightGreen  = CustomGUIUtils.GetColorBackgroundStyle(XKCDColors.LightGreen);
        lightRed    = CustomGUIUtils.GetColorBackgroundStyle(XKCDColors.LightRed);
        lightYellow = CustomGUIUtils.GetColorBackgroundStyle(XKCDColors.LightYellow);
    }
Example #5
0
    static void Init()
    {
        Debug.Log("Init");
        clients = FindObjectsOfType <SimpleClient>();

        // Load configuration data
        AmqpConfigurationEditor.LoadConfiguration();

        //Restore the connection index
        RestoreConfigurationIndex();

        osmMapRect = new OSMMapRect();

        // Prepare GUI-Styles
        lightGreen  = CustomGUIUtils.GetColorBackgroundStyle(XKCDColors.LightGreen);
        lightRed    = CustomGUIUtils.GetColorBackgroundStyle(XKCDColors.LightRed);
        lightYellow = CustomGUIUtils.GetColorBackgroundStyle(XKCDColors.LightYellow);
        darkgrey    = CustomGUIUtils.GetColorBackgroundStyle(XKCDColors.DarkGrey);

        timerFontStyle.font     = (Font)Resources.Load("digitalmono");
        timerFontStyle.fontSize = 34;

        // Get existing open window or if none, make a new one:
        window = (SimpleClientEditorWindow)EditorWindow.GetWindow(typeof(SimpleClientEditorWindow));
        window.Show();
    }
Example #6
0
    private void DrawSelection()
    {
        Color red = Color.black;

        red.a = 0.6f;

        Color redAlpha = Color.red;

        redAlpha.a = 0.3f;


        int tileRadius = TileManager.tileRadius;

        for (int i = -tileRadius; i <= tileRadius; i++)
        {
            for (int j = -tileRadius; j <= tileRadius; j++)
            {
                OSMBoundingBox box = new OSMBoundingBox(
                    TileManager.OriginLongitude - TileManager.TileWidth / 2d + TileManager.TileWidth * i,
                    TileManager.OriginLatitude - TileManager.TileWidth / 2d + TileManager.TileWidth * j,
                    TileManager.OriginLongitude + TileManager.TileWidth / 2d + TileManager.TileWidth * i,
                    TileManager.OriginLatitude + TileManager.TileWidth / 2d + TileManager.TileWidth * j
                    );
                Vector2 pixelPositionMin = WorldToPixelPosition(box.MinLongitude, box.MinLatitude, ZoomLevel);
                Vector2 pixelPositionMax = WorldToPixelPosition(box.MaxLongitude, box.MaxLatitude, ZoomLevel);
                Vector2 pixelSize        = pixelPositionMax - pixelPositionMin;
                Rect    rect             = new Rect(pixelPositionMin.x - pixelOrigin.x - 1, pixelPositionMin.y - pixelOrigin.y + 1, pixelSize.x - 2, pixelSize.y + 2);
                //CustomGUIUtils.DrawFrameBox(rect, red, 1f, redAlpha);
                GUI.DrawTexture(rect, CustomGUIUtils.GetSimpleColorTexture(redAlpha), ScaleMode.StretchToFill, true);
                //Debug.Log(rect);
            }
        }
    }
Example #7
0
    private void DrawJobItemBar(TodoItem item, float y)
    {
        if (item.status == Status.PENDING)
        {
            return;
        }

        Color color = Color.white;

        switch (item.status)
        {
        case Status.PENDING:
            color = XKCDColors.LightRed;
            break;

        case Status.IN_PROGRESS:
            color = XKCDColors.LightRed;
            Rect rect = JobRect(item, y);
            CustomGUIUtils.DrawFrameBox(rect, color, 1f, Color.black);
            rect.width = 200;
            GUI.Label(rect, item.name);
            break;

        case Status.DONE:
            color = XKCDColors.LightAquamarine;
            CustomGUIUtils.DrawFrameBox(JobRect(item, y), color, 1f, Color.black);
            break;

        default:
            statusStyle = GUIStyle.none;
            break;
        }
    }
Example #8
0
 /// <summary>
 /// Draws the GUIAreas with the set Color. Only use in OnGUI()
 /// </summary>
 public static void DrawGUIAreas()
 {
     foreach (Rect rect in insideGUIRects.Values)
     {
         CustomGUIUtils.DrawBox(rect, color);
     }
 }
Example #9
0
    public static void DrawMouseDebug()
    {
        Vector3 mouse = Input.mousePosition.SwapScreenToWorldPoint();

        CustomGUIUtils.DrawBox(
            new Rect(
                mouse.x - CustomHandles.HandlePixelSize,
                mouse.y - CustomHandles.HandlePixelSize,
                CustomHandles.HandlePixelSize * 2,
                CustomHandles.HandlePixelSize * 2), new Color(0f, 1f, 0f, 0.3f));
    }
Example #10
0
    public static void Label(Vector3 point, string text)
    {
        Vector3 position = Camera.main.WorldToScreenPoint(point);

        GUIStyle style = CustomGUIUtils.GetColorTextStyle(Color.black, 14);

        style.alignment = TextAnchor.MiddleCenter;
        Vector2 sizeOfLabel = style.CalcSize(new GUIContent(text));

        Rect rect = new Rect(position.x - (sizeOfLabel.x / 2f), (Screen.height - position.y) - (sizeOfLabel.y / 2f), sizeOfLabel.x, sizeOfLabel.y);

        GUI.Label(rect, text, style);
    }
Example #11
0
    public void OnGUI()
    {
        if (colors.Count > 1)
        {
            tex = CustomGUIUtils.GetGradientTexture(width, height, colors.ToArray());
        }

        if (tex != null)
        {
            //for (int i = 0; i < height; i++)
            //{
            GUI.Label(new Rect(0f, 0f, width, height), tex);
            //}
        }
    }
Example #12
0
    public static bool DrawDefaultInspectorFoldout(this Editor customEditor, MonoBehaviour behaviour, bool showDefaultInspector)
    {
        // Globaly turned the DefaultInspectorFoldout on or off
        if (hideDefaultInspectorFoldout)
        {
            return(false);
        }

        if (showDefaultInspector = EditorGUILayout.Foldout(showDefaultInspector, behaviour.GetType().ToString() + "-Default-Inspector") && behaviour != null)
        {
            CustomGUIUtils.BeginGroup();
            customEditor.DrawDefaultInspector();
            CustomGUIUtils.EndGroup();
        }
        return(showDefaultInspector);
    }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        var mgr    = (GlobalManager)target;
        var levels = mgr.Levels;

        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Levels (" + levels.Length + ")", EditorStyles.boldLabel);

        var toRemove = -1;

        CustomGUIUtils.DrawSeparator();
        for (var i = 0; i < levels.Length; ++i)
        {
            var level = levels[i];
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(level.ToString());
            if (GUILayout.Button("X"))
            {
                toRemove = i;
            }
            EditorGUILayout.EndHorizontal();
        }
        CustomGUIUtils.DrawSeparator();

        if (toRemove >= 0)
        {
            ArrayUtility.RemoveAt(ref levels, toRemove);
            levels = levels.Where(lvl => SceneUtility.IsValidSceneName(lvl.SceneName)).ToArray();
        }

        var sceneName = SceneUtility.InspectSceneSelectionDropdown(null, null);

        if (SceneUtility.IsValidSceneName(sceneName))
        {
            ArrayUtility.Add(ref levels, new LevelInfo(sceneName));
        }

        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            mgr.Levels = levels;
            EditorUtility.SetDirty(target);
        }
    }
Example #14
0
    public static void Label(string text, Rect rect, float angle)
    {
        //Vector3 position = Camera.main.WorldToScreenPoint(point);

        GUIStyle style = CustomGUIUtils.GetColorTextStyle(Color.black, 14);
        //style.alignment = TextAnchor.MiddleCenter;
        //Vector2 sizeOfLabel = style.CalcSize(new GUIContent(text));

        //Rect rect = new Rect(position.x - (sizeOfLabel.x / 2f), (Screen.height - position.y) - (sizeOfLabel.y / 2f), sizeOfLabel.x, sizeOfLabel.y);

        //Vector2 pivotPoint = new Vector2(position.x, Screen.height - position.y);
        //Rect rect = GUILayoutUtility.GetLastRect();
        Vector2 pivotPoint = new Vector2(rect.xMax, rect.yMax);

        GUIUtility.RotateAroundPivot(angle, pivotPoint);
        GUI.Label(rect, text, style);
        GUIUtility.RotateAroundPivot(-angle, pivotPoint);
    }
Example #15
0
    private void DrawTodoItemBar(TodoItem item, float y)
    {
        if (item.status == Status.PENDING)
        {
            return;
        }

        Color color = Color.white;

        switch (item.status)
        {
        case Status.PENDING:
            color = XKCDColors.LightRed;
            break;

        case Status.IN_PROGRESS:
            color = XKCDColors.LightYellow;
            Rect rect = TodoRect(item, y);
            CustomGUIUtils.DrawFrameBox(rect, color, 1f, Color.black);
            rect.width = 200;
            GUI.Label(rect, item.name);
            break;

        case Status.DONE:
            color = XKCDColors.LightGreen;
            Rect rectBox = TodoRect(item, y);
            CustomGUIUtils.DrawFrameBox(rectBox, color, 1f, Color.black);
            //if (rectBox.Contains(Event.current.mousePosition))
            //{
            //    Rect tooltip = new Rect(rectBox);
            //    tooltip.width = 100;
            //    CustomGUIUtils.DrawFrameBox(tooltip, XKCDColors.YellowTan, 1, XKCDColors.YellowOrange);
            //    GUI.Label(tooltip, item.name);

            //}
            break;

        default:
            statusStyle = GUIStyle.none;
            break;
        }
    }
Example #16
0
    private void DrawOSMMap(Rect mapRect)
    {
        // Handle Interaction Mouse-Actions
        Move();
        Zoom();
        SetYouAreHere();

        // Draw Map
        for (int x = left % TileSizePixels; x < left + mapRect.width + TileSizePixels; x += TileSizePixels)
        {
            for (int y = top % TileSizePixels; y < top + mapRect.height + TileSizePixels; y += TileSizePixels)
            {
                Rect      tileRect    = new Rect(x, y, TileSizePixels, TileSizePixels);
                Vector2   tileIndex   = CalculateGridIndex(GUIToCoordinateSystemPosition(tileRect.center));
                Texture2D tileTexture = OSMTileProvider.DownloadTileTexture((int)tileIndex.x, (int)tileIndex.y, ZoomLevel);

                GUI.DrawTexture(tileRect, tileTexture, ScaleMode.ScaleToFit);
                //GUI.Label(tileRect, "TileIndex: " + tileIndex.ToString());
            }
        }

        // Draw TileManager-Selection/Boundings-Settings
        DrawSelection();
        DrawYouAreHere();

        #region Debug-Draw-Methods
        //if (drawGrid)
        //    DrawGrid(mapRect);
        //if (drawOrigin)
        //    DrawOrigin(mapRect);
        //if (drawMouse)
        //    DrawMouse(mapRect);
        #endregion // Debug-Draw-Methods

        // Draw Location Search-Bar
        DrawSearchBar();
        DrawSearchResults();

        CustomGUIUtils.DrawOuterFrame(mapRect, 2, XKCDColors.Black);
    }
Example #17
0
    void OnGUI()
    {
        if (initialized)
        {
            #region sidebar

            if (sidebarOpen)
            {
                sidebarRect = openRect;
            }
            else
            {
                sidebarRect = closedRect;
            }


            CustomGUIUtils.DrawFrameBox(sidebarRect, Color.gray, 3f, Color.black);
            if (GUI.Button(new Rect(sidebarRect.xMax - 10, sidebarRect.height / 2 - 10, 20f, 20f), (sidebarOpen ? DefaultIconSet.ArrowsLeft : DefaultIconSet.ArrowsRight)))
            {
                sidebarOpen = !sidebarOpen;
            }


            if (sidebarOpen)
            {
                scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(openRect.width), GUILayout.Height(openRect.height));

                this.guiMethod();

                GUILayout.EndScrollView();
            }
            else
            {
            }



            #endregion // sidebar
        }
    }
Example #18
0
    public override void OnInspectorGUI()
    {
        var spell = (Spell)target;

        serializedObject.Update();

        // start drawing spell
        spell.Cooldown = EditorGUILayout.FloatField("Cooldown", spell.Cooldown);


        CustomGUIUtils.DrawSeparator();
        InspectSpellTargetSettings(spell.Targets);

        CustomGUIUtils.DrawSeparator();
        InspectCastPhaseTemplate();

        CustomGUIUtils.DrawSeparator();
        InspectProjectilePhaseTemplate();

        CustomGUIUtils.DrawSeparator();
        InspectImpactPhaseTemplate();

        //if (GUI.changed) {
        // write values back
        serializedObject.ApplyModifiedProperties();
        EditorUtility.SetDirty(target);
        //}

        // TODO: For duplicate, we need to also duplicate all ScriptableObject sub assets
//		if (GUILayout.Button ("Duplicate")) {
//			var newSpell = Object.Instantiate(spell) as Spell;
//			ProjectWindowUtil.StartNameEditingIfProjectWindowExists(
//				newSpell.GetInstanceID(),
//				ScriptableObject.CreateInstance<EndNameEdit>(),
//				string.Format("{0}.asset", "new spell"),
//				AssetPreview.GetMiniThumbnail(newSpell),
//				null);
//		}
    }
Example #19
0
    public override void OnInspectorGUI()
    {
        // Update client
        serializedObject.Update();

        this.client.ServerMode = EditorGUILayout.Toggle("Act as Server", this.client.ServerMode);

        // Generate the connection dropdown options/content
        #region Dropdown connections
        var connectionNames = AmqpConfigurationEditor.GetConnectionNames();
        var options         = new List <GUIContent>();

        for (var i = 0; i < connectionNames.Length; i++)
        {
            var cName = connectionNames[i];
            if (string.IsNullOrEmpty(client.Connection) || client.Connection == cName)
            {
                index = i;
            }
            options.Add(new GUIContent(cName));
        }

        // Connections drop down
        string tooltip = "Select the AMQP connection to use. Connections can be configured in the AMQP/Configuration menu.";
        index = EditorGUILayout.Popup(new GUIContent("Connection", tooltip), index, options.ToArray());

        // If the index has changed, record the change
        if (index != lastIndex)
        {
            Undo.RecordObject(target, "Undo Connection change");
        }

        // Set the connection name based on dropdown value
        client.Connection = connection.stringValue = options[index].text;
        #endregion // Dropdown connections

        // Draw the rest of the inspector's default layout
        //DrawDefaultInspector();
        if (GUILayout.Button("Awake"))
        {
            this.client.Awake();
            this.Repaint();
        }
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("EnableUpdate"))
        {
            this.client.EnableUpdate();
            this.Repaint();
        }

        if (GUILayout.Button("DisableUpdate"))
        {
            this.client.DisableUpdate();
            this.Repaint();
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Toggle("IsConnecting?", this.client.isConnecting);
        EditorGUILayout.Toggle("IsConnected?", this.client.IsConnected);
        EditorGUILayout.Toggle("hasConnected?", this.client.hasConnected);
        EditorGUILayout.Toggle("isDisconnecting?", this.client.isDisconnecting);
        EditorGUILayout.Toggle("hasDisconnected?", this.client.hasDisconnected);
        EditorGUILayout.Toggle("isReconnecting?", this.client.isReconnecting);
        EditorGUILayout.Toggle("wasBlocked?", this.client.wasBlocked);
        EditorGUILayout.Toggle("hasAborted?", this.client.hasAborted);
        EditorGUILayout.Toggle("canSubscribe?", this.client.canSubscribe);


        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Connect"))
        {
            this.client.Connect();
            this.Repaint();
        }

        if (GUILayout.Button("Disconnect"))
        {
            this.client.Disconnect();
            this.Repaint();
        }
        EditorGUILayout.EndHorizontal();

        #region Available Queues
        //if (showAvailableQueues = EditorGUILayout.Foldout(showAvailableQueues, "Available Queues:"))
        //{
        EditorGUILayout.BeginVertical("box");
        foreach (var queue in this.client.GetQueues())
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name:", queue.Name);


            if (GUILayout.Button("Subscribe", GUILayout.Width(30)))
            {
                this.client.SubscribeToQueue(queue.Name);
            }

            if (GUILayout.Button("X", GUILayout.Width(30)))
            {
                this.client.DeleteQueue(queue.Name);
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndVertical();
        //}
        #endregion Available Queues

        #region Create Queue
        EditorGUILayout.BeginHorizontal("box");
        this.queueName = EditorGUILayout.TextField("Queue Name", this.queueName);
        if (GUILayout.Button("Create"))
        {
            this.client.DeclareQueue(this.queueName);
        }
        EditorGUILayout.EndHorizontal();
        #endregion // Create Queue

        #region Subscribe Queue
        AmqpQueue[] queues = this.client.GetQueues();
        string[]    names  = new string[queues.Length];
        for (int i = 0; i < queues.Length; i++)
        {
            names[i] = queues[i].Name;
        }

        selectedQueue = EditorGUILayout.Popup("Queue", selectedQueue, names);
        if (queues.Length != 0)
        {
            if (GUILayout.Button("Subscribe to " + names[this.selectedQueue] + " Queue"))
            {
                this.client.SubscribeToQueue(names[this.selectedQueue]);
            }
        }
        #endregion // Subscribe Queue


        if (this.client.ServerMode)
        {
            #region JobQueue
            string[] jobQueueNames = new string[this.client.GetQueues().Length];
            for (int i = 0; i < this.client.GetQueues().Length; i++)
            {
                jobQueueNames[i] = this.client.GetQueues()[i].Name;
            }

            this.jobQueueIndex = EditorGUILayout.Popup("JobQueue", this.jobQueueIndex, jobQueueNames);
            for (int i = 0; i < jobQueueNames.Length; i++)
            {
                if (jobQueueNames[i] == "jobs")
                {
                    this.jobQueueIndex = i;
                    break;
                }
            }
            string jobQueueName = this.client.GetQueues().Length == 0 ? "not set" : jobQueueNames[this.jobQueueIndex];
            //EditorGUILayout.LabelField("JobQueue", jobQueueName);
            #endregion // JobQueue

            #region ReplyQueue
            string[] replyToQueueNames = new string[this.client.GetQueues().Length];
            for (int i = 0; i < this.client.GetQueues().Length; i++)
            {
                replyToQueueNames[i] = this.client.GetQueues()[i].Name;
            }

            this.replyQueueIndex = EditorGUILayout.Popup("ReplyToQueue", this.replyQueueIndex, replyToQueueNames);
            for (int i = 0; i < replyToQueueNames.Length; i++)
            {
                if (replyToQueueNames[i] == "reply")
                {
                    this.replyQueueIndex = i;
                    break;
                }
            }
            string replyQueueName = this.client.GetQueues().Length == 0 ? "not set" : replyToQueueNames[this.replyQueueIndex];
            //EditorGUILayout.LabelField("ReplyToQueue", replyQueueName);
            #endregion // JobQueue

            #region JobQueue
            string[] statusUpdateQueueNames = new string[this.client.GetQueues().Length];
            for (int i = 0; i < this.client.GetQueues().Length; i++)
            {
                statusUpdateQueueNames[i] = this.client.GetQueues()[i].Name;
            }

            this.statusUpdateQueueIndex = EditorGUILayout.Popup("ReplyToQueue", this.statusUpdateQueueIndex, statusUpdateQueueNames);
            for (int i = 0; i < statusUpdateQueueNames.Length; i++)
            {
                if (statusUpdateQueueNames[i] == "statusUpdates")
                {
                    this.statusUpdateQueueIndex = i;
                    break;
                }
            }
            string statusUpdateQueueName = this.client.GetQueues().Length == 0 ? "not set" : statusUpdateQueueNames[this.statusUpdateQueueIndex];
            //EditorGUILayout.LabelField("ReplyToQueue", replyQueueName);
            #endregion // JobQueue


            EditorGUILayout.BeginVertical("box");
            TileManager.TileWidth       = (double)EditorGUILayout.FloatField("TileWidth", (float)TileManager.TileWidth);
            TileManager.tileRadius      = EditorGUILayout.IntField("TileRadius", TileManager.tileRadius);
            TileManager.LOD             = EditorGUILayout.IntField("LOD", TileManager.LOD);
            TileManager.OriginLatitude  = (double)EditorGUILayout.FloatField("OriginLatitude", (float)TileManager.OriginLatitude);
            TileManager.OriginLongitude = (double)EditorGUILayout.FloatField("OriginLongitude", (float)TileManager.OriginLongitude);
            EditorGUILayout.EndVertical();

            this.client.method = (SerializationMethod)EditorGUILayout.EnumPopup("SerializationMethod", this.client.method);

            if (GUILayout.Button("Send OSM-Job-Messages"))
            {
                this.client.SendOSMJobMessages(
                    jobQueueName,
                    replyQueueName,
                    statusUpdateQueueName,
                    TileManager.tileRadius,
                    TileManager.TileWidth,
                    TileManager.OriginLongitude,
                    TileManager.OriginLatitude,
                    this.client.method);
            }

            if (GUILayout.Button("Generate locally"))
            {
                mainScene = EditorSceneManager.GetActiveScene();

                swComplete.Start();

                tiles = new List <Tile>();

                for (int i = -TileManager.tileRadius; i <= TileManager.tileRadius; i++)
                {
                    for (int j = -TileManager.tileRadius; j <= TileManager.tileRadius; j++)
                    {
                        jobs++;
                        Stopwatch sw = new Stopwatch();
                        sw.Reset();
                        sw.Start();

                        Tile newTile = Tile.CreateTileGO(i, j, 5);
                        tiles.Add(newTile);
                        tileJobsLocal.Add(i + "/" + j, newTile);
                        tileJobsStopwatchLocal.Add(i + "/" + j, sw);
                        //newTile.ProceduralDone += GenerationDone;
                        //newTile.StartQuery();

                        //EditorSceneManager.SaveScenes
                        //SceneManager.SetActiveScene(mainScene);
                    }
                }

                tiles[0].ProceduralDone += GenerationDone;
                tiles[0].StartQuery();
            }
        }
        else // Client-Mode
        {
            #region JobQueue
            string[] jobQueueNames = new string[this.client.GetQueues().Length];
            for (int i = 0; i < this.client.GetQueues().Length; i++)
            {
                jobQueueNames[i] = this.client.GetQueues()[i].Name;
            }

            this.jobQueueIndex = EditorGUILayout.Popup("JobQueue", this.jobQueueIndex, jobQueueNames);
            string jobQueueName = this.client.GetQueues().Length == 0 ? "not set" : jobQueueNames[this.jobQueueIndex];
            EditorGUILayout.LabelField("JobQueue", jobQueueName);
            if (jobQueueNames.Length != 0)
            {
                if (GUILayout.Button("Subscribe to " + jobQueueNames[this.jobQueueIndex] + " Queue"))
                {
                    //this.client.BasicQos(1, 1, true);
                    this.client.SubscribeToQueue(jobQueueNames[this.jobQueueIndex]);
                }
            }

            #endregion // JobQueue
        }

        GUI.backgroundColor = Color.white;
        EditorGUILayout.BeginVertical("box");
        {
            foreach (StatusUpdateMessage item in SimpleClient.jobStatus.Values)
            {
                CustomGUIUtils.BeginGroup();
                {
                    switch (item.status)
                    {
                    case Status.PENDING:
                        statusStyle = lightRed;
                        break;

                    case Status.IN_PROGRESS:
                        statusStyle = lightYellow;
                        break;

                    case Status.DONE:
                        statusStyle = lightGreen;
                        break;

                    default:
                        statusStyle = GUIStyle.none;
                        break;
                    }
                    EditorGUILayout.BeginHorizontal(statusStyle);
                    EditorGUILayout.LabelField("" + item.jobID, GUILayout.Width(20f));
                    EditorGUILayout.LabelField("" + item.name, GUILayout.Width(80f));
                    EditorGUILayout.EndHorizontal();

                    foreach (string todo in item.childTodos)
                    {
                        CustomGUIUtils.BeginGroup();
                        TodoItem todoItem = item.childDict[todo];
                        switch (todoItem.status)
                        {
                        case Status.PENDING:
                            statusStyle = lightRed;
                            break;

                        case Status.IN_PROGRESS:
                            statusStyle = lightYellow;
                            break;

                        case Status.DONE:
                            statusStyle = lightGreen;
                            break;

                        default:
                            statusStyle = GUIStyle.none;
                            break;
                        }
                        EditorGUILayout.BeginHorizontal(statusStyle);
                        EditorGUILayout.LabelField(todoItem.name);
                        EditorGUILayout.EndHorizontal();
                        DrawTodoItem(todoItem);

                        CustomGUIUtils.EndGroup();
                    }
                }
                CustomGUIUtils.EndGroup();
            }
        }
        EditorGUILayout.EndVertical();

        // Save/serialized modified connection
        serializedObject.ApplyModifiedProperties();

        // Update the last connection index
        lastIndex = index;
    }
Example #20
0
    public override void OnInspectorGUI()
    {
        GUILayout.Label("Behaviour_Node2D-Editor", EditorStyles.boldLabel);

        if (Selection.gameObjects.Length >= 2)
        {
            if (GUILayout.Button("Merge Nodes"))
            {
                GameObject     node1          = Selection.gameObjects[0];
                Node_Behaviour node1Behaviour = node1.GetComponent <Node_Behaviour>();
                Node           node1Node      = node1Behaviour.Node;

                List <GameObject> mergeNodesGOs = new List <GameObject>();
                List <Node>       combineNodes  = new List <Node>();
                for (int i = 1; i < Selection.gameObjects.Length; i++)
                {
                    GameObject     node2          = Selection.gameObjects[1];
                    Node_Behaviour node2Behaviour = node2.GetComponent <Node_Behaviour>();
                    Node           node2Node      = node2Behaviour.Node;
                    combineNodes.Add(node2Node);
                    mergeNodesGOs.Add(node2);
                }

                node1Node.MergeWith(combineNodes.ToArray());
                foreach (GameObject go in mergeNodesGOs)
                {
                    DestroyImmediate(go);
                }
            }
        }


        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        //// Get Position from changes in the VectorField in Inspection
        Vector3 oldPosition = node.Position;
        Vector3 newPosition = EditorGUILayout.Vector3Field("Position", node.Position);

        if (oldPosition != newPosition)
        {
            Debug.Log("Auslöser Node2D-Editor-OnInspectorGUI");
            node.Position = newPosition;
            nodeBehaviour.transform.position = newPosition;
        }


        if (nodeBehaviour != null && node != null)
        {
            EditorGUILayout.Separator();
            if (edgesFoldout = EditorGUILayout.Foldout(edgesFoldout, "Edges"))
            {
                CustomGUIUtils.BeginGroup();

                if (arrivalsFoldout = EditorGUILayout.Foldout(arrivalsFoldout, "Arrivals (" + node.ArrivalDegree.ToString() + ")"))
                {
                    CustomGUIUtils.BeginGroup();
                    int count = 0;
                    foreach (Edge edge in node.Arrivals)
                    {
                        EditorGUILayout.LabelField("Arrival " + count++, edge.Id);
                    }
                    CustomGUIUtils.EndGroup();
                }

                if (departuresFoldout = EditorGUILayout.Foldout(departuresFoldout, "Departures (" + node.DepartureDegree.ToString() + ")"))
                {
                    CustomGUIUtils.BeginGroup();
                    int count = 0;
                    foreach (Edge edge in node.Departures)
                    {
                        EditorGUILayout.LabelField("Departure " + count++, edge.Id);
                    }
                    CustomGUIUtils.EndGroup();
                }

                if (EditorGUILayout.Foldout(listenerFoldout, "Listeners"))
                {
                    CustomGUIUtils.BeginGroup();
                    int count = 0;

                    foreach (string name in node.PrintEventHandlers())
                    {
                        EditorGUILayout.LabelField("" + count++, name);
                    }
                    CustomGUIUtils.EndGroup();
                }

                CustomGUIUtils.EndGroup();
            }
        }

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        if (advancedGizmoSettings = EditorGUILayout.Foldout(advancedGizmoSettings, "Behaviour_Edge2D-Advanced-Gizmo-Settings"))
        {
            CustomGUIUtils.BeginGroup();
            Node_Behaviour.NodeGizmoSize                = (Node_Behaviour.GizmoSize)EditorGUILayout.EnumPopup("GizmoSize", Node_Behaviour.NodeGizmoSize);
            Node_Behaviour.DrawLabels                   = EditorGUILayout.Toggle("Show Label", Node_Behaviour.DrawLabels);
            nodeBehaviour.DrawHelpLinesGizmo            = EditorGUILayout.Toggle("Show Help-Lines", nodeBehaviour.DrawHelpLinesGizmo);
            nodeBehaviour.DrawSecondLevelHelpLinesGizmo = EditorGUILayout.Toggle("Show SecondLevel Help-Lines", nodeBehaviour.DrawSecondLevelHelpLinesGizmo);

            Node_Behaviour.DrawAnglePieGizmoMaster = EditorGUILayout.Toggle("Draw Angle-Pie Gizmo", Node_Behaviour.DrawAnglePieGizmoMaster);

            if (Node_Behaviour.DrawAnglePieGizmoMaster)
            {
                CustomGUIUtils.BeginGroup();
                nodeBehaviour.DrawAnglePieGizmo = EditorGUILayout.Toggle("Draw Angle-Pie Gizmo", nodeBehaviour.DrawAnglePieGizmo);
                if (nodeBehaviour.DrawAnglePieGizmo)
                {
                    Node_Behaviour.DrawAnglePieGizmoDynamic = EditorGUILayout.Toggle("Dynamic Radius", Node_Behaviour.DrawAnglePieGizmoDynamic);

                    if (!Node_Behaviour.DrawAnglePieGizmoDynamic)
                    {
                        nodeBehaviour.AnglePieGizmoRadius = EditorGUILayout.Slider("Radius", nodeBehaviour.AnglePieGizmoRadius, 0f, 10f);
                    }
                }
                CustomGUIUtils.EndGroup();
            }
            CustomGUIUtils.EndGroup();
        }

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        // Draw the DefaultInspector for this Behvaiour
        showDefaultInspector = this.DrawDefaultInspectorFoldout(nodeBehaviour, showDefaultInspector);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(nodeBehaviour);
        }
    }
Example #21
0
 static ColorWheel()
 {
     BlackTransparentGradient = CustomGUIUtils.GetGradientTexture(255, 1, new Color(0, 0, 0, 1f), Color.black);
 }
Example #22
0
    public static void ColorPicker(string name, Rect boundingRect, ref float angle, ref float radius, ref float dimm, ref Color color)
    {
        // Draw bounding Rectangle
        Rect newBounds = new Rect(boundingRect);

        newBounds.height += 70f;
        newBounds         = newBounds.AddFrame(4);
        GUIAreas.Add(name, newBounds);
        CustomGUIUtils.DrawFrameBox(newBounds, Color.white, 1f, Color.black);
        CustomGUIUtils.DrawFrameBox(boundingRect, Color.white, 1f, Color.black);

        // Calculate box-values
        float boxWidth     = Mathf.Min(boundingRect.width, boundingRect.height);
        float boxWidthHalf = boxWidth / 2f;

        // Draw Color-Wheel
        GUI.DrawTexture(boundingRect, DefaultIconSet.ColorWheel);

        // Get old State
        if (!colorPickers.TryGetValue(name, out currentColorPicker))
        {
            currentColorPicker = new ColorPickerProperties();
            //currentColorPicker.pickerXY = new Vector2(boxWidthHalf, boxWidthHalf);
            colorPickers.Add(name, currentColorPicker);
        }

        if (!currentColorPicker.isDragging)
        {
            // Calculate Vector for the PickerPosition
            Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
            Vector3    vect     = rotation * Vector3.left;
            Debug.Log(vect);

            currentColorPicker.pickerXY = vect.normalized * ((boxWidthHalf / 100) * radius) + boundingRect.Position().Vector3FromVector2XY();
            Debug.Log("Calculated Color Picker: " + currentColorPicker.pickerXY);

            currentColorPicker.dimm   = dimm;
            currentColorPicker.angle  = angle;
            currentColorPicker.radius = radius;
        }

        Vector3 mousePosition = Input.mousePosition.SwapScreenToWorldPoint();
        Vector2 mouseXY       = new Vector2(mousePosition.x, mousePosition.y);

        // Draw Picker
        Rect pickerRect = new Rect(
            currentColorPicker.pickerXY.x + boundingRect.xMin - 10f,
            currentColorPicker.pickerXY.y + boundingRect.yMin - 10f,
            20f,
            20f);

        GUI.DrawTexture(pickerRect, DefaultIconSet.Location);

        // Handle Mouse-Input
        if (pickerRect.Contains(Input.mousePosition.SwapScreenToWorldPoint()) && Input.GetMouseButtonDown(0))
        {
            currentColorPicker.isDragging = true;
        }
        else if (currentColorPicker.isDragging && Input.GetMouseButton(0))
        {
            // Set Color-Picker Position
            currentColorPicker.pickerXY = mouseXY - boundingRect.Position();

            Vector2 direction = mouseXY - boundingRect.center;
            if (mouseXY.y > boundingRect.center.y)
            {
                angle = 360 - Vector2.Angle(-Vector2.right, direction);
            }
            else
            {
                angle = Vector2.Angle(-Vector2.right, direction);
            }


            float magnitude = direction.magnitude / (boxWidthHalf / 100);
            radius = Mathf.Clamp(magnitude, 0f, 100f);

            currentColorPicker.pickerXY = boundingRect.Position() + direction.normalized * Mathf.Clamp(magnitude, 0, boxWidthHalf);

            currentColorPicker.angle  = angle;
            currentColorPicker.radius = radius;
        }
        else if (currentColorPicker.isDragging && Input.GetMouseButtonUp(0))
        {
            currentColorPicker.isDragging = false;
        }

        // Calculate Pixel Coordinates of the picker in the ColorWheel
        Vector2 pixelCoords = new Vector2();

        pixelCoords.x = ((float)DefaultIconSet.ColorWheel.width / boxWidth) * currentColorPicker.pickerXY.x;
        pixelCoords.y = DefaultIconSet.ColorWheel.height - ((float)DefaultIconSet.ColorWheel.height / boxWidth) * currentColorPicker.pickerXY.y;
        //Debug.Log("pixelcoords: " + pixelCoords);

        color = DefaultIconSet.ColorWheel.GetPixel((int)pixelCoords.x, (int)pixelCoords.y);

        // Draw Dimmer-Gradient-Color-View
        CustomGUIUtils.DrawFrameBox(new Rect(boundingRect.xMin, boundingRect.yMax + 5, boxWidth, 25), color, 1f, Color.black);
        GUI.DrawTexture(new Rect(boundingRect.xMin, boundingRect.yMax + 5, boxWidth, 25), BlackTransparentGradient);

        angle  = currentColorPicker.angle;
        radius = currentColorPicker.radius;
        dimm   = GUI.HorizontalSlider(new Rect(boundingRect.xMin, boundingRect.yMax + 40f, boxWidth, 20), Mathf.Clamp(currentColorPicker.dimm, 0, 100), 0f, 100f);;
        currentColorPicker.dimm = dimm;

        // Draw Dimmer-Label
        GUIStyle style = CustomGUIUtils.GetColorTextStyle(Color.black, 14);

        style.alignment = TextAnchor.MiddleCenter;
        GUI.Label(new Rect(boundingRect.xMin, boundingRect.yMax + 50f, boxWidth, 20), ((int)dimm).ToString(), style);
        //Debug.Log(currentColorPicker.pickerXY.ToString() + "  angle: " + angle + "  r=" + radius + "  dimm=" + dimm);
        colorPickers[name] = currentColorPicker;
    }
Example #23
0
    public override void OnInspectorGUI()
    {
        if (GUILayout.Button("Create Node"))
        {
            graphBehaviour.CreateNodeBehaviour(Vector3.zero);
        }


        //if (nodesFoldout = EditorGUILayout.Foldout(nodesFoldout, "Nodes (" + graph.Nodes.Count + ")"))
        //{
        //    CustomGUIUtils.BeginGroup();
        //    int count = 1;
        //    foreach (Node node in graph.Nodes)
        //    {
        //        EditorGUILayout.LabelField("Node " + count++, node.Id);
        //        //EditorGUILayout.ObjectField(edgeBeh, typeof(Behaviour_Edge2D), GUILayout.ExpandWidth(true));
        //    }
        //    CustomGUIUtils.EndGroup();
        //}


        //if (edgesFoldout = EditorGUILayout.Foldout(edgesFoldout, "Edges (" + graph.Edges.Count + ")"))
        //{
        //    CustomGUIUtils.BeginGroup();
        //    int count = 1;
        //    foreach (Edge edge in graph.Edges)
        //    {
        //        EditorGUILayout.LabelField("Edge " + count++, edge.Id);
        //        //EditorGUILayout.ObjectField(edgeBeh, typeof(Behaviour_Edge2D), GUILayout.ExpandWidth(true));
        //    }
        //    CustomGUIUtils.EndGroup();
        //}

        if (nodesFoldout = EditorGUILayout.Foldout(nodesFoldout, "Node Behaviours (" + graphBehaviour.NodeBehaviours.Count + ")"))
        {
            CustomGUIUtils.BeginGroup();
            int count = 1;
            foreach (Node_Behaviour nodeBehaviour in graphBehaviour.NodeBehaviours)
            {
                EditorGUILayout.LabelField("NodeBehaviour " + count++, nodeBehaviour.Node.Id);
                //EditorGUILayout.ObjectField(edgeBeh, typeof(Behaviour_Edge2D), GUILayout.ExpandWidth(true));
            }
            CustomGUIUtils.EndGroup();
        }


        if (edgesFoldout = EditorGUILayout.Foldout(edgesFoldout, "Edge Behaviours (" + graphBehaviour.EdgeBehaviours.Count + ")"))
        {
            CustomGUIUtils.BeginGroup();
            int count = 1;
            foreach (Edge_Behaviour edgeBehaviour in graphBehaviour.EdgeBehaviours)
            {
                EditorGUILayout.LabelField("EdgeBehaviour " + count++, edgeBehaviour.Edge.Id);
                //EditorGUILayout.ObjectField(edgeBeh, typeof(Behaviour_Edge2D), GUILayout.ExpandWidth(true));
            }
            CustomGUIUtils.EndGroup();
        }



        EditorGUILayout.Separator();
        EditorGUILayout.Separator();
        // Draw the DefaultInspector for this Behvaiour
        showDefaultInspector = this.DrawDefaultInspectorFoldout(graphBehaviour, showDefaultInspector);


        if (GUI.changed)
        {
            EditorUtility.SetDirty(graphBehaviour);
        }
    }
Example #24
0
    void OnGUI()
    {
        CustomGUIUtils.BeginSideBar("sidebarLeft", SidebarType.LEFT, new Rect(0f, 100f, Screen.width / 4f, 300f), false, 2f, EasingCurves.EaseType.linear, 2f);

        GUILayout.BeginHorizontal();
        GUILayout.Label("WallHeight:", GUILayout.Width(70f), GUILayout.Height(30f));
        GUILayout.HorizontalSlider(2f, 0f, 10f, GUILayout.Height(30f));
        GUILayout.EndHorizontal();

        CustomGUIUtils.EndSideBar();

        CustomGUIUtils.BeginSideBar("sidebarRight",
                                    SidebarType.RIGHT,
                                    new Rect(0f, 100f, 200f, 300f),
                                    false,
                                    5f,
                                    EasingCurves.EaseType.easeInBounce,
                                    EasingCurves.EaseType.easeInOutBounce,
                                    2f);
        GUILayout.Button("Button");



        CustomGUIUtils.EndSideBar();

        CustomGUIUtils.BeginSideBar("sidebarTop",
                                    SidebarType.TOP,
                                    new Rect(250f, 100f, 200f, 300f),
                                    false,
                                    7f,
                                    EasingCurves.EaseType.easeInElastic,
                                    EasingCurves.EaseType.easeOutElastic,
                                    2f);
        GUILayout.Button("Button");
        CustomGUIUtils.EndSideBar();

        CustomGUIUtils.BeginSideBar("sidebarBottom",
                                    SidebarType.BOTTOM,
                                    new Rect(500f, 100f, 200f, 300f),
                                    false,
                                    10f,
                                    EasingCurves.EaseType.easeInSine,
                                    EasingCurves.EaseType.easeOutSine,
                                    2f);
        GUILayout.Button("Button");
        CustomGUIUtils.EndSideBar();


        CustomGUIUtils.BeginSideBar("sidebarMiddleTOP",
                                    SidebarType.TOP,
                                    new Rect(130, 200, 400, 200),
                                    new Rect(0, 0, 100f, 200f),
                                    false,
                                    10f,
                                    EasingCurves.EaseType.easeInSine,
                                    EasingCurves.EaseType.easeOutSine,
                                    2f);
        GUILayout.Button("Button");
        GUILayout.Button("Button");

        GUILayout.Button("Button");

        CustomGUIUtils.EndSideBar();

        CustomGUIUtils.BeginSideBar("sidebarMiddleRIGHT",
                                    SidebarType.RIGHT,
                                    new Rect(130, 200, 400, 200),
                                    new Rect(0, 0, 200f, 100f),
                                    false,
                                    10f,
                                    EasingCurves.EaseType.easeInSine,
                                    EasingCurves.EaseType.easeOutSine,
                                    2f);
        GUILayout.Button("Button");
        CustomGUIUtils.EndSideBar();

        CustomGUIUtils.BeginSideBar("sidebarMiddleLEFT",
                                    SidebarType.LEFT,
                                    new Rect(130, 200, 400, 200),
                                    new Rect(0, 0, 100f, 200f),
                                    false,
                                    10f,
                                    EasingCurves.EaseType.easeInSine,
                                    EasingCurves.EaseType.easeOutSine,
                                    2f);

        GUILayout.Button("Button");

        CustomGUIUtils.EndSideBar();

        CustomGUIUtils.BeginSideBar("sidebarMiddleBOTTOM",
                                    SidebarType.BOTTOM,
                                    new Rect(130, 200, 400, 200),
                                    new Rect(100, 0, 200f, 100f),
                                    false,
                                    10f,
                                    EasingCurves.EaseType.easeInSine,
                                    EasingCurves.EaseType.easeOutSine,
                                    2f);
        GUILayout.Button("Button");
        CustomGUIUtils.EndSideBar();



        //float lineHeight = 50f;
        //float lineSeparator = 3f;

        //Rect parent = CustomGUIUtils.BeginSideBar("sidebarLeft", SidebarType.LEFT, new Rect(0f, 100f, Screen.width / 4f, 400f), false, 2f, EasingCurves.EaseType.easeInQuart, EasingCurves.EaseType.easeOutQuart, 2f);

        //////GUILayout.BeginHorizontal();
        //////GUILayout.Label("WallHeight:", GUILayout.Width(70f), GUILayout.Height(30f));
        //////GUILayout.HorizontalSlider(2f, 0f, 10f, GUILayout.Height(30f));
        //////GUILayout.EndHorizontal();

        ////Debug.Log(parent);
        //for (int i = 0; i < 10; i++)
        //{
        //    CustomGUIUtils.BeginSideBar("sidebarLeft" + i, SidebarType.LEFT, parent, new Rect(0f, lineHeight * i + lineSeparator * i, parent.width - 20, lineHeight), false, 2f, EasingCurves.EaseType.easeInQuart, EasingCurves.EaseType.easeOutQuart, 2f);
        //    GUILayout.Label("sidebarLeft" + i);

        //    CustomGUIUtils.EndSideBar();
        //}

        //////CustomGUIUtils.BeginSideBar("sidebarMiddleBOTTOM",
        //////    SidebarType.LEFT,
        //////    parent,
        //////    new Rect(0, 0, 200f, 100f),
        //////    false,
        //////    10f,
        //////    EasingCurves.EaseType.easeInSine,
        //////    EasingCurves.EaseType.easeOutSine,
        //////    2f);
        //////GUILayout.Button("Button");
        //////CustomGUIUtils.EndSideBar();


        //if (GUILayout.Button("showDialog"))
        //{
        //    Debug.Log("clicked");
        //    showDialog = true;

        //}

        //CustomGUIUtils.EndSideBar();

        //DialogResultType result = DialogResultType.UNDEFINED;

        //if (showDialog)
        //{
        //    result = CustomGUIUtils.Dialog(DialogType.OK, "Bleh", "bleh bleh bleh...", new Rect(Screen.width / 4f, Screen.height / 4f, Screen.width / 2f, Screen.height / 2f), 1f, ref showDialog);
        //}

        //switch (result)
        //{
        //    case DialogResultType.YES:
        //        break;
        //    case DialogResultType.NO:
        //        break;
        //    case DialogResultType.CANCEL:
        //        break;
        //    case DialogResultType.OK:
        //        break;
        //    case DialogResultType.UNDEFINED:
        //        break;
        //    default:
        //        break;
        //}
    }
Example #25
0
    public void OnGUI()
    {
        GUI.Label(new Rect(boxWidth + 50, 0, 500, 500), "Dragging String = " + draggingString + "\n strings.Count " + strings.Count + "\n" + strings.ListToString <String>());

        accumulatedHeight = gap;

        // Draw DropAreas
        for (int i = 0; i < strings.Count; i++)
        {
            if (dragNDrop.DropAreaBegin(i.ToString()))
            {
                CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Orangeish);
                //GUI.Label(dragNDrop.ThisDropArea.Rect, "  " + i + ". " + dragNDrop.ThisDropArea.ToString());
                GUI.Label(dragNDrop.ThisDropArea.Rect, "   " + i);

                dragNDrop.ThisDropArea.Rect = new Rect(gap, accumulatedHeight, boxWidth, boxHeight);
                accumulatedHeight          += gap + boxHeight;

                dragNDrop.SetObject(i.ToString(), strings[i]);
                dragNDrop.DropAreaEnd(i.ToString());
            }
        }


        accumulatedHeight = gap;
        List <String> concurrentStrings = new List <string>(strings);
        int           currentItem       = 0;

        foreach (String str in concurrentStrings)
        {
            DragObject currentstr = dragNDrop.TryGetDragObject(str);

            int i = concurrentStrings.IndexOf(str);

            if (currentstr.IsDragging)
            {
                draggingStringOldIndex = i;
                draggingString         = strings[i];
                strings.RemoveAt(i);
                Debug.Log("Dragging String = " + draggingString + "\n" + strings.ListToString <String>());
            }
            if (dragNDrop.DragObjectBegin(concurrentStrings[i]))
            {
                CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
                GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, concurrentStrings[i].ToString());

                Rect icon = new Rect(dragNDrop.CurrentDragObject.CurrentRect);
                icon.width = icon.height;
                GUI.DrawTexture(icon, DefaultIconSet.Device);
                dragNDrop.DragObjectEnd(concurrentStrings[i]);
            }

            currentItem++;
        }


        if (draggingString != null)
        {
            for (int i = 0; i < strings.Count; i++)
            {
                DropArea dropArea;
                if (dragNDrop.dropAreas.TryGetValue(i.ToString(), out dropArea))
                {
                    dragNDrop.TryCreateDropArea("before" + i, null, new Rect(dropArea.Rect.x, dropArea.Rect.y, dropArea.Rect.width, dropArea.Rect.height / 2f), dropArea.Types.ToArray());
                    dragNDrop.TryCreateDropArea("after" + i, null, new Rect(dropArea.Rect.x, dropArea.Rect.y + dropArea.Rect.height / 2f, dropArea.Rect.width, dropArea.Rect.height / 2f), dropArea.Types.ToArray());

                    if (dragNDrop.DropAreaBegin("before" + i))
                    {
                        if (dragNDrop.ThisDropArea.ContainsMouse())
                        {
                            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Greenish);
                            //GUI.Label(dragNDrop.ThisDropArea.Rect, "  " + i + ". " + dragNDrop.ThisDropArea.ToString());
                            GUI.Label(dragNDrop.ThisDropArea.Rect, "before   " + i);
                        }
                        dragNDrop.DropAreaEnd("before" + i);
                    }

                    if (dragNDrop.DropAreaBegin("after" + i))
                    {
                        //CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Greenish);
                        ////GUI.Label(dragNDrop.ThisDropArea.Rect, "  " + i + ". " + dragNDrop.ThisDropArea.ToString());
                        //GUI.Label(dragNDrop.ThisDropArea.Rect, "after   " + i);
                        if (dragNDrop.ThisDropArea.ContainsMouse())
                        {
                            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Greenish);
                            //GUI.Label(dragNDrop.ThisDropArea.Rect, "  " + i + ". " + dragNDrop.ThisDropArea.ToString());
                            GUI.Label(dragNDrop.ThisDropArea.Rect, "after   " + i);
                        }
                        dragNDrop.DropAreaEnd("after" + i);
                    }
                }
            }


            bool newDropArea = false;
            if (dragNDrop.DragObjectBegin(draggingString))
            {
                CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
                GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, draggingString.ToString());

                Rect icon = new Rect(dragNDrop.CurrentDragObject.CurrentRect);
                icon.width = icon.height;
                GUI.DrawTexture(icon, DefaultIconSet.Device);
                newDropArea = dragNDrop.DragObjectEnd(draggingString);
            }

            //if (newDropArea)
            //{

            //}

            DragObject currentstr = dragNDrop.TryGetDragObject(draggingString);
            if (!currentstr.IsDragging)
            {
                Debug.Log(currentstr.DropArea.Id);
                if (currentstr.DropArea.Id.StartsWith("before") || currentstr.DropArea.Id.StartsWith("after"))
                {
                    if (currentstr.DropArea.Id.StartsWith("before"))
                    {
                        int newIndex = int.Parse(currentstr.DropArea.Id.Replace("before", ""));
                        strings.Insert(newIndex, draggingString);
                    }
                    else if (currentstr.DropArea.Id.StartsWith("after"))
                    {
                        int newIndex = int.Parse(currentstr.DropArea.Id.Replace("after", "")) + 1;
                        strings.Insert(newIndex, draggingString);
                        currentstr.t           = 0f;
                        currentstr.Ease        = true;
                        currentstr.EaseEndRect = dragNDrop.dropAreas[newIndex.ToString()].Rect;
                    }
                }
                else
                {
                    //strings.Capacity += 1;
                    Debug.Log("old Index" + draggingStringOldIndex);
                    strings.Insert(draggingStringOldIndex, draggingString);
                }
                draggingString         = null;
                draggingStringOldIndex = -1;
            }
        }
    }
Example #26
0
    public void OnGUI()
    {
        for (int i = 0; i < 4; i++)
        {
            dragNDrop.DropAreaBegin("A" + i);
            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightRed);
            GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
            dragNDrop.DropAreaEnd("A" + i);


            dragNDrop.DropAreaBegin("B" + i);
            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.GreenApple);
            GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
            dragNDrop.DropAreaEnd("B" + i);


            dragNDrop.DropAreaBegin("C" + i);
            CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue);
            GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
            dragNDrop.DropAreaEnd("C" + i);
        }

        dragNDrop.DropAreaBegin("D");
        CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue);
        GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
        dragNDrop.DropAreaEnd("D");

        dragNDrop.DropAreaBegin("inner1");
        CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightRed);
        GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
        dragNDrop.DropAreaEnd("inner1");

        dragNDrop.DropAreaBegin("inner2");
        CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.GreenApple);
        GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString());
        dragNDrop.DropAreaEnd("inner2");


        foreach (String stri in strings)
        {
            dragNDrop.DragObjectBegin(stri);
            CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
            GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, stri.ToString());
            GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device);
            dragNDrop.DragObjectEnd(stri);
        }



        foreach (object obj in objects)
        {
            dragNDrop.DragObjectBegin(obj);

            if (dragNDrop.CurrentDragObject.IsDragging)
            {
                Rect drawRect = dragNDrop.CurrentDragObject.CurrentRect;
                drawRect.width = drawRect.height = 50;
                drawRect.x     = InputHelpers.MouseOnGUI().x - drawRect.width / 2;
                drawRect.y     = InputHelpers.MouseOnGUI().y - drawRect.height / 2;
                GUI.DrawTexture(drawRect, DefaultIconSet.Device);
            }
            else
            {
                CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey);
                GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, obj.ToString());
                GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device);
            }



            dragNDrop.DragObjectEnd(obj);
        }


        //foreach (DropArea dropArea in dragNDrop.dropAreas.Values)
        //{
        //    if (dropArea.Object != null)
        //    {
        //        if (dropArea.Object.GetType() == typeof(A))
        //        {
        //            A readA = dropArea.GetObject<A>();
        //            Debug.Log("A gelesen: " + readA.ToString());
        //        }
        //    }
        //}
    }
Example #27
0
 private static void DrawVerticalLine(Rect rect, float x, Color color)
 {
     //if (x > rect.xMin && x < rect.xMax)
     CustomGUIUtils.DrawBox(new Rect(x, rect.yMin, 1, rect.height), color);
 }
Example #28
0
 private static void DrawHorizontalLine(Rect rect, float y, Color color)
 {
     //if (y > rect.yMin && y < rect.yMax)
     CustomGUIUtils.DrawBox(new Rect(rect.xMin, y, rect.width, 1), color);
 }
Example #29
0
 private static void DrawDot(Vector2 center)
 {
     CustomGUIUtils.DrawBox(new Rect(center.x - 1, center.y - 1, 3, 3), Color.black);
 }
Example #30
0
 static void Init()
 {
     here       = Resources.Load("here") as Texture2D;
     lightGreen = CustomGUIUtils.GetColorBackgroundStyle(XKCDColors.LightGreen);
 }