mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-31 02:14:09 +03:00
Add support for internal screenshots
"But people already have screenshot tools", you might protest. The rationale is simple: If you play with any video setting other than 1x windowed (no stretching and no letterbox), then your screenshot will be too big if you want the internal resolution of 320x240, and downscaling will be an inconvenience. The point is to make screenshots based off of internal resolution so they are always pixel perfect and ideally never have to be altered once taken. I've added the keybind of F6 to do this. Right now it saves to a temporary test location with the same filename; future commits will save to properly-timestamped filenames.
This commit is contained in:
@@ -48,6 +48,7 @@ static char* basePath = NULL;
|
||||
static char writeDir[MAX_PATH] = {'\0'};
|
||||
static char saveDir[MAX_PATH] = {'\0'};
|
||||
static char levelDir[MAX_PATH] = {'\0'};
|
||||
static char screenshotDir[MAX_PATH] = {'\0'};
|
||||
static char mainLangDir[MAX_PATH] = {'\0'};
|
||||
static bool isMainLangDirFromRepo = false;
|
||||
static bool doesLangDirExist = false;
|
||||
@@ -260,6 +261,15 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD
|
||||
mkdir(levelDir, 0777);
|
||||
vlog_info("Level directory: %s", levelDir);
|
||||
|
||||
/* Store full screenshot directory */
|
||||
SDL_snprintf(screenshotDir, sizeof(screenshotDir), "%s%s%s",
|
||||
writeDir,
|
||||
"screenshots",
|
||||
pathSep
|
||||
);
|
||||
mkdir(screenshotDir, 0777);
|
||||
vlog_info("Screenshot directory: %s", screenshotDir);
|
||||
|
||||
basePath = SDL_GetBasePath();
|
||||
|
||||
if (basePath == NULL)
|
||||
@@ -799,6 +809,38 @@ static PHYSFS_sint64 read_bytes(
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
bool FILESYSTEM_saveFile(const char* name, const unsigned char* data, const size_t len)
|
||||
{
|
||||
if (!isInit)
|
||||
{
|
||||
vlog_warn("Filesystem not initialized! Not writing just to be safe.");
|
||||
return false;
|
||||
}
|
||||
|
||||
PHYSFS_File* handle = PHYSFS_openWrite(name);
|
||||
if (handle == NULL)
|
||||
{
|
||||
vlog_error(
|
||||
"Could not open PHYSFS handle for %s: %s",
|
||||
name, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
|
||||
);
|
||||
return false;
|
||||
}
|
||||
PHYSFS_sint64 bytes_written = PHYSFS_writeBytes(handle, data, len);
|
||||
if ((size_t) bytes_written != len)
|
||||
{
|
||||
vlog_warn("%s: Number of bytes written is not as expected", name);
|
||||
}
|
||||
|
||||
int success = PHYSFS_close(handle);
|
||||
if (success == 0)
|
||||
{
|
||||
vlog_error("%s: Could not close handle", name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FILESYSTEM_loadFileToMemory(
|
||||
const char *name,
|
||||
unsigned char **mem,
|
||||
|
||||
Reference in New Issue
Block a user