修复切换场景时按钮回调函数执行两次的BUG
This commit is contained in:
parent
26ed76ae2b
commit
f5752252a2
|
|
@ -46,7 +46,7 @@ e2d::Image::~Image()
|
||||||
|
|
||||||
bool e2d::Image::open(const Resource& res)
|
bool e2d::Image::open(const Resource& res)
|
||||||
{
|
{
|
||||||
if (!res.isResource())
|
if (res.isFile())
|
||||||
{
|
{
|
||||||
WARN_IF(res.getFileName().isEmpty(), "Image open failed! Invalid file name.");
|
WARN_IF(res.getFileName().isEmpty(), "Image open failed! Invalid file name.");
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ bool e2d::Image::preload(const Resource& res)
|
||||||
ID2D1Bitmap *pBitmap = nullptr;
|
ID2D1Bitmap *pBitmap = nullptr;
|
||||||
IWICImagingFactory *pImagingFactory = Renderer::getImagingFactory();
|
IWICImagingFactory *pImagingFactory = Renderer::getImagingFactory();
|
||||||
|
|
||||||
if (res.isResource())
|
if (!res.isFile())
|
||||||
{
|
{
|
||||||
HRSRC imageResHandle = nullptr;
|
HRSRC imageResHandle = nullptr;
|
||||||
HGLOBAL imageResDataHandle = nullptr;
|
HGLOBAL imageResDataHandle = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "..\e2dtool.h"
|
#include "..\e2dtool.h"
|
||||||
|
|
||||||
e2d::Resource::Resource(const String & fileName)
|
e2d::Resource::Resource(const String & fileName)
|
||||||
: _isResource(false)
|
: _isFile(true)
|
||||||
, _fileName(fileName)
|
, _fileName(fileName)
|
||||||
, _resNameId(0)
|
, _resNameId(0)
|
||||||
, _resType()
|
, _resType()
|
||||||
|
|
@ -9,16 +9,16 @@ e2d::Resource::Resource(const String & fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Resource::Resource(size_t resNameId, const String & resType)
|
e2d::Resource::Resource(size_t resNameId, const String & resType)
|
||||||
: _isResource(true)
|
: _isFile(false)
|
||||||
, _fileName()
|
, _fileName()
|
||||||
, _resNameId(resNameId)
|
, _resNameId(resNameId)
|
||||||
, _resType(resType)
|
, _resType(resType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Resource::isResource() const
|
bool e2d::Resource::isFile() const
|
||||||
{
|
{
|
||||||
return _isResource;
|
return _isFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::String & e2d::Resource::getFileName() const
|
const e2d::String & e2d::Resource::getFileName() const
|
||||||
|
|
@ -38,7 +38,7 @@ const e2d::String & e2d::Resource::getResType() const
|
||||||
|
|
||||||
size_t e2d::Resource::getKey() const
|
size_t e2d::Resource::getKey() const
|
||||||
{
|
{
|
||||||
return _isResource ? _resNameId : _fileName.getHashCode();
|
return _isFile ? _fileName.getHashCode() : _resNameId;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Resource::operator>(const Resource &res) const
|
bool e2d::Resource::operator>(const Resource &res) const
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ void e2d::SceneManager::push(Scene * scene, Transition * transition /* = nullptr
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 保存下一场景的指针
|
// 保存下一场景的指针
|
||||||
|
if (_nextScene) _nextScene->release();
|
||||||
_nextScene = scene;
|
_nextScene = scene;
|
||||||
_nextScene->retain();
|
_nextScene->retain();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -191,10 +191,9 @@ void e2d::Button::_fixedUpdate()
|
||||||
if (_isSelected &&
|
if (_isSelected &&
|
||||||
_normal->containsPoint(input->getMousePos()))
|
_normal->containsPoint(input->getMousePos()))
|
||||||
{
|
{
|
||||||
|
_isSelected = false;
|
||||||
_runCallback();
|
_runCallback();
|
||||||
}
|
}
|
||||||
// 标记 _isSelected 为 false
|
|
||||||
_isSelected = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->isPress(MouseCode::Left))
|
if (input->isPress(MouseCode::Left))
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ bool e2d::Music::open(const Resource& res)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.isResource())
|
if (!res.isFile())
|
||||||
{
|
{
|
||||||
HRSRC hResInfo;
|
HRSRC hResInfo;
|
||||||
HGLOBAL hResData;
|
HGLOBAL hResData;
|
||||||
|
|
|
||||||
|
|
@ -803,8 +803,8 @@ public:
|
||||||
const String& resType /* ×ÊÔ´ÀàÐÍ */
|
const String& resType /* ×ÊÔ´ÀàÐÍ */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 是否是资源类型
|
// 是否是本地文件
|
||||||
bool isResource() const;
|
bool isFile() const;
|
||||||
|
|
||||||
const String& getFileName() const;
|
const String& getFileName() const;
|
||||||
|
|
||||||
|
|
@ -821,7 +821,7 @@ public:
|
||||||
bool operator<= (const Resource &) const;
|
bool operator<= (const Resource &) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _isResource;
|
bool _isFile;
|
||||||
size_t _resNameId;
|
size_t _resNameId;
|
||||||
String _resType;
|
String _resType;
|
||||||
String _fileName;
|
String _fileName;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue