Skip to content

Commit

Permalink
do not throw exceptions when parsing editor layer (fixes #174 and #180)
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Feb 13, 2024
1 parent e32bda0 commit c300f1d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/features/TypeInZLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

using namespace geode::prelude;

class $modify(EditorUI) {
class $modify(TypeInUI, EditorUI) {
bool init(LevelEditorLayer* lel) {
if (!EditorUI::init(lel))
return false;
Expand All @@ -19,7 +19,7 @@ class $modify(EditorUI) {
auto layerLockSpr = CCSprite::createWithSpriteFrameName("GJ_lockGray_001.png");
layerLockSpr->setScale(.75f);
auto layerLockBtn = CCMenuItemSpriteExtra::create(
layerLockSpr, this, menu_selector(EditorUI::onLockLayer)
layerLockSpr, this, menu_selector(TypeInUI::onLockLayerReal)
);
layerLockBtn->setID("lock-layer"_spr);
layerMenu->insertBefore(layerLockBtn, nullptr);
Expand All @@ -28,12 +28,9 @@ class $modify(EditorUI) {
m_currentLayerLabel = EditableBMLabelProxy::replace(
m_currentLayerLabel, this, 40.f, "Z",
[this](auto str) {
try {
m_editorLayer->m_currentLayer = std::stoi(str);
}
catch(...) {
m_editorLayer->m_currentLayer = -1;
}
char* err;
auto num = std::strtol(str.c_str(), &err, 10);
m_editorLayer->m_currentLayer = *err ? -1 : num;
},
[this](auto) {
this->updateLockBtn();
Expand Down

0 comments on commit c300f1d

Please sign in to comment.