mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +00:00
- Replaced 'C:\\ZDOOMDAT' with a #define in version.h.
- Moved screenshot code into DCanvas so that it can be overridden by subclasses with a different buffer. SVN r643 (trunk)
This commit is contained in:
parent
682e0dbe95
commit
6804e66208
7 changed files with 57 additions and 34 deletions
|
@ -9,6 +9,9 @@ December 25, 2007
|
|||
minor win for cards that support it.
|
||||
|
||||
December 25, 2007 (Changes by Graf Zahl)
|
||||
- Replaced 'C:\\ZDOOMDAT' with a #define in version.h.
|
||||
- Moved screenshot code into DCanvas so that it can be overridden by
|
||||
subclasses with a different buffer.
|
||||
- added a P_PointInSector function and replaced all calls to retrieve an
|
||||
actor's sector in the game engine code with it. This way there's a clear
|
||||
distinction between renderer-specific and game-specific calls.
|
||||
|
|
|
@ -2259,7 +2259,7 @@ void D_DoomMain (void)
|
|||
if (Args.CheckParm("-cdrom"))
|
||||
{
|
||||
Printf (GStrings("D_CDROM"));
|
||||
mkdir ("c:\\zdoomdat", 0);
|
||||
mkdir (CDROM_DIR, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1850,7 +1850,7 @@ FString G_BuildSaveName (const char *prefix, int slot)
|
|||
#ifndef unix
|
||||
else if (Args.CheckParm ("-cdrom"))
|
||||
{
|
||||
leader = "c:/zdoomdat/";
|
||||
leader = CDROM_DIR "/";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -569,7 +569,7 @@ FString FGameConfigFile::GetConfigPath (bool tryProg)
|
|||
if (path.IsEmpty())
|
||||
{
|
||||
if (Args.CheckParm ("-cdrom"))
|
||||
return "c:\\zdoomdat\\zdoom.ini";
|
||||
return CDROM_DIR "\\zdoom.ini";
|
||||
|
||||
path = progdir;
|
||||
path += "zdoom.ini";
|
||||
|
@ -617,7 +617,7 @@ void FGameConfigFile::AddAutoexec (DArgs *list, const char *game)
|
|||
#ifndef unix
|
||||
if (Args.CheckParm ("-cdrom"))
|
||||
{
|
||||
path = "c:\\zdoomdat\\autoexec.cfg";
|
||||
path = CDROM_DIR "\\autoexec.cfg";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -306,9 +306,9 @@ FString GetUserFile (const char *file, bool nodir)
|
|||
|
||||
FString path = home;
|
||||
if (path[path.Len()-1] != '/')
|
||||
path += nodir ? "/" : "/.zdoom";
|
||||
path += nodir ? "/" : "/"GAME_DIR;
|
||||
else if (!nodir)
|
||||
path += ".zdoom";
|
||||
path += GAME_DIR;
|
||||
|
||||
if (!nodir)
|
||||
{
|
||||
|
@ -542,7 +542,7 @@ void WritePCXfile (FILE *file, const DCanvas *canvas, const PalEntry *palette)
|
|||
void WritePNGfile (FILE *file, const DCanvas *canvas, const PalEntry *palette)
|
||||
{
|
||||
if (!M_CreatePNG (file, canvas, palette) ||
|
||||
!M_AppendPNGText (file, "Software", "ZDoom " DOTVERSIONSTR) ||
|
||||
!M_AppendPNGText (file, "Software", GAMENAME DOTVERSIONSTR) ||
|
||||
!M_FinishPNG (file))
|
||||
{
|
||||
Printf ("Could not create screenshot.\n");
|
||||
|
@ -572,9 +572,8 @@ static bool FindFreeName (FString &fullname, const char *extension)
|
|||
|
||||
void M_ScreenShot (const char *filename)
|
||||
{
|
||||
FILE *file;
|
||||
FString autoname;
|
||||
bool writepcx = (stricmp (screenshot_type, "pcx") == 0); // PNG is the default
|
||||
bool writepcx = screen->CanWritePCX() && (stricmp (screenshot_type, "pcx") == 0); // PNG is the default
|
||||
|
||||
// find a file name to save it to
|
||||
if (filename == NULL || filename[0] == '\0')
|
||||
|
@ -582,7 +581,7 @@ void M_ScreenShot (const char *filename)
|
|||
#ifndef unix
|
||||
if (Args.CheckParm ("-cdrom"))
|
||||
{
|
||||
autoname = "C:\\ZDOOMDAT\\";
|
||||
autoname = CDROM_DIR "\\";
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -615,30 +614,7 @@ void M_ScreenShot (const char *filename)
|
|||
CreatePath(screenshot_dir);
|
||||
|
||||
// save the screenshot
|
||||
screen->Lock (true);
|
||||
//D_Display (true);
|
||||
|
||||
PalEntry palette[256];
|
||||
screen->GetFlashedPalette (palette);
|
||||
|
||||
file = fopen (autoname.GetChars(), "wb");
|
||||
if (file == NULL)
|
||||
{
|
||||
Printf ("Could not open %s\n", autoname.GetChars());
|
||||
screen->Unlock ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (writepcx)
|
||||
{
|
||||
WritePCXfile (file, screen, palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
WritePNGfile (file, screen, palette);
|
||||
}
|
||||
fclose (file);
|
||||
screen->Unlock ();
|
||||
screen->Save(autoname, writepcx);
|
||||
|
||||
if (!screenshot_quiet)
|
||||
{
|
||||
|
@ -646,6 +622,40 @@ void M_ScreenShot (const char *filename)
|
|||
}
|
||||
}
|
||||
|
||||
bool DCanvas::CanWritePCX()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void DCanvas::Save(const char *filename, bool writepcx)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
Lock (true);
|
||||
|
||||
PalEntry palette[256];
|
||||
screen->GetFlashedPalette (palette);
|
||||
|
||||
file = fopen (filename, "wb");
|
||||
if (file == NULL)
|
||||
{
|
||||
Printf ("Could not open %s\n", filename);
|
||||
Unlock ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (writepcx)
|
||||
{
|
||||
WritePCXfile (file, this, palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
WritePNGfile (file, this, palette);
|
||||
}
|
||||
fclose (file);
|
||||
Unlock ();
|
||||
}
|
||||
|
||||
CCMD (screenshot)
|
||||
{
|
||||
if (argv.argc() == 1)
|
||||
|
|
|
@ -142,6 +142,7 @@ public:
|
|||
|
||||
// Access control
|
||||
virtual bool Lock () = 0; // Returns true if the surface was lost since last time
|
||||
virtual bool Lock (bool usesimplecanvas) { return Lock(); }
|
||||
virtual void Unlock () = 0;
|
||||
virtual bool IsLocked () { return Buffer != NULL; } // Returns true if the surface is locked
|
||||
|
||||
|
@ -181,6 +182,12 @@ public:
|
|||
// Can be overridden so that the colormaps for sector color/fade won't be built.
|
||||
virtual bool UsesColormap() const;
|
||||
|
||||
// software renderer always returns true but other renderers may not want to implement PCX.
|
||||
bool CanWritePCX();
|
||||
|
||||
// Saves canvas to a file
|
||||
void Save(const char *filename, bool writepcx);
|
||||
|
||||
// Text drawing functions -----------------------------------------------
|
||||
|
||||
virtual void SetFont (FFont *font);
|
||||
|
|
|
@ -86,6 +86,9 @@
|
|||
|
||||
#ifdef unix
|
||||
#define HOME_DIR "~/.zdoom"
|
||||
#define GAME_DIR ".zdoom"
|
||||
#else
|
||||
#define CDROM_DIR "C:\\ZDOOMDAT"
|
||||
#endif
|
||||
|
||||
// MINSAVEVER is the minimum level snapshot version that can be loaded.
|
||||
|
|
Loading…
Reference in a new issue