mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-15 03:25:01 -05:00
addSideArt overload for styling
This commit is contained in:
parent
77e7c6d969
commit
f79e87af93
2 changed files with 47 additions and 10 deletions
|
@ -27,6 +27,13 @@ namespace geode {
|
|||
return static_cast<bool>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
enum class SideArtStyle {
|
||||
Layer,
|
||||
LayerGray,
|
||||
PopupBlue,
|
||||
PopupGold,
|
||||
};
|
||||
|
||||
/**
|
||||
* Add side art (corner pieces) for a layer
|
||||
* @param to Layer to add corner pieces to
|
||||
|
@ -34,7 +41,25 @@ namespace geode {
|
|||
* @param useAnchorLayout If true, `to` is given an `AnchorLayout` and the
|
||||
* corners' positions are dynamically updated
|
||||
*/
|
||||
GEODE_DLL void addSideArt(cocos2d::CCNode* to, SideArt sides = SideArt::All, bool useAnchorLayout = false);
|
||||
GEODE_DLL void addSideArt(
|
||||
cocos2d::CCNode* to,
|
||||
SideArt sides = SideArt::All,
|
||||
bool useAnchorLayout = false
|
||||
);
|
||||
/**
|
||||
* Add side art (corner pieces) for a layer
|
||||
* @param to Layer to add corner pieces to
|
||||
* @param sides Which corners to populate; by default, populates all
|
||||
* @param style Which side art sprites to use
|
||||
* @param useAnchorLayout If true, `to` is given an `AnchorLayout` and the
|
||||
* corners' positions are dynamically updated
|
||||
*/
|
||||
GEODE_DLL void addSideArt(
|
||||
cocos2d::CCNode* to,
|
||||
SideArt sides,
|
||||
SideArtStyle style,
|
||||
bool useAnchorLayout = false
|
||||
);
|
||||
|
||||
/**
|
||||
* Add the rounded comment borders to a node
|
||||
|
|
|
@ -18,28 +18,40 @@ CCSprite* geode::createLayerBG() {
|
|||
return bg;
|
||||
}
|
||||
|
||||
void geode::addSideArt(CCNode* to, SideArt sides, bool useAnchorLayout) {
|
||||
void geode::addSideArt(CCNode* to, SideArt sides, SideArtStyle style, bool useAnchorLayout) {
|
||||
const char* sprite;
|
||||
float offset;
|
||||
switch (style) {
|
||||
default:
|
||||
case SideArtStyle::Layer: sprite = "GJ_sideArt_001.png"; offset = 35; break;
|
||||
case SideArtStyle::LayerGray: sprite = "gauntletCorner_001.png"; offset = 35; break;
|
||||
case SideArtStyle::PopupBlue: sprite = "rewardCorner_001.png"; offset = 24.75f; break;
|
||||
case SideArtStyle::PopupGold: sprite = "dailyLevelCorner_001.png"; offset = 24.75f; break;
|
||||
}
|
||||
if (sides & SideArt::BottomLeft) {
|
||||
auto spr = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
|
||||
to->addChildAtPosition(spr, Anchor::BottomLeft, ccp(35, 35), useAnchorLayout);
|
||||
auto spr = CCSprite::createWithSpriteFrameName(sprite);
|
||||
to->addChildAtPosition(spr, Anchor::BottomLeft, ccp(offset, offset), useAnchorLayout);
|
||||
}
|
||||
if (sides & SideArt::BottomRight) {
|
||||
auto spr = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
|
||||
auto spr = CCSprite::createWithSpriteFrameName(sprite);
|
||||
spr->setFlipX(true);
|
||||
to->addChildAtPosition(spr, Anchor::BottomRight, ccp(-35, 35), useAnchorLayout);
|
||||
to->addChildAtPosition(spr, Anchor::BottomRight, ccp(-offset, offset), useAnchorLayout);
|
||||
}
|
||||
if (sides & SideArt::TopLeft) {
|
||||
auto spr = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
|
||||
auto spr = CCSprite::createWithSpriteFrameName(sprite);
|
||||
spr->setFlipY(true);
|
||||
to->addChildAtPosition(spr, Anchor::TopLeft, ccp(35, -35), useAnchorLayout);
|
||||
to->addChildAtPosition(spr, Anchor::TopLeft, ccp(offset, -offset), useAnchorLayout);
|
||||
}
|
||||
if (sides & SideArt::TopRight) {
|
||||
auto spr = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
|
||||
auto spr = CCSprite::createWithSpriteFrameName(sprite);
|
||||
spr->setFlipX(true);
|
||||
spr->setFlipY(true);
|
||||
to->addChildAtPosition(spr, Anchor::TopRight, ccp(-35, -35), useAnchorLayout);
|
||||
to->addChildAtPosition(spr, Anchor::TopRight, ccp(-offset, -offset), useAnchorLayout);
|
||||
}
|
||||
}
|
||||
void geode::addSideArt(CCNode* to, SideArt sides, bool useAnchorLayout) {
|
||||
return addSideArt(to, sides, SideArtStyle::Layer, useAnchorLayout);
|
||||
}
|
||||
|
||||
void geode::addListBorders(CCNode* to, CCPoint const& center, CCSize const& size) {
|
||||
// if the size is 346.f, the top aligns perfectly by default :3
|
||||
|
|
Loading…
Reference in a new issue