Exemplo n.º 1
0
void Tile::press(MapEditor& editor, QMouseEvent* pEvent)
{
    if (pEvent->button() == Qt::RightButton || pEvent->button() == Qt::LeftButton)
    {
        // create brush
        auto brush = brushIndexFromMouseButton(pEvent->button());
        auto pos = editor.mapToScene(pEvent->pos()).toPoint();
        // if there is an old brush, release it
        _finishBrush();
        try
        {
            m_pCurrentBrush = MAP::BRUSH::BrushFactory::createBrush(m_BrushInfos.at(static_cast<std::size_t>(brush)), m_DBMgr, editor.getMapData().getMapLayer(),
                              editor.getLayerType(), editor.getLayerIndex() - 1);
            GEOMETRY::Point<uint32> tilePos(pos.x() / MAP::TILE_SIZE, pos.y() / MAP::TILE_SIZE);

            // if tileSet mapping, set brush size equal tileSet size
            if (m_BrushInfos.at(static_cast<std::size_t>(brush)).getType() == MAP::BRUSH::BrushInfo::Type::TILE_SET)
            {
                if (auto pTileSet = m_DBMgr.getTileSetDatabase().getPrototype(m_BrushInfos.at(static_cast<std::size_t>(brush)).getID()))
                    m_pCurrentBrush->setBrushSize(pTileSet->getSize());
            }

            m_pCurrentBrush->start(tilePos);
            editor.scene()->update();
            m_pCurrentEditor = &editor;
        }
        catch (const MAP::EXCEPTION::LayerOutOfRangeException&) {}
    }
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
	QApplication levelEditor(argc, argv);
	MapEditor window;
	window.setWindowIcon(QIcon("images/Mushroom.png"));
	window.show();
	return levelEditor.exec();
}
void MainMenu::OnMapEditor() {
	MapEditor *pMapEditor;
	if((pMapEditor = new MapEditor()) == NULL) {
		perror("MainMenu::OnMapEditor()");
		exit(EXIT_FAILURE);
	}

	pMapEditor->RunEditor();
	delete pMapEditor;
}
Exemplo n.º 4
0
int main()
{
	Map loadMap("TestFormat.cf");
	if (loadMap.Error())
		std::cout << loadMap.ErrorDesc() << '\n';
	loadMap.PrintInfo();

	MapEditor newEditor;
	newEditor.Run();

	return 1;
}
Exemplo n.º 5
0
//==============================================================================
//
// main function; calls OnExecute to run game loop
int main(int argc, char* argv[]) {
  string arg2="",arg1="";

  int out; // indicates if the application should quit after the game exits

  if(argc>2) arg2 = argv[2];
  if(argc>1) arg1 = argv[1];

  do {
    MapEditor* theApp = new MapEditor(arg1, arg2);
    out = theApp->OnExecute();
    delete theApp;
  } while(out == 2);
}
void MAPPING_MODE::ScriptArea::press(MapEditor& editor, QMouseEvent* pEvent)
{
    if (pEvent->button() != Qt::LeftButton)
        return;

    auto pos = editor.mapToScene(pEvent->pos()).toPoint();
    if (auto pItem = editor.scene()->itemAt(pos, QTransform()))
    {
        if (pItem->type() == MAPPING_MODE::ITEM_MOVE_POINT)
            return;
    }

    auto pItem = editor.addScriptArea(AREA::Data(GEOMETRY::Rectangle<int32>(GEOMETRY::Point<int32>(pos.x(), pos.y()), GEOMETRY::Size<int32>())),
        ACTION::Data("test"));
    editor.addRevert(new MAPPING_MODE::SCRIPT_AREA::REVERT::Add(pItem->getScriptArea()->getGUID(), editor));
}
void MAPPING_MODE::ScriptArea::remove(MapEditor& editor)
{
    std::unique_ptr<MAP::REVERT::RevertContainer> pRevertContainer(new MAP::REVERT::RevertContainer());

    for (auto pItem : editor.scene()->selectedItems())
    {
        if (auto pScript = dynamic_cast<ScriptAreaItem*>(pItem->parentItem()))
        {
            // take from editor and map and add revert
            editor.takeScriptArea(pScript->getScriptArea()->getGUID());
            new DelayedDeleteObject<ScriptAreaItem>(pScript);
            pRevertContainer->addRevert(new MAPPING_MODE::SCRIPT_AREA::REVERT::Remove(pScript->getScriptArea(), editor));
        }
    }
    editor.addRevert(pRevertContainer.release());
}
void MAPPING_MODE::ScriptArea::paste(MapEditor& editor, const QPoint& pos)
{
    for (auto& data : m_CopyData)
    {
        if (auto pItem = editor.addScriptArea(data.first, data.second))
            pItem->moveBy(m_Offset.getX(), m_Offset.getY());
    }
}
void MAPPING_MODE::ScriptArea::copy(const MapEditor& editor)
{
    m_CopyData.clear();
    m_Offset = GEOMETRY::Point<int32>::maximum();
    for (auto pItem : editor.scene()->selectedItems())
    {
        if (auto pScript = dynamic_cast<ScriptAreaItem*>(pItem->parentItem()))
        {
            m_CopyData.push_back(std::make_pair(pScript->getScriptArea()->getArea()->getData(), pScript->getScriptArea()->getAction()->getData()));

            // calculate offset
            m_Offset.getX() = std::min(int32(pScript->x()), m_Offset.getX());
            m_Offset.getY() = std::min(int32(pScript->y()), m_Offset.getY());
        }
    }
}
Exemplo n.º 10
0
void Tile::move(MapEditor& editor, QMouseEvent* pEvent)
{
    if (m_pCurrentEditor && &editor == m_pCurrentEditor)
    {
        try
        {
            auto pos = editor.mapToScene(pEvent->pos()).toPoint();
            GEOMETRY::Point<uint32> tilePos(pos.x() / MAP::TILE_SIZE, pos.y() / MAP::TILE_SIZE);

            m_pCurrentBrush->start(tilePos);
            m_pCurrentEditor->scene()->update();
        }
        catch (const MAP::EXCEPTION::LayerOutOfRangeException&) {}
    }
    else
        _finishBrush();
}
Exemplo n.º 11
0
void MainMenu::onMapEditor() {
	MapEditor *pMapEditor = new MapEditor();
	pMapEditor->RunEditor();
	delete pMapEditor;
}
Exemplo n.º 12
0
void Editor::OnTest(wxCommandEvent& )
{
    MapEditor* editor = new MapEditor();
    editor->Show();
}