const Path Instance::GetTmpPath(GenericString file)
		{
			Path path;
			path.Reserve( 255 );

			if (uint length = ::GetTempPath( path.Capacity() + 1, path.Ptr() ))
			{
				if (length > path.Capacity() + 1)
				{
					path.Reserve( length - 1 );
					length = ::GetTempPath( path.Capacity() + 1, path.Ptr() );
				}

				if (length)
					path = GetLongPath( path.Ptr() );
			}

			if (path.Length())
				path.MakePretty( true );
			else
				path << ".\\";

			if (file.Empty())
				file = L"nestopia.tmp";

			path << file;

			return path;
		}
Esempio n. 2
0
		const Path Browser::SaveFile(wchar_t* const filter,Path initial)
		{
			Path path;
			path.Reserve( MAX_PATH*2 );

			const Path extension( initial.Extension() );

			if (initial.File().Length() && initial.File()[0] != '.')
				path = initial.File();

			initial.File().Clear();

			Object::Pod<OPENFILENAME> ofn;

			ofn.lStructSize     = sizeof(ofn);
			ofn.hwndOwner       = Application::Instance::GetActiveWindow();
			ofn.lpstrFile       = path.Ptr();
			ofn.nMaxFile        = path.Capacity();
			ofn.lpstrInitialDir = initial.Length() ? initial.Ptr() : L".";
			ofn.Flags           = OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY;

			if (filter)
			{
				for (uint i=0; filter[i]; ++i)
				{
					if (filter[i] == '\t')
						filter[i] = '\0';
				}

				ofn.lpstrFilter = filter;
				ofn.nFilterIndex = 1;
			}

			if (extension.Length())
				ofn.lpstrDefExt = extension.Ptr();

			if (::GetSaveFileName( &ofn ))
				path.Validate();
			else
				path.Clear();

			return path;
		}
Esempio n. 3
0
		void Main::OnEmuEvent(const Managers::Emulator::Event event,const Managers::Emulator::Data data)
		{
			switch (event)
			{
				case Managers::Emulator::EVENT_POWER_ON:
				case Managers::Emulator::EVENT_POWER_OFF:

					if (emulator.NetPlayers())
					{
						menu.ToggleModeless( event == Managers::Emulator::EVENT_POWER_ON );
					}
					else if (Fullscreen())
					{
						const bool show = (event == Managers::Emulator::EVENT_POWER_OFF);
						menu.Show( show );
						Application::Instance::ShowChildWindows( show );
					}
					break;

				case Managers::Emulator::EVENT_LOAD:
				{
					Path name;

					if (emulator.IsCart())
					{
						name = Nes::Cartridge(emulator).GetProfile()->game.title.c_str();
					}
					else if (emulator.IsNsf())
					{
						name.Import( Nes::Nsf(emulator).GetName() );
					}

					if (name.Empty())
					{
						name = emulator.GetImagePath().Target().File();
						name.Extension().Clear();
					}

					if (name.Length())
						window.Text() << (name << " - " << MainWindow::name).Ptr();

					break;
				}

				case Managers::Emulator::EVENT_UNLOAD:

					window.Text() << MainWindow::name;
					break;

				case Managers::Emulator::EVENT_NETPLAY_MODE:

					menu[IDM_VIEW_SWITCH_SCREEN].Enable( !data );
					break;
			}
		}
Esempio n. 4
0
		const Path Browser::OpenFile(wchar_t* const filter,const Path dir,const Path ext)
		{
			for (uint i=0; filter[i]; ++i)
			{
				if (filter[i] == '\t')
					filter[i] = '\0';
			}

			Path path;
			path.Reserve( MAX_PATH*2 );

			Object::Pod<OPENFILENAME> ofn;

			ofn.lStructSize     = sizeof(ofn);
			ofn.hwndOwner       = Application::Instance::GetActiveWindow();
			ofn.lpstrFile       = path.Ptr();
			ofn.nMaxFile        = path.Capacity();
			ofn.lpstrInitialDir = dir.Length() ? dir.Ptr() : L".";
			ofn.Flags           = OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;

			if (filter)
			{
				ofn.lpstrFilter = filter;
				ofn.nFilterIndex = 1;
			}

			if (ext.Length())
				ofn.lpstrDefExt = ext.Ptr();

			if (::GetOpenFileName( &ofn ))
				path.Validate();
			else
				path.Clear();

			return path;
		}
		void Netplay::Add(Path path)
		{
			enum
			{
				TYPES = Managers::Paths::File::GAME|Managers::Paths::File::ARCHIVE
			};

			if (path.Length() && games.paths.size() < Games::LIMIT && paths.CheckFile( path, TYPES ) && games.paths.insert( path ).second)
			{
				games.state = Games::DIRTY;

				if (dialog)
					dialog.ListView( IDC_NETPLAY_GAMELIST ).Add( path.Target().File() );
			}
		}
//Retorna la descomposicion en key-path del grafo pasado por parametro
Collection* KeyPathLocalSearch::KeyPathDecomp(Graph *g){
	
		Graph *grafo = g->Copy();
		Collection *K = new Collection();
		//nodos que pueden ser extremos de los key-path, son terminales o key-nodes
		Collection * terminals =  g->GetTerminals();
		Collection * key_nodes = g->GetKeyNodes(true);
		Collection * end_nodes = terminals->Union(key_nodes);
		
		int node, currentNode, lastIdentifier, degree;
		bool isTerminal, isKeyNode;
		
		//para cada posible nodo extremo de key-path
		for (int i=0; i<end_nodes->Size(); i++){
			node = ((Integer*)end_nodes->GetItem(i))->GetValue();
			Collection * end_node_adyacents = grafo->GetAdyacents(node);
			//para cada adyacente al nodo extremo
			for (int j = 0; j < end_node_adyacents->Size(); j++){
				lastIdentifier = node;
				//creo el camino
				Path * aux = new Path(g);
				//agrego el extremo
				aux->Add(node);
				//calculo el nodo siguiente del camino
				currentNode = ((Integer*)end_node_adyacents->GetItem(j))->GetValue();
				degree = grafo->GetNodeDegree(currentNode);
				if (grafo->IsNodeEnabled(currentNode) && degree != 0){
					do
					{
						//agrego nodo al camino
						aux->Add(currentNode);
						Collection * adyacents = grafo->GetAdyacents(currentNode);
						//calculo si es terminal y si es key-node
						isTerminal = g->IsTerminal(currentNode);
						isKeyNode = g->IsKeyNode(currentNode);
						//si es nodo intermedio actualizo el currentNode
						if(! isTerminal && ! isKeyNode){
							if(((Integer*)adyacents->GetItem(0))->GetValue() == lastIdentifier){
								lastIdentifier = currentNode;
								currentNode = ((Integer*)adyacents->GetItem(1))->GetValue();
							}
							else{
								lastIdentifier = currentNode;
								currentNode = ((Integer*)adyacents->GetItem(0))->GetValue();
							}
						}
						adyacents->Destroy();
					}while(! isTerminal && ! isKeyNode); //mientras este en nodos intermedios
					K->Add((Object*)aux);
					//apago aristas y nodos del path, dejo prendidos los extremos
					if (aux->Length() > 2)
					{
						for (int ind=1; ind<aux->Length()-1; ind++){
							Collection *adyacents = grafo->GetAdyacents(aux->GetNode(ind));
							//apago aristas si es que existen
							for (int iter=0; iter<adyacents->Size();iter++){
								if (grafo->ExistEdge(aux->GetNode(ind),((Integer*)adyacents->GetItem(iter))->GetValue()))
									grafo->DisableEdge(aux->GetNode(ind),((Integer*)adyacents->GetItem(iter))->GetValue());
							}
							grafo->DisableNode(aux->GetNode(ind));	
							adyacents->Destroy();
						}
					}
					else //key-path de dos nodos
					{
						grafo->DisableEdge(aux->GetNode(0),aux->GetNode(1));
					}
				}
				else{
					delete aux;
				}
			}
			end_node_adyacents->Destroy();
		}
		terminals->Destroy();
		key_nodes->Destroy();
		delete end_nodes;
		delete grafo;
		return K;
}