mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +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,6 +237,8 @@ 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; } }
|
||||
|
@ -360,6 +364,8 @@ 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);
|
||||
|
@ -469,6 +475,8 @@ 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);
|
||||
|
|
|
@ -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,19 +3255,21 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
//draw the cursor
|
||||
if(!cursorLocation.IsEmpty) g.DrawImage(Resources.Cursor, cursorLocation);
|
||||
|
||||
if (General.Settings.DrawScreenshotInfo)
|
||||
{
|
||||
//gather some info
|
||||
string info;
|
||||
if(displayextrainfo && General.Editing.Mode != null)
|
||||
if (displayextrainfo && General.Editing.Mode != null)
|
||||
{
|
||||
info = General.Map.FileTitle + " | " + General.Map.Options.CurrentName + " | ";
|
||||
|
||||
//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?
|
||||
if(pos.IsFinite())
|
||||
if (pos.IsFinite())
|
||||
{
|
||||
info += "X:" + Math.Round(pos.x) + " Y:" + Math.Round(pos.y);
|
||||
}
|
||||
|
@ -3296,19 +3299,22 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
float py = 4;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (usejpg)
|
||||
{
|
||||
ImageCodecInfo jpegCodec = null;
|
||||
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
|
||||
foreach(ImageCodecInfo codec in codecs)
|
||||
foreach (ImageCodecInfo codec in codecs)
|
||||
{
|
||||
if(codec.FormatID == ImageFormat.Jpeg.Guid)
|
||||
if (codec.FormatID == ImageFormat.Jpeg.Guid)
|
||||
{
|
||||
jpegCodec = codec;
|
||||
break;
|
||||
|
@ -3320,6 +3326,11 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
encoderParams.Param[0] = qualityParam;
|
||||
|
||||
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