add LoadImage wrapper in CKTexture
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
#include "CKTexture.hpp"
|
||||
#include "../CKStateChunk.hpp"
|
||||
#include "../CKContext.hpp"
|
||||
#include "../MgrImpls/CKPathManager.hpp"
|
||||
|
||||
namespace LibCmo::CK2::ObjImpls {
|
||||
|
||||
@ -330,6 +332,24 @@ namespace LibCmo::CK2::ObjImpls {
|
||||
return m_ImageHost;
|
||||
}
|
||||
|
||||
bool CKTexture::LoadImage(CKSTRING filename, CKDWORD slot) {
|
||||
// check file name
|
||||
if (filename == nullptr) return false;
|
||||
// check slot
|
||||
if (slot >= m_ImageHost.GetSlotCount()) return false;
|
||||
|
||||
// resolve file name first
|
||||
XContainer::XString filepath;
|
||||
XContainer::NSXString::FromCKSTRING(filepath, filename);
|
||||
if (!m_Context->GetPathManager()->ResolveFileName(filepath)) return false;
|
||||
|
||||
// try loading image
|
||||
if (!m_ImageHost.LoadImage(XContainer::NSXString::ToCKSTRING(filepath), slot)) return false;
|
||||
|
||||
// sync file name
|
||||
return m_ImageHost.SetSlotFileName(slot, XContainer::NSXString::ToCKSTRING(filepath));
|
||||
}
|
||||
|
||||
bool CKTexture::IsUseMipmap() const {
|
||||
return m_UseMipMap;
|
||||
}
|
||||
|
@ -21,6 +21,14 @@ namespace LibCmo::CK2::ObjImpls {
|
||||
|
||||
CKBitmapData& GetUnderlyingData();
|
||||
|
||||
/**
|
||||
* @brief A wrapper of underlying CKBitmapData::LoadImage. Not only load image, but also set file name.
|
||||
* @param filename[in] File name of loading image.
|
||||
* @param slot[in] The slot that image will be loaded into.
|
||||
* @return True if success.
|
||||
*/
|
||||
bool LoadImage(CKSTRING filename, CKDWORD slot);
|
||||
|
||||
bool IsUseMipmap() const;
|
||||
void UseMipmap(bool isUse);
|
||||
CKDWORD GetMipmapLevel() const;
|
||||
|
Reference in New Issue
Block a user