Esempio n. 1
0
void MainWindow::on_actionNewNPC_config_triggered()
{
    //Check if data configs are valid
    if( configs.check() )
    {
        WriteToLog(QtCriticalMsg, QString("Error! *.INI configs not loaded"));
        QMessageBox::warning(this, tr("Configuration is loaded with errors"),
                             tr("Cannot create NPC config file:\nConfiguration package loaded with errors.").arg(ConfStatus::configPath));
        //Show configuration status window
        on_actionCurConfig_triggered();
        return;
    }

    //NpcDialog * npcList = new NpcDialog(&configs);
    ItemSelectDialog * npcList = new ItemSelectDialog(&configs, ItemSelectDialog::TAB_NPC);
    npcList->removeEmptyEntry(ItemSelectDialog::TAB_NPC);
    npcList->setWindowFlags (Qt::Window | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
    npcList->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, npcList->size(), qApp->desktop()->availableGeometry()));
    npcList->setWindowTitle(tr("Create new NPC.txt configuration file"));
    if(npcList->exec()==QDialog::Accepted)
    {
        NpcEdit *child = createNPCChild();
        child->newFile( npcList->npcID );
        child->show();
    }
    delete npcList;
    updateMenus(true);
}
Esempio n. 2
0
void MainWindow::on_actionNewNPC_config_triggered()
{
    //NpcDialog * npcList = new NpcDialog(&configs);
    ItemSelectDialog * npcList = new ItemSelectDialog(&configs, ItemSelectDialog::TAB_NPC);
    npcList->removeEmptyEntry(ItemSelectDialog::TAB_NPC);
    npcList->setWindowFlags (Qt::Window | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
    npcList->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, npcList->size(), qApp->desktop()->availableGeometry()));
    npcList->setWindowTitle(tr("Create new NPC.txt configuration file"));
    if(npcList->exec()==QDialog::Accepted)
    {
        npcedit *child = createNPCChild();
        child->newFile( npcList->npcID );
        child->show();
    }
    delete npcList;

}
Esempio n. 3
0
void ItemScene::contextMenu( QGraphicsSceneMouseEvent * mouseEvent )
{
    m_scene->m_contextMenuIsOpened = true; //bug protector
    //Remove selection from non-bgo items
    if(!this->isSelected())
    {
        m_scene->clearSelection();
        this->setSelected(true);
    }

    setSelected(true);//minor, but so dumb mistake was here: "this" instead of "true"
    QMenu ItemMenu;

    QMenu * copyPreferences = ItemMenu.addMenu(tr("Copy preferences"));
        copyPreferences->deleteLater();
            QAction *copyItemID = copyPreferences->addAction(tr("Scenery-ID: %1").arg(m_data.id));
                copyItemID->deleteLater();
            QAction *copyPosXY = copyPreferences->addAction(tr("Position: X, Y"));
                copyPosXY->deleteLater();
            QAction *copyPosXYWH = copyPreferences->addAction(tr("Position: X, Y, Width, Height"));
                copyPosXYWH->deleteLater();
            QAction *copyPosLTRB = copyPreferences->addAction(tr("Position: Left, Top, Right, Bottom"));
                copyPosLTRB->deleteLater();

    QAction *copyTile = ItemMenu.addAction(tr("Copy"));
    QAction *cutTile = ItemMenu.addAction(tr("Cut"));
        ItemMenu.addSeparator();
    QAction *transform = ItemMenu.addAction(tr("Transform into"));
    QAction *transform_all = ItemMenu.addAction(tr("Transform all %1 into").arg("SCENERY-%1").arg(m_data.id));
        ItemMenu.addSeparator();
    QAction *remove = ItemMenu.addAction(tr("Remove"));
    QAction *remove_all =       ItemMenu.addAction(tr("Remove all %1").arg("SCENERY-%1").arg(m_data.id));

QAction *selected = ItemMenu.exec(mouseEvent->screenPos());

    if(!selected)
    {
        #ifdef _DEBUG_
        WriteToLog(QtDebugMsg, "Context Menu <- NULL");
        #endif
        return;
    }

    if(selected==copyItemID)
    {
        QApplication::clipboard()->setText(QString("%1").arg(m_data.id));
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==copyPosXY)
    {
        QApplication::clipboard()->setText(
                            QString("X=%1; Y=%2;")
                               .arg(m_data.x)
                               .arg(m_data.y)
                               );
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==copyPosXYWH)
    {
        QApplication::clipboard()->setText(
                            QString("X=%1; Y=%2; W=%3; H=%4;")
                               .arg(m_data.x)
                               .arg(m_data.y)
                               .arg(m_imageSize.width())
                               .arg(m_imageSize.height())
                               );
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==copyPosLTRB)
    {
        QApplication::clipboard()->setText(
                            QString("Left=%1; Top=%2; Right=%3; Bottom=%4;")
                               .arg(m_data.x)
                               .arg(m_data.y)
                               .arg(m_data.x+m_imageSize.width())
                               .arg(m_data.y+m_imageSize.height())
                               );
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==cutTile)
    {
        MainWinConnect::pMainWin->on_actionCut_triggered();
    }
    else
    if(selected==copyTile)
    {
        MainWinConnect::pMainWin->on_actionCopy_triggered();
    }
    else
    if((selected==transform)||(selected==transform_all))
    {
        WorldData oldData;
        WorldData newData;
        int transformTO;

        ItemSelectDialog * itemList = new ItemSelectDialog(m_scene->m_configs, ItemSelectDialog::TAB_SCENERY,0,0,0,0,0,0,0,0,0, m_scene->m_subWindow);
        itemList->removeEmptyEntry(ItemSelectDialog::TAB_SCENERY);
        util::DialogToCenter(itemList, true);

        if(itemList->exec()==QDialog::Accepted)
        {
            QList<QGraphicsItem *> our_items;
            bool sameID=false;
            transformTO = itemList->sceneryID;
            unsigned long oldID = m_data.id;

            if(selected==transform)
                our_items=m_scene->selectedItems();
            else
            if(selected==transform_all)
            {
                our_items=m_scene->items();
                sameID=true;
            }

            foreach(QGraphicsItem * SelItem, our_items )
            {
                if(SelItem->data(ITEM_TYPE).toString()=="SCENERY")
                {
                    if((!sameID)||(((ItemScene *) SelItem)->m_data.id==oldID))
                    {
                        oldData.scenery.push_back( ((ItemScene *) SelItem)->m_data );
                        ((ItemScene *) SelItem)->transformTo(transformTO);
                        newData.scenery.push_back( ((ItemScene *) SelItem)->m_data );
                    }
                }
            }
        }
Esempio n. 4
0
void ItemMusic::contextMenu( QGraphicsSceneMouseEvent * mouseEvent )
{
    m_scene->m_contextMenuIsOpened = true;
    //Remove selection from non-bgo items
    if(!this->isSelected())
    {
        m_scene->clearSelection();
        this->setSelected(true);
    }

    this->setSelected(true);
    QMenu ItemMenu;

    if(!m_musicTitle.isEmpty())
    {
        QAction *title = ItemMenu.addAction(QString("[%1]").arg(m_musicTitle));
        title->setEnabled(false);
    }else if(m_data.id==0)
    {
        QAction *title = ItemMenu.addAction(QString("[%1]").arg(tr("<Silence>")));
        title->setEnabled(false);
    }
    QAction *play = ItemMenu.addAction(tr("Play this"));
        ItemMenu.addSeparator();

    QMenu * copyPreferences = ItemMenu.addMenu(tr("Copy preferences"));
        copyPreferences->deleteLater();
            QAction *copyItemID = copyPreferences->addAction(tr("World-Music-ID: %1").arg(m_data.id));
                copyItemID->deleteLater();
            QAction *copyPosXY = copyPreferences->addAction(tr("Position: X, Y"));
                copyPosXY->deleteLater();
            QAction *copyPosXYWH = copyPreferences->addAction(tr("Position: X, Y, Width, Height"));
                copyPosXYWH->deleteLater();
            QAction *copyPosLTRB = copyPreferences->addAction(tr("Position: Left, Top, Right, Bottom"));
                copyPosLTRB->deleteLater();

    QAction *copyTile = ItemMenu.addAction(tr("Copy"));
    QAction *cutTile = ItemMenu.addAction(tr("Cut"));
        ItemMenu.addSeparator();
    QAction *transform = ItemMenu.addAction(tr("Transform into"));
    QAction *transform_all = ItemMenu.addAction(tr("Transform all %1 into").arg("MUSIC-%1%2")
                                                .arg(m_data.id)
                                                .arg( m_data.music_file.isEmpty()?"":" ("+m_data.music_file+")" ) );
        ItemMenu.addSeparator();
    QAction *remove =       ItemMenu.addAction(tr("Remove"));
    QAction *remove_all =   ItemMenu.addAction(tr("Remove all %1").arg("MUSIC-%1").arg(m_data.id));

QAction *selected = ItemMenu.exec(mouseEvent->screenPos());

    if(!selected)
    {
        #ifdef _DEBUG_
        WriteToLog(QtDebugMsg, "Context Menu <- NULL");
        #endif
        return;
    }

    if(selected==play)
    {
        m_scene->m_subWindow->currentMusic = m_data.id;
        LvlMusPlay::setMusic(LvlMusPlay::WorldMusic, m_data.id, m_data.music_file);
        LvlMusPlay::updatePlayerState(true);
        MainWinConnect::pMainWin->setMusicButton(true);
    }
    else
    if(selected==copyItemID)
    {
        QApplication::clipboard()->setText(QString("%1").arg(m_data.id));
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==copyPosXY)
    {
        QApplication::clipboard()->setText(
                            QString("X=%1; Y=%2;")
                               .arg(m_data.x)
                               .arg(m_data.y)
                               );
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==copyPosXYWH)
    {
        QApplication::clipboard()->setText(
                            QString("X=%1; Y=%2; W=%3; H=%4;")
                               .arg(m_data.x)
                               .arg(m_data.y)
                               .arg(m_imageSize.width())
                               .arg(m_imageSize.height())
                               );
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==copyPosLTRB)
    {
        QApplication::clipboard()->setText(
                            QString("Left=%1; Top=%2; Right=%3; Bottom=%4;")
                               .arg(m_data.x)
                               .arg(m_data.y)
                               .arg(m_data.x+m_imageSize.width())
                               .arg(m_data.y+m_imageSize.height())
                               );
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==cutTile)
    {
        MainWinConnect::pMainWin->on_actionCut_triggered();
    }
    else
    if(selected==copyTile)
    {
        MainWinConnect::pMainWin->on_actionCopy_triggered();
    }
    else
    if((selected==transform)||(selected==transform_all))
    {
        WorldData oldData;
        WorldData newData;
        int transformTO;
        QString transformTO_file;

        ItemSelectDialog * itemList = new ItemSelectDialog(m_scene->m_configs, ItemSelectDialog::TAB_MUSIC,0,0,0,0,0,0,0,0,0, m_scene->m_subWindow);
        itemList->removeEmptyEntry(ItemSelectDialog::TAB_MUSIC);
        util::DialogToCenter(itemList, true);

        if(itemList->exec()==QDialog::Accepted)
        {
            QList<QGraphicsItem *> our_items;
            bool sameID=false;
            transformTO   = itemList->musicID;
            transformTO_file = itemList->musicFile;
            unsigned long oldID = m_data.id;

            if(selected==transform)
                our_items=m_scene->selectedItems();
            else
            if(selected==transform_all)
            {
                our_items=m_scene->items();
                sameID=true;
            }

            foreach(QGraphicsItem * SelItem, our_items )
            {
                if(SelItem->data(ITEM_TYPE).toString()=="MUSICBOX")
                {
                    if((!sameID)||(((ItemMusic *) SelItem)->m_data.id==oldID))
                    {
                        oldData.music.push_back( ((ItemMusic *) SelItem)->m_data );
                        ((ItemMusic *) SelItem)->transformTo(transformTO, transformTO_file);
                        newData.music.push_back( ((ItemMusic *) SelItem)->m_data );
                    }
                }
            }
        }
Esempio n. 5
0
void ItemPath::contextMenu( QGraphicsSceneMouseEvent * mouseEvent )
{
    m_scene->contextMenuOpened = true; //bug protector
    //Remove selection from non-bgo items
    if(!this->isSelected())
    {
        m_scene->clearSelection();
        this->setSelected(true);
    }

    this->setSelected(true);
    QMenu ItemMenu;

    QMenu * copyPreferences =   ItemMenu.addMenu(tr("Copy preferences"));
    QAction *copyItemID =       copyPreferences->addAction(tr("Path-ID: %1").arg(m_data.id));
    QAction *copyPosXY =        copyPreferences->addAction(tr("Position: X, Y"));
    QAction *copyPosXYWH =      copyPreferences->addAction(tr("Position: X, Y, Width, Height"));
    QAction *copyPosLTRB =      copyPreferences->addAction(tr("Position: Left, Top, Right, Bottom"));

    QAction *copyTile =         ItemMenu.addAction(tr("Copy"));
    QAction *cutTile =          ItemMenu.addAction(tr("Cut"));
                                ItemMenu.addSeparator();
    QAction *transform =        ItemMenu.addAction(tr("Transform into"));
    QAction *transform_all =    ItemMenu.addAction(tr("Transform all %1 into").arg("PATH-%1").arg(m_data.id));
                                ItemMenu.addSeparator();
    QAction *remove =           ItemMenu.addAction(tr("Remove"));


    QAction *selected =         ItemMenu.exec(mouseEvent->screenPos());
    if(!selected) return;

    if(selected==copyItemID)
    {
        QApplication::clipboard()->setText(QString("%1").arg(m_data.id));
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==copyPosXY)
    {
        QApplication::clipboard()->setText(
                            QString("X=%1; Y=%2;")
                               .arg(m_data.x)
                               .arg(m_data.y)
                               );
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==copyPosXYWH)
    {
        QApplication::clipboard()->setText(
                            QString("X=%1; Y=%2; W=%3; H=%4;")
                               .arg(m_data.x)
                               .arg(m_data.y)
                               .arg(m_imageSize.width())
                               .arg(m_imageSize.height())
                               );
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==copyPosLTRB)
    {
        QApplication::clipboard()->setText(
                            QString("Left=%1; Top=%2; Right=%3; Bottom=%4;")
                               .arg(m_data.x)
                               .arg(m_data.y)
                               .arg(m_data.x+m_imageSize.width())
                               .arg(m_data.y+m_imageSize.height())
                               );
        MainWinConnect::pMainWin->showStatusMsg(tr("Preferences has been copied: %1").arg(QApplication::clipboard()->text()));
    }
    else
    if(selected==cutTile)
    {
        MainWinConnect::pMainWin->on_actionCut_triggered();
    }
    else
    if(selected==copyTile)
    {
        MainWinConnect::pMainWin->on_actionCopy_triggered();
    }
    else
    if((selected==transform)||(selected==transform_all))
    {
        WorldData oldData;
        WorldData newData;
        int transformTO;

        ItemSelectDialog * itemList = new ItemSelectDialog(m_scene->pConfigs, ItemSelectDialog::TAB_PATH,0,0,0,0,0,0,0,0,0, m_scene->_edit);
        itemList->removeEmptyEntry(ItemSelectDialog::TAB_PATH);
        util::DialogToCenter(itemList, true);

        if(itemList->exec()==QDialog::Accepted)
        {
            QList<QGraphicsItem *> our_items;
            bool sameID=false;
            transformTO = itemList->pathID;
            unsigned long oldID = m_data.id;

            if(selected==transform)
                our_items=m_scene->selectedItems();
            else
            if(selected==transform_all)
            {
                our_items=m_scene->items();
                sameID=true;
            }

            foreach(QGraphicsItem * SelItem, our_items )
            {
                if(SelItem->data(ITEM_TYPE).toString()=="PATH")
                {
                    if((!sameID)||(((ItemPath *) SelItem)->m_data.id==oldID))
                    {
                        oldData.paths.push_back( ((ItemPath *) SelItem)->m_data );
                        ((ItemPath *) SelItem)->transformTo(transformTO);
                        newData.paths.push_back( ((ItemPath *) SelItem)->m_data );
                    }
                }
            }
        }