- added feature to display an image from file on the background along with ability to scale it

- fixed some scaled sizes in some image data classes
This commit is contained in:
codeimp 2008-10-15 19:14:32 +00:00
parent 1bf3ab747c
commit 6d1f43c7c6
9 changed files with 243 additions and 36 deletions

View file

@ -12,6 +12,9 @@
- Make DECORATE support - Make DECORATE support
- Make plugin dependencies
(load BEFORE and load AFTER so that also their functions are called in that order)
- Make dialog and editing mode help documentation - Make dialog and editing mode help documentation
- Make Plugin Development Kit - Make Plugin Development Kit

View file

@ -45,6 +45,18 @@ namespace CodeImp.DoomBuilder.Data
// Initialize // Initialize
this.filepathname = filepathname; this.filepathname = filepathname;
SetName(name); SetName(name);
// Temporarily load file
Bitmap bmp = (Bitmap)Bitmap.FromFile(filepathname);
// Get width and height from image
width = bmp.Size.Width;
height = bmp.Size.Height;
scaledwidth = (float)bmp.Size.Width * General.Map.Config.DefaultTextureScale;
scaledheight = (float)bmp.Size.Height * General.Map.Config.DefaultTextureScale;
// Unload file
bmp.Dispose();
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
@ -69,6 +81,8 @@ namespace CodeImp.DoomBuilder.Data
// Get width and height from image // Get width and height from image
width = bitmap.Size.Width; width = bitmap.Size.Width;
height = bitmap.Size.Height; height = bitmap.Size.Height;
scaledwidth = (float)bitmap.Size.Width * General.Map.Config.DefaultTextureScale;
scaledheight = (float)bitmap.Size.Height * General.Map.Config.DefaultTextureScale;
// Pass on to base // Pass on to base
base.LocalLoadImage(); base.LocalLoadImage();

View file

@ -102,13 +102,16 @@ namespace CodeImp.DoomBuilder.Data
// Constructor // Constructor
public ImageData() public ImageData()
{ {
// We have no destructor
GC.SuppressFinalize(this);
// Defaults // Defaults
usecolorcorrection = true; usecolorcorrection = true;
} }
// Destructor
~ImageData()
{
this.Dispose();
}
// Disposer // Disposer
public virtual void Dispose() public virtual void Dispose()
{ {
@ -243,6 +246,8 @@ namespace CodeImp.DoomBuilder.Data
bitmap = new Bitmap(Properties.Resources.Failed); bitmap = new Bitmap(Properties.Resources.Failed);
width = bitmap.Size.Width; width = bitmap.Size.Width;
height = bitmap.Size.Height; height = bitmap.Size.Height;
scaledwidth = (float)bitmap.Size.Width * General.Map.Config.DefaultTextureScale;
scaledheight = (float)bitmap.Size.Height * General.Map.Config.DefaultTextureScale;
} }
// Image is ready // Image is ready

View file

@ -40,7 +40,21 @@ namespace CodeImp.DoomBuilder.Data
{ {
// Initialize // Initialize
SetName(resourcename); SetName(resourcename);
// Temporarily load resource from memory
Stream bitmapdata = General.ThisAssembly.GetManifestResourceStream("CodeImp.DoomBuilder.Resources." + Name);
Bitmap bmp = (Bitmap)Image.FromStream(bitmapdata);
// Get width and height from image
width = bmp.Size.Width;
height = bmp.Size.Height;
scaledwidth = (float)bmp.Size.Width;
scaledheight = (float)bmp.Size.Height;
// Done
bmp.Dispose();
bitmapdata.Dispose();
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }

View file

@ -45,6 +45,7 @@ namespace CodeImp.DoomBuilder.Editing
public const int SOURCE_TEXTURES = 0; public const int SOURCE_TEXTURES = 0;
public const int SOURCE_FLATS = 1; public const int SOURCE_FLATS = 1;
public const int SOURCE_FILE = 2;
#endregion #endregion
@ -60,6 +61,7 @@ namespace CodeImp.DoomBuilder.Editing
private int backsource; private int backsource;
private ImageData backimage = new NullImage(); private ImageData backimage = new NullImage();
private int backoffsetx, backoffsety; private int backoffsetx, backoffsety;
private float backscalex, backscaley;
// Disposing // Disposing
private bool isdisposed; private bool isdisposed;
@ -75,6 +77,8 @@ namespace CodeImp.DoomBuilder.Editing
internal ImageData Background { get { return backimage; } } internal ImageData Background { get { return backimage; } }
internal int BackgroundX { get { return backoffsetx; } } internal int BackgroundX { get { return backoffsetx; } }
internal int BackgroundY { get { return backoffsety; } } internal int BackgroundY { get { return backoffsety; } }
internal float BackgroundScaleX { get { return backscalex; } }
internal float BackgroundScaleY { get { return backscaley; } }
internal bool Disposed { get { return isdisposed; } } internal bool Disposed { get { return isdisposed; } }
#endregion #endregion
@ -86,7 +90,9 @@ namespace CodeImp.DoomBuilder.Editing
{ {
// Initialize // Initialize
SetGridSize(DEFAULT_GRID_SIZE); SetGridSize(DEFAULT_GRID_SIZE);
backscalex = 1.0f;
backscaley = 1.0f;
// Register actions // Register actions
General.Actions.BindMethods(this); General.Actions.BindMethods(this);
@ -99,6 +105,9 @@ namespace CodeImp.DoomBuilder.Editing
{ {
if(!isdisposed) if(!isdisposed)
{ {
// Dispose image if needed
if(backimage is FileImage) (backimage as FileImage).Dispose();
// Clean up // Clean up
backimage = null; backimage = null;
@ -138,30 +147,38 @@ namespace CodeImp.DoomBuilder.Editing
LinkBackground(); LinkBackground();
} }
// This sets the background offset // This sets the background view
internal void SetBackgroundOffset(int offsetx, int offsety) internal void SetBackgroundView(int offsetx, int offsety, float scalex, float scaley)
{ {
// Set background offset // Set background offset
this.backoffsetx = offsetx; this.backoffsetx = offsetx;
this.backoffsety = offsety; this.backoffsety = offsety;
this.backscalex = scalex;
this.backscaley = scaley;
} }
// This finds and links the background image // This finds and links the background image
internal void LinkBackground() internal void LinkBackground()
{ {
// From textures? // Dispose image if needed
if(backsource == SOURCE_TEXTURES) if(backimage is FileImage) (backimage as FileImage).Dispose();
{
// Get this texture
backimage = General.Map.Data.GetTextureImage(background);
}
// From flats?
else if(backsource == SOURCE_FLATS)
{
// Get this flat
backimage = General.Map.Data.GetFlatImage(background);
}
// Where to load background from?
switch(backsource)
{
case SOURCE_TEXTURES:
backimage = General.Map.Data.GetTextureImage(background);
break;
case SOURCE_FLATS:
backimage = General.Map.Data.GetFlatImage(background);
break;
case SOURCE_FILE:
backimage = new FileImage(background, background);
break;
}
// Make sure it is loaded // Make sure it is loaded
backimage.LoadImage(); backimage.LoadImage();
backimage.CreateTexture(); backimage.CreateTexture();

View file

@ -731,7 +731,11 @@ namespace CodeImp.DoomBuilder.Rendering
{ {
Vector2D ltpos, rbpos; Vector2D ltpos, rbpos;
Vector2D backoffset = new Vector2D((float)General.Map.Grid.BackgroundX, (float)General.Map.Grid.BackgroundY); Vector2D backoffset = new Vector2D((float)General.Map.Grid.BackgroundX, (float)General.Map.Grid.BackgroundY);
Vector2D backimagesize = new Vector2D((float)General.Map.Grid.Background.Width, (float)General.Map.Grid.Background.Height); Vector2D backimagesize = new Vector2D((float)General.Map.Grid.Background.ScaledWidth, (float)General.Map.Grid.Background.ScaledHeight);
Vector2D backimagescale = new Vector2D(General.Map.Grid.BackgroundScaleX, General.Map.Grid.BackgroundScaleY);
// Scale the background image size
backimagesize *= backimagescale;
// Only if a background image is set // Only if a background image is set
if((General.Map.Grid.Background != null) && if((General.Map.Grid.Background != null) &&

View file

@ -32,6 +32,10 @@ namespace CodeImp.DoomBuilder.Windows
System.Windows.Forms.Label label1; System.Windows.Forms.Label label1;
System.Windows.Forms.GroupBox groupBox2; System.Windows.Forms.GroupBox groupBox2;
this.gridsize = new System.Windows.Forms.NumericUpDown(); this.gridsize = new System.Windows.Forms.NumericUpDown();
this.backscaley = new System.Windows.Forms.NumericUpDown();
this.backscalex = new System.Windows.Forms.NumericUpDown();
this.backscale = new System.Windows.Forms.Label();
this.selectfile = new System.Windows.Forms.Button();
this.showbackground = new System.Windows.Forms.CheckBox(); this.showbackground = new System.Windows.Forms.CheckBox();
this.backoffsety = new System.Windows.Forms.NumericUpDown(); this.backoffsety = new System.Windows.Forms.NumericUpDown();
this.backoffsetx = new System.Windows.Forms.NumericUpDown(); this.backoffsetx = new System.Windows.Forms.NumericUpDown();
@ -41,18 +45,23 @@ namespace CodeImp.DoomBuilder.Windows
this.backgroundimage = new System.Windows.Forms.Panel(); this.backgroundimage = new System.Windows.Forms.Panel();
this.cancel = new System.Windows.Forms.Button(); this.cancel = new System.Windows.Forms.Button();
this.apply = new System.Windows.Forms.Button(); this.apply = new System.Windows.Forms.Button();
this.browsefile = new System.Windows.Forms.OpenFileDialog();
groupBox1 = new System.Windows.Forms.GroupBox(); groupBox1 = new System.Windows.Forms.GroupBox();
label1 = new System.Windows.Forms.Label(); label1 = new System.Windows.Forms.Label();
groupBox2 = new System.Windows.Forms.GroupBox(); groupBox2 = new System.Windows.Forms.GroupBox();
groupBox1.SuspendLayout(); groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gridsize)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gridsize)).BeginInit();
groupBox2.SuspendLayout(); groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.backscaley)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.backscalex)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.backoffsety)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.backoffsety)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.backoffsetx)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.backoffsetx)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// groupBox1 // groupBox1
// //
groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
groupBox1.Controls.Add(this.gridsize); groupBox1.Controls.Add(this.gridsize);
groupBox1.Controls.Add(label1); groupBox1.Controls.Add(label1);
groupBox1.Location = new System.Drawing.Point(12, 12); groupBox1.Location = new System.Drawing.Point(12, 12);
@ -96,6 +105,12 @@ namespace CodeImp.DoomBuilder.Windows
// //
// groupBox2 // groupBox2
// //
groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
groupBox2.Controls.Add(this.backscaley);
groupBox2.Controls.Add(this.backscalex);
groupBox2.Controls.Add(this.backscale);
groupBox2.Controls.Add(this.selectfile);
groupBox2.Controls.Add(this.showbackground); groupBox2.Controls.Add(this.showbackground);
groupBox2.Controls.Add(this.backoffsety); groupBox2.Controls.Add(this.backoffsety);
groupBox2.Controls.Add(this.backoffsetx); groupBox2.Controls.Add(this.backoffsetx);
@ -105,11 +120,80 @@ namespace CodeImp.DoomBuilder.Windows
groupBox2.Controls.Add(this.backgroundimage); groupBox2.Controls.Add(this.backgroundimage);
groupBox2.Location = new System.Drawing.Point(12, 89); groupBox2.Location = new System.Drawing.Point(12, 89);
groupBox2.Name = "groupBox2"; groupBox2.Name = "groupBox2";
groupBox2.Size = new System.Drawing.Size(285, 181); groupBox2.Size = new System.Drawing.Size(285, 255);
groupBox2.TabIndex = 1; groupBox2.TabIndex = 1;
groupBox2.TabStop = false; groupBox2.TabStop = false;
groupBox2.Text = " Background "; groupBox2.Text = " Background ";
// //
// backscaley
//
this.backscaley.Enabled = false;
this.backscaley.ImeMode = System.Windows.Forms.ImeMode.Off;
this.backscaley.Location = new System.Drawing.Point(197, 209);
this.backscaley.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.backscaley.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.backscaley.Name = "backscaley";
this.backscaley.Size = new System.Drawing.Size(57, 20);
this.backscaley.TabIndex = 11;
this.backscaley.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// backscalex
//
this.backscalex.Enabled = false;
this.backscalex.ImeMode = System.Windows.Forms.ImeMode.Off;
this.backscalex.Location = new System.Drawing.Point(134, 209);
this.backscalex.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.backscalex.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.backscalex.Name = "backscalex";
this.backscalex.Size = new System.Drawing.Size(57, 20);
this.backscalex.TabIndex = 10;
this.backscalex.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// backscale
//
this.backscale.AutoSize = true;
this.backscale.Enabled = false;
this.backscale.Location = new System.Drawing.Point(40, 211);
this.backscale.Name = "backscale";
this.backscale.Size = new System.Drawing.Size(88, 14);
this.backscale.TabIndex = 9;
this.backscale.Text = "Scale in percent:";
//
// selectfile
//
this.selectfile.Enabled = false;
this.selectfile.Location = new System.Drawing.Point(137, 122);
this.selectfile.Name = "selectfile";
this.selectfile.Size = new System.Drawing.Size(117, 25);
this.selectfile.TabIndex = 8;
this.selectfile.Text = "Select File...";
this.selectfile.UseVisualStyleBackColor = true;
this.selectfile.Click += new System.EventHandler(this.selectfile_Click);
//
// showbackground // showbackground
// //
this.showbackground.AutoSize = true; this.showbackground.AutoSize = true;
@ -125,7 +209,7 @@ namespace CodeImp.DoomBuilder.Windows
// //
this.backoffsety.Enabled = false; this.backoffsety.Enabled = false;
this.backoffsety.ImeMode = System.Windows.Forms.ImeMode.Off; this.backoffsety.ImeMode = System.Windows.Forms.ImeMode.Off;
this.backoffsety.Location = new System.Drawing.Point(197, 137); this.backoffsety.Location = new System.Drawing.Point(197, 172);
this.backoffsety.Maximum = new decimal(new int[] { this.backoffsety.Maximum = new decimal(new int[] {
4096, 4096,
0, 0,
@ -139,7 +223,7 @@ namespace CodeImp.DoomBuilder.Windows
// //
this.backoffsetx.Enabled = false; this.backoffsetx.Enabled = false;
this.backoffsetx.ImeMode = System.Windows.Forms.ImeMode.Off; this.backoffsetx.ImeMode = System.Windows.Forms.ImeMode.Off;
this.backoffsetx.Location = new System.Drawing.Point(134, 137); this.backoffsetx.Location = new System.Drawing.Point(134, 172);
this.backoffsetx.Maximum = new decimal(new int[] { this.backoffsetx.Maximum = new decimal(new int[] {
4096, 4096,
0, 0,
@ -153,7 +237,7 @@ namespace CodeImp.DoomBuilder.Windows
// //
this.backoffset.AutoSize = true; this.backoffset.AutoSize = true;
this.backoffset.Enabled = false; this.backoffset.Enabled = false;
this.backoffset.Location = new System.Drawing.Point(25, 140); this.backoffset.Location = new System.Drawing.Point(25, 175);
this.backoffset.Name = "backoffset"; this.backoffset.Name = "backoffset";
this.backoffset.Size = new System.Drawing.Size(103, 14); this.backoffset.Size = new System.Drawing.Size(103, 14);
this.backoffset.TabIndex = 4; this.backoffset.TabIndex = 4;
@ -162,7 +246,7 @@ namespace CodeImp.DoomBuilder.Windows
// selectflat // selectflat
// //
this.selectflat.Enabled = false; this.selectflat.Enabled = false;
this.selectflat.Location = new System.Drawing.Point(92, 91); this.selectflat.Location = new System.Drawing.Point(137, 91);
this.selectflat.Name = "selectflat"; this.selectflat.Name = "selectflat";
this.selectflat.Size = new System.Drawing.Size(117, 25); this.selectflat.Size = new System.Drawing.Size(117, 25);
this.selectflat.TabIndex = 3; this.selectflat.TabIndex = 3;
@ -173,7 +257,7 @@ namespace CodeImp.DoomBuilder.Windows
// selecttexture // selecttexture
// //
this.selecttexture.Enabled = false; this.selecttexture.Enabled = false;
this.selecttexture.Location = new System.Drawing.Point(92, 60); this.selecttexture.Location = new System.Drawing.Point(137, 60);
this.selecttexture.Name = "selecttexture"; this.selecttexture.Name = "selecttexture";
this.selecttexture.Size = new System.Drawing.Size(117, 25); this.selecttexture.Size = new System.Drawing.Size(117, 25);
this.selecttexture.TabIndex = 2; this.selecttexture.TabIndex = 2;
@ -188,13 +272,14 @@ namespace CodeImp.DoomBuilder.Windows
this.backgroundimage.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.backgroundimage.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.backgroundimage.Location = new System.Drawing.Point(28, 60); this.backgroundimage.Location = new System.Drawing.Point(28, 60);
this.backgroundimage.Name = "backgroundimage"; this.backgroundimage.Name = "backgroundimage";
this.backgroundimage.Size = new System.Drawing.Size(58, 56); this.backgroundimage.Size = new System.Drawing.Size(91, 87);
this.backgroundimage.TabIndex = 1; this.backgroundimage.TabIndex = 1;
// //
// cancel // cancel
// //
this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancel.Location = new System.Drawing.Point(185, 283); this.cancel.Location = new System.Drawing.Point(185, 357);
this.cancel.Name = "cancel"; this.cancel.Name = "cancel";
this.cancel.Size = new System.Drawing.Size(112, 25); this.cancel.Size = new System.Drawing.Size(112, 25);
this.cancel.TabIndex = 22; this.cancel.TabIndex = 22;
@ -204,7 +289,8 @@ namespace CodeImp.DoomBuilder.Windows
// //
// apply // apply
// //
this.apply.Location = new System.Drawing.Point(67, 283); this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.apply.Location = new System.Drawing.Point(67, 357);
this.apply.Name = "apply"; this.apply.Name = "apply";
this.apply.Size = new System.Drawing.Size(112, 25); this.apply.Size = new System.Drawing.Size(112, 25);
this.apply.TabIndex = 21; this.apply.TabIndex = 21;
@ -212,12 +298,18 @@ namespace CodeImp.DoomBuilder.Windows
this.apply.UseVisualStyleBackColor = true; this.apply.UseVisualStyleBackColor = true;
this.apply.Click += new System.EventHandler(this.apply_Click); this.apply.Click += new System.EventHandler(this.apply_Click);
// //
// browsefile
//
this.browsefile.Filter = "All supported images|*.bmp;*.jpg;*.png|All Files|*.*";
this.browsefile.RestoreDirectory = true;
this.browsefile.Title = "Select Background Image File";
//
// GridSetupForm // GridSetupForm
// //
this.AcceptButton = this.apply; this.AcceptButton = this.apply;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.cancel; this.CancelButton = this.cancel;
this.ClientSize = new System.Drawing.Size(309, 318); this.ClientSize = new System.Drawing.Size(309, 392);
this.Controls.Add(this.cancel); this.Controls.Add(this.cancel);
this.Controls.Add(this.apply); this.Controls.Add(this.apply);
this.Controls.Add(groupBox2); this.Controls.Add(groupBox2);
@ -237,6 +329,8 @@ namespace CodeImp.DoomBuilder.Windows
((System.ComponentModel.ISupportInitialize)(this.gridsize)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gridsize)).EndInit();
groupBox2.ResumeLayout(false); groupBox2.ResumeLayout(false);
groupBox2.PerformLayout(); groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.backscaley)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.backscalex)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.backoffsety)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.backoffsety)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.backoffsetx)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.backoffsetx)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
@ -255,5 +349,10 @@ namespace CodeImp.DoomBuilder.Windows
private System.Windows.Forms.Button cancel; private System.Windows.Forms.Button cancel;
private System.Windows.Forms.Button apply; private System.Windows.Forms.Button apply;
private System.Windows.Forms.Label backoffset; private System.Windows.Forms.Label backoffset;
private System.Windows.Forms.Button selectfile;
private System.Windows.Forms.NumericUpDown backscaley;
private System.Windows.Forms.NumericUpDown backscalex;
private System.Windows.Forms.Label backscale;
private System.Windows.Forms.OpenFileDialog browsefile;
} }
} }

View file

@ -68,6 +68,8 @@ namespace CodeImp.DoomBuilder.Windows
// Show background offset // Show background offset
backoffsetx.Value = General.Map.Grid.BackgroundX; backoffsetx.Value = General.Map.Grid.BackgroundX;
backoffsety.Value = General.Map.Grid.BackgroundY; backoffsety.Value = General.Map.Grid.BackgroundY;
backscalex.Value = (int)(General.Map.Grid.BackgroundScaleX * 100.0f);
backscaley.Value = (int)(General.Map.Grid.BackgroundScaleY * 100.0f);
} }
// Show Background changed // Show Background changed
@ -76,9 +78,13 @@ namespace CodeImp.DoomBuilder.Windows
// Enable/disable controls // Enable/disable controls
selecttexture.Enabled = showbackground.Checked; selecttexture.Enabled = showbackground.Checked;
selectflat.Enabled = showbackground.Checked; selectflat.Enabled = showbackground.Checked;
selectfile.Enabled = showbackground.Checked;
backoffset.Enabled = showbackground.Checked; backoffset.Enabled = showbackground.Checked;
backscale.Enabled = showbackground.Checked;
backoffsetx.Enabled = showbackground.Checked; backoffsetx.Enabled = showbackground.Checked;
backoffsety.Enabled = showbackground.Checked; backoffsety.Enabled = showbackground.Checked;
backscalex.Enabled = showbackground.Checked;
backscaley.Enabled = showbackground.Checked;
} }
// Browse texture // Browse texture
@ -93,7 +99,9 @@ namespace CodeImp.DoomBuilder.Windows
// Set this texture as background // Set this texture as background
backgroundname = result; backgroundname = result;
backgroundsource = GridSetup.SOURCE_TEXTURES; backgroundsource = GridSetup.SOURCE_TEXTURES;
General.DisplayZoomedImage(backgroundimage, General.Map.Data.GetTextureImage(result).GetPreview()); ImageData img = General.Map.Data.GetTextureImage(result);
img.LoadImage();
General.DisplayZoomedImage(backgroundimage, img.Bitmap);
} }
} }
@ -109,7 +117,25 @@ namespace CodeImp.DoomBuilder.Windows
// Set this flat as background // Set this flat as background
backgroundname = result; backgroundname = result;
backgroundsource = GridSetup.SOURCE_FLATS; backgroundsource = GridSetup.SOURCE_FLATS;
General.DisplayZoomedImage(backgroundimage, General.Map.Data.GetFlatImage(result).GetPreview()); ImageData img = General.Map.Data.GetFlatImage(result);
img.LoadImage();
General.DisplayZoomedImage(backgroundimage, img.Bitmap);
}
}
// Browse file
private void selectfile_Click(object sender, EventArgs e)
{
// Browse for file
if(browsefile.ShowDialog(this) == DialogResult.OK)
{
// Set this file as background
backgroundname = browsefile.FileName;
backgroundsource = GridSetup.SOURCE_FILE;
ImageData img = new FileImage(backgroundname, backgroundname);
img.LoadImage();
General.DisplayZoomedImage(backgroundimage, new Bitmap(img.Bitmap));
img.Dispose();
} }
} }
@ -125,7 +151,8 @@ namespace CodeImp.DoomBuilder.Windows
{ {
// Apply // Apply
General.Map.Grid.SetGridSize((int)gridsize.Value); General.Map.Grid.SetGridSize((int)gridsize.Value);
General.Map.Grid.SetBackgroundOffset((int)backoffsetx.Value, (int)backoffsety.Value); General.Map.Grid.SetBackgroundView((int)backoffsetx.Value, (int)backoffsety.Value,
(float)backscalex.Value / 100.0f, (float)backscaley.Value / 100.0f);
// Background image? // Background image?
if(showbackground.Checked) if(showbackground.Checked)

View file

@ -117,12 +117,12 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="groupBox1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="groupBox1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="groupBox1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="groupBox1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="gridsize.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="gridsize.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
@ -132,12 +132,33 @@
<metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</metadata> </metadata>
<metadata name="groupBox2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="gridsize.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</metadata> </metadata>
<metadata name="groupBox2.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="groupBox2.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="groupBox2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="backscaley.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="backscalex.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="backscale.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="selectfile.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="showbackground.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="showbackground.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
@ -165,6 +186,9 @@
<metadata name="apply.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="apply.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="browsefile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>