Exemplo n.º 1
0
bool MapBG::Load(const char* fp)
{
	if (!FileExists(fp))
	{
		LOG(NFormat("MapBG: File not exists, \"%s\"", fp));
		return false;
	}

	if (!LoadFromXMLFile(_levels, fp))
	{
		LOG("MapBG: Error while loading map from XML-file!");
		return false;
	}

	_mapDir = AppendFileName(GetFileDirectory(fp), GetFileTitle(fp));
	_currLevel = _levels.GetCount() > 0 ? 0 : -1;
	if (_currLevel < 0)
	{
		LOG("MapBG: No zoom levels found in map!");
		return false;
	}
	_recalc = true;

	return true;
}
Exemplo n.º 2
0
//==============================================================================================
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);
	}
}
Exemplo n.º 3
0
void MapEditor::OnLoadMap()
{
	WithMapLoadLayout<TopWindow> dlg;
	CtrlLayoutOKCancel(dlg, t_("Load Map..."));

	String dir = AppendFileName( GetFileDirectory(GetExeFilePath()), "Mipmaps");
	Vector<String> files = GetDirectoryFiles(dir, "*.map");
	Sort(files);

	if (files.GetCount() <= 0)
	{
		Exclamation(t_("No any file to load!"));
		return;
	}

	for (int i = 0; i < files.GetCount(); ++i)
		dlg.MapList.Add(files[i], files[i]);
	dlg.MapList.SetIndex(0);

	if (dlg.Execute() != IDOK)
		return;

	String fp = AppendFileName(dir, (~dlg.MapList).ToString());

	if (!FileExists(fp))
	{
		Exclamation(NFormat(t_("File not found: %s"), fp));
		return;
	}

	if (!LoadFromXMLFile(_map, fp))
	{
		Exclamation(NFormat(t_("Error while loading map from file: %s"), fp));
		return;
	}

	UpdateLevelList();
	UpdateEditorCtrls();
}
Exemplo n.º 4
0
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;
}