Make resource interface based on "char *" as it is easier to detect a nullptr.
Can't change the return type to std::string. Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
a5eaf8a011
commit
40d3e822e9
7 changed files with 20 additions and 23 deletions
|
@ -6,13 +6,13 @@
|
|||
|
||||
#include "Log.h"
|
||||
|
||||
HRSRC FindResource(void *, const std::string & filename, const char *)
|
||||
HRSRC FindResource(void *, const char * filename, const char *)
|
||||
{
|
||||
HRSRC result;
|
||||
|
||||
if (!filename.empty())
|
||||
if (filename)
|
||||
{
|
||||
const std::string path = "resource/" + filename;
|
||||
const std::string path = std::string("resource/") + filename;
|
||||
|
||||
int fd = open(path.c_str(), O_RDONLY);
|
||||
|
||||
|
@ -31,15 +31,15 @@ HRSRC FindResource(void *, const std::string & filename, const char *)
|
|||
|
||||
if (result.data.empty())
|
||||
{
|
||||
LogFileOutput("FindResource: could not load resource %s\n", filename.c_str());
|
||||
LogFileOutput("FindResource: could not load resource %s\n", filename);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
HBITMAP LoadBitmap(HINSTANCE hInstance, const std::string & filename)
|
||||
HBITMAP LoadBitmap(HINSTANCE hInstance, const char * filename)
|
||||
{
|
||||
LogFileOutput("LoadBitmap: not loading resource %s\n", filename.c_str());
|
||||
LogFileOutput("LoadBitmap: not loading resource %s\n", filename);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
#include "Log.h"
|
||||
|
||||
HRSRC FindResource(void *, const std::string & filename, const char *)
|
||||
HRSRC FindResource(void *, const char * filename, const char *)
|
||||
{
|
||||
HRSRC result;
|
||||
|
||||
if (!filename.empty())
|
||||
if (filename)
|
||||
{
|
||||
const std::string path = ":/resources/" + filename;
|
||||
const std::string path = std::string(":/resources/") + filename;
|
||||
|
||||
QFile res(QString::fromStdString(path));
|
||||
if (res.exists() && res.open(QIODevice::ReadOnly))
|
||||
|
@ -23,7 +23,7 @@ HRSRC FindResource(void *, const std::string & filename, const char *)
|
|||
|
||||
if (result.data.empty())
|
||||
{
|
||||
LogFileOutput("FindResource: could not load resource %s\n", filename.c_str());
|
||||
LogFileOutput("FindResource: could not load resource %s\n", filename);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -34,20 +34,20 @@ struct CBITMAP : public CHANDLE
|
|||
QImage image;
|
||||
};
|
||||
|
||||
HBITMAP LoadBitmap(HINSTANCE hInstance, const std::string & filename)
|
||||
HBITMAP LoadBitmap(HINSTANCE hInstance, const char * filename)
|
||||
{
|
||||
Q_UNUSED(hInstance)
|
||||
|
||||
QImage image;
|
||||
if (!filename.empty())
|
||||
if (filename)
|
||||
{
|
||||
const std::string path = ":/resources/" + filename + ".BMP";
|
||||
const std::string path = std::string(":/resources/") + filename + ".BMP";
|
||||
image = QImage(QString::fromStdString(path));
|
||||
}
|
||||
|
||||
if (image.isNull())
|
||||
{
|
||||
LogFileOutput("LoadBitmap: could not load resource %s\n", filename.c_str());
|
||||
LogFileOutput("LoadBitmap: could not load resource %s\n", filename);
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
// Resources
|
||||
|
||||
HRSRC FindResource(void *, const std::string & filename, const char *);
|
||||
HRSRC FindResource(void *, const char * filename, const char *);
|
||||
|
||||
// Bitmap
|
||||
HBITMAP LoadBitmap(HINSTANCE hInstance, const std::string & filename);
|
||||
HBITMAP LoadBitmap(HINSTANCE hInstance, const char * filename);
|
||||
LONG GetBitmapBits(HBITMAP hbit, LONG cb, LPVOID lpvBits);
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ typedef HANDLE HBITMAP;
|
|||
typedef HANDLE HGDIOBJ;
|
||||
|
||||
// Bitmap
|
||||
HBITMAP LoadBitmap(HINSTANCE hInstance, const std::string & filename);
|
||||
HBITMAP LoadBitmap(HINSTANCE hInstance, const char * filename);
|
||||
LONG GetBitmapBits(HBITMAP hbit, LONG cb, LPVOID lpvBits);
|
||||
|
||||
BOOL DeleteObject(HGDIOBJ ho);
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
#include "../resource/resource.h"
|
||||
#include "Log.h"
|
||||
|
||||
// forward declared
|
||||
HRSRC FindResource(void *, const std::string & filename, const char *);
|
||||
|
||||
const char * MAKEINTRESOURCE(int x)
|
||||
{
|
||||
switch (x)
|
||||
|
|
|
@ -19,7 +19,7 @@ struct HRSRC : public CHANDLE
|
|||
};
|
||||
|
||||
const char * MAKEINTRESOURCE(int x);
|
||||
HRSRC FindResource(void *, const std::string & filename, const char *);
|
||||
HRSRC FindResource(void *, const char * filename, const char *);
|
||||
DWORD SizeofResource(void *, const HRSRC &);
|
||||
HGLOBAL LoadResource(void *, HRSRC &);
|
||||
BYTE * LockResource(HGLOBAL);
|
||||
|
|
|
@ -10,7 +10,7 @@ void unregisterSoundBuffer(IDirectSoundBuffer * buffer)
|
|||
|
||||
// Resources
|
||||
|
||||
HRSRC FindResource(void *, const std::string & filename, const char *)
|
||||
HRSRC FindResource(void *, const char * filename, const char *)
|
||||
{
|
||||
return HRSRC();
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ int MessageBox(HWND, const char * text, const char * caption, UINT type) { retur
|
|||
|
||||
// Bitmap
|
||||
|
||||
HBITMAP LoadBitmap(HINSTANCE hInstance, const std::string & filename)
|
||||
HBITMAP LoadBitmap(HINSTANCE hInstance, const char * filename)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue