//============================================================================================== void RunWithConfig(UrpWindow &win, int configAction, int windowInstancingMethod, UrpTopWindow *parentWindow = NULL) { // Note that you must load config to open a window (Procedural dictator, that's me) if (configAction & CONFIGACTION_LOAD) { // Call all class Serialize functions. Each class has either a custom Serialize function // or defaults to base class Ctrl GetData/SetData virtual functions. // Primarily only responsible for Serializing window placement, since U++ SerializePlacement // function handles the problem fairly well. // LoadFromFile(win, win.binConfigFile); // Call all class Xmlize functions. Again these are either custom or from Ctrl base. // Many of the U++ classes never bothered to implement this. LoadFromXMLFile(win, win.xmlConfigFile); switch (windowInstancingMethod) { case WINDOWINSTANCINGMETHOD_RUN: win.Run(); // Note that initial call from main will always be modal, following calls will be modeless break; case WINDOWINSTANCINGMETHOD_OPEN: win.Open(); // Modeless and retains position set previously in serialize, whereas run ignores position info break; case WINDOWINSTANCINGMETHOD_NONE: break; } } // ..AND you must save config to close, dammit! if (configAction & CONFIGACTION_SAVE) { if (windowInstancingMethod == WINDOWINSTANCINGMETHOD_CLOSE) { if (win.IsOpen()) { // Probably not if it was modal win.Hide(); // For speed, we can hide it before we call the closer win.Close(); } } // Store any changes user made to window positioning/sizing. // Binary serialization files get flushed when any changes are made to their input // attributes, which is why I only keep window placement here. // StoreToFile(win, win.binConfigFile); // Hack in Ctrl class to make Xmlize virtual // Store text xmlized values. XML format means user customizations are retained over // version releases, which is significant, and sad that U++ does not make this easier. StoreAsXMLFile(win, NULL, win.xmlConfigFile); } }
void MapEditor::OnSaveMap() { CalculateAllPrompt(); if (!StoreAsXMLFile(_map, _map.GetName(), AppendFileName( AppendFileName(GetFileDirectory(GetExeFilePath()), "Mipmaps"), _map.GetName() + ".map" ))) { Exclamation(t_("Error while saving map to file!")); } UpdateEditorCtrls(); }
TreeTest::TreeTest() { CtrlLayout(*this, "Window title"); //Node<One<Element> > root.SetAsRoot(); root.leaf.Create(); root.leaf->name = "/"; root.SetCount(3); Node<One<Element> > & child = root[2]; ASSERT(child.GetParent() == &root); ASSERT(child.GetRoot() == &root); child.leaf.Create(); child.leaf->name = "Hallo"; String & s = child.GetParent()->leaf->name; s = "root"; String & ss = root.leaf->name; ASSERT(ss.IsEqual(s)); //Node<Element> roota.SetAsRoot(); roota.leaf.name = "/"; roota.leaf.value = "Hallo"; roota.SetCount(3); Node<Element> & childa = roota[2]; childa.leaf.name = "Servus"; childa.leaf.value = 123; ASSERT(childa.GetParent() == &roota); ASSERT(childa.GetRoot() == &roota); String & sa = childa.GetParent()->leaf.name; sa = "root"; String & ssa = roota.leaf.name; ASSERT(ssa.IsEqual(sa)); #if 1 StoreAsXMLFile(roota, "MyTree", "check.xml"); Node<Element> roota_; LoadFromXMLFile(roota_, "check.xml"); StoreAsXMLFile(roota_, "MyTree", "check1.xml"); #endif #if 1 StoreToFile(roota, "check.cfg"); Node<Element> roota__; LoadFromFile(roota__, "check.cfg"); StoreToFile(roota__, "check1.cfg"); #endif //NodeB<Element> rootb.SetAsRoot(); rootb.name = "/"; rootb.value = "Hallo"; rootb.SetCount(3); NodeB<Element> & childb = rootb[2]; childb.name = "Servus"; childb.value = 123; ASSERT(childb.GetParent() == &rootb); ASSERT(childb.GetRoot() == &rootb); String & sb = childb.GetParent()->name; sb = "root"; String & ssb = rootb.name; ASSERT(ssb.IsEqual(sb)); #if 0 StoreAsXMLFile(rootb, "CHECK"); NodeB<Element> rootb_; LoadFromXMLFile(rootb_); StoreAsXMLFile(rootb_, "CHECK1"); #endif #if 0 StoreToFile(rootb); Node<Element> rootb__; LoadFromFile(rootb__); StoreToFile(rootb__); #endif //NodeB<One<Element> > rootc.SetAsRoot(); rootc.One<Element>::Create(); rootc->name = "/"; rootc.SetCount(3); NodeB<One<Element> > & childc = rootc[2]; ASSERT(childc.GetParent() == &rootc); ASSERT(childc.GetRoot() == &rootc); childc.One<Element>::Create(); childc->name = "Hallo"; String & sc = childc.GetParent()->operator*().name; sc = "root"; String & ssc = rootc->name; ASSERT(ssc.IsEqual(sc)); //MapNode<String, Element> mroota.SetAsRoot(); mroota.leaf.name = "/"; mroota.leaf.value = "Hallo"; mroota.Add("a"); mroota.Add("b"); mroota.Add("c"); MapNode<String, Element> & childd = mroota[2]; childd.leaf.name = "Servus"; childd.leaf.value = 123; ASSERT(childd.GetParent() == &mroota); ASSERT(childd.GetRoot() == &mroota); String & sd = childd.GetParent()->leaf.name; sd = "root"; String & ssd = roota.leaf.name; ASSERT(ssd.IsEqual(sd)); int x = 123; }