2007-11-10 19:24:52 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using System.IO;
|
|
|
|
using CodeImp.DoomBuilder.Config;
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
2008-05-29 11:54:45 +00:00
|
|
|
using CodeImp.DoomBuilder.Controls;
|
2007-11-10 19:24:52 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2008-05-29 11:54:45 +00:00
|
|
|
namespace CodeImp.DoomBuilder.Windows
|
2007-11-10 19:24:52 +00:00
|
|
|
{
|
2008-01-02 21:49:43 +00:00
|
|
|
internal partial class GridSetupForm : DelayedForm
|
2007-11-10 19:24:52 +00:00
|
|
|
{
|
|
|
|
// Variables
|
|
|
|
private string backgroundname;
|
|
|
|
private int backgroundsource;
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public GridSetupForm()
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
// Show grid size
|
|
|
|
gridsize.Value = General.Map.Grid.GridSize;
|
|
|
|
|
|
|
|
// Background image?
|
|
|
|
if((General.Map.Grid.Background != null) &&
|
2009-01-24 14:48:43 +00:00
|
|
|
!(General.Map.Grid.Background is UnknownImage))
|
2007-11-10 19:24:52 +00:00
|
|
|
{
|
|
|
|
// Show background image
|
|
|
|
showbackground.Checked = true;
|
|
|
|
backgroundname = General.Map.Grid.BackgroundName;
|
|
|
|
backgroundsource = General.Map.Grid.BackgroundSource;
|
2009-01-24 14:48:43 +00:00
|
|
|
General.DisplayZoomedImage(backgroundimage, General.Map.Grid.Background.GetBitmap());
|
2007-11-10 19:24:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No background image
|
|
|
|
showbackground.Checked = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show background offset
|
|
|
|
backoffsetx.Value = General.Map.Grid.BackgroundX;
|
|
|
|
backoffsety.Value = General.Map.Grid.BackgroundY;
|
2008-10-15 19:14:32 +00:00
|
|
|
backscalex.Value = (int)(General.Map.Grid.BackgroundScaleX * 100.0f);
|
|
|
|
backscaley.Value = (int)(General.Map.Grid.BackgroundScaleY * 100.0f);
|
2007-11-10 19:24:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Show Background changed
|
|
|
|
private void showbackground_CheckedChanged(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
// Enable/disable controls
|
|
|
|
selecttexture.Enabled = showbackground.Checked;
|
|
|
|
selectflat.Enabled = showbackground.Checked;
|
2008-10-15 19:14:32 +00:00
|
|
|
selectfile.Enabled = showbackground.Checked;
|
2007-11-10 19:24:52 +00:00
|
|
|
backoffset.Enabled = showbackground.Checked;
|
2008-10-15 19:14:32 +00:00
|
|
|
backscale.Enabled = showbackground.Checked;
|
2007-11-10 19:24:52 +00:00
|
|
|
backoffsetx.Enabled = showbackground.Checked;
|
|
|
|
backoffsety.Enabled = showbackground.Checked;
|
2008-10-15 19:14:32 +00:00
|
|
|
backscalex.Enabled = showbackground.Checked;
|
|
|
|
backscaley.Enabled = showbackground.Checked;
|
2007-11-10 19:24:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Browse texture
|
|
|
|
private void selecttexture_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
string result;
|
|
|
|
|
|
|
|
// Browse for texture
|
|
|
|
result = TextureBrowserForm.Browse(this, backgroundname);
|
|
|
|
if(result != null)
|
|
|
|
{
|
|
|
|
// Set this texture as background
|
|
|
|
backgroundname = result;
|
|
|
|
backgroundsource = GridSetup.SOURCE_TEXTURES;
|
2008-10-15 19:14:32 +00:00
|
|
|
ImageData img = General.Map.Data.GetTextureImage(result);
|
|
|
|
img.LoadImage();
|
2009-01-24 14:48:43 +00:00
|
|
|
General.DisplayZoomedImage(backgroundimage, img.GetBitmap());
|
2007-11-10 19:24:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Browse flat
|
|
|
|
private void selectflat_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
string result;
|
|
|
|
|
|
|
|
// Browse for flat
|
|
|
|
result = FlatBrowserForm.Browse(this, backgroundname);
|
|
|
|
if(result != null)
|
|
|
|
{
|
|
|
|
// Set this flat as background
|
|
|
|
backgroundname = result;
|
|
|
|
backgroundsource = GridSetup.SOURCE_FLATS;
|
2008-10-15 19:14:32 +00:00
|
|
|
ImageData img = General.Map.Data.GetFlatImage(result);
|
|
|
|
img.LoadImage();
|
2009-01-24 14:48:43 +00:00
|
|
|
General.DisplayZoomedImage(backgroundimage, img.GetBitmap());
|
2008-10-15 19:14:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
2009-01-03 19:45:59 +00:00
|
|
|
ImageData img = new FileImage(backgroundname, backgroundname, false, 1.0f, 1.0f);
|
2008-10-15 19:14:32 +00:00
|
|
|
img.LoadImage();
|
2009-01-24 14:48:43 +00:00
|
|
|
General.DisplayZoomedImage(backgroundimage, new Bitmap(img.GetBitmap()));
|
2008-10-15 19:14:32 +00:00
|
|
|
img.Dispose();
|
2007-11-10 19:24:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cancelled
|
|
|
|
private void cancel_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
DialogResult = DialogResult.Cancel;
|
|
|
|
this.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply
|
|
|
|
private void apply_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
// Apply
|
|
|
|
General.Map.Grid.SetGridSize((int)gridsize.Value);
|
2008-10-15 19:14:32 +00:00
|
|
|
General.Map.Grid.SetBackgroundView((int)backoffsetx.Value, (int)backoffsety.Value,
|
|
|
|
(float)backscalex.Value / 100.0f, (float)backscaley.Value / 100.0f);
|
2007-11-10 19:24:52 +00:00
|
|
|
|
|
|
|
// Background image?
|
|
|
|
if(showbackground.Checked)
|
|
|
|
{
|
|
|
|
// Set background image
|
|
|
|
General.Map.Grid.SetBackground(backgroundname, backgroundsource);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No background image
|
|
|
|
General.Map.Grid.SetBackground(null, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Done
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
this.Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|