@@ -32,38 +32,32 @@ class ModifyAttemptCountPopup : public geode::Popup<GJGameLevel*> {
3232 }
3333 void onSetButtonClick (CCObject* sender){
3434 if (inputNode->getString ().empty ()){return ;}
35- try {
36- int val = std::stoi (inputNode-> getString ());
35+ int val = geode::numFromString< int >(inputNode-> getString ()). unwrapOr (- 1 );
36+ if ( val > - 1 ) {
3737 setAttempts (val);
38- this ->removeMeAndCleanup ();
39- } catch (const std::invalid_argument& e) {
40- log::warn (" Input is not a valid integer" );
41- } catch (const std::out_of_range& e) {
42- log::warn (" Input is out of range" );
38+ this ->onClose (nullptr );
39+ } else {
40+ geode::Notification::create (" Input is not a valid number" , NotificationIcon::Error, 2 .f )->show ();
4341 }
4442 }
4543 void onPlusButtonClick (CCObject* sender){
4644 if (inputNode->getString ().empty ()){return ;}
47- try {
48- int val = std::stoi (inputNode-> getString ());
45+ int val = geode::numFromString< int >(inputNode-> getString ()). unwrapOr (- 1 );
46+ if ( val > - 1 ) {
4947 addAttempts (val);
50- this ->removeMeAndCleanup ();
51- } catch (const std::invalid_argument& e) {
52- log::warn (" Input is not a valid integer" );
53- } catch (const std::out_of_range& e) {
54- log::warn (" Input is out of range" );
48+ this ->onClose (nullptr );
49+ } else {
50+ geode::Notification::create (" Input is not a valid number" , NotificationIcon::Error, 2 .f )->show ();
5551 }
5652 }
5753 void onMinusButtonClick (CCObject* sender){
5854 if (inputNode->getString ().empty ()){return ;}
59- try {
60- int val = std::stoi (inputNode-> getString ());
55+ int val = geode::numFromString< int >(inputNode-> getString ()). unwrapOr (- 1 );
56+ if ( val > - 1 ) {
6157 subtractAttempts (val);
62- this ->removeMeAndCleanup ();
63- } catch (const std::invalid_argument& e) {
64- log::warn (" Input is not a valid integer" );
65- } catch (const std::out_of_range& e) {
66- log::warn (" Input is out of range" );
58+ this ->onClose (nullptr );
59+ } else {
60+ geode::Notification::create (" Input is not a valid number" , NotificationIcon::Error, 2 .f )->show ();
6761 }
6862 }
6963 bool setup (GJGameLevel* level) override {
@@ -75,8 +69,8 @@ class ModifyAttemptCountPopup : public geode::Popup<GJGameLevel*> {
7569 auto menu = CCMenu::create ();
7670
7771 auto input = CCTextInputNode::create (100 , 100 , " Attempts" , " bigFont.fnt" );
78- input->setScale (0.75 );
79- input->setPosition (CCPoint (272.5 , 170 ));
72+ input->setScale (0.75 );
73+ input->setPosition (CCPoint (this -> m_mainLayer -> getContentWidth () / 2 . f , 170 ));
8074 input->setAllowedChars (" 0123456789" );
8175 inputNode = input;
8276
0 commit comments