diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt index 426d3aa61..51d44137a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt @@ -7,6 +7,7 @@ ADD_SUBDIRECTORY(disp_sheet_id) ADD_SUBDIRECTORY(object_viewer) ADD_SUBDIRECTORY(georges_editor) ADD_SUBDIRECTORY(translation_manager) +ADD_SUBDIRECTORY(tile_editor) # Note: Temporarily disabled until development continues. #ADD_SUBDIRECTORY(zone_painter) # Ryzom Specific Plugins diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/CMakeLists.txt new file mode 100644 index 000000000..f3458c909 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/CMakeLists.txt @@ -0,0 +1,47 @@ +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${QT_INCLUDES}) + +FILE(GLOB SRC *.cpp *.h) +SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) + +SET(OVQT_TILE_EDITOR_PLUGIN_HDR + tile_model.h + tile_editor_main_window.h + tile_editor_plugin.h) + +SET(OVQT_TILE_EDITOR_PLUGIN_UIS + tile_editor_main_window.ui) + +SET(OVQT_PLUG_TILE_EDITOR_RCS tile_editor.qrc) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTOPENGL TRUE) + +QT4_WRAP_CPP(OVQT_TILE_EDITOR_PLUGIN_MOC_SRC ${OVQT_TILE_EDITOR_PLUGIN_HDR}) +QT4_ADD_RESOURCES( OVQT_PLUG_TILE_EDITOR_RC_SRCS ${OVQT_PLUG_TILE_EDITOR_RCS}) +QT4_WRAP_UI(OVQT_TILE_EDITOR_PLUGIN_UI_HDRS ${OVQT_TILE_EDITOR_PLUGIN_UIS}) + +SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_TILE_EDITOR_PLUGIN_UI_HDRS}) +SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_TILE_EDITOR_PLUGIN_MOC_SRC} ${OVQT_PLUG_TILE_EDITOR_RC_SRCS}) +SOURCE_GROUP("Tile Editor Plugin" FILES ${SRC}) +SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) + +ADD_LIBRARY(ovqt_plugin_tile_editor MODULE ${SRC} ${OVQT_TILE_EDITOR_PLUGIN_MOC_SRC} ${OVQT_PLUG_TILE_EDITOR_RC_SRCS} ${OVQT_EXT_SYS_SRC} ${OVQT_TILE_EDITOR_PLUGIN_UI_HDRS}) + +TARGET_LINK_LIBRARIES(ovqt_plugin_tile_editor ovqt_plugin_core nelmisc ${QT_LIBRARIES}) + +IF(WITH_STLPORT) + TARGET_LINK_LIBRARIES(ovqt_plugin_tile_editor ${CMAKE_THREAD_LIBS_INIT}) +ENDIF(WITH_STLPORT) + +NL_DEFAULT_PROPS(ovqt_plugin_tile_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Tile Editor") +NL_ADD_RUNTIME_FLAGS(ovqt_plugin_tile_editor) +NL_ADD_LIB_SUFFIX(ovqt_plugin_tile_editor) + +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) + +INSTALL(TARGETS ovqt_plugin_tile_editor LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/add_tile.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/add_tile.png new file mode 100644 index 000000000..a9de8f51d Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/add_tile.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/delete_image.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/delete_image.png new file mode 100644 index 000000000..1bc3b4e84 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/delete_image.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/delete_tile.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/delete_tile.png new file mode 100644 index 000000000..613c6a5f8 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/delete_tile.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/down.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/down.png new file mode 100644 index 000000000..b0033cf64 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/down.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/empty_image.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/empty_image.png new file mode 100644 index 000000000..9a2e358ab Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/empty_image.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_add_item.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_add_item.png new file mode 100644 index 000000000..bde338f78 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_add_item.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_delete_item.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_delete_item.png new file mode 100644 index 000000000..a5a1787d5 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_delete_item.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_new.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_new.png new file mode 100644 index 000000000..d45dcb467 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_new.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_open.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_open.png new file mode 100644 index 000000000..c4992affd Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_open.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_save.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_save.png new file mode 100644 index 000000000..7f7d35e9a Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_save.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_save_as.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_save_as.png new file mode 100644 index 000000000..1558632b9 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/ic_nel_save_as.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/left.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/left.png new file mode 100644 index 000000000..9c94db1aa Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/left.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/nel.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/nel.png new file mode 100644 index 000000000..d2139bb25 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/nel.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/replace_image.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/replace_image.png new file mode 100644 index 000000000..94d9b76c8 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/replace_image.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/reset.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/reset.png new file mode 100644 index 000000000..6693e842c Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/reset.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/right.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/right.png new file mode 100644 index 000000000..eb51b8385 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/right.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation0.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation0.png new file mode 100644 index 000000000..7434c4959 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation0.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation180.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation180.png new file mode 100644 index 000000000..7ce524883 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation180.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation270.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation270.png new file mode 100644 index 000000000..32b47a97c Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation270.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation90.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation90.png new file mode 100644 index 000000000..2eb11b322 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/rotation90.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/up.png b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/up.png new file mode 100644 index 000000000..e5145d052 Binary files /dev/null and b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/images/up.png differ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/ovqt_plugin_tile_editor.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/ovqt_plugin_tile_editor.xml new file mode 100644 index 000000000..0e21a2eb9 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/ovqt_plugin_tile_editor.xml @@ -0,0 +1,10 @@ + + ovqt_plugin_tile_editor + TileEditor + 1.0 + Ryzom Core + Tile bank editing plugin. + + + + \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor.qrc b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor.qrc new file mode 100644 index 000000000..55950d217 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor.qrc @@ -0,0 +1,29 @@ + + + images/add_tile.png + images/delete_image.png + images/delete_tile.png + images/replace_image.png + + + images/ic_nel_add_item.png + images/ic_nel_new.png + images/ic_nel_open.png + images/ic_nel_save.png + images/ic_nel_save_as.png + images/down.png + images/left.png + images/reset.png + images/right.png + images/up.png + + + images/rotation0.png + images/rotation90.png + images/rotation180.png + images/rotation270.png + + + images/empty_image.png + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_main_window.cpp new file mode 100644 index 000000000..a0faa03f8 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_main_window.cpp @@ -0,0 +1,171 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "tile_editor_main_window.h" + +#include "nel/misc/path.h" + +#include +#include +#include +#include +#include + +#include "../core/icore.h" +#include "../core/core_constants.h" +#include "../core/menu_manager.h" + +#include "tile_model.h" +#include "tile_item.h" + +TileEditorMainWindow::TileEditorMainWindow(QWidget *parent) + : QMainWindow(parent), + m_ui(new Ui::TileEditorMainWindow) +{ + m_ui->setupUi(this); + m_undoStack = new QUndoStack(this); + + // Retrieve the menu manager + Core::ICore *core = Core::ICore::instance(); + Core::MenuManager *menuManager = core->menuManager(); + + QMenu *m_tileEditorMenu; + // Create tile rotation drop down toolbar menu. + m_rotationMenu = new QMenu(tr("Rotate Tile"), m_ui->toolBar); + m_rotationMenu->setIcon(QIcon(":/tileRotation/images/rotation0.png")); + QList rotateActions; + rotateActions.push_back(m_ui->actionRotateTile0); + rotateActions.push_back(m_ui->actionRotateTile90); + rotateActions.push_back(m_ui->actionRotateTile180); + rotateActions.push_back(m_ui->actionRotateTile270); + m_rotationMenu->addActions(rotateActions); + m_ui->toolBar->addAction(m_rotationMenu->menuAction()); + + // Create the tile zoom menu. + m_zoomMenu = new QMenu(tr("Zoom"), m_ui->toolBar); + QList zoomActions; + + m_tileEditorMenu = new QMenu(tr("Tile Editor"), core->menuManager()->menuBar()); + m_tileDisplayMenu = new QMenu(tr("Tile Display"), m_ui->toolBar); + QList displayActions; + displayActions.push_back(m_ui->actionTileDisplayFilename); + displayActions.push_back(m_ui->actionTileDisplayIndex); + m_ui->actionTileDisplayIndex->setChecked(true); + m_tileDisplayMenu->addActions(displayActions); + m_tileEditorMenu->addMenu(m_tileDisplayMenu); + core->menuManager()->menuBar()->addMenu(m_tileEditorMenu); + + // Set up the list views. + QStringList headers; + headers << "Tile Set"; + m_model = new TileModel(headers, this); + + // Set up the tile set list view. + m_ui->tileSetLV->setModel(m_model); + m_ui->tileSetLV->setRootIndex(m_model->index(0,0)); + connect(m_ui->tileSetAddTB, SIGNAL(clicked()), this, SLOT(onTileSetAdd())); + + // 128x128 List View + m_ui->listView128->setModel(m_model); + m_ui->listView128->addAction(m_ui->actionAddTile); + m_ui->listView128->addAction(m_ui->actionDeleteTile); + m_ui->listView128->addAction(m_ui->actionReplaceImage); + m_ui->listView128->addAction(m_ui->actionDeleteImage); + + // Connect context menu actions up. + connect(m_ui->actionAddTile, SIGNAL(triggered(bool)), this, SLOT(onActionAddTile(bool))); + connect(m_ui->actionDeleteTile, SIGNAL(triggered(bool)), this, SLOT(onActionDeleteTile(bool))); + connect(m_ui->actionReplaceImage, SIGNAL(triggered(bool)), this, SLOT(onActionReplaceImage(bool))); + connect(m_ui->actionDeleteImage, SIGNAL(triggered(bool)), this, SLOT(onActioneleteImage(bool))); +} + +TileEditorMainWindow::~TileEditorMainWindow() +{ + delete m_ui; + delete m_undoStack; + delete m_rotationMenu; + delete m_zoomMenu; +} + +void TileEditorMainWindow::onActionAddTile(bool triggered) +{ + onActionAddTile(m_ui->tileViewTabWidget->currentIndex()); +} + +void TileEditorMainWindow::onActionDeleteTile(bool triggered) +{ +} + +void TileEditorMainWindow::onActionReplaceImage(bool triggered) +{ +} + +void TileEditorMainWindow::onActionDeleteImage(bool triggered) +{ +} + +void TileEditorMainWindow::onTileSetAdd() +{ + bool ok; + QString text = QInputDialog::getText(this, tr("Add Tile Set"), tr("Enter Tile Set name:"), QLineEdit::Normal, "", &ok); + if (ok && !text.isEmpty()) + { + //if (ui.tileSetListWidget->findItems(text, Qt::MatchExactly).count() > 0) + //{ + // QMessageBox::information( this, tr("Error Adding Tile Set"), tr("This name already exists") ); + //} + //else + //{ + + QModelIndex index = m_ui->tileSetLV->selectionModel()->currentIndex(); + TileModel *model = static_cast(m_ui->tileSetLV->model()); + + if(index.isValid()) + { + if(!model->insertRow(index.row()+1, index.parent())) + return; + + //updateActions() + + for(int column=0; columncolumnCount(index.parent()); column++) + { + QModelIndex child = model->index(index.row()+1, column, index.parent()); + model->setData(child, QVariant(text), Qt::EditRole); + } + } + else + { + QVector items; + items.push_back(QVariant(text)); + TileItem *item = new TileItem(items, 0); + model->appendRow(item); + //updateActions() + } + + // tileBank.addTileSet( text.toStdString() ); + + // ui.tileSetListWidget->addItem(text); + // ui.tileSetListWidget->setCurrentRow(ui.tileSetListWidget->count() - 1); + //} + } +} + +void TileEditorMainWindow::onActionAddTile(int tabId) +{ + QFileDialog::Options options; + QString selectedFilter; + QStringList fileNames = QFileDialog::getOpenFileNames(this, "Choose Tile Texture", "." , "PNG Bitmap(*.png);;All Files (*.*);;", &selectedFilter, options); +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_main_window.h new file mode 100644 index 000000000..2f5ce3731 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_main_window.h @@ -0,0 +1,63 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef TILE_EDITOR_MAIN_WINDOW_H +#define TILE_EDITOR_MAIN_WINDOW_H + +#include "ui_tile_editor_main_window.h" + +#include "nel/misc/types_nl.h" +#include "nel/misc/sheet_id.h" + +#include + +namespace Ui { + class TileEditorMainWindow; +} + +class TileModel; + +class TileEditorMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit TileEditorMainWindow(QWidget *parent = 0); + ~TileEditorMainWindow(); + + QUndoStack *getUndoStack() { return m_undoStack; } + +public Q_SLOTS: + void onActionAddTile(bool triggered); + void onActionDeleteTile(bool triggered); + void onActionReplaceImage(bool triggered); + void onActionDeleteImage(bool triggered); + void onTileSetAdd(); + +private: + void onActionAddTile(int tabId); + + Ui::TileEditorMainWindow *m_ui; + QUndoStack *m_undoStack; + QMenu *m_rotationMenu; + QMenu *m_zoomMenu; + QMenu *m_tileDisplayMenu; + QMenu *m_tileEditorMenu; + + TileModel *m_model; +}; + +#endif // TILE_EDITOR_MAIN_WINDOW_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_main_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_main_window.ui new file mode 100644 index 000000000..7b76e6aaa --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_main_window.ui @@ -0,0 +1,663 @@ + + + TileEditorMainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + 0 + + + + 128x128 + + + + + + Qt::ActionsContextMenu + + + + + + + Edit Channel + + + + + + Diffuse + + + true + + + + + + + Additive + + + + + + + + + + + 256x256 + + + + + + + + + Edit Channel + + + + + + Diffuse + + + true + + + true + + + + + + + Additive + + + + + + + + + + + Transition + + + + + + + + + Edit Channel + + + + + + Diffuse + + + true + + + + + + + Additive + + + + + + + Alpha + + + + + + + + + + + Displacement + + + + + + + + + + Tile Set Details + + + + + + Qt::LeftToRight + + + Oriented + + + + + + + + + + Surface Data: + + + + + + + Vegetation Set: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + ... + + + + + + + + + + + :/newPrefix/reset.png:/newPrefix/reset.png + + + + + + + + + + + + + Tile Editor Tool Bar + + + TopToolBarArea + + + false + + + + + + + + + Tile Bank + + + 1 + + + + + + + Lands + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + :/movementIcons/images/ic_nel_add_item.png:/movementIcons/images/ic_nel_add_item.png + + + + + + + ... + + + + :/movementIcons/images/reset.png:/movementIcons/images/reset.png + + + + + + + ... + + + + :/movementIcons/images/ic_nel_open.png:/movementIcons/images/ic_nel_open.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Tile Sets + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + ... + + + + :/movementIcons/images/up.png:/movementIcons/images/up.png + + + + + + + ... + + + + :/movementIcons/images/down.png:/movementIcons/images/down.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + :/movementIcons/images/ic_nel_add_item.png:/movementIcons/images/ic_nel_add_item.png + + + + + + + ... + + + + :/movementIcons/images/reset.png:/movementIcons/images/reset.png + + + + + + + ... + + + + :/movementIcons/images/ic_nel_open.png:/movementIcons/images/ic_nel_open.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + ... + + + + + + + ... + + + + + + + + + Tile Bank Texture Path + + + + + + + + + + + + + + + + :/movementIcons/images/ic_nel_open.png:/movementIcons/images/ic_nel_open.png + + + Open Tile Bank + + + Open Tile Bank + + + + + + :/tileRotation/images/rotation0.png:/tileRotation/images/rotation0.png + + + 0 + + + Rotate Tile 0 Degrees + + + + + + :/movementIcons/images/ic_nel_save.png:/movementIcons/images/ic_nel_save.png + + + Save Tile Bank + + + Save Tile Bank + + + + + + :/movementIcons/images/ic_nel_save_as.png:/movementIcons/images/ic_nel_save_as.png + + + Save Tile Bank As... + + + Save Tile Bank As... + + + + + + :/tileRotation/images/rotation90.png:/tileRotation/images/rotation90.png + + + 90 + + + Rotate Tile 90 Degrees + + + + + + :/tileRotation/images/rotation180.png:/tileRotation/images/rotation180.png + + + 180 + + + Rotate Tile180 Degrees + + + + + + :/tileRotation/images/rotation270.png:/tileRotation/images/rotation270.png + + + 270 + + + Rotate Tile 270 Degrees + + + + + Batch Load + + + Batch Load + + + + + Import Border + + + Import Border + + + + + Export Border + + + Export Border + + + + + true + + + Index + + + Display Tile Index + + + + + true + + + Filename + + + Display Tile Filename + + + + + + :/tileTools/images/add_tile.png:/tileTools/images/add_tile.png + + + Add Tile + + + Add Tile + + + + + + :/tileTools/images/delete_tile.png:/tileTools/images/delete_tile.png + + + Delete Tile + + + Delete Tile + + + + + + :/tileTools/images/replace_image.png:/tileTools/images/replace_image.png + + + Replace Image + + + Replace Image + + + + + + :/tileTools/images/delete_image.png:/tileTools/images/delete_image.png + + + Delete Image + + + Delete Image + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_plugin.cpp new file mode 100644 index 000000000..ac12766b8 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_plugin.cpp @@ -0,0 +1,75 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Project includes +#include "tile_editor_plugin.h" +#include "tile_editor_main_window.h" +#include "../core/icore.h" +#include "../core/menu_manager.h" +#include "../core/core_constants.h" + +// Qt includes +#include +#include +#include +#include +#include +#include + +// NeL includes +#include "nel/misc/debug.h" + +using namespace TileEditorPluginQt; + +TileEditorPlugin::~TileEditorPlugin() +{ + Q_FOREACH(QObject *obj, m_autoReleaseObjects) + { + m_plugMan->removeObject(obj); + } + qDeleteAll(m_autoReleaseObjects); + m_autoReleaseObjects.clear(); +} + +bool TileEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) +{ + Q_UNUSED(errorString); + m_plugMan = pluginManager; + addAutoReleasedObject(new TileEditorContext()); + return true; +} + +void TileEditorPlugin::extensionsInitialized() +{ +} + +void TileEditorPlugin::setNelContext(NLMISC::INelContext *nelContext) +{ +#ifdef NL_OS_WINDOWS + // Ensure that a context doesn't exist yet. + // This only applies to platforms without PIC, e.g. Windows. + nlassert(!NLMISC::INelContext::isContextInitialised()); +#endif // NL_OS_WINDOWS + m_LibContext = new NLMISC::CLibraryContext(*nelContext); +} + +void TileEditorPlugin::addAutoReleasedObject(QObject *obj) +{ + m_plugMan->addObject(obj); + m_autoReleaseObjects.prepend(obj); +} + +Q_EXPORT_PLUGIN(TileEditorPlugin) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_plugin.h new file mode 100644 index 000000000..2398be2c4 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_editor_plugin.h @@ -0,0 +1,109 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef TILE_EDITOR_PLUGIN_H +#define TILE_EDITOR_PLUGIN_H + +#include "../../extension_system/iplugin.h" +#include "../core/icontext.h" + +#include "nel/misc/app_context.h" + +#include "tile_editor_main_window.h" + +#include + +namespace NLMISC +{ +class CLibraryContext; +} + +namespace TileEditorPluginQt +{ + +class TileEditorPlugin : public QObject, public ExtensionSystem::IPlugin +{ + Q_OBJECT + Q_INTERFACES(ExtensionSystem::IPlugin) +public: + + ~TileEditorPlugin(); + + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); + void extensionsInitialized(); + void setNelContext(NLMISC::INelContext *nelContext); + + void addAutoReleasedObject(QObject *obj); + +protected: + NLMISC::CLibraryContext *m_LibContext; + +private: + ExtensionSystem::IPluginManager *m_plugMan; + QList m_autoReleaseObjects; + +}; + +class TileEditorContext: public Core::IContext +{ + Q_OBJECT +public: + TileEditorContext(QObject *parent = 0) : IContext(parent) + { + m_tileEditorMainWindow = new TileEditorMainWindow(); + } + + virtual ~TileEditorContext() + { + delete m_tileEditorMainWindow; + } + + virtual QString id() const + { + return QLatin1String("TileEditor"); + } + + virtual QString trName() const + { + return tr("Tile Editor"); + } + + virtual QIcon icon() const + { + return QIcon(":/tileRotation/images/rotation0.png"); + } + + virtual QUndoStack *undoStack() + { + return m_tileEditorMainWindow->getUndoStack(); + } + + virtual void open() + { + } + + virtual QWidget *widget() + { + return m_tileEditorMainWindow; + } + +private: + TileEditorMainWindow *m_tileEditorMainWindow; +}; + +} // namespace TileEditorPluginQt + +#endif // TILE_EDITOR_PLUGIN_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_item.cpp new file mode 100644 index 000000000..d6c87017d --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_item.cpp @@ -0,0 +1,138 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "tile_item.h" + +TileItem::TileItem(const QVector &data, TileItem *parent) +{ + parentItem = parent; + itemData = data; +} + +TileItem::~TileItem() +{ + qDeleteAll(childItems); +} + +void TileItem::appendChild(TileItem *item) +{ + childItems.append(item); +} + +TileItem *TileItem::child(int row) +{ + return childItems.value(row); +} + +int TileItem::childCount() const +{ + return childItems.count(); +} + +int TileItem::childNumber() const +{ + if(parentItem) + return parentItem->childItems.indexOf(const_cast(this)); + return 0; +} + +bool TileItem::insertChildren(int position, int count, int columns) +{ + if(position<0 || position>childItems.size()) + return false; + + for(int row = 0; row < count; row++) + { + QVector data(columns); + TileItem *item = new TileItem(data, this); + childItems.insert(position, item); + } + + return true; +} + +bool TileItem::removeChildren(int position, int count) +{ + if(position<0 || position+count>childItems.size()) + return false; + + for(int row=0; row itemData.size()) + return false; + + for(int column=0; columninsertColumns(position, columns); + + return true; +} + +int TileItem::row() const +{ + if(parentItem) + return parentItem->childItems.indexOf(const_cast(this)); + + return 0; +} + +int TileItem::columnCount() const +{ + return itemData.count(); +} + +QVariant TileItem::data(int column) const +{ + return itemData.value(column); +} + +bool TileItem::setData(int column, const QVariant &value) +{ + if(column < 0 || column >= itemData.size()) + return false; + + itemData[column] = value; + return true; +} + +TileItem *TileItem::parent() +{ + return parentItem; +} + +void TileItem::appendRow(const QList &items) +{ + Q_FOREACH(TileItem *item, items) + appendRow(item); +} + +void TileItem::appendRow(TileItem *item) +{ + childItems.append(item); +} +//QImage *TileItem::getTileImageFromChannel(int channel) +//{ +// return m_tileChannels[channel]; +//} + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_item.h new file mode 100644 index 000000000..4d9f13e0f --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_item.h @@ -0,0 +1,66 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef TILE_ITEM_H +#define TILE_ITEM_H + +#include "nel/misc/types_nl.h" + +#include +#include + +class TileItem +{ +public: + + TileItem(const QVector &data, TileItem *parent=0); + ~TileItem(); + + void appendChild(TileItem *child); + + TileItem *child(int row); + int childCount() const; + int childNumber() const; + int columnCount() const; + bool setData(int column, const QVariant &value); + QVariant data(int column) const; + + bool insertChildren(int position, int count, int columns); + bool removeChildren(int position, int count); + bool insertColumns(int position, int columns); + + int row() const; + TileItem *parent(); + + void appendRow(const QList &items); + void appendRow(TileItem *item); + + //QImage *getTileImageFromChannel(int channel); + + //int getTileIndex() { return m_tileIndex; } + //QString getTileFilename() { return m_tileFilename; } + +private: + QList childItems; + QVector itemData; + TileItem *parentItem; + + //QMap m_tileChannels; + //int m_tileIndex; + //QString m_tileFilename; +}; + +#endif // TILE_ITEM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_model.cpp new file mode 100644 index 000000000..20911310c --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_model.cpp @@ -0,0 +1,123 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "tile_model.h" +#include "tile_item.h" + +#include + +TileModel::TileModel(const QStringList &headers, QObject *parent) : QAbstractItemModel(parent) +{ + QVector rootData; + Q_FOREACH(QString header, headers) + rootData << header; + + rootItem = new TileItem(rootData); +} + +TileModel::~TileModel() +{ + delete rootItem; +} + +TileItem *TileModel::getItem(const QModelIndex &index) const +{ + if(index.isValid()) + { + TileItem *item = static_cast(index.internalPointer()); + if(item) return item; + } + return rootItem; +} + +QModelIndex TileModel::index(int row, int column, const QModelIndex &parent) const +{ + if(parent.isValid() && parent.column() != 0) + return QModelIndex(); + + TileItem *parentItem = getItem(parent); + + TileItem *childItem = parentItem->child(row); + if(childItem) + return createIndex(row, column, childItem); + else + return QModelIndex(); +} + +QModelIndex TileModel::parent(const QModelIndex &index) const +{ + if(!index.isValid()) + return QModelIndex(); + + TileItem *childItem = getItem(index); + TileItem *parentItem = childItem->parent(); + + if(parentItem == rootItem) + return QModelIndex(); + + return createIndex(parentItem->childNumber(), 0, parentItem); +} + +int TileModel::rowCount(const QModelIndex &parent) const +{ + TileItem *parentItem = getItem(parent); + return parentItem->childCount(); +} + +int TileModel::columnCount(const QModelIndex &parent) const +{ + TileItem *parentItem = getItem(parent); + return parentItem->columnCount(); +} + +QVariant TileModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid()) + return QVariant(); + + if(role != Qt::DisplayRole) + return QVariant(); + + TileItem *item = static_cast(index.internalPointer()); + return item->data(index.column()); +} + +Qt::ItemFlags TileModel::flags(const QModelIndex &index) const +{ + if(!index.isValid()) + return Qt::ItemIsEnabled; + + return Qt::ItemIsEnabled|Qt::ItemIsSelectable; +} + +QVariant TileModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(orientation == Qt::Horizontal && role == Qt::DisplayRole) + return rootItem->data(section); + + return QVariant(); +} + +void TileModel::appendRow(const QList &items) +{ + rootItem->appendRow(items); +} + + +void TileModel::appendRow(TileItem *item) +{ + rootItem->appendRow(item); +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_model.h new file mode 100644 index 000000000..692d1ee65 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/tile_editor/tile_model.h @@ -0,0 +1,54 @@ +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef TILE_MODEL_H +#define TILE_MODEL_H + +#include "nel/misc/types_nl.h" + +#include + +class TileItem; + +class TileModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + TileModel::TileModel(const QStringList &headers, QObject *parent); + ~TileModel(); + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, const QModelIndex &parent= QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + + // Tile Model specific functions + void appendRow(const QList &items); + void appendRow(TileItem *item); + +private: + TileItem *getItem(const QModelIndex &index) const; + + //QList m_tiles; + //int m_activeEditChannel; + TileItem *rootItem; +}; + +#endif // TILE_128_MODEL_H