Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: Sledge.Editor/Documents/DocumentSubscriptions.cs
- ===================================================================
- --- Sledge.Editor/Documents/DocumentSubscriptions.cs (revision 489)
- +++ Sledge.Editor/Documents/DocumentSubscriptions.cs (working copy)
- @@ -440,7 +440,7 @@
- }
- }
- - var qf = new QuickForm("Select wall width").NumericUpDown("Wall width (negative to hollow outwards)", -1024, 1024, 0, 32).OkCancel();
- + var qf = new QuickForm("Select wall width") { UseShortcutKeys = true } .NumericUpDown("Wall width (negative to hollow outwards)", -1024, 1024, 0, 32).OkCancel();
- decimal width;
- do
- Index: Sledge.Editor/Rendering/Arrays/MapObjectArray.cs
- ===================================================================
- --- Sledge.Editor/Rendering/Arrays/MapObjectArray.cs (revision 489)
- +++ Sledge.Editor/Rendering/Arrays/MapObjectArray.cs (working copy)
- @@ -18,7 +18,8 @@
- {
- private const int Textured = 0;
- private const int Transparent = 1;
- - private const int Wireframe = 2;
- + private const int BrushWireframe = 2; //mxd. Renamed
- + private const int EntityWireframe = 3; //mxd
- public MapObjectArray(IEnumerable<MapObject> data)
- : base(data)
- @@ -71,12 +72,28 @@
- public void RenderWireframe(IGraphicsContext context)
- {
- - foreach (var subset in GetSubsets(Wireframe))
- + foreach (var subset in GetSubsets(BrushWireframe))
- {
- Render(context, BeginMode.Lines, subset);
- }
- +
- + foreach (var subset in GetSubsets(EntityWireframe)) //mxd
- + {
- + Render(context, BeginMode.Lines, subset);
- }
- + }
- + //mxd
- + public void RenderVertices(IGraphicsContext context)
- + {
- + OpenTK.Graphics.OpenGL.GL.PointSize(4.0f); //TODO: make this into setting? Restore initial value? Set during propgram startup?
- + foreach (var subset in GetSubsets(BrushWireframe))
- + {
- + Render(context, BeginMode.Points, subset);
- + }
- +
- + }
- +
- public void UpdatePartial(IEnumerable<MapObject> objects)
- {
- UpdatePartial(objects.OfType<Solid>().SelectMany(x => x.Faces));
- @@ -111,7 +128,7 @@
- var faces = obj.OfType<Solid>().SelectMany(x => x.Faces).ToList();
- var entities = obj.OfType<Entity>().Where(x => x.Children.Count == 0).ToList();
- - StartSubset(Wireframe);
- + StartSubset(BrushWireframe);
- // Render solids
- foreach (var group in faces.GroupBy(x => new { x.Texture.Texture, Transparent = HasTransparency(x) }))
- @@ -126,7 +143,7 @@
- PushOffset(face);
- var index = PushData(Convert(face));
- if (!face.Parent.IsRenderHidden3D) PushIndex(subset, index, Triangulate(face.Vertices.Count));
- - if (!face.Parent.IsRenderHidden2D) PushIndex(Wireframe, index, Linearise(face.Vertices.Count));
- + if (!face.Parent.IsRenderHidden2D) PushIndex(BrushWireframe, index, Linearise(face.Vertices.Count));
- if (group.Key.Transparent) PushSubset(subset, face);
- }
- @@ -134,6 +151,9 @@
- if (!group.Key.Transparent) PushSubset(subset, group.Key.Texture);
- }
- + PushSubset(BrushWireframe, (object)null); //mxd
- + StartSubset(EntityWireframe); //mxd
- +
- // Render entities
- foreach (var g in entities.GroupBy(x => x.HasModel()))
- {
- @@ -148,7 +168,7 @@
- {
- var index = PushData(Convert(face));
- if (!face.Parent.IsRenderHidden3D) PushIndex(Textured, index, Triangulate(face.Vertices.Count));
- - if (!face.Parent.IsRenderHidden2D) PushIndex(Wireframe, index, Linearise(face.Vertices.Count));
- + if (!face.Parent.IsRenderHidden2D) PushIndex(EntityWireframe, index, Linearise(face.Vertices.Count));
- }
- if (g.Key) PushSubset(Textured, entity);
- }
- @@ -155,7 +175,7 @@
- if (!g.Key) PushSubset(Textured, (ITexture) null);
- }
- - PushSubset(Wireframe, (object)null);
- + PushSubset(EntityWireframe, (object)null);
- }
- private bool HasTransparency(Face face)
- Index: Sledge.Editor/Rendering/Helpers/EntityTextHelper.cs
- ===================================================================
- --- Sledge.Editor/Rendering/Helpers/EntityTextHelper.cs (revision 489)
- +++ Sledge.Editor/Rendering/Helpers/EntityTextHelper.cs (working copy)
- @@ -49,7 +49,10 @@
- var nameProp = entityData.GetPropertyValue("targetname");
- if (!String.IsNullOrWhiteSpace(nameProp)) text += ": " + nameProp;
- - _printer.Print(text, _printerFont, o.Colour, new RectangleF((float)start.X + 2, viewport.Height - (float)end.Y - _printerFont.Height - 6, viewport.Width, viewport.Height));
- + var wid = _printer.Measure(text, _printerFont, new RectangleF(0, 0, viewport.Width, viewport.Height)); //mxd
- + var cx = (float)(start.X + (end.X - start.X) / 2); //mxd
- +
- + _printer.Print(text, _printerFont, o.Colour, new RectangleF(cx - wid.BoundingBox.Width / 2, viewport.Height - (float)end.Y - _printerFont.Height - 6, viewport.Width, viewport.Height));
- }
- public void AfterRender2D(Viewport2D viewport)
- Index: Sledge.Editor/Rendering/Renderers/ModernRenderer.cs
- ===================================================================
- --- Sledge.Editor/Rendering/Renderers/ModernRenderer.cs (revision 489)
- +++ Sledge.Editor/Rendering/Renderers/ModernRenderer.cs (working copy)
- @@ -116,6 +116,7 @@
- // Render wireframe (untransformed)
- _mapObject2DShader.ModelView = modelView;
- _array.RenderWireframe(context.Context);
- + _array.RenderVertices(context.Context); //mxd
- _decalArray.RenderWireframe(context.Context);
- // Render wireframe (transformed)
- @@ -123,6 +124,7 @@
- _mapObject2DShader.SelectedOnly = true;
- _mapObject2DShader.SelectedColour = new Vector4(1, 0, 0, 1);
- _array.RenderWireframe(context.Context);
- + _array.RenderVertices(context.Context); //mxd
- _decalArray.RenderWireframe(context.Context);
- _mapObject2DShader.Unbind();
- Index: Sledge.Editor/Settings/SettingsForm.Designer.cs
- ===================================================================
- --- Sledge.Editor/Settings/SettingsForm.Designer.cs (revision 489)
- +++ Sledge.Editor/Settings/SettingsForm.Designer.cs (working copy)
- @@ -1969,6 +1969,7 @@
- this.SelectedGameMapDirBrowse.TabIndex = 8;
- this.SelectedGameMapDirBrowse.Text = "Browse...";
- this.SelectedGameMapDirBrowse.UseVisualStyleBackColor = true;
- + this.SelectedGameMapDirBrowse.Click += new System.EventHandler(this.SelectedGameMapDirBrowseClicked);
- //
- // SelectedGameAutosaveTime
- //
- @@ -2040,6 +2041,7 @@
- this.SelectedGameDiffAutosaveDirBrowse.TabIndex = 13;
- this.SelectedGameDiffAutosaveDirBrowse.Text = "Browse...";
- this.SelectedGameDiffAutosaveDirBrowse.UseVisualStyleBackColor = true;
- + this.SelectedGameDiffAutosaveDirBrowse.Click += new System.EventHandler(this.SelectedGameDiffAutosaveDirBrowseClicked);
- //
- // label12
- //
- Index: Sledge.Editor/Tools/BaseBoxTool.cs
- ===================================================================
- --- Sledge.Editor/Tools/BaseBoxTool.cs (revision 489)
- +++ Sledge.Editor/Tools/BaseBoxTool.cs (working copy)
- @@ -8,6 +8,7 @@
- using OpenTK.Graphics.OpenGL;
- using TextPrinter = OpenTK.Graphics.TextPrinter;
- using TextQuality = OpenTK.Graphics.TextQuality;
- +using Sledge.Editor.Documents;
- namespace Sledge.Editor.Tools
- {
- @@ -173,7 +174,7 @@
- State = new BoxState();
- _printer = new TextPrinter(TextQuality.Low);
- - _printerFont = new Font(FontFamily.GenericSansSerif, 18, GraphicsUnit.Pixel);
- + _printerFont = new Font(FontFamily.GenericSansSerif, 12, GraphicsUnit.Pixel);
- }
- protected virtual void OnBoxChanged()
- @@ -615,6 +616,10 @@
- Coord(end.DX, end.DY, start.DZ);
- Coord(start.DX, end.DY, start.DZ);
- GL.End();
- +
- + GL.LineStipple(4, 0xAAAA); //mxd
- + GL.Enable(EnableCap.LineStipple); //mxd
- +
- GL.Begin(PrimitiveType.LineLoop);
- GL.Color3(GetRenderBoxColour());
- Coord(start.DX, start.DY, start.DZ);
- @@ -622,6 +627,8 @@
- Coord(end.DX, end.DY, start.DZ);
- Coord(start.DX, end.DY, start.DZ);
- GL.End();
- +
- + GL.Disable(EnableCap.LineStipple); //mxd
- }
- protected virtual bool ShouldRenderResizeBox(Viewport2D viewport)
- @@ -636,63 +643,63 @@
- var width = Math.Abs(start.DX - end.DX);
- var height = Math.Abs(start.DY - end.DY);
- double x1, y1, x2, y2;
- - var handleWidth = width / 10d;
- - var handleHeight = height / 10d;
- + var handleSize = (width + height) / 20d; //mxd
- +
- switch (State.Handle)
- {
- case ResizeHandle.TopLeft:
- x1 = start.DX;
- - x2 = x1 + handleWidth;
- - y1 = end.DY;
- - y2 = y1 - handleHeight;
- + x2 = x1 + handleSize;
- + y1 = end.DY - handleSize;
- + y2 = end.DY;
- break;
- case ResizeHandle.Top:
- x1 = start.DX;
- x2 = end.DX;
- - y1 = end.DY;
- - y2 = y1 - handleHeight;
- + y1 = end.DY - handleSize;
- + y2 = end.DY;
- break;
- case ResizeHandle.TopRight:
- - x1 = end.DX - handleWidth;
- + x1 = end.DX - handleSize;
- x2 = end.DX;
- - y1 = end.DY;
- - y2 = y1 - handleHeight;
- + y1 = end.DY - handleSize;
- + y2 = end.DY;
- break;
- case ResizeHandle.Left:
- x1 = start.DX;
- - x2 = x1 + handleWidth;
- - y1 = end.DY;
- - y2 = start.DY;
- + x2 = x1 + handleSize;
- + y1 = start.DY;
- + y2 = end.DY;
- break;
- case ResizeHandle.Center:
- x1 = start.DX;
- x2 = end.DX;
- - y1 = end.DY;
- - y2 = start.DY;
- + y1 = start.DY;
- + y2 = end.DY;
- break;
- case ResizeHandle.Right:
- - x1 = end.DX - handleWidth;
- + x1 = end.DX - handleSize;
- x2 = end.DX;
- - y1 = end.DY;
- - y2 = start.DY;
- + y1 = start.DY;
- + y2 = end.DY;
- break;
- case ResizeHandle.BottomLeft:
- x1 = start.DX;
- - x2 = x1 + handleWidth;
- + x2 = x1 + handleSize;
- y1 = start.DY;
- - y2 = y1 + handleHeight;
- + y2 = y1 + handleSize;
- break;
- case ResizeHandle.Bottom:
- x1 = start.DX;
- x2 = end.DX;
- y1 = start.DY;
- - y2 = y1 + handleHeight;
- + y2 = y1 + handleSize;
- break;
- case ResizeHandle.BottomRight:
- - x1 = end.DX - handleWidth;
- + x1 = end.DX - handleSize;
- x2 = end.DX;
- y1 = start.DY;
- - y2 = y1 + handleHeight;
- + y2 = y1 + handleSize;
- break;
- default:
- throw new ArgumentOutOfRangeException();
- @@ -713,12 +720,18 @@
- GL.End();
- }
- + //mxd
- protected void RenderBoxText(Viewport2D viewport, Coordinate boxStart, Coordinate boxEnd)
- {
- + RenderBoxText(viewport, boxStart, boxEnd, (float)HandleWidth);
- + }
- +
- + protected void RenderBoxText(Viewport2D viewport, Coordinate boxStart, Coordinate boxEnd, float padding)
- + {
- if (!Sledge.Settings.View.DrawBoxText) return;
- - var widthText = (boxEnd.X - boxStart.X).ToString("0.0");
- - var heightText = (boxEnd.Y - boxStart.Y).ToString("0.0");
- + var widthText = (Math.Round(boxEnd.X - boxStart.X, 1)).ToString("G29");
- + var heightText = (Math.Round(boxEnd.Y - boxStart.Y, 1)).ToString("G29");
- var wid = _printer.Measure(widthText, _printerFont, new RectangleF(0, 0, viewport.Width, viewport.Height));
- var hei = _printer.Measure(heightText, _printerFont, new RectangleF(0, 0, viewport.Width, viewport.Height));
- @@ -726,11 +739,12 @@
- boxStart = viewport.WorldToScreen(boxStart);
- boxEnd = viewport.WorldToScreen(boxEnd);
- - var cx = (float)(boxStart.X + (boxEnd.X - boxStart.X) / 2);
- - var cy = (float)(boxStart.Y + (boxEnd.Y - boxStart.Y) / 2);
- + var cx = (float)(boxStart.X + ((boxEnd.X - boxStart.X) / 2));
- + var cy = (float)(boxStart.Y + ((boxEnd.Y - boxStart.Y) / 2));
- + var offset = (float)HandleWidth / 2;
- - var wrect = new RectangleF(cx - wid.BoundingBox.Width / 2, viewport.Height - (float)boxEnd.Y - _printerFont.Height - 15, wid.BoundingBox.Width * 1.2f, wid.BoundingBox.Height);
- - var hrect = new RectangleF((float)boxEnd.X + 15, viewport.Height - cy - hei.BoundingBox.Height / 2, hei.BoundingBox.Width * 1.2f, hei.BoundingBox.Height);
- + var wrect = new RectangleF(cx - wid.BoundingBox.Width / 2, viewport.Height - (float)boxEnd.Y - _printerFont.Height - padding - offset, wid.BoundingBox.Width * 1.2f, wid.BoundingBox.Height);
- + var hrect = new RectangleF((float)boxEnd.X + padding + offset, viewport.Height - cy - hei.BoundingBox.Height * 0.75f, hei.BoundingBox.Width * 1.2f, hei.BoundingBox.Height);
- GL.Disable(EnableCap.CullFace);
- @@ -739,7 +753,7 @@
- _printer.Print(heightText, _printerFont, BoxColour, hrect);
- _printer.End();
- - GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.CullFace);
- + GL.Enable(EnableCap.CullFace);
- }
- protected virtual void Render2D(Viewport2D viewport)
- @@ -757,7 +771,7 @@
- }
- if (ShouldDrawBoxText(viewport))
- {
- - RenderBoxText(viewport, start, end);
- + RenderBoxText(viewport, start, end, 0f);
- }
- }
- Index: Sledge.Editor/Tools/SelectTool.cs
- ===================================================================
- --- Sledge.Editor/Tools/SelectTool.cs (revision 489)
- +++ Sledge.Editor/Tools/SelectTool.cs (working copy)
- @@ -296,6 +296,9 @@
- #region Double Click
- public override void MouseDoubleClick(ViewportBase viewport, ViewportEvent e)
- {
- + //mxd. Do not perform this when space is down
- + if (KeyboardState.IsKeyDown(Keys.Space)) return;
- +
- if (WidgetAction((w, vp, ev) => w.MouseDoubleClick(vp, ev), viewport, e)) return;
- if (viewport is Viewport3D && !Document.Selection.IsEmpty() && !ObjectPropertiesDialog.IsShowing)
- @@ -319,9 +322,6 @@
- /// <param name="e">The click event</param>
- protected override void MouseDown3D(Viewport3D viewport, ViewportEvent e)
- {
- - // Do not perform selection if space is down
- - if (KeyboardState.IsKeyDown(Keys.Space)) return;
- -
- // First, get the ray that is cast from the clicked point along the viewport frustrum
- var ray = viewport.CastRayFromScreen(e.X, e.Y);
- Index: Sledge.Editor/Tools/TextureApplicationForm.cs
- ===================================================================
- --- Sledge.Editor/Tools/TextureApplicationForm.cs (revision 489)
- +++ Sledge.Editor/Tools/TextureApplicationForm.cs (working copy)
- @@ -503,6 +503,12 @@
- }
- }
- + //mxd
- + private void TexturesListTextureSelected(object sender, TextureItem item)
- + {
- + OnTextureApply(item);
- + }
- +
- private void TreatAsOneCheckboxToggled(object sender, EventArgs e)
- {
- if (_freeze) return;
- @@ -527,5 +533,6 @@
- Mediator.Publish(HotkeysMediator.SwitchTool, HotkeyTool.Texture);
- }
- }
- +
- }
- }
- Index: Sledge.Editor/Tools/TextureApplicationForm.Designer.cs
- ===================================================================
- --- Sledge.Editor/Tools/TextureApplicationForm.Designer.cs (revision 489)
- +++ Sledge.Editor/Tools/TextureApplicationForm.Designer.cs (working copy)
- @@ -600,6 +600,7 @@
- this.RecentTexturesList.SortDescending = false;
- this.RecentTexturesList.SortOrder = Sledge.Editor.UI.TextureListPanel.TextureSortOrder.None;
- this.RecentTexturesList.TabIndex = 38;
- + this.RecentTexturesList.TextureSelected += new Sledge.Editor.UI.TextureListPanel.TextureSelectedEventHandler(this.TexturesListTextureSelected);
- //
- // SelectedTexturesList
- //
- @@ -614,6 +615,7 @@
- this.SelectedTexturesList.SortDescending = false;
- this.SelectedTexturesList.SortOrder = Sledge.Editor.UI.TextureListPanel.TextureSortOrder.Name;
- this.SelectedTexturesList.TabIndex = 37;
- + this.SelectedTexturesList.TextureSelected += new Sledge.Editor.UI.TextureListPanel.TextureSelectedEventHandler(this.TexturesListTextureSelected);
- //
- // TextureApplicationForm
- //
- Index: Sledge.Editor/UI/Camera2DViewportListener.cs
- ===================================================================
- --- Sledge.Editor/UI/Camera2DViewportListener.cs (revision 489)
- +++ Sledge.Editor/UI/Camera2DViewportListener.cs (working copy)
- @@ -5,6 +5,7 @@
- using Sledge.DataStructures.Geometric;
- using Sledge.Extensions;
- using Sledge.UI;
- +using System.Drawing;
- namespace Sledge.Editor.UI
- {
- @@ -29,6 +30,8 @@
- if (e.KeyCode == Keys.Space)
- {
- Viewport.Cursor = Cursors.Default;
- + _mouseDown = null; //mxd
- + Viewport.Capture = false; //mxd
- e.Handled = true;
- }
- }
- @@ -38,6 +41,9 @@
- if (e.KeyCode == Keys.Space)
- {
- Viewport.Cursor = Cursors.SizeAll;
- + Viewport.Capture = true; //mxd
- + Point p = e.Sender.PointToClient(Cursor.Position); //TODO: (mxd) Shouldn't ViewportEvent always have proper mouse location?
- + _mouseDown = new Coordinate(p.X, Viewport2D.Height - p.Y, 0); //mxd
- e.Handled = true;
- }
- var str = e.KeyCode.ToString();
- @@ -67,15 +73,11 @@
- public void MouseMove(ViewportEvent e)
- {
- - var lmouse = Control.MouseButtons.HasFlag(MouseButtons.Left);
- var mmouse = Control.MouseButtons.HasFlag(MouseButtons.Middle);
- var space = KeyboardState.IsKeyDown(Keys.Space);
- if (space || mmouse)
- {
- Viewport.Cursor = Cursors.SizeAll;
- -
- - if (lmouse || mmouse)
- - {
- var point = new Coordinate(e.X, Viewport2D.Height - e.Y, 0);
- var difference = _mouseDown - point;
- Viewport2D.Position += difference / Viewport2D.Zoom;
- @@ -82,7 +84,6 @@
- _mouseDown = point;
- e.Handled = true;
- }
- - }
- var pt = Viewport2D.Expand(Viewport2D.ScreenToWorld(new Coordinate(e.X, Viewport2D.Height - e.Y, 0)));
- Mediator.Publish(EditorMediator.MouseCoordinatesChanged, pt);
- @@ -104,7 +105,7 @@
- public void MouseUp(ViewportEvent e)
- {
- - if ((KeyboardState.IsKeyDown(Keys.Space) && e.Button == MouseButtons.Left) || e.Button == MouseButtons.Middle) e.Handled = true;
- + if (KeyboardState.IsKeyDown(Keys.Space) || e.Button == MouseButtons.Middle) e.Handled = true;
- if (e.Button == MouseButtons.Middle) Viewport.Cursor = Cursors.Default;
- _mouseDown = null;
- }
- @@ -113,7 +114,7 @@
- public void MouseDown(ViewportEvent e)
- {
- - if ((KeyboardState.IsKeyDown(Keys.Space) && e.Button == MouseButtons.Left) || e.Button == MouseButtons.Middle) e.Handled = true;
- + if (KeyboardState.IsKeyDown(Keys.Space) || e.Button == MouseButtons.Middle) e.Handled = true;
- if (e.Button == MouseButtons.Middle) Viewport.Cursor = Cursors.SizeAll;
- _mouseDown = new Coordinate(e.X, Viewport2D.Height - e.Y, 0);
- }
- Index: Sledge.Editor/UI/Camera3DViewportListener.cs
- ===================================================================
- --- Sledge.Editor/UI/Camera3DViewportListener.cs (revision 489)
- +++ Sledge.Editor/UI/Camera3DViewportListener.cs (working copy)
- @@ -19,7 +19,6 @@
- private int LastKnownX { get; set; }
- private int LastKnownY { get; set; }
- private bool PositionKnown { get; set; }
- - private bool FreeLook { get; set; }
- private bool FreeLookToggle { get; set; }
- private bool CursorVisible { get; set; }
- private Rectangle CursorClip { get; set; }
- @@ -34,7 +33,6 @@
- LastKnownX = 0;
- LastKnownY = 0;
- PositionKnown = false;
- - FreeLook = false;
- FreeLookToggle = false;
- CursorVisible = true;
- Focus = false;
- @@ -76,6 +74,8 @@
- IfKey(Keys.S, () => Camera.Advance(-move), ignore);
- IfKey(Keys.A, () => Camera.Strafe(-move), ignore);
- IfKey(Keys.D, () => Camera.Strafe(move), ignore);
- + IfKey(Keys.Q, () => Camera.AscendAbs(move), ignore); //mxd
- + IfKey(Keys.E, () => Camera.AscendAbs(-move), ignore); //mxd
- IfKey(Keys.Right, () => Camera.Pan(-tilt), ignore);
- IfKey(Keys.Left, () => Camera.Pan(tilt), ignore);
- IfKey(Keys.Up, () => Camera.Tilt(-tilt), ignore);
- @@ -111,7 +111,7 @@
- public void Render2D()
- {
- - if (!Focus || !FreeLook) return;
- + if (!Focus || !Camera.FreeLook) return;
- TextureHelper.Unbind();
- GL.Begin(PrimitiveType.Lines);
- @@ -145,7 +145,7 @@
- {
- SetFreeLook();
- }
- - if (FreeLook)
- + if (Camera.FreeLook)
- {
- e.Handled = true;
- }
- @@ -154,20 +154,19 @@
- private void SetFreeLook()
- {
- if (!Viewport.IsUnlocked(this)) return;
- - FreeLook = false;
- if (FreeLookToggle)
- {
- - FreeLook = true;
- + Camera.FreeLook = true;
- }
- else
- {
- - var space = KeyboardState.IsKeyDown(Keys.Space) || ToolManager.ActiveTool is CameraTool;
- + var space = KeyboardState.IsKeyDown(Keys.Space);
- var left = Control.MouseButtons.HasFlag(MouseButtons.Left);
- var right = Control.MouseButtons.HasFlag(MouseButtons.Right);
- - FreeLook = space && (left || right);
- + Camera.FreeLook = space || (ToolManager.ActiveTool is CameraTool && (left || right));
- }
- - if (FreeLook && CursorVisible)
- + if (Camera.FreeLook && CursorVisible)
- {
- CursorClip = Cursor.Clip;
- Cursor.Clip = Viewport.RectangleToScreen(new Rectangle(0, 0, Viewport.Width, Viewport.Height));
- @@ -176,7 +175,7 @@
- Cursor.Hide();
- Viewport.AquireInputLock(this);
- }
- - else if (!FreeLook && !CursorVisible)
- + else if (!Camera.FreeLook && !CursorVisible)
- {
- Cursor.Clip = CursorClip;
- CursorClip = Rectangle.Empty;
- @@ -189,7 +188,7 @@
- public void KeyPress(ViewportEvent e)
- {
- - if (FreeLook)
- + if (Camera.FreeLook)
- {
- e.Handled = true;
- }
- @@ -198,7 +197,7 @@
- public void MouseMove(ViewportEvent e)
- {
- if (!Focus) return;
- - if (PositionKnown && FreeLook)
- + if (PositionKnown && Camera.FreeLook)
- {
- var dx = LastKnownX - e.X;
- var dy = e.Y - LastKnownY;
- @@ -215,7 +214,7 @@
- private void MouseMoved(ViewportEvent e, int dx, int dy)
- {
- - if (!FreeLook) return;
- + if (!Camera.FreeLook) return;
- var left = Control.MouseButtons.HasFlag(MouseButtons.Left);
- var right = Control.MouseButtons.HasFlag(MouseButtons.Right);
- @@ -279,7 +278,7 @@
- public void MouseLeave(ViewportEvent e)
- {
- - if (FreeLook)
- + if (Camera.FreeLook)
- {
- LastKnownX = Viewport.Width/2;
- LastKnownY = Viewport.Height/2;
- Index: Sledge.Editor/UI/TextureBrowser.cs
- ===================================================================
- --- Sledge.Editor/UI/TextureBrowser.cs (revision 489)
- +++ Sledge.Editor/UI/TextureBrowser.cs (working copy)
- @@ -20,6 +20,20 @@
- var so = GetMemory("SortBy", 0);
- InitializeComponent();
- +
- + //mxd. Apply window position, state and size
- + Point location = GetMemory("Location", Point.Empty);
- + Size size = GetMemory("Size", Size.Empty);
- + if (location.IsEmpty || size.IsEmpty)
- + {
- + this.WindowState = FormWindowState.Maximized;
- + }
- + else
- + {
- + this.Location = location;
- + this.Size = size;
- + }
- +
- TextureList.TextureSelected += TextureSelected;
- TextureList.SelectionChanged += SelectionChanged;
- SizeCombo.SelectedIndex = 2;
- @@ -209,5 +223,20 @@
- SetMemory("SortDescending", SortDescendingCheckbox.Checked);
- TextureList.SortDescending = SortDescendingCheckbox.Checked;
- }
- +
- + //mxd. Save window size and location
- + private void TextureBrowser_FormClosing(object sender, FormClosingEventArgs e)
- + {
- + if (this.WindowState == FormWindowState.Maximized)
- + {
- + SetMemory("Location", Point.Empty);
- + SetMemory("Size", Size.Empty);
- }
- + else
- + {
- + SetMemory("Location", this.Location);
- + SetMemory("Size", this.Size);
- }
- + }
- + }
- +}
- Index: Sledge.Editor/UI/TextureBrowser.Designer.cs
- ===================================================================
- --- Sledge.Editor/UI/TextureBrowser.Designer.cs (revision 489)
- +++ Sledge.Editor/UI/TextureBrowser.Designer.cs (working copy)
- @@ -224,8 +224,9 @@
- this.KeyPreview = true;
- this.MinimizeBox = false;
- this.Name = "TextureBrowser";
- + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
- this.Text = "Texture Browser";
- - this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
- + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TextureBrowser_FormClosing);
- this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TextureBrowserKeyPress);
- this.panel1.ResumeLayout(false);
- this.panel1.PerformLayout();
- Index: Sledge.Graphics/Camera.cs
- ===================================================================
- --- Sledge.Graphics/Camera.cs (revision 489)
- +++ Sledge.Graphics/Camera.cs (working copy)
- @@ -15,6 +15,9 @@
- public int FOV { get; set; }
- public int ClipDistance { get; set; }
- + //mxd. I don't think that's the proper way to handle this, but I don't see an easy way to get to Camera3DViewportListener from a Tool
- + public bool FreeLook { get; set; }
- +
- public Camera()
- {
- LookAt = new Vector3(1, 0, 0);
- @@ -107,6 +110,14 @@
- Location += add;
- }
- + //mxd. Ascend/descent in world-space
- + public void AscendAbs(decimal units)
- + {
- + var up = new Vector3(0, 0, (float)units);
- + LookAt += up;
- + Location += up;
- + }
- +
- public Vector3 GetUp()
- {
- var temp = LookAt - Location;
- Index: Sledge.UI/Viewport3D.cs
- ===================================================================
- --- Sledge.UI/Viewport3D.cs (revision 489)
- +++ Sledge.UI/Viewport3D.cs (working copy)
- @@ -49,7 +49,11 @@
- public override void FocusOn(Box box)
- {
- - FocusOn(box.Center, Coordinate.UnitY * -box.Length);
- + decimal dist = System.Math.Max(System.Math.Max(box.Width, box.Length), box.Height); //mxd
- + Vector3 normal = Camera.Location - Camera.LookAt; //mxd
- + Vector v = new Vector(new Coordinate((decimal)normal.X, (decimal)normal.Y, (decimal)normal.Z), dist); //mxd
- +
- + FocusOn(box.Center, new Coordinate((decimal)v.X, (decimal)v.Y, (decimal)v.Z)); //mxd
- }
- public override void FocusOn(Coordinate coordinate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement