Skip to content

Commit

Permalink
LayerManager progress 2
Browse files Browse the repository at this point in the history
layer locking and shit works now yay
very prone to crashing tho

new binding processSelectObjects
  • Loading branch information
CattoDev committed Oct 9, 2023
1 parent 675d064 commit 149079c
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 178 deletions.
47 changes: 30 additions & 17 deletions src/features/LayerManager/LayerEditPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ void LayerEditPopup::setup() {

m_buttonMenu->addChild(resetBtn);

registerWithTouchDispatcher();
this->registerWithTouchDispatcher();
CCDirector::sharedDirector()->getTouchDispatcher()->incrementForcePrio(2);

setKeypadEnabled(true);
setTouchEnabled(true);
this->setKeypadEnabled(true);
this->setTouchEnabled(true);

if (m_eLayer->m_name.size())
m_nameInput->setString(m_eLayer->m_name.c_str());
Expand All @@ -160,15 +160,17 @@ void LayerEditPopup::setup() {

m_opacitySlider->updateBar();

sliderChanged(nullptr);
this->sliderChanged(nullptr);
updateLockSprite(m_lockBtn, m_eLayer);
updateShowSprite(m_showBtn, m_eLayer);
}

void LayerEditPopup::onShow(CCObject* pSender) {
auto btn = as<CCMenuItemSpriteExtra*>(pSender);

if (!m_eLayer) return;
if (!m_eLayer) {
return;
}

m_eLayer->m_visible = !m_eLayer->m_visible;

Expand All @@ -178,7 +180,9 @@ void LayerEditPopup::onShow(CCObject* pSender) {
void LayerEditPopup::onLock(CCObject* pSender) {
auto btn = as<CCMenuItemSpriteExtra*>(pSender);

if (!m_eLayer) return;
if (!m_eLayer) {
return;
}

m_eLayer->m_locked = !m_eLayer->m_locked;

Expand All @@ -188,9 +192,11 @@ void LayerEditPopup::onLock(CCObject* pSender) {
void LayerEditPopup::sliderChanged(CCObject* pSender) {
auto winSize = CCDirector::sharedDirector()->getWinSize();

if (!m_eLayer) return;
if (!m_eLayer) {
return;
}

auto o = static_cast<int>(getSliderValue() * 255);
auto o = static_cast<int>(this->getSliderValue() * 255);

// for the mfs with slider limit bypass
if (o < 0) o = 0;
Expand Down Expand Up @@ -218,17 +224,18 @@ float LayerEditPopup::getSliderValue() {
void LayerEditPopup::onResetOpacity(CCObject* pSender) {
m_opacitySlider->setValue(LayerManager::get()->default_opacity / 255.0f);
m_opacitySlider->updateBar();
sliderChanged(nullptr);
this->sliderChanged(nullptr);
}

void LayerEditPopup::onReset(CCObject* pSender) {
m_nameInput->setString("");
onResetOpacity(pSender);
this->onResetOpacity(pSender);
}

void LayerEditPopup::onClose(CCObject*) {
if (m_viewPopup)
if (m_viewPopup) {
m_viewPopup->updateLayerItem(m_eLayer->m_layerNumber, m_eLayer);
}

BrownAlertDelegate::onClose(nullptr);
}
Expand All @@ -238,18 +245,22 @@ void LayerEditPopup::textChanged(CCTextInputNode* pInput) {
case s_opacityInputTag: {
int o = LayerManager::get()->default_opacity;

if (!m_eLayer) return;
if (!m_eLayer) {
return;
}

try { o = std::stoi(pInput->getString()); } catch (...) {}

// for the mfs with mhv6 character filter & text length bypass
if (o < 0) o = 0;
if (o > 255) o = 255;

if (o == LayerManager::get()->default_opacity)
if (o == LayerManager::get()->default_opacity) {
m_eLayer->m_opacity = LayerManager::use_default_opacity;
else
}
else {
m_eLayer->m_opacity = o;
}

m_opacitySlider->setValue(o / 255.0f);
m_opacitySlider->updateBar();
Expand All @@ -261,10 +272,12 @@ void LayerEditPopup::textChanged(CCTextInputNode* pInput) {
} break;

case s_nameInputTag: {
if (m_nameInput->getString() && strlen(m_nameInput->getString()))
if (m_nameInput->getString() && strlen(m_nameInput->getString())) {
m_eLayer->m_name = m_nameInput->getString();
else
}
else {
m_eLayer->m_name = "";
}
} break;
}
}
Expand All @@ -283,4 +296,4 @@ LayerEditPopup* LayerEditPopup::create(LayerViewPopup* popup, LayerManager::Laye

CC_SAFE_DELETE(pRet);
return nullptr;
}
}
Loading

0 comments on commit 149079c

Please sign in to comment.