[deploy] update Resource
This commit is contained in:
parent
9a0c5b2023
commit
530fca11cc
|
|
@ -26,11 +26,11 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
Resource::Resource()
|
Resource::Resource()
|
||||||
: id_(0)
|
: id_(0)
|
||||||
, type_(nullptr)
|
, type_()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Resource::Resource(uint32_t id, const wchar_t* type)
|
Resource::Resource(uint32_t id, const String& type)
|
||||||
: id_(id)
|
: id_(id)
|
||||||
, type_(type)
|
, type_(type)
|
||||||
{
|
{
|
||||||
|
|
@ -45,7 +45,7 @@ Resource::Data Resource::GetData() const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRSRC res_info = FindResourceW(nullptr, MAKEINTRESOURCE(id_), type_);
|
HRSRC res_info = FindResourceA(nullptr, MAKEINTRESOURCEA(id_), type_.data());
|
||||||
if (res_info == nullptr)
|
if (res_info == nullptr)
|
||||||
{
|
{
|
||||||
KGE_ERROR("FindResource failed");
|
KGE_ERROR("FindResource failed");
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
Data();
|
Data();
|
||||||
|
|
||||||
operator bool() const;
|
bool IsValid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -60,7 +60,7 @@ public:
|
||||||
/// @brief 构造资源
|
/// @brief 构造资源
|
||||||
/// @param id 资源 ID
|
/// @param id 资源 ID
|
||||||
/// @param type 资源类型
|
/// @param type 资源类型
|
||||||
Resource(uint32_t id, const wchar_t* type);
|
Resource(uint32_t id, const String& type);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取资源的二进制数据
|
/// @brief 获取资源的二进制数据
|
||||||
|
|
@ -73,11 +73,11 @@ public:
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取资源类型
|
/// @brief 获取资源类型
|
||||||
const wchar_t* GetType() const;
|
String GetType() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t id_;
|
uint32_t id_;
|
||||||
const wchar_t* type_;
|
String type_;
|
||||||
|
|
||||||
mutable Resource::Data data_;
|
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;
|
return buffer != nullptr && size;
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +98,7 @@ inline uint32_t Resource::GetId() const
|
||||||
return id_;
|
return id_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const wchar_t* Resource::GetType() const
|
inline String Resource::GetType() const
|
||||||
{
|
{
|
||||||
return type_;
|
return type_;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ bool FileSystem::ExtractResourceToFile(const Resource& res, const String& dest_f
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Resource::Data data = res.GetData();
|
Resource::Data data = res.GetData();
|
||||||
if (data)
|
if (data.IsValid())
|
||||||
{
|
{
|
||||||
DWORD written_bytes = 0;
|
DWORD written_bytes = 0;
|
||||||
::WriteFile(file_handle, data.buffer, data.size, &written_bytes, NULL);
|
::WriteFile(file_handle, data.buffer, data.size, &written_bytes, NULL);
|
||||||
|
|
|
||||||
|
|
@ -824,7 +824,7 @@ ResourceFontFileStream::ResourceFontFileStream()
|
||||||
STDMETHODIMP ResourceFontFileStream::Initialize(const Resource resource)
|
STDMETHODIMP ResourceFontFileStream::Initialize(const Resource resource)
|
||||||
{
|
{
|
||||||
Resource::Data data = resource.GetData();
|
Resource::Data data = resource.GetData();
|
||||||
HRESULT hr = data ? S_OK : E_FAIL;
|
HRESULT hr = data.IsValid() ? S_OK : E_FAIL;
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ void RendererImpl::CreateTexture(Texture& texture, const Resource& resource)
|
||||||
{
|
{
|
||||||
Resource::Data data = resource.GetData();
|
Resource::Data data = resource.GetData();
|
||||||
|
|
||||||
hr = data ? S_OK : E_FAIL;
|
hr = data.IsValid() ? S_OK : E_FAIL;
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
|
|
@ -308,7 +308,7 @@ void RendererImpl::CreateGifImage(GifImage& gif, const Resource& resource)
|
||||||
{
|
{
|
||||||
Resource::Data data = resource.GetData();
|
Resource::Data data = resource.GetData();
|
||||||
|
|
||||||
hr = data ? S_OK : E_FAIL;
|
hr = data.IsValid() ? S_OK : E_FAIL;
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue