@@ -142,6 +142,10 @@ namespace ede {
142142
143143 for (Node* node : nodes) {
144144 if (node) {
145+ std::set<std::string>& current_callbacks = node->selected_callbacks ;
146+ std::ostringstream stream;
147+ std::copy (current_callbacks.begin (), current_callbacks.end (), std::ostream_iterator<std::string>(stream, " " ));
148+ std::string result_str = stream.str ();
145149 if (SpeechNode* speech_node = node->AsSpeech ()) {
146150 std::stringstream ss;
147151 ss << " {" ;
@@ -151,21 +155,18 @@ namespace ede {
151155 if (speech_node->responses .empty ())
152156 ss << " " ;
153157 ss << " }" ;
154- raw_info += std::format (R"( [{{ "id": "{}" ; "type": "Speech" ; "next_node_id": "{}" ; "expected_responses": "{}" }} ; )" ,
155- node->id , node->nextNodeId , ss.str ());
156- std::set<std::string>& current_callbacks = node->selected_callbacks ;
157- std::ostringstream stream;
158- std::copy (current_callbacks.begin (), current_callbacks.end (), std::ostream_iterator<std::string>(stream, " " ));
159- std::string result_str = stream.str ();
158+ raw_info += std::format (R"( [{{ "id": "{}" ; "type": "Speech" ; "next_node_id": "{}" ; "expected_responses": "{}" }} ; "callbacks": "{}")" ,
159+ node->id , node->nextNodeId , ss.str (), result_str);
160+
160161 ImGui::Text (std::format (" Node {}: {{\n \" id\" : \" {}\" ,\n \" type\" : \" Speech\" ,\n \" text\" : \" {}\" ,\n \" next_node_id\" : \" {}\" ,\n \" expected_responses\" : \" {}\" ,\n \" callbacks\" : \" {{ {}}}\"\n }}" , node->id , node->id , node->text , node->nextNodeId , ss.str (), result_str).c_str ());
161162
162163 }
163164 if (ResponseNode* response_node = node->AsResponse ()) {
164165
165- raw_info += std::format (R"( [{{ "id": "{}" ; "type": "Response" ; "next_node_id": "{}" }} ; )" ,
166- node->id , node->nextNodeId );
166+ raw_info += std::format (R"( [{{ "id": "{}" ; "type": "Response" ; "next_node_id": "{}" ; "callbacks": "{}" }} ; )" ,
167+ node->id , node->nextNodeId , result_str );
167168
168- ImGui::Text (" Node %d : {\n \" id\" : \" %d \" ,\n \" type\" : \" Response\" ,\n \" next_node_id\" : \" %d \"\n } " , node->id , node->id , node->nextNodeId );
169+ ImGui::Text (std::format ( " Node {} : {{ \n \" id\" : \" {} \" ,\n \" type\" : \" Response\" ,\n \" next_node_id\" : \" {} \" , \n \" callbacks \" : \" {{ {}}} \"\n }} " , node->id , node->id , node->nextNodeId , result_str). c_str () );
169170
170171 }
171172 ImGui::Dummy (ImVec2 (0 .0f , 2 .0f ));
@@ -211,14 +212,20 @@ namespace ede {
211212 }
212213 std::set<std::string>& current_callbacks = ede::GetCallbacksMutable ();
213214 ImGui::Indent ();
214- for (auto & callback : current_callbacks) {
215+
216+ // display current callback tags and delete buttons
217+ for (auto it = current_callbacks.begin (); it != current_callbacks.end ();) {
218+
219+ const auto & callback = *it;
215220 TEXT_BULLET (" >" , callback.c_str ());
216221 ImGui::SameLine ();
217- if (ImGui::Button (" X" )) {
218- auto it = std::find (current_callbacks.begin (), current_callbacks.end (), callback);
219- if (it != current_callbacks.end ()) {
220- current_callbacks.erase (it);
221- }
222+ std::string button_label = " X##" + callback;
223+ if (ImGui::Button (button_label.c_str ())) {
224+ ede::NotifyCallbackDeletion (callback);
225+ it = current_callbacks.erase (it);
226+ }
227+ else {
228+ ++it;
222229 }
223230 }
224231 ImGui::Unindent ();
@@ -244,27 +251,4 @@ namespace ede {
244251 ImGui::End ();
245252 }
246253
247- /* ******************************************************
248- * Helper methods
249- *******************************************************/
250-
251- void LinkCallback (ImGui::MarkdownLinkCallbackData data_);
252- inline ImGui::MarkdownImageData ImageCallback (ImGui::MarkdownLinkCallbackData data_);
253-
254- static ImFont* H1 = NULL ;
255- static ImFont* H2 = NULL ;
256- static ImFont* H3 = NULL ;
257-
258- static ImGui::MarkdownConfig mdConfig;
259-
260-
261- void LinkCallback (ImGui::MarkdownLinkCallbackData data_)
262- {
263- std::string url (data_.link , data_.linkLength );
264- if (!data_.isImage )
265- {
266- ShellExecuteA (NULL , " open" , url.c_str (), NULL , NULL , SW_SHOWNORMAL );
267- }
268- }
269-
270254}
0 commit comments