Esempio n. 1
0
        /* ----------------------------------
         * ON GUI: Used for drawing the window every unity event
         * ----------------------------------*/
        public override void Draw(int aID)
        {
            if (mapScene == null)
            {
                GUILayout.Label("There is no selected element. Please select or create one.");
                return;
            }


            if (placeSearcher == null)
            {
                Init();
            }

            placeSearcher.LayoutBegin();

            // Location control
            mapScene.LatLon = EditorGUILayout.Vector2Field("Location", mapScene.LatLon.ToVector2()).ToVector2d();
            if (mapScene.LatLon != map.Center)
            {
                map.Center = mapScene.LatLon;
            }

            EditorGUILayout.BeginHorizontal();
            // Map Elements
            mapElementReorderableList.list = mapScene.Elements;
            var elementsWidth = 150;

            mapElementReorderableList.elementHeight = mapElementReorderableList.list.Count == 0 ? 20 : 70;
            EditorGUILayout.BeginVertical(GUILayout.Width(elementsWidth), GUILayout.ExpandHeight(true));
            mapElementReorderableList.DoLayoutList();
            EditorGUILayout.EndVertical();

            var mapRect = EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

            // Map drawing
            if (map.DrawMap(mapRect) && movingReference != null)
            {
                this.positionManagers[movingReference].Repositionate(map, mapRect);
                movingReference = null;
            }

            if (movingReference != null && Event.current.type == EventType.Repaint)
            {
                this.positionManagers[movingReference].Repositionate(map, mapRect);
            }

            mapScene.LatLon = map.Center;
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            if (placeSearcher.LayoutEnd())
            {
                mapScene.LatLon = placeSearcher.LatLon;
                Repaint();
            }
        }
Esempio n. 2
0
        public override void Draw(int aID)
        {
            if (selectedElement == -1)
            {
                GUILayout.Label("Nothing selected");
                return;
            }

            element = Controller.Instance.SelectedChapterDataControl.getObjects <GeoElement>()[selectedElement];


            actionsList.list = element.Actions;
            // Set geometries list reference
            map.Geometries = new List <GMLGeometry>()
            {
                element.Geometry
            };

            selected = GUILayout.Toolbar(selected, menus);

            switch (selected)
            {
            case 0:     // Map view
            {
                element.Geometry.Type = (GMLGeometry.GeometryType)EditorGUILayout.EnumPopup("Geometry type", element.Geometry.Type);
                EditorGUILayout.LabelField("Points: " + element.Geometry.Points.Count);
                element.Geometry.Influence = EditorGUILayout.FloatField("Influence Radius", element.Geometry.Influence);


                if (GUILayout.Button("Center") && element.Geometry.Points.Count > 0)
                {
                    Center(element);
                }

                if (GUILayout.Button(!editing ? "Edit" : "Finish"))
                {
                    editing = !editing;
                }

                EditorGUILayout.Separator();
                placeSearcher.LayoutBegin();

                // Location control
                location = EditorGUILayout.Vector2Field("Location", location);
                if (location != map.Center.ToVector2())
                {
                    map.Center = new Vector2d(location.x, location.y);
                }

                // Map drawing
                if (editing)
                {
                    map.selectedGeometry = element.Geometry;
                }

                if (map.DrawMap(GUILayoutUtility.GetRect(0, 0, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true))) && element != null && editing)
                {
                    element.Geometry.AddPoint(map.GeoMousePosition);
                }

                location = map.Center.ToVector2();

                if (placeSearcher.LayoutEnd())
                {
                    // If new Location is selected from the dropdown
                    location = placeSearcher.LatLon.ToVector2();
                    Repaint();
                }
            } break;

            case 1:
            {
                GUILayout.Label("Full description");
                element.FullDescription = GUILayout.TextArea(element.FullDescription, GUILayout.Height(250));

                element.Name                = EditorGUILayout.TextField("Name", element.Name);
                element.BriefDescription    = EditorGUILayout.TextField("Brief description", element.BriefDescription);
                element.DetailedDescription = EditorGUILayout.TextField("Detailed description", element.DetailedDescription);

                GUILayout.Label("Element image");
                GUILayout.BeginHorizontal();
                GUILayout.Box(element.Image, GUILayout.Width(0.78f * m_Rect.width));
                if (GUILayout.Button(TC.get("Buttons.Select"), GUILayout.Width(0.2f * m_Rect.width)))
                {
                    ShowAssetChooser(AssetType.Image);
                }
                GUILayout.EndHorizontal();
            }
            break;

            case 2:
            {
                actionsList.list = element.Actions;
                actionsList.DoList(new Rect(0, 50, m_Rect.width * 0.99f, m_Rect.height));
            }
            break;
            }
        }