Skip to content

Commit c92aafc

Browse files
committed
fixed message object save/load
1 parent ecd1c31 commit c92aafc

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/objects/gui/moMessage.cpp

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void moMessage::newObject(){
6868

6969
//--------------------------------------------------------------
7070
void moMessage::setupObjectContent(shared_ptr<ofAppGLFWWindow> &mainWindow){
71-
71+
loadMessageSetting();
7272
}
7373

7474
//--------------------------------------------------------------
@@ -119,7 +119,9 @@ void moMessage::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
119119
ImGui::Dummy(ImVec2(-1,ImGui::GetWindowSize().y/2 - (40*scaleFactor))); // Padding top
120120
ImGui::PushItemWidth(-24*scaleFactor);
121121
ImGui::PushStyleColor(ImGuiCol_FrameBg, VHS_DGRAY);
122-
ImGui::InputText("##source", &actualMessage);
122+
if(ImGui::InputText("##source", &actualMessage)){
123+
saveMessageSetting();
124+
}
123125
ImGui::PopStyleColor(1);
124126
ImGui::PopItemWidth();
125127
ImGui::SameLine(); ImGuiEx::HelpMarker("Always check receiving objects reference for UPPERCASE/LOWERCASE messages.");
@@ -148,6 +150,41 @@ void moMessage::removeObjectContent(bool removeFileFromData){
148150

149151
}
150152

153+
//--------------------------------------------------------------
154+
void moMessage::loadMessageSetting(){
155+
ofxXmlSettings XML;
156+
157+
if (XML.loadFile(patchFile)){
158+
int totalObjects = XML.getNumTags("object");
159+
for(int i=0;i<totalObjects;i++){
160+
if(XML.pushTag("object", i)){
161+
if(XML.getValue("id", -1) == this->nId){
162+
actualMessage = XML.getValue("text","none");
163+
}
164+
XML.popTag();
165+
}
166+
}
167+
}
168+
}
169+
170+
//--------------------------------------------------------------
171+
void moMessage::saveMessageSetting(){
172+
ofxXmlSettings XML;
173+
174+
if (XML.loadFile(patchFile)){
175+
int totalObjects = XML.getNumTags("object");
176+
for(int i=0;i<totalObjects;i++){
177+
if(XML.pushTag("object", i)){
178+
if(XML.getValue("id", -1) == this->nId){
179+
XML.setValue("text",actualMessage);
180+
}
181+
XML.popTag();
182+
}
183+
}
184+
XML.saveFile();
185+
}
186+
}
187+
151188

152189
OBJECT_REGISTER( moMessage, "message", OFXVP_OBJECT_CAT_GUI)
153190

src/objects/gui/moMessage.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ class moMessage : public PatchObject {
5454

5555
void removeObjectContent(bool removeFileFromData=false) override;
5656

57+
void loadMessageSetting();
58+
void saveMessageSetting();
5759

58-
string actualMessage;
60+
61+
string actualMessage;
5962

6063
private:
6164

0 commit comments

Comments
 (0)