mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-17 20:10:23 +03:00
Cleaned Up AppPlatform & Input Classes
* Cleaned up AppPlatform classes * Documented & improved Keyboard & Mouse classes * Improved input-handling code in the Windows & SDL main.cpp files
This commit is contained in:
committed by
iProgramInCpp
parent
e731fefbea
commit
d5ee7bfc08
@@ -13,28 +13,6 @@ AppPlatform_sdl::AppPlatform_sdl(std::string storageDir, SDL_Window *window)
|
||||
{
|
||||
}
|
||||
|
||||
// Ensure Screenshots Folder Exists
|
||||
void ensure_screenshots_folder(const char *screenshots)
|
||||
{
|
||||
// Check Screenshots Folder
|
||||
struct stat obj;
|
||||
if (stat(screenshots, &obj) != 0 || !S_ISDIR(obj.st_mode))
|
||||
{
|
||||
// Create Screenshots Folder
|
||||
#ifdef _WIN32
|
||||
int ret = mkdir(screenshots);
|
||||
#else
|
||||
int ret = mkdir(screenshots, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
#endif
|
||||
if (ret != 0)
|
||||
{
|
||||
// Unable To Create Folder
|
||||
LogMsg("Error Creating Directory: %s: %s", screenshots, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Take Screenshot
|
||||
static int save_png(const char *filename, unsigned char *pixels, int line_size, int width, int height)
|
||||
{
|
||||
@@ -110,6 +88,28 @@ ret:
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Ensure Screenshots Folder Exists
|
||||
void AppPlatform_sdl::ensureDirectoryExists(const char* path)
|
||||
{
|
||||
// Check Screenshots Folder
|
||||
struct stat obj;
|
||||
if (stat(screenshots, &obj) != 0 || !S_ISDIR(obj.st_mode))
|
||||
{
|
||||
// Create Screenshots Folder
|
||||
#ifdef _WIN32
|
||||
int ret = mkdir(screenshots);
|
||||
#else
|
||||
int ret = mkdir(screenshots, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
#endif
|
||||
if (ret != 0)
|
||||
{
|
||||
// Unable To Create Folder
|
||||
LogMsg("Error Creating Directory: %s: %s", screenshots, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AppPlatform_sdl::saveScreenshot(const std::string& filename, int glWidth, int glHeight)
|
||||
{
|
||||
// Get Directory
|
||||
|
||||
Reference in New Issue
Block a user