Ejemplo n.º 1
0
bool BinOArchive::operator()(u64& value, const char* name, const char* label)
{
    openNode(name);
    stream_.write(value);
    closeNode(name);
    return true;
}
Ejemplo n.º 2
0
bool BinOArchive::operator()(const Serializer& ser, const char* name, const char* label)
{
    openNode(name, false);
    ser(*this);
    closeNode(name, false);
    return true;
}
Ejemplo n.º 3
0
bool BinOArchive::operator()(WStringInterface& value, const char* name, const char* label)
{
	bool size8 = (wcslen(value.get()) + 1)*sizeof(wchar_t) < SIZE16;
	openNode(name, size8);
	stream_ << value.get();
	stream_.write(wchar_t(0));
	closeNode(name, size8);
	return true;
}
Ejemplo n.º 4
0
bool BinOArchive::operator()(StringInterface& value, const char* name, const char* label)
{
	bool size8 = strlen(value.get()) + 1 < SIZE16;
    openNode(name, size8);
	stream_ << value.get();
	stream_.write(char(0));
    closeNode(name, size8);
    return true;
}
Ejemplo n.º 5
0
bool BinIArchive::operator()(const Serializer& ser, const char* name, const char* label)
{
	if(!strlen(name)){
		ser(*this);
		return true;
	}

	if(!openNode(name))
		return false;

	ser(*this);
	closeNode(name, false);
	return true;
}
Ejemplo n.º 6
0
bool BinIArchive::operator()(char& value, const char* name, const char* label)
{
	if(!strlen(name)){
		read(value);
		return true;
	}

	if(!openNode(name))
		return false;

	read(value);
	closeNode(name);
	return true;
}
Ejemplo n.º 7
0
bool BinIArchive::operator()(WStringInterface& value, const char* name, const char* label)
{
	if(!strlen(name)){
		wstringBuffer_.clear();
		read(wstringBuffer_);
		value.set(wstringBuffer_.c_str());
		return true;
	}

	if(!openNode(name))
		return false;

	wstringBuffer_.clear();
	read(wstringBuffer_);
	value.set(wstringBuffer_.c_str());
	closeNode(name);
	return true;
}
Ejemplo n.º 8
0
bool BinIArchive::operator()(PointerInterface& ptr, const char* name, const char* label)
{
	if(strlen(name) && !openNode(name))
		return false;

	string typeName;
	read(typeName);
	if(ptr.get() && (typeName.empty() || strcmp(typeName.c_str(), ptr.registeredTypeName()) != 0))
		ptr.create(""); // 0

	if(!typeName.empty() && !ptr.get())
		ptr.create(typeName.c_str());

	if(Serializer ser = ptr.serializer())
		ser(*this);

	if(strlen(name))
		closeNode(name);
	return true;
}
Ejemplo n.º 9
0
bool BinOArchive::operator()(ContainerInterface& ser, const char* name, const char* label)
{
	openNode(name, false);

	unsigned int size = (unsigned int)ser.size();
	if(size < SIZE16)
		stream_.write((unsigned char)size);
	else if(size < 0x10000){
		stream_.write(SIZE16);
		stream_.write((unsigned short)size);
	}
	else{
		stream_.write(SIZE32);
		stream_.write(size);
	}

	if(strlen(name)){
		if(size > 0){
			int i = 0;
			do {
				char buffer[16];
#ifdef _MSC_VER
				_itoa(i++, buffer, 10);
#else
				sprintf(buffer, "%d", i++);
#endif
				ser(*this, buffer, "");
			} while (ser.next());
		}

		closeNode(name, false);
	}
	else{
		if(size > 0)
			do 
				ser(*this, "", "");
				while (ser.next());
	}

    return true;
}
Ejemplo n.º 10
0
/**
 * Add pixmap or clipart key.
 * @param dt date/time
 * @param filename the filename of the image
 * @param name the relative path to the image in the store (optional)
 */
void DomNode::addKey( const QDateTime& dt, const QString& filename, const QString& name )
{
    const QDate date ( dt.date() );
    const QTime time ( dt.time() );

    addNode( "KEY" );
    setAttribute( "filename", CheckAndEscapeXmlText(filename) );
    setAttribute( "year", date.year() );
    setAttribute( "month", date.month() );
    setAttribute( "day", date.day() );
    setAttribute( "hour", time.hour() );
    setAttribute( "minute", time.minute() );
    setAttribute( "second", time.second() );
    setAttribute( "msec", time.msec() );

    if (!name.isEmpty())
    {
        setAttribute( "name", CheckAndEscapeXmlText(name) );
    }
    closeNode( "KEY" );
}
Ejemplo n.º 11
0
void MainWindow::on_ui_removeFile_clicked()
{
	foreach(const QModelIndex& index, ui_projects->selectionModel()->selectedRows()) {
		const int type = m_projectsModel.indexType(index);
		Project* project = m_projectsModel.indexToProject(index);
		if(type == ProjectsModel::FileType) {
			const TinyNode* node = m_projectsModel.indexToNode(index);
			QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Are You Sure?"),
				tr("Permanently delete ") + QTinyNode::name(node) + "?",
				QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
			
			if(ret == QMessageBox::No) continue;
			qWarning() << "Node path" << QString::fromStdString(node->path());
			closeNode(node);
			project->archive()->TinyArchive::remove(node->path());
			project->sync();
		} else if(type == ProjectsModel::ProjectType) {
			project->sync();
			ProjectManager::ref().closeProject(project);
		}
	}
	// ui_projects->expandAll();
}
Ejemplo n.º 12
0
bool BinIArchive::operator()(ContainerInterface& ser, const char* name, const char* label)
{
	if(strlen(name)){
		if(!openNode(name))
			return false;

		size_t size = currentBlock().readPackedSize();
		ser.resize(size);

		if(size > 0){
			int i = 0;
			do{
				char buffer[16];
#ifdef _MSC_VER
				_itoa(i++, buffer, 10);
#else
				sprintf(buffer, "%d", i++);
#endif
				ser(*this, buffer, "");
			}
			while(ser.next());
		}
		closeNode(name);
		return true;
	}
	else{
		size_t size = currentBlock().readPackedSize();
		ser.resize(size);
		if(size > 0){
			do
				ser(*this, "", "");
				while(ser.next());
		}
		return true;
	}
}
Ejemplo n.º 13
0
bool BinOArchive::operator()(PointerInterface& ptr, const char* name, const char* label)
{
	openNode(name, false);

	const char* typeName = ptr.registeredTypeName();
	if (!typeName)
		typeName = "";
	if (typeName[0] == '\0' && ptr.get()) {
		YASLI_ASSERT(0 && "Writing unregistered class. Use YASLI_CLASS_NAME macro for registration.");
	}

	TypeID baseType = ptr.baseType();

	if(ptr.get()){
		stream_ << typeName;
		stream_.write(char(0));
		ptr.serializer()(*this);
	}
	else
		stream_.write(char(0));

	closeNode(name, false);
	return true;
}
Ejemplo n.º 14
0
path* 
FlexibleAStar::search(node* start, node* goal)
{
	nodesExpanded=0;
	nodesTouched=0;
	searchTime =0;
	nodesGenerated = 0;

	if(verbose) 
	{
		std::cout << "getPath() mapLevel: ";
		std::cout <<start->getLabelL(kAbstractionLevel)<<std::endl;
	}

	if(!checkParameters(start, goal))
		return NULL;

	start->setLabelF(kTemporaryLabel, heuristic->h(start, goal));
	start->backpointer = 0;
	
	altheap openList(heuristic, goal, 30);
	std::map<int, node*> closedList;
	
	openList.add(start);
	path *p = NULL;
	
	Timer t;
	t.startTimer();
	while(1) 
	{
		node* current = ((node*)openList.remove()); 

		// check if the current node is the goal (early termination)
		if(current == goal)
		{
			closeNode(current, &closedList);
			p = extractBestPath(current);
			if(verbose)
				debug->printNode(std::string("goal found! "), current);
			break;
		}
		
		// expand current node
		expand(current, goal, &openList, &closedList);
		closeNode(current, &closedList);
				
		// terminate when the open list is empty
		if(openList.empty())
		{
			if(verbose) std::cout << "search failed. ";
			break;
		}
	}
	searchTime = t.endTimer();
	closedList.clear();

	start->drawColor = 3;
	goal->drawColor = 3;

	if(verbose)
	{
		std::cout << "\n";
		debug->printPath(p); 
	}

	return p;	
}
Ejemplo n.º 15
0
/* VaultShopMain */
VaultShopMain::VaultShopMain()
{
    // Basic Form Settings
    setWindowTitle("VaultShop " PLASMASHOP_VERSION);
    //setWindowIcon(QIcon(":/res/VaultShop.png"));

    // Set up actions
    fActions[kFileOpenVault] = new QAction(qStdIcon("document-open"), tr("&Load Vault..."), this);
    fActions[kFileSaveVault] = new QAction(qStdIcon("document-save"), tr("&Save Vault"), this);
    fActions[kFileExit] = new QAction(tr("E&xit"), this);
    fActions[kVaultOpenNode] = new QAction(tr("Subscribe to &Node..."), this);

    fActions[kNodeUnLink] = new QAction(tr("Remove"), this);
    fActions[kNodeLink] = new QAction(tr("Add Node..."), this);
    fActions[kNodeCreate] = new QAction(tr("Create Node"), this);
    fActions[kNodeUnsubscribe] = new QAction(tr("Un-subscribe"), this);
    //fActions[kNodeRenameVault] = new QAction(tr("Rename Vault..."), this);

    fActions[kFileOpenVault]->setShortcut(Qt::CTRL + Qt::Key_O);
    fActions[kFileSaveVault]->setShortcut(Qt::CTRL + Qt::Key_S);
    fActions[kFileExit]->setShortcut(Qt::ALT + Qt::Key_F4);
    fActions[kVaultOpenNode]->setShortcut(Qt::Key_F2);

    // Main Menus
    QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
    fileMenu->addAction(fActions[kFileOpenVault]);
    fileMenu->addAction(fActions[kFileSaveVault]);
    fileMenu->addSeparator();
    fileMenu->addAction(fActions[kFileExit]);

    QMenu* vaultMenu = menuBar()->addMenu(tr("&Vault"));
    vaultMenu->addAction(fActions[kVaultOpenNode]);

    // Toolbars
    QToolBar* fileTbar = addToolBar(tr("File Toolbar"));
    fileTbar->setObjectName("FileToolBar");
    fileTbar->addAction(fActions[kFileOpenVault]);
    fileTbar->addAction(fActions[kFileSaveVault]);
    statusBar();

    // Main Splitter
    QSplitter* splitter = new QSplitter(Qt::Horizontal, this);
    splitter->setObjectName("Splitter");

    // Node Browser
    fVaultTree = new QTreeWidget(splitter);
    fVaultTree->setUniformRowHeights(true);
    fVaultTree->setHeaderHidden(true);
    fVaultTree->setContextMenuPolicy(Qt::CustomContextMenu);

    // Property Editor
    fNodeTab = new QTabWidget(splitter);
    fGenericEditor = new QVaultNode(fNodeTab);
    fNodeTab->addTab(fGenericEditor, tr("Node Properties"));
    fCustomEditor = NULL;
    fSavEditor = NULL;
    fEditorTabPreference = 0;

    // Layout
    splitter->addWidget(fVaultTree);
    splitter->addWidget(fNodeTab);
    setCentralWidget(splitter);
    splitter->setSizes(QList<int>() << 160 << 320);

    // Global UI Signals
    connect(fActions[kFileExit], SIGNAL(triggered()), this, SLOT(close()));
    connect(fActions[kFileOpenVault], SIGNAL(triggered()), this, SLOT(openGame()));
    connect(fActions[kFileSaveVault], SIGNAL(triggered()), this, SLOT(performSave()));
    connect(fActions[kVaultOpenNode], SIGNAL(triggered()), this, SLOT(openNode()));
    connect(fActions[kNodeUnLink], SIGNAL(triggered()), this, SLOT(unlinkNode()));
    connect(fActions[kNodeLink], SIGNAL(triggered()), this, SLOT(linkNode()));
    connect(fActions[kNodeCreate], SIGNAL(triggered()), this, SLOT(createNode()));
    connect(fActions[kNodeUnsubscribe], SIGNAL(triggered()), this, SLOT(closeNode()));
    //connect(fActions[kNodeRenameVault], SIGNAL(triggered()), this, SLOT(renameVault()));

    connect(fVaultTree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
            this, SLOT(treeItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
    connect(fVaultTree, SIGNAL(customContextMenuRequested(const QPoint&)),
            this, SLOT(treeContextMenu(const QPoint&)));
    connect(fNodeTab, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
    connect(fGenericEditor, SIGNAL(typeModified()), this, SLOT(typeModified()));
    connect(this, SIGNAL(nodeChanged(unsigned int)), this, SLOT(refreshNode(unsigned int)));

    // Load UI Settings
    QSettings settings("PlasmaShop", "VaultShop");
    resize(settings.value("WinSize", QSize(480, 600)).toSize());
    if (settings.contains("WinPos"))
        move(settings.value("WinPos").toPoint());
    if (settings.value("WinMaximized", false).toBool())
        showMaximized();

    if (settings.contains("WinState"))
        restoreState(settings.value("WinState").toByteArray());

    fLastDir = settings.value("LastDir").toString();
    if (!fLastDir.isEmpty())
        loadGame(fLastDir);
}