meh, more.

This commit is contained in:
codeimp 2007-09-24 19:54:47 +00:00
parent 0c71d48d5f
commit 994839117b
23 changed files with 398 additions and 64 deletions

View file

@ -15,9 +15,9 @@ shortcuts
mainwindow
{
positionx = 170;
sizeheight = 572;
sizeheight = 555;
windowstate = 2;
sizewidth = 739;
sizewidth = 660;
positiony = 95;
}

BIN
Resources/Icons/NewMap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

BIN
Resources/Icons/OpenMap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

BIN
Resources/Icons/SaveMap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

BIN
Resources/Icons/Zoom.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
Resources/Icons/Zoom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

View file

@ -118,6 +118,7 @@
<Compile Include="Rendering\IResource.cs" />
<Compile Include="Rendering\PixelColor.cs" />
<Compile Include="Rendering\PTVertex.cs" />
<Compile Include="Rendering\Renderer.cs" />
<Compile Include="Rendering\Renderer2D.cs" />
<Compile Include="Rendering\Renderer3D.cs" />
<Compile Include="Images\TextureImage.cs" />
@ -157,6 +158,10 @@
</ItemGroup>
<ItemGroup>
<Content Include="Resources\Builder.ico" />
<None Include="Resources\Zoom.png" />
<None Include="Resources\SaveMap.png" />
<None Include="Resources\OpenMap.png" />
<None Include="Resources\NewMap.png" />
<None Include="Resources\Splash2small.png" />
</ItemGroup>
<ItemGroup>

View file

@ -35,7 +35,7 @@ using CodeImp.DoomBuilder.Controls;
namespace CodeImp.DoomBuilder.Editing
{
internal class EditMode : IDisposable
internal abstract class EditMode : IDisposable
{
#region ================== Constants
@ -43,9 +43,6 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Variables
// Graphics
protected D3DGraphics graphics;
// Disposing
protected bool isdisposed = false;
@ -53,7 +50,6 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Properties
// Disposing
public bool IsDisposed { get { return isdisposed; } }
#endregion
@ -63,9 +59,6 @@ namespace CodeImp.DoomBuilder.Editing
// Constructor
public EditMode()
{
// Initialize
this.graphics = General.Map.Graphics;
// Bind any methods
ActionAttribute.BindMethods(this);

View file

@ -52,36 +52,7 @@ namespace CodeImp.DoomBuilder.Editing
// Constructor
public FrozenOverviewMode()
{
float left = float.MaxValue;
float top = float.MaxValue;
float right = float.MinValue;
float bottom = float.MinValue;
float scalew, scaleh, scale;
float width, height;
// Go for all vertices
foreach(Vertex v in General.Map.Data.Vertices)
{
// Adjust boundaries by vertices
if(v.Position.x < left) left = v.Position.x;
if(v.Position.x > right) right = v.Position.x;
if(v.Position.y < top) top = v.Position.y;
if(v.Position.y > bottom) bottom = v.Position.y;
}
// Calculate width/height
width = (right - left);
height = (bottom - top);
// Calculate scale to view map at
scalew = (float)General.Map.Graphics.RenderTarget.ClientSize.Width / (width * 1.1f);
scaleh = (float)General.Map.Graphics.RenderTarget.ClientSize.Height / (height * 1.1f);
if(scalew < scaleh) scale = scalew; else scale = scaleh;
// Change the view to see the whole map
renderer.ScaleView(scale);
renderer.PositionView(left + (right - left) * 0.5f, top + (bottom - top) * 0.5f);
General.Map.Data.Update();
CenterInScreen();
}
// Diposer

View file

@ -64,7 +64,7 @@ namespace CodeImp.DoomBuilder.Editing
public ViewClassicMode()
{
// Initialize
this.renderer = graphics.Renderer2D;
this.renderer = General.Map.Graphics.Renderer2D;
}
// Diposer
@ -154,8 +154,8 @@ namespace CodeImp.DoomBuilder.Editing
newscale = renderer.Scale * deltaz;
// Get the dimensions of the display
clientsize = new Vector2D(graphics.RenderTarget.ClientSize.Width,
graphics.RenderTarget.ClientSize.Height);
clientsize = new Vector2D(General.Map.Graphics.RenderTarget.ClientSize.Width,
General.Map.Graphics.RenderTarget.ClientSize.Height);
// When mouse is inside display
if(mouseinside)
@ -171,13 +171,66 @@ namespace CodeImp.DoomBuilder.Editing
// Calculate view position difference
diff = ((clientsize / newscale) - (clientsize / renderer.Scale)) * zoompos;
// Zoom now
renderer.PositionView(renderer.OffsetX - diff.x, renderer.OffsetY + diff.y);
renderer.ScaleView(newscale);
General.Map.Data.Update();
RedrawDisplay();
// Determine new unprojected mouse coordinates
mousemappos = renderer.GetMapCoordinates(mousepos);
General.MainWindow.UpdateCoordinates(mousemappos);
}
// This zooms to a specific level
public void SetZoom(float newscale)
{
// Zoom now
renderer.ScaleView(newscale);
General.Map.Data.Update();
RedrawDisplay();
// Determine new unprojected mouse coordinates
mousemappos = renderer.GetMapCoordinates(mousepos);
General.MainWindow.UpdateCoordinates(mousemappos);
}
// This zooms and scrolls to fit the map in the window
public void CenterInScreen()
{
float left = float.MaxValue;
float top = float.MaxValue;
float right = float.MinValue;
float bottom = float.MinValue;
float scalew, scaleh, scale;
float width, height;
// Go for all vertices
foreach(Vertex v in General.Map.Data.Vertices)
{
// Adjust boundaries by vertices
if(v.Position.x < left) left = v.Position.x;
if(v.Position.x > right) right = v.Position.x;
if(v.Position.y < top) top = v.Position.y;
if(v.Position.y > bottom) bottom = v.Position.y;
}
// Calculate width/height
width = (right - left);
height = (bottom - top);
// Calculate scale to view map at
scalew = (float)General.Map.Graphics.RenderTarget.ClientSize.Width / (width * 1.1f);
scaleh = (float)General.Map.Graphics.RenderTarget.ClientSize.Height / (height * 1.1f);
if(scalew < scaleh) scale = scalew; else scale = scaleh;
// Change the view to see the whole map
renderer.ScaleView(scale);
renderer.PositionView(left + (right - left) * 0.5f, top + (bottom - top) * 0.5f);
General.Map.Data.Update();
RedrawDisplay();
// Determine new unprojected mouse coordinates
mousemappos = renderer.GetMapCoordinates(mousepos);
General.MainWindow.UpdateCoordinates(mousemappos);

View file

@ -24,6 +24,7 @@ using System.Text;
using System.Drawing;
using SlimDX.Direct3D9;
using System.Drawing.Imaging;
using CodeImp.DoomBuilder.Rendering;
#endregion

View file

@ -48,8 +48,21 @@ namespace CodeImp.DoomBuilder.Interface
this.menuhelp = new System.Windows.Forms.ToolStripMenuItem();
this.itemhelpabout = new System.Windows.Forms.ToolStripMenuItem();
this.toolbar = new System.Windows.Forms.ToolStrip();
this.buttonnewmap = new System.Windows.Forms.ToolStripButton();
this.buttonopenmap = new System.Windows.Forms.ToolStripButton();
this.buttonsavemap = new System.Windows.Forms.ToolStripButton();
this.statusbar = new System.Windows.Forms.StatusStrip();
this.statuslabel = new System.Windows.Forms.ToolStripStatusLabel();
this.zoomlabel = new System.Windows.Forms.ToolStripStatusLabel();
this.buttonzoom = new System.Windows.Forms.ToolStripDropDownButton();
this.itemzoom200 = new System.Windows.Forms.ToolStripMenuItem();
this.itemzoom100 = new System.Windows.Forms.ToolStripMenuItem();
this.itemzoom50 = new System.Windows.Forms.ToolStripMenuItem();
this.itemzoom25 = new System.Windows.Forms.ToolStripMenuItem();
this.itemzoom10 = new System.Windows.Forms.ToolStripMenuItem();
this.itemzoom5 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.itemzoomfittoscreen = new System.Windows.Forms.ToolStripMenuItem();
this.xposlabel = new System.Windows.Forms.ToolStripStatusLabel();
this.yposlabel = new System.Windows.Forms.ToolStripStatusLabel();
this.panelinfo = new System.Windows.Forms.Panel();
@ -61,6 +74,7 @@ namespace CodeImp.DoomBuilder.Interface
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.menumain.SuspendLayout();
this.toolbar.SuspendLayout();
this.statusbar.SuspendLayout();
this.SuspendLayout();
//
@ -122,6 +136,7 @@ namespace CodeImp.DoomBuilder.Interface
//
// itemnewmap
//
this.itemnewmap.Image = global::CodeImp.DoomBuilder.Properties.Resources.NewMap;
this.itemnewmap.Name = "itemnewmap";
this.itemnewmap.ShortcutKeyDisplayString = "";
this.itemnewmap.Size = new System.Drawing.Size(201, 22);
@ -131,6 +146,7 @@ namespace CodeImp.DoomBuilder.Interface
//
// itemopenmap
//
this.itemopenmap.Image = global::CodeImp.DoomBuilder.Properties.Resources.OpenMap;
this.itemopenmap.Name = "itemopenmap";
this.itemopenmap.Size = new System.Drawing.Size(201, 22);
this.itemopenmap.Tag = "openmap";
@ -146,6 +162,7 @@ namespace CodeImp.DoomBuilder.Interface
//
// itemsavemap
//
this.itemsavemap.Image = global::CodeImp.DoomBuilder.Properties.Resources.SaveMap;
this.itemsavemap.Name = "itemsavemap";
this.itemsavemap.Size = new System.Drawing.Size(201, 22);
this.itemsavemap.Text = "Save Map";
@ -194,17 +211,52 @@ namespace CodeImp.DoomBuilder.Interface
// toolbar
//
this.toolbar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.toolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.buttonnewmap,
this.buttonopenmap,
this.buttonsavemap});
this.toolbar.Location = new System.Drawing.Point(0, 24);
this.toolbar.Name = "toolbar";
this.toolbar.Size = new System.Drawing.Size(731, 25);
this.toolbar.TabIndex = 1;
this.toolbar.Text = "toolStrip1";
//
// buttonnewmap
//
this.buttonnewmap.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.buttonnewmap.Image = global::CodeImp.DoomBuilder.Properties.Resources.NewMap;
this.buttonnewmap.ImageTransparentColor = System.Drawing.Color.Magenta;
this.buttonnewmap.Name = "buttonnewmap";
this.buttonnewmap.Size = new System.Drawing.Size(23, 22);
this.buttonnewmap.Text = "toolStripButton1";
this.buttonnewmap.Click += new System.EventHandler(this.itemnewmap_Click);
//
// buttonopenmap
//
this.buttonopenmap.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.buttonopenmap.Image = global::CodeImp.DoomBuilder.Properties.Resources.OpenMap;
this.buttonopenmap.ImageTransparentColor = System.Drawing.Color.Magenta;
this.buttonopenmap.Name = "buttonopenmap";
this.buttonopenmap.Size = new System.Drawing.Size(23, 22);
this.buttonopenmap.Text = "toolStripButton1";
this.buttonopenmap.Click += new System.EventHandler(this.itemopenmap_Click);
//
// buttonsavemap
//
this.buttonsavemap.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.buttonsavemap.Image = global::CodeImp.DoomBuilder.Properties.Resources.SaveMap;
this.buttonsavemap.ImageTransparentColor = System.Drawing.Color.Magenta;
this.buttonsavemap.Name = "buttonsavemap";
this.buttonsavemap.Size = new System.Drawing.Size(23, 22);
this.buttonsavemap.Text = "toolStripButton1";
//
// statusbar
//
this.statusbar.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.statusbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.statuslabel,
this.zoomlabel,
this.buttonzoom,
toolStripSeparator1,
this.xposlabel,
toolStripStatusLabel1,
@ -219,11 +271,99 @@ namespace CodeImp.DoomBuilder.Interface
//
this.statuslabel.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.statuslabel.Name = "statuslabel";
this.statuslabel.Size = new System.Drawing.Size(599, 18);
this.statuslabel.Size = new System.Drawing.Size(520, 18);
this.statuslabel.Spring = true;
this.statuslabel.Text = "Initializing user interface...";
this.statuslabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// zoomlabel
//
this.zoomlabel.AutoSize = false;
this.zoomlabel.Name = "zoomlabel";
this.zoomlabel.Size = new System.Drawing.Size(50, 18);
this.zoomlabel.Text = "50%";
this.zoomlabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.zoomlabel.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay;
//
// buttonzoom
//
this.buttonzoom.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.buttonzoom.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.itemzoom200,
this.itemzoom100,
this.itemzoom50,
this.itemzoom25,
this.itemzoom10,
this.itemzoom5,
this.toolStripSeparator2,
this.itemzoomfittoscreen});
this.buttonzoom.Image = global::CodeImp.DoomBuilder.Properties.Resources.Zoom;
this.buttonzoom.ImageTransparentColor = System.Drawing.Color.Transparent;
this.buttonzoom.Name = "buttonzoom";
this.buttonzoom.Size = new System.Drawing.Size(29, 21);
this.buttonzoom.Text = "Zoom";
this.buttonzoom.ToolTipText = "Zoom level";
//
// itemzoom200
//
this.itemzoom200.Name = "itemzoom200";
this.itemzoom200.Size = new System.Drawing.Size(167, 22);
this.itemzoom200.Tag = "200";
this.itemzoom200.Text = "200%";
this.itemzoom200.Click += new System.EventHandler(this.itemzoomto_Click);
//
// itemzoom100
//
this.itemzoom100.Name = "itemzoom100";
this.itemzoom100.Size = new System.Drawing.Size(167, 22);
this.itemzoom100.Tag = "100";
this.itemzoom100.Text = "100%";
this.itemzoom100.Click += new System.EventHandler(this.itemzoomto_Click);
//
// itemzoom50
//
this.itemzoom50.Name = "itemzoom50";
this.itemzoom50.Size = new System.Drawing.Size(167, 22);
this.itemzoom50.Tag = "50";
this.itemzoom50.Text = "50%";
this.itemzoom50.Click += new System.EventHandler(this.itemzoomto_Click);
//
// itemzoom25
//
this.itemzoom25.Name = "itemzoom25";
this.itemzoom25.Size = new System.Drawing.Size(167, 22);
this.itemzoom25.Tag = "25";
this.itemzoom25.Text = "25%";
this.itemzoom25.Click += new System.EventHandler(this.itemzoomto_Click);
//
// itemzoom10
//
this.itemzoom10.Name = "itemzoom10";
this.itemzoom10.Size = new System.Drawing.Size(167, 22);
this.itemzoom10.Tag = "10";
this.itemzoom10.Text = "10%";
this.itemzoom10.Click += new System.EventHandler(this.itemzoomto_Click);
//
// itemzoom5
//
this.itemzoom5.Name = "itemzoom5";
this.itemzoom5.Size = new System.Drawing.Size(167, 22);
this.itemzoom5.Tag = "5";
this.itemzoom5.Text = "5%";
this.itemzoom5.Click += new System.EventHandler(this.itemzoomto_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(164, 6);
//
// itemzoomfittoscreen
//
this.itemzoomfittoscreen.Name = "itemzoomfittoscreen";
this.itemzoomfittoscreen.Size = new System.Drawing.Size(167, 22);
this.itemzoomfittoscreen.Text = "Fit to screen";
this.itemzoomfittoscreen.Click += new System.EventHandler(this.itemzoomfittoscreen_Click);
//
// xposlabel
//
this.xposlabel.AutoSize = false;
@ -300,6 +440,8 @@ namespace CodeImp.DoomBuilder.Interface
this.Load += new System.EventHandler(this.MainForm_Load);
this.menumain.ResumeLayout(false);
this.menumain.PerformLayout();
this.toolbar.ResumeLayout(false);
this.toolbar.PerformLayout();
this.statusbar.ResumeLayout(false);
this.statusbar.PerformLayout();
this.ResumeLayout(false);
@ -329,5 +471,18 @@ namespace CodeImp.DoomBuilder.Interface
private System.Windows.Forms.ToolStripMenuItem itemnorecent;
private System.Windows.Forms.ToolStripStatusLabel xposlabel;
private System.Windows.Forms.ToolStripStatusLabel yposlabel;
private System.Windows.Forms.ToolStripButton buttonnewmap;
private System.Windows.Forms.ToolStripButton buttonopenmap;
private System.Windows.Forms.ToolStripButton buttonsavemap;
private System.Windows.Forms.ToolStripStatusLabel zoomlabel;
private System.Windows.Forms.ToolStripDropDownButton buttonzoom;
private System.Windows.Forms.ToolStripMenuItem itemzoomfittoscreen;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem itemzoom100;
private System.Windows.Forms.ToolStripMenuItem itemzoom200;
private System.Windows.Forms.ToolStripMenuItem itemzoom50;
private System.Windows.Forms.ToolStripMenuItem itemzoom25;
private System.Windows.Forms.ToolStripMenuItem itemzoom10;
private System.Windows.Forms.ToolStripMenuItem itemzoom5;
}
}

View file

@ -21,10 +21,12 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Globalization;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Editing;
#endregion
@ -71,6 +73,9 @@ namespace CodeImp.DoomBuilder.Interface
// Setup controls
InitializeComponent();
// Fix things
buttonzoom.Font = menufile.Font;
// Apply shortcut keys
ApplyShortcutKeys();
@ -199,6 +204,54 @@ namespace CodeImp.DoomBuilder.Interface
// Update status bar
statusbar.Update();
}
// This changes zoom display
public void UpdateZoom(float scale)
{
// Update scale label
if(float.IsNaN(scale))
zoomlabel.Text = "--";
else
{
scale *= 100;
zoomlabel.Text = scale.ToString("##0") + "%";
}
// Update status bar
statusbar.Update();
}
// Zoom to a specified level
private void itemzoomto_Click(object sender, EventArgs e)
{
int zoom;
if(General.Map == null) return;
// In classic mode?
if(General.Map.Mode is ViewClassicMode)
{
// Requested from menu?
if(sender is ToolStripMenuItem)
{
// Get integral zoom level
zoom = int.Parse((sender as ToolStripMenuItem).Tag.ToString(), CultureInfo.InvariantCulture);
// Zoom now
(General.Map.Mode as ViewClassicMode).SetZoom((float)zoom / 100f);
}
}
}
// Zoom to fit in screen
private void itemzoomfittoscreen_Click(object sender, EventArgs e)
{
if(General.Map == null) return;
// In classic mode?
if(General.Map.Mode is ViewClassicMode)
(General.Map.Mode as ViewClassicMode).CenterInScreen();
}
#endregion
@ -250,7 +303,7 @@ namespace CodeImp.DoomBuilder.Interface
General.Map.Graphics.Reset();
// Make sure control is repainted
display.Update();
//display.Update();
}
// Redraw now

View file

@ -60,6 +60,27 @@ namespace CodeImp.DoomBuilder.Properties {
}
}
internal static System.Drawing.Bitmap NewMap {
get {
object obj = ResourceManager.GetObject("NewMap", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap OpenMap {
get {
object obj = ResourceManager.GetObject("OpenMap", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap SaveMap {
get {
object obj = ResourceManager.GetObject("SaveMap", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Splash2 {
get {
object obj = ResourceManager.GetObject("Splash2", resourceCulture);
@ -73,5 +94,12 @@ namespace CodeImp.DoomBuilder.Properties {
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Zoom {
get {
object obj = ResourceManager.GetObject("Zoom", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View file

@ -118,10 +118,22 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="OpenMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Splash2small" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Splash2small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SaveMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SaveMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Splash2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Splash2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="NewMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NewMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Zoom" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Zoom.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View file

@ -296,6 +296,10 @@ namespace CodeImp.DoomBuilder.Rendering
// Initialize settings
SetupSettings();
// Reset renderers
renderer2d.Reset();
renderer3d.Reset();
// TODO: Reload all Direct3D resources
// Success

View file

@ -0,0 +1,62 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace CodeImp.DoomBuilder.Rendering
{
internal abstract class Renderer : IDisposable
{
#region ================== Constants
#endregion
#region ================== Variables
// Disposing
protected bool isdisposed = false;
#endregion
#region ================== Properties
// Disposing
public bool IsDisposed { get { return isdisposed; } }
#endregion
#region ================== Constructor / Disposer
// Constructor
public Renderer()
{
// Initialize
// We have no destructor
GC.SuppressFinalize(this);
}
// Diposer
public virtual void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
// Clean up
// Done
isdisposed = true;
}
}
#endregion
#region ================== Methods
// This is called when the graphics need to be reset
public virtual void Reset() { }
#endregion
}
}

View file

@ -37,7 +37,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.Rendering
{
internal unsafe class Renderer2D : IDisposable
internal unsafe class Renderer2D : Renderer
{
#region ================== Constants
@ -59,9 +59,6 @@ namespace CodeImp.DoomBuilder.Rendering
private float scale;
private float offsetx;
private float offsety;
// Disposing
private bool isdisposed = false;
#endregion
@ -70,7 +67,6 @@ namespace CodeImp.DoomBuilder.Rendering
public float OffsetX { get { return offsetx; } }
public float OffsetY { get { return offsety; } }
public float Scale { get { return scale; } }
public bool IsDisposed { get { return isdisposed; } }
#endregion
@ -90,7 +86,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Diposer
public void Dispose()
public override void Dispose()
{
// Not already disposed?
if(!isdisposed)
@ -101,7 +97,7 @@ namespace CodeImp.DoomBuilder.Rendering
pixels = null;
// Done
isdisposed = true;
base.Dispose();
}
}
@ -111,8 +107,12 @@ namespace CodeImp.DoomBuilder.Rendering
// This is called resets when the device is reset
// (when resized or display adapter was changed)
public void Reset()
public override void Reset()
{
// Trash old image
graphics.RenderTarget.BackgroundImage = null;
if(image != null) image.Dispose();
// Re-create image memory
CreateMemory();
}
@ -170,6 +170,9 @@ namespace CodeImp.DoomBuilder.Rendering
{
// Change zoom scale
this.scale = scale;
// Show zoom on main window
General.MainWindow.UpdateZoom(scale);
// Recalculate linedefs (normal lengths must be adjusted)
foreach(Linedef l in General.Map.Data.Linedefs) l.NeedUpdate();

View file

@ -32,7 +32,7 @@ using System.ComponentModel;
namespace CodeImp.DoomBuilder.Rendering
{
internal class Renderer3D : IDisposable
internal class Renderer3D : Renderer
{
#region ================== Constants
@ -43,16 +43,10 @@ namespace CodeImp.DoomBuilder.Rendering
// Owner
private D3DGraphics graphics;
// Disposing
private bool isdisposed = false;
#endregion
#region ================== Properties
// Disposing
public bool IsDisposed { get { return isdisposed; } }
#endregion
#region ================== Constructor / Disposer
@ -61,14 +55,14 @@ namespace CodeImp.DoomBuilder.Rendering
public Renderer3D(D3DGraphics graphics)
{
// Initialize
this.graphics = graphics;
this.graphics = General.Map.Graphics;
// We have no destructor
GC.SuppressFinalize(this);
}
// Diposer
public void Dispose()
public override void Dispose()
{
// Not already disposed?
if(!isdisposed)
@ -76,7 +70,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Clean up
// Done
isdisposed = true;
base.Dispose();
}
}

BIN
Source/Resources/NewMap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

BIN
Source/Resources/Zoom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B