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:
Brent Da Mage
2023-08-19 06:26:50 -05:00
committed by iProgramInCpp
parent e731fefbea
commit d5ee7bfc08
21 changed files with 422 additions and 375 deletions

View File

@@ -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