Add options to save screenshots in PNG format and to disable the infobox in the top right corner. No menu entries for these options because I'm lazy and most people probably won't need these settings anyway.

This commit is contained in:
MascaraSnake 2016-03-01 22:48:15 +01:00
parent f54f193332
commit 649f5595dd
3 changed files with 85 additions and 64 deletions

View File

@ -840,4 +840,6 @@ rendernightspath = true;
defaultceilheight = 128; defaultceilheight = 128;
defaultfloorheight = 0; defaultfloorheight = 0;
defaultbrightness = 255; defaultbrightness = 255;
dynamicgridsize = false; dynamicgridsize = false;
drawscreenshotinfo = true;
compressscreenshots = true;

View File

@ -132,6 +132,8 @@ namespace CodeImp.DoomBuilder.Config
private bool rendernightspath; private bool rendernightspath;
private bool dynamicgridsize; private bool dynamicgridsize;
private int ignoredremoterevision; private int ignoredremoterevision;
private bool drawscreenshotinfo;
private bool compressscreenshots;
// These are not stored in the configuration, only used at runtime // These are not stored in the configuration, only used at runtime
private int defaultbrightness; private int defaultbrightness;
@ -235,9 +237,11 @@ namespace CodeImp.DoomBuilder.Config
public bool RenderNiGHTSPath { get { return rendernightspath; } internal set { rendernightspath = value; } } public bool RenderNiGHTSPath { get { return rendernightspath; } internal set { rendernightspath = value; } }
public bool DynamicGridSize { get { return dynamicgridsize; } internal set { dynamicgridsize = value; } } //mxd public bool DynamicGridSize { get { return dynamicgridsize; } internal set { dynamicgridsize = value; } } //mxd
internal int IgnoredRemoteRevision { get { return ignoredremoterevision; } set { ignoredremoterevision = value; } } //mxd internal int IgnoredRemoteRevision { get { return ignoredremoterevision; } set { ignoredremoterevision = value; } } //mxd
public bool DrawScreenshotInfo { get { return drawscreenshotinfo; } set { drawscreenshotinfo = value; } }
public bool CompressScreenshots { get { return compressscreenshots; } set { compressscreenshots = value; } }
//mxd. Left here for compatibility reasons... //mxd. Left here for compatibility reasons...
public string DefaultTexture { get { return General.Map != null ? General.Map.Options.DefaultWallTexture : "-"; } set { if(General.Map != null) General.Map.Options.DefaultWallTexture = value; } } public string DefaultTexture { get { return General.Map != null ? General.Map.Options.DefaultWallTexture : "-"; } set { if(General.Map != null) General.Map.Options.DefaultWallTexture = value; } }
public string DefaultFloorTexture { get { return General.Map != null ? General.Map.Options.DefaultFloorTexture : "-"; } set { if(General.Map != null) General.Map.Options.DefaultFloorTexture = value; } } public string DefaultFloorTexture { get { return General.Map != null ? General.Map.Options.DefaultFloorTexture : "-"; } set { if(General.Map != null) General.Map.Options.DefaultFloorTexture = value; } }
public string DefaultCeilingTexture { get { return General.Map != null ? General.Map.Options.DefaultCeilingTexture : "-"; } set { if(General.Map != null) General.Map.Options.DefaultCeilingTexture = value; } } public string DefaultCeilingTexture { get { return General.Map != null ? General.Map.Options.DefaultCeilingTexture : "-"; } set { if(General.Map != null) General.Map.Options.DefaultCeilingTexture = value; } }
public int DefaultBrightness { get { return defaultbrightness; } set { defaultbrightness = value; } } public int DefaultBrightness { get { return defaultbrightness; } set { defaultbrightness = value; } }
@ -360,9 +364,11 @@ namespace CodeImp.DoomBuilder.Config
rendernightspath = cfg.ReadSetting("rendernightspath", true); rendernightspath = cfg.ReadSetting("rendernightspath", true);
dynamicgridsize = cfg.ReadSetting("dynamicgridsize", true); //mxd dynamicgridsize = cfg.ReadSetting("dynamicgridsize", true); //mxd
ignoredremoterevision = cfg.ReadSetting("ignoredremoterevision", 0); //mxd ignoredremoterevision = cfg.ReadSetting("ignoredremoterevision", 0); //mxd
drawscreenshotinfo = cfg.ReadSetting("drawscreenshotinfo", true);
compressscreenshots = cfg.ReadSetting("compressscreenshots", true);
//mxd. Sector defaults //mxd. Sector defaults
defaultceilheight = cfg.ReadSetting("defaultceilheight", 128); defaultceilheight = cfg.ReadSetting("defaultceilheight", 128);
defaultfloorheight = cfg.ReadSetting("defaultfloorheight", 0); defaultfloorheight = cfg.ReadSetting("defaultfloorheight", 0);
defaultbrightness = cfg.ReadSetting("defaultbrightness", 192); defaultbrightness = cfg.ReadSetting("defaultbrightness", 192);
@ -469,9 +475,11 @@ namespace CodeImp.DoomBuilder.Config
cfg.WriteSetting("rendernightspath", rendernightspath); //mxd cfg.WriteSetting("rendernightspath", rendernightspath); //mxd
cfg.WriteSetting("dynamicgridsize", dynamicgridsize); //mxd cfg.WriteSetting("dynamicgridsize", dynamicgridsize); //mxd
cfg.WriteSetting("ignoredremoterevision", ignoredremoterevision); //mxd cfg.WriteSetting("ignoredremoterevision", ignoredremoterevision); //mxd
cfg.WriteSetting("drawscreenshotinfo", drawscreenshotinfo);
cfg.WriteSetting("compressscreenshots", compressscreenshots);
//mxd. Sector defaults //mxd. Sector defaults
cfg.WriteSetting("defaultceilheight", defaultceilheight); cfg.WriteSetting("defaultceilheight", defaultceilheight);
cfg.WriteSetting("defaultfloorheight", defaultfloorheight); cfg.WriteSetting("defaultfloorheight", defaultfloorheight);
cfg.WriteSetting("defaultbrightness", defaultbrightness); cfg.WriteSetting("defaultbrightness", defaultbrightness);

View File

@ -3242,7 +3242,8 @@ namespace CodeImp.DoomBuilder.Windows
//create path //create path
string date = DateTime.Now.ToString("yyyy.MM.dd HH-mm-ss.fff"); string date = DateTime.Now.ToString("yyyy.MM.dd HH-mm-ss.fff");
string revision = (General.DebugBuild ? "DEVBUILD" : "R" + General.ThisAssembly.GetName().Version.MinorRevision); string revision = (General.DebugBuild ? "DEVBUILD" : "R" + General.ThisAssembly.GetName().Version.MinorRevision);
string path = Path.Combine(folder, name + date + " [" + revision + "].jpg"); bool usejpg = General.Settings.CompressScreenshots;
string path = Path.Combine(folder, name + date + " [" + revision + "]" + (usejpg ? ".jpg" : ".png"));
//save image //save image
using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
@ -3254,73 +3255,83 @@ namespace CodeImp.DoomBuilder.Windows
//draw the cursor //draw the cursor
if(!cursorLocation.IsEmpty) g.DrawImage(Resources.Cursor, cursorLocation); if(!cursorLocation.IsEmpty) g.DrawImage(Resources.Cursor, cursorLocation);
//gather some info if (General.Settings.DrawScreenshotInfo)
string info; {
if(displayextrainfo && General.Editing.Mode != null) //gather some info
{ string info;
info = General.Map.FileTitle + " | " + General.Map.Options.CurrentName + " | "; if (displayextrainfo && General.Editing.Mode != null)
{
info = General.Map.FileTitle + " | " + General.Map.Options.CurrentName + " | ";
//get map coordinates //get map coordinates
if(General.Editing.Mode is ClassicMode) if (General.Editing.Mode is ClassicMode)
{ {
Vector2D pos = ((ClassicMode) General.Editing.Mode).MouseMapPos; Vector2D pos = ((ClassicMode)General.Editing.Mode).MouseMapPos;
//mouse inside the view? //mouse inside the view?
if(pos.IsFinite()) if (pos.IsFinite())
{ {
info += "X:" + Math.Round(pos.x) + " Y:" + Math.Round(pos.y); info += "X:" + Math.Round(pos.x) + " Y:" + Math.Round(pos.y);
} }
else else
{ {
info += "X:" + Math.Round(General.Map.Renderer2D.TranslateX) + " Y:" + Math.Round(General.Map.Renderer2D.TranslateY); info += "X:" + Math.Round(General.Map.Renderer2D.TranslateX) + " Y:" + Math.Round(General.Map.Renderer2D.TranslateY);
} }
} }
else else
{ //should be visual mode { //should be visual mode
info += "X:" + Math.Round(General.Map.VisualCamera.Position.x) + " Y:" + Math.Round(General.Map.VisualCamera.Position.y) + " Z:" + Math.Round(General.Map.VisualCamera.Position.z); info += "X:" + Math.Round(General.Map.VisualCamera.Position.x) + " Y:" + Math.Round(General.Map.VisualCamera.Position.y) + " Z:" + Math.Round(General.Map.VisualCamera.Position.z);
} }
//add the revision number //add the revision number
info += " | " + revision; info += " | " + revision;
} }
else else
{ {
//just use the revision number //just use the revision number
info = revision; info = revision;
} }
//draw info //draw info
Font font = new Font("Tahoma", 10); Font font = new Font("Tahoma", 10);
SizeF rect = g.MeasureString(info, font); SizeF rect = g.MeasureString(info, font);
float px = bounds.Width - rect.Width - 4; float px = bounds.Width - rect.Width - 4;
float py = 4; float py = 4;
g.FillRectangle(Brushes.Black, px, py, rect.Width, rect.Height + 3); g.FillRectangle(Brushes.Black, px, py, rect.Width, rect.Height + 3);
using(SolidBrush brush = new SolidBrush(Color.White)) using (SolidBrush brush = new SolidBrush(Color.White))
{ {
g.DrawString(info, font, brush, px + 2, py + 2); g.DrawString(info, font, brush, px + 2, py + 2);
} }
}
} }
try try
{ {
ImageCodecInfo jpegCodec = null; if (usejpg)
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders(); {
foreach(ImageCodecInfo codec in codecs) ImageCodecInfo jpegCodec = null;
{ ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
if(codec.FormatID == ImageFormat.Jpeg.Guid) foreach (ImageCodecInfo codec in codecs)
{ {
jpegCodec = codec; if (codec.FormatID == ImageFormat.Jpeg.Guid)
break; {
} jpegCodec = codec;
} break;
}
}
EncoderParameter qualityParam = new EncoderParameter(Encoder.Quality, 90L); EncoderParameter qualityParam = new EncoderParameter(Encoder.Quality, 90L);
EncoderParameters encoderParams = new EncoderParameters(1); EncoderParameters encoderParams = new EncoderParameters(1);
encoderParams.Param[0] = qualityParam; encoderParams.Param[0] = qualityParam;
bitmap.Save(path, jpegCodec, encoderParams); bitmap.Save(path, jpegCodec, encoderParams);
DisplayStatus(StatusType.Info, "Screenshot saved to '" + path + "'"); }
else
{
bitmap.Save(path, ImageFormat.Png);
}
DisplayStatus(StatusType.Info, "Screenshot saved to '" + path + "'");
} }
catch(ExternalException e) catch(ExternalException e)
{ {