public override void Draw(float Alpha) { float Brightness = 0.35f + 0.15f * HoverAlpha; EditorStatic.DrawRectangle(MyRectangle, new Color(Brightness * Alpha, Brightness * Alpha, Brightness * Alpha, 0.5f * Alpha), true); Vector4 col; if (Selected) { col = new Vector4(0, 1, 1, 1) * Alpha; } else { col = new Vector4(0, 0, 0, 1) * Alpha; } EditorStatic.DrawRectangle(MyRectangle, new Color(col), false); if (Image != null) { Game1.spriteBatch.Draw(Image, ImageRectangle, new Color(Vector4.One * Alpha)); } base.Draw(Alpha); }
public virtual void PreDraw() { Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, DepthStencilState.None, RasterizerState.CullNone, null, Matrix.CreateTranslation(ScrollRectangle.X, ScrollRectangle.Y, 0)); Game1.graphicsDevice.SetRenderTarget(RenderTarget); Game1.graphicsDevice.Clear(new Color(0, 0, 0, 0)); EditorStatic.DrawRectangle(ScrollRectangle, new Color(BackgroundColor * HoverAlpha), true); EditorStatic.DrawRectangle(ScrollRectangle, new Color(EdgeColor * HoverAlpha), false); }
public Button(Texture2D Image, Rectangle MyRectangle, Rectangle HoverRectangle, int Margin, ClickEvent MyClickEvent) { this.Image = Image; this.PositionRectangle = MyRectangle; this.MyRectangle = PositionRectangle; this.Margin = Margin; this.HoverRectangle = HoverRectangle; StartRectangle = EditorStatic.CloneRectangle(MyRectangle); ImageRectangle = new Rectangle(MyRectangle.X + Margin, MyRectangle.Y + Margin, MyRectangle.Width - Margin, MyRectangle.Height - Margin); this.MyClickEvent = MyClickEvent; }
public void Create() { StartRectangle = EditorStatic.CloneRectangle(MyRectangle); RenderTarget = new RenderTarget2D(Game1.graphicsDevice, MyRectangle.Width * 2, MyRectangle.Height, false, SurfaceFormat.Alpha8, DepthFormat.None); ScrollRectangle = EditorStatic.SizeCloneRectangle(MyRectangle); ScrollTarget = EditorStatic.SizeCloneRectangle(ScrollRectangle); if (ScrollLR) { AddForm(LeftScroll = new Button(Game1.contentManager.Load <Texture2D>("Editor/ScrollArrow2"), new Rectangle(26, MyRectangle.Height / 2, 32, 32), new Rectangle(26, MyRectangle.Height / 2, 48, 48), 4, ScrollLeft)); AddForm(RightScroll = new Button(Game1.contentManager.Load <Texture2D>("Editor/ScrollArrow"), new Rectangle(MyRectangle.Width - 26, MyRectangle.Height / 2, 32, 32), new Rectangle(MyRectangle.Width - 26, MyRectangle.Height / 2, 48, 48), 4, ScrollRight)); } }
public void Load() { TimeLineMode = false; for (int i = 0; i < BasicObjectCreator.BasicObjectTypes.Length; i++) { BasicObjectCreator.BasicObjectTypes[i].Create(); BasicObjectCreator.BasicObjectTypes[i].Load(); } windowManager = new WindowManager(); editorStatic = new EditorStatic(); SelectedBox = Game1.contentManager.Load <Texture2D>("Editor/Selected"); Alert = Game1.contentManager.Load <Texture2D>("Editor/Warning"); CreateNewLevel(); }
public void UpdateGui() { if (Game1.self.Window.ClientBounds.Width > 0 && Game1.self.Window.ClientBounds.Height > 0) { WindowRectangle = new Rectangle(0, 0, Game1.self.Window.ClientBounds.Width, Game1.self.Window.ClientBounds.Height); // TopWindow.MyRectangle.X = WindowRectangle.Width / 2 - TopWindow.MyRectangle.Width / 2; // TopWindow.StartRectangle.X = TopWindow.MyRectangle.X; // TopWindow.HoverRectangle.X = TopWindow.MyRectangle.X; backgroundSelectorWindow.MyRectangle.Y = Game1.self.Window.ClientBounds.Height - 100; backgroundSelectorWindow.HoverRectangle.Y = Game1.self.Window.ClientBounds.Height - 100; backgroundSelectorWindow.StartRectangle.Y = Game1.self.Window.ClientBounds.Height - 100; editorWindow.MyRectangle.Width = Game1.self.Window.ClientBounds.Width; editorWindow.MyRectangle.Height = Game1.self.Window.ClientBounds.Height; editorWindow.HoverRectangle = EditorStatic.CloneRectangle(editorWindow.MyRectangle); editorWindow.ScrollRectangle = EditorStatic.CloneRectangle(editorWindow.MyRectangle); if (GameManager.MyLevel != null) { GameManager.MyLevel.HasResized = true; } editorWindow.RenderTarget = new RenderTarget2D(Game1.graphicsDevice, editorWindow.MyRectangle.Width, editorWindow.MyRectangle.Height); } }
public EditorStatic() { self = this; BlankTexture = Game1.contentManager.Load <Texture2D>("blank"); }
public override void Update() { MousePos = Vector2.Transform(new Vector2(WindowManager.mouseState.X, WindowManager.mouseState.Y), Matrix.Invert(GameManager.MyLevel.MyCamera.ReturnMatrix())); MousePoint = new Point((int)MousePos.X, (int)MousePos.Y); if (WindowManager.KeyState.IsKeyDown(Keys.Delete)) { List <Object> DeleteList = new List <object>(); foreach (BasicObject Object in GameManager.MyLevel.ObjectList) { if (Object.Selected) { DeleteList.Add(Object); } } foreach (BasicObject Object in DeleteList) { Object.Delete(); } } if (WindowManager.mouseState.LeftButton == ButtonState.Released) { if (DraggingMove) { GameManager.MyLevel.HasChanged = true; foreach (BasicObject Object in GameManager.MyLevel.ObjectList) { if (Object.Selected) { int x = (int)(Math.Floor(Object.Position.X / MasterEditor.GridSize.X) * (float)MasterEditor.GridSize.X); int y = (int)(Math.Floor(Object.Position.Y / MasterEditor.GridSize.Y) * (float)MasterEditor.GridSize.Y); Object.ChangePosition(new Vector2(x, y)); } } } if (DraggingSelect) { if (MasterEditor.mouseMode == MouseMode.Select) { foreach (BasicObject Object in GameManager.MyLevel.ObjectList) { Object.ChangeSelect(false); } foreach (BasicObject Object in GameManager.MyLevel.ObjectList) { if (Object.MyRectangle.Intersects(DragRectangle)) { Object.ChangeSelect(true); } } } else { Rectangle LvlRect = GameManager.MyLevel.MyRectangle; for (int x = (int)(Math.Floor(LvlRect.X / MasterEditor.GridSize.X) * (float)MasterEditor.GridSize.X); x < LvlRect.X + LvlRect.Width; x += (int)MasterEditor.GridSize.X) { for (int y = (int)(Math.Floor(LvlRect.Y / MasterEditor.GridSize.X) * (float)MasterEditor.GridSize.X); y < LvlRect.Y + LvlRect.Height; y += (int)MasterEditor.GridSize.Y) { Rectangle CheckRect = new Rectangle(x, y, (int)MasterEditor.GridSize.X, (int)MasterEditor.GridSize.Y); if (CheckRect.Intersects(DragRectangle)) { bool PlaceFree = false; if (GameManager.MyLevel.MyRectangle.Contains(CheckRect)) { PlaceFree = true; foreach (BasicObject Object in GameManager.MyLevel.ObjectList) { if (Object.MyRectangle.Intersects(CheckRect)) { PlaceFree = false; } } } if (PlaceFree) { BasicObject Object = (BasicObject)Instancer.CreateInstanceOf(MasterEditor.SelectedObjectCreater, GameManager.MyLevel); Object.Create(MasterEditor.GridSize, new Vector2(x, y)); } } } } } } DraggingMove = false; DraggingSelect = false; Dragging = false; } if (WindowManager.mouseState.RightButton == ButtonState.Released) { DraggingCamera = false; } if (Dragging) { Rectangle PreviousRect = EditorStatic.CloneRectangle(GameManager.MyLevel.MyRectangle); Rectangle LevelRect = GameManager.MyLevel.MyRectangle; LevelRect.Width += (int)(MousePos.X - DragPos.X) * DraggingX; LevelRect.Height += (int)(MousePos.Y - DragPos.Y) * DraggingY; LevelRect.X += (int)(MousePos.X - DragPos.X) * Math.Abs(Math.Min(0, DraggingX)); LevelRect.Y += (int)(MousePos.Y - DragPos.Y) * Math.Abs(Math.Min(0, DraggingY)); LevelRect.Width = Math.Max(100, LevelRect.Width); LevelRect.Height = Math.Max(100, LevelRect.Height); GameManager.MyLevel.MyRectangle = LevelRect; GameManager.MyLevel.HasResized = true; GameManager.MyLevel.MyCamera.EditorOffset += new Vector2(LevelRect.Width - PreviousRect.Width, LevelRect.Height - PreviousRect.Height) / 2 * new Vector2(Math.Abs(DraggingX), Math.Abs(DraggingY)); DragPos = MousePos; } if (DraggingSelect) { DragRectangle.Width = MousePoint.X - DragRectangle.X; DragRectangle.Height = MousePoint.Y - DragRectangle.Y; } if (DraggingMove) { Vector2 Change = MousePos - MoveDragPos; foreach (BasicObject Object in GameManager.MyLevel.ObjectList) { if (Object.Selected) { Object.ChangePosition(Object.Position + Change); } } MoveDragPos = MousePos; } if (DraggingCamera) { GameManager.MyLevel.MyCamera.EditorOffset += (MousePos - CameraDragPos) / 2; CameraDragPos = MousePos; } if (GameManager.MyLevel != null) { GameManager.MyLevel.MyCamera.MyRectangle = new Vector4( GameManager.MyLevel.MyCamera.EditorOffset.X + (Game1.self.Window.ClientBounds.Width - GameManager.MyLevel.MyRectangle.Width) / 2, GameManager.MyLevel.MyCamera.EditorOffset.Y + (Game1.self.Window.ClientBounds.Height - GameManager.MyLevel.MyRectangle.Height) / 2, //200,200, Game1.self.Window.ClientBounds.Width, Game1.self.Window.ClientBounds.Height ); } base.Update(); }