bool CMapWidget::event(QEvent *e) { if (e->type() == QEvent::ToolTip) { QHelpEvent *helpEvent = static_cast<QHelpEvent *>(e); QPoint point = helpEvent->pos(); CMapView *view = getView(); CMapLevel *level = view->getCurrentlyViewedLevel(); CMapElement *element = level ? level->findElementAt(point) : 0; QString s; if (element) { if (element->getElementType() == ROOM) { s = ((CMapRoom*)element)->getLabel(); } else if (element->getElementType() == ZONE) { s = ((CMapZone*)element)->getLabel(); } if (!s.trimmed().isEmpty()) QToolTip::showText (helpEvent->globalPos(), s, this); else QToolTip::hideText (); } } return QWidget::event(e); }
void CMapWidget::showContexMenu(QMouseEvent *e) { CMapLevel *level = viewWidget->getCurrentlyViewedLevel(); if (!level) return; CMapView *view = mapManager->getActiveView(); view->setSelectedPos(e->pos()); selectedPos = e->pos(); view->setSelectedElement(0); CMapElement *element = level->findElementAt (e->pos()); if (!element) { showOtherContextMenu(); return; } view->setSelectedElement(element); mapManager->unsetEditElement(); switch(element->getElementType()) { case ROOM : showRoomContextMenu(); break; case PATH : showPathContextMenu(); break; case TEXT : showTextContextMenu(); break; default : showOtherContextMenu(); break; } }
/** * This method is used to save all the paths in a zone * @param doc The document being the paths are saved too * @param rootNode The XML node to save the paths to * @param zone The zone to save */ void CMapFileFilterXML::saveZoneLinks(QDomDocument *doc,QDomElement *pathsNode,QDomElement *linksNode,CMapZone *zone) { if (zone == NULL) return; for ( CMapLevel *level=zone->getLevels()->first(); level != 0; level=zone->getLevels()->next()) { for ( CMapRoom *room=level->getRoomList()->first(); room != 0; room=level->getRoomList()->next() ) { for (CMapPath *path = room->getPathList()->first(); path != 0; path=room->getPathList()->next() ) { QDomElement pathElement = doc->createElement("Path"); path->saveQDomElement(doc,&pathElement); savePluginPropertiesForElement(path,doc,&pathElement); pathsNode->appendChild(pathElement); } } for ( CMapText *text=level->getTextList()->first(); text != 0; text=level->getTextList()->next()) { CMapElement *element = text->getLinkElement(); if (element) { QDomElement linkElement = doc->createElement("Link"); linkElement.setAttribute("SrcType",text->getElementType()); linkElement.setAttribute("SrcLevel",text->getLevel()->getLevelID()); linkElement.setAttribute("SrcID",text->getTextID()); linkElement.setAttribute("DestType",element->getElementType()); linkElement.setAttribute("DestLevel",element->getLevel()->getLevelID()); if (element->getElementType()==ROOM) { linkElement.setAttribute("DestID",((CMapRoom *)element)->getRoomID()); linkElement.setAttribute("LabelPos",(int)((CMapRoom *)element)->getLabelPosition()); } if (element->getElementType()==ZONE) { linkElement.setAttribute("DestID",((CMapZone *)element)->getZoneID()); linkElement.setAttribute("LabelPos",(int)((CMapZone *)element)->getLabelPosition()); } linksNode->appendChild(linkElement); } } for ( CMapZone* subZone=level->getZoneList()->first(); subZone != 0; subZone=level->getZoneList()->next() ) { saveZoneLinks(doc,pathsNode,linksNode,subZone); } } }
void CMapCmdElementDelete::undo() { QStringList groupList = properties->groupList(); for (QStringList::Iterator it = groupList.begin(); it != groupList.end(); ++it) { if (*it == "<default>") continue; KConfigGroup group = properties->group (*it); if (group.hasKey("Deleted")) continue; CMapElement *elm = createElement(group); elm->loadProperties(group); for (CMapPluginBase *plugin = manager->getPluginList()->first(); plugin!=0; plugin = manager->getPluginList()->next()) { plugin->afterElementUndeleted(elm); } } }
bool CSceneManager::Init() { if(m_pHge->Resource_AttachPack("res.dat"))printf("LoadPack Success!\n"); else printf("LoadPack Fail!Try To Load From File...\n"); m_pRs = new hgeResourceManager(SCRIPTNAME); m_pRs->Precache(); m_pCamera = new C2DCamera(); m_pSelectSqure = new CSeletSqure(m_pRs, m_pCamera); m_pBG = m_pRs->GetSprite("Logo"); m_pSltSpr = m_pRs->GetSprite("TouchStart"); m_pMask = m_pRs->GetSprite("Black"); m_pGUI = new hgeGUI(); m_pGUI->SetCursor(m_pRs->GetSprite("Cursor")); m_pMap = new CMap(20,20, "city.bmp"); if(!m_pMap->Init()) return false; m_objs.push_back(new CGrid(m_pMap->m_col,m_pMap->m_row,m_pMap->m_tileWidth,m_pMap->m_tileHeight)); CMapElement* elem = new CMapElement(m_pRs, Point(40,40*8), "Elem01"); elem->Init(); m_objs.push_back(elem); elem = new CMapElement(m_pRs, Point(40*2,40*10), "Elem02"); elem->Init(); m_objs.push_back(elem); for(int i = 0;i < 32;i ++) { //AddUnit("girl", 400.f + 30*i, 180.f+m_pHge->Random_Float(0,50),CUnit::ENEMY); AddUnit("neko", 400, 250.f ,CUnit::OUR); } AddUnit("girl", 400, 250.f ,CUnit::OUR); m_pPlayer = new CPlayer(m_pRs, m_pSelectSqure, m_pMap); printf("Init Success!\n"); return true; }