Fixed, Visual mode: "Paste Texture Flood-Fill" action used long texture names regardless of current setting in Map Options.

Internal: "uselongtexturenames" setting is now stored in map settings file, not in the program configuration file.
Fixed, Color Picker plugin: in some cases mouse movement was processed incorrectly.
Fixed, Color Picker plugin: float color value output was culture settings-dependant.
This commit is contained in:
MaxED 2015-02-19 13:00:19 +00:00
parent 321a56a850
commit 0ea022fa4e
11 changed files with 86 additions and 61 deletions

View file

@ -1665,7 +1665,7 @@ namespace CodeImp.DoomBuilder.Geometry
// When resetsectormarks is set to true, all sectors will first be marked false (not aligned).
// Setting resetsectormarks to false is usefull to fill only within a specific selection
// (set the marked property to true for the sectors outside the selection)
public static void FloodfillFlats(Sector start, bool fillceilings, long originalflat, ImageData fillflat, bool resetsectormarks)
public static void FloodfillFlats(Sector start, bool fillceilings, long originalflat, string fillflat, bool resetsectormarks)
{
Stack<Sector> todo = new Stack<Sector>(50);
@ -1686,10 +1686,8 @@ namespace CodeImp.DoomBuilder.Geometry
Sector s = todo.Pop();
// Apply new flat
if(fillceilings)
s.SetCeilTexture(fillflat.Name);
else
s.SetFloorTexture(fillflat.Name);
if(fillceilings) s.SetCeilTexture(fillflat);
else s.SetFloorTexture(fillflat);
s.Marked = true;
// Go for all sidedefs to add neighbouring sectors
@ -1720,7 +1718,7 @@ namespace CodeImp.DoomBuilder.Geometry
// When resetsidemarks is set to true, all sidedefs will first be marked false (not aligned).
// Setting resetsidemarks to false is usefull to fill only within a specific selection
// (set the marked property to true for the sidedefs outside the selection)
public static void FloodfillTextures(Sidedef start, long originaltexture, ImageData filltexture, bool resetsidemarks)
public static void FloodfillTextures(Sidedef start, long originaltexture, string filltexture, bool resetsidemarks)
{
Stack<SidedefFillJob> todo = new Stack<SidedefFillJob>(50);
@ -1743,10 +1741,11 @@ namespace CodeImp.DoomBuilder.Geometry
SidedefFillJob j = todo.Pop();
// Apply texturing
if(j.sidedef.HighRequired() && j.sidedef.LongHighTexture == originaltexture) j.sidedef.SetTextureHigh(filltexture.Name);
if(j.sidedef.HighRequired() && j.sidedef.LongHighTexture == originaltexture) j.sidedef.SetTextureHigh(filltexture);
if((j.sidedef.LongMiddleTexture != MapSet.EmptyLongName || j.sidedef.MiddleRequired()) &&
(j.sidedef.LongMiddleTexture == originaltexture)) j.sidedef.SetTextureMid(filltexture.Name);
if(j.sidedef.LowRequired() && j.sidedef.LongLowTexture == originaltexture) j.sidedef.SetTextureLow(filltexture.Name);
(j.sidedef.LongMiddleTexture == originaltexture)) j.sidedef.SetTextureMid(filltexture);
if(j.sidedef.LowRequired() && j.sidedef.LongLowTexture == originaltexture) j.sidedef.SetTextureLow(filltexture);
j.sidedef.Marked = true;
if(j.forward)

View file

@ -79,6 +79,9 @@ namespace CodeImp.DoomBuilder.Map
private bool overridefloorheight;
private bool overrideceilheight;
private bool overridebrightness;
//mxd.
private bool uselongtexturenames;
#endregion
@ -130,6 +133,9 @@ namespace CodeImp.DoomBuilder.Map
public bool OverrideCeilingHeight { get { return overrideceilheight; } set { overrideceilheight = value; } }
public bool OverrideBrightness { get { return overridebrightness; } set { overridebrightness = value; } }
//mxd
public bool UseLongTextureNames { get { return uselongtexturenames; } set { uselongtexturenames = value; } }
#endregion
#region ================== Constructor / Disposer
@ -154,7 +160,7 @@ namespace CodeImp.DoomBuilder.Map
}
// Constructor to load from Doom Builder Map Settings Configuration
internal MapOptions(Configuration cfg, string mapname)
internal MapOptions(Configuration cfg, string mapname, bool longtexturenamessupported)
{
IDictionary resinfo;
DataLocation res;
@ -213,6 +219,9 @@ namespace CodeImp.DoomBuilder.Map
overrideceilheight = this.mapconfig.ReadSetting("overrideceilheight", false);
overridebrightness = this.mapconfig.ReadSetting("overridebrightness", false);
//mxd
uselongtexturenames = longtexturenamessupported && this.mapconfig.ReadSetting("uselongtexturenames", false);
// Resources
IDictionary reslist = this.mapconfig.ReadSetting("resources", new Hashtable());
foreach(DictionaryEntry mp in reslist)
@ -334,6 +343,9 @@ namespace CodeImp.DoomBuilder.Map
mapconfig.WriteSetting("overrideceilheight", overrideceilheight);
mapconfig.WriteSetting("overridebrightness", overridebrightness);
//mxd
mapconfig.WriteSetting("uselongtexturenames", uselongtexturenames);
//mxd. Write script compiler
if(!string.IsNullOrEmpty(scriptcompiler))
mapconfig.WriteSetting("scriptcompiler", scriptcompiler);

View file

@ -193,7 +193,7 @@ namespace CodeImp.DoomBuilder.Windows
// Create new map options, pass settings which should stay unchanged
//TODO: are there other settings which should stay unchanged?..
MapOptions newoptions = new MapOptions(mapsettings, mapslist.SelectedItems[0].Text);
MapOptions newoptions = new MapOptions(mapsettings, mapslist.SelectedItems[0].Text, options.UseLongTextureNames);
newoptions.ConfigFile = options.ConfigFile;
options = newoptions;

View file

@ -473,8 +473,23 @@ namespace CodeImp.DoomBuilder.Windows
else
mapsettings = new Configuration(true);
//mxd. Get proper configuration file
bool longtexturenamessupported = false;
string configfile = General.AutoLoadConfig;
if(string.IsNullOrEmpty(configfile)) configfile = mapsettings.ReadSetting("gameconfig", "");
if(configfile.Trim().Length == 0)
{
showdialog = true;
}
else
{
//TODO: test this!
Configuration gamecfg = new Configuration(configfile);
longtexturenamessupported = gamecfg.ReadSetting("longtexturenames", false);
}
// Set map name and other options
options = new MapOptions(mapsettings, General.AutoLoadMap);
options = new MapOptions(mapsettings, General.AutoLoadMap, longtexturenamessupported);
// Set resource data locations
options.CopyResources(General.AutoLoadResources);
@ -483,9 +498,7 @@ namespace CodeImp.DoomBuilder.Windows
options.StrictPatches = General.AutoLoadStrictPatches;
// Set configuration file (constructor already does this, but we want this info from the cmd args if possible)
options.ConfigFile = General.AutoLoadConfig;
if(options.ConfigFile == null) options.ConfigFile = mapsettings.ReadSetting("gameconfig", "");
if(options.ConfigFile.Trim().Length == 0) showdialog = true;
options.ConfigFile = configfile;
}
else
{

View file

@ -283,7 +283,7 @@ namespace CodeImp.DoomBuilder.Windows
}
//mxd. Use long texture names?
if(longtexturenames.Enabled) General.Settings.WriteSetting("browserwindow.uselongtexturenames", longtexturenames.Checked);
if(longtexturenames.Enabled) options.UseLongTextureNames = longtexturenames.Checked;
// Hide window
this.DialogResult = DialogResult.OK;
@ -337,7 +337,7 @@ namespace CodeImp.DoomBuilder.Windows
// Update long texture names checkbox (mxd)
longtexturenames.Enabled = ci.Configuration.ReadSetting("longtexturenames", false);
longtexturenames.Checked = longtexturenames.Enabled && General.Settings.ReadSetting("browserwindow.uselongtexturenames", false);
longtexturenames.Checked = longtexturenames.Enabled && options.UseLongTextureNames;
}
// When keys are pressed in the level name field

View file

@ -353,7 +353,7 @@ namespace CodeImp.DoomBuilder.Windows
// Update long texture names checkbox (mxd)
longtexturenames.Enabled = cfg.ReadSetting("longtexturenames", false);
longtexturenames.Checked = longtexturenames.Enabled && General.Settings.ReadSetting("browserwindow.uselongtexturenames", false);
longtexturenames.Checked = longtexturenames.Enabled && options.UseLongTextureNames;
}
// OK clicked
@ -432,7 +432,7 @@ namespace CodeImp.DoomBuilder.Windows
}
//mxd. Use long texture names?
if (longtexturenames.Enabled) General.Settings.WriteSetting("browserwindow.uselongtexturenames", longtexturenames.Checked);
if(longtexturenames.Enabled) options.UseLongTextureNames = longtexturenames.Checked;
// Hide window
wadfile.Dispose();
@ -498,7 +498,7 @@ namespace CodeImp.DoomBuilder.Windows
{
// Get the map name
selectedmapname = mapslist.SelectedItems[0].Text;
options = new MapOptions(mapsettings, selectedmapname);
options = new MapOptions(mapsettings, selectedmapname, longtexturenames.Enabled);
// Get locations from previous selected map settings
locations = new DataLocationList(mapsettings, "maps." + selectedmapname + ".resources");

View file

@ -64,7 +64,7 @@ namespace CodeImp.DoomBuilder.Windows
// Setup texture browser
ImageBrowserControl.ShowTextureSizes = General.Settings.ReadSetting("browserwindow.showtexturesizes", General.Settings.ShowTextureSizes);
ImageBrowserControl.UseLongTextureNames = General.Map.Config.UseLongTextureNames && General.Settings.ReadSetting("browserwindow.uselongtexturenames", true);
ImageBrowserControl.UseLongTextureNames = General.Map.Options.UseLongTextureNames;
browser.BrowseFlats = browseflats;
browser.ApplySettings();
@ -447,7 +447,7 @@ namespace CodeImp.DoomBuilder.Windows
//mxd. Save ImageBrowserControl settings
General.Settings.WriteSetting("browserwindow.showtexturesizes", ImageBrowserControl.ShowTextureSizes);
if(General.Map.Config.UseLongTextureNames) General.Settings.WriteSetting("browserwindow.uselongtexturenames", ImageBrowserControl.UseLongTextureNames);
if(General.Map.Config.UseLongTextureNames) General.Map.Options.UseLongTextureNames = ImageBrowserControl.UseLongTextureNames;
// Clean up
browser.CleanUp();

View file

@ -561,7 +561,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(BuilderPlug.Me.CopiedFlat != null)
{
string oldtexture = GetTextureName();
long oldtexturelong = Lump.MakeLongName(oldtexture);
long oldtexturelong = Lump.MakeLongName(General.Map.Data.GetFullFlatName(oldtexture)); //mxd
string newtexture = BuilderPlug.Me.CopiedFlat;
if(newtexture != oldtexture)
{
@ -599,7 +599,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Do the fill
Tools.FloodfillFlats(this.Sector.Sector, fillceilings, oldtexturelong, newtextureimage, false);
Tools.FloodfillFlats(this.Sector.Sector, fillceilings, oldtexturelong, newtexture, false);
// Get the changed sectors
List<Sector> changes = General.Map.Map.GetMarkedSectors(true);
@ -711,9 +711,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Copy texture
public virtual void OnCopyTexture()
{
BuilderPlug.Me.CopiedFlat = GetTextureName();
if(General.Map.Config.MixTexturesFlats) BuilderPlug.Me.CopiedTexture = GetTextureName();
mode.SetActionResult("Copied flat '" + GetTextureName() + "'.");
if(Texture == null) return; //mxd
string texturename = (!General.Map.Options.UseLongTextureNames ? Texture.ShortName : GetTextureName()); //mxd
BuilderPlug.Me.CopiedFlat = texturename;
if(General.Map.Config.MixTexturesFlats) BuilderPlug.Me.CopiedTexture = texturename;
mode.SetActionResult("Copied flat '" + texturename + "'.");
}
public virtual void OnPasteTexture() { }

View file

@ -946,7 +946,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(BuilderPlug.Me.CopiedTexture != null)
{
string oldtexture = GetTextureName();
long oldtexturelong = Lump.MakeLongName(oldtexture);
long oldtexturelong = Lump.MakeLongName(General.Map.Data.GetFullTextureName(oldtexture)); //mxd
string newtexture = BuilderPlug.Me.CopiedTexture;
if(newtexture != oldtexture)
{
@ -974,7 +974,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Do the alignment
Tools.FloodfillTextures(this.Sidedef, oldtexturelong, newtextureimage, false);
Tools.FloodfillTextures(this.Sidedef, oldtexturelong, newtexture, false);
// Get the changed sidedefs
List<Sidedef> changes = General.Map.Map.GetMarkedSidedefs(true);
@ -1100,9 +1100,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Copy texture
public virtual void OnCopyTexture()
{
BuilderPlug.Me.CopiedTexture = GetTextureName();
if(General.Map.Config.MixTexturesFlats) BuilderPlug.Me.CopiedFlat = GetTextureName();
mode.SetActionResult("Copied texture '" + GetTextureName() + "'.");
if(Texture == null) return; //mxd
string texturename = (!General.Map.Options.UseLongTextureNames ? Texture.ShortName : GetTextureName()); //mxd
BuilderPlug.Me.CopiedTexture = texturename;
if(General.Map.Config.MixTexturesFlats) BuilderPlug.Me.CopiedFlat = texturename;
mode.SetActionResult("Copied texture '" + texturename + "'.");
}
// Copy texture offsets

View file

@ -95,12 +95,9 @@ namespace CodeImp.DoomBuilder.ColorPicker.Controls
break;
case COLOR_INFO_HEX:
string r = RGB.Red.ToString("X");
if (r.Length == 1) r = "0" + r;
string g = RGB.Green.ToString("X");
if (g.Length == 1) g = "0" + g;
string b = RGB.Blue.ToString("X");
if (b.Length == 1) b = "0" + b;
string r = RGB.Red.ToString("X02");
string g = RGB.Green.ToString("X02");
string b = RGB.Blue.ToString("X02");
isInUpdate = true;
tbFloatVals.Text = r + g + b;
@ -108,12 +105,9 @@ namespace CodeImp.DoomBuilder.ColorPicker.Controls
break;
case COLOR_INFO_FLOAT:
string r2 = ((float)Math.Round(RGB.Red / 255f, 2)).ToString();
if (r2.Length == 1) r2 += ".0";
string g2 = ((float)Math.Round(RGB.Green / 255f, 2)).ToString();
if (g2.Length == 1) g2 += ".0";
string b2 = ((float)Math.Round(RGB.Blue / 255f, 2)).ToString();
if (b2.Length == 1) b2 += ".0";
string r2 = ((float)Math.Round(RGB.Red / 255f, 2)).ToString("F02", CultureInfo.InvariantCulture);
string g2 = ((float)Math.Round(RGB.Green / 255f, 2)).ToString("F02", CultureInfo.InvariantCulture);
string b2 = ((float)Math.Round(RGB.Blue / 255f, 2)).ToString("F02", CultureInfo.InvariantCulture);
isInUpdate = true;
tbFloatVals.Text = r2 + " " + g2 + " " + b2;
@ -181,16 +175,6 @@ namespace CodeImp.DoomBuilder.ColorPicker.Controls
UpdateCancelButton(RGB);
}
private void ColorPickerControl_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
changeType = ChangeStyle.MouseMove;
selectedPoint = new Point(e.X, e.Y);
this.Invalidate();
}
}
private void ColorChanged(object sender, ColorChangedEventArgs e)
{
SetRGB(e.RGB);
@ -211,7 +195,17 @@ namespace CodeImp.DoomBuilder.ColorPicker.Controls
}
}
private void HandleMouse(object sender, MouseEventArgs e)
private void ColorPickerControl_MouseDown(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
changeType = ChangeStyle.MouseMove;
selectedPoint = new Point(e.X, e.Y);
this.Invalidate();
}
}
private void OnMouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
@ -227,10 +221,11 @@ namespace CodeImp.DoomBuilder.ColorPicker.Controls
changeType = ChangeStyle.None;
}
private void OnMouseUp(object sender, EventArgs e)
private void OnMouseLeave(object sender, EventArgs e)
{
colorWheel.SetMouseUp();
changeType = ChangeStyle.None;
selectedPoint = Point.Empty;
}
private void btnOK_Click(object sender, EventArgs e)

View file

@ -1,4 +1,6 @@
namespace CodeImp.DoomBuilder.ColorPicker.Controls {
using CodeImp.DoomBuilder.Controls;
namespace CodeImp.DoomBuilder.ColorPicker.Controls {
partial class ColorPickerControl {
/// <summary>
/// Требуется переменная конструктора.
@ -33,7 +35,7 @@
this.nudBlue = new System.Windows.Forms.NumericUpDown();
this.nudGreen = new System.Windows.Forms.NumericUpDown();
this.Label2 = new System.Windows.Forms.Label();
this.tbFloatVals = new System.Windows.Forms.TextBox();
this.tbFloatVals = new CodeImp.DoomBuilder.Controls.AutoSelectTextbox();
this.pRGB = new System.Windows.Forms.Panel();
this.cbColorInfo = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.nudRed)).BeginInit();
@ -197,9 +199,9 @@
this.Name = "ColorPickerControl";
this.Size = new System.Drawing.Size(311, 183);
this.Load += new System.EventHandler(this.ColorPickerControl_Load);
this.MouseLeave += new System.EventHandler(this.OnMouseUp);
this.MouseLeave += new System.EventHandler(this.OnMouseLeave);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.OnPaint);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.HandleMouse);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ColorPickerControl_MouseDown);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseUp);
((System.ComponentModel.ISupportInitialize)(this.nudRed)).EndInit();
@ -223,7 +225,7 @@
internal System.Windows.Forms.NumericUpDown nudBlue;
internal System.Windows.Forms.NumericUpDown nudGreen;
internal System.Windows.Forms.Label Label2;
private System.Windows.Forms.TextBox tbFloatVals;
private CodeImp.DoomBuilder.Controls.AutoSelectTextbox tbFloatVals;
private System.Windows.Forms.Panel pRGB;
private System.Windows.Forms.ComboBox cbColorInfo;
}