Esempio n. 1
0
 public void SetSelected(bool Selected)
 {
     if (this.Selected != Selected)
     {
         this.Selected = Selected;
         if (this.Selected)
         {
             foreach (Widget w in Parent.Widgets)
             {
                 if (w is ConnectionWidget && (ConnectionWidget)w != this)
                 {
                     ((ConnectionWidget)w).SetSelected(false);
                 }
             }
         }
         Color Color = Selected ? new Color(47, 160, 193) : Color.WHITE;
         MapLabel.SetTextColor(Color);
         XLabel.SetTextColor(Color);
         YLabel.SetTextColor(Color);
         MapBox.SetTextColor(Color);
         XBox.SetTextColor(Color);
         YBox.SetTextColor(Color);
         SetBackgroundColor(Selected ? new Color(19, 36, 55) : Color.ALPHA);
         MapConnectionWidget mcw = Editor.MainWindow.MapWidget.MapViewerConnections.ConnectionWidgets.Find(w => w.MapID == this.MapConnection.MapID);
         mcw.SetDarkOverlay((byte)(Selected ? 32 : 192));
         mcw.Outline.SetOuterColor(Selected ? new Color(53, 210, 255) : Color.ALPHA);
         mcw.Outline.SetThickness(2);
         mcw.SetZIndex(Selected ? 1 : 0);
     }
 }
Esempio n. 2
0
 public virtual void UpdateConnectionPositions()
 {
     for (int i = 0; i < ConnectionWidgets.Count; i++)
     {
         MapConnectionWidget mcw = ConnectionWidgets[i];
         mcw.SetZoomFactor(ZoomFactor);
         mcw.UpdateSize();
         mcw.SetPosition(MapWidget.Position.X + (int)Math.Round(mcw.RelativeX * 32d * ZoomFactor),
                         MapWidget.Position.Y + (int)Math.Round(mcw.RelativeY * 32d * ZoomFactor));
     }
 }
Esempio n. 3
0
        public void SetOffset(int RelativeX, int RelativeY)
        {
            MapConnectionWidget mcw = Editor.MainWindow.MapWidget.MapViewerConnections.ConnectionWidgets.Find(w => w.MapID == this.MapConnection.MapID);

            this.MapConnection.RelativeX = RelativeX;
            this.MapConnection.RelativeY = RelativeY;
            Game.MapConnection c = Game.Data.Maps[this.MapConnection.MapID].Connections.Find(conn => conn.MapID == Editor.MainWindow.MapWidget.Map.ID);
            c.RelativeX   = -RelativeX;
            c.RelativeY   = -RelativeY;
            mcw.RelativeX = RelativeX;
            mcw.RelativeY = RelativeY;
            Editor.MainWindow.MapWidget.MapViewerConnections.PositionMap();
        }
Esempio n. 4
0
 public virtual void RedrawConnectedMaps()
 {
     foreach (MapConnectionWidget mcw in ConnectionWidgets)
     {
         mcw.Dispose();
     }
     ConnectionWidgets.Clear();
     MapWidget.Rect = new Rect(0, 0, Map.Width, Map.Height);
     foreach (MapConnection c in Map.Connections)
     {
         Map map = Data.Maps[c.MapID];
         MapConnectionWidget mcw = new MapConnectionWidget(MainContainer);
         mcw.LoadLayers(map, c.RelativeX, c.RelativeY);
         ConnectionWidgets.Add(mcw);
     }
 }
Esempio n. 5
0
        public override void Update()
        {
            base.Update();
            MapConnectionWidget mcw = Editor.MainWindow.MapWidget.MapViewerConnections.ConnectionWidgets.Find(w => w.MapID == this.MapConnection.MapID);

            if (this.Selected && (this.SelectedWidget || mcw.SelectedWidget))
            {
                int Diff = Input.Press(odl.SDL2.SDL.SDL_Keycode.SDLK_LSHIFT) || Input.Press(odl.SDL2.SDL.SDL_Keycode.SDLK_RSHIFT) ? 10 : 1;
                if (Input.Trigger(odl.SDL2.SDL.SDL_Keycode.SDLK_LEFT) || TimerPassed("left"))
                {
                    if (TimerPassed("left"))
                    {
                        ResetTimer("left");
                    }
                    SetOffset(this.MapConnection.RelativeX - Diff, this.MapConnection.RelativeY);
                }
                if (Input.Trigger(odl.SDL2.SDL.SDL_Keycode.SDLK_RIGHT) || TimerPassed("right"))
                {
                    if (TimerPassed("right"))
                    {
                        ResetTimer("right");
                    }
                    SetOffset(this.MapConnection.RelativeX + Diff, this.MapConnection.RelativeY);
                }
                if (Input.Trigger(odl.SDL2.SDL.SDL_Keycode.SDLK_UP) || TimerPassed("up"))
                {
                    if (TimerPassed("up"))
                    {
                        ResetTimer("up");
                    }
                    SetOffset(this.MapConnection.RelativeX, this.MapConnection.RelativeY - Diff);
                }
                if (Input.Trigger(odl.SDL2.SDL.SDL_Keycode.SDLK_DOWN) || TimerPassed("down"))
                {
                    if (TimerPassed("down"))
                    {
                        ResetTimer("down");
                    }
                    SetOffset(this.MapConnection.RelativeX, this.MapConnection.RelativeY + Diff);
                }

                if (Input.Press(odl.SDL2.SDL.SDL_Keycode.SDLK_LEFT))
                {
                    if (!TimerExists("left_initial") && !TimerExists("left"))
                    {
                        SetTimer("left_initial", 300);
                    }
                    else if (TimerPassed("left_initial"))
                    {
                        DestroyTimer("left_initial");
                        SetTimer("left", 50);
                    }
                }
                else
                {
                    if (TimerExists("left"))
                    {
                        DestroyTimer("left");
                    }
                    if (TimerExists("left_initial"))
                    {
                        DestroyTimer("left_initial");
                    }
                }
                if (Input.Press(odl.SDL2.SDL.SDL_Keycode.SDLK_RIGHT))
                {
                    if (!TimerExists("right_initial") && !TimerExists("right"))
                    {
                        SetTimer("right_initial", 300);
                    }
                    else if (TimerPassed("right_initial"))
                    {
                        DestroyTimer("right_initial");
                        SetTimer("right", 50);
                    }
                }
                else
                {
                    if (TimerExists("right"))
                    {
                        DestroyTimer("right");
                    }
                    if (TimerExists("right_initial"))
                    {
                        DestroyTimer("right_initial");
                    }
                }
                if (Input.Press(odl.SDL2.SDL.SDL_Keycode.SDLK_UP))
                {
                    if (!TimerExists("up_initial") && !TimerExists("up"))
                    {
                        SetTimer("up_initial", 300);
                    }
                    else if (TimerPassed("up_initial"))
                    {
                        DestroyTimer("up_initial");
                        SetTimer("up", 50);
                    }
                }
                else
                {
                    if (TimerExists("up"))
                    {
                        DestroyTimer("up");
                    }
                    if (TimerExists("up_initial"))
                    {
                        DestroyTimer("up_initial");
                    }
                }
                if (Input.Press(odl.SDL2.SDL.SDL_Keycode.SDLK_DOWN))
                {
                    if (!TimerExists("down_initial") && !TimerExists("down"))
                    {
                        SetTimer("down_initial", 300);
                    }
                    else if (TimerPassed("down_initial"))
                    {
                        DestroyTimer("down_initial");
                        SetTimer("down", 50);
                    }
                }
                else
                {
                    if (TimerExists("down"))
                    {
                        DestroyTimer("down");
                    }
                    if (TimerExists("down_initial"))
                    {
                        DestroyTimer("down_initial");
                    }
                }
            }
        }