diff --git a/yg/skin.cpp b/yg/skin.cpp index 9ff3b2a019..04f2b6ac26 100644 --- a/yg/skin.cpp +++ b/yg/skin.cpp @@ -30,12 +30,26 @@ namespace yg m_resourceManager(resourceManager) { m_startTextPage = m_currentTextPage = m_pages.size(); - addDynamicPages(m_textPagesCount); + addTextPages(m_textPagesCount); m_startDynamicPage = m_currentDynamicPage = m_pages.size(); addDynamicPages(m_dynamicPagesCount); } + void Skin::addTextPages(int count) + { + m_pages.reserve(m_pages.size() + count); + + addClearPageFn(bind(&Skin::clearPageHandles, this, _1), 0); + + for (size_t i = 0; i < count; ++i) + { + uint8_t pageID = (uint8_t)m_pages.size(); + m_pages.push_back(make_shared_ptr(new SkinPage(m_resourceManager, pageID))); + m_pages.back()->addOverflowFn(bind(&Skin::changeCurrentTextPage, this), 0); + } + } + void Skin::addDynamicPages(int count) { m_pages.reserve(m_pages.size() + count); @@ -46,7 +60,7 @@ namespace yg { uint8_t pageID = (uint8_t)m_pages.size(); m_pages.push_back(make_shared_ptr(new SkinPage(m_resourceManager, pageID))); - m_pages.back()->addOverflowFn(bind(&Skin::onOverflow, this, pageID), 0); + m_pages.back()->addOverflowFn(bind(&Skin::changeCurrentDynamicPage, this), 0); } } @@ -180,11 +194,12 @@ namespace yg /// Called from the skin page on handles overflow. /// Never called on texture overflow, as this situation /// are explicitly checked in the mapXXX() functions. - void Skin::onOverflow(uint8_t pageID) +/* void Skin::onOverflow(uint8_t pageID) { LOG(LINFO, ("Called from SkinPage as a reaction on handles overflow for pageID=", (uint32_t)pageID)); changeCurrentDynamicPage(); } + */ void Skin::changeCurrentDynamicPage() { diff --git a/yg/skin.hpp b/yg/skin.hpp index e042b5e68e..2b5a70ac8b 100644 --- a/yg/skin.hpp +++ b/yg/skin.hpp @@ -70,6 +70,7 @@ namespace yg friend class SkinLoader; void addDynamicPages(int count); + void addTextPages(int count); typedef pair id_pair_t; id_pair_t unpackID(uint32_t id) const; @@ -92,7 +93,7 @@ namespace yg void callOverflowFns(uint8_t pageID); void clearPageHandles(uint8_t pageID); - void onOverflow(uint8_t pageID); +// void onOverflow(uint8_t pageID); void changeCurrentDynamicPage(); void changeCurrentTextPage(); diff --git a/yg/skin_page.cpp b/yg/skin_page.cpp index ba732713b5..46c9a12ed5 100644 --- a/yg/skin_page.cpp +++ b/yg/skin_page.cpp @@ -315,7 +315,10 @@ namespace yg bool SkinPage::hasRoom(const PenInfo &penInfo) const { if (penInfo.m_isSolid) - return hasRoom(penInfo.m_color); + { + return m_packer.hasRoom(penInfo.m_w + 4, penInfo.m_w + 4); + // return hasRoom(penInfo.m_color); + } else { uint32_t len = static_cast(accumulate(penInfo.m_pat.begin(), penInfo.m_pat.end(), 0.0));