コード例 #1
0
ファイル: MapWindow.cs プロジェクト: dotlive/uAdventure
        /* ----------------------------------
         * INIT: Used for late initialization after constructor
         * ----------------------------------*/
        void Init()
        {
            EditorApplication.update += this.Update;

            place.DataStructure  = HelperExtention.GetOrCreateSObjectReturn <StructSearchData>(ref place.DataStructure, PATH_SAVE_SCRIPTABLE_OBJECT);
            place.namePlaceСache = "";
            place.DataStructure.dataChache.Clear();

            addressDropdown = new DropDown("Address");
            map             = new GUIMap();
            map.Repaint    += Repaint;
            map.Zoom        = 19;

            geometriesReorderableList = new ReorderableList(new ArrayList(), typeof(GMLGeometry), true, true, true, true);
            geometriesReorderableList.drawHeaderCallback  += DrawGMLGeometryHeader;
            geometriesReorderableList.drawElementCallback += DrawGMLGeometry;
            geometriesReorderableList.onAddCallback       += AddGMLGeometry;
            geometriesReorderableList.onRemoveCallback    += RemoveGMLGeometry;
            geometriesReorderableList.onReorderCallback   += ReorderGMLGeometries;

            // Creating the geometry list
            geometries = new List <GMLGeometry>();
            // Set geometries list reference
            geometriesReorderableList.list = geometries;
            map.Geometries = geometries;
        }
コード例 #2
0
        public void Draw(GUIMap map, Rect area)
        {
            UpdateValues();
            var corner = area.position + new Vector2(position.x * area.width / gameWidth, area.height - (position.y * area.height / gameHeight));

            if (Texture != null)
            {
                var size = new Vector2(Texture.width * scale, Texture.height * scale);
                GUI.DrawTexture(new Rect(corner - new Vector2(size.x / 2f, size.y), size), Texture);
            }
        }
コード例 #3
0
        /* ----------------------------------
         * INIT: Used for late initialization after constructor
         * ----------------------------------*/
        void Init()
        {
            placeSearcher = new PlaceSearcher("Address");
            placeSearcher.OnRequestRepaint += Repaint;
            map = new GUIMap();
            map.Repaint += Repaint;
            map.Zoom = 19;

            actionsList = new ReorderableList(new List<GeoAction>(), typeof(GeoAction));
            actionsList.headerHeight = 40;
            actionsList.elementHeight = 60;
            actionsList.drawHeaderCallback = DrawActionsHeader;
            actionsList.drawElementCallback = DrawActionElement;
            actionsList.onAddDropdownCallback = OnAddActionDropdown;
        }
コード例 #4
0
        /* ----------------------------------
         * INIT: Used for late initialization after constructor
         * ----------------------------------*/
        void Init()
        {
            placeSearcher = new PlaceSearcher("Address");
            placeSearcher.OnRequestRepaint += Repaint;

            map          = new GUIMap();
            map.Repaint += Repaint;
            map.Zoom     = 19;

            mapElementReorderableList = new ReorderableList(new ArrayList(), typeof(MapElement), true, true, true, true);
            mapElementReorderableList.drawHeaderCallback    += DrawMapElementsHeader;
            mapElementReorderableList.drawElementCallback   += DrawMapElement;
            mapElementReorderableList.onAddDropdownCallback += OnAddMapElementDropdown;
            mapElementReorderableList.onRemoveCallback      += RemoveMapElement;

            this.positionManagers = new Dictionary <ExtElemReference, ExtElemReferenceGUIMapPositionManager>();
        }
コード例 #5
0
            void OnGUI()
            {
                if (guiMap == null)
                {
                    guiMap = new GUIMap();
                }


                debugWindowRect = GUI.Window(12341234, debugWindowRect, (id) =>
                {
                    var mapRect = new Rect(2, 18, 196, 180);
                    using (new GUILayout.AreaScope(mapRect))
                    {
                        guiMap.Center = GeoExtension.Instance.Location;
                        guiMap.Zoom   = 17;
                        guiMap.DrawMap(new Rect(0, 0, 196, 180));
                        // Calculate the player pixel relative to the map
                        var playerMeters        = MapzenGo.Helpers.GM.LatLonToMeters(GeoExtension.Instance.Location);
                        var playerPixel         = MapzenGo.Helpers.GM.MetersToPixels(playerMeters, guiMap.Zoom);
                        var playerPixelRelative = playerPixel + guiMap.PATR;

                        // Do the point handling
                        var pointControl = GUIUtility.GetControlID("PlayerPosition".GetHashCode(), FocusType.Passive);
                        EditorGUI.BeginChangeCheck();
                        var newPlayerPixel = HandleUtil.HandlePointMovement(pointControl, playerPixelRelative.ToVector2(), 10,
                                                                            (point, isOver, isActive) => HandleUtil.DrawPoint(point, 4, Color.cyan,
                                                                                                                              Color.black), MouseCursor.MoveArrow);
                        if (EditorGUI.EndChangeCheck())
                        {
                            // If changed, restore the point to the geochar
                            playerPixel  = newPlayerPixel.ToVector2d() - guiMap.PATR;
                            playerMeters = MapzenGo.Helpers.GM.PixelsToMeters(playerPixel, guiMap.Zoom);
                            GeoExtension.Instance.Location = MapzenGo.Helpers.GM.MetersToLatLon(playerMeters);
                        }

                        guiMap.ProcessEvents(mapRect);
                    }
                    GUI.DragWindow();
                },
                                             "DebugWindow");
            }
コード例 #6
0
 public MapEditor() : base()
 {
     guiMap        = new GUIMap();
     placeSearcher = ScriptableObject.CreateInstance <PlaceSearcher>();
 }
コード例 #7
0
        void OnGUI()
        {
            var paintSimbol = disconnectedSimbol;

            switch (Input.location.status)
            {
            default:
            case LocationServiceStatus.Failed:
            case LocationServiceStatus.Stopped:
                paintSimbol = disconnectedSimbol;
                break;

            case LocationServiceStatus.Initializing:
                paintSimbol = connectingSimbol;
                break;

            case LocationServiceStatus.Running:
                var connecting = ((time > blinkingTime / 2f) ? connectedSimbol : connectingSimbol);
                paintSimbol = IsLocationValid() ? connectedSimbol : connecting;
                break;
            }

            /*if (Event.current.type == EventType.Repaint)
             *  GUI.DrawTexture(new Rect(Screen.width - iconWidth - 5, 5, iconWidth, iconHeight), paintSimbol);*/

            if (guiMap == null)
            {
                guiMap = new GUIMap();
            }

            if (Input.GetKeyDown(KeyCode.G))
            {
                hidden = !hidden;
            }

            if (!hidden && (inMapScene || inZoneControl))
            {
                debugWindowRect = GUI.Window(12341234, debugWindowRect, (id) =>
                {
                    var mapRect = new Rect(2, 18, 196, 180);
                    using (new GUILayout.AreaScope(mapRect))
                    {
                        guiMap.Center = GeoExtension.Instance.Location;
                        guiMap.Zoom   = 17;
                        guiMap.DrawMap(new Rect(0, 0, 196, 180));
                        // Calculate the player pixel relative to the map
                        var playerMeters        = MapzenGo.Helpers.GM.LatLonToMeters(GeoExtension.Instance.Location);
                        var playerPixel         = MapzenGo.Helpers.GM.MetersToPixels(playerMeters, guiMap.Zoom);
                        var playerPixelRelative = playerPixel + guiMap.PATR;

                        // Do the point handling
                        var pointControl   = GUIUtility.GetControlID("PlayerPosition".GetHashCode(), FocusType.Passive);
                        var oldPlayerPixel = playerPixelRelative.ToVector2();
                        var newPlayerPixel = HandlePointMovement(pointControl, oldPlayerPixel, 60,
                                                                 (point, isOver, isActive) =>
                        {
                            var locationRect    = new Rect(0, 0, 30, 30);
                            locationRect.center = point;
                            locationRect.y     -= locationRect.height / 2f;
                            GUI.DrawTexture(locationRect, pointer);
                        });

                        if (oldPlayerPixel != newPlayerPixel)
                        {
                            // If changed, restore the point to the geochar
                            playerPixel  = newPlayerPixel.ToVector2d() - guiMap.PATR;
                            playerMeters = MapzenGo.Helpers.GM.PixelsToMeters(playerPixel, guiMap.Zoom);
                            GeoExtension.Instance.Location = MapzenGo.Helpers.GM.MetersToLatLon(playerMeters);
                        }

                        guiMap.ProcessEvents(mapRect);

                        GUI.Label(new Rect(0, 0, 196, 40), "Drag the pointer to move");
                    }
                    GUI.DragWindow();
                },
                                             "Debug Location");
            }
        }