void MainWindowView::Update(UPDATE_CODE updateCode) { if(updateCode == UPDATE_NEW_ASSOCIATED_FILE) { //File name of the added associated file const QString& fileNameAdded = m_pAssociatedFiles->GetLastModifiedFileName(); //Open the file in the aditor as a non mai file OpenXmlFile(fileNameAdded, false); } else if(updateCode == UPDATE_REMOVED_ASSOCIATED_FILE) { const QString& fileNameRemoved = m_pAssociatedFiles->GetLastModifiedFileName(); //Remove the file from the editor ClearSingleXml(fileNameRemoved); } else if(updateCode == UPDATE_XML_DOCUMENT) { //Set the start in both the combo box SetModifiedStarInComboBox(); //Activate the save action EnableSaveActions(); } }
void MainWindowView::dropEvent(QDropEvent *event) { //Take the ulrs const QList<QUrl>& urls = event->mimeData()->urls(); //Controlf if the url list is not empty if (urls.isEmpty()) { return; } //If it's not a valid file in the local file system const QString& fileName = urls.first().toLocalFile(); if (fileName.isEmpty()) { return; } //All it's ok try to open the new file asking the action that the user wants QMessageBox msgBox; msgBox.setText("Do you want to open the file as main file or add as associate file?\n\n" + fileName); msgBox.setIcon(QMessageBox::Question); //Buttons QPushButton* openAsMainFileBnt = msgBox.addButton(tr("Open as main file"), QMessageBox::ActionRole); QPushButton* openAsAssociateFileBnt = msgBox.addButton(tr("Open as associate file"), QMessageBox::ActionRole); msgBox.addButton(QMessageBox::Abort); //Set yes as defalut button msgBox.setDefaultButton(openAsMainFileBnt); //Show the dialog msgBox.exec(); if(msgBox.clickedButton() == openAsMainFileBnt) { //Open as main file OpenXmlFile(fileName, true); } else if(msgBox.clickedButton() == openAsAssociateFileBnt) { //Add to the associate files m_pAssociatedFiles->AddAssociatedFileName(fileName); //It's not needed to insert the file because if it's iserted, tha min will open the file automatically } }
int CBoxProxyView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; // 创建DC m_pDC = new CClientDC(this); ASSERT(m_pDC != NULL); // 选择像素格式 if(!bSetDCPixelFormat()) return -1; // 创建渲染环境, 并使它成为当前渲染环境 m_hRC = wglCreateContext(m_pDC->GetSafeHdc()); wglMakeCurrent(m_pDC->GetSafeHdc(), m_hRC); OpenXmlFile(defaultFileName); return 0; }
void CBoxProxyView::OnFileNew() { // TODO: 在此添加命令处理程序代码 OpenXmlFile(defaultFileName); }
void CLevel::Load( TiXmlElement * root ) { if ( root == NULL ) { return; } int sw = VIRTUAL_WIDTH; int sh = VIRTUAL_HEIGHT; root->QueryIntAttribute("w", &sw); root->QueryIntAttribute("h", &sh); mSceneWidth = (uint32)sw; mSceneHeight = (uint32)sh; int initCamX = 0; int initCamY = 0; root->QueryIntAttribute("init_cam_x", &initCamX); root->QueryIntAttribute("init_cam_y", &initCamY); mInitCam.x = (float)initCamX; mInitCam.y = (float)initCamY; // includes TiXmlElement * elem_inc = root->FirstChildElement("include"); for(; elem_inc; elem_inc = elem_inc->NextSiblingElement("include")) { const char * path = elem_inc->Attribute("path"); if ( path != 0 ) { TiXmlDocument doc; if ( OpenXmlFile(path, &doc) ) { TiXmlElement * elem_templ = doc.FirstChildElement("template"); for(; elem_templ; elem_templ = elem_templ->NextSiblingElement("template")) { AddTemplate( (TiXmlElement *)elem_templ->Clone(), true ); } } } mIncludes.push_back((TiXmlElement *)elem_inc->Clone()); } // templates TiXmlElement * elem_templ = root->FirstChildElement("template"); for(; elem_templ; elem_templ = elem_templ->NextSiblingElement("template")) { AddTemplate( (TiXmlElement *)elem_templ->Clone(), false ); } TiXmlElement * elem_obj = root->FirstChildElement("object"); for(; elem_obj; elem_obj = elem_obj->NextSiblingElement("object")) { GameObjectPtr obj; const char * type = elem_obj->Attribute("type"); const char * tmpl = elem_obj->Attribute("template"); obj = CreateObject( type, tmpl ); IwAssert(LEVEL, obj != NULL); obj->Load( elem_obj ); obj->Init(); AddObject( obj ); #if APP_SAVE_XML obj->SetSave(true); #endif } DoAddObjs(); }
void MainWindowView::CreateAction() { //Create Action for create a new XML m_pNewXmlAct = new QAction(QIcon(":/icon/new.png"), "&New XML", this); m_pNewXmlAct->setShortcut(QKeySequence::New); m_pNewXmlAct->setStatusTip("Create a new XML file. The current work will be closed"); connect(m_pNewXmlAct, SIGNAL(triggered()), this, SLOT(NewMainXmlFile())); //Create Action for open a new XML m_pOpenXmlAct = new QAction(QIcon(":/icon/open.png"), "&Open XML", this); m_pOpenXmlAct->setShortcut(QKeySequence::Open); m_pOpenXmlAct->setStatusTip("Open a preexisting XML file. The current work will be closed"); connect(m_pOpenXmlAct, SIGNAL(triggered()), this, SLOT(OpenXmlFile())); //Create Action for save the left XML m_pSaveLeftXmlAct = new QAction(QIcon(":/icon/save.png"), "Save &Left XML", this); m_pSaveLeftXmlAct->setShortcut(tr("CTRL+S")); m_pSaveLeftXmlAct->setStatusTip("Save the xml document current shown in the left tree"); connect(m_pSaveLeftXmlAct, SIGNAL(triggered()), this, SLOT(SaveLeftXmlFile())); //Create Action for save the right XML m_pSaveRightXmlAct = new QAction(QIcon(":/icon/save.png"), "Save &Right XML", this); m_pSaveRightXmlAct->setShortcut(tr("CTRL+D")); m_pSaveRightXmlAct->setStatusTip("Save the xml document current shown in the right tree"); connect(m_pSaveRightXmlAct, SIGNAL(triggered()), this, SLOT(SaveRightXmlFile())); //Create Action for save all XML m_pSaveAllXmlAct = new QAction(QIcon(":/icon/saveAll.png"), "Save All XML", this); m_pSaveAllXmlAct->setShortcut(tr("CTRL+SHIFT+S")); m_pSaveAllXmlAct->setStatusTip("Save the xml document current shown in the right tree"); connect(m_pSaveAllXmlAct, SIGNAL(triggered()), this, SLOT(SaveAllXmlFile())); //Create Action for exit from the program m_pExitProgrammAct = new QAction(QIcon(":/icon/exit.png"), tr("&Exit"), this); m_pExitProgrammAct->setShortcut(tr("CTRL+Q")); m_pExitProgrammAct->setStatusTip(QString::fromUtf8("Quit the program")); connect(m_pExitProgrammAct, SIGNAL(triggered()), this, SLOT(close())); //Create Action for undo m_pUndoAct = new QAction(QIcon(":/icon/undo.png"), tr("&Undo"), this); m_pUndoAct->setShortcut(tr("CTRL+Z")); m_pUndoAct->setStatusTip(QString::fromUtf8("Undo the last action")); connect(m_pUndoAct, SIGNAL(triggered()), this, SLOT(Undo())); //Create Action for redo m_pRedoAct = new QAction(QIcon(":/icon/redo.png"), tr("&Redo"), this); m_pRedoAct->setShortcut(tr("CTRL+Y")); m_pRedoAct->setStatusTip(QString::fromUtf8("Redo the last undo action")); connect(m_pRedoAct, SIGNAL(triggered()), this, SLOT(Redo())); //Create Action for manage tag filter m_setAttributeNameTagCollapseAct = new QAction(QIcon(":/icon/collapse.png"), "Set Collapse &Tag Filter", this); m_setAttributeNameTagCollapseAct->setShortcut(tr("ALT+T")); m_setAttributeNameTagCollapseAct->setStatusTip("Set the attribute name to display when collapse same tags"); connect(m_setAttributeNameTagCollapseAct, SIGNAL(triggered()), this, SLOT(EditAttributeNameTagCollapse())); //Create Action for manage associate XML files m_pManageAssociateXmlFilesAct = new QAction(QIcon(":/icon/associate.png"), "Manage &Associated XML", this); m_pManageAssociateXmlFilesAct->setShortcut(tr("ALT+M")); m_pManageAssociateXmlFilesAct->setStatusTip("Manage the associated xml files"); connect(m_pManageAssociateXmlFilesAct, SIGNAL(triggered()), this, SLOT(EditAssociatedFileNames())); //Create Action for manage XML relations m_pManageXmlRelationAct = new QAction(QIcon(":/icon/relation.jpg"), "Manage XML &Relations", this); m_pManageXmlRelationAct->setShortcut(tr("ALT+R")); m_pManageXmlRelationAct->setStatusTip("Manage the associated xml files"); connect(m_pManageXmlRelationAct, SIGNAL(triggered()), this, SLOT(ManageXmlRelations())); //Create Action for import XML relations m_pInportXmlRelationAct = new QAction(QIcon(":/icon/import.png"), "Import XML &Relations", this); m_pInportXmlRelationAct->setShortcut(tr("ALT+I")); m_pInportXmlRelationAct->setStatusTip("Manage the associated xml files"); connect(m_pInportXmlRelationAct, SIGNAL(triggered()), this, SLOT(ImportXmlRelations())); //Create Action for export XML relations m_pExportXmlRelationAct = new QAction(QIcon(":/icon/export.png"), "Export XML &Relations", this); m_pExportXmlRelationAct->setShortcut(tr("ALT+E")); m_pExportXmlRelationAct->setStatusTip("Manage the associated xml files"); connect(m_pExportXmlRelationAct, SIGNAL(triggered()), this, SLOT(ExportXmlRelations())); //Create Action for Check the xml relations m_pCheckXmlRelationAct = new QAction(QIcon(":/icon/check.png"), "&Check XML Relations", this); m_pCheckXmlRelationAct->setShortcut(tr("ALT+SHIFT+C")); m_pCheckXmlRelationAct->setStatusTip("Control the consistence of the relations in the main XML and in all associated files"); connect(m_pCheckXmlRelationAct, SIGNAL(triggered()), this, SLOT(CheckXmlRelation())); //Create Action for show the about dialog m_pAboutAct = new QAction(QIcon(":/icon/iconaexe.png"), "&About " APPLICATION_NAME, this); m_pAboutAct->setShortcut(QKeySequence::WhatsThis); m_pAboutAct->setStatusTip(tr("Shows info about the application")); connect(m_pAboutAct, SIGNAL(triggered()), this, SLOT(About())); }