void ananasTreeView::ContextMenuAdd( QMenu* m ) { //--QLabel *caption = new QLabel( tr("<font color=darkblue><u><b>" "Context Menu</b></u></font>"), this ); //--caption->setAlignment( Qt::AlignCenter ); //--m->insertItem( caption ); //m->insertItem( tr("&Rename"), this, SLOT( itemRename() ), //Qt::CTRL+Qt::Key_R); QAction* rename = m->addAction(tr("&Rename")); rename->setShortcut(Qt::CTRL+Qt::Key_R); connect(rename,SIGNAL(triggered()),SLOT(itemRename())); //m->insertItem( tr("&Edit"), this, SLOT( itemEdit() ), //Qt::CTRL+Qt::Key_E ); QAction* edit = m->addAction(tr("&Edit")); edit->setShortcut(Qt::CTRL+Qt::Key_E); connect(edit,SIGNAL(triggered()),SLOT(itemEdit())); //m->insertItem( tr("&Delete"), this, SLOT( itemDelete() ), //Qt::CTRL+Qt::Key_D ); QAction* del = m->addAction(tr("&Delete")); del->setShortcut(Qt::CTRL+Qt::Key_D); connect(del,SIGNAL(triggered()),SLOT(itemDelete())); //m->insertItem( tr("&MoveUp"), this, SLOT( itemMoveUp() ), //Qt::CTRL+Qt::Key_U ); QAction* moveUp = m->addAction(tr("&MoveUp")); moveUp->setShortcut(Qt::CTRL+Qt::Key_U); connect(moveUp,SIGNAL(triggered()),SLOT(itemMoveUp())); //m->insertItem( tr("&MoveDown"), this, SLOT( itemMoveDown() ), //Qt::CTRL+Qt::Key_M ); QAction* moveDown = m->addAction(tr("&MoveDown")); moveDown->setShortcut(Qt::CTRL+Qt::Key_M); connect(moveDown,SIGNAL(triggered()),SLOT(itemMoveDown())); //m->insertItem( tr("&SaveItem"), this, SLOT( itemSave() ) ); QAction* saveItem = m->addAction(tr("&SaveItem")); connect(saveItem,SIGNAL(triggered()),SLOT(itemSave())); //m->insertItem( tr("&LoadItem"), this, SLOT( itemLoad() ) ); QAction* loadItem = m->addAction(tr("&LoadItem")); connect(loadItem,SIGNAL(triggered()),SLOT(itemLoad())); m->addSeparator(); };
void WorldItems::LoadItems() { string line; int num; ifstream itemLoad("ItemLocations.txt"); if (itemLoad.is_open()) { for (vector<Item>::iterator it = m_items.begin(); it != m_items.end(); ++it) { getline(itemLoad, line); it->SetSaveLocation((save_location)atoi(line.c_str())); getline(itemLoad, line); it->SetRoomId(atoi(line.c_str())); getline(itemLoad, line); it->SetNpcName(line); } itemLoad.close(); } else cout << "Unable to open save file for loading." << endl; }