[deploy] update Resource

This commit is contained in:
Nomango 2020-04-07 16:39:44 +08:00
parent 9a0c5b2023
commit 530fca11cc
5 changed files with 14 additions and 14 deletions

View File

@ -26,11 +26,11 @@ namespace kiwano
{
Resource::Resource()
: id_(0)
, type_(nullptr)
, type_()
{
}
Resource::Resource(uint32_t id, const wchar_t* type)
Resource::Resource(uint32_t id, const String& type)
: id_(id)
, type_(type)
{
@ -45,7 +45,7 @@ Resource::Data Resource::GetData() const
break;
}
HRSRC res_info = FindResourceW(nullptr, MAKEINTRESOURCE(id_), type_);
HRSRC res_info = FindResourceA(nullptr, MAKEINTRESOURCEA(id_), type_.data());
if (res_info == nullptr)
{
KGE_ERROR("FindResource failed");

View File

@ -49,7 +49,7 @@ public:
Data();
operator bool() const;
bool IsValid() const;
};
/// \~chinese
@ -60,7 +60,7 @@ public:
/// @brief 构造资源
/// @param id 资源 ID
/// @param type 资源类型
Resource(uint32_t id, const wchar_t* type);
Resource(uint32_t id, const String& type);
/// \~chinese
/// @brief 获取资源的二进制数据
@ -73,11 +73,11 @@ public:
/// \~chinese
/// @brief 获取资源类型
const wchar_t* GetType() const;
String GetType() const;
private:
uint32_t id_;
const wchar_t* type_;
uint32_t id_;
String type_;
mutable Resource::Data data_;
};
@ -88,7 +88,7 @@ inline Resource::Data::Data()
{
}
inline Resource::Data::operator bool() const
inline bool Resource::Data::IsValid() const
{
return buffer != nullptr && size;
}
@ -98,7 +98,7 @@ inline uint32_t Resource::GetId() const
return id_;
}
inline const wchar_t* Resource::GetType() const
inline String Resource::GetType() const
{
return type_;
}

View File

@ -177,7 +177,7 @@ bool FileSystem::ExtractResourceToFile(const Resource& res, const String& dest_f
return false;
Resource::Data data = res.GetData();
if (data)
if (data.IsValid())
{
DWORD written_bytes = 0;
::WriteFile(file_handle, data.buffer, data.size, &written_bytes, NULL);

View File

@ -824,7 +824,7 @@ ResourceFontFileStream::ResourceFontFileStream()
STDMETHODIMP ResourceFontFileStream::Initialize(const Resource resource)
{
Resource::Data data = resource.GetData();
HRESULT hr = data ? S_OK : E_FAIL;
HRESULT hr = data.IsValid() ? S_OK : E_FAIL;
if (SUCCEEDED(hr))
{

View File

@ -220,7 +220,7 @@ void RendererImpl::CreateTexture(Texture& texture, const Resource& resource)
{
Resource::Data data = resource.GetData();
hr = data ? S_OK : E_FAIL;
hr = data.IsValid() ? S_OK : E_FAIL;
if (SUCCEEDED(hr))
{
@ -308,7 +308,7 @@ void RendererImpl::CreateGifImage(GifImage& gif, const Resource& resource)
{
Resource::Data data = resource.GetData();
hr = data ? S_OK : E_FAIL;
hr = data.IsValid() ? S_OK : E_FAIL;
if (SUCCEEDED(hr))
{