MCPcopy Create free account
hub / github.com/GlobedGD/globed2 / onClose

Method onClose

src/modules/scripting-ui/ui/SetupEmbeddedScriptPopup.cpp:186–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186void SetupEmbeddedScriptPopup::onClose(CCObject* obj) {
187 if (m_madeChanges && !m_doSave && !m_confirmedExit) {
188 globed::confirmPopup(
189 "Note",
190 "Are you sure you want to <cr>discard</c> all the changes you've made?",
191 "Cancel", "Discard",
192 [this](auto) {
193 m_confirmedExit = true;
194 this->onClose(nullptr);
195 }
196 );
197
198 return;
199 }
200
201 // commit changes
202 if (m_doSave) {
203 auto res = m_script.encode(true, m_scriptPrefix);
204 if (!res) {
205 log::error("Failed to save script: {}", res.unwrapErr());
206 globed::alertFormat("Error", "Failed to save script: {}", res.unwrapErr());
207 } else {
208 auto data = std::move(res).unwrap();
209 m_object->m_text = gd::string((const char*) data.data(), data.size());
210 }
211 }
212
213 BasePopup::onClose(obj);
214}
215
216SetupEmbeddedScriptPopup* SetupEmbeddedScriptPopup::create(TextGameObject* obj) {
217 auto ret = new SetupEmbeddedScriptPopup();

Callers 1

initMethod · 0.95

Calls 4

confirmPopupFunction · 0.85
alertFormatFunction · 0.85
encodeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected