mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-03-13 06:02:38 +00:00
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:
parent
f54f193332
commit
649f5595dd
3 changed files with 85 additions and 64 deletions
|
@ -841,3 +841,5 @@ defaultceilheight = 128;
|
|||
defaultfloorheight = 0;
|
||||
defaultbrightness = 255;
|
||||
dynamicgridsize = false;
|
||||
drawscreenshotinfo = true;
|
||||
compressscreenshots = true;
|
|
@ -132,6 +132,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private bool rendernightspath;
|
||||
private bool dynamicgridsize;
|
||||
private int ignoredremoterevision;
|
||||
private bool drawscreenshotinfo;
|
||||
private bool compressscreenshots;
|
||||
|
||||
// These are not stored in the configuration, only used at runtime
|
||||
private int defaultbrightness;
|
||||
|
@ -235,9 +237,11 @@ namespace CodeImp.DoomBuilder.Config
|
|||
public bool RenderNiGHTSPath { get { return rendernightspath; } internal set { rendernightspath = value; } }
|
||||
public bool DynamicGridSize { get { return dynamicgridsize; } internal set { dynamicgridsize = 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...
|
||||
public string DefaultTexture { get { return General.Map != null ? General.Map.Options.DefaultWallTexture : "-"; } set { if(General.Map != null) General.Map.Options.DefaultWallTexture = value; } }
|
||||
//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 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 int DefaultBrightness { get { return defaultbrightness; } set { defaultbrightness = value; } }
|
||||
|
@ -360,9 +364,11 @@ namespace CodeImp.DoomBuilder.Config
|
|||
rendernightspath = cfg.ReadSetting("rendernightspath", true);
|
||||
dynamicgridsize = cfg.ReadSetting("dynamicgridsize", true); //mxd
|
||||
ignoredremoterevision = cfg.ReadSetting("ignoredremoterevision", 0); //mxd
|
||||
drawscreenshotinfo = cfg.ReadSetting("drawscreenshotinfo", true);
|
||||
compressscreenshots = cfg.ReadSetting("compressscreenshots", true);
|
||||
|
||||
//mxd. Sector defaults
|
||||
defaultceilheight = cfg.ReadSetting("defaultceilheight", 128);
|
||||
//mxd. Sector defaults
|
||||
defaultceilheight = cfg.ReadSetting("defaultceilheight", 128);
|
||||
defaultfloorheight = cfg.ReadSetting("defaultfloorheight", 0);
|
||||
defaultbrightness = cfg.ReadSetting("defaultbrightness", 192);
|
||||
|
||||
|
@ -469,9 +475,11 @@ namespace CodeImp.DoomBuilder.Config
|
|||
cfg.WriteSetting("rendernightspath", rendernightspath); //mxd
|
||||
cfg.WriteSetting("dynamicgridsize", dynamicgridsize); //mxd
|
||||
cfg.WriteSetting("ignoredremoterevision", ignoredremoterevision); //mxd
|
||||
cfg.WriteSetting("drawscreenshotinfo", drawscreenshotinfo);
|
||||
cfg.WriteSetting("compressscreenshots", compressscreenshots);
|
||||
|
||||
//mxd. Sector defaults
|
||||
cfg.WriteSetting("defaultceilheight", defaultceilheight);
|
||||
//mxd. Sector defaults
|
||||
cfg.WriteSetting("defaultceilheight", defaultceilheight);
|
||||
cfg.WriteSetting("defaultfloorheight", defaultfloorheight);
|
||||
cfg.WriteSetting("defaultbrightness", defaultbrightness);
|
||||
|
||||
|
|
|
@ -3242,7 +3242,8 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
//create path
|
||||
string date = DateTime.Now.ToString("yyyy.MM.dd HH-mm-ss.fff");
|
||||
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
|
||||
using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
|
||||
|
@ -3254,73 +3255,83 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
//draw the cursor
|
||||
if(!cursorLocation.IsEmpty) g.DrawImage(Resources.Cursor, cursorLocation);
|
||||
|
||||
//gather some info
|
||||
string info;
|
||||
if(displayextrainfo && General.Editing.Mode != null)
|
||||
{
|
||||
info = General.Map.FileTitle + " | " + General.Map.Options.CurrentName + " | ";
|
||||
if (General.Settings.DrawScreenshotInfo)
|
||||
{
|
||||
//gather some info
|
||||
string info;
|
||||
if (displayextrainfo && General.Editing.Mode != null)
|
||||
{
|
||||
info = General.Map.FileTitle + " | " + General.Map.Options.CurrentName + " | ";
|
||||
|
||||
//get map coordinates
|
||||
if(General.Editing.Mode is ClassicMode)
|
||||
{
|
||||
Vector2D pos = ((ClassicMode) General.Editing.Mode).MouseMapPos;
|
||||
//get map coordinates
|
||||
if (General.Editing.Mode is ClassicMode)
|
||||
{
|
||||
Vector2D pos = ((ClassicMode)General.Editing.Mode).MouseMapPos;
|
||||
|
||||
//mouse inside the view?
|
||||
if(pos.IsFinite())
|
||||
{
|
||||
info += "X:" + Math.Round(pos.x) + " Y:" + Math.Round(pos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
info += "X:" + Math.Round(General.Map.Renderer2D.TranslateX) + " Y:" + Math.Round(General.Map.Renderer2D.TranslateY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //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);
|
||||
}
|
||||
//mouse inside the view?
|
||||
if (pos.IsFinite())
|
||||
{
|
||||
info += "X:" + Math.Round(pos.x) + " Y:" + Math.Round(pos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
info += "X:" + Math.Round(General.Map.Renderer2D.TranslateX) + " Y:" + Math.Round(General.Map.Renderer2D.TranslateY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //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);
|
||||
}
|
||||
|
||||
//add the revision number
|
||||
info += " | " + revision;
|
||||
}
|
||||
else
|
||||
{
|
||||
//just use the revision number
|
||||
info = revision;
|
||||
}
|
||||
//add the revision number
|
||||
info += " | " + revision;
|
||||
}
|
||||
else
|
||||
{
|
||||
//just use the revision number
|
||||
info = revision;
|
||||
}
|
||||
|
||||
//draw info
|
||||
Font font = new Font("Tahoma", 10);
|
||||
SizeF rect = g.MeasureString(info, font);
|
||||
float px = bounds.Width - rect.Width - 4;
|
||||
float py = 4;
|
||||
//draw info
|
||||
Font font = new Font("Tahoma", 10);
|
||||
SizeF rect = g.MeasureString(info, font);
|
||||
float px = bounds.Width - rect.Width - 4;
|
||||
float py = 4;
|
||||
|
||||
g.FillRectangle(Brushes.Black, px, py, rect.Width, rect.Height + 3);
|
||||
using(SolidBrush brush = new SolidBrush(Color.White))
|
||||
{
|
||||
g.DrawString(info, font, brush, px + 2, py + 2);
|
||||
}
|
||||
g.FillRectangle(Brushes.Black, px, py, rect.Width, rect.Height + 3);
|
||||
using (SolidBrush brush = new SolidBrush(Color.White))
|
||||
{
|
||||
g.DrawString(info, font, brush, px + 2, py + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ImageCodecInfo jpegCodec = null;
|
||||
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
|
||||
foreach(ImageCodecInfo codec in codecs)
|
||||
{
|
||||
if(codec.FormatID == ImageFormat.Jpeg.Guid)
|
||||
{
|
||||
jpegCodec = codec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (usejpg)
|
||||
{
|
||||
ImageCodecInfo jpegCodec = null;
|
||||
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
|
||||
foreach (ImageCodecInfo codec in codecs)
|
||||
{
|
||||
if (codec.FormatID == ImageFormat.Jpeg.Guid)
|
||||
{
|
||||
jpegCodec = codec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EncoderParameter qualityParam = new EncoderParameter(Encoder.Quality, 90L);
|
||||
EncoderParameters encoderParams = new EncoderParameters(1);
|
||||
encoderParams.Param[0] = qualityParam;
|
||||
EncoderParameter qualityParam = new EncoderParameter(Encoder.Quality, 90L);
|
||||
EncoderParameters encoderParams = new EncoderParameters(1);
|
||||
encoderParams.Param[0] = qualityParam;
|
||||
|
||||
bitmap.Save(path, jpegCodec, encoderParams);
|
||||
DisplayStatus(StatusType.Info, "Screenshot saved to '" + path + "'");
|
||||
bitmap.Save(path, jpegCodec, encoderParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap.Save(path, ImageFormat.Png);
|
||||
}
|
||||
DisplayStatus(StatusType.Info, "Screenshot saved to '" + path + "'");
|
||||
}
|
||||
catch(ExternalException e)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue