mirror of
https://github.com/geode-sdk/geode.git
synced 2025-02-17 00:30:26 -05:00
add CCNode::setScaledContentSize, CCNode::getScaledContentWidth etc.
This commit is contained in:
parent
6414737b0c
commit
be0880f49c
2 changed files with 27 additions and 0 deletions
13
loader/include/Geode/cocos/base_nodes/CCNode.h
vendored
13
loader/include/Geode/cocos/base_nodes/CCNode.h
vendored
|
@ -1054,10 +1054,23 @@ public:
|
|||
*/
|
||||
GEODE_DLL void swapChildIndices(CCNode* first, CCNode* second);
|
||||
|
||||
/**
|
||||
* @note Make sure to set the scale first!
|
||||
* @note Geode addition
|
||||
*/
|
||||
GEODE_DLL void setScaledContentSize(CCSize const& size);
|
||||
// @note Geode addition
|
||||
GEODE_DLL void setContentWidth(float width);
|
||||
// @note Geode addition
|
||||
GEODE_DLL void setContentHeight(float width);
|
||||
// @note Geode addition
|
||||
GEODE_DLL float getContentWidth() const;
|
||||
// @note Geode addition
|
||||
GEODE_DLL float getContentHeight() const;
|
||||
// @note Geode addition
|
||||
GEODE_DLL float getScaledContentWidth() const;
|
||||
// @note Geode addition
|
||||
GEODE_DLL float getScaledContentHeight() const;
|
||||
|
||||
template <class Filter, class... Args>
|
||||
geode::EventListenerProtocol* addEventListener(
|
||||
|
|
|
@ -50,6 +50,10 @@ bool CCNode::hasAncestor(CCNode* ancestor) {
|
|||
// these use setContentSize and getContentSize because they're virtuals and
|
||||
// some node may override those for wacky behaviour
|
||||
|
||||
void CCNode::setScaledContentSize(CCSize const& size) {
|
||||
this->setContentSize({ size.width / m_fScaleX, size.height / m_fScaleY });
|
||||
}
|
||||
|
||||
void CCNode::setContentWidth(float width) {
|
||||
this->setContentSize({ width, m_obContentSize.height });
|
||||
}
|
||||
|
@ -66,6 +70,16 @@ float CCNode::getContentHeight() const {
|
|||
return this->getContentSize().height;
|
||||
}
|
||||
|
||||
// getScaledContentSize is not const bruh
|
||||
|
||||
float CCNode::getScaledContentWidth() const {
|
||||
return this->getContentWidth() * m_fScaleX;
|
||||
}
|
||||
|
||||
float CCNode::getScaledContentHeight() const {
|
||||
return this->getContentHeight() * m_fScaleY;
|
||||
}
|
||||
|
||||
CCArray* Layout::getNodesToPosition(CCNode* on) const {
|
||||
auto arr = CCArray::create();
|
||||
for (auto child : CCArrayExt<CCNode*>(on->getChildren())) {
|
||||
|
|
Loading…
Reference in a new issue