-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
151 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
src/features/BuildTools/AutoColorTrigger/ColorTriggerPopup.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#include "ColorTriggerPopup.hpp" | ||
|
||
bool ColorTriggerPopup::setup() { | ||
this->setTitle("Auto Color Trigger"); | ||
auto winSize = CCDirector::sharedDirector()->getWinSize(); | ||
|
||
m_pRangeStartInput = CCTextInputNode::create(60.f, 60.f, "0", "bigFont.fnt"); | ||
m_pRangeStartInput->setAllowedChars("0123456789"); | ||
m_pRangeStartInput->setPosition(ccp(winSize.width / 2 - 60.0f, winSize.height / 2)); | ||
this->m_mainLayer->addChild(m_pRangeStartInput); | ||
|
||
m_pRangeEndInput = CCTextInputNode::create(60.f, 60.f, "0", "bigFont.fnt"); | ||
m_pRangeEndInput->setAllowedChars("0123456789"); | ||
m_pRangeEndInput->setPosition(ccp(winSize.width / 2 + 60.0f, winSize.height / 2)); | ||
this->m_mainLayer->addChild(m_pRangeEndInput); | ||
|
||
auto idek = CCLabelBMFont::create("-", "bigFont.fnt"); | ||
idek->setPosition(winSize / 2); | ||
idek->setScale(.7f); | ||
this->m_mainLayer->addChild(idek); | ||
|
||
auto startID = CCLabelBMFont::create("Start ID:", "goldFont.fnt"); | ||
startID->setPosition(ccp(winSize.width / 2 - 60.0f, winSize.height / 2 + 30.0f)); | ||
startID->setScale(.6f); | ||
this->m_mainLayer->addChild(startID); | ||
|
||
auto endID = CCLabelBMFont::create("End ID:", "goldFont.fnt"); | ||
endID->setPosition(ccp(winSize.width / 2 + 60.0f, winSize.height / 2 + 30.0f)); | ||
endID->setScale(.6f); | ||
this->m_mainLayer->addChild(endID); | ||
|
||
auto colorBtnSpr = ButtonSprite::create("Create", 0, 0, .8f, false, "goldFont.fnt", "GJ_button_01.png", 0.f); | ||
colorBtnSpr->setScale(.8f); | ||
|
||
auto colorBtn = CCMenuItemSpriteExtra::create(colorBtnSpr, this, menu_selector(ColorTriggerPopup::onCreate)); | ||
colorBtn->setPosition(ccp(0.0f, - 170.f / 2 + 25.0f)); | ||
this->m_buttonMenu->addChild(colorBtn); | ||
return true; | ||
} | ||
|
||
void ColorTriggerPopup::onCreate(CCObject* pSender) { | ||
int rangeStart = 0; | ||
int rangeEnd = 1012; | ||
|
||
if (this->m_pRangeStartInput && | ||
this->m_pRangeStartInput->getString() && | ||
strlen(this->m_pRangeStartInput->getString())) | ||
rangeStart = std::atoi(this->m_pRangeStartInput->getString()); | ||
|
||
if (this->m_pRangeEndInput && | ||
this->m_pRangeEndInput->getString() && | ||
strlen(this->m_pRangeEndInput->getString())) | ||
rangeEnd = std::atoi(this->m_pRangeEndInput->getString()); | ||
|
||
auto lel = GameManager::sharedState()->getEditorLayer(); | ||
|
||
auto dict = lel->m_levelSettings->m_effectManager->m_colorActions; | ||
CCDictElement* el; | ||
auto pos = lel->getObjectLayer()->convertToNodeSpace(CCDirector::sharedDirector()->getWinSize() / 2); | ||
float y = pos.y; | ||
std::stringstream ss; | ||
|
||
EditorUI::get()->deselectAll(); | ||
|
||
auto objs = CCArray::create(); | ||
|
||
for (int i = 0; i < dict->count(); i++) { | ||
auto el = dict->valueForKey(i); | ||
|
||
const auto colorID = i; | ||
if (colorID < rangeStart || colorID > rangeEnd) continue; | ||
|
||
auto color = static_cast<ColorAction*>(GJEffectManager::get()->getColorAction(i)); | ||
|
||
auto obj = static_cast<EffectGameObject*>(lel->createObject(899, { pos.x, y }, false)); | ||
|
||
obj->m_targetColorID = colorID; | ||
obj->m_colColor = color->m_color; | ||
obj->m_blending = color->m_blending; | ||
obj->m_opacity = color->m_opacity; | ||
obj->m_playerColor1 = color->m_playerColor == 1; | ||
obj->m_playerColor2 = color->m_playerColor == 2; | ||
obj->m_copyColorID = color->m_copyID; | ||
obj->m_hsvValue = color->m_copyHSV; | ||
obj->updateLabel(); | ||
|
||
if (lel->m_currentLayer != -1) | ||
obj->m_editorLayer = lel->m_currentLayer; | ||
|
||
objs->addObject(obj); | ||
|
||
y += 30.0f; | ||
} | ||
|
||
EditorUI::get()->selectObjects(objs, true); | ||
objs->release(); | ||
|
||
EditorUI::get()->updateButtons(); | ||
|
||
if (this->m_pPauseLayer) | ||
this->m_pPauseLayer->onResume(pSender); | ||
|
||
this->onClose(pSender); | ||
} | ||
|
||
void ColorTriggerPopup::onInfo(CCObject*) { | ||
|
||
} | ||
|
||
ColorTriggerPopup* ColorTriggerPopup::create(EditorPauseLayer* pl) { | ||
auto pRet = new ColorTriggerPopup(); | ||
|
||
if (pRet && pRet->init(250.0f, 170.0f)) { | ||
pRet->m_pPauseLayer = pl; | ||
pRet->autorelease(); | ||
return pRet; | ||
} | ||
|
||
CC_SAFE_DELETE(pRet); | ||
return nullptr; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/features/BuildTools/AutoColorTrigger/ColorTriggerPopup.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <Geode/Geode.hpp> | ||
|
||
using namespace geode::prelude; | ||
|
||
class ColorTriggerPopup : public Popup<> { | ||
protected: | ||
CCTextInputNode* m_pRangeStartInput; | ||
CCTextInputNode* m_pRangeEndInput; | ||
EditorPauseLayer* m_pPauseLayer; | ||
|
||
bool setup() override; | ||
|
||
void onCreate(cocos2d::CCObject*); | ||
void onInfo(cocos2d::CCObject*); | ||
|
||
public: | ||
static ColorTriggerPopup* create(EditorPauseLayer* = nullptr); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters