Merged Georges Editor branch.

This commit is contained in:
dfighter1985 2014-04-22 21:12:26 +02:00
commit e24447e98c
36 changed files with 2347 additions and 0 deletions

View file

@ -13,6 +13,7 @@ IF(WITH_GUI)
ENDIF(WITH_GUI) ENDIF(WITH_GUI)
ADD_SUBDIRECTORY(translation_manager) ADD_SUBDIRECTORY(translation_manager)
ADD_SUBDIRECTORY(tile_editor)
ADD_SUBDIRECTORY(bnp_manager) ADD_SUBDIRECTORY(bnp_manager)
# Note: Temporarily disabled until development continues. # Note: Temporarily disabled until development continues.
#ADD_SUBDIRECTORY(zone_painter) #ADD_SUBDIRECTORY(zone_painter)

View file

@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View file

@ -0,0 +1,10 @@
<plugin-spec>
<library-name>ovqt_plugin_tile_editor</library-name>
<name>TileEditor</name>
<version>1.0</version>
<vendor>Ryzom Core</vendor>
<description>Tile bank editing plugin.</description>
<dependencies>
<dependency plugin-name="Core" version="0.8"/>
</dependencies>
</plugin-spec>

View file

@ -0,0 +1,29 @@
<RCC>
<qresource prefix="tileTools">
<file>images/add_tile.png</file>
<file>images/delete_image.png</file>
<file>images/delete_tile.png</file>
<file>images/replace_image.png</file>
</qresource>
<qresource prefix="movementIcons">
<file>images/ic_nel_add_item.png</file>
<file>images/ic_nel_new.png</file>
<file>images/ic_nel_open.png</file>
<file>images/ic_nel_save.png</file>
<file>images/ic_nel_save_as.png</file>
<file>images/down.png</file>
<file>images/left.png</file>
<file>images/reset.png</file>
<file>images/right.png</file>
<file>images/up.png</file>
</qresource>
<qresource prefix="tileRotation">
<file>images/rotation0.png</file>
<file>images/rotation90.png</file>
<file>images/rotation180.png</file>
<file>images/rotation270.png</file>
</qresource>
<qresource prefix="placeHolder">
<file>images/empty_image.png</file>
</qresource>
</RCC>

View file

@ -0,0 +1,299 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#include "tile_editor_main_window.h"
#include "nel/misc/path.h"
#include <QtGui/QMessageBox>
#include <QtGui/QApplication>
#include <QtGui/QMenu>
#include <QFileDialog>
#include <QInputDialog>
#include "../core/icore.h"
#include "../core/core_constants.h"
#include "../core/menu_manager.h"
#include "tile_model.h"
#include "tile_item.h"
#include "tile_item_delegate.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();
// 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<QAction*> 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);
m_zoomActionGroup = new QActionGroup(this);
m_zoomSignalMapper = new QSignalMapper(this);
QList<QAction*> zoomActions;
zoomActions.push_back(m_ui->actionZoom50);
zoomActions.push_back(m_ui->actionZoom100);
zoomActions.push_back(m_ui->actionZoom200);
m_zoomActionGroup->addAction(m_ui->actionZoom50);
m_zoomActionGroup->addAction(m_ui->actionZoom100);
m_zoomActionGroup->addAction(m_ui->actionZoom200);
m_zoomMenu->addActions(zoomActions);
m_ui->toolBar->addAction(m_zoomMenu->menuAction());
m_tileEditorMenu = new QMenu(tr("Tile Editor"), core->menuManager()->menuBar());
m_tileDisplayMenu = new QMenu(tr("Tile Display"), m_ui->toolBar);
QList<QAction*> 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);
m_tileItemDelegate = new TileItemDelegate();
// 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()));
connect(m_ui->tileSetLV->selectionModel(),
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(changeActiveTileSet(const QModelIndex &, const QModelIndex &)));
// 128x128 List View
//m_ui->listView128->setItemDelegate(m_tileItemDelegate);
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);
// 256x256 List View
//m_ui->listView256->setItemDelegate(m_tileItemDelegate);
m_ui->listView256->setModel(m_model);
m_ui->listView256->addAction(m_ui->actionAddTile);
m_ui->listView256->addAction(m_ui->actionDeleteTile);
m_ui->listView256->addAction(m_ui->actionReplaceImage);
m_ui->listView256->addAction(m_ui->actionDeleteImage);
// Transition List View
//m_ui->listViewTransition->setItemDelegate(m_tileItemDelegate);
m_ui->listViewTransition->setModel(m_model);
m_ui->listViewTransition->addAction(m_ui->actionReplaceImage);
m_ui->listViewTransition->addAction(m_ui->actionDeleteImage);
// Displacement List View
//m_ui->listViewDisplacement->setItemDelegate(m_tileItemDelegate);
m_ui->listViewDisplacement->setModel(m_model);
m_ui->listViewDisplacement->addAction(m_ui->actionReplaceImage);
m_ui->listViewDisplacement->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)));
connect(m_ui->actionTileDisplayFilename, SIGNAL(toggled(bool)), m_model, SLOT(selectFilenameDisplay(bool)));
connect(m_ui->actionTileDisplayIndex, SIGNAL(toggled(bool)), m_model, SLOT(selectIndexDisplay(bool)));
//connect(m_ui->tileViewTabWidget, SIGNAL(currentChanged(int)), m_tileItemDelegate, SLOT(currentTab(int)));
// Connect the zoom buttons.
connect(m_ui->actionZoom50, SIGNAL(triggered()), m_zoomSignalMapper, SLOT(map()));
m_zoomSignalMapper->setMapping(m_ui->actionZoom50, 0);
connect(m_ui->actionZoom100, SIGNAL(triggered()), m_zoomSignalMapper, SLOT(map()));
m_zoomSignalMapper->setMapping(m_ui->actionZoom100, 1);
connect(m_ui->actionZoom200, SIGNAL(triggered()), m_zoomSignalMapper, SLOT(map()));
m_zoomSignalMapper->setMapping(m_ui->actionZoom200, 2);
connect(m_zoomSignalMapper, SIGNAL(mapped(int)), this, SLOT(onZoomFactor(int)));
}
TileEditorMainWindow::~TileEditorMainWindow()
{
delete m_ui;
delete m_undoStack;
delete m_rotationMenu;
delete m_zoomMenu;
delete m_tileDisplayMenu;
delete m_tileEditorMenu;
delete m_zoomMenu;
delete m_zoomActionGroup;
delete m_zoomSignalMapper;
}
void TileEditorMainWindow::onZoomFactor(int level)
{
int tile128Scaled=TileModel::TILE_128_BASE_SIZE;
int tile256Scaled=TileModel::TILE_256_BASE_SIZE;
int tileTransScaled=TileModel::TILE_TRANSITION_BASE_SIZE;
int tileDispScaled=TileModel::TILE_DISPLACE_BASE_SIZE;
switch(level)
{
// Zoom Level 50%
case 0:
nlinfo("zooming to 50%");
TileModel::CurrentZoomFactor = TileModel::TileZoom50;
tile128Scaled /= 2;
tile256Scaled /= 2;
tileTransScaled /= 2;
tileDispScaled /= 2;
break;
case 1:
nlinfo("zooming to 100%");
TileModel::CurrentZoomFactor = TileModel::TileZoom100;
break;
case 2:
nlinfo("zooming to 200%");
TileModel::CurrentZoomFactor = TileModel::TileZoom200;
tile128Scaled *= 2;
tile256Scaled *= 2;
tileTransScaled *= 2;
tileDispScaled *= 2;
break;
default:
nlwarning("Invalid Time Zoom Factor passed.");
break;
};
nlinfo("resizing transition view. base size: %d factor %d to: %d", TileModel::TILE_TRANSITION_BASE_SIZE, level, tileTransScaled);
m_ui->listView128->setIconSize(QSize(tile128Scaled, tile128Scaled));
m_ui->listView128->setCurrentIndex(m_ui->listView128->model()->index(0, 0, m_ui->listView128->rootIndex()));
m_ui->listView256->setIconSize(QSize(tile256Scaled, tile256Scaled));
m_ui->listView256->setCurrentIndex(m_ui->listView256->model()->index(0, 0, m_ui->listView256->rootIndex()));
m_ui->listViewTransition->setIconSize(QSize(tileTransScaled, tileTransScaled));
m_ui->listViewTransition->setCurrentIndex(m_ui->listViewTransition->model()->index(0, 0, m_ui->listViewTransition->rootIndex()));
m_ui->listViewDisplacement->setIconSize(QSize(tileDispScaled, tileDispScaled));
m_ui->listViewDisplacement->setCurrentIndex(m_ui->listViewDisplacement->model()->index(0, 0, m_ui->listViewDisplacement->rootIndex()));
m_ui->listViewTransition->repaint();
}
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<TileModel*>(m_ui->tileSetLV->model());
//if(index.isValid())
//{
// if(!model->insertRow(index.row()+1, index.parent()))
// return;
// //updateActions()
// for(int column=0; column<model->columnCount(index.parent()); column++)
// {
// QModelIndex child = model->index(index.row()+1, column, index.parent());
// model->setData(child, QVariant(text), Qt::EditRole);
// }
//}
//else
//{
// Create and append the new tile set to the model.
TileSetNode *tileSet = model->createTileSetNode(text);
// Retrieve how many rows there currently are and set the current index using that.
m_ui->tileSetLV->reset();
uint32 rows = model->rowCount();
m_ui->tileSetLV->setCurrentIndex(model->index(rows-1, 0));
}
}
void TileEditorMainWindow::onActionAddTile(int tabId)
{
QFileDialog::Options options;
QString selectedFilter;
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Choose Tile Texture", "." , "Images (*.png);;All Files (*.*)", &selectedFilter, options);
}
void TileEditorMainWindow::changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex)
{
TileModel *model = static_cast<TileModel*>(m_ui->tileSetLV->model());
QModelIndex tile128Idx = model->index(0, 0, newIndex);
QModelIndex tile256Idx = model->index(1, 0, newIndex);
QModelIndex tileTransIdx = model->index(2, 0, newIndex);
QModelIndex tileDispIdx = model->index(3, 0, newIndex);
m_ui->listView128->setRootIndex(tile128Idx);
m_ui->listView128->setCurrentIndex(m_ui->listView128->model()->index(0, 0, m_ui->listView128->rootIndex()));
m_ui->listView256->setRootIndex(tile256Idx);
m_ui->listView256->setCurrentIndex(m_ui->listView256->model()->index(0, 0, m_ui->listView256->rootIndex()));
m_ui->listViewTransition->setRootIndex(tileTransIdx);
m_ui->listViewTransition->setCurrentIndex(m_ui->listViewTransition->model()->index(0, 0, m_ui->listViewTransition->rootIndex()));
m_ui->listViewDisplacement->setRootIndex(tileDispIdx);
m_ui->listViewDisplacement->setCurrentIndex(m_ui->listViewDisplacement->model()->index(0, 0, m_ui->listViewDisplacement->rootIndex()));
//nlinfo("number of rows in displacement: %d", tileDispIdx.model()->rowCount(tileDispIdx));
//m_ui->listView128->reset();
//m_ui->listView256->reset();
//m_ui->listViewTransition->reset();
//m_ui->listViewDisplacement->reset();
}

View file

@ -0,0 +1,72 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#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 <QtGui/QUndoStack>
#include <QSignalMapper>
namespace Ui {
class TileEditorMainWindow;
}
class TileModel;
class TileItemDelegate;
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();
void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex);
void onZoomFactor(int level);
private:
void onActionAddTile(int tabId);
Ui::TileEditorMainWindow *m_ui;
QUndoStack *m_undoStack;
QMenu *m_rotationMenu;
QMenu *m_tileDisplayMenu;
QMenu *m_tileEditorMenu;
QMenu *m_zoomMenu;
QActionGroup *m_zoomActionGroup;
QSignalMapper *m_zoomSignalMapper;
TileModel *m_model;
TileItemDelegate *m_tileItemDelegate;
};
#endif // TILE_EDITOR_MAIN_WINDOW_H

View file

@ -0,0 +1,795 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TileEditorMainWindow</class>
<widget class="QMainWindow" name="TileEditorMainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tileViewTabWidget">
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="tab128">
<attribute name="title">
<string>128x128</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="QListView" name="listView128">
<property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="iconSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="editChannel128GB">
<property name="title">
<string>Edit Channel</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="radioButton_5">
<property name="text">
<string>Diffuse</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_6">
<property name="text">
<string>Additive</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab256">
<attribute name="title">
<string>256x256</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QListView" name="listView256">
<property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="iconSize">
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="editChannel256GB">
<property name="title">
<string>Edit Channel</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QRadioButton" name="radioButton_10">
<property name="text">
<string>Diffuse</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_9">
<property name="text">
<string>Additive</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabTransition">
<attribute name="title">
<string>Transition</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<widget class="QListView" name="listViewTransition">
<property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="iconSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="layoutMode">
<enum>QListView::SinglePass</enum>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="editChannelTransitionGB">
<property name="title">
<string>Edit Channel</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QRadioButton" name="radioButton_13">
<property name="text">
<string>Diffuse</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_12">
<property name="text">
<string>Additive</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_11">
<property name="text">
<string>Alpha</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabDisplacement">
<attribute name="title">
<string>Displacement</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_13">
<item row="0" column="0">
<widget class="QListView" name="listViewDisplacement">
<property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>true</bool>
</property>
<property name="resizeMode">
<enum>QListView::Fixed</enum>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="uniformItemSizes">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabTileSetDetails">
<attribute name="title">
<string>Tile Set Details</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="6" column="0">
<widget class="QCheckBox" name="orientedCheckBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Oriented</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLineEdit" name="surfaceDataLineEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Surface Data:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Vegetation Set:</string>
</property>
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="chooseVegetPushButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="resetVegetPushButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../tile_edit_qt/tile_edit_qt.qrc">
<normaloff>:/newPrefix/reset.png</normaloff>:/newPrefix/reset.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>Tile Editor Tool Bar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionOpenTileBank"/>
<addaction name="actionSaveTileBank"/>
<addaction name="actionSaveTileBankAs"/>
<addaction name="separator"/>
</widget>
<widget class="QDockWidget" name="tileBankDockWidget">
<property name="windowTitle">
<string>Tile Bank</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Lands</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QListWidget" name="listWidget"/>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton_3">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/ic_nel_add_item.png</normaloff>:/movementIcons/images/ic_nel_add_item.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_2">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/reset.png</normaloff>:/movementIcons/images/reset.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/ic_nel_open.png</normaloff>:/movementIcons/images/ic_nel_open.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Tile Sets</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton_5">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/up.png</normaloff>:/movementIcons/images/up.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_4">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/down.png</normaloff>:/movementIcons/images/down.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="tileSetAddTB">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/ic_nel_add_item.png</normaloff>:/movementIcons/images/ic_nel_add_item.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_7">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/reset.png</normaloff>:/movementIcons/images/reset.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_6">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/ic_nel_open.png</normaloff>:/movementIcons/images/ic_nel_open.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPushButton" name="tileBankTexturePathPB">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tileBankTexturePathTB">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Tile Bank Texture Path</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QListView" name="tileSetLV"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<action name="actionOpenTileBank">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/ic_nel_open.png</normaloff>:/movementIcons/images/ic_nel_open.png</iconset>
</property>
<property name="text">
<string>Open Tile Bank</string>
</property>
<property name="toolTip">
<string>Open Tile Bank</string>
</property>
</action>
<action name="actionRotateTile0">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/tileRotation/images/rotation0.png</normaloff>:/tileRotation/images/rotation0.png</iconset>
</property>
<property name="text">
<string>0</string>
</property>
<property name="toolTip">
<string>Rotate Tile 0 Degrees</string>
</property>
</action>
<action name="actionSaveTileBank">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/ic_nel_save.png</normaloff>:/movementIcons/images/ic_nel_save.png</iconset>
</property>
<property name="text">
<string>Save Tile Bank</string>
</property>
<property name="toolTip">
<string>Save Tile Bank</string>
</property>
</action>
<action name="actionSaveTileBankAs">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/movementIcons/images/ic_nel_save_as.png</normaloff>:/movementIcons/images/ic_nel_save_as.png</iconset>
</property>
<property name="text">
<string>Save Tile Bank As...</string>
</property>
<property name="toolTip">
<string>Save Tile Bank As...</string>
</property>
</action>
<action name="actionRotateTile90">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/tileRotation/images/rotation90.png</normaloff>:/tileRotation/images/rotation90.png</iconset>
</property>
<property name="text">
<string>90</string>
</property>
<property name="toolTip">
<string>Rotate Tile 90 Degrees</string>
</property>
</action>
<action name="actionRotateTile180">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/tileRotation/images/rotation180.png</normaloff>:/tileRotation/images/rotation180.png</iconset>
</property>
<property name="text">
<string>180</string>
</property>
<property name="toolTip">
<string>Rotate Tile180 Degrees</string>
</property>
</action>
<action name="actionRotateTile270">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/tileRotation/images/rotation270.png</normaloff>:/tileRotation/images/rotation270.png</iconset>
</property>
<property name="text">
<string>270</string>
</property>
<property name="toolTip">
<string>Rotate Tile 270 Degrees</string>
</property>
</action>
<action name="actionBatchLoad">
<property name="text">
<string>Batch Load</string>
</property>
<property name="toolTip">
<string>Batch Load</string>
</property>
</action>
<action name="actionImportBorder">
<property name="text">
<string>Import Border</string>
</property>
<property name="toolTip">
<string>Import Border</string>
</property>
</action>
<action name="actionExportBorder">
<property name="text">
<string>Export Border</string>
</property>
<property name="toolTip">
<string>Export Border</string>
</property>
</action>
<action name="actionTileDisplayIndex">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Index</string>
</property>
<property name="toolTip">
<string>Display Tile Index</string>
</property>
</action>
<action name="actionTileDisplayFilename">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Filename</string>
</property>
<property name="toolTip">
<string>Display Tile Filename</string>
</property>
</action>
<action name="actionAddTile">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/tileTools/images/add_tile.png</normaloff>:/tileTools/images/add_tile.png</iconset>
</property>
<property name="text">
<string>Add Tile</string>
</property>
<property name="toolTip">
<string>Add Tile</string>
</property>
</action>
<action name="actionDeleteTile">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/tileTools/images/delete_tile.png</normaloff>:/tileTools/images/delete_tile.png</iconset>
</property>
<property name="text">
<string>Delete Tile</string>
</property>
<property name="toolTip">
<string>Delete Tile</string>
</property>
</action>
<action name="actionReplaceImage">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/tileTools/images/replace_image.png</normaloff>:/tileTools/images/replace_image.png</iconset>
</property>
<property name="text">
<string>Replace Image</string>
</property>
<property name="toolTip">
<string>Replace Image</string>
</property>
</action>
<action name="actionDeleteImage">
<property name="icon">
<iconset resource="tile_editor.qrc">
<normaloff>:/tileTools/images/delete_image.png</normaloff>:/tileTools/images/delete_image.png</iconset>
</property>
<property name="text">
<string>Delete Image</string>
</property>
<property name="toolTip">
<string>Delete Image</string>
</property>
</action>
<action name="actionZoom50">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Zoom 50%</string>
</property>
</action>
<action name="actionZoom100">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Zoom 100%</string>
</property>
</action>
<action name="actionZoom200">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Zoom 200%</string>
</property>
</action>
</widget>
<resources>
<include location="tile_editor.qrc"/>
<include location="../../../../tile_edit_qt/tile_edit_qt.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -0,0 +1,75 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
// 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 <QtCore/QObject>
#include <QtGui/QMessageBox>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QAction>
#include <QtGui/QMenuBar>
// 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)

View file

@ -0,0 +1,109 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#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 <QtCore/QObject>
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<QObject *> 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

View file

@ -0,0 +1,292 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#include <QPixmap>
#include "tile_item.h"
//#include "tile_widget.h"
#include <nel/misc/debug.h>
Node::Node() : m_parentItem(0)
{
}
Node::Node(const QVector<QVariant> &data, Node *parent)
{
m_parentItem = parent;
m_itemData = data;
}
Node::~Node()
{
qDeleteAll(m_childItems);
}
void Node::appendChild(Node *item)
{
m_childItems.append(item);
}
Node *Node::child(int row)
{
//nlinfo("row %d and size %d", row, childItems.size());
return m_childItems.value(row);
}
int Node::childCount() const
{
return m_childItems.count();
}
int Node::childNumber() const
{
if(m_parentItem)
return m_parentItem->m_childItems.indexOf(const_cast<Node*>(this));
return 0;
}
bool Node::insertChildren(int position, int count, int columns)
{
if(position<0 || position>m_childItems.size())
return false;
for(int row = 0; row < count; row++)
{
QVector<QVariant> data(columns);
Node *item = new Node(data, this);
m_childItems.insert(position, item);
}
return true;
}
bool Node::removeChildren(int position, int count)
{
if(position<0 || position+count>m_childItems.size())
return false;
for(int row=0; row<count; row++)
delete m_childItems.takeAt(position);
return true;
}
bool Node::insertColumns(int position, int columns)
{
if(position<0 || position > m_itemData.size())
return false;
for(int column=0; column<columns; column++)
m_itemData.insert(position, columns);
Q_FOREACH(Node *child, m_childItems)
child->insertColumns(position, columns);
return true;
}
int Node::row() const
{
if(m_parentItem)
return m_parentItem->m_childItems.indexOf(const_cast<Node*>(this));
return 0;
}
int Node::columnCount() const
{
return m_itemData.count();
}
QVariant Node::data(int column, int role) const
{
if(role == Qt::DisplayRole ||
role == TileModel::TileFilenameIndexRole ||
role == TileModel::TileFilenameRole ||
role == TileModel::TileIndexRole)
return m_itemData.value(column);
return QVariant();
}
bool Node::setData(int column, const QVariant &value)
{
if(column < 0 || column >= m_itemData.size())
return false;
m_itemData[column] = value;
return true;
}
Node *Node::parent()
{
return m_parentItem;
}
void Node::setParent(Node *parent)
{
m_parentItem = parent;
}
void Node::appendRow(const QList<Node*> &items)
{
Q_FOREACH(Node *item, items)
appendRow(item);
}
void Node::appendRow(Node *item)
{
item->setParent(this);
m_childItems.append(item);
}
///////////////////////////////////////////////////
TileSetNode::TileSetNode(QString tileSetName, Node *parent) : m_tileSetName(tileSetName)
{
m_parentItem = parent;
}
TileSetNode::~TileSetNode()
{
qDeleteAll(m_childItems);
}
QVariant TileSetNode::data(int column, int role) const
{
if(role == Qt::DisplayRole ||
role == TileModel::TileFilenameIndexRole ||
role == TileModel::TileFilenameRole ||
role == TileModel::TileIndexRole)
return QVariant(m_tileSetName);
return QVariant();
}
int TileSetNode::columnCount() const
{
return 1;
}
///////////////////////////////////////////////////
TileTypeNode::TileTypeNode(TileModel::TNodeTileType type, Node *parent) : m_nodeTileType(type)
{
m_parentItem = parent;
}
TileTypeNode::~TileTypeNode()
{
qDeleteAll(m_childItems);
}
QVariant TileTypeNode::data(int column, int role) const
{
if(role == Qt::DisplayRole ||
role == TileModel::TileFilenameIndexRole ||
role == TileModel::TileFilenameRole ||
role == TileModel::TileIndexRole)
return QVariant(TileModel::getTileTypeName(m_nodeTileType));
return QVariant();
}
int TileTypeNode::columnCount() const
{
return 1;
}
TileModel::TNodeTileType TileTypeNode::getTileType()
{
return m_nodeTileType;
}
///////////////////////////////////////////////////
TileItemNode::TileItemNode(int tileId, TileModel::TTileChannel channel, QString filename, Node *parent) : m_tileId(tileId)
{
m_tileFilename[channel] = filename;
m_parentItem = parent;
//nlinfo("dispalying tile %d - %s", m_tileId, m_tileFilename[TileModel::TileDiffuse].toStdString().c_str());
}
TileItemNode::~TileItemNode()
{
qDeleteAll(m_childItems);
}
void TileItemNode::setTileFilename(TileModel::TTileChannel channel, QString filename)
{
m_tileFilename[channel] = filename;
}
QVariant TileItemNode::data(int column, int role) const
{
// find some way to know which file/bitmap to display
QString tileFilename = m_tileFilename[TileModel::TileDiffuse];
if(role == TileModel::TilePixmapRole || role == Qt::DecorationRole)
{
TileTypeNode *parent = dynamic_cast<TileTypeNode*>(m_parentItem);
if(parent == NULL)
return QVariant();
// Retrieve the target tile size.
uint32 tileSize = TileModel::getTileTypeSize(parent->getTileType());
if(tileFilename.isEmpty() || tileFilename == "empty")
tileFilename = ":/placeHolder/images/empty_image.png";
QPixmap pixmap;// = new QPixmap();
if(!pixmap.load(tileFilename))
nlinfo("failed to load %s", tileFilename.toStdString().c_str());
if(TileModel::CurrentZoomFactor == TileModel::TileZoom200)
tileSize *= 2;
else if(TileModel::CurrentZoomFactor == TileModel::TileZoom50)
tileSize /= 2;
pixmap.scaled(tileSize, tileSize);
return pixmap;
}
else if(role == Qt::DisplayRole)
{
return QVariant(tileFilename);
}
else if(role == TileModel::TileFilenameRole)
{
return QVariant(tileFilename);
}
else if(role == TileModel::TileIndexRole)
{
return QVariant("("+QString::number(m_tileId)+")");
}
else if(role == TileModel::TileFilenameIndexRole)
{
return QVariant(tileFilename + " ("+QString::number(m_tileId)+")");
}
return QVariant();
}
int TileItemNode::columnCount() const
{
return 1;
}

View file

@ -0,0 +1,103 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef TILE_ITEM_H
#define TILE_ITEM_H
#include "nel/misc/types_nl.h"
#include <QAbstractListModel>
#include <QVector>
#include "tile_model.h"
class TileWidget;
class Node
{
public:
Node();
Node(const QVector<QVariant> &data, Node *parent=0);
virtual ~Node();
void appendChild(Node *child);
Node *child(int row);
int childCount() const;
int childNumber() const;
virtual int columnCount() const;
bool setData(int column, const QVariant &value);
virtual QVariant data(int column, int role) const;
bool insertChildren(int position, int count, int columns);
bool removeChildren(int position, int count);
bool insertColumns(int position, int columns);
int row() const;
Node *parent();
void setParent(Node *parent);
void appendRow(const QList<Node*> &items);
void appendRow(Node *item);
protected:
QList<Node*> m_childItems;
QVector<QVariant> m_itemData;
Node *m_parentItem;
};
class TileSetNode : public Node
{
public:
TileSetNode(QString tileSetName, Node *parent=0);
virtual ~TileSetNode();
QVariant data(int column, int role) const;
int columnCount() const;
const QString &getTileSetName();
private:
QString m_tileSetName;
};
class TileTypeNode : public Node
{
public:
TileTypeNode(TileModel::TNodeTileType type, Node *parent=0);
virtual ~TileTypeNode();
QVariant data(int column, int role) const;
int columnCount() const;
TileModel::TNodeTileType getTileType();
private:
TileModel::TNodeTileType m_nodeTileType;
};
class TileItemNode : public Node
{
public:
TileItemNode(int tileId, TileModel::TTileChannel channel, QString filename, Node *parent=0);
virtual ~TileItemNode();
QVariant data(int column, int role) const;
int columnCount() const;
void setTileFilename(TileModel::TTileChannel channel, QString filename);
private:
int m_tileId;
QMap<TileModel::TTileChannel, QString> m_tileFilename;
QMap<TileModel::TTileChannel, TileWidget*> m_tileWidget;
};
#endif // TILE_ITEM_H

View file

@ -0,0 +1,122 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#include <QtGui/QtGui>
#include <nel/misc/debug.h>
#include "tile_item_delegate.h"
#include "tile_model.h"
TileItemDelegate::TileItemDelegate()
{
m_zoomFactor = ZoomNormal;
m_imageHint = 128;
}
TileItemDelegate::~TileItemDelegate()
{
}
void TileItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter,option,index);
painter->save();
QFont font = QApplication::font();
//font.setBold(true);
//SubFont.setWeight(SubFont.weight()-2);
QFontMetrics fm(font);
QPixmap tile = qvariant_cast<QPixmap>(index.data(TileModel::TilePixmapRole));
QString tileFileText = qvariant_cast<QString>(index.data(TileModel::TileFilenameRole));
QString tileIdText = qvariant_cast<QString>(index.data(TileModel::TileIndexRole));
QSize tileSize = tile.size();
//QRect headerRect = option.rect;
QRect rect(option.rect);
//QRect tileRect(option.rect);
int textHeight = fm.height();
int iconPosModX = PIXMAP_MARGIN + (tile.width() / 2);
int iconPosModY = (option.rect.height() - tile.height()) / 2;
painter->drawPixmap(rect.adjusted(iconPosModX, iconPosModY, iconPosModX, iconPosModY).topLeft(), tile);
//tileRect.setRight(tileSize.width()+30);
//tileRect.setTop(tileRect.top()+5);
//headerRect.setLeft(tileRect.right());
//subheaderRect.setLeft(tileRect.right());
//headerRect.setTop(headerRect.top()+5);
//headerRect.setBottom(headerRect.top()+fm.height());
//subheaderRect.setTop(headerRect.bottom()+2);
//painter->drawPixmap(targetrect, pixmap, sourcerect)
//painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height()));
//painter->drawPixmap(QPoint(tileRect.left()+tileSize.width()/2+2,tileRect.top()+tileSize.height()/2+3),tile);
//painter->setFont(font);
//painter->drawText(headerRect,headerText);
//painter->setFont(SubFont);
//painter->drawText(subheaderRect.left(),subheaderRect.top()+17,subText);
painter->restore();
}
QSize TileItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
QPixmap tile = qvariant_cast<QPixmap>(index.data(TileModel::TilePixmapRole));
QSize tileSize = tile.size();
QFont font = QApplication::font();
QFontMetrics fm(font);
return(QSize(tileSize.width()+(2*PIXMAP_MARGIN), tileSize.height()+fm.height()+(2*PIXMAP_MARGIN)));
}
TileItemDelegate::TZoomFactor TileItemDelegate::getZoomFactor()
{
return m_zoomFactor;
}
void TileItemDelegate::setZoomFactor(TileItemDelegate::TZoomFactor zoomFactor)
{
m_zoomFactor = zoomFactor;
}
// SLOTS
void TileItemDelegate::currentTab(int index)
{
if(index == 1)
{
nlinfo("switching delegate to 1 or 256");
m_imageHint = 256;
}
else
{
nlinfo("switching delegate to 0,2,3 or 128");
m_imageHint = 128;
}
}

View file

@ -0,0 +1,57 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef TILE_ITEM_DELEGATE_H
#define TILE_ITEM_DELEGATE_H
#include <QtGui/QWidget>
#include <QPixmap>
#include <QStyledItemDelegate>
#include "ui_tile_widget.h"
#include <nel/misc/types_nl.h>
class TileItemDelegate : public QStyledItemDelegate
{
public:
enum TZoomFactor
{
ZoomSmall = 0,
ZoomNormal = 1,
ZoomLarge = 2
};
static const int PIXMAP_MARGIN = 5;
TileItemDelegate();
virtual ~TileItemDelegate();
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const;
TZoomFactor getZoomFactor();
void setZoomFactor(TZoomFactor zoomFactor);
public Q_SLOTS:
void currentTab(int index);
private:
TZoomFactor m_zoomFactor;
int m_imageHint;
};
#endif // TILE_ITEM_DELEGATE_H

View file

@ -0,0 +1,230 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#include "tile_model.h"
#include "tile_item.h"
#include <QStringList>
#include <nel/misc/debug.h>
// Initialize the static members
TileModel::TTileZoomFactor TileModel::CurrentZoomFactor;
TileModel::TileModel(const QStringList &headers, QObject *parent) : QAbstractItemModel(parent)
{
QVector<QVariant> rootData;
Q_FOREACH(QString header, headers)
rootData << header;
rootItem = new Node(rootData);
TileModel::CurrentZoomFactor = TileModel::TileZoom100;
m_indexDisplay = true;
m_fileDisplay = true;
}
TileModel::~TileModel()
{
delete rootItem;
}
Node *TileModel::getItem(const QModelIndex &index) const
{
if(index.isValid())
{
Node *item = static_cast<Node*>(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();
Node *parentItem = getItem(parent);
Node *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();
Node *childItem = getItem(index);
Node *parentItem = childItem->parent();
if(parentItem == rootItem)
return QModelIndex();
return createIndex(parentItem->childNumber(), 0, parentItem);
}
int TileModel::rowCount(const QModelIndex &parent) const
{
Node *parentItem = getItem(parent);
return parentItem->childCount();
}
int TileModel::columnCount(const QModelIndex &parent) const
{
Node *parentItem = getItem(parent);
return parentItem->columnCount();
}
QVariant TileModel::data(const QModelIndex &index, int role) const
{
if(!index.isValid())
return QVariant();
Node *item = static_cast<Node*>(index.internalPointer());
// Translate the display role to the settings-specific role.
if(role == Qt::DisplayRole)
{
if(m_indexDisplay && m_fileDisplay)
role = TileFilenameIndexRole;
else if(m_fileDisplay)
role = TileFilenameRole;
else if(m_indexDisplay)
role = TileIndexRole;
}
return item->data(index.column(), role);
}
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,role);
return QVariant();
}
void TileModel::appendRow(const QList<Node*> &items)
{
rootItem->appendRow(items);
}
void TileModel::appendRow(Node *item)
{
rootItem->appendRow(item);
}
TileSetNode *TileModel::createTileSetNode(QString tileSetName)
{
// Create the new tile set.
TileSetNode *tileSet = new TileSetNode(tileSetName);
// child for 128x128 tiles
TileTypeNode *tile128= new TileTypeNode(Tile128);
tileSet->appendRow(tile128);
// child for 256x256 tiles
TileTypeNode *tile256= new TileTypeNode(Tile256);
tileSet->appendRow(tile256);
// child for transition tiles.
TileTypeNode *tileTrans= new TileTypeNode(TileTransition);
tileSet->appendRow(tileTrans);
// Add the default transition tiles.
// TODO tie this to CTileSet::count from NeL
for(int transPos=0; transPos<48; transPos++)
{
TileItemNode *transTile= new TileItemNode(transPos, TileDiffuse, QString("empty"));
tileTrans->appendRow(transTile);
}
// child for displacement tiles
TileTypeNode *tileDisp= new TileTypeNode(TileDisplacement);
tileSet->appendRow(tileDisp);
// Add the default displacement tiles.
// TODO tie this to CTileSet::CountDisplace from NeL
for(int dispPos=0; dispPos<16; dispPos++)
{
TileItemNode *dispTile= new TileItemNode(dispPos, TileDiffuse, QString("empty"));
tileDisp->appendRow(dispTile);
}
// Append them in the correct order to the tile set.
this->appendRow(tileSet);
return tileSet;
}
const char *TileModel::getTileTypeName(TileModel::TNodeTileType type)
{
switch(type)
{
case Tile128:
return "128";
case Tile256:
return "256";
case TileTransition:
return "Transition";
case TileDisplacement:
return "Displacement";
default:
break;
}
return "UNKNOWN";
}
uint32 TileModel::getTileTypeSize(TileModel::TNodeTileType type)
{
switch(type)
{
case Tile128:
return 128;
case Tile256:
return 256;
case TileTransition:
return 64;
case TileDisplacement:
return 32;
default:
break;
}
return 0;
}
void TileModel::selectFilenameDisplay(bool selected)
{
m_fileDisplay = selected;
}
void TileModel::selectIndexDisplay(bool selected)
{
m_indexDisplay = selected;
}

View file

@ -0,0 +1,106 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef TILE_MODEL_H
#define TILE_MODEL_H
#include "nel/misc/types_nl.h"
#include <QAbstractListModel>
class Node;
class TileSetNode;
class TileModel : public QAbstractItemModel
{
Q_OBJECT
public:
enum TTileChannel
{
TileDiffuse = 0,
TileAdditive = 1,
TileAlpha = 2,
};
enum TNodeTileType
{
Tile128 = 0,
Tile256 = 1,
TileTransition = 2,
TileDisplacement = 3
};
enum TTileItemRole
{
TilePixmapRole = Qt::UserRole+1,
TileFilenameRole = Qt::UserRole+2,
TileIndexRole = Qt::UserRole+3,
TileFilenameIndexRole = Qt::UserRole+4
};
enum TTileZoomFactor
{
TileZoom50 = 0,
TileZoom100 = 1,
TileZoom200 = 2
};
static const int TILE_DISPLACE_BASE_SIZE = 32;
static const int TILE_TRANSITION_BASE_SIZE = 64;
static const int TILE_128_BASE_SIZE = 128;
static const int TILE_256_BASE_SIZE = 256;
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<Node*> &items);
void appendRow(Node *item);
TileSetNode *createTileSetNode(QString tileSetName);
static const char *getTileTypeName(TNodeTileType type);
static uint32 getTileTypeSize(TileModel::TNodeTileType type);
static TTileZoomFactor CurrentZoomFactor;
public Q_SLOTS:
void selectFilenameDisplay(bool selected);
void selectIndexDisplay(bool selected);
private:
Node *getItem(const QModelIndex &index) const;
bool m_fileDisplay;
bool m_indexDisplay;
//TTileZoomFactor m_tileZoomFactor;
//QList<TileItem*> m_tiles;
//int m_activeEditChannel;
Node *rootItem;
};
#endif // TILE_MODEL_H