Skip to content

Commit

Permalink
re-add corners to bi layers
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Dec 17, 2023
1 parent a11606a commit 8c97d90
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 36 deletions.
27 changes: 0 additions & 27 deletions src/layers/CustomCreatorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,33 +114,6 @@ bool CustomCreatorLayer::init() {
infoBtn->setSizeMult(1.2f);
infoBtn->setID("bi-info-button");

auto cornerBL = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
cornerBL->setPosition({0,0});
cornerBL->setAnchorPoint({0,0});
addChild(cornerBL, -1);
cornerBL->setID("bi-corner-bl");

auto cornerUL = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
cornerUL->setPosition({0,winSize.height});
cornerUL->setAnchorPoint({0,0});
cornerUL->setRotation(90);
cornerUL->setID("bi-corner-ul");
addChild(cornerUL, -1);

auto cornerUR = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
cornerUR->setPosition({winSize.width,winSize.height});
cornerUR->setAnchorPoint({0,0});
cornerUR->setRotation(180);
cornerUR->setID("bi-corner-ur");
addChild(cornerUR, -1);

auto cornerBR = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
cornerBR->setPosition({winSize.width,0});
cornerBR->setAnchorPoint({0,0});
cornerBR->setRotation(270);
cornerBR->setID("bi-corner-br");
addChild(cornerBR, -1);

return true;
}

Expand Down
45 changes: 40 additions & 5 deletions src/layers/_bases/BIBaseLayer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "BIBaseLayer.h"

BIBaseLayer* BIBaseLayer::create() {
BIBaseLayer* BIBaseLayer::create(bool BL, bool BR, bool TL, bool TR) {
auto ret = new BIBaseLayer();
if (ret && ret->init()) {
if (ret && ret->init(BL, BR, TL, TR)) {
ret->autorelease();
} else {
delete ret;
Expand All @@ -11,7 +11,7 @@ BIBaseLayer* BIBaseLayer::create() {
return ret;
}

bool BIBaseLayer::init() {
bool BIBaseLayer::init(bool BL, bool BR, bool TL, bool TR) {
auto backgroundSprite = CCSprite::create("game_bg_14_001.png");

auto winSize = CCDirector::sharedDirector()->getWinSize();
Expand All @@ -37,13 +37,48 @@ bool BIBaseLayer::init() {
menuBack->addChild(backBtn);
menuBack->setPosition({25, winSize.height - 25});

m_cornerBL = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
m_cornerBL->setPosition({0,0});
m_cornerBL->setAnchorPoint({0,0});
addChild(m_cornerBL, -1);
m_cornerBL->setID("bi-corner-bl");

m_cornerTL = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
m_cornerTL->setPosition({0,winSize.height});
m_cornerTL->setAnchorPoint({0,0});
m_cornerTL->setRotation(90);
m_cornerTL->setID("bi-corner-ul");
addChild(m_cornerTL, -1);

m_cornerTR = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
m_cornerTR->setPosition({winSize.width,winSize.height});
m_cornerTR->setAnchorPoint({0,0});
m_cornerTR->setRotation(180);
m_cornerTR->setID("bi-corner-ur");
addChild(m_cornerTR, -1);

m_cornerBR = CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
m_cornerBR->setPosition({winSize.width,0});
m_cornerBR->setAnchorPoint({0,0});
m_cornerBR->setRotation(270);
m_cornerBR->setID("bi-corner-br");
addChild(m_cornerBR, -1);

addChild(menuBack);

setKeypadEnabled(true);
setCorners(BL, BR, TL, TR);

return true;
}

void BIBaseLayer::setCorners(bool BL, bool BR, bool TL, bool TR) {
m_cornerBL->setVisible(BL);
m_cornerBR->setVisible(BR);
m_cornerTL->setVisible(TL);
m_cornerTR->setVisible(TR);
}

void BIBaseLayer::keyBackClicked() {
CCDirector::sharedDirector()->popSceneWithTransition(0.5f, PopTransition::kPopTransitionFade);
}
Expand All @@ -53,8 +88,8 @@ void BIBaseLayer::onBack(CCObject* object) {
keyBackClicked();
}

CCScene* BIBaseLayer::scene() {
auto layer = BIBaseLayer::create();
CCScene* BIBaseLayer::scene(bool BL, bool BR, bool TL, bool TR) {
auto layer = BIBaseLayer::create(BL, BR, TL, TR);
auto scene = CCScene::create();
scene->addChild(layer);
return scene;
Expand Down
12 changes: 9 additions & 3 deletions src/layers/_bases/BIBaseLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ using namespace geode::prelude;

class BIBaseLayer : public cocos2d::CCLayer {
protected:
virtual bool init();
virtual bool init(bool TL = true, bool TR = true, bool BL = true, bool BR = true);
virtual void keyBackClicked();
void onBack(cocos2d::CCObject*);
public:
static BIBaseLayer* create();
static cocos2d::CCScene* scene();
static BIBaseLayer* create(bool TL = true, bool TR = true, bool BL = true, bool BR = true);
static cocos2d::CCScene* scene(bool TL = true, bool TR = true, bool BL = true, bool BR = true);
void setCorners(bool TL, bool TR, bool BL, bool BR);

CCSprite* m_cornerBL = nullptr;
CCSprite* m_cornerBR = nullptr;
CCSprite* m_cornerTL = nullptr;
CCSprite* m_cornerTR = nullptr;
};
2 changes: 1 addition & 1 deletion src/layers/_bases/BIViewLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BIViewLayer* BIViewLayer::create(bool paginated) {
}

bool BIViewLayer::init(bool paginated) {
BIBaseLayer::init();
BIBaseLayer::init(true, true, false, false);

m_paginated = paginated;

Expand Down

0 comments on commit 8c97d90

Please sign in to comment.