diff --git a/changelog.md b/changelog.md index 4c41b77..47e1aa8 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,10 @@ # Changelog +## v0.2.0-alpha + * Implemented simple curve drawing support with the use of Anti-Grain Geometry library + +## v0.1.1-alpha + * Added Android support in mod.json + ## v0.1.0-alpha * Initial release, only supports line drawings. \ No newline at end of file diff --git a/mod.json b/mod.json index 3ea30c9..78ae24e 100644 --- a/mod.json +++ b/mod.json @@ -4,7 +4,7 @@ "win": "2.206", "android": "2.206" }, - "version": "v0.1.1-alpha", + "version": "v0.2.0-alpha", "id": "alk.allium", "name": "Allium Drawing Tool", "developer": "alk", diff --git a/src/hooks/EditorUI.cpp b/src/hooks/EditorUI.cpp index 5a77961..f7315a3 100644 --- a/src/hooks/EditorUI.cpp +++ b/src/hooks/EditorUI.cpp @@ -2,6 +2,7 @@ #include #include #include +#include using namespace geode::prelude; using namespace allium; @@ -44,19 +45,6 @@ struct EditorUIHook : Modify { return true; } - $override - void keyDown(enumKeyCodes key) { - if (key == KEY_Enter) { - if (BrushManager::get()->m_currentDrawer) { - BrushManager::get()->m_currentDrawer->clearOverlay(); - BrushManager::get()->m_currentDrawer->updateLine(); - } - } - else { - EditorUI::keyDown(key); - } - } - CCPoint getLayerPosition(CCTouch* touch) { auto objectLayer = LevelEditorLayer::get()->m_objectLayer; auto glPoint = CCDirector::get()->convertToGL(touch->getLocationInView()); @@ -101,7 +89,27 @@ struct EditorUIHook : Modify { EditorUI::showUI(show); auto alliumButton = static_cast(this->getChildByIDRecursive("allium-button"_spr)); - alliumButton->setEnabled(show); - alliumButton->setVisible(show); + if (alliumButton) { + alliumButton->setEnabled(show); + alliumButton->setVisible(show); + } + + auto finalizeButton = static_cast(this->getChildByIDRecursive("allium-finalize-button"_spr)); + if (finalizeButton) { + finalizeButton->setEnabled(show); + finalizeButton->setVisible(show); + } } -}; \ No newline at end of file +}; + +$execute { + using namespace keybinds; + + BindManager::get()->registerBindable({ + "finalize-brush"_spr, + "Finalize brush", + "Finalizes the brush created by the drawer.", + { Keybind::create(KEY_Enter, Modifier::None) }, + "Allium/Brushes" + }); +} \ No newline at end of file diff --git a/src/ui/AlliumPopup.cpp b/src/ui/AlliumPopup.cpp index 20b0f48..1c944bf 100644 --- a/src/ui/AlliumPopup.cpp +++ b/src/ui/AlliumPopup.cpp @@ -30,6 +30,11 @@ void AlliumPopup::brushToggleCallback(CCMenuItemToggler* toggle) { brushDrawer->removeFromParent(); brushDrawer = nullptr; } + auto buttonMenu = EditorUI::get()->getChildByID("editor-buttons-menu"); + auto finalizeButton = static_cast(buttonMenu->getChildByID("allium-finalize-button"_spr)); + if (finalizeButton) { + finalizeButton->removeFromParent(); + } if (toggle == m_lineBrushToggle) { brushDrawer = LineBrushDrawer::create(); @@ -39,6 +44,29 @@ void AlliumPopup::brushToggleCallback(CCMenuItemToggler* toggle) { else if (toggle == m_curveBrushToggle) { brushDrawer = CurveBrushDrawer::create(); + auto topSprite = CCLabelBMFont::create("Finalize", "bigFont.fnt"); + + auto mySprite = BasedButtonSprite::create( + topSprite, BaseType::Editor, + static_cast(EditorBaseSize::Normal), static_cast(EditorBaseColor::Orange) + ); + mySprite->setTopRelativeScale(1.6f); + + auto myButton = CCMenuItemExt::createSpriteExtra( + mySprite, [this](CCObject* sender) { + if (BrushManager::get()->m_currentDrawer) { + BrushManager::get()->m_currentDrawer->clearOverlay(); + BrushManager::get()->m_currentDrawer->updateLine(); + } + } + ); + myButton->setID("allium-finalize-button"_spr); + // size set in Node IDs itself + myButton->setContentSize({ 40.f, 40.f }); + + buttonMenu->addChild(myButton); + buttonMenu->updateLayout(); + BrushManager::get()->m_currentBrush = BrushType::Curve; } else {