lots of changes/additions

This commit is contained in:
codeimp 2007-12-27 01:24:11 +00:00
parent 4cf0f18dbb
commit 679bb6980f
43 changed files with 818 additions and 145 deletions

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = true;
@ -339,7 +340,7 @@ gen_sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -290,7 +291,7 @@ sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -291,7 +292,7 @@ sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -18,6 +18,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -347,7 +348,7 @@ sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = true;
@ -346,7 +347,7 @@ gen_sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -315,7 +316,7 @@ sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "HexenMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -323,7 +324,7 @@ sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = true;
@ -323,7 +324,7 @@ gen_sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = true;
@ -356,7 +357,7 @@ gen_sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = true;
@ -358,7 +359,7 @@ gen_sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "HexenMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -350,7 +351,7 @@ sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -293,7 +294,7 @@ sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -291,7 +292,7 @@ sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// Engine specific features
mixtexturesflats = true;
@ -357,7 +358,7 @@ gen_sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "HexenMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -511,7 +512,7 @@ gen_sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "HexenMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -505,7 +506,7 @@ gen_sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "HexenMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -350,7 +351,7 @@ sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "HexenMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -510,7 +511,7 @@ gen_sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -15,6 +15,7 @@ formatinterface = "DoomMapSetIO";
soundlinedefflags = 64; // See linedefflags
singlesidedflags = 1; // See linedefflags
doublesidedflags = 4; // See linedefflags
impassableflags = 1;
// No generalized types
generalizedlinedefs = false;
@ -313,7 +314,7 @@ sectortypes
// LINEDEF FLAGS
linedefflags
{
1 = "Impassible";
1 = "Impassable";
2 = "Block Monster";
4 = "Double Sided";
8 = "Upper Unpegged";

View file

@ -107,6 +107,9 @@
<Compile Include="Interface\ActionSelectorControl.Designer.cs">
<DependentUpon>ActionSelectorControl.cs</DependentUpon>
</Compile>
<Compile Include="Interface\AutoSelectTextbox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Interface\CheckboxArrayControl.cs">
<SubType>UserControl</SubType>
</Compile>

View file

@ -49,6 +49,7 @@ namespace CodeImp.DoomBuilder.Config
private int soundlinedefflags;
private int singlesidedflags;
private int doublesidedflags;
private int impassableflags;
private bool mixtexturesflats;
// Map lumps
@ -80,6 +81,7 @@ namespace CodeImp.DoomBuilder.Config
public int SoundLinedefFlags { get { return soundlinedefflags; } }
public int SingleSidedFlags { get { return singlesidedflags; } }
public int DoubleSidedFlags { get { return doublesidedflags; } }
public int ImpassableFlags { get { return impassableflags; } }
public bool MixTexturesFlats { get { return mixtexturesflats; } }
// Map lumps
@ -124,6 +126,7 @@ namespace CodeImp.DoomBuilder.Config
soundlinedefflags = cfg.ReadSetting("soundlinedefflags", 0);
singlesidedflags = cfg.ReadSetting("singlesidedflags", 0);
doublesidedflags = cfg.ReadSetting("doublesidedflags", 0);
impassableflags = cfg.ReadSetting("impassableflags", 0);
mixtexturesflats = cfg.ReadSetting("mixtexturesflats", false);
// Get map lumps

View file

@ -50,9 +50,11 @@ namespace CodeImp.DoomBuilder.Data
// Textures
private Dictionary<long, ImageData> textures;
private List<string> texturenames;
// Flats
private Dictionary<long, ImageData> flats;
private List<string> flatnames;
// Sprites
private Dictionary<long, ImageData> sprites;
@ -70,6 +72,8 @@ namespace CodeImp.DoomBuilder.Data
public Playpal Palette { get { return palette; } }
public ICollection<ImageData> Textures { get { return textures.Values; } }
public ICollection<ImageData> Flats { get { return flats.Values; } }
public List<string> TextureNames { get { return texturenames; } }
public List<string> FlatNames { get { return flatnames; } }
public bool IsDisposed { get { return isdisposed; } }
public bool IsLoading { get { return (backgroundloader != null) && backgroundloader.IsAlive; } }
@ -127,6 +131,8 @@ namespace CodeImp.DoomBuilder.Data
textures = new Dictionary<long, ImageData>();
flats = new Dictionary<long, ImageData>();
sprites = new Dictionary<long, ImageData>();
texturenames = new List<string>();
flatnames = new List<string>();
// Go for all locations
foreach(DataLocation dl in locations)
@ -195,7 +201,7 @@ namespace CodeImp.DoomBuilder.Data
foreach(KeyValuePair<long, ImageData> i in flats) i.Value.Dispose();
foreach(KeyValuePair<long, ImageData> i in sprites) i.Value.Dispose();
palette = null;
// Dispose containers
foreach(DataReader c in containers) c.Dispose();
containers.Clear();
@ -402,12 +408,14 @@ namespace CodeImp.DoomBuilder.Data
foreach(ImageData img in images)
{
// Add or replace in textures list
if(!textures.ContainsKey(img.LongName)) texturenames.Add(img.Name);
textures.Remove(img.LongName);
textures.Add(img.LongName, img);
// Also add as flat when using mixed resources
if(General.Map.Config.MixTexturesFlats)
{
if(!flats.ContainsKey(img.LongName)) flatnames.Add(img.Name);
flats.Remove(img.LongName);
flats.Add(img.LongName, img);
}
@ -514,12 +522,14 @@ namespace CodeImp.DoomBuilder.Data
foreach(ImageData img in images)
{
// Add or replace in flats list
if(!flats.ContainsKey(img.LongName)) flatnames.Add(img.Name);
flats.Remove(img.LongName);
flats.Add(img.LongName, img);
// Also add as texture when using mixed resources
if(General.Map.Config.MixTexturesFlats)
{
if(!textures.ContainsKey(img.LongName)) texturenames.Add(img.Name);
textures.Remove(img.LongName);
textures.Add(img.LongName, img);
}

View file

@ -760,7 +760,8 @@ namespace CodeImp.DoomBuilder
Console.WriteLine(line);
// Write to log file
File.AppendAllText(logfile, line + Environment.NewLine);
try { File.AppendAllText(logfile, line + Environment.NewLine); }
catch(Exception) { }
}
// This outputs log information
@ -770,7 +771,8 @@ namespace CodeImp.DoomBuilder
Console.Write(text);
// Write to log file
File.AppendAllText(logfile, text);
try { File.AppendAllText(logfile, text); }
catch(Exception) { }
}
#endregion

View file

@ -28,7 +28,7 @@ namespace CodeImp.DoomBuilder.Interface
/// </summary>
private void InitializeComponent()
{
this.number = new System.Windows.Forms.TextBox();
this.number = new CodeImp.DoomBuilder.Interface.AutoSelectTextbox();
this.list = new System.Windows.Forms.ComboBox();
this.numberpanel = new System.Windows.Forms.Panel();
this.numberpanel.SuspendLayout();
@ -91,7 +91,7 @@ namespace CodeImp.DoomBuilder.Interface
#endregion
private System.Windows.Forms.TextBox number;
private CodeImp.DoomBuilder.Interface.AutoSelectTextbox number;
private System.Windows.Forms.ComboBox list;
private System.Windows.Forms.Panel numberpanel;
}

View file

@ -0,0 +1,94 @@
#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.Globalization;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.Interface
{
public class AutoSelectTextbox : TextBox
{
#region ================== Constants
#endregion
#region ================== Variables
private int eventcount = 0;
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Disposer
#endregion
#region ================== Methods
// When gaining focus
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
// Reset counter
eventcount = 0;
}
// When losing focus
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
// Reset counter
eventcount = 0;
}
// When mouse pressed down
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
// Select all text when this mouseclick gives focus
if(eventcount == 0) this.SelectAll();
eventcount++;
}
// When key is pressed
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
eventcount++;
}
#endregion
}
}

View file

@ -39,11 +39,18 @@ namespace CodeImp.DoomBuilder.Interface
{
public class FlatSelectorControl : ImageSelectorControl
{
// Setup
public void Initialize()
{
// Fill autocomplete list
name.AutoCompleteCustomSource.AddRange(General.Map.Data.FlatNames.ToArray());
}
// This finds the image we need for the given flat name
protected override Image FindImage(string name)
protected override Image FindImage(string imagename)
{
// Check if name is a "none" texture
if((name.Length < 1) || (name[0] == '-'))
if((imagename.Length < 1) || (imagename[0] == '-'))
{
// Flat required!
return CodeImp.DoomBuilder.Properties.Resources.MissingTexture;
@ -51,18 +58,18 @@ namespace CodeImp.DoomBuilder.Interface
else
{
// Set the image
return General.Map.Data.GetFlatBitmap(name);
return General.Map.Data.GetFlatBitmap(imagename);
}
}
// This browses for a flat
protected override string BrowseImage(string name)
protected override string BrowseImage(string imagename)
{
string result;
// Browse for texture
result = FlatBrowserForm.Browse(this.ParentForm, name);
if(result != null) return result; else return name;
result = FlatBrowserForm.Browse(this.ParentForm, imagename);
if(result != null) return result; else return imagename;
}
}
}

View file

@ -29,7 +29,7 @@ namespace CodeImp.DoomBuilder.Interface
private void InitializeComponent()
{
this.preview = new System.Windows.Forms.Panel();
this.name = new System.Windows.Forms.TextBox();
this.name = new CodeImp.DoomBuilder.Interface.AutoSelectTextbox();
this.SuspendLayout();
//
// preview
@ -45,6 +45,8 @@ namespace CodeImp.DoomBuilder.Interface
//
// name
//
this.name.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
this.name.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
this.name.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.name.Location = new System.Drawing.Point(0, 64);
this.name.Name = "name";
@ -67,7 +69,8 @@ namespace CodeImp.DoomBuilder.Interface
#endregion
private System.Windows.Forms.Panel preview;
private System.Windows.Forms.TextBox name;
protected System.Windows.Forms.Panel preview;
protected CodeImp.DoomBuilder.Interface.AutoSelectTextbox name;
}
}

View file

@ -38,9 +38,6 @@ namespace CodeImp.DoomBuilder.Interface
{
public abstract partial class ImageSelectorControl : UserControl
{
// Events
public event EventHandler ImageClicked;
// Properties
public string TextureName { get { return name.Text; } set { name.Text = value; } }
@ -50,7 +47,7 @@ namespace CodeImp.DoomBuilder.Interface
// Initialize
InitializeComponent();
}
// When resized
private void ImageSelectorControl_Resize(object sender, EventArgs e)
{
@ -71,9 +68,25 @@ namespace CodeImp.DoomBuilder.Interface
}
// This must determine and return the image to show
protected abstract Image FindImage(string name);
protected abstract Image FindImage(string imagename);
// This must show the image browser and return the selected texture name
protected abstract string BrowseImage(string name);
protected abstract string BrowseImage(string imagename);
// This determines the result value
public string GetResult(string original)
{
// Anyting entered?
if(name.Text.Trim().Length > 0)
{
// Return the new value
return name.Text;
}
else
{
// Nothing given, keep original value
return original;
}
}
}
}

View file

@ -38,6 +38,8 @@ namespace CodeImp.DoomBuilder.Interface
System.Windows.Forms.Label label8;
System.Windows.Forms.Label label9;
System.Windows.Forms.Label label10;
System.Windows.Forms.Label label11;
System.Windows.Forms.Label label12;
this.cancel = new System.Windows.Forms.Button();
this.apply = new System.Windows.Forms.Button();
this.actiongroup = new System.Windows.Forms.GroupBox();
@ -53,20 +55,20 @@ namespace CodeImp.DoomBuilder.Interface
this.tabPage2 = new System.Windows.Forms.TabPage();
this.backside = new System.Windows.Forms.CheckBox();
this.backgroup = new System.Windows.Forms.GroupBox();
this.backsector = new CodeImp.DoomBuilder.Interface.NumericTextbox();
this.backlow = new CodeImp.DoomBuilder.Interface.TextureSelectorControl();
this.backmid = new CodeImp.DoomBuilder.Interface.TextureSelectorControl();
this.backhigh = new CodeImp.DoomBuilder.Interface.TextureSelectorControl();
this.backoffsety = new CodeImp.DoomBuilder.Interface.NumericTextbox();
this.backoffsetx = new CodeImp.DoomBuilder.Interface.NumericTextbox();
this.backsector = new System.Windows.Forms.Button();
this.frontside = new System.Windows.Forms.CheckBox();
this.frontgroup = new System.Windows.Forms.GroupBox();
this.frontsector = new CodeImp.DoomBuilder.Interface.NumericTextbox();
this.frontlow = new CodeImp.DoomBuilder.Interface.TextureSelectorControl();
this.frontmid = new CodeImp.DoomBuilder.Interface.TextureSelectorControl();
this.fronthigh = new CodeImp.DoomBuilder.Interface.TextureSelectorControl();
this.frontoffsety = new CodeImp.DoomBuilder.Interface.NumericTextbox();
this.frontoffsetx = new CodeImp.DoomBuilder.Interface.NumericTextbox();
this.frontsector = new System.Windows.Forms.Button();
label2 = new System.Windows.Forms.Label();
label1 = new System.Windows.Forms.Label();
label3 = new System.Windows.Forms.Label();
@ -77,6 +79,8 @@ namespace CodeImp.DoomBuilder.Interface
label8 = new System.Windows.Forms.Label();
label9 = new System.Windows.Forms.Label();
label10 = new System.Windows.Forms.Label();
label11 = new System.Windows.Forms.Label();
label12 = new System.Windows.Forms.Label();
this.actiongroup.SuspendLayout();
this.settingsgroup.SuspendLayout();
this.tabs.SuspendLayout();
@ -134,7 +138,7 @@ namespace CodeImp.DoomBuilder.Interface
// label6
//
label6.AutoSize = true;
label6.Location = new System.Drawing.Point(16, 104);
label6.Location = new System.Drawing.Point(16, 79);
label6.Name = "label6";
label6.Size = new System.Drawing.Size(81, 14);
label6.TabIndex = 7;
@ -143,7 +147,7 @@ namespace CodeImp.DoomBuilder.Interface
// label7
//
label7.AutoSize = true;
label7.Location = new System.Drawing.Point(16, 104);
label7.Location = new System.Drawing.Point(16, 79);
label7.Name = "label7";
label7.Size = new System.Drawing.Size(81, 14);
label7.TabIndex = 7;
@ -176,6 +180,24 @@ namespace CodeImp.DoomBuilder.Interface
label10.Text = "Upper";
label10.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// label11
//
label11.AutoSize = true;
label11.Location = new System.Drawing.Point(26, 40);
label11.Name = "label11";
label11.Size = new System.Drawing.Size(71, 14);
label11.TabIndex = 13;
label11.Text = "Sector Index:";
//
// label12
//
label12.AutoSize = true;
label12.Location = new System.Drawing.Point(26, 40);
label12.Name = "label12";
label12.Size = new System.Drawing.Size(71, 14);
label12.TabIndex = 16;
label12.Text = "Sector Index:";
//
// cancel
//
this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@ -186,6 +208,7 @@ namespace CodeImp.DoomBuilder.Interface
this.cancel.TabIndex = 17;
this.cancel.Text = "Cancel";
this.cancel.UseVisualStyleBackColor = true;
this.cancel.Click += new System.EventHandler(this.cancel_Click);
//
// apply
//
@ -196,6 +219,7 @@ namespace CodeImp.DoomBuilder.Interface
this.apply.TabIndex = 16;
this.apply.Text = "OK";
this.apply.UseVisualStyleBackColor = true;
this.apply.Click += new System.EventHandler(this.apply_Click);
//
// actiongroup
//
@ -222,9 +246,12 @@ namespace CodeImp.DoomBuilder.Interface
this.newtag.TabIndex = 8;
this.newtag.Text = "New Tag";
this.newtag.UseVisualStyleBackColor = true;
this.newtag.Click += new System.EventHandler(this.newtag_Click);
//
// tag
//
this.tag.AllowNegative = false;
this.tag.AllowRelative = true;
this.tag.Location = new System.Drawing.Point(62, 75);
this.tag.Name = "tag";
this.tag.Size = new System.Drawing.Size(68, 20);
@ -336,19 +363,22 @@ namespace CodeImp.DoomBuilder.Interface
this.backside.TabIndex = 2;
this.backside.Text = "Back Side";
this.backside.UseVisualStyleBackColor = true;
this.backside.CheckStateChanged += new System.EventHandler(this.backside_CheckStateChanged);
//
// backgroup
//
this.backgroup.Controls.Add(this.backsector);
this.backgroup.Controls.Add(label12);
this.backgroup.Controls.Add(this.backlow);
this.backgroup.Controls.Add(this.backmid);
this.backgroup.Controls.Add(this.backhigh);
this.backgroup.Controls.Add(this.backoffsety);
this.backgroup.Controls.Add(this.backoffsetx);
this.backgroup.Controls.Add(label7);
this.backgroup.Controls.Add(this.backsector);
this.backgroup.Controls.Add(label8);
this.backgroup.Controls.Add(label9);
this.backgroup.Controls.Add(label10);
this.backgroup.Enabled = false;
this.backgroup.Location = new System.Drawing.Point(8, 157);
this.backgroup.Name = "backgroup";
this.backgroup.Size = new System.Drawing.Size(499, 140);
@ -356,6 +386,16 @@ namespace CodeImp.DoomBuilder.Interface
this.backgroup.TabStop = false;
this.backgroup.Text = " ";
//
// backsector
//
this.backsector.AllowNegative = false;
this.backsector.AllowRelative = false;
this.backsector.Location = new System.Drawing.Point(103, 37);
this.backsector.Name = "backsector";
this.backsector.Size = new System.Drawing.Size(94, 20);
this.backsector.TabIndex = 17;
this.backsector.Enter += new System.EventHandler(this.SelectAllText);
//
// backlow
//
this.backlow.Location = new System.Drawing.Point(416, 37);
@ -385,26 +425,23 @@ namespace CodeImp.DoomBuilder.Interface
//
// backoffsety
//
this.backoffsety.Location = new System.Drawing.Point(154, 101);
this.backoffsety.AllowNegative = true;
this.backoffsety.AllowRelative = true;
this.backoffsety.Location = new System.Drawing.Point(152, 76);
this.backoffsety.Name = "backoffsety";
this.backoffsety.Size = new System.Drawing.Size(45, 20);
this.backoffsety.TabIndex = 9;
this.backoffsety.Enter += new System.EventHandler(this.SelectAllText);
//
// backoffsetx
//
this.backoffsetx.Location = new System.Drawing.Point(103, 101);
this.backoffsetx.AllowNegative = true;
this.backoffsetx.AllowRelative = true;
this.backoffsetx.Location = new System.Drawing.Point(103, 76);
this.backoffsetx.Name = "backoffsetx";
this.backoffsetx.Size = new System.Drawing.Size(45, 20);
this.backoffsetx.TabIndex = 8;
//
// backsector
//
this.backsector.Location = new System.Drawing.Point(103, 37);
this.backsector.Name = "backsector";
this.backsector.Size = new System.Drawing.Size(96, 24);
this.backsector.TabIndex = 6;
this.backsector.Text = "Select Sector";
this.backsector.UseVisualStyleBackColor = true;
this.backoffsetx.Enter += new System.EventHandler(this.SelectAllText);
//
// frontside
//
@ -415,19 +452,22 @@ namespace CodeImp.DoomBuilder.Interface
this.frontside.TabIndex = 0;
this.frontside.Text = "Front Side";
this.frontside.UseVisualStyleBackColor = true;
this.frontside.CheckStateChanged += new System.EventHandler(this.frontside_CheckStateChanged);
//
// frontgroup
//
this.frontgroup.Controls.Add(this.frontsector);
this.frontgroup.Controls.Add(label11);
this.frontgroup.Controls.Add(this.frontlow);
this.frontgroup.Controls.Add(this.frontmid);
this.frontgroup.Controls.Add(this.fronthigh);
this.frontgroup.Controls.Add(this.frontoffsety);
this.frontgroup.Controls.Add(this.frontoffsetx);
this.frontgroup.Controls.Add(label6);
this.frontgroup.Controls.Add(this.frontsector);
this.frontgroup.Controls.Add(label5);
this.frontgroup.Controls.Add(label4);
this.frontgroup.Controls.Add(label3);
this.frontgroup.Enabled = false;
this.frontgroup.Location = new System.Drawing.Point(8, 8);
this.frontgroup.Name = "frontgroup";
this.frontgroup.Size = new System.Drawing.Size(499, 140);
@ -435,6 +475,16 @@ namespace CodeImp.DoomBuilder.Interface
this.frontgroup.TabStop = false;
this.frontgroup.Text = " ";
//
// frontsector
//
this.frontsector.AllowNegative = false;
this.frontsector.AllowRelative = false;
this.frontsector.Location = new System.Drawing.Point(103, 37);
this.frontsector.Name = "frontsector";
this.frontsector.Size = new System.Drawing.Size(94, 20);
this.frontsector.TabIndex = 14;
this.frontsector.Enter += new System.EventHandler(this.SelectAllText);
//
// frontlow
//
this.frontlow.Location = new System.Drawing.Point(416, 37);
@ -464,26 +514,23 @@ namespace CodeImp.DoomBuilder.Interface
//
// frontoffsety
//
this.frontoffsety.Location = new System.Drawing.Point(154, 101);
this.frontoffsety.AllowNegative = true;
this.frontoffsety.AllowRelative = true;
this.frontoffsety.Location = new System.Drawing.Point(152, 76);
this.frontoffsety.Name = "frontoffsety";
this.frontoffsety.Size = new System.Drawing.Size(45, 20);
this.frontoffsety.TabIndex = 9;
this.frontoffsety.Enter += new System.EventHandler(this.SelectAllText);
//
// frontoffsetx
//
this.frontoffsetx.Location = new System.Drawing.Point(103, 101);
this.frontoffsetx.AllowNegative = true;
this.frontoffsetx.AllowRelative = true;
this.frontoffsetx.Location = new System.Drawing.Point(103, 76);
this.frontoffsetx.Name = "frontoffsetx";
this.frontoffsetx.Size = new System.Drawing.Size(45, 20);
this.frontoffsetx.TabIndex = 8;
//
// frontsector
//
this.frontsector.Location = new System.Drawing.Point(103, 37);
this.frontsector.Name = "frontsector";
this.frontsector.Size = new System.Drawing.Size(96, 24);
this.frontsector.TabIndex = 6;
this.frontsector.Text = "Select Sector";
this.frontsector.UseVisualStyleBackColor = true;
this.frontoffsetx.Enter += new System.EventHandler(this.SelectAllText);
//
// LinedefEditForm
//
@ -535,19 +582,19 @@ namespace CodeImp.DoomBuilder.Interface
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.GroupBox frontgroup;
private System.Windows.Forms.CheckBox frontside;
private System.Windows.Forms.Button frontsector;
private NumericTextbox frontoffsety;
private NumericTextbox frontoffsetx;
private System.Windows.Forms.CheckBox backside;
private System.Windows.Forms.GroupBox backgroup;
private NumericTextbox backoffsety;
private NumericTextbox backoffsetx;
private System.Windows.Forms.Button backsector;
private TextureSelectorControl frontlow;
private TextureSelectorControl frontmid;
private TextureSelectorControl fronthigh;
private TextureSelectorControl backlow;
private TextureSelectorControl backmid;
private TextureSelectorControl backhigh;
private NumericTextbox backsector;
private NumericTextbox frontsector;
}
}

View file

@ -27,6 +27,7 @@ using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.IO;
using System.IO;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Editing;
#endregion
@ -48,39 +49,245 @@ namespace CodeImp.DoomBuilder.Interface
// Fill linedef actions list
action.AddInfo(General.Map.Config.SortedLinedefActions.ToArray());
// Initialize image selectors
fronthigh.Initialize();
frontmid.Initialize();
frontlow.Initialize();
backhigh.Initialize();
backmid.Initialize();
backlow.Initialize();
}
// This sets up the form to edit the given lines
public void Setup(ICollection<Linedef> lines)
{
Linedef fl;
// Keep this list
this.lines = lines;
// Go for all flags
////////////////////////////////////////////////////////////////////////
// Set all options to the first linedef properties
////////////////////////////////////////////////////////////////////////
// Get first line
fl = General.GetByIndex<Linedef>(lines, 0);
// Flags
foreach(CheckBox c in flags.Checkboxes)
c.Checked = (fl.Flags & (int)c.Tag) != 0;
// Action/activation/tags
action.Value = fl.Action;
tag.Text = fl.Tag.ToString();
// Front side and back side checkboxes
frontside.Checked = (fl.Front != null);
backside.Checked = (fl.Back != null);
// Front settings
if(fl.Front != null)
{
// Set the option with the first line's setting
c.Checked = (General.GetByIndex<Linedef>(lines, 0).Flags & (int)c.Tag) != 0;
// Go for all lines
foreach(Linedef l in lines)
{
// Make the option gray if it is different
if(((l.Flags & (int)c.Tag) != 0) != c.Checked)
c.CheckState = CheckState.Indeterminate;
}
fronthigh.TextureName = fl.Front.HighTexture;
frontmid.TextureName = fl.Front.MiddleTexture;
frontlow.TextureName = fl.Front.LowTexture;
frontsector.Text = fl.Front.Sector.Index.ToString();
frontoffsetx.Text = fl.Front.OffsetX.ToString();
frontoffsety.Text = fl.Front.OffsetY.ToString();
}
// Set the action to the first line's action
action.Value = General.GetByIndex<Linedef>(lines, 0).Action;
// Back settings
if(fl.Back != null)
{
backhigh.TextureName = fl.Back.HighTexture;
backmid.TextureName = fl.Back.MiddleTexture;
backlow.TextureName = fl.Back.LowTexture;
backsector.Text = fl.Back.Sector.Index.ToString();
backoffsetx.Text = fl.Back.OffsetX.ToString();
backoffsety.Text = fl.Back.OffsetY.ToString();
}
////////////////////////////////////////////////////////////////////////
// Now go for all lines and change the options when a setting is different
////////////////////////////////////////////////////////////////////////
// Go for all lines
foreach(Linedef l in lines)
{
// Erase the option if it is different
if(l.Action != action.Value)
action.Empty = true;
// Flags
foreach(CheckBox c in flags.Checkboxes)
{
if(((l.Flags & (int)c.Tag) != 0) != c.Checked)
{
c.ThreeState = true;
c.CheckState = CheckState.Indeterminate;
}
}
// Action/activation/tags
if(l.Action != action.Value) action.Empty = true;
if(l.Tag.ToString() != tag.Text) tag.Text = "";
// Front side checkbox
if((l.Front != null) != frontside.Checked)
{
frontside.ThreeState = true;
frontside.CheckState = CheckState.Indeterminate;
frontside.AutoCheck = false;
}
// Back side checkbox
if((l.Back != null) != backside.Checked)
{
backside.ThreeState = true;
backside.CheckState = CheckState.Indeterminate;
backside.AutoCheck = false;
}
// Front settings
if(l.Front != null)
{
if(fronthigh.TextureName != l.Front.HighTexture) fronthigh.TextureName = "";
if(frontmid.TextureName != l.Front.MiddleTexture) frontmid.TextureName = "";
if(frontlow.TextureName != l.Front.LowTexture) frontlow.TextureName = "";
if(frontsector.Text != l.Front.Sector.Index.ToString()) frontsector.Text = "";
if(frontoffsetx.Text != l.Front.OffsetX.ToString()) frontoffsetx.Text = "";
if(frontoffsety.Text != l.Front.OffsetY.ToString()) frontoffsety.Text = "";
}
// Back settings
if(l.Back != null)
{
if(backhigh.TextureName != l.Back.HighTexture) backhigh.TextureName = "";
if(backmid.TextureName != l.Back.MiddleTexture) backmid.TextureName = "";
if(backlow.TextureName != l.Back.LowTexture) backlow.TextureName = "";
if(backsector.Text != l.Back.Sector.Index.ToString()) backsector.Text = "";
if(backoffsetx.Text != l.Back.OffsetX.ToString()) backoffsetx.Text = "";
if(backoffsety.Text != l.Back.OffsetY.ToString()) backoffsety.Text = "";
}
}
}
// Front side (un)checked
private void frontside_CheckStateChanged(object sender, EventArgs e)
{
// Enable/disable panel
// NOTE: Also enabled when checkbox is grayed!
frontgroup.Enabled = (frontside.CheckState != CheckState.Unchecked);
}
// Back side (un)checked
private void backside_CheckStateChanged(object sender, EventArgs e)
{
// Enable/disable panel
// NOTE: Also enabled when checkbox is grayed!
backgroup.Enabled = (backside.CheckState != CheckState.Unchecked);
}
// This selects all text in a textbox
private void SelectAllText(object sender, EventArgs e)
{
(sender as TextBox).SelectAll();
}
// Apply clicked
private void apply_Click(object sender, EventArgs e)
{
string undodesc = "linedef";
Sector s;
int index;
// Make undo
if(lines.Count > 1) undodesc = lines.Count + " linedefs";
General.Map.UndoRedo.CreateUndo("edit " + undodesc, UndoGroup.None, 0, false);
// Go for all the lines
foreach(Linedef l in lines)
{
// Apply all flags
foreach(CheckBox c in flags.Checkboxes)
{
if(c.CheckState == CheckState.Checked) l.Flags |= (int)c.Tag;
else if(c.CheckState == CheckState.Unchecked) l.Flags &= ~(int)c.Tag;
}
// Action/activation/tags
if(!action.Empty) l.Action = action.Value;
l.Tag = tag.GetResult(l.Tag);
// Remove front side?
if((l.Front != null) && (frontside.CheckState == CheckState.Unchecked))
{
l.Front.Dispose();
}
// Create or modify front side?
if(frontside.CheckState == CheckState.Checked)
{
// Make sure we have a valid sector (make a new one if needed)
if(l.Front != null) index = l.Front.Sector.Index; else index = -1;
s = General.Map.Map.GetSectorByIndex(frontsector.GetResult(index));
if(s == null) s = General.Map.Map.CreateSector();
// Create new sidedef?
if(l.Front == null) General.Map.Map.CreateSidedef(l, true, s);
// Change sector?
if(l.Front.Sector != s) l.Front.ChangeSector(s);
// Apply settings
l.Front.OffsetX = frontoffsetx.GetResult(l.Front.OffsetX);
l.Front.OffsetY = frontoffsety.GetResult(l.Front.OffsetY);
l.Front.SetTextureHigh(fronthigh.GetResult(l.Front.HighTexture));
l.Front.SetTextureMid(frontmid.GetResult(l.Front.MiddleTexture));
l.Front.SetTextureLow(frontlow.GetResult(l.Front.LowTexture));
}
// Remove back side?
if((l.Back != null) && (backside.CheckState == CheckState.Unchecked))
{
l.Back.Dispose();
}
// Create or modify back side?
if(backside.CheckState == CheckState.Checked)
{
// Make sure we have a valid sector (make a new one if needed)
if(l.Back != null) index = l.Back.Sector.Index; else index = -1;
s = General.Map.Map.GetSectorByIndex(backsector.GetResult(index));
if(s == null) s = General.Map.Map.CreateSector();
// Create new sidedef?
if(l.Back == null) General.Map.Map.CreateSidedef(l, false, s);
// Change sector?
if(l.Back.Sector != s) l.Back.ChangeSector(s);
// Apply settings
l.Back.OffsetX = backoffsetx.GetResult(l.Back.OffsetX);
l.Back.OffsetY = backoffsety.GetResult(l.Back.OffsetY);
l.Back.SetTextureHigh(backhigh.GetResult(l.Back.HighTexture));
l.Back.SetTextureMid(backmid.GetResult(l.Back.MiddleTexture));
l.Back.SetTextureLow(backlow.GetResult(l.Back.LowTexture));
}
}
// Done
this.DialogResult = DialogResult.OK;
this.Close();
}
// Cancel clicked
private void cancel_Click(object sender, EventArgs e)
{
// Be gone
this.DialogResult = DialogResult.Cancel;
this.Close();
}
// This finds a new (unused) tag
private void newtag_Click(object sender, EventArgs e)
{
tag.Text = General.Map.Map.GetNewTag().ToString();
}
}
}

View file

@ -177,6 +177,18 @@
<metadata name="label10.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label11.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label11.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label12.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label12.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="cancel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -222,6 +234,9 @@
<metadata name="backgroup.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="backsector.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="backlow.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -237,15 +252,15 @@
<metadata name="backoffsetx.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="backsector.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="frontside.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="frontgroup.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="frontsector.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="frontlow.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -261,9 +276,6 @@
<metadata name="frontoffsetx.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="frontsector.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

View file

@ -189,10 +189,10 @@ namespace CodeImp.DoomBuilder.Interface
//
// action
//
this.action.AutoSize = true;
this.action.AutoEllipsis = true;
this.action.Location = new System.Drawing.Point(55, 19);
this.action.Name = "action";
this.action.Size = new System.Drawing.Size(190, 14);
this.action.Size = new System.Drawing.Size(197, 14);
this.action.TabIndex = 1;
this.action.Text = "0 - Big Door that goes Wobbly Wobbly";
//

View file

@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Editing;
namespace CodeImp.DoomBuilder.Interface
{
internal class NumericTextbox : TextBox
internal class NumericTextbox : AutoSelectTextbox
{
#region ================== Constants
@ -40,10 +40,16 @@ namespace CodeImp.DoomBuilder.Interface
#region ================== Variables
private bool allownegative = false; // Allow negative numbers
private bool allowrelative = false; // Allow ++ and -- prefix for relative changes
#endregion
#region ================== Properties
public bool AllowNegative { get { return allownegative; } set { allownegative = value; } }
public bool AllowRelative { get { return allowrelative; } set { allowrelative = value; } }
#endregion
#region ================== Constructor / Disposer
@ -55,17 +61,142 @@ namespace CodeImp.DoomBuilder.Interface
// When a key is pressed
protected override void OnKeyPress(KeyPressEventArgs e)
{
// Not numeric or control key?
if("-+0123456789\b".IndexOf(e.KeyChar) == -1)
string allowedchars = "0123456789\b";
string nonselectedtext;
string textpart;
int selectionpos;
int numprefixes;
char otherprefix;
// Determine allowed chars
if(allownegative) allowedchars += "-";
if(allowrelative) allowedchars += "+-";
// Check if key is not allowed
if(allowedchars.IndexOf(e.KeyChar) == -1)
{
// Cancel this
e.Handled = true;
}
else
{
// Check if + or - is pressed
if((e.KeyChar == '+') || (e.KeyChar == '-'))
{
// Determine non-selected text
if(this.SelectionLength > 0)
{
nonselectedtext = this.Text.Substring(0, this.SelectionStart) +
this.Text.Substring(this.SelectionStart + this.SelectionLength);
}
else if(this.SelectionLength < 0)
{
nonselectedtext = this.Text.Substring(0, this.SelectionStart + this.SelectionLength) +
this.Text.Substring(this.SelectionStart);
}
else
{
nonselectedtext = this.Text;
}
// Not at the start?
selectionpos = this.SelectionStart - 1;
if(this.SelectionLength < 0) selectionpos = (this.SelectionStart + this.SelectionLength) - 1;
if(selectionpos > -1)
{
// Find any other characters before the insert position
textpart = this.Text.Substring(0, selectionpos + 1);
textpart = textpart.Replace("+", "");
textpart = textpart.Replace("-", "");
if(textpart.Length > 0)
{
// Cancel this
e.Handled = true;
}
}
// Determine other prefix
if(e.KeyChar == '+') otherprefix = '-'; else otherprefix = '+';
// Limit the number of + and - allowed
numprefixes = nonselectedtext.Split(e.KeyChar, otherprefix).Length;
if(numprefixes > 2)
{
// Can't have more than 2 prefixes
e.Handled = true;
}
else if(numprefixes > 1)
{
// Must have 2 the same prefixes
if(this.Text.IndexOf(e.KeyChar) == -1) e.Handled = true;
// Double prefix must be allowed
if(!allowrelative) e.Handled = true;
}
}
}
// Call base
base.OnKeyPress(e);
}
// Validate contents
protected override void OnValidating(CancelEventArgs e)
{
string textpart = this.Text;
// Strip prefixes
textpart = textpart.Replace("+", "");
textpart = textpart.Replace("-", "");
// No numbers left?
if(textpart.Length == 0)
{
// Make the textbox empty
this.Text = "";
}
// Call base
base.OnValidating(e);
}
// This determines the result value
public int GetResult(int original)
{
string textpart = this.Text;
// Strip prefixes
textpart = textpart.Replace("+", "");
textpart = textpart.Replace("-", "");
// Any numbers left?
if(textpart.Length > 0)
{
// Prefixed with ++?
if(this.Text.StartsWith("++"))
{
// Add number to original
return original + int.Parse(textpart);
}
// Prefixed with --?
else if(this.Text.StartsWith("--"))
{
// Subtract number from original
return original - int.Parse(textpart);
}
else
{
// Return the new value
return int.Parse(this.Text);
}
}
else
{
// Nothing given, keep original value
return original;
}
}
#endregion
}
}

View file

@ -28,13 +28,13 @@ namespace CodeImp.DoomBuilder.Interface
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.GroupBox groupBox1;
System.Windows.Forms.Label label13;
System.Windows.Forms.Label label5;
System.Windows.Forms.Label label4;
System.Windows.Forms.Label label3;
System.Windows.Forms.Label label2;
System.Windows.Forms.Label label1;
this.sectorinfo = new System.Windows.Forms.GroupBox();
this.brightness = new System.Windows.Forms.Label();
this.height = new System.Windows.Forms.Label();
this.tag = new System.Windows.Forms.Label();
@ -47,40 +47,39 @@ namespace CodeImp.DoomBuilder.Interface
this.floorpanel = new System.Windows.Forms.GroupBox();
this.floorname = new System.Windows.Forms.Label();
this.floortex = new System.Windows.Forms.Panel();
groupBox1 = new System.Windows.Forms.GroupBox();
label13 = new System.Windows.Forms.Label();
label5 = new System.Windows.Forms.Label();
label4 = new System.Windows.Forms.Label();
label3 = new System.Windows.Forms.Label();
label2 = new System.Windows.Forms.Label();
label1 = new System.Windows.Forms.Label();
groupBox1.SuspendLayout();
this.sectorinfo.SuspendLayout();
this.ceilingpanel.SuspendLayout();
this.floorpanel.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
// sectorinfo
//
groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.sectorinfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
groupBox1.Controls.Add(this.brightness);
groupBox1.Controls.Add(label13);
groupBox1.Controls.Add(this.height);
groupBox1.Controls.Add(label5);
groupBox1.Controls.Add(this.tag);
groupBox1.Controls.Add(this.floor);
groupBox1.Controls.Add(this.ceiling);
groupBox1.Controls.Add(label4);
groupBox1.Controls.Add(label3);
groupBox1.Controls.Add(label2);
groupBox1.Controls.Add(this.effect);
groupBox1.Controls.Add(label1);
groupBox1.Location = new System.Drawing.Point(0, 0);
groupBox1.Name = "groupBox1";
groupBox1.Size = new System.Drawing.Size(230, 100);
groupBox1.TabIndex = 2;
groupBox1.TabStop = false;
groupBox1.Text = " Sector ";
this.sectorinfo.Controls.Add(this.brightness);
this.sectorinfo.Controls.Add(label13);
this.sectorinfo.Controls.Add(this.height);
this.sectorinfo.Controls.Add(label5);
this.sectorinfo.Controls.Add(this.tag);
this.sectorinfo.Controls.Add(this.floor);
this.sectorinfo.Controls.Add(this.ceiling);
this.sectorinfo.Controls.Add(label4);
this.sectorinfo.Controls.Add(label3);
this.sectorinfo.Controls.Add(label2);
this.sectorinfo.Controls.Add(this.effect);
this.sectorinfo.Controls.Add(label1);
this.sectorinfo.Location = new System.Drawing.Point(0, 0);
this.sectorinfo.Name = "sectorinfo";
this.sectorinfo.Size = new System.Drawing.Size(230, 100);
this.sectorinfo.TabIndex = 2;
this.sectorinfo.TabStop = false;
this.sectorinfo.Text = " Sector ";
//
// brightness
//
@ -259,14 +258,14 @@ namespace CodeImp.DoomBuilder.Interface
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.floorpanel);
this.Controls.Add(this.ceilingpanel);
this.Controls.Add(groupBox1);
this.Controls.Add(this.sectorinfo);
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.MaximumSize = new System.Drawing.Size(10000, 100);
this.MinimumSize = new System.Drawing.Size(100, 100);
this.Name = "SectorInfoPanel";
this.Size = new System.Drawing.Size(450, 100);
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
this.sectorinfo.ResumeLayout(false);
this.sectorinfo.PerformLayout();
this.ceilingpanel.ResumeLayout(false);
this.floorpanel.ResumeLayout(false);
this.ResumeLayout(false);
@ -287,5 +286,6 @@ namespace CodeImp.DoomBuilder.Interface
private System.Windows.Forms.GroupBox floorpanel;
private System.Windows.Forms.Label floorname;
private System.Windows.Forms.Panel floortex;
private System.Windows.Forms.GroupBox sectorinfo;
}
}

View file

@ -48,6 +48,7 @@ namespace CodeImp.DoomBuilder.Interface
// TODO: Lookup effect description in config
// Sector info
sectorinfo.Text = " Sector " + s.Index.ToString() + " ";
effect.Text = s.Effect.ToString();
ceiling.Text = s.CeilHeight.ToString();
floor.Text = s.FloorHeight.ToString();

View file

@ -117,10 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</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="sectorinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="brightness.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@ -186,6 +183,12 @@
<metadata name="ceilingtex.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ceilingname.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ceilingtex.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="floorpanel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -195,6 +198,12 @@
<metadata name="floortex.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="floorname.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="floortex.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

View file

@ -45,11 +45,18 @@ namespace CodeImp.DoomBuilder.Interface
// Properties
public bool Required { get { return required; } set { required = value; } }
// Setup
public void Initialize()
{
// Fill autocomplete list
name.AutoCompleteCustomSource.AddRange(General.Map.Data.TextureNames.ToArray());
}
// This finds the image we need for the given texture name
protected override Image FindImage(string name)
protected override Image FindImage(string imagename)
{
// Check if name is a "none" texture
if((name.Length < 1) || (name[0] == '-'))
if((imagename.Length < 1) || (imagename[0] == '-'))
{
// Determine image to show
if(required)
@ -60,18 +67,18 @@ namespace CodeImp.DoomBuilder.Interface
else
{
// Set the image
return General.Map.Data.GetTextureBitmap(name);
return General.Map.Data.GetTextureBitmap(imagename);
}
}
// This browses for a texture
protected override string BrowseImage(string name)
protected override string BrowseImage(string imagename)
{
string result;
// Browse for texture
result = TextureBrowserForm.Browse(this.ParentForm, name);
if(result != null) return result; else return name;
result = TextureBrowserForm.Browse(this.ParentForm, imagename);
if(result != null) return result; else return imagename;
}
}
}

View file

@ -87,9 +87,9 @@ namespace CodeImp.DoomBuilder.Map
public Sidedef Front { get { return front; } }
public Sidedef Back { get { return back; } }
public bool IsDisposed { get { return isdisposed; } }
public int Flags { get { return flags; } }
public int Action { get { return action; } }
public int Tag { get { return tag; } }
public int Flags { get { return flags; } set { flags = value; } }
public int Action { get { return action; } set { action = value; } }
public int Tag { get { return tag; } set { tag = value; if((tag < 0) || (tag > MapSet.HIGHEST_TAG)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } }
public bool Selected { get { return selected; } set { selected = value; } }
public float LengthSq { get { return lengthsq; } }
public float Length { get { return length; } }

View file

@ -34,8 +34,19 @@ namespace CodeImp.DoomBuilder.Map
{
public sealed class MapSet : IDisposable
{
#region ================== Constants
// Highest tag
public const int HIGHEST_TAG = 65534;
#endregion
#region ================== Variables
// Sector indexing
private List<int> indexholes;
private int lastsectorindex;
// Map structures
private LinkedList<Vertex> vertices;
private LinkedList<Linedef> linedefs;
@ -70,7 +81,9 @@ namespace CodeImp.DoomBuilder.Map
sidedefs = new LinkedList<Sidedef>();
sectors = new LinkedList<Sector>();
things = new LinkedList<Thing>();
indexholes = new List<int>();
lastsectorindex = 0;
// We have no destructor
GC.SuppressFinalize(this);
}
@ -112,6 +125,7 @@ namespace CodeImp.DoomBuilder.Map
sidedefs = null;
sectors = null;
things = null;
indexholes = null;
// Done
isdisposed = true;
@ -259,6 +273,28 @@ namespace CodeImp.DoomBuilder.Map
// This creates a new sector
public Sector CreateSector()
{
int index;
// Do we have any index holes we can use?
if(indexholes.Count > 0)
{
// Take one of the index holes
index = indexholes[indexholes.Count - 1];
indexholes.RemoveAt(indexholes.Count - 1);
}
else
{
// Make a new index
index = lastsectorindex++;
}
// Make the sector
return CreateSector(index);
}
// This creates a new sector
public Sector CreateSector(int index)
{
LinkedListNode<Sector> listitem;
Sector s;
@ -267,7 +303,7 @@ namespace CodeImp.DoomBuilder.Map
listitem = new LinkedListNode<Sector>(null);
// Make the sector
s = new Sector(this, listitem);
s = new Sector(this, listitem, index);
listitem.Value = s;
// Add sector to the list
@ -297,6 +333,12 @@ namespace CodeImp.DoomBuilder.Map
return t;
}
// This adds a sector index hole
public void AddSectorIndexHole(int index)
{
indexholes.Add(index);
}
#endregion
#region ================== Updating
@ -960,6 +1002,45 @@ namespace CodeImp.DoomBuilder.Map
#region ================== Tools
// This returns the next unused tag number
public int GetNewTag()
{
bool[] usedtags = new bool[HIGHEST_TAG+1];
usedtags.Initialize();
// Check all sectors
foreach(Sector s in sectors) usedtags[s.Tag] = true;
// Check all lines
foreach(Linedef l in linedefs) usedtags[l.Tag] = true;
// Check all things
foreach(Thing t in things) usedtags[t.Tag] = true;
// Now find the first unused index
for(int i = 1; i <= HIGHEST_TAG; i++)
if(usedtags[i] == false) return i;
// Problem: all tags used!
// Lets ignore this problem for now, who needs 65-thousand tags?!
return 0;
}
// This returns the sector with the given index or null when the index is not in use
// TODO: Speed this up by keeping sector references with indices in a dictionary?
public Sector GetSectorByIndex(int index)
{
// Go for all sectors
foreach(Sector s in sectors)
{
// Return sector when index matches
if(s.Index == index) return s;
}
// Nothing found
return null;
}
// This makes a list of lines related to vertex selection
// A line is unstable when one vertex is selected and the other isn't.
public ICollection<Linedef> LinedefsFromSelectedVertices(bool includeunselected, bool includestable, bool includeunstable)

View file

@ -48,6 +48,7 @@ namespace CodeImp.DoomBuilder.Map
private LinkedList<Thing> things;
// Properties
private int index;
private int floorheight;
private int ceilheight;
private string floortexname;
@ -75,6 +76,7 @@ namespace CodeImp.DoomBuilder.Map
public ICollection<Sidedef> Sidedefs { get { return sidedefs; } }
public ICollection<Thing> Things { get { return things; } }
public bool IsDisposed { get { return isdisposed; } }
public int Index { get { return index; } }
public int FloorHeight { get { return floorheight; } }
public int CeilHeight { get { return ceilheight; } }
public string FloorTexture { get { return floortexname; } }
@ -82,7 +84,7 @@ namespace CodeImp.DoomBuilder.Map
public long LongFloorTexture { get { return longfloortexname; } }
public long LongCeilTexture { get { return longceiltexname; } }
public int Effect { get { return effect; } }
public int Tag { get { return tag; } }
public int Tag { get { return tag; } set { tag = value; if((tag < 0) || (tag > MapSet.HIGHEST_TAG)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } }
public int Brightness { get { return brightness; } }
public bool Selected { get { return selected; } set { selected = value; } }
public Sector Clone { get { return clone; } set { clone = value; } }
@ -92,13 +94,16 @@ namespace CodeImp.DoomBuilder.Map
#region ================== Constructor / Disposer
// Constructor
public Sector(MapSet map, LinkedListNode<Sector> listitem)
public Sector(MapSet map, LinkedListNode<Sector> listitem, int index)
{
// Initialize
this.map = map;
this.mainlistitem = listitem;
this.sidedefs = new LinkedList<Sidedef>();
this.things = new LinkedList<Thing>();
this.index = index;
SetCeilTexture("-");
SetFloorTexture("-");
// We have no destructor
GC.SuppressFinalize(this);
@ -115,6 +120,9 @@ namespace CodeImp.DoomBuilder.Map
// Remove from main list
mainlistitem.List.Remove(mainlistitem);
// Register the index as free
map.AddSectorIndexHole(index);
// Dispose the sidedefs that are attached to this sector
// because a sidedef cannot exist without reference to its sector.

View file

@ -71,8 +71,8 @@ namespace CodeImp.DoomBuilder.Map
public Sidedef Other { get { if(this == linedef.Front) return linedef.Back; else return linedef.Front; } }
public Sector Sector { get { return sector; } }
public bool IsDisposed { get { return isdisposed; } }
public int OffsetX { get { return offsetx; } }
public int OffsetY { get { return offsety; } }
public int OffsetX { get { return offsetx; } set { offsetx = value; } }
public int OffsetY { get { return offsety; } set { offsety = value; } }
public string HighTexture { get { return texnamehigh; } }
public string MiddleTexture { get { return texnamemid; } }
public string LowTexture { get { return texnamelow; } }
@ -92,6 +92,9 @@ namespace CodeImp.DoomBuilder.Map
this.mainlistitem = listitem;
this.linedef = l;
this.sector = s;
SetTextureHigh("-");
SetTextureMid("-");
SetTextureLow("-");
// Attach to the linedef
if(front) l.AttachFront(this); else l.AttachBack(this);
@ -276,6 +279,19 @@ namespace CodeImp.DoomBuilder.Map
longtexnamelow = Lump.MakeLongName(name);
}
// This changes sector
public void ChangeSector(Sector newsector)
{
// Detach from sector
sector.DetachSidedef(sectorlistitem);
// Change sector
sector = newsector;
// Attach to sector
sectorlistitem = sector.AttachSidedef(this);
}
#endregion
}
}

View file

@ -90,6 +90,7 @@ namespace CodeImp.DoomBuilder.Map
public int X { get { return x; } }
public int Y { get { return y; } }
public int ZOffset { get { return zoffset; } }
public int Tag { get { return tag; } set { tag = value; if((tag < 0) || (tag > MapSet.HIGHEST_TAG)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } }
public Sector Sector { get { return sector; } }
#endregion

View file

@ -611,15 +611,14 @@ namespace CodeImp.DoomBuilder.Rendering
// This returns the color for a linedef
public PixelColor DetermineLinedefColor(Linedef l)
{
// Sinlgesided lines
if((l.Back == null) || (l.Front == null))
// Impassable lines
if((l.Flags & General.Map.Config.ImpassableFlags) != 0)
{
// Determine color
if(l.Selected) return General.Colors.Selection;
else if(l.Action != 0) return General.Colors.Actions;
else return General.Colors.Linedefs;
}
// Doublesided lines
else
{
// Determine color