Changed: EOL
This commit is contained in:
parent
d8a6c9f966
commit
6b3b85962a
36 changed files with 10933 additions and 10933 deletions
|
@ -1,23 +1,23 @@
|
||||||
ADD_SUBDIRECTORY(core)
|
ADD_SUBDIRECTORY(core)
|
||||||
ADD_SUBDIRECTORY(example)
|
ADD_SUBDIRECTORY(example)
|
||||||
ADD_SUBDIRECTORY(ovqt_sheet_builder)
|
ADD_SUBDIRECTORY(ovqt_sheet_builder)
|
||||||
ADD_SUBDIRECTORY(landscape_editor)
|
ADD_SUBDIRECTORY(landscape_editor)
|
||||||
ADD_SUBDIRECTORY(log)
|
ADD_SUBDIRECTORY(log)
|
||||||
ADD_SUBDIRECTORY(disp_sheet_id)
|
ADD_SUBDIRECTORY(disp_sheet_id)
|
||||||
ADD_SUBDIRECTORY(object_viewer)
|
ADD_SUBDIRECTORY(object_viewer)
|
||||||
ADD_SUBDIRECTORY(georges_editor)
|
ADD_SUBDIRECTORY(georges_editor)
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(world_editor)
|
ADD_SUBDIRECTORY(world_editor)
|
||||||
IF(WITH_GUI)
|
IF(WITH_GUI)
|
||||||
ADD_SUBDIRECTORY(gui_editor)
|
ADD_SUBDIRECTORY(gui_editor)
|
||||||
ENDIF(WITH_GUI)
|
ENDIF(WITH_GUI)
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(translation_manager)
|
ADD_SUBDIRECTORY(translation_manager)
|
||||||
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)
|
||||||
|
|
||||||
# Ryzom Specific Plugins
|
# Ryzom Specific Plugins
|
||||||
IF(WITH_RYZOM AND WITH_RYZOM_TOOLS)
|
IF(WITH_RYZOM AND WITH_RYZOM_TOOLS)
|
||||||
ADD_SUBDIRECTORY(mission_compiler)
|
ADD_SUBDIRECTORY(mission_compiler)
|
||||||
ENDIF(WITH_RYZOM AND WITH_RYZOM_TOOLS)
|
ENDIF(WITH_RYZOM AND WITH_RYZOM_TOOLS)
|
||||||
|
|
|
@ -1,73 +1,73 @@
|
||||||
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
|
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${LIBXML2_INCLUDE_DIR}
|
${LIBXML2_INCLUDE_DIR}
|
||||||
${QT_INCLUDES})
|
${QT_INCLUDES})
|
||||||
|
|
||||||
FILE(GLOB SRC *.cpp *.h)
|
FILE(GLOB SRC *.cpp *.h)
|
||||||
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.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_manager.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
||||||
|
|
||||||
SET(OVQT_CORE_PLUGIN_HDR
|
SET(OVQT_CORE_PLUGIN_HDR
|
||||||
icore.h
|
icore.h
|
||||||
icontext.h
|
icontext.h
|
||||||
icore_listener.h
|
icore_listener.h
|
||||||
ioptions_page.h
|
ioptions_page.h
|
||||||
core_plugin.h
|
core_plugin.h
|
||||||
core.h
|
core.h
|
||||||
main_window.h
|
main_window.h
|
||||||
menu_manager.h
|
menu_manager.h
|
||||||
context_manager.h
|
context_manager.h
|
||||||
settings_dialog.h
|
settings_dialog.h
|
||||||
search_paths_settings_page.h
|
search_paths_settings_page.h
|
||||||
general_settings_page.h
|
general_settings_page.h
|
||||||
plugin_view_dialog.h
|
plugin_view_dialog.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui
|
SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui
|
||||||
plugin_view_dialog.ui
|
plugin_view_dialog.ui
|
||||||
general_settings_page.ui
|
general_settings_page.ui
|
||||||
search_paths_settings_page.ui
|
search_paths_settings_page.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_CORE_PLUGIN_RCS core.qrc)
|
SET(OVQT_CORE_PLUGIN_RCS core.qrc)
|
||||||
|
|
||||||
SET(QT_USE_QTGUI TRUE)
|
SET(QT_USE_QTGUI TRUE)
|
||||||
SET(QT_USE_QTOPENGL TRUE)
|
SET(QT_USE_QTOPENGL TRUE)
|
||||||
|
|
||||||
QT4_ADD_RESOURCES(OVQT_CORE_PLUGIN_RC_SRCS ${OVQT_CORE_PLUGIN_RCS})
|
QT4_ADD_RESOURCES(OVQT_CORE_PLUGIN_RC_SRCS ${OVQT_CORE_PLUGIN_RCS})
|
||||||
QT4_WRAP_CPP(OVQT_CORE_PLUGIN_MOC_SRC ${OVQT_CORE_PLUGIN_HDR})
|
QT4_WRAP_CPP(OVQT_CORE_PLUGIN_MOC_SRC ${OVQT_CORE_PLUGIN_HDR})
|
||||||
QT4_WRAP_UI(OVQT_CORE_PLUGIN_UI_HDRS ${OVQT_CORE_PLUGIN_UIS})
|
QT4_WRAP_UI(OVQT_CORE_PLUGIN_UI_HDRS ${OVQT_CORE_PLUGIN_UIS})
|
||||||
|
|
||||||
SOURCE_GROUP(QtResources FILES ${OVQT_CORE_PLUGIN_UIS} ${OVQT_CORE_PLUGIN_RCS})
|
SOURCE_GROUP(QtResources FILES ${OVQT_CORE_PLUGIN_UIS} ${OVQT_CORE_PLUGIN_RCS})
|
||||||
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_CORE_PLUGIN_UI_HDRS})
|
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_CORE_PLUGIN_UI_HDRS})
|
||||||
SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_CORE_PLUGIN_MOC_SRC})
|
SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_CORE_PLUGIN_MOC_SRC})
|
||||||
SOURCE_GROUP("Core Plugin" FILES ${SRC})
|
SOURCE_GROUP("Core Plugin" FILES ${SRC})
|
||||||
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
||||||
|
|
||||||
ADD_LIBRARY(ovqt_plugin_core SHARED ${SRC} ${OVQT_CORE_PLUGIN_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_CORE_PLUGIN_RC_SRCS} ${OVQT_CORE_PLUGIN_UI_HDRS})
|
ADD_LIBRARY(ovqt_plugin_core SHARED ${SRC} ${OVQT_CORE_PLUGIN_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_CORE_PLUGIN_RC_SRCS} ${OVQT_CORE_PLUGIN_UI_HDRS})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(ovqt_plugin_core nelmisc ${QT_LIBRARIES})
|
TARGET_LINK_LIBRARIES(ovqt_plugin_core nelmisc ${QT_LIBRARIES})
|
||||||
|
|
||||||
NL_DEFAULT_PROPS(ovqt_plugin_core "NeL, Tools, 3D: Object Viewer Qt Plugin: Core")
|
NL_DEFAULT_PROPS(ovqt_plugin_core "NeL, Tools, 3D: Object Viewer Qt Plugin: Core")
|
||||||
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_core)
|
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_core)
|
||||||
NL_ADD_LIB_SUFFIX(ovqt_plugin_core)
|
NL_ADD_LIB_SUFFIX(ovqt_plugin_core)
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DCORE_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
|
ADD_DEFINITIONS(-DCORE_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
IF(WITH_INSTALL_LIBRARIES)
|
IF(WITH_INSTALL_LIBRARIES)
|
||||||
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${OVQT_PLUGIN_DIR} COMPONENT tools3d)
|
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${OVQT_PLUGIN_DIR} COMPONENT tools3d)
|
||||||
ELSE(WITH_INSTALL_LIBRARIES)
|
ELSE(WITH_INSTALL_LIBRARIES)
|
||||||
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${OVQT_PLUGIN_DIR} COMPONENT tools3d)
|
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${OVQT_PLUGIN_DIR} COMPONENT tools3d)
|
||||||
ENDIF(WITH_INSTALL_LIBRARIES)
|
ENDIF(WITH_INSTALL_LIBRARIES)
|
||||||
ELSE(WIN32)
|
ELSE(WIN32)
|
||||||
IF(WITH_INSTALL_LIBRARIES)
|
IF(WITH_INSTALL_LIBRARIES)
|
||||||
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d)
|
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION ${NL_LIB_PREFIX} ARCHIVE DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d)
|
||||||
ELSE(WITH_INSTALL_LIBRARIES)
|
ELSE(WITH_INSTALL_LIBRARIES)
|
||||||
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d)
|
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION ${NL_LIB_PREFIX} RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d)
|
||||||
ENDIF(WITH_INSTALL_LIBRARIES)
|
ENDIF(WITH_INSTALL_LIBRARIES)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ovqt_plugin_core.xml DESTINATION ${OVQT_PLUGIN_SPECS_DIR} COMPONENT tools3d)
|
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ovqt_plugin_core.xml DESTINATION ${OVQT_PLUGIN_SPECS_DIR} COMPONENT tools3d)
|
||||||
|
|
||||||
|
|
|
@ -1,59 +1,59 @@
|
||||||
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
|
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${LIBXML2_INCLUDE_DIR}
|
${LIBXML2_INCLUDE_DIR}
|
||||||
${QT_INCLUDES})
|
${QT_INCLUDES})
|
||||||
|
|
||||||
FILE(GLOB SRC *.cpp *.h)
|
FILE(GLOB SRC *.cpp *.h)
|
||||||
|
|
||||||
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.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_manager.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h
|
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR landscape_editor_plugin.h
|
||||||
landscape_editor_window.h
|
landscape_editor_window.h
|
||||||
landscape_scene_base.h
|
landscape_scene_base.h
|
||||||
landscape_scene.h
|
landscape_scene.h
|
||||||
list_zones_model.h
|
list_zones_model.h
|
||||||
list_zones_widget.h
|
list_zones_widget.h
|
||||||
landscape_view.h
|
landscape_view.h
|
||||||
project_settings_dialog.h
|
project_settings_dialog.h
|
||||||
snapshot_dialog.h
|
snapshot_dialog.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui
|
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS landscape_editor_window.ui
|
||||||
list_zones_widget.ui
|
list_zones_widget.ui
|
||||||
project_settings_dialog.ui
|
project_settings_dialog.ui
|
||||||
shapshot_dialog.ui
|
shapshot_dialog.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc)
|
SET(OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS landscape_editor.qrc)
|
||||||
|
|
||||||
SET(QT_USE_QTGUI TRUE)
|
SET(QT_USE_QTGUI TRUE)
|
||||||
SET(QT_USE_QTOPENGL TRUE)
|
SET(QT_USE_QTOPENGL TRUE)
|
||||||
|
|
||||||
QT4_ADD_RESOURCES(OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS ${OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS})
|
QT4_ADD_RESOURCES(OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS ${OVQT_PLUGIN_LANDSCAPE_EDITOR_RCS})
|
||||||
QT4_WRAP_CPP(OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC ${OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR})
|
QT4_WRAP_CPP(OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC ${OVQT_PLUGIN_LANDSCAPE_EDITOR_HDR})
|
||||||
QT4_WRAP_UI(OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS})
|
QT4_WRAP_UI(OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS})
|
||||||
|
|
||||||
SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS})
|
SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UIS})
|
||||||
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS})
|
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS})
|
||||||
SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC} OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS)
|
SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC} OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS)
|
||||||
SOURCE_GROUP("Landscape Editor Plugin" FILES ${SRC})
|
SOURCE_GROUP("Landscape Editor Plugin" FILES ${SRC})
|
||||||
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
||||||
|
|
||||||
ADD_LIBRARY(ovqt_plugin_landscape_editor SHARED ${SRC}
|
ADD_LIBRARY(ovqt_plugin_landscape_editor SHARED ${SRC}
|
||||||
${OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC}
|
${OVQT_PLUGIN_LANDSCAPE_EDITOR_MOC_SRC}
|
||||||
${OVQT_EXT_SYS_SRC}
|
${OVQT_EXT_SYS_SRC}
|
||||||
${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS}
|
${OVQT_PLUGIN_LANDSCAPE_EDITOR_UI_HDRS}
|
||||||
${OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS})
|
${OVQT_PLUGIN_LANDSCAPE_EDITOR_RC_SRCS})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(ovqt_plugin_landscape_editor ovqt_plugin_core nelmisc nel3d nelgeorges nelligo ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY})
|
TARGET_LINK_LIBRARIES(ovqt_plugin_landscape_editor ovqt_plugin_core nelmisc nel3d nelgeorges nelligo ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY})
|
||||||
|
|
||||||
NL_DEFAULT_PROPS(ovqt_plugin_landscape_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Landscape Editor")
|
NL_DEFAULT_PROPS(ovqt_plugin_landscape_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Landscape Editor")
|
||||||
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_landscape_editor)
|
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_landscape_editor)
|
||||||
NL_ADD_LIB_SUFFIX(ovqt_plugin_landscape_editor)
|
NL_ADD_LIB_SUFFIX(ovqt_plugin_landscape_editor)
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DLANDSCAPE_EDITOR_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
|
ADD_DEFINITIONS(-DLANDSCAPE_EDITOR_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
|
||||||
|
|
||||||
INSTALL(TARGETS ovqt_plugin_landscape_editor LIBRARY DESTINATION ${OVQT_PLUGIN_DIR} RUNTIME DESTINATION ${NL_BIN_PREFIX} ARCHIVE DESTINATION ${OVQT_PLUGIN_DIR} COMPONENT tools3d)
|
INSTALL(TARGETS ovqt_plugin_landscape_editor LIBRARY DESTINATION ${OVQT_PLUGIN_DIR} RUNTIME DESTINATION ${NL_BIN_PREFIX} ARCHIVE DESTINATION ${OVQT_PLUGIN_DIR} COMPONENT tools3d)
|
||||||
#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ovqt_plugin_landscape_editor.xml DESTINATION ${OVQT_PLUGIN_SPECS_DIR} COMPONENT tools3d)
|
#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ovqt_plugin_landscape_editor.xml DESTINATION ${OVQT_PLUGIN_SPECS_DIR} COMPONENT tools3d)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,206 +1,206 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "builder_zone_base.h"
|
#include "builder_zone_base.h"
|
||||||
#include "landscape_scene_base.h"
|
#include "landscape_scene_base.h"
|
||||||
#include "zone_region_editor.h"
|
#include "zone_region_editor.h"
|
||||||
#include "pixmap_database.h"
|
#include "pixmap_database.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtGui/QProgressDialog>
|
#include <QtGui/QProgressDialog>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
int NewLandId = 0;
|
int NewLandId = 0;
|
||||||
|
|
||||||
ZoneBuilderBase::ZoneBuilderBase(LandscapeSceneBase *landscapeScene)
|
ZoneBuilderBase::ZoneBuilderBase(LandscapeSceneBase *landscapeScene)
|
||||||
: m_pixmapDatabase(0),
|
: m_pixmapDatabase(0),
|
||||||
m_landscapeSceneBase(landscapeScene)
|
m_landscapeSceneBase(landscapeScene)
|
||||||
{
|
{
|
||||||
nlassert(m_landscapeSceneBase);
|
nlassert(m_landscapeSceneBase);
|
||||||
m_pixmapDatabase = new PixmapDatabase();
|
m_pixmapDatabase = new PixmapDatabase();
|
||||||
m_lastPathName = "";
|
m_lastPathName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoneBuilderBase::~ZoneBuilderBase()
|
ZoneBuilderBase::~ZoneBuilderBase()
|
||||||
{
|
{
|
||||||
delete m_pixmapDatabase;
|
delete m_pixmapDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneBuilderBase::init(const QString &pathName, bool displayProgress)
|
bool ZoneBuilderBase::init(const QString &pathName, bool displayProgress)
|
||||||
{
|
{
|
||||||
if (pathName.isEmpty())
|
if (pathName.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
if (pathName != m_lastPathName)
|
if (pathName != m_lastPathName)
|
||||||
{
|
{
|
||||||
m_lastPathName = pathName;
|
m_lastPathName = pathName;
|
||||||
QString zoneBankPath = pathName;
|
QString zoneBankPath = pathName;
|
||||||
zoneBankPath += "/zoneligos/";
|
zoneBankPath += "/zoneligos/";
|
||||||
|
|
||||||
// Init the ZoneBank
|
// Init the ZoneBank
|
||||||
m_zoneBank.reset();
|
m_zoneBank.reset();
|
||||||
if (!initZoneBank (zoneBankPath))
|
if (!initZoneBank (zoneBankPath))
|
||||||
{
|
{
|
||||||
m_zoneBank.reset();
|
m_zoneBank.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Construct the DataBase from the ZoneBank
|
// Construct the DataBase from the ZoneBank
|
||||||
QString zoneBitmapPath = pathName;
|
QString zoneBitmapPath = pathName;
|
||||||
zoneBitmapPath += "/zonebitmaps/";
|
zoneBitmapPath += "/zonebitmaps/";
|
||||||
m_pixmapDatabase->reset();
|
m_pixmapDatabase->reset();
|
||||||
if (!m_pixmapDatabase->loadPixmaps(zoneBitmapPath, m_zoneBank, displayProgress))
|
if (!m_pixmapDatabase->loadPixmaps(zoneBitmapPath, m_zoneBank, displayProgress))
|
||||||
{
|
{
|
||||||
m_zoneBank.reset();
|
m_zoneBank.reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZoneBuilderBase::loadZoneRegion(const QString &fileName, int defaultId)
|
int ZoneBuilderBase::loadZoneRegion(const QString &fileName, int defaultId)
|
||||||
{
|
{
|
||||||
LandscapeItem landItem;
|
LandscapeItem landItem;
|
||||||
landItem.zoneRegionObject = new ZoneRegionObject();
|
landItem.zoneRegionObject = new ZoneRegionObject();
|
||||||
landItem.zoneRegionObject->load(fileName.toStdString());
|
landItem.zoneRegionObject->load(fileName.toStdString());
|
||||||
|
|
||||||
if (!checkOverlaps(landItem.zoneRegionObject->ligoZoneRegion()))
|
if (!checkOverlaps(landItem.zoneRegionObject->ligoZoneRegion()))
|
||||||
{
|
{
|
||||||
delete landItem.zoneRegionObject;
|
delete landItem.zoneRegionObject;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int id = defaultId;
|
int id = defaultId;
|
||||||
if (id == -1)
|
if (id == -1)
|
||||||
id = NewLandId++;
|
id = NewLandId++;
|
||||||
// landItem.builderZoneRegion = new BuilderZoneRegion(LandCounter);
|
// landItem.builderZoneRegion = new BuilderZoneRegion(LandCounter);
|
||||||
// landItem.builderZoneRegion->init(this);
|
// landItem.builderZoneRegion->init(this);
|
||||||
|
|
||||||
m_landscapeSceneBase->addZoneRegion(landItem.zoneRegionObject->ligoZoneRegion());
|
m_landscapeSceneBase->addZoneRegion(landItem.zoneRegionObject->ligoZoneRegion());
|
||||||
// landItem.rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion());
|
// landItem.rectItem = m_landscapeScene->createLayerBlackout(landItem.zoneRegionObject->ligoZoneRegion());
|
||||||
m_landscapeMap.insert(id, landItem);
|
m_landscapeMap.insert(id, landItem);
|
||||||
|
|
||||||
calcMask();
|
calcMask();
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneBuilderBase::deleteZoneRegion(int id)
|
void ZoneBuilderBase::deleteZoneRegion(int id)
|
||||||
{
|
{
|
||||||
if (m_landscapeMap.contains(id))
|
if (m_landscapeMap.contains(id))
|
||||||
{
|
{
|
||||||
m_landscapeSceneBase->delZoneRegion(m_landscapeMap.value(id).zoneRegionObject->ligoZoneRegion());
|
m_landscapeSceneBase->delZoneRegion(m_landscapeMap.value(id).zoneRegionObject->ligoZoneRegion());
|
||||||
delete m_landscapeMap.value(id).zoneRegionObject;
|
delete m_landscapeMap.value(id).zoneRegionObject;
|
||||||
// delete m_landscapeMap.value(id).builderZoneRegion;
|
// delete m_landscapeMap.value(id).builderZoneRegion;
|
||||||
m_landscapeMap.remove(id);
|
m_landscapeMap.remove(id);
|
||||||
calcMask();
|
calcMask();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nlwarning("Landscape (id %i) not found", id);
|
nlwarning("Landscape (id %i) not found", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZoneBuilderBase::countZoneRegion() const
|
int ZoneBuilderBase::countZoneRegion() const
|
||||||
{
|
{
|
||||||
return m_landscapeMap.size();
|
return m_landscapeMap.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoneRegionObject *ZoneBuilderBase::zoneRegion(int id) const
|
ZoneRegionObject *ZoneBuilderBase::zoneRegion(int id) const
|
||||||
{
|
{
|
||||||
return m_landscapeMap.value(id).zoneRegionObject;
|
return m_landscapeMap.value(id).zoneRegionObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneBuilderBase::initZoneBank (const QString &pathName)
|
bool ZoneBuilderBase::initZoneBank (const QString &pathName)
|
||||||
{
|
{
|
||||||
QDir *dir = new QDir(pathName);
|
QDir *dir = new QDir(pathName);
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << "*.ligozone";
|
filters << "*.ligozone";
|
||||||
|
|
||||||
// Find all ligozone files in dir
|
// Find all ligozone files in dir
|
||||||
QStringList listFiles = dir->entryList(filters, QDir::Files);
|
QStringList listFiles = dir->entryList(filters, QDir::Files);
|
||||||
|
|
||||||
std::string error;
|
std::string error;
|
||||||
Q_FOREACH(QString file, listFiles)
|
Q_FOREACH(QString file, listFiles)
|
||||||
{
|
{
|
||||||
//nlinfo(file.toStdString().c_str());
|
//nlinfo(file.toStdString().c_str());
|
||||||
if (!m_zoneBank.addElement((pathName + file).toStdString(), error))
|
if (!m_zoneBank.addElement((pathName + file).toStdString(), error))
|
||||||
QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok);
|
QMessageBox::critical(0, QObject::tr("Landscape editor"), QString(error.c_str()), QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
delete dir;
|
delete dir;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PixmapDatabase *ZoneBuilderBase::pixmapDatabase() const
|
PixmapDatabase *ZoneBuilderBase::pixmapDatabase() const
|
||||||
{
|
{
|
||||||
return m_pixmapDatabase;
|
return m_pixmapDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ZoneBuilderBase::dataPath() const
|
QString ZoneBuilderBase::dataPath() const
|
||||||
{
|
{
|
||||||
return m_lastPathName;
|
return m_lastPathName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneBuilderBase::calcMask()
|
void ZoneBuilderBase::calcMask()
|
||||||
{
|
{
|
||||||
m_minY = m_minX = 1000000;
|
m_minY = m_minX = 1000000;
|
||||||
m_maxY = m_maxX = -1000000;
|
m_maxY = m_maxX = -1000000;
|
||||||
|
|
||||||
if (m_landscapeMap.size() == 0)
|
if (m_landscapeMap.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMapIterator<int, LandscapeItem> i(m_landscapeMap);
|
QMapIterator<int, LandscapeItem> i(m_landscapeMap);
|
||||||
while (i.hasNext())
|
while (i.hasNext())
|
||||||
{
|
{
|
||||||
i.next();
|
i.next();
|
||||||
const NLLIGO::CZoneRegion ®ion = i.value().zoneRegionObject->ligoZoneRegion();
|
const NLLIGO::CZoneRegion ®ion = i.value().zoneRegionObject->ligoZoneRegion();
|
||||||
|
|
||||||
if (m_minX > region.getMinX())
|
if (m_minX > region.getMinX())
|
||||||
m_minX = region.getMinX();
|
m_minX = region.getMinX();
|
||||||
if (m_minY > region.getMinY())
|
if (m_minY > region.getMinY())
|
||||||
m_minY = region.getMinY();
|
m_minY = region.getMinY();
|
||||||
if (m_maxX < region.getMaxX())
|
if (m_maxX < region.getMaxX())
|
||||||
m_maxX = region.getMaxX();
|
m_maxX = region.getMaxX();
|
||||||
if (m_maxY < region.getMaxY())
|
if (m_maxY < region.getMaxY())
|
||||||
m_maxY = region.getMaxY();
|
m_maxY = region.getMaxY();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneBuilderBase::checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion)
|
bool ZoneBuilderBase::checkOverlaps(const NLLIGO::CZoneRegion &newZoneRegion)
|
||||||
{
|
{
|
||||||
QMapIterator<int, LandscapeItem> it(m_landscapeMap);
|
QMapIterator<int, LandscapeItem> it(m_landscapeMap);
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
it.next();
|
it.next();
|
||||||
const NLLIGO::CZoneRegion &zoneRegion = it.value().zoneRegionObject->ligoZoneRegion();
|
const NLLIGO::CZoneRegion &zoneRegion = it.value().zoneRegionObject->ligoZoneRegion();
|
||||||
for (sint32 y = zoneRegion.getMinY(); y <= zoneRegion.getMaxY(); ++y)
|
for (sint32 y = zoneRegion.getMinY(); y <= zoneRegion.getMaxY(); ++y)
|
||||||
for (sint32 x = zoneRegion.getMinX(); x <= zoneRegion.getMaxX(); ++x)
|
for (sint32 x = zoneRegion.getMinX(); x <= zoneRegion.getMaxX(); ++x)
|
||||||
{
|
{
|
||||||
const std::string &refZoneName = zoneRegion.getName(x, y);
|
const std::string &refZoneName = zoneRegion.getName(x, y);
|
||||||
if (refZoneName != STRING_UNUSED)
|
if (refZoneName != STRING_UNUSED)
|
||||||
{
|
{
|
||||||
const std::string &zoneName = newZoneRegion.getName(x, y);
|
const std::string &zoneName = newZoneRegion.getName(x, y);
|
||||||
if ((zoneName != STRING_UNUSED) && (zoneName != STRING_OUT_OF_BOUND))
|
if ((zoneName != STRING_UNUSED) && (zoneName != STRING_OUT_OF_BOUND))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,107 +1,107 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#ifndef BUILDER_ZONE_REGION_H
|
#ifndef BUILDER_ZONE_REGION_H
|
||||||
#define BUILDER_ZONE_REGION_H
|
#define BUILDER_ZONE_REGION_H
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/ligo/zone_bank.h>
|
#include <nel/ligo/zone_bank.h>
|
||||||
#include <nel/ligo/zone_region.h>
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
// STL includes
|
// STL includes
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
class ZoneBuilder;
|
class ZoneBuilder;
|
||||||
class ToUpdate;
|
class ToUpdate;
|
||||||
|
|
||||||
// CZoneRegion contains informations about the zones painted.
|
// CZoneRegion contains informations about the zones painted.
|
||||||
// (Legacy class from old world editor. It needs to refactoring!)
|
// (Legacy class from old world editor. It needs to refactoring!)
|
||||||
class BuilderZoneRegion
|
class BuilderZoneRegion
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit BuilderZoneRegion(uint regionId);
|
explicit BuilderZoneRegion(uint regionId);
|
||||||
|
|
||||||
// New interface
|
// New interface
|
||||||
bool init(ZoneBuilder *zoneBuilder);
|
bool init(ZoneBuilder *zoneBuilder);
|
||||||
void add(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
void add(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
||||||
void invertCutEdge(sint32 x, sint32 y, uint8 cePos);
|
void invertCutEdge(sint32 x, sint32 y, uint8 cePos);
|
||||||
void cycleTransition(sint32 x, sint32 y);
|
void cycleTransition(sint32 x, sint32 y);
|
||||||
bool addNotPropagate(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
bool addNotPropagate(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
||||||
|
|
||||||
/// Brutal adding a zone over empty space do not propagate in any way -> can result
|
/// Brutal adding a zone over empty space do not propagate in any way -> can result
|
||||||
/// in inconsistency when trying the propagation mode
|
/// in inconsistency when trying the propagation mode
|
||||||
void addForce (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
void addForce (sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
||||||
void del(sint32 x, sint32 y, bool transition = false, ToUpdate *pUpdate = 0);
|
void del(sint32 x, sint32 y, bool transition = false, ToUpdate *pUpdate = 0);
|
||||||
void move(sint32 x, sint32 y);
|
void move(sint32 x, sint32 y);
|
||||||
uint32 countZones();
|
uint32 countZones();
|
||||||
void reduceMin();
|
void reduceMin();
|
||||||
uint getRegionId() const;
|
uint getRegionId() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// An element of the graph
|
// An element of the graph
|
||||||
struct SMatNode
|
struct SMatNode
|
||||||
{
|
{
|
||||||
std::string Name;
|
std::string Name;
|
||||||
// Position in the tree (vector of nodes)
|
// Position in the tree (vector of nodes)
|
||||||
std::vector<uint32> Arcs;
|
std::vector<uint32> Arcs;
|
||||||
};
|
};
|
||||||
|
|
||||||
void addTransition(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
void addTransition(sint32 x, sint32 y, uint8 rot, uint8 flip, NLLIGO::CZoneBankElement *zoneBankElement);
|
||||||
|
|
||||||
void addToUpdateAndCreate(BuilderZoneRegion *builderZoneRegion, sint32 sharePos, sint32 x, sint32 y,
|
void addToUpdateAndCreate(BuilderZoneRegion *builderZoneRegion, sint32 sharePos, sint32 x, sint32 y,
|
||||||
const std::string &newMat, ToUpdate *ptCreate, ToUpdate *ptUpdate);
|
const std::string &newMat, ToUpdate *ptCreate, ToUpdate *ptUpdate);
|
||||||
|
|
||||||
void putTransitions(sint32 x, sint32 y, const NLLIGO::SPiece &mask, const std::string &matName, ToUpdate *ptUpdate);
|
void putTransitions(sint32 x, sint32 y, const NLLIGO::SPiece &mask, const std::string &matName, ToUpdate *ptUpdate);
|
||||||
void updateTrans(sint32 x, sint32 y, NLLIGO::CZoneBankElement *zoneBankElement = 0);
|
void updateTrans(sint32 x, sint32 y, NLLIGO::CZoneBankElement *zoneBankElement = 0);
|
||||||
|
|
||||||
std::string getNextMatInTree(const std::string &matA, const std::string &matB);
|
std::string getNextMatInTree(const std::string &matA, const std::string &matB);
|
||||||
|
|
||||||
/// Find the fastest way between posA and posB in the MatTree (Dijkstra)
|
/// Find the fastest way between posA and posB in the MatTree (Dijkstra)
|
||||||
void tryPath(uint32 posA, uint32 posB, std::vector<uint32> &path);
|
void tryPath(uint32 posA, uint32 posB, std::vector<uint32> &path);
|
||||||
|
|
||||||
void set(sint32 x, sint32 y, sint32 posX, sint32 posY, const std::string &zoneName, bool transition = false);
|
void set(sint32 x, sint32 y, sint32 posX, sint32 posY, const std::string &zoneName, bool transition = false);
|
||||||
void setRot(sint32 x, sint32 y, uint8 rot);
|
void setRot(sint32 x, sint32 y, uint8 rot);
|
||||||
void setFlip(sint32 x, sint32 y, uint8 flip);
|
void setFlip(sint32 x, sint32 y, uint8 flip);
|
||||||
void resize(sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY);
|
void resize(sint32 newMinX, sint32 newMaxX, sint32 newMinY, sint32 newMaxY);
|
||||||
|
|
||||||
void placePiece(sint32 x, sint32 y, uint8 rot, uint8 flip,
|
void placePiece(sint32 x, sint32 y, uint8 rot, uint8 flip,
|
||||||
NLLIGO::SPiece &sMask, NLLIGO::SPiece &sPosX, NLLIGO::SPiece &sPosY,
|
NLLIGO::SPiece &sMask, NLLIGO::SPiece &sPosX, NLLIGO::SPiece &sPosY,
|
||||||
const std::string &eltName);
|
const std::string &eltName);
|
||||||
|
|
||||||
uint m_regionId;
|
uint m_regionId;
|
||||||
|
|
||||||
// To use the global mask
|
// To use the global mask
|
||||||
ZoneBuilder *m_zoneBuilder;
|
ZoneBuilder *m_zoneBuilder;
|
||||||
|
|
||||||
// The tree of transition between materials
|
// The tree of transition between materials
|
||||||
std::vector<SMatNode> m_matTree;
|
std::vector<SMatNode> m_matTree;
|
||||||
|
|
||||||
bool m_firstInit;
|
bool m_firstInit;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
||||||
#endif // BUILDER_ZONE_REGION_H
|
#endif // BUILDER_ZONE_REGION_H
|
||||||
|
|
|
@ -1,178 +1,178 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "landscape_actions.h"
|
#include "landscape_actions.h"
|
||||||
#include "builder_zone.h"
|
#include "builder_zone.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
LigoTileCommand::LigoTileCommand(const LigoData &data, const ZonePosition &zonePos,
|
LigoTileCommand::LigoTileCommand(const LigoData &data, const ZonePosition &zonePos,
|
||||||
ZoneBuilder *zoneBuilder, LandscapeScene *scene,
|
ZoneBuilder *zoneBuilder, LandscapeScene *scene,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: QUndoCommand(parent),
|
: QUndoCommand(parent),
|
||||||
m_zoneBuilder(zoneBuilder),
|
m_zoneBuilder(zoneBuilder),
|
||||||
m_scene(scene)
|
m_scene(scene)
|
||||||
{
|
{
|
||||||
// Backup position
|
// Backup position
|
||||||
m_zonePos = zonePos;
|
m_zonePos = zonePos;
|
||||||
|
|
||||||
// Backup new data
|
// Backup new data
|
||||||
m_newLigoData = data;
|
m_newLigoData = data;
|
||||||
|
|
||||||
// Backup old data
|
// Backup old data
|
||||||
m_zoneBuilder->ligoData(m_oldLigoData, m_zonePos);
|
m_zoneBuilder->ligoData(m_oldLigoData, m_zonePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
LigoTileCommand::~LigoTileCommand()
|
LigoTileCommand::~LigoTileCommand()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void LigoTileCommand::undo ()
|
void LigoTileCommand::undo ()
|
||||||
{
|
{
|
||||||
m_zoneBuilder->setLigoData(m_oldLigoData, m_zonePos);
|
m_zoneBuilder->setLigoData(m_oldLigoData, m_zonePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LigoTileCommand::redo ()
|
void LigoTileCommand::redo ()
|
||||||
{
|
{
|
||||||
m_zoneBuilder->setLigoData(m_newLigoData, m_zonePos);
|
m_zoneBuilder->setLigoData(m_newLigoData, m_zonePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
UndoScanRegionCommand::UndoScanRegionCommand(bool direction, ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent)
|
UndoScanRegionCommand::UndoScanRegionCommand(bool direction, ZoneBuilder *zoneBuilder, LandscapeScene *scene, QUndoCommand *parent)
|
||||||
: QUndoCommand(parent),
|
: QUndoCommand(parent),
|
||||||
m_direction(direction),
|
m_direction(direction),
|
||||||
m_zoneBuilder(zoneBuilder),
|
m_zoneBuilder(zoneBuilder),
|
||||||
m_scene(scene)
|
m_scene(scene)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UndoScanRegionCommand::~UndoScanRegionCommand()
|
UndoScanRegionCommand::~UndoScanRegionCommand()
|
||||||
{
|
{
|
||||||
m_zonePositionList.clear();
|
m_zonePositionList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UndoScanRegionCommand::setScanList(const QList<ZonePosition> &zonePositionList)
|
void UndoScanRegionCommand::setScanList(const QList<ZonePosition> &zonePositionList)
|
||||||
{
|
{
|
||||||
m_zonePositionList = zonePositionList;
|
m_zonePositionList = zonePositionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UndoScanRegionCommand::undo()
|
void UndoScanRegionCommand::undo()
|
||||||
{
|
{
|
||||||
if (m_direction)
|
if (m_direction)
|
||||||
applyChanges();
|
applyChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UndoScanRegionCommand::redo()
|
void UndoScanRegionCommand::redo()
|
||||||
{
|
{
|
||||||
if (!m_direction)
|
if (!m_direction)
|
||||||
applyChanges();
|
applyChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UndoScanRegionCommand::applyChanges()
|
void UndoScanRegionCommand::applyChanges()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
||||||
m_scene->deleteItemZone(m_zonePositionList.at(i));
|
m_scene->deleteItemZone(m_zonePositionList.at(i));
|
||||||
|
|
||||||
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
for (int i = 0; i < m_zonePositionList.size(); ++i)
|
||||||
{
|
{
|
||||||
LigoData data;
|
LigoData data;
|
||||||
m_zoneBuilder->ligoData(data, m_zonePositionList.at(i));
|
m_zoneBuilder->ligoData(data, m_zonePositionList.at(i));
|
||||||
m_scene->createItemZone(data, m_zonePositionList.at(i));
|
m_scene->createItemZone(data, m_zonePositionList.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LigoResizeCommand::LigoResizeCommand(int index, sint32 newMinX, sint32 newMaxX,
|
LigoResizeCommand::LigoResizeCommand(int index, sint32 newMinX, sint32 newMaxX,
|
||||||
sint32 newMinY, sint32 newMaxY, ZoneBuilder *zoneBuilder,
|
sint32 newMinY, sint32 newMaxY, ZoneBuilder *zoneBuilder,
|
||||||
QUndoCommand *parent)
|
QUndoCommand *parent)
|
||||||
: QUndoCommand(parent),
|
: QUndoCommand(parent),
|
||||||
m_zoneBuilder(zoneBuilder)
|
m_zoneBuilder(zoneBuilder)
|
||||||
{
|
{
|
||||||
m_index = index;
|
m_index = index;
|
||||||
m_newMinX = newMinX;
|
m_newMinX = newMinX;
|
||||||
m_newMaxX = newMaxX;
|
m_newMaxX = newMaxX;
|
||||||
m_newMinY = newMinY;
|
m_newMinY = newMinY;
|
||||||
m_newMaxY = newMaxY;
|
m_newMaxY = newMaxY;
|
||||||
|
|
||||||
// Backup old region zone
|
// Backup old region zone
|
||||||
m_oldZoneRegion = m_zoneBuilder->zoneRegion(m_index)->ligoZoneRegion();
|
m_oldZoneRegion = m_zoneBuilder->zoneRegion(m_index)->ligoZoneRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
LigoResizeCommand::~LigoResizeCommand()
|
LigoResizeCommand::~LigoResizeCommand()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void LigoResizeCommand::undo ()
|
void LigoResizeCommand::undo ()
|
||||||
{
|
{
|
||||||
// Restore old region zone
|
// Restore old region zone
|
||||||
m_zoneBuilder->zoneRegion(m_index)->setLigoZoneRegion(m_oldZoneRegion);
|
m_zoneBuilder->zoneRegion(m_index)->setLigoZoneRegion(m_oldZoneRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LigoResizeCommand::redo ()
|
void LigoResizeCommand::redo ()
|
||||||
{
|
{
|
||||||
// Get the zone region
|
// Get the zone region
|
||||||
NLLIGO::CZoneRegion ®ion = m_zoneBuilder->zoneRegion(m_index)->ligoZoneRegion();
|
NLLIGO::CZoneRegion ®ion = m_zoneBuilder->zoneRegion(m_index)->ligoZoneRegion();
|
||||||
|
|
||||||
sint32 i, j;
|
sint32 i, j;
|
||||||
std::vector<LigoData> newZones;
|
std::vector<LigoData> newZones;
|
||||||
newZones.resize((1 + m_newMaxX - m_newMinX) * (1 + m_newMaxY - m_newMinY));
|
newZones.resize((1 + m_newMaxX - m_newMinX) * (1 + m_newMaxY - m_newMinY));
|
||||||
|
|
||||||
sint32 newStride = 1 + m_newMaxX - m_newMinX;
|
sint32 newStride = 1 + m_newMaxX - m_newMinX;
|
||||||
sint32 Stride = 1 + region.getMaxX() - region.getMinX();
|
sint32 Stride = 1 + region.getMaxX() - region.getMinX();
|
||||||
|
|
||||||
for (j = m_newMinY; j <= m_newMaxY; ++j)
|
for (j = m_newMinY; j <= m_newMaxY; ++j)
|
||||||
for (i = m_newMinX; i <= m_newMaxX; ++i)
|
for (i = m_newMinX; i <= m_newMaxX; ++i)
|
||||||
{
|
{
|
||||||
// Ref on the new value
|
// Ref on the new value
|
||||||
LigoData &data = newZones[(i - m_newMinX) + (j - m_newMinY) * newStride];
|
LigoData &data = newZones[(i - m_newMinX) + (j - m_newMinY) * newStride];
|
||||||
|
|
||||||
// In the old array ?
|
// In the old array ?
|
||||||
if ((i >= region.getMinX()) && (i <= region.getMaxX()) &&
|
if ((i >= region.getMinX()) && (i <= region.getMaxX()) &&
|
||||||
(j >= region.getMinY()) && (j <= region.getMaxY()))
|
(j >= region.getMinY()) && (j <= region.getMaxY()))
|
||||||
{
|
{
|
||||||
// Backup values
|
// Backup values
|
||||||
m_zoneBuilder->ligoData(data, ZonePosition(i, j, m_index));
|
m_zoneBuilder->ligoData(data, ZonePosition(i, j, m_index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
region.resize(m_newMinX, m_newMaxX, m_newMinY, m_newMaxY);
|
region.resize(m_newMinX, m_newMaxX, m_newMinY, m_newMaxY);
|
||||||
|
|
||||||
for (j = m_newMinY; j <= m_newMaxY; ++j)
|
for (j = m_newMinY; j <= m_newMaxY; ++j)
|
||||||
for (i = m_newMinX; i <= m_newMaxX; ++i)
|
for (i = m_newMinX; i <= m_newMaxX; ++i)
|
||||||
{
|
{
|
||||||
// Ref on the new value
|
// Ref on the new value
|
||||||
const LigoData &data = newZones[(i - m_newMinX) + (j - m_newMinY) * newStride];
|
const LigoData &data = newZones[(i - m_newMinX) + (j - m_newMinY) * newStride];
|
||||||
|
|
||||||
region.setName(i, j, data.zoneName);
|
region.setName(i, j, data.zoneName);
|
||||||
region.setPosX(i, j, data.posX);
|
region.setPosX(i, j, data.posX);
|
||||||
region.setPosY(i, j, data.posY);
|
region.setPosY(i, j, data.posY);
|
||||||
region.setRot(i, j, data.rot);
|
region.setRot(i, j, data.rot);
|
||||||
region.setFlip(i, j, data.flip);
|
region.setFlip(i, j, data.flip);
|
||||||
uint k;
|
uint k;
|
||||||
for (k = 0; k < 4; k++)
|
for (k = 0; k < 4; k++)
|
||||||
{
|
{
|
||||||
region.setSharingMatNames(i, j, k, data.sharingMatNames[k]);
|
region.setSharingMatNames(i, j, k, data.sharingMatNames[k]);
|
||||||
region.setSharingCutEdges(i, j, k, data.sharingCutEdges[k]);
|
region.setSharingCutEdges(i, j, k, data.sharingCutEdges[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,100 +1,100 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "landscape_editor_plugin.h"
|
#include "landscape_editor_plugin.h"
|
||||||
#include "landscape_editor_window.h"
|
#include "landscape_editor_window.h"
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include "nel/misc/debug.h"
|
#include "nel/misc/debug.h"
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
LandscapeEditorPlugin::~LandscapeEditorPlugin()
|
LandscapeEditorPlugin::~LandscapeEditorPlugin()
|
||||||
{
|
{
|
||||||
Q_FOREACH(QObject *obj, m_autoReleaseObjects)
|
Q_FOREACH(QObject *obj, m_autoReleaseObjects)
|
||||||
{
|
{
|
||||||
m_plugMan->removeObject(obj);
|
m_plugMan->removeObject(obj);
|
||||||
}
|
}
|
||||||
qDeleteAll(m_autoReleaseObjects);
|
qDeleteAll(m_autoReleaseObjects);
|
||||||
m_autoReleaseObjects.clear();
|
m_autoReleaseObjects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LandscapeEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
bool LandscapeEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||||
{
|
{
|
||||||
Q_UNUSED(errorString);
|
Q_UNUSED(errorString);
|
||||||
m_plugMan = pluginManager;
|
m_plugMan = pluginManager;
|
||||||
|
|
||||||
addAutoReleasedObject(new LandscapeEditorContext(this));
|
addAutoReleasedObject(new LandscapeEditorContext(this));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorPlugin::extensionsInitialized()
|
void LandscapeEditorPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorPlugin::shutdown()
|
void LandscapeEditorPlugin::shutdown()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
void LandscapeEditorPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
// Ensure that a context doesn't exist yet.
|
// Ensure that a context doesn't exist yet.
|
||||||
// This only applies to platforms without PIC, e.g. Windows.
|
// This only applies to platforms without PIC, e.g. Windows.
|
||||||
nlassert(!NLMISC::INelContext::isContextInitialised());
|
nlassert(!NLMISC::INelContext::isContextInitialised());
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
m_libContext = new NLMISC::CLibraryContext(*nelContext);
|
m_libContext = new NLMISC::CLibraryContext(*nelContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorPlugin::addAutoReleasedObject(QObject *obj)
|
void LandscapeEditorPlugin::addAutoReleasedObject(QObject *obj)
|
||||||
{
|
{
|
||||||
m_plugMan->addObject(obj);
|
m_plugMan->addObject(obj);
|
||||||
m_autoReleaseObjects.prepend(obj);
|
m_autoReleaseObjects.prepend(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
LandscapeEditorContext::LandscapeEditorContext(QObject *parent)
|
LandscapeEditorContext::LandscapeEditorContext(QObject *parent)
|
||||||
: IContext(parent),
|
: IContext(parent),
|
||||||
m_landEditorWindow(0)
|
m_landEditorWindow(0)
|
||||||
{
|
{
|
||||||
m_landEditorWindow = new LandscapeEditorWindow();
|
m_landEditorWindow = new LandscapeEditorWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoStack *LandscapeEditorContext::undoStack()
|
QUndoStack *LandscapeEditorContext::undoStack()
|
||||||
{
|
{
|
||||||
return m_landEditorWindow->undoStack();
|
return m_landEditorWindow->undoStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorContext::open()
|
void LandscapeEditorContext::open()
|
||||||
{
|
{
|
||||||
m_landEditorWindow->open();
|
m_landEditorWindow->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *LandscapeEditorContext::widget()
|
QWidget *LandscapeEditorContext::widget()
|
||||||
{
|
{
|
||||||
return m_landEditorWindow;
|
return m_landEditorWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Q_EXPORT_PLUGIN(LandscapeEditor::LandscapeEditorPlugin)
|
Q_EXPORT_PLUGIN(LandscapeEditor::LandscapeEditorPlugin)
|
||||||
|
|
|
@ -1,414 +1,414 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "landscape_editor_window.h"
|
#include "landscape_editor_window.h"
|
||||||
#include "landscape_editor_constants.h"
|
#include "landscape_editor_constants.h"
|
||||||
#include "builder_zone.h"
|
#include "builder_zone.h"
|
||||||
#include "zone_region_editor.h"
|
#include "zone_region_editor.h"
|
||||||
#include "landscape_scene.h"
|
#include "landscape_scene.h"
|
||||||
#include "project_settings_dialog.h"
|
#include "project_settings_dialog.h"
|
||||||
#include "snapshot_dialog.h"
|
#include "snapshot_dialog.h"
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/menu_manager.h"
|
#include "../core/menu_manager.h"
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtGui/QStatusBar>
|
#include <QtGui/QStatusBar>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
static const int LANDSCAPE_ID = 32;
|
static const int LANDSCAPE_ID = 32;
|
||||||
int NewLandCounter = 0;
|
int NewLandCounter = 0;
|
||||||
QString _lastDir;
|
QString _lastDir;
|
||||||
|
|
||||||
LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
m_currentItem(0),
|
m_currentItem(0),
|
||||||
m_landscapeScene(0),
|
m_landscapeScene(0),
|
||||||
m_zoneBuilder(0),
|
m_zoneBuilder(0),
|
||||||
m_undoStack(0),
|
m_undoStack(0),
|
||||||
m_oglWidget(0)
|
m_oglWidget(0)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
m_landscapeScene = new LandscapeScene(160, this);
|
m_landscapeScene = new LandscapeScene(160, this);
|
||||||
|
|
||||||
m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack);
|
m_zoneBuilder = new ZoneBuilder(m_landscapeScene, m_ui.zoneListWidget, m_undoStack);
|
||||||
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
m_ui.zoneListWidget->setZoneBuilder(m_zoneBuilder);
|
||||||
m_ui.zoneListWidget->updateUi();
|
m_ui.zoneListWidget->updateUi();
|
||||||
|
|
||||||
m_landscapeScene->setZoneBuilder(m_zoneBuilder);
|
m_landscapeScene->setZoneBuilder(m_zoneBuilder);
|
||||||
m_ui.graphicsView->setScene(m_landscapeScene);
|
m_ui.graphicsView->setScene(m_landscapeScene);
|
||||||
|
|
||||||
m_ui.newLandAction->setIcon(QIcon(Core::Constants::ICON_NEW));
|
m_ui.newLandAction->setIcon(QIcon(Core::Constants::ICON_NEW));
|
||||||
m_ui.saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
m_ui.saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
||||||
m_ui.saveLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
m_ui.saveLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
||||||
m_ui.saveAsLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS));
|
m_ui.saveAsLandAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS));
|
||||||
m_ui.zonesDockWidget->toggleViewAction()->setIcon(QIcon(Constants::ICON_LANDSCAPE_ZONES));
|
m_ui.zonesDockWidget->toggleViewAction()->setIcon(QIcon(Constants::ICON_LANDSCAPE_ZONES));
|
||||||
m_ui.landscapesDockWidget->toggleViewAction()->setIcon(QIcon(Constants::ICON_ZONE_ITEM));
|
m_ui.landscapesDockWidget->toggleViewAction()->setIcon(QIcon(Constants::ICON_ZONE_ITEM));
|
||||||
|
|
||||||
m_ui.deleteLandAction->setEnabled(false);
|
m_ui.deleteLandAction->setEnabled(false);
|
||||||
|
|
||||||
createMenus();
|
createMenus();
|
||||||
createToolBars();
|
createToolBars();
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
connect(m_ui.saveAction, SIGNAL(triggered()), this, SLOT(save()));
|
connect(m_ui.saveAction, SIGNAL(triggered()), this, SLOT(save()));
|
||||||
connect(m_ui.projectSettingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings()));
|
connect(m_ui.projectSettingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings()));
|
||||||
connect(m_ui.snapshotAction, SIGNAL(triggered()), this, SLOT(openSnapshotDialog()));
|
connect(m_ui.snapshotAction, SIGNAL(triggered()), this, SLOT(openSnapshotDialog()));
|
||||||
connect(m_ui.enableGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool)));
|
connect(m_ui.enableGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool)));
|
||||||
|
|
||||||
connect(m_ui.newLandAction, SIGNAL(triggered()), this, SLOT(newLand()));
|
connect(m_ui.newLandAction, SIGNAL(triggered()), this, SLOT(newLand()));
|
||||||
connect(m_ui.setActiveLandAction, SIGNAL(triggered()), this, SLOT(setActiveLand()));
|
connect(m_ui.setActiveLandAction, SIGNAL(triggered()), this, SLOT(setActiveLand()));
|
||||||
connect(m_ui.saveLandAction, SIGNAL(triggered()), this, SLOT(saveSelectedLand()));
|
connect(m_ui.saveLandAction, SIGNAL(triggered()), this, SLOT(saveSelectedLand()));
|
||||||
connect(m_ui.saveAsLandAction, SIGNAL(triggered()), this, SLOT(saveAsSelectedLand()));
|
connect(m_ui.saveAsLandAction, SIGNAL(triggered()), this, SLOT(saveAsSelectedLand()));
|
||||||
connect(m_ui.deleteLandAction, SIGNAL(triggered()), this, SLOT(deleteSelectedLand()));
|
connect(m_ui.deleteLandAction, SIGNAL(triggered()), this, SLOT(deleteSelectedLand()));
|
||||||
connect(m_ui.transitionModeAction, SIGNAL(toggled(bool)), m_landscapeScene, SLOT(setTransitionMode(bool)));
|
connect(m_ui.transitionModeAction, SIGNAL(toggled(bool)), m_landscapeScene, SLOT(setTransitionMode(bool)));
|
||||||
|
|
||||||
connect(m_ui.landscapesListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenu()));
|
connect(m_ui.landscapesListWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenu()));
|
||||||
m_ui.landscapesListWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_ui.landscapesListWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
m_statusBarTimer = new QTimer(this);
|
m_statusBarTimer = new QTimer(this);
|
||||||
connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
|
connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
|
||||||
|
|
||||||
m_statusInfo = new QLabel(this);
|
m_statusInfo = new QLabel(this);
|
||||||
m_statusInfo->hide();
|
m_statusInfo->hide();
|
||||||
Core::ICore::instance()->mainWindow()->statusBar()->addPermanentWidget(m_statusInfo);
|
Core::ICore::instance()->mainWindow()->statusBar()->addPermanentWidget(m_statusInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
LandscapeEditorWindow::~LandscapeEditorWindow()
|
LandscapeEditorWindow::~LandscapeEditorWindow()
|
||||||
{
|
{
|
||||||
writeSettings();
|
writeSettings();
|
||||||
delete m_zoneBuilder;
|
delete m_zoneBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoStack *LandscapeEditorWindow::undoStack() const
|
QUndoStack *LandscapeEditorWindow::undoStack() const
|
||||||
{
|
{
|
||||||
return m_undoStack;
|
return m_undoStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::open()
|
void LandscapeEditorWindow::open()
|
||||||
{
|
{
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this,
|
QStringList fileNames = QFileDialog::getOpenFileNames(this,
|
||||||
tr("Open NeL Ligo land file"), _lastDir,
|
tr("Open NeL Ligo land file"), _lastDir,
|
||||||
tr("All NeL Ligo land files (*.land)"));
|
tr("All NeL Ligo land files (*.land)"));
|
||||||
|
|
||||||
setCursor(Qt::WaitCursor);
|
setCursor(Qt::WaitCursor);
|
||||||
if (!fileNames.isEmpty())
|
if (!fileNames.isEmpty())
|
||||||
{
|
{
|
||||||
QStringList list = fileNames;
|
QStringList list = fileNames;
|
||||||
_lastDir = QFileInfo(list.front()).absolutePath();
|
_lastDir = QFileInfo(list.front()).absolutePath();
|
||||||
Q_FOREACH(QString fileName, fileNames)
|
Q_FOREACH(QString fileName, fileNames)
|
||||||
{
|
{
|
||||||
int row = createLandscape(fileName);
|
int row = createLandscape(fileName);
|
||||||
if (row != -1)
|
if (row != -1)
|
||||||
setActiveLandscape(row);
|
setActiveLandscape(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::save()
|
void LandscapeEditorWindow::save()
|
||||||
{
|
{
|
||||||
saveLandscape(m_ui.landscapesListWidget->row(m_currentItem), true);
|
saveLandscape(m_ui.landscapesListWidget->row(m_currentItem), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::openProjectSettings()
|
void LandscapeEditorWindow::openProjectSettings()
|
||||||
{
|
{
|
||||||
ProjectSettingsDialog *dialog = new ProjectSettingsDialog(m_zoneBuilder->dataPath(), this);
|
ProjectSettingsDialog *dialog = new ProjectSettingsDialog(m_zoneBuilder->dataPath(), this);
|
||||||
dialog->show();
|
dialog->show();
|
||||||
int ok = dialog->exec();
|
int ok = dialog->exec();
|
||||||
if (ok == QDialog::Accepted)
|
if (ok == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
m_zoneBuilder->init(dialog->dataPath(), true);
|
m_zoneBuilder->init(dialog->dataPath(), true);
|
||||||
m_ui.zoneListWidget->updateUi();
|
m_ui.zoneListWidget->updateUi();
|
||||||
}
|
}
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::openSnapshotDialog()
|
void LandscapeEditorWindow::openSnapshotDialog()
|
||||||
{
|
{
|
||||||
SnapshotDialog *dialog = new SnapshotDialog(this);
|
SnapshotDialog *dialog = new SnapshotDialog(this);
|
||||||
dialog->show();
|
dialog->show();
|
||||||
int ok = dialog->exec();
|
int ok = dialog->exec();
|
||||||
if (ok == QDialog::Accepted)
|
if (ok == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(this,
|
QString fileName = QFileDialog::getSaveFileName(this,
|
||||||
tr("Save screenshot landscape"), _lastDir,
|
tr("Save screenshot landscape"), _lastDir,
|
||||||
tr("Image file (*.png)"));
|
tr("Image file (*.png)"));
|
||||||
|
|
||||||
setCursor(Qt::WaitCursor);
|
setCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->currentZoneRegion()->ligoZoneRegion();
|
NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->currentZoneRegion()->ligoZoneRegion();
|
||||||
sint32 regionMinX = zoneRegion.getMinX();
|
sint32 regionMinX = zoneRegion.getMinX();
|
||||||
sint32 regionMaxX = zoneRegion.getMaxX();
|
sint32 regionMaxX = zoneRegion.getMaxX();
|
||||||
sint32 regionMinY = zoneRegion.getMinY();
|
sint32 regionMinY = zoneRegion.getMinY();
|
||||||
sint32 regionMaxY = zoneRegion.getMaxY();
|
sint32 regionMaxY = zoneRegion.getMaxY();
|
||||||
|
|
||||||
int regionWidth = (regionMaxX - regionMinX + 1);
|
int regionWidth = (regionMaxX - regionMinX + 1);
|
||||||
int regionHeight = (regionMaxY - regionMinY + 1);
|
int regionHeight = (regionMaxY - regionMinY + 1);
|
||||||
|
|
||||||
int cellSize = m_landscapeScene->cellSize();
|
int cellSize = m_landscapeScene->cellSize();
|
||||||
QRectF rect(regionMinX * cellSize, abs(regionMaxY) * cellSize, regionWidth * cellSize, regionHeight * cellSize);
|
QRectF rect(regionMinX * cellSize, abs(regionMaxY) * cellSize, regionWidth * cellSize, regionHeight * cellSize);
|
||||||
|
|
||||||
if (dialog->isCustomSize())
|
if (dialog->isCustomSize())
|
||||||
{
|
{
|
||||||
int widthSnapshot = dialog->widthSnapshot();
|
int widthSnapshot = dialog->widthSnapshot();
|
||||||
int heightSnapshot = dialog->heightSnapshot();
|
int heightSnapshot = dialog->heightSnapshot();
|
||||||
if (dialog->isKeepRatio())
|
if (dialog->isKeepRatio())
|
||||||
heightSnapshot = (widthSnapshot / regionWidth) * regionHeight;
|
heightSnapshot = (widthSnapshot / regionWidth) * regionHeight;
|
||||||
|
|
||||||
m_landscapeScene->snapshot(fileName, widthSnapshot, heightSnapshot, rect);
|
m_landscapeScene->snapshot(fileName, widthSnapshot, heightSnapshot, rect);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_landscapeScene->snapshot(fileName, regionWidth * dialog->resolutionZone(),
|
m_landscapeScene->snapshot(fileName, regionWidth * dialog->resolutionZone(),
|
||||||
regionHeight * dialog->resolutionZone(), rect);
|
regionHeight * dialog->resolutionZone(), rect);
|
||||||
}
|
}
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::customContextMenu()
|
void LandscapeEditorWindow::customContextMenu()
|
||||||
{
|
{
|
||||||
if (m_ui.landscapesListWidget->currentRow() == -1)
|
if (m_ui.landscapesListWidget->currentRow() == -1)
|
||||||
return;
|
return;
|
||||||
QMenu *popurMenu = new QMenu(this);
|
QMenu *popurMenu = new QMenu(this);
|
||||||
popurMenu->addAction(m_ui.setActiveLandAction);
|
popurMenu->addAction(m_ui.setActiveLandAction);
|
||||||
popurMenu->addAction(m_ui.saveLandAction);
|
popurMenu->addAction(m_ui.saveLandAction);
|
||||||
popurMenu->addAction(m_ui.saveAsLandAction);
|
popurMenu->addAction(m_ui.saveAsLandAction);
|
||||||
popurMenu->addAction(m_ui.deleteLandAction);
|
popurMenu->addAction(m_ui.deleteLandAction);
|
||||||
popurMenu->exec(QCursor::pos());
|
popurMenu->exec(QCursor::pos());
|
||||||
delete popurMenu;
|
delete popurMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::newLand()
|
void LandscapeEditorWindow::newLand()
|
||||||
{
|
{
|
||||||
int row = createLandscape(QString());
|
int row = createLandscape(QString());
|
||||||
if (row != -1)
|
if (row != -1)
|
||||||
setActiveLandscape(row);
|
setActiveLandscape(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::setActiveLand()
|
void LandscapeEditorWindow::setActiveLand()
|
||||||
{
|
{
|
||||||
setActiveLandscape(m_ui.landscapesListWidget->currentRow());
|
setActiveLandscape(m_ui.landscapesListWidget->currentRow());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::saveSelectedLand()
|
void LandscapeEditorWindow::saveSelectedLand()
|
||||||
{
|
{
|
||||||
saveLandscape(m_ui.landscapesListWidget->currentRow(), true);
|
saveLandscape(m_ui.landscapesListWidget->currentRow(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::saveAsSelectedLand()
|
void LandscapeEditorWindow::saveAsSelectedLand()
|
||||||
{
|
{
|
||||||
saveLandscape(m_ui.landscapesListWidget->currentRow(), false);
|
saveLandscape(m_ui.landscapesListWidget->currentRow(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::deleteSelectedLand()
|
void LandscapeEditorWindow::deleteSelectedLand()
|
||||||
{
|
{
|
||||||
int row = m_ui.landscapesListWidget->currentRow();
|
int row = m_ui.landscapesListWidget->currentRow();
|
||||||
int current_row = m_ui.landscapesListWidget->row(m_currentItem);
|
int current_row = m_ui.landscapesListWidget->row(m_currentItem);
|
||||||
QListWidgetItem *item = m_ui.landscapesListWidget->item(row);
|
QListWidgetItem *item = m_ui.landscapesListWidget->item(row);
|
||||||
if (row == current_row)
|
if (row == current_row)
|
||||||
{
|
{
|
||||||
if (row == 0)
|
if (row == 0)
|
||||||
++row;
|
++row;
|
||||||
else
|
else
|
||||||
--row;
|
--row;
|
||||||
setActiveLandscape(row);
|
setActiveLandscape(row);
|
||||||
}
|
}
|
||||||
m_zoneBuilder->deleteZoneRegion(item->data(LANDSCAPE_ID).toInt());
|
m_zoneBuilder->deleteZoneRegion(item->data(LANDSCAPE_ID).toInt());
|
||||||
m_ui.landscapesListWidget->removeItemWidget(item);
|
m_ui.landscapesListWidget->removeItemWidget(item);
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
if (m_ui.landscapesListWidget->count() == 1)
|
if (m_ui.landscapesListWidget->count() == 1)
|
||||||
m_ui.deleteLandAction->setEnabled(false);
|
m_ui.deleteLandAction->setEnabled(false);
|
||||||
|
|
||||||
m_undoStack->clear();
|
m_undoStack->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LandscapeEditorWindow::createLandscape(const QString &fileName)
|
int LandscapeEditorWindow::createLandscape(const QString &fileName)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
id = m_zoneBuilder->createZoneRegion();
|
id = m_zoneBuilder->createZoneRegion();
|
||||||
else
|
else
|
||||||
id = m_zoneBuilder->createZoneRegion(fileName);
|
id = m_zoneBuilder->createZoneRegion(fileName);
|
||||||
|
|
||||||
if (id == -1)
|
if (id == -1)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, "Landscape Editor", tr("Cannot add this zone because it overlaps existing ones"));
|
QMessageBox::critical(this, "Landscape Editor", tr("Cannot add this zone because it overlaps existing ones"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ZoneRegionObject *zoneRegion = m_zoneBuilder->zoneRegion(id);
|
ZoneRegionObject *zoneRegion = m_zoneBuilder->zoneRegion(id);
|
||||||
m_ui.graphicsView->setCenter(QPointF(zoneRegion->ligoZoneRegion().getMinX() * m_landscapeScene->cellSize(),
|
m_ui.graphicsView->setCenter(QPointF(zoneRegion->ligoZoneRegion().getMinX() * m_landscapeScene->cellSize(),
|
||||||
abs(zoneRegion->ligoZoneRegion().getMinY()) * m_landscapeScene->cellSize()));
|
abs(zoneRegion->ligoZoneRegion().getMinY()) * m_landscapeScene->cellSize()));
|
||||||
|
|
||||||
QListWidgetItem *item;
|
QListWidgetItem *item;
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
item = new QListWidgetItem(QString("NewLandscape%1").arg(NewLandCounter++), m_ui.landscapesListWidget);
|
item = new QListWidgetItem(QString("NewLandscape%1").arg(NewLandCounter++), m_ui.landscapesListWidget);
|
||||||
else
|
else
|
||||||
item = new QListWidgetItem(fileName, m_ui.landscapesListWidget);
|
item = new QListWidgetItem(fileName, m_ui.landscapesListWidget);
|
||||||
|
|
||||||
item->setData(LANDSCAPE_ID, id);
|
item->setData(LANDSCAPE_ID, id);
|
||||||
item->setFont(QFont("SansSerif", 9, QFont::Normal));
|
item->setFont(QFont("SansSerif", 9, QFont::Normal));
|
||||||
|
|
||||||
if (m_ui.landscapesListWidget->count() > 1)
|
if (m_ui.landscapesListWidget->count() > 1)
|
||||||
m_ui.deleteLandAction->setEnabled(true);
|
m_ui.deleteLandAction->setEnabled(true);
|
||||||
|
|
||||||
return m_ui.landscapesListWidget->count() - 1;
|
return m_ui.landscapesListWidget->count() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::setActiveLandscape(int row)
|
void LandscapeEditorWindow::setActiveLandscape(int row)
|
||||||
{
|
{
|
||||||
if ((0 <= row) && (row < m_ui.landscapesListWidget->count()))
|
if ((0 <= row) && (row < m_ui.landscapesListWidget->count()))
|
||||||
{
|
{
|
||||||
if (m_currentItem != 0)
|
if (m_currentItem != 0)
|
||||||
m_currentItem->setFont(QFont("SansSerif", 9, QFont::Normal));
|
m_currentItem->setFont(QFont("SansSerif", 9, QFont::Normal));
|
||||||
|
|
||||||
QListWidgetItem *item = m_ui.landscapesListWidget->item(row);
|
QListWidgetItem *item = m_ui.landscapesListWidget->item(row);
|
||||||
item->setFont(QFont("SansSerif", 9, QFont::Bold));
|
item->setFont(QFont("SansSerif", 9, QFont::Bold));
|
||||||
m_zoneBuilder->setCurrentZoneRegion(item->data(LANDSCAPE_ID).toInt());
|
m_zoneBuilder->setCurrentZoneRegion(item->data(LANDSCAPE_ID).toInt());
|
||||||
m_currentItem = item;
|
m_currentItem = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::saveLandscape(int row, bool force)
|
void LandscapeEditorWindow::saveLandscape(int row, bool force)
|
||||||
{
|
{
|
||||||
if ((0 <= row) && (row < m_ui.landscapesListWidget->count()))
|
if ((0 <= row) && (row < m_ui.landscapesListWidget->count()))
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = m_ui.landscapesListWidget->item(row);
|
QListWidgetItem *item = m_ui.landscapesListWidget->item(row);
|
||||||
ZoneRegionObject *regionObject = m_zoneBuilder->zoneRegion(item->data(LANDSCAPE_ID).toInt());
|
ZoneRegionObject *regionObject = m_zoneBuilder->zoneRegion(item->data(LANDSCAPE_ID).toInt());
|
||||||
if ((!force) || (regionObject->fileName().empty()))
|
if ((!force) || (regionObject->fileName().empty()))
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(this,
|
QString fileName = QFileDialog::getSaveFileName(this,
|
||||||
tr("Save NeL Ligo land file"), _lastDir,
|
tr("Save NeL Ligo land file"), _lastDir,
|
||||||
tr("NeL Ligo land file (*.land)"));
|
tr("NeL Ligo land file (*.land)"));
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
{
|
{
|
||||||
regionObject->setFileName(fileName.toStdString());
|
regionObject->setFileName(fileName.toStdString());
|
||||||
regionObject->save();
|
regionObject->save();
|
||||||
regionObject->setModified(false);
|
regionObject->setModified(false);
|
||||||
item->setText(fileName);
|
item->setText(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
regionObject->save();
|
regionObject->save();
|
||||||
regionObject->setModified(false);
|
regionObject->setModified(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::showEvent(QShowEvent *showEvent)
|
void LandscapeEditorWindow::showEvent(QShowEvent *showEvent)
|
||||||
{
|
{
|
||||||
QMainWindow::showEvent(showEvent);
|
QMainWindow::showEvent(showEvent);
|
||||||
if (m_oglWidget != 0)
|
if (m_oglWidget != 0)
|
||||||
m_oglWidget->makeCurrent();
|
m_oglWidget->makeCurrent();
|
||||||
m_statusInfo->show();
|
m_statusInfo->show();
|
||||||
m_statusBarTimer->start(100);
|
m_statusBarTimer->start(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::hideEvent(QHideEvent *hideEvent)
|
void LandscapeEditorWindow::hideEvent(QHideEvent *hideEvent)
|
||||||
{
|
{
|
||||||
QMainWindow::hideEvent(hideEvent);
|
QMainWindow::hideEvent(hideEvent);
|
||||||
m_statusInfo->hide();
|
m_statusInfo->hide();
|
||||||
m_statusBarTimer->stop();
|
m_statusBarTimer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::updateStatusBar()
|
void LandscapeEditorWindow::updateStatusBar()
|
||||||
{
|
{
|
||||||
m_statusInfo->setText(m_landscapeScene->zoneNameFromMousePos());
|
m_statusInfo->setText(m_landscapeScene->zoneNameFromMousePos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::createMenus()
|
void LandscapeEditorWindow::createMenus()
|
||||||
{
|
{
|
||||||
Core::MenuManager *menuManager = Core::ICore::instance()->menuManager();
|
Core::MenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::createToolBars()
|
void LandscapeEditorWindow::createToolBars()
|
||||||
{
|
{
|
||||||
Core::MenuManager *menuManager = Core::ICore::instance()->menuManager();
|
Core::MenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||||
//QAction *action = menuManager->action(Core::Constants::NEW);
|
//QAction *action = menuManager->action(Core::Constants::NEW);
|
||||||
//m_ui.fileToolBar->addAction(action);
|
//m_ui.fileToolBar->addAction(action);
|
||||||
//action = menuManager->action(Core::Constants::SAVE);
|
//action = menuManager->action(Core::Constants::SAVE);
|
||||||
//m_ui.fileToolBar->addAction(action);
|
//m_ui.fileToolBar->addAction(action);
|
||||||
//action = menuManager->action(Core::Constants::SAVE_AS);
|
//action = menuManager->action(Core::Constants::SAVE_AS);
|
||||||
//m_ui.fileToolBar->addAction(action);
|
//m_ui.fileToolBar->addAction(action);
|
||||||
|
|
||||||
QAction *action = menuManager->action(Core::Constants::OPEN);
|
QAction *action = menuManager->action(Core::Constants::OPEN);
|
||||||
m_ui.fileToolBar->addAction(m_ui.newLandAction);
|
m_ui.fileToolBar->addAction(m_ui.newLandAction);
|
||||||
m_ui.fileToolBar->addAction(action);
|
m_ui.fileToolBar->addAction(action);
|
||||||
m_ui.fileToolBar->addAction(m_ui.saveAction);
|
m_ui.fileToolBar->addAction(m_ui.saveAction);
|
||||||
m_ui.fileToolBar->addSeparator();
|
m_ui.fileToolBar->addSeparator();
|
||||||
|
|
||||||
action = menuManager->action(Core::Constants::UNDO);
|
action = menuManager->action(Core::Constants::UNDO);
|
||||||
if (action != 0)
|
if (action != 0)
|
||||||
m_ui.fileToolBar->addAction(action);
|
m_ui.fileToolBar->addAction(action);
|
||||||
|
|
||||||
action = menuManager->action(Core::Constants::REDO);
|
action = menuManager->action(Core::Constants::REDO);
|
||||||
if (action != 0)
|
if (action != 0)
|
||||||
m_ui.fileToolBar->addAction(action);
|
m_ui.fileToolBar->addAction(action);
|
||||||
|
|
||||||
m_ui.zoneToolBar->insertAction(m_ui.enableGridAction, m_ui.landscapesDockWidget->toggleViewAction());
|
m_ui.zoneToolBar->insertAction(m_ui.enableGridAction, m_ui.landscapesDockWidget->toggleViewAction());
|
||||||
m_ui.zoneToolBar->insertAction(m_ui.enableGridAction, m_ui.zonesDockWidget->toggleViewAction());
|
m_ui.zoneToolBar->insertAction(m_ui.enableGridAction, m_ui.zonesDockWidget->toggleViewAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::readSettings()
|
void LandscapeEditorWindow::readSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
||||||
restoreState(settings->value(Constants::LANDSCAPE_WINDOW_STATE).toByteArray());
|
restoreState(settings->value(Constants::LANDSCAPE_WINDOW_STATE).toByteArray());
|
||||||
restoreGeometry(settings->value(Constants::LANDSCAPE_WINDOW_GEOMETRY).toByteArray());
|
restoreGeometry(settings->value(Constants::LANDSCAPE_WINDOW_GEOMETRY).toByteArray());
|
||||||
|
|
||||||
// Read landscape data directory (contains sub-paths: zone logos, zone bitmaps)
|
// Read landscape data directory (contains sub-paths: zone logos, zone bitmaps)
|
||||||
m_zoneBuilder->init(settings->value(Constants::LANDSCAPE_DATA_DIRECTORY).toString());
|
m_zoneBuilder->init(settings->value(Constants::LANDSCAPE_DATA_DIRECTORY).toString());
|
||||||
m_ui.zoneListWidget->updateUi();
|
m_ui.zoneListWidget->updateUi();
|
||||||
|
|
||||||
// Use OpenGL graphics system instead raster graphics system
|
// Use OpenGL graphics system instead raster graphics system
|
||||||
if (settings->value(Constants::LANDSCAPE_USE_OPENGL, false).toBool())
|
if (settings->value(Constants::LANDSCAPE_USE_OPENGL, false).toBool())
|
||||||
{
|
{
|
||||||
m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer));
|
m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer));
|
||||||
m_ui.graphicsView->setViewport(m_oglWidget);
|
m_ui.graphicsView->setViewport(m_oglWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::writeSettings()
|
void LandscapeEditorWindow::writeSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
settings->beginGroup(Constants::LANDSCAPE_EDITOR_SECTION);
|
||||||
settings->setValue(Constants::LANDSCAPE_WINDOW_STATE, saveState());
|
settings->setValue(Constants::LANDSCAPE_WINDOW_STATE, saveState());
|
||||||
settings->setValue(Constants::LANDSCAPE_WINDOW_GEOMETRY, saveGeometry());
|
settings->setValue(Constants::LANDSCAPE_WINDOW_GEOMETRY, saveGeometry());
|
||||||
settings->setValue(Constants::LANDSCAPE_DATA_DIRECTORY, m_zoneBuilder->dataPath());
|
settings->setValue(Constants::LANDSCAPE_DATA_DIRECTORY, m_zoneBuilder->dataPath());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,498 +1,498 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "landscape_scene.h"
|
#include "landscape_scene.h"
|
||||||
#include "pixmap_database.h"
|
#include "pixmap_database.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
#include <QtGui/QGraphicsPixmapItem>
|
#include <QtGui/QGraphicsPixmapItem>
|
||||||
#include <QtGui/QGraphicsSimpleTextItem>
|
#include <QtGui/QGraphicsSimpleTextItem>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
static const int ZONE_NAME = 0;
|
static const int ZONE_NAME = 0;
|
||||||
static const int LAYER_ZONES = 2;
|
static const int LAYER_ZONES = 2;
|
||||||
static const int LAYER_EMPTY_ZONES = 3;
|
static const int LAYER_EMPTY_ZONES = 3;
|
||||||
static const int LAYER_BLACKOUT = 4;
|
static const int LAYER_BLACKOUT = 4;
|
||||||
const char *const LAYER_BLACKOUT_NAME = "blackout";
|
const char *const LAYER_BLACKOUT_NAME = "blackout";
|
||||||
|
|
||||||
const int MAX_SCENE_WIDTH = 256;
|
const int MAX_SCENE_WIDTH = 256;
|
||||||
const int MAX_SCENE_HEIGHT = 256;
|
const int MAX_SCENE_HEIGHT = 256;
|
||||||
|
|
||||||
LandscapeScene::LandscapeScene(int sizeCell, QObject *parent)
|
LandscapeScene::LandscapeScene(int sizeCell, QObject *parent)
|
||||||
: QGraphicsScene(parent),
|
: QGraphicsScene(parent),
|
||||||
m_cellSize(sizeCell),
|
m_cellSize(sizeCell),
|
||||||
m_transitionMode(false),
|
m_transitionMode(false),
|
||||||
m_mouseButton(Qt::NoButton),
|
m_mouseButton(Qt::NoButton),
|
||||||
m_zoneBuilder(0)
|
m_zoneBuilder(0)
|
||||||
{
|
{
|
||||||
setSceneRect(QRectF(0, m_cellSize, MAX_SCENE_WIDTH * m_cellSize, MAX_SCENE_HEIGHT * m_cellSize));
|
setSceneRect(QRectF(0, m_cellSize, MAX_SCENE_WIDTH * m_cellSize, MAX_SCENE_HEIGHT * m_cellSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
LandscapeScene::~LandscapeScene()
|
LandscapeScene::~LandscapeScene()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int LandscapeScene::cellSize() const
|
int LandscapeScene::cellSize() const
|
||||||
{
|
{
|
||||||
return m_cellSize;
|
return m_cellSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
void LandscapeScene::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
||||||
{
|
{
|
||||||
m_zoneBuilder = zoneBuilder;
|
m_zoneBuilder = zoneBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePosition &zonePos)
|
QGraphicsItem *LandscapeScene::createItemZone(const LigoData &data, const ZonePosition &zonePos)
|
||||||
{
|
{
|
||||||
if ((data.zoneName == STRING_OUT_OF_BOUND) || (checkUnderZone(zonePos.x, zonePos.y)))
|
if ((data.zoneName == STRING_OUT_OF_BOUND) || (checkUnderZone(zonePos.x, zonePos.y)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (data.zoneName == STRING_UNUSED)
|
if (data.zoneName == STRING_UNUSED)
|
||||||
return createItemEmptyZone(zonePos);
|
return createItemEmptyZone(zonePos);
|
||||||
|
|
||||||
if ((m_zoneBuilder == 0) || (data.zoneName.empty()))
|
if ((m_zoneBuilder == 0) || (data.zoneName.empty()))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Get image from pixmap database
|
// Get image from pixmap database
|
||||||
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.zoneName.c_str()));
|
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(data.zoneName.c_str()));
|
||||||
if (pixmap == 0)
|
if (pixmap == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Rotate the image counterclockwise
|
// Rotate the image counterclockwise
|
||||||
QMatrix matrix;
|
QMatrix matrix;
|
||||||
matrix.rotate(-data.rot * 90.0);
|
matrix.rotate(-data.rot * 90.0);
|
||||||
|
|
||||||
QGraphicsPixmapItem *item;
|
QGraphicsPixmapItem *item;
|
||||||
|
|
||||||
if (data.flip == 0)
|
if (data.flip == 0)
|
||||||
{
|
{
|
||||||
item = addPixmap(pixmap->transformed(matrix, Qt::SmoothTransformation));
|
item = addPixmap(pixmap->transformed(matrix, Qt::SmoothTransformation));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// mirror image
|
// mirror image
|
||||||
QImage mirrorImage = pixmap->toImage();
|
QImage mirrorImage = pixmap->toImage();
|
||||||
QPixmap mirrorPixmap = QPixmap::fromImage(mirrorImage.mirrored(true, false));
|
QPixmap mirrorPixmap = QPixmap::fromImage(mirrorImage.mirrored(true, false));
|
||||||
item = addPixmap(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation));
|
item = addPixmap(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation));
|
||||||
}
|
}
|
||||||
// Enable bilinear filtering
|
// Enable bilinear filtering
|
||||||
item->setTransformationMode(Qt::SmoothTransformation);
|
item->setTransformationMode(Qt::SmoothTransformation);
|
||||||
|
|
||||||
sint32 sizeX = 1, sizeY = 1;
|
sint32 sizeX = 1, sizeY = 1;
|
||||||
sizeX = float(pixmap->width()) / m_zoneBuilder->pixmapDatabase()->textureSize();
|
sizeX = float(pixmap->width()) / m_zoneBuilder->pixmapDatabase()->textureSize();
|
||||||
sizeY = float(pixmap->width()) / m_zoneBuilder->pixmapDatabase()->textureSize();
|
sizeY = float(pixmap->width()) / m_zoneBuilder->pixmapDatabase()->textureSize();
|
||||||
|
|
||||||
sint32 deltaX = 0, deltaY = 0;
|
sint32 deltaX = 0, deltaY = 0;
|
||||||
|
|
||||||
// Calculate offset for graphics item (for items with size that are larger than 1)
|
// Calculate offset for graphics item (for items with size that are larger than 1)
|
||||||
if ((sizeX > 1) || (sizeY > 1))
|
if ((sizeX > 1) || (sizeY > 1))
|
||||||
{
|
{
|
||||||
if (data.flip == 0)
|
if (data.flip == 0)
|
||||||
{
|
{
|
||||||
switch (data.rot)
|
switch (data.rot)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
deltaX = -data.posX;
|
deltaX = -data.posX;
|
||||||
deltaY = -data.posY + sizeY - 1;
|
deltaY = -data.posY + sizeY - 1;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
deltaX = -(sizeY - 1 - data.posY);
|
deltaX = -(sizeY - 1 - data.posY);
|
||||||
deltaY = -data.posX + sizeX - 1;
|
deltaY = -data.posX + sizeX - 1;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
deltaX = -(sizeX - 1 - data.posX);
|
deltaX = -(sizeX - 1 - data.posX);
|
||||||
deltaY = data.posY;
|
deltaY = data.posY;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
deltaX = -data.posY;
|
deltaX = -data.posY;
|
||||||
deltaY = data.posX;
|
deltaY = data.posX;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (data.rot)
|
switch (data.rot)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
deltaX = -(sizeX - 1 - data.posX);
|
deltaX = -(sizeX - 1 - data.posX);
|
||||||
deltaY = -data.posY + sizeY - 1;
|
deltaY = -data.posY + sizeY - 1;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
deltaX = -(sizeY - 1 - data.posY);
|
deltaX = -(sizeY - 1 - data.posY);
|
||||||
deltaY = +data.posX;
|
deltaY = +data.posX;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
deltaX = -data.posX;
|
deltaX = -data.posX;
|
||||||
deltaY = data.posY;
|
deltaY = data.posY;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
deltaX = -data.posY;
|
deltaX = -data.posY;
|
||||||
deltaY = -data.posX + sizeX - 1;
|
deltaY = -data.posX + sizeX - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set position graphics item with offset for large piece
|
// Set position graphics item with offset for large piece
|
||||||
item->setPos((zonePos.x + deltaX) * m_cellSize, (abs(int(zonePos.y + deltaY))) * m_cellSize);
|
item->setPos((zonePos.x + deltaX) * m_cellSize, (abs(int(zonePos.y + deltaY))) * m_cellSize);
|
||||||
|
|
||||||
// The size graphics item should be equal or proportional m_cellSize
|
// The size graphics item should be equal or proportional m_cellSize
|
||||||
item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize());
|
item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize());
|
||||||
|
|
||||||
item->setData(ZONE_NAME, QString(data.zoneName.c_str()));
|
item->setData(ZONE_NAME, QString(data.zoneName.c_str()));
|
||||||
|
|
||||||
// for not full item zone
|
// for not full item zone
|
||||||
item->setZValue(LAYER_ZONES);
|
item->setZValue(LAYER_ZONES);
|
||||||
|
|
||||||
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos)
|
QGraphicsItem *LandscapeScene::createItemEmptyZone(const ZonePosition &zonePos)
|
||||||
{
|
{
|
||||||
if (m_zoneBuilder == 0)
|
if (m_zoneBuilder == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (checkUnderZone(zonePos.x, zonePos.y))
|
if (checkUnderZone(zonePos.x, zonePos.y))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Get image from pixmap database
|
// Get image from pixmap database
|
||||||
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED));
|
QPixmap *pixmap = m_zoneBuilder->pixmapDatabase()->pixmap(QString(STRING_UNUSED));
|
||||||
|
|
||||||
if (pixmap == 0)
|
if (pixmap == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
QGraphicsPixmapItem *item = addPixmap(*pixmap);
|
QGraphicsPixmapItem *item = addPixmap(*pixmap);
|
||||||
|
|
||||||
// Enable bilinear filtering
|
// Enable bilinear filtering
|
||||||
item->setTransformationMode(Qt::SmoothTransformation);
|
item->setTransformationMode(Qt::SmoothTransformation);
|
||||||
|
|
||||||
// Set position graphics item
|
// Set position graphics item
|
||||||
item->setPos(zonePos.x * m_cellSize, abs(int(zonePos.y)) * m_cellSize);
|
item->setPos(zonePos.x * m_cellSize, abs(int(zonePos.y)) * m_cellSize);
|
||||||
|
|
||||||
// The size graphics item should be equal or proportional m_cellSize
|
// The size graphics item should be equal or proportional m_cellSize
|
||||||
item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize());
|
item->setScale(float(m_cellSize) / m_zoneBuilder->pixmapDatabase()->textureSize());
|
||||||
|
|
||||||
// for not full item zone
|
// for not full item zone
|
||||||
item->setZValue(LAYER_EMPTY_ZONES);
|
item->setZValue(LAYER_EMPTY_ZONES);
|
||||||
|
|
||||||
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsRectItem *LandscapeScene::createLayerBlackout(const NLLIGO::CZoneRegion &zoneRegion)
|
QGraphicsRectItem *LandscapeScene::createLayerBlackout(const NLLIGO::CZoneRegion &zoneRegion)
|
||||||
{
|
{
|
||||||
QGraphicsRectItem *rectItem = addRect(zoneRegion.getMinX() * m_cellSize,
|
QGraphicsRectItem *rectItem = addRect(zoneRegion.getMinX() * m_cellSize,
|
||||||
abs(zoneRegion.getMaxY()) * m_cellSize,
|
abs(zoneRegion.getMaxY()) * m_cellSize,
|
||||||
(abs(zoneRegion.getMaxX() - zoneRegion.getMinX()) + 1) * m_cellSize,
|
(abs(zoneRegion.getMaxX() - zoneRegion.getMinX()) + 1) * m_cellSize,
|
||||||
(abs(zoneRegion.getMaxY() - zoneRegion.getMinY()) + 1) * m_cellSize,
|
(abs(zoneRegion.getMaxY() - zoneRegion.getMinY()) + 1) * m_cellSize,
|
||||||
Qt::NoPen, QBrush(QColor(0, 0, 0, 50)));
|
Qt::NoPen, QBrush(QColor(0, 0, 0, 50)));
|
||||||
|
|
||||||
rectItem->setZValue(LAYER_BLACKOUT);
|
rectItem->setZValue(LAYER_BLACKOUT);
|
||||||
rectItem->setData(ZONE_NAME, QString(LAYER_BLACKOUT_NAME));
|
rectItem->setData(ZONE_NAME, QString(LAYER_BLACKOUT_NAME));
|
||||||
return rectItem;
|
return rectItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::deleteItemZone(const ZonePosition &zonePos)
|
void LandscapeScene::deleteItemZone(const ZonePosition &zonePos)
|
||||||
{
|
{
|
||||||
QGraphicsItem *item = itemAt(zonePos.x * m_cellSize, abs(zonePos.y) * m_cellSize);
|
QGraphicsItem *item = itemAt(zonePos.x * m_cellSize, abs(zonePos.y) * m_cellSize);
|
||||||
if ((item != 0) && (item->data(ZONE_NAME).toString() != QString(LAYER_BLACKOUT_NAME)))
|
if ((item != 0) && (item->data(ZONE_NAME).toString() != QString(LAYER_BLACKOUT_NAME)))
|
||||||
{
|
{
|
||||||
removeItem(item);
|
removeItem(item);
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
void LandscapeScene::addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||||
{
|
{
|
||||||
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
||||||
{
|
{
|
||||||
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string zoneName = zoneRegion.getName(i, j);
|
std::string zoneName = zoneRegion.getName(i, j);
|
||||||
if (zoneName == STRING_UNUSED)
|
if (zoneName == STRING_UNUSED)
|
||||||
{
|
{
|
||||||
ZonePosition zonePos(i, j, -1);
|
ZonePosition zonePos(i, j, -1);
|
||||||
QGraphicsItem *item = createItemEmptyZone(zonePos);
|
QGraphicsItem *item = createItemEmptyZone(zonePos);
|
||||||
}
|
}
|
||||||
else if (!zoneName.empty())
|
else if (!zoneName.empty())
|
||||||
{
|
{
|
||||||
LigoData data;
|
LigoData data;
|
||||||
ZonePosition zonePos(i, j, -1);
|
ZonePosition zonePos(i, j, -1);
|
||||||
data.zoneName = zoneName;
|
data.zoneName = zoneName;
|
||||||
data.rot = zoneRegion.getRot(i, j);
|
data.rot = zoneRegion.getRot(i, j);
|
||||||
data.flip = zoneRegion.getFlip(i, j);
|
data.flip = zoneRegion.getFlip(i, j);
|
||||||
data.posX = zoneRegion.getPosX(i, j);
|
data.posX = zoneRegion.getPosX(i, j);
|
||||||
data.posY = zoneRegion.getPosY(i, j);
|
data.posY = zoneRegion.getPosY(i, j);
|
||||||
QGraphicsItem *item = createItemZone(data, zonePos);
|
QGraphicsItem *item = createItemZone(data, zonePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
void LandscapeScene::delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||||
{
|
{
|
||||||
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
||||||
{
|
{
|
||||||
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
||||||
{
|
{
|
||||||
deleteItemZone(ZonePosition(i, -j, -1));
|
deleteItemZone(ZonePosition(i, -j, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::snapshot(const QString &fileName, int width, int height, const QRectF &landRect)
|
void LandscapeScene::snapshot(const QString &fileName, int width, int height, const QRectF &landRect)
|
||||||
{
|
{
|
||||||
if (m_zoneBuilder == 0)
|
if (m_zoneBuilder == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Create image
|
// Create image
|
||||||
QImage image(landRect.width(), landRect.height(), QImage::Format_RGB888);
|
QImage image(landRect.width(), landRect.height(), QImage::Format_RGB888);
|
||||||
QPainter painter(&image);
|
QPainter painter(&image);
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
||||||
// Add white background
|
// Add white background
|
||||||
painter.setBrush(QBrush(Qt::white));
|
painter.setBrush(QBrush(Qt::white));
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
painter.drawRect(0, 0, landRect.width(), landRect.height());
|
painter.drawRect(0, 0, landRect.width(), landRect.height());
|
||||||
|
|
||||||
// Paint landscape
|
// Paint landscape
|
||||||
render(&painter, QRectF(0, 0, landRect.width(), landRect.height()), landRect);
|
render(&painter, QRectF(0, 0, landRect.width(), landRect.height()), landRect);
|
||||||
|
|
||||||
QImage scaledImage = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
QImage scaledImage = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
scaledImage.save(fileName);
|
scaledImage.save(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LandscapeScene::zoneNameFromMousePos() const
|
QString LandscapeScene::zoneNameFromMousePos() const
|
||||||
{
|
{
|
||||||
if ((m_posY > 0) || (m_posY < -MAX_SCENE_HEIGHT) ||
|
if ((m_posY > 0) || (m_posY < -MAX_SCENE_HEIGHT) ||
|
||||||
(m_posX < 0) || (m_posX > MAX_SCENE_WIDTH))
|
(m_posX < 0) || (m_posX > MAX_SCENE_WIDTH))
|
||||||
return "NOT A VALID ZONE";
|
return "NOT A VALID ZONE";
|
||||||
|
|
||||||
return QString("%1_%2%3 %4 %5 ").arg(-m_posY).arg(QChar('A' + (m_posX/26))).
|
return QString("%1_%2%3 %4 %5 ").arg(-m_posY).arg(QChar('A' + (m_posX/26))).
|
||||||
arg(QChar('A' + (m_posX%26))).arg(m_mouseX, 0,'f',2).arg(-m_mouseY, 0,'f',2);
|
arg(QChar('A' + (m_posX%26))).arg(m_mouseX, 0,'f',2).arg(-m_mouseY, 0,'f',2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
void LandscapeScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
{
|
{
|
||||||
qreal x = mouseEvent->scenePos().x();
|
qreal x = mouseEvent->scenePos().x();
|
||||||
qreal y = mouseEvent->scenePos().y();
|
qreal y = mouseEvent->scenePos().y();
|
||||||
if ((x < 0) || (y < 0))
|
if ((x < 0) || (y < 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_posX = sint32(floor(x / m_cellSize));
|
m_posX = sint32(floor(x / m_cellSize));
|
||||||
m_posY = sint32(-floor(y / m_cellSize));
|
m_posY = sint32(-floor(y / m_cellSize));
|
||||||
|
|
||||||
if (m_zoneBuilder == 0)
|
if (m_zoneBuilder == 0)
|
||||||
return;
|
return;
|
||||||
if (m_transitionMode)
|
if (m_transitionMode)
|
||||||
{
|
{
|
||||||
if (mouseEvent->button() == Qt::LeftButton)
|
if (mouseEvent->button() == Qt::LeftButton)
|
||||||
|
|
||||||
// Need add offset(= cellSize) on y axes
|
// Need add offset(= cellSize) on y axes
|
||||||
m_zoneBuilder->addTransition(sint(x), sint(-y + m_cellSize));
|
m_zoneBuilder->addTransition(sint(x), sint(-y + m_cellSize));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mouseEvent->button() == Qt::LeftButton)
|
if (mouseEvent->button() == Qt::LeftButton)
|
||||||
m_zoneBuilder->addZone(m_posX, m_posY);
|
m_zoneBuilder->addZone(m_posX, m_posY);
|
||||||
else if (mouseEvent->button() == Qt::RightButton)
|
else if (mouseEvent->button() == Qt::RightButton)
|
||||||
m_zoneBuilder->delZone(m_posX, m_posY);
|
m_zoneBuilder->delZone(m_posX, m_posY);
|
||||||
}
|
}
|
||||||
m_mouseButton = mouseEvent->button();
|
m_mouseButton = mouseEvent->button();
|
||||||
|
|
||||||
QGraphicsScene::mousePressEvent(mouseEvent);
|
QGraphicsScene::mousePressEvent(mouseEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
void LandscapeScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
{
|
{
|
||||||
qreal x = mouseEvent->scenePos().x();
|
qreal x = mouseEvent->scenePos().x();
|
||||||
qreal y = mouseEvent->scenePos().y();
|
qreal y = mouseEvent->scenePos().y();
|
||||||
|
|
||||||
sint32 posX = sint32(floor(x / m_cellSize));
|
sint32 posX = sint32(floor(x / m_cellSize));
|
||||||
sint32 posY = sint32(-floor(y / m_cellSize));
|
sint32 posY = sint32(-floor(y / m_cellSize));
|
||||||
|
|
||||||
if ((m_posX != posX || m_posY != posY) &&
|
if ((m_posX != posX || m_posY != posY) &&
|
||||||
(m_mouseButton == Qt::LeftButton ||
|
(m_mouseButton == Qt::LeftButton ||
|
||||||
m_mouseButton == Qt::RightButton))
|
m_mouseButton == Qt::RightButton))
|
||||||
{
|
{
|
||||||
if (m_transitionMode)
|
if (m_transitionMode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_mouseButton == Qt::LeftButton)
|
if (m_mouseButton == Qt::LeftButton)
|
||||||
m_zoneBuilder->addZone(posX, posY);
|
m_zoneBuilder->addZone(posX, posY);
|
||||||
else if (m_mouseButton == Qt::RightButton)
|
else if (m_mouseButton == Qt::RightButton)
|
||||||
m_zoneBuilder->delZone(posX, posY);
|
m_zoneBuilder->delZone(posX, posY);
|
||||||
}
|
}
|
||||||
m_posX = posX;
|
m_posX = posX;
|
||||||
m_posY = posY;
|
m_posY = posY;
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_posX = posX;
|
m_posX = posX;
|
||||||
m_posY = posY;
|
m_posY = posY;
|
||||||
|
|
||||||
m_mouseX = mouseEvent->scenePos().x();
|
m_mouseX = mouseEvent->scenePos().x();
|
||||||
m_mouseY = mouseEvent->scenePos().y() - m_cellSize;
|
m_mouseY = mouseEvent->scenePos().y() - m_cellSize;
|
||||||
QGraphicsScene::mouseMoveEvent(mouseEvent);
|
QGraphicsScene::mouseMoveEvent(mouseEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
void LandscapeScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
{
|
{
|
||||||
m_mouseButton = Qt::NoButton;
|
m_mouseButton = Qt::NoButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LandscapeScene::checkUnderZone(const int posX, const int posY)
|
bool LandscapeScene::checkUnderZone(const int posX, const int posY)
|
||||||
{
|
{
|
||||||
QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize);
|
QGraphicsItem *item = itemAt((posX * m_cellSize), abs(posY) * m_cellSize);
|
||||||
if (item != 0)
|
if (item != 0)
|
||||||
{
|
{
|
||||||
//if (item->data(ZONE_NAME) == QString(LAYER_BLACKOUT_NAME))
|
//if (item->data(ZONE_NAME) == QString(LAYER_BLACKOUT_NAME))
|
||||||
// return false;
|
// return false;
|
||||||
//else
|
//else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LandscapeScene::transitionMode() const
|
bool LandscapeScene::transitionMode() const
|
||||||
{
|
{
|
||||||
return m_transitionMode;
|
return m_transitionMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::setTransitionMode(bool enabled)
|
void LandscapeScene::setTransitionMode(bool enabled)
|
||||||
{
|
{
|
||||||
m_transitionMode = enabled;
|
m_transitionMode = enabled;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::drawForeground(QPainter *painter, const QRectF &rect)
|
void LandscapeScene::drawForeground(QPainter *painter, const QRectF &rect)
|
||||||
{
|
{
|
||||||
QGraphicsScene::drawForeground(painter, rect);
|
QGraphicsScene::drawForeground(painter, rect);
|
||||||
if ((m_zoneBuilder->currentIdZoneRegion() != -1) && (m_transitionMode))
|
if ((m_zoneBuilder->currentIdZoneRegion() != -1) && (m_transitionMode))
|
||||||
drawTransition(painter, rect);
|
drawTransition(painter, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeScene::drawTransition(QPainter *painter, const QRectF &rect)
|
void LandscapeScene::drawTransition(QPainter *painter, const QRectF &rect)
|
||||||
{
|
{
|
||||||
int left = int(floor(rect.left() / m_cellSize));
|
int left = int(floor(rect.left() / m_cellSize));
|
||||||
int right = int(floor(rect.right() / m_cellSize));
|
int right = int(floor(rect.right() / m_cellSize));
|
||||||
int top = int(floor(rect.top() / m_cellSize));
|
int top = int(floor(rect.top() / m_cellSize));
|
||||||
int bottom = int(floor(rect.bottom() / m_cellSize));
|
int bottom = int(floor(rect.bottom() / m_cellSize));
|
||||||
|
|
||||||
QVector<QLine> redLines;
|
QVector<QLine> redLines;
|
||||||
QVector<QLine> whiteLines;
|
QVector<QLine> whiteLines;
|
||||||
|
|
||||||
for (int i = left; i < right + 1; ++i)
|
for (int i = left; i < right + 1; ++i)
|
||||||
{
|
{
|
||||||
for (int j = top; j < bottom + 1; ++j)
|
for (int j = top; j < bottom + 1; ++j)
|
||||||
{
|
{
|
||||||
// Get LIGO data
|
// Get LIGO data
|
||||||
NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->currentZoneRegion()->ligoZoneRegion();
|
NLLIGO::CZoneRegion &zoneRegion = m_zoneBuilder->currentZoneRegion()->ligoZoneRegion();
|
||||||
uint8 ceUp = zoneRegion.getCutEdge (i, -j, 0);
|
uint8 ceUp = zoneRegion.getCutEdge (i, -j, 0);
|
||||||
uint8 ceLeft = zoneRegion.getCutEdge (i, -j, 2);
|
uint8 ceLeft = zoneRegion.getCutEdge (i, -j, 2);
|
||||||
if ((ceUp > 0) && (ceUp < 3))
|
if ((ceUp > 0) && (ceUp < 3))
|
||||||
{
|
{
|
||||||
// Calculate position vertical lines
|
// Calculate position vertical lines
|
||||||
int x1, x2, y1, y2;
|
int x1, x2, y1, y2;
|
||||||
|
|
||||||
y1 = j * m_cellSize + m_cellSize / 12.0f;
|
y1 = j * m_cellSize + m_cellSize / 12.0f;
|
||||||
y2 = y1 - (m_cellSize / 6.0f);
|
y2 = y1 - (m_cellSize / 6.0f);
|
||||||
|
|
||||||
x1 = i * m_cellSize + 3.0f * m_cellSize / 12.0f;
|
x1 = i * m_cellSize + 3.0f * m_cellSize / 12.0f;
|
||||||
x2 = i * m_cellSize + 5.0f * m_cellSize / 12.0f;
|
x2 = i * m_cellSize + 5.0f * m_cellSize / 12.0f;
|
||||||
if (ceUp == 1)
|
if (ceUp == 1)
|
||||||
{
|
{
|
||||||
whiteLines.push_back(QLine(x1, y1, x1, y2));
|
whiteLines.push_back(QLine(x1, y1, x1, y2));
|
||||||
whiteLines.push_back(QLine(x2, y1, x2, y2));
|
whiteLines.push_back(QLine(x2, y1, x2, y2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
redLines.push_back(QLine(x1, y1, x1, y2));
|
redLines.push_back(QLine(x1, y1, x1, y2));
|
||||||
redLines.push_back(QLine(x2, y1, x2, y2));
|
redLines.push_back(QLine(x2, y1, x2, y2));
|
||||||
}
|
}
|
||||||
|
|
||||||
x1 = i * m_cellSize + 7.0f * m_cellSize / 12.0f;
|
x1 = i * m_cellSize + 7.0f * m_cellSize / 12.0f;
|
||||||
x2 = i * m_cellSize + 9.0f * m_cellSize / 12.0f;
|
x2 = i * m_cellSize + 9.0f * m_cellSize / 12.0f;
|
||||||
if (ceUp == 1)
|
if (ceUp == 1)
|
||||||
{
|
{
|
||||||
redLines.push_back(QLine(x1, y1, x1, y2));
|
redLines.push_back(QLine(x1, y1, x1, y2));
|
||||||
redLines.push_back(QLine(x2, y1, x2, y2));
|
redLines.push_back(QLine(x2, y1, x2, y2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
whiteLines.push_back(QLine(x1, y1, x1, y2));
|
whiteLines.push_back(QLine(x1, y1, x1, y2));
|
||||||
whiteLines.push_back(QLine(x2, y1, x2, y2));
|
whiteLines.push_back(QLine(x2, y1, x2, y2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((ceLeft > 0) && (ceLeft < 3))
|
if ((ceLeft > 0) && (ceLeft < 3))
|
||||||
{
|
{
|
||||||
// Calculate position horizontal lines
|
// Calculate position horizontal lines
|
||||||
int x1, x2, y1, y2;
|
int x1, x2, y1, y2;
|
||||||
|
|
||||||
x1 = i * m_cellSize - m_cellSize / 12.0f;
|
x1 = i * m_cellSize - m_cellSize / 12.0f;
|
||||||
x2 = x1 + (m_cellSize / 6.0f);
|
x2 = x1 + (m_cellSize / 6.0f);
|
||||||
|
|
||||||
y1 = j * m_cellSize + 3.0f * m_cellSize / 12.0f;
|
y1 = j * m_cellSize + 3.0f * m_cellSize / 12.0f;
|
||||||
y2 = j * m_cellSize + 5.0f * m_cellSize / 12.0f;
|
y2 = j * m_cellSize + 5.0f * m_cellSize / 12.0f;
|
||||||
if (ceLeft == 1)
|
if (ceLeft == 1)
|
||||||
{
|
{
|
||||||
redLines.push_back(QLine(x1, y1, x2, y1));
|
redLines.push_back(QLine(x1, y1, x2, y1));
|
||||||
redLines.push_back(QLine(x1, y2, x2, y2));
|
redLines.push_back(QLine(x1, y2, x2, y2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
whiteLines.push_back(QLine(x1, y1, x2, y1));
|
whiteLines.push_back(QLine(x1, y1, x2, y1));
|
||||||
whiteLines.push_back(QLine(x1, y2, x2, y2));
|
whiteLines.push_back(QLine(x1, y2, x2, y2));
|
||||||
}
|
}
|
||||||
|
|
||||||
y1 = j * m_cellSize + 7.0f * m_cellSize / 12.0f;
|
y1 = j * m_cellSize + 7.0f * m_cellSize / 12.0f;
|
||||||
y2 = j * m_cellSize + 9.0f * m_cellSize / 12.0f;
|
y2 = j * m_cellSize + 9.0f * m_cellSize / 12.0f;
|
||||||
if (ceLeft == 1)
|
if (ceLeft == 1)
|
||||||
{
|
{
|
||||||
whiteLines.push_back(QLine(x1, y1, x2, y1));
|
whiteLines.push_back(QLine(x1, y1, x2, y1));
|
||||||
whiteLines.push_back(QLine(x1, y2, x2, y2));
|
whiteLines.push_back(QLine(x1, y2, x2, y2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
redLines.push_back(QLine(x1, y1, x2, y1));
|
redLines.push_back(QLine(x1, y1, x2, y1));
|
||||||
redLines.push_back(QLine(x1, y2, x2, y2));
|
redLines.push_back(QLine(x1, y2, x2, y2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw lines
|
// Draw lines
|
||||||
painter->setPen(QPen(Qt::red, 0, Qt::SolidLine));
|
painter->setPen(QPen(Qt::red, 0, Qt::SolidLine));
|
||||||
painter->drawLines(redLines);
|
painter->drawLines(redLines);
|
||||||
painter->setPen(QPen(Qt::white, 0, Qt::SolidLine));
|
painter->setPen(QPen(Qt::white, 0, Qt::SolidLine));
|
||||||
painter->drawLines(whiteLines);
|
painter->drawLines(whiteLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,331 +1,331 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "landscape_scene_base.h"
|
#include "landscape_scene_base.h"
|
||||||
#include "pixmap_database.h"
|
#include "pixmap_database.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
#include <QtGui/QGraphicsPixmapItem>
|
#include <QtGui/QGraphicsPixmapItem>
|
||||||
#include <QtGui/QGraphicsSimpleTextItem>
|
#include <QtGui/QGraphicsSimpleTextItem>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
static const int ZONE_NAME = 0;
|
static const int ZONE_NAME = 0;
|
||||||
static const int LAYER_ZONES = 2;
|
static const int LAYER_ZONES = 2;
|
||||||
static const int LAYER_EMPTY_ZONES = 3;
|
static const int LAYER_EMPTY_ZONES = 3;
|
||||||
|
|
||||||
// TODO: delete
|
// TODO: delete
|
||||||
const char *const LAYER_BLACKOUT_NAME = "blackout";
|
const char *const LAYER_BLACKOUT_NAME = "blackout";
|
||||||
|
|
||||||
const int MAX_SCENE_WIDTH = 256;
|
const int MAX_SCENE_WIDTH = 256;
|
||||||
const int MAX_SCENE_HEIGHT = 256;
|
const int MAX_SCENE_HEIGHT = 256;
|
||||||
|
|
||||||
LandscapeSceneBase::LandscapeSceneBase(int sizeCell, QObject *parent)
|
LandscapeSceneBase::LandscapeSceneBase(int sizeCell, QObject *parent)
|
||||||
: QGraphicsScene(parent),
|
: QGraphicsScene(parent),
|
||||||
m_cellSize(sizeCell),
|
m_cellSize(sizeCell),
|
||||||
m_zoneBuilderBase(0)
|
m_zoneBuilderBase(0)
|
||||||
{
|
{
|
||||||
setSceneRect(QRectF(0, m_cellSize, MAX_SCENE_WIDTH * m_cellSize, MAX_SCENE_HEIGHT * m_cellSize));
|
setSceneRect(QRectF(0, m_cellSize, MAX_SCENE_WIDTH * m_cellSize, MAX_SCENE_HEIGHT * m_cellSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
LandscapeSceneBase::~LandscapeSceneBase()
|
LandscapeSceneBase::~LandscapeSceneBase()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int LandscapeSceneBase::cellSize() const
|
int LandscapeSceneBase::cellSize() const
|
||||||
{
|
{
|
||||||
return m_cellSize;
|
return m_cellSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeSceneBase::setZoneBuilder(ZoneBuilderBase *zoneBuilder)
|
void LandscapeSceneBase::setZoneBuilder(ZoneBuilderBase *zoneBuilder)
|
||||||
{
|
{
|
||||||
m_zoneBuilderBase = zoneBuilder;
|
m_zoneBuilderBase = zoneBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const ZonePosition &zonePos)
|
QGraphicsItem *LandscapeSceneBase::createItemZone(const LigoData &data, const ZonePosition &zonePos)
|
||||||
{
|
{
|
||||||
if ((data.zoneName == STRING_OUT_OF_BOUND) || (checkUnderZone(zonePos.x, zonePos.y)))
|
if ((data.zoneName == STRING_OUT_OF_BOUND) || (checkUnderZone(zonePos.x, zonePos.y)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (data.zoneName == STRING_UNUSED)
|
if (data.zoneName == STRING_UNUSED)
|
||||||
return createItemEmptyZone(zonePos);
|
return createItemEmptyZone(zonePos);
|
||||||
|
|
||||||
if ((m_zoneBuilderBase == 0) || (data.zoneName.empty()))
|
if ((m_zoneBuilderBase == 0) || (data.zoneName.empty()))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Get image from pixmap database
|
// Get image from pixmap database
|
||||||
QPixmap *pixmap = m_zoneBuilderBase->pixmapDatabase()->pixmap(QString(data.zoneName.c_str()));
|
QPixmap *pixmap = m_zoneBuilderBase->pixmapDatabase()->pixmap(QString(data.zoneName.c_str()));
|
||||||
if (pixmap == 0)
|
if (pixmap == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Rotate the image counter clockwise
|
// Rotate the image counter clockwise
|
||||||
QMatrix matrix;
|
QMatrix matrix;
|
||||||
matrix.rotate(-data.rot * 90.0);
|
matrix.rotate(-data.rot * 90.0);
|
||||||
|
|
||||||
QGraphicsPixmapItem *item;
|
QGraphicsPixmapItem *item;
|
||||||
|
|
||||||
if (data.flip == 0)
|
if (data.flip == 0)
|
||||||
{
|
{
|
||||||
item = addPixmap(pixmap->transformed(matrix, Qt::SmoothTransformation));
|
item = addPixmap(pixmap->transformed(matrix, Qt::SmoothTransformation));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// mirror image
|
// mirror image
|
||||||
QImage mirrorImage = pixmap->toImage();
|
QImage mirrorImage = pixmap->toImage();
|
||||||
QPixmap mirrorPixmap = QPixmap::fromImage(mirrorImage.mirrored(true, false));
|
QPixmap mirrorPixmap = QPixmap::fromImage(mirrorImage.mirrored(true, false));
|
||||||
item = addPixmap(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation));
|
item = addPixmap(mirrorPixmap.transformed(matrix, Qt::SmoothTransformation));
|
||||||
}
|
}
|
||||||
// Enable bilinear filtering
|
// Enable bilinear filtering
|
||||||
item->setTransformationMode(Qt::SmoothTransformation);
|
item->setTransformationMode(Qt::SmoothTransformation);
|
||||||
|
|
||||||
sint32 sizeX = 1, sizeY = 1;
|
sint32 sizeX = 1, sizeY = 1;
|
||||||
sizeX = float(pixmap->width()) / m_zoneBuilderBase->pixmapDatabase()->textureSize();
|
sizeX = float(pixmap->width()) / m_zoneBuilderBase->pixmapDatabase()->textureSize();
|
||||||
sizeY = float(pixmap->width()) / m_zoneBuilderBase->pixmapDatabase()->textureSize();
|
sizeY = float(pixmap->width()) / m_zoneBuilderBase->pixmapDatabase()->textureSize();
|
||||||
|
|
||||||
sint32 deltaX = 0, deltaY = 0;
|
sint32 deltaX = 0, deltaY = 0;
|
||||||
|
|
||||||
// Calculate offset for graphics item (for items with size that are larger than 1)
|
// Calculate offset for graphics item (for items with size that are larger than 1)
|
||||||
if ((sizeX > 1) || (sizeY > 1))
|
if ((sizeX > 1) || (sizeY > 1))
|
||||||
{
|
{
|
||||||
if (data.flip == 0)
|
if (data.flip == 0)
|
||||||
{
|
{
|
||||||
switch (data.rot)
|
switch (data.rot)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
deltaX = -data.posX;
|
deltaX = -data.posX;
|
||||||
deltaY = -data.posY + sizeY - 1;
|
deltaY = -data.posY + sizeY - 1;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
deltaX = -(sizeY - 1 - data.posY);
|
deltaX = -(sizeY - 1 - data.posY);
|
||||||
deltaY = -data.posX + sizeX - 1;
|
deltaY = -data.posX + sizeX - 1;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
deltaX = -(sizeX - 1 - data.posX);
|
deltaX = -(sizeX - 1 - data.posX);
|
||||||
deltaY = data.posY;
|
deltaY = data.posY;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
deltaX = -data.posY;
|
deltaX = -data.posY;
|
||||||
deltaY = data.posX;
|
deltaY = data.posX;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (data.rot)
|
switch (data.rot)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
deltaX = -(sizeX - 1 - data.posX);
|
deltaX = -(sizeX - 1 - data.posX);
|
||||||
deltaY = -data.posY + sizeY - 1;
|
deltaY = -data.posY + sizeY - 1;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
deltaX = -(sizeY - 1 - data.posY);
|
deltaX = -(sizeY - 1 - data.posY);
|
||||||
deltaY = +data.posX;
|
deltaY = +data.posX;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
deltaX = -data.posX;
|
deltaX = -data.posX;
|
||||||
deltaY = data.posY;
|
deltaY = data.posY;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
deltaX = -data.posY;
|
deltaX = -data.posY;
|
||||||
deltaY = -data.posX + sizeX - 1;
|
deltaY = -data.posX + sizeX - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set position graphics item with offset for large piece
|
// Set position graphics item with offset for large piece
|
||||||
item->setPos((zonePos.x + deltaX) * m_cellSize, (abs(int(zonePos.y + deltaY))) * m_cellSize);
|
item->setPos((zonePos.x + deltaX) * m_cellSize, (abs(int(zonePos.y + deltaY))) * m_cellSize);
|
||||||
|
|
||||||
// The size graphics item should be equal or proportional m_cellSize
|
// The size graphics item should be equal or proportional m_cellSize
|
||||||
item->setScale(float(m_cellSize) / m_zoneBuilderBase->pixmapDatabase()->textureSize());
|
item->setScale(float(m_cellSize) / m_zoneBuilderBase->pixmapDatabase()->textureSize());
|
||||||
|
|
||||||
item->setData(ZONE_NAME, QString(data.zoneName.c_str()));
|
item->setData(ZONE_NAME, QString(data.zoneName.c_str()));
|
||||||
|
|
||||||
// for not full item zone
|
// for not full item zone
|
||||||
item->setZValue(LAYER_ZONES);
|
item->setZValue(LAYER_ZONES);
|
||||||
|
|
||||||
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsItem *LandscapeSceneBase::createItemEmptyZone(const ZonePosition &zonePos)
|
QGraphicsItem *LandscapeSceneBase::createItemEmptyZone(const ZonePosition &zonePos)
|
||||||
{
|
{
|
||||||
if (m_zoneBuilderBase == 0)
|
if (m_zoneBuilderBase == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (checkUnderZone(zonePos.x, zonePos.y))
|
if (checkUnderZone(zonePos.x, zonePos.y))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Get image from pixmap database
|
// Get image from pixmap database
|
||||||
QPixmap *pixmap = m_zoneBuilderBase->pixmapDatabase()->pixmap(QString(STRING_UNUSED));
|
QPixmap *pixmap = m_zoneBuilderBase->pixmapDatabase()->pixmap(QString(STRING_UNUSED));
|
||||||
if (pixmap == 0)
|
if (pixmap == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
QGraphicsPixmapItem *item = addPixmap(*pixmap);
|
QGraphicsPixmapItem *item = addPixmap(*pixmap);
|
||||||
|
|
||||||
// Enable bilinear filtering
|
// Enable bilinear filtering
|
||||||
item->setTransformationMode(Qt::SmoothTransformation);
|
item->setTransformationMode(Qt::SmoothTransformation);
|
||||||
|
|
||||||
// Set position graphics item
|
// Set position graphics item
|
||||||
item->setPos(zonePos.x * m_cellSize, abs(int(zonePos.y)) * m_cellSize);
|
item->setPos(zonePos.x * m_cellSize, abs(int(zonePos.y)) * m_cellSize);
|
||||||
|
|
||||||
// The size graphics item should be equal or proportional m_cellSize
|
// The size graphics item should be equal or proportional m_cellSize
|
||||||
item->setScale(float(m_cellSize) / m_zoneBuilderBase->pixmapDatabase()->textureSize());
|
item->setScale(float(m_cellSize) / m_zoneBuilderBase->pixmapDatabase()->textureSize());
|
||||||
|
|
||||||
// for not full item zone
|
// for not full item zone
|
||||||
item->setZValue(LAYER_EMPTY_ZONES);
|
item->setZValue(LAYER_EMPTY_ZONES);
|
||||||
|
|
||||||
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
item->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeSceneBase::deleteItemZone(const ZonePosition &zonePos)
|
void LandscapeSceneBase::deleteItemZone(const ZonePosition &zonePos)
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> listItems = items(QPointF(zonePos.x * m_cellSize + 10, abs(zonePos.y) * m_cellSize + 10),
|
QList<QGraphicsItem *> listItems = items(QPointF(zonePos.x * m_cellSize + 10, abs(zonePos.y) * m_cellSize + 10),
|
||||||
Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
|
Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
|
||||||
Q_FOREACH(QGraphicsItem *item, listItems)
|
Q_FOREACH(QGraphicsItem *item, listItems)
|
||||||
{
|
{
|
||||||
if (qgraphicsitem_cast<QGraphicsPixmapItem *>(item) != 0)
|
if (qgraphicsitem_cast<QGraphicsPixmapItem *>(item) != 0)
|
||||||
{
|
{
|
||||||
removeItem(item);
|
removeItem(item);
|
||||||
delete item;
|
delete item;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeSceneBase::addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
void LandscapeSceneBase::addZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||||
{
|
{
|
||||||
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
||||||
{
|
{
|
||||||
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string zoneName = zoneRegion.getName(i, j);
|
std::string zoneName = zoneRegion.getName(i, j);
|
||||||
if (zoneName == STRING_UNUSED)
|
if (zoneName == STRING_UNUSED)
|
||||||
{
|
{
|
||||||
ZonePosition zonePos(i, j, -1);
|
ZonePosition zonePos(i, j, -1);
|
||||||
QGraphicsItem *item = createItemEmptyZone(zonePos);
|
QGraphicsItem *item = createItemEmptyZone(zonePos);
|
||||||
}
|
}
|
||||||
else if (!zoneName.empty())
|
else if (!zoneName.empty())
|
||||||
{
|
{
|
||||||
LigoData data;
|
LigoData data;
|
||||||
ZonePosition zonePos(i, j, -1);
|
ZonePosition zonePos(i, j, -1);
|
||||||
data.zoneName = zoneName;
|
data.zoneName = zoneName;
|
||||||
data.rot = zoneRegion.getRot(i, j);
|
data.rot = zoneRegion.getRot(i, j);
|
||||||
data.flip = zoneRegion.getFlip(i, j);
|
data.flip = zoneRegion.getFlip(i, j);
|
||||||
data.posX = zoneRegion.getPosX(i, j);
|
data.posX = zoneRegion.getPosX(i, j);
|
||||||
data.posY = zoneRegion.getPosY(i, j);
|
data.posY = zoneRegion.getPosY(i, j);
|
||||||
QGraphicsItem *item = createItemZone(data, zonePos);
|
QGraphicsItem *item = createItemZone(data, zonePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeSceneBase::delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
void LandscapeSceneBase::delZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||||
{
|
{
|
||||||
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i)
|
||||||
{
|
{
|
||||||
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j)
|
||||||
{
|
{
|
||||||
|
|
||||||
deleteItemZone(ZonePosition(i, -j, -1));
|
deleteItemZone(ZonePosition(i, -j, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeSceneBase::snapshot(const QString &fileName, int width, int height, const QRectF &landRect)
|
void LandscapeSceneBase::snapshot(const QString &fileName, int width, int height, const QRectF &landRect)
|
||||||
{
|
{
|
||||||
if (m_zoneBuilderBase == 0)
|
if (m_zoneBuilderBase == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Create image
|
// Create image
|
||||||
QImage image(landRect.width(), landRect.height(), QImage::Format_RGB888);
|
QImage image(landRect.width(), landRect.height(), QImage::Format_RGB888);
|
||||||
QPainter painter(&image);
|
QPainter painter(&image);
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
||||||
// Add white background
|
// Add white background
|
||||||
painter.setBrush(QBrush(Qt::white));
|
painter.setBrush(QBrush(Qt::white));
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
painter.drawRect(0, 0, landRect.width(), landRect.height());
|
painter.drawRect(0, 0, landRect.width(), landRect.height());
|
||||||
|
|
||||||
// Paint landscape
|
// Paint landscape
|
||||||
render(&painter, QRectF(0, 0, landRect.width(), landRect.height()), landRect);
|
render(&painter, QRectF(0, 0, landRect.width(), landRect.height()), landRect);
|
||||||
|
|
||||||
QImage scaledImage = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
QImage scaledImage = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
scaledImage.save(fileName);
|
scaledImage.save(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LandscapeSceneBase::zoneNameFromMousePos() const
|
QString LandscapeSceneBase::zoneNameFromMousePos() const
|
||||||
{
|
{
|
||||||
if ((m_posY > 0) || (m_posY < -MAX_SCENE_HEIGHT) ||
|
if ((m_posY > 0) || (m_posY < -MAX_SCENE_HEIGHT) ||
|
||||||
(m_posX < 0) || (m_posX > MAX_SCENE_WIDTH))
|
(m_posX < 0) || (m_posX > MAX_SCENE_WIDTH))
|
||||||
return "NOT A VALID ZONE";
|
return "NOT A VALID ZONE";
|
||||||
|
|
||||||
return QString("%1_%2%3 %4 %5 ").arg(-m_posY+1).arg(QChar('A' + (m_posX/26))).
|
return QString("%1_%2%3 %4 %5 ").arg(-m_posY+1).arg(QChar('A' + (m_posX/26))).
|
||||||
arg(QChar('A' + (m_posX%26))).arg(m_mouseX, 0,'f',2).arg(-m_mouseY, 0,'f',2);
|
arg(QChar('A' + (m_posX%26))).arg(m_mouseX, 0,'f',2).arg(-m_mouseY, 0,'f',2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeSceneBase::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
void LandscapeSceneBase::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
{
|
{
|
||||||
QGraphicsScene::mousePressEvent(mouseEvent);
|
QGraphicsScene::mousePressEvent(mouseEvent);
|
||||||
|
|
||||||
qreal x = mouseEvent->scenePos().x();
|
qreal x = mouseEvent->scenePos().x();
|
||||||
qreal y = mouseEvent->scenePos().y();
|
qreal y = mouseEvent->scenePos().y();
|
||||||
m_posX = sint32(floor(x / m_cellSize));
|
m_posX = sint32(floor(x / m_cellSize));
|
||||||
m_posY = sint32(-floor(y / m_cellSize));
|
m_posY = sint32(-floor(y / m_cellSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
{
|
{
|
||||||
m_mouseX = mouseEvent->scenePos().x();
|
m_mouseX = mouseEvent->scenePos().x();
|
||||||
m_mouseY = mouseEvent->scenePos().y() - m_cellSize;
|
m_mouseY = mouseEvent->scenePos().y() - m_cellSize;
|
||||||
|
|
||||||
m_posX = sint32(floor(m_mouseX / m_cellSize));
|
m_posX = sint32(floor(m_mouseX / m_cellSize));
|
||||||
m_posY = sint32(-floor(m_mouseY / m_cellSize));
|
m_posY = sint32(-floor(m_mouseY / m_cellSize));
|
||||||
|
|
||||||
QGraphicsScene::mouseMoveEvent(mouseEvent);
|
QGraphicsScene::mouseMoveEvent(mouseEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LandscapeSceneBase::checkUnderZone(const int posX, const int posY)
|
bool LandscapeSceneBase::checkUnderZone(const int posX, const int posY)
|
||||||
{
|
{
|
||||||
// TODO: Why crash program?
|
// TODO: Why crash program?
|
||||||
// QList<QGraphicsItem *> listItems = items(QPointF(posX * m_cellSize + 10, abs(posY) * m_cellSize + 10),
|
// QList<QGraphicsItem *> listItems = items(QPointF(posX * m_cellSize + 10, abs(posY) * m_cellSize + 10),
|
||||||
// Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
|
// Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
|
||||||
|
|
||||||
QList<QGraphicsItem *> listItems = items();
|
QList<QGraphicsItem *> listItems = items();
|
||||||
|
|
||||||
QPointF point(posX, abs(posY));
|
QPointF point(posX, abs(posY));
|
||||||
Q_FOREACH(QGraphicsItem *item, listItems)
|
Q_FOREACH(QGraphicsItem *item, listItems)
|
||||||
{
|
{
|
||||||
if (item->pos() == point)
|
if (item->pos() == point)
|
||||||
{
|
{
|
||||||
if (qgraphicsitem_cast<QGraphicsPixmapItem *>(item) != 0)
|
if (qgraphicsitem_cast<QGraphicsPixmapItem *>(item) != 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,254 +1,254 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "landscape_view.h"
|
#include "landscape_view.h"
|
||||||
#include "landscape_editor_constants.h"
|
#include "landscape_editor_constants.h"
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
LandscapeView::LandscapeView(QWidget *parent)
|
LandscapeView::LandscapeView(QWidget *parent)
|
||||||
: QGraphicsView(parent),
|
: QGraphicsView(parent),
|
||||||
m_visibleGrid(true),
|
m_visibleGrid(true),
|
||||||
m_visibleText(true)
|
m_visibleText(true)
|
||||||
{
|
{
|
||||||
setTransformationAnchor(AnchorUnderMouse);
|
setTransformationAnchor(AnchorUnderMouse);
|
||||||
setBackgroundBrush(QBrush(Qt::lightGray));
|
setBackgroundBrush(QBrush(Qt::lightGray));
|
||||||
|
|
||||||
m_cellSize = 160;
|
m_cellSize = 160;
|
||||||
m_maxView = 0.06;
|
m_maxView = 0.06;
|
||||||
m_minView = 32.0;
|
m_minView = 32.0;
|
||||||
m_maxViewText = 0.6;
|
m_maxViewText = 0.6;
|
||||||
|
|
||||||
//A modified version of centerOn(), handles special cases
|
//A modified version of centerOn(), handles special cases
|
||||||
setCenter(QPointF(500.0, 500.0));
|
setCenter(QPointF(500.0, 500.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
LandscapeView::~LandscapeView()
|
LandscapeView::~LandscapeView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LandscapeView::isVisibleGrid() const
|
bool LandscapeView::isVisibleGrid() const
|
||||||
{
|
{
|
||||||
return m_visibleGrid;
|
return m_visibleGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::setVisibleGrid(bool visible)
|
void LandscapeView::setVisibleGrid(bool visible)
|
||||||
{
|
{
|
||||||
m_visibleGrid = visible;
|
m_visibleGrid = visible;
|
||||||
scene()->update();
|
scene()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::setVisibleText(bool visible)
|
void LandscapeView::setVisibleText(bool visible)
|
||||||
{
|
{
|
||||||
m_visibleText = visible;
|
m_visibleText = visible;
|
||||||
scene()->update();
|
scene()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::wheelEvent(QWheelEvent *event)
|
void LandscapeView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
//How fast we zoom
|
//How fast we zoom
|
||||||
float numSteps = (( event->delta() / 8 ) / 15) * 1.2;
|
float numSteps = (( event->delta() / 8 ) / 15) * 1.2;
|
||||||
|
|
||||||
QMatrix mat = matrix();
|
QMatrix mat = matrix();
|
||||||
QPointF mousePosition = event->pos();
|
QPointF mousePosition = event->pos();
|
||||||
|
|
||||||
mat.translate((width() / 2) - mousePosition.x(), (height() / 2) - mousePosition.y());
|
mat.translate((width() / 2) - mousePosition.x(), (height() / 2) - mousePosition.y());
|
||||||
|
|
||||||
if ( numSteps > 0 )
|
if ( numSteps > 0 )
|
||||||
mat.scale(numSteps, numSteps);
|
mat.scale(numSteps, numSteps);
|
||||||
else
|
else
|
||||||
mat.scale(-1 / numSteps, -1 / numSteps);
|
mat.scale(-1 / numSteps, -1 / numSteps);
|
||||||
|
|
||||||
mat.translate(mousePosition.x() - (width() / 2), mousePosition.y() - (height() / 2));
|
mat.translate(mousePosition.x() - (width() / 2), mousePosition.y() - (height() / 2));
|
||||||
|
|
||||||
//Adjust to the new center for correct zooming
|
//Adjust to the new center for correct zooming
|
||||||
setMatrix(mat);
|
setMatrix(mat);
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::mousePressEvent(QMouseEvent *event)
|
void LandscapeView::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QGraphicsView::mousePressEvent(event);
|
QGraphicsView::mousePressEvent(event);
|
||||||
if (event->button() != Qt::MiddleButton)
|
if (event->button() != Qt::MiddleButton)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//For panning the view
|
//For panning the view
|
||||||
m_lastPanPoint = event->pos();
|
m_lastPanPoint = event->pos();
|
||||||
setCursor(Qt::ClosedHandCursor);
|
setCursor(Qt::ClosedHandCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::mouseMoveEvent(QMouseEvent *event)
|
void LandscapeView::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(!m_lastPanPoint.isNull())
|
if(!m_lastPanPoint.isNull())
|
||||||
{
|
{
|
||||||
//Get how much we panned
|
//Get how much we panned
|
||||||
QPointF delta = mapToScene(m_lastPanPoint) - mapToScene(event->pos());
|
QPointF delta = mapToScene(m_lastPanPoint) - mapToScene(event->pos());
|
||||||
m_lastPanPoint = event->pos();
|
m_lastPanPoint = event->pos();
|
||||||
|
|
||||||
//Update the center ie. do the pan
|
//Update the center ie. do the pan
|
||||||
setCenter(getCenter() + delta);
|
setCenter(getCenter() + delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsView::mouseMoveEvent(event);
|
QGraphicsView::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::mouseReleaseEvent(QMouseEvent *event)
|
void LandscapeView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
m_lastPanPoint = QPoint();
|
m_lastPanPoint = QPoint();
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
QGraphicsView::mouseReleaseEvent(event);
|
QGraphicsView::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::resizeEvent(QResizeEvent *event)
|
void LandscapeView::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
//Get the rectangle of the visible area in scene coords
|
//Get the rectangle of the visible area in scene coords
|
||||||
QRectF visibleArea = mapToScene(rect()).boundingRect();
|
QRectF visibleArea = mapToScene(rect()).boundingRect();
|
||||||
setCenter(visibleArea.center());
|
setCenter(visibleArea.center());
|
||||||
|
|
||||||
//Call the subclass resize so the scrollbars are updated correctly
|
//Call the subclass resize so the scrollbars are updated correctly
|
||||||
QGraphicsView::resizeEvent(event);
|
QGraphicsView::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::setCenter(const QPointF ¢erPoint)
|
void LandscapeView::setCenter(const QPointF ¢erPoint)
|
||||||
{
|
{
|
||||||
//Get the rectangle of the visible area in scene coords
|
//Get the rectangle of the visible area in scene coords
|
||||||
QRectF visibleArea = mapToScene(rect()).boundingRect();
|
QRectF visibleArea = mapToScene(rect()).boundingRect();
|
||||||
|
|
||||||
//Get the scene area
|
//Get the scene area
|
||||||
QRectF sceneBounds = sceneRect();
|
QRectF sceneBounds = sceneRect();
|
||||||
|
|
||||||
double boundX = visibleArea.width() / 2.0;
|
double boundX = visibleArea.width() / 2.0;
|
||||||
double boundY = visibleArea.height() / 2.0;
|
double boundY = visibleArea.height() / 2.0;
|
||||||
double boundWidth = sceneBounds.width() - 2.0 * boundX;
|
double boundWidth = sceneBounds.width() - 2.0 * boundX;
|
||||||
double boundHeight = sceneBounds.height() - 2.0 * boundY;
|
double boundHeight = sceneBounds.height() - 2.0 * boundY;
|
||||||
|
|
||||||
//The max boundary that the centerPoint can be to
|
//The max boundary that the centerPoint can be to
|
||||||
QRectF bounds(boundX, boundY, boundWidth, boundHeight);
|
QRectF bounds(boundX, boundY, boundWidth, boundHeight);
|
||||||
|
|
||||||
if(bounds.contains(centerPoint))
|
if(bounds.contains(centerPoint))
|
||||||
{
|
{
|
||||||
//We are within the bounds
|
//We are within the bounds
|
||||||
m_currentCenterPoint = centerPoint;
|
m_currentCenterPoint = centerPoint;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//We need to clamp or use the center of the screen
|
//We need to clamp or use the center of the screen
|
||||||
if(visibleArea.contains(sceneBounds))
|
if(visibleArea.contains(sceneBounds))
|
||||||
{
|
{
|
||||||
//Use the center of scene ie. we can see the whole scene
|
//Use the center of scene ie. we can see the whole scene
|
||||||
m_currentCenterPoint = sceneBounds.center();
|
m_currentCenterPoint = sceneBounds.center();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_currentCenterPoint = centerPoint;
|
m_currentCenterPoint = centerPoint;
|
||||||
|
|
||||||
//We need to clamp the center. The centerPoint is too large
|
//We need to clamp the center. The centerPoint is too large
|
||||||
if (centerPoint.x() > bounds.x() + bounds.width())
|
if (centerPoint.x() > bounds.x() + bounds.width())
|
||||||
m_currentCenterPoint.setX(bounds.x() + bounds.width());
|
m_currentCenterPoint.setX(bounds.x() + bounds.width());
|
||||||
else if(centerPoint.x() < bounds.x())
|
else if(centerPoint.x() < bounds.x())
|
||||||
m_currentCenterPoint.setX(bounds.x());
|
m_currentCenterPoint.setX(bounds.x());
|
||||||
|
|
||||||
if(centerPoint.y() > bounds.y() + bounds.height())
|
if(centerPoint.y() > bounds.y() + bounds.height())
|
||||||
m_currentCenterPoint.setY(bounds.y() + bounds.height());
|
m_currentCenterPoint.setY(bounds.y() + bounds.height());
|
||||||
else if(centerPoint.y() < bounds.y())
|
else if(centerPoint.y() < bounds.y())
|
||||||
m_currentCenterPoint.setY(bounds.y());
|
m_currentCenterPoint.setY(bounds.y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the scrollbars
|
//Update the scrollbars
|
||||||
centerOn(m_currentCenterPoint);
|
centerOn(m_currentCenterPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF LandscapeView::getCenter() const
|
QPointF LandscapeView::getCenter() const
|
||||||
{
|
{
|
||||||
//return m_currentCenterPoint;
|
//return m_currentCenterPoint;
|
||||||
return mapToScene(viewport()->rect().center());
|
return mapToScene(viewport()->rect().center());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect)
|
void LandscapeView::drawForeground(QPainter *painter, const QRectF &rect)
|
||||||
{
|
{
|
||||||
QGraphicsView::drawForeground(painter, rect);
|
QGraphicsView::drawForeground(painter, rect);
|
||||||
|
|
||||||
if (!m_visibleGrid)
|
if (!m_visibleGrid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
painter->setPen(QPen(Qt::white, 0, Qt::SolidLine));
|
painter->setPen(QPen(Qt::white, 0, Qt::SolidLine));
|
||||||
drawGrid(painter, rect);
|
drawGrid(painter, rect);
|
||||||
|
|
||||||
if (!m_visibleText)
|
if (!m_visibleText)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (transform().m11() > m_maxViewText)
|
if (transform().m11() > m_maxViewText)
|
||||||
{
|
{
|
||||||
painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine));
|
painter->setPen(QPen(Qt::white, 0.5, Qt::SolidLine));
|
||||||
drawZoneNames(painter, rect);
|
drawZoneNames(painter, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::drawGrid(QPainter *painter, const QRectF &rect)
|
void LandscapeView::drawGrid(QPainter *painter, const QRectF &rect)
|
||||||
{
|
{
|
||||||
qreal left = m_cellSize * floor(rect.left() / m_cellSize);
|
qreal left = m_cellSize * floor(rect.left() / m_cellSize);
|
||||||
qreal top = m_cellSize * floor(rect.top() / m_cellSize);
|
qreal top = m_cellSize * floor(rect.top() / m_cellSize);
|
||||||
|
|
||||||
QVector<QLine> lines;
|
QVector<QLine> lines;
|
||||||
|
|
||||||
// Calculate vertical lines
|
// Calculate vertical lines
|
||||||
while (left < rect.right())
|
while (left < rect.right())
|
||||||
{
|
{
|
||||||
lines.push_back(QLine(int(left), int(rect.bottom()), int(left), int(rect.top())));
|
lines.push_back(QLine(int(left), int(rect.bottom()), int(left), int(rect.top())));
|
||||||
left += m_cellSize;
|
left += m_cellSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate horizontal lines
|
// Calculate horizontal lines
|
||||||
while (top < rect.bottom())
|
while (top < rect.bottom())
|
||||||
{
|
{
|
||||||
lines.push_back(QLine(int(rect.left()), int(top), int(rect.right()), int(top)));
|
lines.push_back(QLine(int(rect.left()), int(top), int(rect.right()), int(top)));
|
||||||
top += m_cellSize;
|
top += m_cellSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw lines
|
// Draw lines
|
||||||
painter->drawLines(lines);
|
painter->drawLines(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeView::drawZoneNames(QPainter *painter, const QRectF &rect)
|
void LandscapeView::drawZoneNames(QPainter *painter, const QRectF &rect)
|
||||||
{
|
{
|
||||||
int leftSide = int(floor(rect.left() / m_cellSize));
|
int leftSide = int(floor(rect.left() / m_cellSize));
|
||||||
int rightSide = int(floor(rect.right() / m_cellSize));
|
int rightSide = int(floor(rect.right() / m_cellSize));
|
||||||
int topSide = int(floor(rect.top() / m_cellSize));
|
int topSide = int(floor(rect.top() / m_cellSize));
|
||||||
int bottomSide = int(floor(rect.bottom() / m_cellSize));
|
int bottomSide = int(floor(rect.bottom() / m_cellSize));
|
||||||
|
|
||||||
for (int i = leftSide; i < rightSide + 1; ++i)
|
for (int i = leftSide; i < rightSide + 1; ++i)
|
||||||
{
|
{
|
||||||
for (int j = topSide; j < bottomSide + 1; ++j)
|
for (int j = topSide; j < bottomSide + 1; ++j)
|
||||||
{
|
{
|
||||||
QString text = QString("%1_%2%3").arg(j).arg(QChar('A' + (i / 26))).arg(QChar('A' + (i % 26)));
|
QString text = QString("%1_%2%3").arg(j).arg(QChar('A' + (i / 26))).arg(QChar('A' + (i % 26)));
|
||||||
painter->drawText(i * m_cellSize + 5, j * m_cellSize + 15, text);
|
painter->drawText(i * m_cellSize + 5, j * m_cellSize + 15, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,137 +1,137 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "list_zones_model.h"
|
#include "list_zones_model.h"
|
||||||
#include "builder_zone.h"
|
#include "builder_zone.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// STL includes
|
// STL includes
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QtGui/QProgressDialog>
|
#include <QtGui/QProgressDialog>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
ListZonesModel::ListZonesModel(int scaleRatio, QObject *parent)
|
ListZonesModel::ListZonesModel(int scaleRatio, QObject *parent)
|
||||||
: QAbstractListModel(parent),
|
: QAbstractListModel(parent),
|
||||||
m_scaleRatio(scaleRatio)
|
m_scaleRatio(scaleRatio)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
ListZonesModel::~ListZonesModel()
|
ListZonesModel::~ListZonesModel()
|
||||||
{
|
{
|
||||||
resetModel();
|
resetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ListZonesModel::rowCount(const QModelIndex & /* parent */) const
|
int ListZonesModel::rowCount(const QModelIndex & /* parent */) const
|
||||||
{
|
{
|
||||||
return m_listNames.count();
|
return m_listNames.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ListZonesModel::columnCount(const QModelIndex & /* parent */) const
|
int ListZonesModel::columnCount(const QModelIndex & /* parent */) const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ListZonesModel::data(const QModelIndex &index, int role) const
|
QVariant ListZonesModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case Qt::TextAlignmentRole:
|
case Qt::TextAlignmentRole:
|
||||||
return int(Qt::AlignLeft | Qt::AlignVCenter);
|
return int(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return m_listNames.at(index.row());
|
return m_listNames.at(index.row());
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
{
|
{
|
||||||
QPixmap *pixmap = getPixmap(m_listNames.at(index.row()));
|
QPixmap *pixmap = getPixmap(m_listNames.at(index.row()));
|
||||||
return qVariantFromValue(*pixmap);
|
return qVariantFromValue(*pixmap);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ListZonesModel::headerData(int section, Qt::Orientation, int role) const
|
QVariant ListZonesModel::headerData(int section, Qt::Orientation, int role) const
|
||||||
{
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesModel::setScaleRatio(int scaleRatio)
|
void ListZonesModel::setScaleRatio(int scaleRatio)
|
||||||
{
|
{
|
||||||
m_scaleRatio = scaleRatio;
|
m_scaleRatio = scaleRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesModel::setListZones(QStringList &listZones)
|
void ListZonesModel::setListZones(QStringList &listZones)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_listNames.clear();
|
m_listNames.clear();
|
||||||
m_listNames = listZones;
|
m_listNames = listZones;
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesModel::resetModel()
|
void ListZonesModel::resetModel()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
QStringList listNames(m_pixmapMap.keys());
|
QStringList listNames(m_pixmapMap.keys());
|
||||||
Q_FOREACH(QString name, listNames)
|
Q_FOREACH(QString name, listNames)
|
||||||
{
|
{
|
||||||
QPixmap *pixmap = m_pixmapMap.value(name);
|
QPixmap *pixmap = m_pixmapMap.value(name);
|
||||||
delete pixmap;
|
delete pixmap;
|
||||||
}
|
}
|
||||||
m_pixmapMap.clear();
|
m_pixmapMap.clear();
|
||||||
m_listNames.clear();
|
m_listNames.clear();
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesModel::rebuildModel(PixmapDatabase *pixmapDatabase)
|
void ListZonesModel::rebuildModel(PixmapDatabase *pixmapDatabase)
|
||||||
{
|
{
|
||||||
resetModel();
|
resetModel();
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
QStringList listNames;
|
QStringList listNames;
|
||||||
listNames = pixmapDatabase->listPixmaps();
|
listNames = pixmapDatabase->listPixmaps();
|
||||||
|
|
||||||
Q_FOREACH(QString name, listNames)
|
Q_FOREACH(QString name, listNames)
|
||||||
{
|
{
|
||||||
QPixmap *pixmap = pixmapDatabase->pixmap(name);
|
QPixmap *pixmap = pixmapDatabase->pixmap(name);
|
||||||
QPixmap *smallPixmap = new QPixmap(pixmap->scaled(pixmap->width() / m_scaleRatio, pixmap->height() / m_scaleRatio));
|
QPixmap *smallPixmap = new QPixmap(pixmap->scaled(pixmap->width() / m_scaleRatio, pixmap->height() / m_scaleRatio));
|
||||||
m_pixmapMap.insert(name, smallPixmap);
|
m_pixmapMap.insert(name, smallPixmap);
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap *ListZonesModel::getPixmap(const QString &zoneName) const
|
QPixmap *ListZonesModel::getPixmap(const QString &zoneName) const
|
||||||
{
|
{
|
||||||
QPixmap *result = 0;
|
QPixmap *result = 0;
|
||||||
if (!m_pixmapMap.contains(zoneName))
|
if (!m_pixmapMap.contains(zoneName))
|
||||||
nlwarning("QPixmap %s not found", zoneName.toStdString().c_str());
|
nlwarning("QPixmap %s not found", zoneName.toStdString().c_str());
|
||||||
else
|
else
|
||||||
result = m_pixmapMap.value(zoneName);
|
result = m_pixmapMap.value(zoneName);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,308 +1,308 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "list_zones_widget.h"
|
#include "list_zones_widget.h"
|
||||||
#include "list_zones_model.h"
|
#include "list_zones_model.h"
|
||||||
#include "builder_zone.h"
|
#include "builder_zone.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
#include <nel/ligo/zone_bank.h>
|
#include <nel/ligo/zone_bank.h>
|
||||||
#include <nel/ligo/zone_region.h>
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
// STL includes
|
// STL includes
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QIcon>
|
#include <QtGui/QIcon>
|
||||||
#include <QtCore/QModelIndex>
|
#include <QtCore/QModelIndex>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
ListZonesWidget::ListZonesWidget(QWidget *parent)
|
ListZonesWidget::ListZonesWidget(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
m_rotCycle(0),
|
m_rotCycle(0),
|
||||||
m_flipCycle(0),
|
m_flipCycle(0),
|
||||||
m_listZonesModel(0),
|
m_listZonesModel(0),
|
||||||
m_zoneBuilder(0)
|
m_zoneBuilder(0)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
m_listZonesModel = new ListZonesModel(4, this);
|
m_listZonesModel = new ListZonesModel(4, this);
|
||||||
m_ui.listView->setModel(m_listZonesModel);
|
m_ui.listView->setModel(m_listZonesModel);
|
||||||
|
|
||||||
m_ui.addFilterButton_1->setChecked(false);
|
m_ui.addFilterButton_1->setChecked(false);
|
||||||
m_ui.addFilterButton_2->setChecked(false);
|
m_ui.addFilterButton_2->setChecked(false);
|
||||||
m_ui.addFilterButton_3->setChecked(false);
|
m_ui.addFilterButton_3->setChecked(false);
|
||||||
|
|
||||||
connect(m_ui.categoryTypeComboBox_1, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_1(QString)));
|
connect(m_ui.categoryTypeComboBox_1, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_1(QString)));
|
||||||
connect(m_ui.categoryTypeComboBox_2, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_2(QString)));
|
connect(m_ui.categoryTypeComboBox_2, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_2(QString)));
|
||||||
connect(m_ui.categoryTypeComboBox_3, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_3(QString)));
|
connect(m_ui.categoryTypeComboBox_3, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_3(QString)));
|
||||||
connect(m_ui.categoryTypeComboBox_4, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_4(QString)));
|
connect(m_ui.categoryTypeComboBox_4, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateFilters_4(QString)));
|
||||||
connect(m_ui.categoryValueComboBox_1, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
connect(m_ui.categoryValueComboBox_1, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
connect(m_ui.categoryValueComboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
connect(m_ui.categoryValueComboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
connect(m_ui.categoryValueComboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
connect(m_ui.categoryValueComboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
connect(m_ui.categoryValueComboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
connect(m_ui.categoryValueComboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
connect(m_ui.logicComboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
connect(m_ui.logicComboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
connect(m_ui.logicComboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
connect(m_ui.logicComboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
connect(m_ui.logicComboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
connect(m_ui.logicComboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(updateListZones()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ListZonesWidget::~ListZonesWidget()
|
ListZonesWidget::~ListZonesWidget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::updateUi()
|
void ListZonesWidget::updateUi()
|
||||||
{
|
{
|
||||||
if (m_zoneBuilder == 0)
|
if (m_zoneBuilder == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
disableSignals(true);
|
disableSignals(true);
|
||||||
std::vector<std::string> listCategoryType;
|
std::vector<std::string> listCategoryType;
|
||||||
m_zoneBuilder->getZoneBank().getCategoriesType(listCategoryType);
|
m_zoneBuilder->getZoneBank().getCategoriesType(listCategoryType);
|
||||||
|
|
||||||
QStringList listCategories;
|
QStringList listCategories;
|
||||||
|
|
||||||
listCategories << STRING_UNUSED;
|
listCategories << STRING_UNUSED;
|
||||||
for (size_t i = 0; i < listCategoryType.size(); ++i)
|
for (size_t i = 0; i < listCategoryType.size(); ++i)
|
||||||
listCategories << QString(listCategoryType[i].c_str());
|
listCategories << QString(listCategoryType[i].c_str());
|
||||||
|
|
||||||
m_ui.categoryTypeComboBox_1->clear();
|
m_ui.categoryTypeComboBox_1->clear();
|
||||||
m_ui.categoryTypeComboBox_2->clear();
|
m_ui.categoryTypeComboBox_2->clear();
|
||||||
m_ui.categoryTypeComboBox_3->clear();
|
m_ui.categoryTypeComboBox_3->clear();
|
||||||
m_ui.categoryTypeComboBox_4->clear();
|
m_ui.categoryTypeComboBox_4->clear();
|
||||||
m_ui.categoryValueComboBox_1->clear();
|
m_ui.categoryValueComboBox_1->clear();
|
||||||
m_ui.categoryValueComboBox_2->clear();
|
m_ui.categoryValueComboBox_2->clear();
|
||||||
m_ui.categoryValueComboBox_3->clear();
|
m_ui.categoryValueComboBox_3->clear();
|
||||||
m_ui.categoryValueComboBox_4->clear();
|
m_ui.categoryValueComboBox_4->clear();
|
||||||
|
|
||||||
m_ui.categoryTypeComboBox_1->addItems(listCategories);
|
m_ui.categoryTypeComboBox_1->addItems(listCategories);
|
||||||
m_ui.categoryTypeComboBox_2->addItems(listCategories);
|
m_ui.categoryTypeComboBox_2->addItems(listCategories);
|
||||||
m_ui.categoryTypeComboBox_3->addItems(listCategories);
|
m_ui.categoryTypeComboBox_3->addItems(listCategories);
|
||||||
m_ui.categoryTypeComboBox_4->addItems(listCategories);
|
m_ui.categoryTypeComboBox_4->addItems(listCategories);
|
||||||
|
|
||||||
disableSignals(false);
|
disableSignals(false);
|
||||||
|
|
||||||
m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase());
|
m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ListZonesWidget::currentZoneName()
|
QString ListZonesWidget::currentZoneName()
|
||||||
{
|
{
|
||||||
QString zoneName = "";
|
QString zoneName = "";
|
||||||
QModelIndex index = m_ui.listView->currentIndex();
|
QModelIndex index = m_ui.listView->currentIndex();
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
zoneName = index.data().toString();
|
zoneName = index.data().toString();
|
||||||
if (m_ui.zoneSelectComboBox->currentIndex() == 1)
|
if (m_ui.zoneSelectComboBox->currentIndex() == 1)
|
||||||
{
|
{
|
||||||
// Random value
|
// Random value
|
||||||
if (m_listSelection.size() > 0)
|
if (m_listSelection.size() > 0)
|
||||||
{
|
{
|
||||||
uint32 randZone = uint32(NLMISC::frand(m_listSelection.size()));
|
uint32 randZone = uint32(NLMISC::frand(m_listSelection.size()));
|
||||||
NLMISC::clamp(randZone, (uint32)0, uint32(m_listSelection.size() - 1));
|
NLMISC::clamp(randZone, (uint32)0, uint32(m_listSelection.size() - 1));
|
||||||
zoneName = m_listSelection[randZone];
|
zoneName = m_listSelection[randZone];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_ui.zoneSelectComboBox->currentIndex() == 2)
|
else if (m_ui.zoneSelectComboBox->currentIndex() == 2)
|
||||||
{
|
{
|
||||||
// Full cycle
|
// Full cycle
|
||||||
if (m_listSelection.size() > 0)
|
if (m_listSelection.size() > 0)
|
||||||
{
|
{
|
||||||
zoneName = m_listSelection[m_zoneNameCycle];
|
zoneName = m_listSelection[m_zoneNameCycle];
|
||||||
m_zoneNameCycle++;
|
m_zoneNameCycle++;
|
||||||
m_zoneNameCycle = m_zoneNameCycle % m_listSelection.size();
|
m_zoneNameCycle = m_zoneNameCycle % m_listSelection.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return zoneName;
|
return zoneName;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ListZonesWidget::currentRot()
|
int ListZonesWidget::currentRot()
|
||||||
{
|
{
|
||||||
int rot = m_ui.rotComboBox->currentIndex();
|
int rot = m_ui.rotComboBox->currentIndex();
|
||||||
if (rot == 4)
|
if (rot == 4)
|
||||||
{
|
{
|
||||||
// Random value
|
// Random value
|
||||||
uint32 randRot = uint32(NLMISC::frand(4.0));
|
uint32 randRot = uint32(NLMISC::frand(4.0));
|
||||||
NLMISC::clamp(randRot, (uint32)0, (uint32)3);
|
NLMISC::clamp(randRot, (uint32)0, (uint32)3);
|
||||||
rot = int(randRot);
|
rot = int(randRot);
|
||||||
}
|
}
|
||||||
else if (rot == 5)
|
else if (rot == 5)
|
||||||
{
|
{
|
||||||
// Full cycle
|
// Full cycle
|
||||||
rot = m_rotCycle;
|
rot = m_rotCycle;
|
||||||
m_rotCycle++;
|
m_rotCycle++;
|
||||||
m_rotCycle = m_rotCycle % 4;
|
m_rotCycle = m_rotCycle % 4;
|
||||||
}
|
}
|
||||||
return rot;
|
return rot;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ListZonesWidget::currentFlip()
|
int ListZonesWidget::currentFlip()
|
||||||
{
|
{
|
||||||
int flip = m_ui.flipComboBox->currentIndex();
|
int flip = m_ui.flipComboBox->currentIndex();
|
||||||
if (flip == 2)
|
if (flip == 2)
|
||||||
{
|
{
|
||||||
// Random value
|
// Random value
|
||||||
uint32 randFlip = uint32(NLMISC::frand(2.0));
|
uint32 randFlip = uint32(NLMISC::frand(2.0));
|
||||||
NLMISC::clamp (randFlip, (uint32)0, (uint32)1);
|
NLMISC::clamp (randFlip, (uint32)0, (uint32)1);
|
||||||
flip = int(randFlip);
|
flip = int(randFlip);
|
||||||
}
|
}
|
||||||
else if (flip == 3)
|
else if (flip == 3)
|
||||||
{
|
{
|
||||||
// Full cycle
|
// Full cycle
|
||||||
flip = m_flipCycle;
|
flip = m_flipCycle;
|
||||||
m_flipCycle++;
|
m_flipCycle++;
|
||||||
m_flipCycle = m_flipCycle % 2;
|
m_flipCycle = m_flipCycle % 2;
|
||||||
}
|
}
|
||||||
return flip;
|
return flip;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ListZonesWidget::isNotPropogate() const
|
bool ListZonesWidget::isNotPropogate() const
|
||||||
{
|
{
|
||||||
return m_ui.propogateCheckBox->isChecked();
|
return m_ui.propogateCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ListZonesWidget::isForce() const
|
bool ListZonesWidget::isForce() const
|
||||||
{
|
{
|
||||||
return m_ui.forceCheckBox->isChecked();
|
return m_ui.forceCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
void ListZonesWidget::setZoneBuilder(ZoneBuilder *zoneBuilder)
|
||||||
{
|
{
|
||||||
m_zoneBuilder = zoneBuilder;
|
m_zoneBuilder = zoneBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::updateFilters_1(const QString &value)
|
void ListZonesWidget::updateFilters_1(const QString &value)
|
||||||
{
|
{
|
||||||
disableSignals(true);
|
disableSignals(true);
|
||||||
std::vector<std::string> allCategoryValues;
|
std::vector<std::string> allCategoryValues;
|
||||||
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
||||||
m_ui.categoryValueComboBox_1->clear();
|
m_ui.categoryValueComboBox_1->clear();
|
||||||
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
||||||
m_ui.categoryValueComboBox_1->addItem(QString(allCategoryValues[i].c_str()));
|
m_ui.categoryValueComboBox_1->addItem(QString(allCategoryValues[i].c_str()));
|
||||||
|
|
||||||
disableSignals(false);
|
disableSignals(false);
|
||||||
updateListZones();
|
updateListZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::updateFilters_2(const QString &value)
|
void ListZonesWidget::updateFilters_2(const QString &value)
|
||||||
{
|
{
|
||||||
disableSignals(true);
|
disableSignals(true);
|
||||||
std::vector<std::string> allCategoryValues;
|
std::vector<std::string> allCategoryValues;
|
||||||
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
||||||
|
|
||||||
m_ui.categoryValueComboBox_2->clear();
|
m_ui.categoryValueComboBox_2->clear();
|
||||||
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
||||||
m_ui.categoryValueComboBox_2->addItem(QString(allCategoryValues[i].c_str()));
|
m_ui.categoryValueComboBox_2->addItem(QString(allCategoryValues[i].c_str()));
|
||||||
|
|
||||||
disableSignals(false);
|
disableSignals(false);
|
||||||
updateListZones();
|
updateListZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::updateFilters_3(const QString &value)
|
void ListZonesWidget::updateFilters_3(const QString &value)
|
||||||
{
|
{
|
||||||
disableSignals(true);
|
disableSignals(true);
|
||||||
std::vector<std::string> allCategoryValues;
|
std::vector<std::string> allCategoryValues;
|
||||||
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
||||||
|
|
||||||
m_ui.categoryValueComboBox_3->clear();
|
m_ui.categoryValueComboBox_3->clear();
|
||||||
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
||||||
m_ui.categoryValueComboBox_3->addItem(QString(allCategoryValues[i].c_str()));
|
m_ui.categoryValueComboBox_3->addItem(QString(allCategoryValues[i].c_str()));
|
||||||
|
|
||||||
disableSignals(false);
|
disableSignals(false);
|
||||||
updateListZones();
|
updateListZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::updateFilters_4(const QString &value)
|
void ListZonesWidget::updateFilters_4(const QString &value)
|
||||||
{
|
{
|
||||||
disableSignals(true);
|
disableSignals(true);
|
||||||
std::vector<std::string> allCategoryValues;
|
std::vector<std::string> allCategoryValues;
|
||||||
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
m_zoneBuilder->getZoneBank().getCategoryValues(value.toStdString(), allCategoryValues);
|
||||||
|
|
||||||
m_ui.categoryValueComboBox_4->clear();
|
m_ui.categoryValueComboBox_4->clear();
|
||||||
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
for(size_t i = 0; i < allCategoryValues.size(); ++i)
|
||||||
m_ui.categoryValueComboBox_4->addItem(QString(allCategoryValues[i].c_str()));
|
m_ui.categoryValueComboBox_4->addItem(QString(allCategoryValues[i].c_str()));
|
||||||
|
|
||||||
disableSignals(false);
|
disableSignals(false);
|
||||||
updateListZones();
|
updateListZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::updateListZones()
|
void ListZonesWidget::updateListZones()
|
||||||
{
|
{
|
||||||
// Execute the filter
|
// Execute the filter
|
||||||
NLLIGO::CZoneBank &zoneBank = m_zoneBuilder->getZoneBank();
|
NLLIGO::CZoneBank &zoneBank = m_zoneBuilder->getZoneBank();
|
||||||
zoneBank.resetSelection ();
|
zoneBank.resetSelection ();
|
||||||
|
|
||||||
if(m_ui.categoryTypeComboBox_1->currentIndex() > 0 )
|
if(m_ui.categoryTypeComboBox_1->currentIndex() > 0 )
|
||||||
zoneBank.addOrSwitch (m_ui.categoryTypeComboBox_1->currentText().toStdString()
|
zoneBank.addOrSwitch (m_ui.categoryTypeComboBox_1->currentText().toStdString()
|
||||||
, m_ui.categoryValueComboBox_1->currentText().toStdString());
|
, m_ui.categoryValueComboBox_1->currentText().toStdString());
|
||||||
|
|
||||||
if(m_ui.categoryTypeComboBox_2->currentIndex() > 0 )
|
if(m_ui.categoryTypeComboBox_2->currentIndex() > 0 )
|
||||||
{
|
{
|
||||||
if (m_ui.logicComboBox_2->currentIndex() == 0) // AND switch wanted
|
if (m_ui.logicComboBox_2->currentIndex() == 0) // AND switch wanted
|
||||||
zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_2->currentText().toStdString()
|
zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_2->currentText().toStdString()
|
||||||
,m_ui.categoryValueComboBox_2->currentText().toStdString());
|
,m_ui.categoryValueComboBox_2->currentText().toStdString());
|
||||||
else // OR switch wanted
|
else // OR switch wanted
|
||||||
zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_2->currentText().toStdString()
|
zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_2->currentText().toStdString()
|
||||||
,m_ui.categoryValueComboBox_2->currentText().toStdString());
|
,m_ui.categoryValueComboBox_2->currentText().toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_ui.categoryTypeComboBox_3->currentIndex() > 0 )
|
if(m_ui.categoryTypeComboBox_3->currentIndex() > 0 )
|
||||||
{
|
{
|
||||||
if (m_ui.logicComboBox_3->currentIndex() == 0) // AND switch wanted
|
if (m_ui.logicComboBox_3->currentIndex() == 0) // AND switch wanted
|
||||||
zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_3->currentText().toStdString()
|
zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_3->currentText().toStdString()
|
||||||
,m_ui.categoryValueComboBox_3->currentText().toStdString());
|
,m_ui.categoryValueComboBox_3->currentText().toStdString());
|
||||||
else // OR switch wanted
|
else // OR switch wanted
|
||||||
zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_3->currentText().toStdString()
|
zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_3->currentText().toStdString()
|
||||||
,m_ui.categoryValueComboBox_3->currentText().toStdString());
|
,m_ui.categoryValueComboBox_3->currentText().toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_ui.categoryTypeComboBox_4->currentIndex() > 0 )
|
if(m_ui.categoryTypeComboBox_4->currentIndex() > 0 )
|
||||||
{
|
{
|
||||||
if (m_ui.logicComboBox_4->currentIndex() == 0) // AND switch wanted
|
if (m_ui.logicComboBox_4->currentIndex() == 0) // AND switch wanted
|
||||||
zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_4->currentText().toStdString()
|
zoneBank.addAndSwitch(m_ui.categoryTypeComboBox_4->currentText().toStdString()
|
||||||
,m_ui.categoryValueComboBox_4->currentText().toStdString());
|
,m_ui.categoryValueComboBox_4->currentText().toStdString());
|
||||||
else // OR switch wanted
|
else // OR switch wanted
|
||||||
zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_4->currentText().toStdString()
|
zoneBank.addOrSwitch(m_ui.categoryTypeComboBox_4->currentText().toStdString()
|
||||||
,m_ui.categoryValueComboBox_4->currentText().toStdString());
|
,m_ui.categoryValueComboBox_4->currentText().toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<NLLIGO::CZoneBankElement *> currentSelection;
|
std::vector<NLLIGO::CZoneBankElement *> currentSelection;
|
||||||
zoneBank.getSelection (currentSelection);
|
zoneBank.getSelection (currentSelection);
|
||||||
|
|
||||||
m_listSelection.clear();
|
m_listSelection.clear();
|
||||||
m_zoneNameCycle = 0;
|
m_zoneNameCycle = 0;
|
||||||
for (size_t i = 0; i < currentSelection.size(); ++i)
|
for (size_t i = 0; i < currentSelection.size(); ++i)
|
||||||
m_listSelection << currentSelection[i]->getName().c_str();
|
m_listSelection << currentSelection[i]->getName().c_str();
|
||||||
|
|
||||||
m_listZonesModel->setListZones(m_listSelection);
|
m_listZonesModel->setListZones(m_listSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::disableSignals(bool block)
|
void ListZonesWidget::disableSignals(bool block)
|
||||||
{
|
{
|
||||||
m_ui.categoryTypeComboBox_1->blockSignals(block);
|
m_ui.categoryTypeComboBox_1->blockSignals(block);
|
||||||
m_ui.categoryTypeComboBox_2->blockSignals(block);
|
m_ui.categoryTypeComboBox_2->blockSignals(block);
|
||||||
m_ui.categoryTypeComboBox_3->blockSignals(block);
|
m_ui.categoryTypeComboBox_3->blockSignals(block);
|
||||||
m_ui.categoryTypeComboBox_4->blockSignals(block);
|
m_ui.categoryTypeComboBox_4->blockSignals(block);
|
||||||
m_ui.categoryValueComboBox_1->blockSignals(block);
|
m_ui.categoryValueComboBox_1->blockSignals(block);
|
||||||
m_ui.categoryValueComboBox_2->blockSignals(block);
|
m_ui.categoryValueComboBox_2->blockSignals(block);
|
||||||
m_ui.categoryValueComboBox_3->blockSignals(block);
|
m_ui.categoryValueComboBox_3->blockSignals(block);
|
||||||
m_ui.categoryValueComboBox_4->blockSignals(block);
|
m_ui.categoryValueComboBox_4->blockSignals(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<plugin-spec>
|
<plugin-spec>
|
||||||
<library-name>ovqt_plugin_landscape_editor</library-name>
|
<library-name>ovqt_plugin_landscape_editor</library-name>
|
||||||
<name>LandscapeEditor</name>
|
<name>LandscapeEditor</name>
|
||||||
<version>0.8</version>
|
<version>0.8</version>
|
||||||
<vendor>GSoC2011_dnk-88</vendor>
|
<vendor>GSoC2011_dnk-88</vendor>
|
||||||
<description>Landscape editor ovqt plugin.</description>
|
<description>Landscape editor ovqt plugin.</description>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency plugin-name="Core" version="0.8"/>
|
<dependency plugin-name="Core" version="0.8"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin-spec>
|
</plugin-spec>
|
|
@ -1,154 +1,154 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "pixmap_database.h"
|
#include "pixmap_database.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
#include <nel/ligo/zone_region.h>
|
#include <nel/ligo/zone_region.h>
|
||||||
|
|
||||||
// STL includes
|
// STL includes
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
#include <QtGui/QProgressDialog>
|
#include <QtGui/QProgressDialog>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
PixmapDatabase::PixmapDatabase(int textureSize)
|
PixmapDatabase::PixmapDatabase(int textureSize)
|
||||||
: m_textureSize(textureSize),
|
: m_textureSize(textureSize),
|
||||||
m_errorPixmap(0)
|
m_errorPixmap(0)
|
||||||
{
|
{
|
||||||
// Create pixmap for case if pixmap and LIGO files not found
|
// Create pixmap for case if pixmap and LIGO files not found
|
||||||
m_errorPixmap = new QPixmap(QSize(m_textureSize, m_textureSize));
|
m_errorPixmap = new QPixmap(QSize(m_textureSize, m_textureSize));
|
||||||
QPainter painter(m_errorPixmap);
|
QPainter painter(m_errorPixmap);
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.fillRect(m_errorPixmap->rect(), QBrush(QColor(Qt::black)));
|
painter.fillRect(m_errorPixmap->rect(), QBrush(QColor(Qt::black)));
|
||||||
painter.setFont(QFont("Helvetica [Cronyx]", 14));
|
painter.setFont(QFont("Helvetica [Cronyx]", 14));
|
||||||
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine));
|
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine));
|
||||||
painter.drawText(m_errorPixmap->rect(), Qt::AlignCenter | Qt::TextWordWrap,
|
painter.drawText(m_errorPixmap->rect(), Qt::AlignCenter | Qt::TextWordWrap,
|
||||||
QObject::tr("Pixmap and LIGO files not found."));
|
QObject::tr("Pixmap and LIGO files not found."));
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
PixmapDatabase::~PixmapDatabase()
|
PixmapDatabase::~PixmapDatabase()
|
||||||
{
|
{
|
||||||
delete m_errorPixmap;
|
delete m_errorPixmap;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank, bool displayProgress)
|
bool PixmapDatabase::loadPixmaps(const QString &zonePath, NLLIGO::CZoneBank &zoneBank, bool displayProgress)
|
||||||
{
|
{
|
||||||
QProgressDialog *progressDialog;
|
QProgressDialog *progressDialog;
|
||||||
std::vector<std::string> listNames;
|
std::vector<std::string> listNames;
|
||||||
zoneBank.getCategoryValues ("zone", listNames);
|
zoneBank.getCategoryValues ("zone", listNames);
|
||||||
if (displayProgress)
|
if (displayProgress)
|
||||||
{
|
{
|
||||||
progressDialog = new QProgressDialog(QObject::tr("Loading ligo zones."), QObject::tr("Cancel"), 0, listNames.size());
|
progressDialog = new QProgressDialog(QObject::tr("Loading ligo zones."), QObject::tr("Cancel"), 0, listNames.size());
|
||||||
progressDialog->show();
|
progressDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint i = 0; i < listNames.size(); ++i)
|
for (uint i = 0; i < listNames.size(); ++i)
|
||||||
{
|
{
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
|
|
||||||
if (displayProgress)
|
if (displayProgress)
|
||||||
progressDialog->setValue(i);
|
progressDialog->setValue(i);
|
||||||
|
|
||||||
NLLIGO::CZoneBankElement *zoneBankItem = zoneBank.getElementByZoneName (listNames[i]);
|
NLLIGO::CZoneBankElement *zoneBankItem = zoneBank.getElementByZoneName (listNames[i]);
|
||||||
|
|
||||||
// Read the texture file
|
// Read the texture file
|
||||||
QString zonePixmapName(listNames[i].c_str());
|
QString zonePixmapName(listNames[i].c_str());
|
||||||
uint8 sizeX = zoneBankItem->getSizeX();
|
uint8 sizeX = zoneBankItem->getSizeX();
|
||||||
uint8 sizeY = zoneBankItem->getSizeY();
|
uint8 sizeY = zoneBankItem->getSizeY();
|
||||||
|
|
||||||
QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png");
|
QPixmap *pixmap = new QPixmap(zonePath + zonePixmapName + ".png");
|
||||||
if (pixmap->isNull())
|
if (pixmap->isNull())
|
||||||
{
|
{
|
||||||
// Generate filled pixmap if could not load pixmap
|
// Generate filled pixmap if could not load pixmap
|
||||||
QPixmap *emptyPixmap = new QPixmap(QSize(sizeX * m_textureSize, sizeY * m_textureSize));
|
QPixmap *emptyPixmap = new QPixmap(QSize(sizeX * m_textureSize, sizeY * m_textureSize));
|
||||||
QPainter painter(emptyPixmap);
|
QPainter painter(emptyPixmap);
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.fillRect(emptyPixmap->rect(), QBrush(QColor(Qt::black)));
|
painter.fillRect(emptyPixmap->rect(), QBrush(QColor(Qt::black)));
|
||||||
painter.setFont(QFont("Helvetica [Cronyx]", 18));
|
painter.setFont(QFont("Helvetica [Cronyx]", 18));
|
||||||
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine));
|
painter.setPen(QPen(Qt::red, 2, Qt::SolidLine));
|
||||||
painter.drawText(emptyPixmap->rect(), Qt::AlignCenter, QObject::tr("Pixmap not found"));
|
painter.drawText(emptyPixmap->rect(), Qt::AlignCenter, QObject::tr("Pixmap not found"));
|
||||||
painter.end();
|
painter.end();
|
||||||
delete pixmap;
|
delete pixmap;
|
||||||
m_pixmapMap.insert(zonePixmapName, emptyPixmap);
|
m_pixmapMap.insert(zonePixmapName, emptyPixmap);
|
||||||
nlwarning(QString("not found " + zonePath + zonePixmapName + ".png").toStdString().c_str());
|
nlwarning(QString("not found " + zonePath + zonePixmapName + ".png").toStdString().c_str());
|
||||||
}
|
}
|
||||||
// All pixmaps must be have same size
|
// All pixmaps must be have same size
|
||||||
else if (pixmap->width() != sizeX * m_textureSize)
|
else if (pixmap->width() != sizeX * m_textureSize)
|
||||||
{
|
{
|
||||||
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(sizeX * m_textureSize, sizeY * m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
delete pixmap;
|
delete pixmap;
|
||||||
m_pixmapMap.insert(zonePixmapName, scaledPixmap);
|
m_pixmapMap.insert(zonePixmapName, scaledPixmap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_pixmapMap.insert(zonePixmapName, pixmap);
|
m_pixmapMap.insert(zonePixmapName, pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap *pixmap = new QPixmap(zonePath + "_unused_.png");
|
QPixmap *pixmap = new QPixmap(zonePath + "_unused_.png");
|
||||||
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(m_textureSize, m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
QPixmap *scaledPixmap = new QPixmap(pixmap->scaled(m_textureSize, m_textureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
delete pixmap;
|
delete pixmap;
|
||||||
m_pixmapMap.insert(QString(STRING_UNUSED), scaledPixmap);
|
m_pixmapMap.insert(QString(STRING_UNUSED), scaledPixmap);
|
||||||
|
|
||||||
if (displayProgress)
|
if (displayProgress)
|
||||||
delete progressDialog;
|
delete progressDialog;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixmapDatabase::reset()
|
void PixmapDatabase::reset()
|
||||||
{
|
{
|
||||||
QStringList listNames(m_pixmapMap.keys());
|
QStringList listNames(m_pixmapMap.keys());
|
||||||
Q_FOREACH(QString name, listNames)
|
Q_FOREACH(QString name, listNames)
|
||||||
{
|
{
|
||||||
QPixmap *pixmap = m_pixmapMap.value(name);
|
QPixmap *pixmap = m_pixmapMap.value(name);
|
||||||
delete pixmap;
|
delete pixmap;
|
||||||
}
|
}
|
||||||
m_pixmapMap.clear();
|
m_pixmapMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList PixmapDatabase::listPixmaps() const
|
QStringList PixmapDatabase::listPixmaps() const
|
||||||
{
|
{
|
||||||
return m_pixmapMap.keys();
|
return m_pixmapMap.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const
|
QPixmap *PixmapDatabase::pixmap(const QString &zoneName) const
|
||||||
{
|
{
|
||||||
QPixmap *result = m_errorPixmap;
|
QPixmap *result = m_errorPixmap;
|
||||||
if (!m_pixmapMap.contains(zoneName))
|
if (!m_pixmapMap.contains(zoneName))
|
||||||
nlwarning("QPixmap %s not found", zoneName.toStdString().c_str());
|
nlwarning("QPixmap %s not found", zoneName.toStdString().c_str());
|
||||||
else
|
else
|
||||||
result = m_pixmapMap.value(zoneName);
|
result = m_pixmapMap.value(zoneName);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PixmapDatabase::textureSize() const
|
int PixmapDatabase::textureSize() const
|
||||||
{
|
{
|
||||||
return m_textureSize;
|
return m_textureSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "project_settings_dialog.h"
|
#include "project_settings_dialog.h"
|
||||||
#include "landscape_editor_constants.h"
|
#include "landscape_editor_constants.h"
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *parent)
|
ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
m_ui.pathLineEdit->setText(dataPath);
|
m_ui.pathLineEdit->setText(dataPath);
|
||||||
setFixedHeight(sizeHint().height());
|
setFixedHeight(sizeHint().height());
|
||||||
connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath()));
|
connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectSettingsDialog::~ProjectSettingsDialog()
|
ProjectSettingsDialog::~ProjectSettingsDialog()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProjectSettingsDialog::dataPath() const
|
QString ProjectSettingsDialog::dataPath() const
|
||||||
{
|
{
|
||||||
return m_ui.pathLineEdit->text();
|
return m_ui.pathLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsDialog::selectPath()
|
void ProjectSettingsDialog::selectPath()
|
||||||
{
|
{
|
||||||
QString dataPath = QFileDialog::getExistingDirectory(this, tr("Select data path"), m_ui.pathLineEdit->text());
|
QString dataPath = QFileDialog::getExistingDirectory(this, tr("Select data path"), m_ui.pathLineEdit->text());
|
||||||
if (!dataPath.isEmpty())
|
if (!dataPath.isEmpty())
|
||||||
m_ui.pathLineEdit->setText(dataPath);
|
m_ui.pathLineEdit->setText(dataPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,70 +1,70 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "snapshot_dialog.h"
|
#include "snapshot_dialog.h"
|
||||||
#include "landscape_editor_constants.h"
|
#include "landscape_editor_constants.h"
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
SnapshotDialog::SnapshotDialog(QWidget *parent)
|
SnapshotDialog::SnapshotDialog(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
setFixedHeight(sizeHint().height());
|
setFixedHeight(sizeHint().height());
|
||||||
}
|
}
|
||||||
|
|
||||||
SnapshotDialog::~SnapshotDialog()
|
SnapshotDialog::~SnapshotDialog()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SnapshotDialog::isCustomSize() const
|
bool SnapshotDialog::isCustomSize() const
|
||||||
{
|
{
|
||||||
return m_ui.customSizeRadioButton->isChecked();
|
return m_ui.customSizeRadioButton->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SnapshotDialog::isKeepRatio() const
|
bool SnapshotDialog::isKeepRatio() const
|
||||||
{
|
{
|
||||||
return m_ui.keepRatioCheckBox->isChecked();
|
return m_ui.keepRatioCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SnapshotDialog::resolutionZone() const
|
int SnapshotDialog::resolutionZone() const
|
||||||
{
|
{
|
||||||
return m_ui.resSpinBox->value();
|
return m_ui.resSpinBox->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SnapshotDialog::widthSnapshot() const
|
int SnapshotDialog::widthSnapshot() const
|
||||||
{
|
{
|
||||||
return m_ui.widthSpinBox->value();
|
return m_ui.widthSpinBox->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SnapshotDialog::heightSnapshot() const
|
int SnapshotDialog::heightSnapshot() const
|
||||||
{
|
{
|
||||||
return m_ui.heightSpinBox->value();
|
return m_ui.heightSpinBox->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,181 +1,181 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "zone_region_editor.h"
|
#include "zone_region_editor.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
#include <nel/misc/file.h>
|
#include <nel/misc/file.h>
|
||||||
#include <nel/misc/i_xml.h>
|
#include <nel/misc/i_xml.h>
|
||||||
#include <nel/misc/o_xml.h>
|
#include <nel/misc/o_xml.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
ZoneRegionObject::ZoneRegionObject()
|
ZoneRegionObject::ZoneRegionObject()
|
||||||
{
|
{
|
||||||
m_fileName = "";
|
m_fileName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoneRegionObject::~ZoneRegionObject()
|
ZoneRegionObject::~ZoneRegionObject()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneRegionObject::load(const std::string &fileName)
|
bool ZoneRegionObject::load(const std::string &fileName)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Open it
|
// Open it
|
||||||
NLMISC::CIFile fileIn;
|
NLMISC::CIFile fileIn;
|
||||||
if (fileIn.open(fileName))
|
if (fileIn.open(fileName))
|
||||||
{
|
{
|
||||||
NLMISC::CIXml xml(true);
|
NLMISC::CIXml xml(true);
|
||||||
xml.init(fileIn);
|
xml.init(fileIn);
|
||||||
m_zoneRegion.serial(xml);
|
m_zoneRegion.serial(xml);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nlwarning("Can't open file %s for reading", fileName.c_str());
|
nlwarning("Can't open file %s for reading", fileName.c_str());
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NLMISC::Exception &e)
|
catch (NLMISC::Exception &e)
|
||||||
{
|
{
|
||||||
nlwarning("Error reading file %s : %s", fileName.c_str(), e.what ());
|
nlwarning("Error reading file %s : %s", fileName.c_str(), e.what ());
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
if (result)
|
if (result)
|
||||||
m_fileName = fileName;
|
m_fileName = fileName;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneRegionObject::save()
|
bool ZoneRegionObject::save()
|
||||||
{
|
{
|
||||||
if (m_fileName.empty())
|
if (m_fileName.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
// Save the landscape
|
// Save the landscape
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
// Open file for writing
|
// Open file for writing
|
||||||
NLMISC::COFile fileOut;
|
NLMISC::COFile fileOut;
|
||||||
if (fileOut.open(m_fileName, false, false, true))
|
if (fileOut.open(m_fileName, false, false, true))
|
||||||
{
|
{
|
||||||
// Be careful with the flushing of the COXml object
|
// Be careful with the flushing of the COXml object
|
||||||
{
|
{
|
||||||
NLMISC::COXml xmlOut;
|
NLMISC::COXml xmlOut;
|
||||||
xmlOut.init(&fileOut);
|
xmlOut.init(&fileOut);
|
||||||
m_zoneRegion.serial(xmlOut);
|
m_zoneRegion.serial(xmlOut);
|
||||||
// Done
|
// Done
|
||||||
m_modified = false;
|
m_modified = false;
|
||||||
}
|
}
|
||||||
fileOut.close();
|
fileOut.close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nlwarning("Can't open file %s for writing.", m_fileName.c_str());
|
nlwarning("Can't open file %s for writing.", m_fileName.c_str());
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NLMISC::Exception &e)
|
catch (NLMISC::Exception &e)
|
||||||
{
|
{
|
||||||
nlwarning("Error writing file %s : %s", m_fileName.c_str(), e.what());
|
nlwarning("Error writing file %s : %s", m_fileName.c_str(), e.what());
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ZoneRegionObject::fileName() const
|
std::string ZoneRegionObject::fileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneRegionObject::setFileName(const std::string &fileName)
|
void ZoneRegionObject::setFileName(const std::string &fileName)
|
||||||
{
|
{
|
||||||
m_fileName = fileName;
|
m_fileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneRegionObject::ligoData(LigoData &data, const sint32 x, const sint32 y)
|
void ZoneRegionObject::ligoData(LigoData &data, const sint32 x, const sint32 y)
|
||||||
{
|
{
|
||||||
data.posX = m_zoneRegion.getPosX(x, y);
|
data.posX = m_zoneRegion.getPosX(x, y);
|
||||||
data.posY = m_zoneRegion.getPosY(x, y);
|
data.posY = m_zoneRegion.getPosY(x, y);
|
||||||
data.zoneName = m_zoneRegion.getName(x, y);
|
data.zoneName = m_zoneRegion.getName(x, y);
|
||||||
data.rot = m_zoneRegion.getRot(x, y);
|
data.rot = m_zoneRegion.getRot(x, y);
|
||||||
data.flip = m_zoneRegion.getFlip(x, y);
|
data.flip = m_zoneRegion.getFlip(x, y);
|
||||||
data.sharingMatNames[0] = m_zoneRegion.getSharingMatNames(x, y, 0);
|
data.sharingMatNames[0] = m_zoneRegion.getSharingMatNames(x, y, 0);
|
||||||
data.sharingMatNames[1] = m_zoneRegion.getSharingMatNames(x, y, 1);
|
data.sharingMatNames[1] = m_zoneRegion.getSharingMatNames(x, y, 1);
|
||||||
data.sharingMatNames[2] = m_zoneRegion.getSharingMatNames(x, y, 2);
|
data.sharingMatNames[2] = m_zoneRegion.getSharingMatNames(x, y, 2);
|
||||||
data.sharingMatNames[3] = m_zoneRegion.getSharingMatNames(x, y, 3);
|
data.sharingMatNames[3] = m_zoneRegion.getSharingMatNames(x, y, 3);
|
||||||
data.sharingCutEdges[0] = m_zoneRegion.getSharingCutEdges(x, y, 0);
|
data.sharingCutEdges[0] = m_zoneRegion.getSharingCutEdges(x, y, 0);
|
||||||
data.sharingCutEdges[1] = m_zoneRegion.getSharingCutEdges(x, y, 1);
|
data.sharingCutEdges[1] = m_zoneRegion.getSharingCutEdges(x, y, 1);
|
||||||
data.sharingCutEdges[2] = m_zoneRegion.getSharingCutEdges(x, y, 2);
|
data.sharingCutEdges[2] = m_zoneRegion.getSharingCutEdges(x, y, 2);
|
||||||
data.sharingCutEdges[3] = m_zoneRegion.getSharingCutEdges(x, y, 3);
|
data.sharingCutEdges[3] = m_zoneRegion.getSharingCutEdges(x, y, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneRegionObject::setLigoData(const LigoData &data, const sint32 x, const sint32 y)
|
void ZoneRegionObject::setLigoData(const LigoData &data, const sint32 x, const sint32 y)
|
||||||
{
|
{
|
||||||
m_zoneRegion.setPosX(x, y, data.posX);
|
m_zoneRegion.setPosX(x, y, data.posX);
|
||||||
m_zoneRegion.setPosY(x, y, data.posY);
|
m_zoneRegion.setPosY(x, y, data.posY);
|
||||||
m_zoneRegion.setName(x, y, data.zoneName);
|
m_zoneRegion.setName(x, y, data.zoneName);
|
||||||
m_zoneRegion.setRot(x, y, data.rot);
|
m_zoneRegion.setRot(x, y, data.rot);
|
||||||
m_zoneRegion.setFlip(x, y, data.flip);
|
m_zoneRegion.setFlip(x, y, data.flip);
|
||||||
m_zoneRegion.setSharingMatNames(x, y, 0, data.sharingMatNames[0]);
|
m_zoneRegion.setSharingMatNames(x, y, 0, data.sharingMatNames[0]);
|
||||||
m_zoneRegion.setSharingMatNames(x, y, 1, data.sharingMatNames[1]);
|
m_zoneRegion.setSharingMatNames(x, y, 1, data.sharingMatNames[1]);
|
||||||
m_zoneRegion.setSharingMatNames(x, y, 2, data.sharingMatNames[2]);
|
m_zoneRegion.setSharingMatNames(x, y, 2, data.sharingMatNames[2]);
|
||||||
m_zoneRegion.setSharingMatNames(x, y, 3, data.sharingMatNames[3]);
|
m_zoneRegion.setSharingMatNames(x, y, 3, data.sharingMatNames[3]);
|
||||||
m_zoneRegion.setSharingCutEdges(x, y, 0, data.sharingCutEdges[0]);
|
m_zoneRegion.setSharingCutEdges(x, y, 0, data.sharingCutEdges[0]);
|
||||||
m_zoneRegion.setSharingCutEdges(x, y, 1, data.sharingCutEdges[1]);
|
m_zoneRegion.setSharingCutEdges(x, y, 1, data.sharingCutEdges[1]);
|
||||||
m_zoneRegion.setSharingCutEdges(x, y, 2, data.sharingCutEdges[2]);
|
m_zoneRegion.setSharingCutEdges(x, y, 2, data.sharingCutEdges[2]);
|
||||||
m_zoneRegion.setSharingCutEdges(x, y, 3, data.sharingCutEdges[3]);
|
m_zoneRegion.setSharingCutEdges(x, y, 3, data.sharingCutEdges[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
NLLIGO::CZoneRegion &ZoneRegionObject::ligoZoneRegion()
|
NLLIGO::CZoneRegion &ZoneRegionObject::ligoZoneRegion()
|
||||||
{
|
{
|
||||||
return m_zoneRegion;
|
return m_zoneRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneRegionObject::setLigoZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
void ZoneRegionObject::setLigoZoneRegion(const NLLIGO::CZoneRegion &zoneRegion)
|
||||||
{
|
{
|
||||||
m_zoneRegion = zoneRegion;
|
m_zoneRegion = zoneRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneRegionObject::checkPos(const sint32 x, const sint32 y)
|
bool ZoneRegionObject::checkPos(const sint32 x, const sint32 y)
|
||||||
{
|
{
|
||||||
return ((x >= m_zoneRegion.getMinX()) &&
|
return ((x >= m_zoneRegion.getMinX()) &&
|
||||||
(x <= m_zoneRegion.getMaxX()) &&
|
(x <= m_zoneRegion.getMaxX()) &&
|
||||||
(y >= m_zoneRegion.getMinY()) &&
|
(y >= m_zoneRegion.getMinY()) &&
|
||||||
(y <= m_zoneRegion.getMaxY()));
|
(y <= m_zoneRegion.getMaxY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneRegionObject::isModified() const
|
bool ZoneRegionObject::isModified() const
|
||||||
{
|
{
|
||||||
return m_modified;
|
return m_modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneRegionObject::setModified(bool modified)
|
void ZoneRegionObject::setModified(bool modified)
|
||||||
{
|
{
|
||||||
m_modified = modified;
|
m_modified = modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
|
@ -1,70 +1,70 @@
|
||||||
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
|
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${LIBXML2_INCLUDE_DIR}
|
${LIBXML2_INCLUDE_DIR}
|
||||||
${QT_INCLUDES}
|
${QT_INCLUDES}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/qtpropertybrowser
|
${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/qtpropertybrowser
|
||||||
)
|
)
|
||||||
|
|
||||||
FILE(GLOB SRC *.cpp *.h)
|
FILE(GLOB SRC *.cpp *.h)
|
||||||
|
|
||||||
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.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_manager.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h
|
SET(OVQT_PLUGIN_WORLD_EDITOR_HDR world_editor_plugin.h
|
||||||
world_editor_window.h
|
world_editor_window.h
|
||||||
world_editor_scene.h
|
world_editor_scene.h
|
||||||
world_editor_scene_item.h
|
world_editor_scene_item.h
|
||||||
primitives_model.h
|
primitives_model.h
|
||||||
primitives_view.h
|
primitives_view.h
|
||||||
project_settings_dialog.h
|
project_settings_dialog.h
|
||||||
property_editor_widget.h
|
property_editor_widget.h
|
||||||
world_editor_settings_page.h
|
world_editor_settings_page.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_WORLD_EDITOR_UIS world_editor_window.ui
|
SET(OVQT_PLUGIN_WORLD_EDITOR_UIS world_editor_window.ui
|
||||||
project_settings_dialog.ui
|
project_settings_dialog.ui
|
||||||
property_editor_widget.ui
|
property_editor_widget.ui
|
||||||
world_editor_settings_page.ui
|
world_editor_settings_page.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(OVQT_PLUGIN_WORLD_EDITOR_RCS world_editor.qrc)
|
SET(OVQT_PLUGIN_WORLD_EDITOR_RCS world_editor.qrc)
|
||||||
|
|
||||||
SET(QT_USE_QTGUI TRUE)
|
SET(QT_USE_QTGUI TRUE)
|
||||||
SET(QT_USE_QTOPENGL TRUE)
|
SET(QT_USE_QTOPENGL TRUE)
|
||||||
|
|
||||||
QT4_ADD_RESOURCES(OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS ${OVQT_PLUGIN_WORLD_EDITOR_RCS})
|
QT4_ADD_RESOURCES(OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS ${OVQT_PLUGIN_WORLD_EDITOR_RCS})
|
||||||
QT4_WRAP_CPP(OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC ${OVQT_PLUGIN_WORLD_EDITOR_HDR})
|
QT4_WRAP_CPP(OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC ${OVQT_PLUGIN_WORLD_EDITOR_HDR})
|
||||||
QT4_WRAP_UI(OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS ${OVQT_PLUGIN_WORLD_EDITOR_UIS})
|
QT4_WRAP_UI(OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS ${OVQT_PLUGIN_WORLD_EDITOR_UIS})
|
||||||
|
|
||||||
SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_WORLD_EDITOR_UIS})
|
SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_WORLD_EDITOR_UIS})
|
||||||
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS})
|
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS})
|
||||||
SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC} OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS)
|
SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC} OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS)
|
||||||
SOURCE_GROUP("World Editor Plugin" FILES ${SRC})
|
SOURCE_GROUP("World Editor Plugin" FILES ${SRC})
|
||||||
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
||||||
|
|
||||||
ADD_LIBRARY(ovqt_plugin_world_editor MODULE ${SRC}
|
ADD_LIBRARY(ovqt_plugin_world_editor MODULE ${SRC}
|
||||||
${OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC}
|
${OVQT_PLUGIN_WORLD_EDITOR_MOC_SRC}
|
||||||
${OVQT_EXT_SYS_SRC}
|
${OVQT_EXT_SYS_SRC}
|
||||||
${OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS}
|
${OVQT_PLUGIN_WORLD_EDITOR_UI_HDRS}
|
||||||
${OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS})
|
${OVQT_PLUGIN_WORLD_EDITOR_RC_SRCS})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES( ovqt_plugin_world_editor
|
TARGET_LINK_LIBRARIES( ovqt_plugin_world_editor
|
||||||
ovqt_plugin_core
|
ovqt_plugin_core
|
||||||
ovqt_plugin_landscape_editor
|
ovqt_plugin_landscape_editor
|
||||||
nelmisc
|
nelmisc
|
||||||
nel3d
|
nel3d
|
||||||
qt_property_browser
|
qt_property_browser
|
||||||
${QT_LIBRARIES}
|
${QT_LIBRARIES}
|
||||||
${QT_QTOPENGL_LIBRARY}
|
${QT_QTOPENGL_LIBRARY}
|
||||||
)
|
)
|
||||||
|
|
||||||
NL_DEFAULT_PROPS(ovqt_plugin_world_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: World Editor")
|
NL_DEFAULT_PROPS(ovqt_plugin_world_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: World Editor")
|
||||||
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_world_editor)
|
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_world_editor)
|
||||||
NL_ADD_LIB_SUFFIX(ovqt_plugin_world_editor)
|
NL_ADD_LIB_SUFFIX(ovqt_plugin_world_editor)
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DWORLD_EDITOR_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
|
ADD_DEFINITIONS(-DWORLD_EDITOR_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
|
||||||
|
|
||||||
INSTALL(TARGETS ovqt_plugin_world_editor LIBRARY DESTINATION ${OVQT_PLUGIN_DIR} RUNTIME DESTINATION ${NL_BIN_PREFIX} ARCHIVE DESTINATION ${OVQT_PLUGIN_DIR} COMPONENT tools3d)
|
INSTALL(TARGETS ovqt_plugin_world_editor LIBRARY DESTINATION ${OVQT_PLUGIN_DIR} RUNTIME DESTINATION ${NL_BIN_PREFIX} ARCHIVE DESTINATION ${OVQT_PLUGIN_DIR} COMPONENT tools3d)
|
||||||
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ovqt_plugin_world_editor.xml DESTINATION ${OVQT_PLUGIN_SPECS_DIR} COMPONENT tools3d)
|
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ovqt_plugin_world_editor.xml DESTINATION ${OVQT_PLUGIN_SPECS_DIR} COMPONENT tools3d)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<plugin-spec>
|
<plugin-spec>
|
||||||
<library-name>ovqt_plugin_world_editor</library-name>
|
<library-name>ovqt_plugin_world_editor</library-name>
|
||||||
<name>WorldEditor</name>
|
<name>WorldEditor</name>
|
||||||
<version>0.6</version>
|
<version>0.6</version>
|
||||||
<vendor>GSoC2011_dnk-88</vendor>
|
<vendor>GSoC2011_dnk-88</vendor>
|
||||||
<description>Landscape editor ovqt plugin.</description>
|
<description>Landscape editor ovqt plugin.</description>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency plugin-name="Core" version="0.8"/>
|
<dependency plugin-name="Core" version="0.8"/>
|
||||||
<dependency plugin-name="LandscapeEditor" version="0.6"/>
|
<dependency plugin-name="LandscapeEditor" version="0.6"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin-spec>
|
</plugin-spec>
|
|
@ -1,312 +1,312 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "primitive_item.h"
|
#include "primitive_item.h"
|
||||||
#include "world_editor_misc.h"
|
#include "world_editor_misc.h"
|
||||||
#include "world_editor_constants.h"
|
#include "world_editor_constants.h"
|
||||||
|
|
||||||
#include "../landscape_editor/landscape_editor_constants.h"
|
#include "../landscape_editor/landscape_editor_constants.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/ligo/ligo_config.h>
|
#include <nel/ligo/ligo_config.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
Node::Node()
|
Node::Node()
|
||||||
: m_parent(0)
|
: m_parent(0)
|
||||||
{
|
{
|
||||||
setData(Constants::PRIMITIVE_IS_VISIBLE, true);
|
setData(Constants::PRIMITIVE_IS_VISIBLE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::~Node()
|
Node::~Node()
|
||||||
{
|
{
|
||||||
if (m_parent)
|
if (m_parent)
|
||||||
m_parent->removeChildNode(this);
|
m_parent->removeChildNode(this);
|
||||||
|
|
||||||
qDeleteAll(m_children);
|
qDeleteAll(m_children);
|
||||||
nlassert(m_children.isEmpty());
|
nlassert(m_children.isEmpty());
|
||||||
m_data.clear();
|
m_data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::prependChildNode(Node *node)
|
void Node::prependChildNode(Node *node)
|
||||||
{
|
{
|
||||||
// Node is already a child
|
// Node is already a child
|
||||||
nlassert(!m_children.contains(node));
|
nlassert(!m_children.contains(node));
|
||||||
|
|
||||||
// Node already has a parent
|
// Node already has a parent
|
||||||
nlassert(!m_children.contains(node));
|
nlassert(!m_children.contains(node));
|
||||||
|
|
||||||
m_children.prepend(node);
|
m_children.prepend(node);
|
||||||
node->m_parent = this;
|
node->m_parent = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::appendChildNode(Node *node)
|
void Node::appendChildNode(Node *node)
|
||||||
{
|
{
|
||||||
// Node is already a child
|
// Node is already a child
|
||||||
nlassert(!m_children.contains(node));
|
nlassert(!m_children.contains(node));
|
||||||
|
|
||||||
// Node already has a parent
|
// Node already has a parent
|
||||||
nlassert(!m_children.contains(node));
|
nlassert(!m_children.contains(node));
|
||||||
|
|
||||||
m_children.append(node);
|
m_children.append(node);
|
||||||
node->m_parent = this;
|
node->m_parent = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::insertChildNodeBefore(Node *node, Node *before)
|
void Node::insertChildNodeBefore(Node *node, Node *before)
|
||||||
{
|
{
|
||||||
// Node is already a child
|
// Node is already a child
|
||||||
nlassert(!m_children.contains(node));
|
nlassert(!m_children.contains(node));
|
||||||
|
|
||||||
// Node already has a parent
|
// Node already has a parent
|
||||||
nlassert(!m_children.contains(node));
|
nlassert(!m_children.contains(node));
|
||||||
|
|
||||||
int idx = before ? m_children.indexOf(before) : -1;
|
int idx = before ? m_children.indexOf(before) : -1;
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
m_children.append(node);
|
m_children.append(node);
|
||||||
else
|
else
|
||||||
m_children.insert(idx, node);
|
m_children.insert(idx, node);
|
||||||
node->m_parent = this;
|
node->m_parent = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::insertChildNodeAfter(Node *node, Node *after)
|
void Node::insertChildNodeAfter(Node *node, Node *after)
|
||||||
{
|
{
|
||||||
// Node is already a child
|
// Node is already a child
|
||||||
nlassert(!m_children.contains(node));
|
nlassert(!m_children.contains(node));
|
||||||
|
|
||||||
// Node already has a parent
|
// Node already has a parent
|
||||||
nlassert(!m_children.contains(node));
|
nlassert(!m_children.contains(node));
|
||||||
|
|
||||||
int idx = after ? m_children.indexOf(after) : -1;
|
int idx = after ? m_children.indexOf(after) : -1;
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
m_children.append(node);
|
m_children.append(node);
|
||||||
else
|
else
|
||||||
m_children.insert(idx + 1, node);
|
m_children.insert(idx + 1, node);
|
||||||
node->m_parent = this;
|
node->m_parent = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::insertChildNode(int pos, Node *node)
|
void Node::insertChildNode(int pos, Node *node)
|
||||||
{
|
{
|
||||||
// Node is already a child
|
// Node is already a child
|
||||||
nlassert(!m_children.contains(node));
|
nlassert(!m_children.contains(node));
|
||||||
|
|
||||||
// Node already has a parent
|
// Node already has a parent
|
||||||
nlassert(!m_children.contains(node));
|
nlassert(!m_children.contains(node));
|
||||||
|
|
||||||
m_children.insert(pos, node);
|
m_children.insert(pos, node);
|
||||||
node->m_parent = this;
|
node->m_parent = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::removeChildNode(Node *node)
|
void Node::removeChildNode(Node *node)
|
||||||
{
|
{
|
||||||
nlassert(m_children.contains(node));
|
nlassert(m_children.contains(node));
|
||||||
nlassert(node->parent() == this);
|
nlassert(node->parent() == this);
|
||||||
|
|
||||||
m_children.removeOne(node);
|
m_children.removeOne(node);
|
||||||
|
|
||||||
node->m_parent = 0;
|
node->m_parent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *Node::child(int row)
|
Node *Node::child(int row)
|
||||||
{
|
{
|
||||||
return m_children.at(row);
|
return m_children.at(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Node::childCount() const
|
int Node::childCount() const
|
||||||
{
|
{
|
||||||
return m_children.count();
|
return m_children.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant Node::data(int key) const
|
QVariant Node::data(int key) const
|
||||||
{
|
{
|
||||||
return m_data[key];
|
return m_data[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setData(int key, const QVariant &data)
|
void Node::setData(int key, const QVariant &data)
|
||||||
{
|
{
|
||||||
m_data[key] = data;
|
m_data[key] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *Node::parent()
|
Node *Node::parent()
|
||||||
{
|
{
|
||||||
return m_parent;
|
return m_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Node::row() const
|
int Node::row() const
|
||||||
{
|
{
|
||||||
if (m_parent)
|
if (m_parent)
|
||||||
return m_parent->m_children.indexOf(const_cast<Node *>(this));
|
return m_parent->m_children.indexOf(const_cast<Node *>(this));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::NodeType Node::type() const
|
Node::NodeType Node::type() const
|
||||||
{
|
{
|
||||||
return BasicNodeType;
|
return BasicNodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldEditNode::WorldEditNode(const QString &name)
|
WorldEditNode::WorldEditNode(const QString &name)
|
||||||
{
|
{
|
||||||
setData(Qt::DisplayRole, name);
|
setData(Qt::DisplayRole, name);
|
||||||
setData(Qt::DecorationRole, QIcon(Constants::ICON_WORLD_EDITOR));
|
setData(Qt::DecorationRole, QIcon(Constants::ICON_WORLD_EDITOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldEditNode::~WorldEditNode()
|
WorldEditNode::~WorldEditNode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditNode::setContext(const QString &name)
|
void WorldEditNode::setContext(const QString &name)
|
||||||
{
|
{
|
||||||
m_context = name;
|
m_context = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WorldEditNode::context() const
|
QString WorldEditNode::context() const
|
||||||
{
|
{
|
||||||
return m_context;
|
return m_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditNode::setDataPath(const QString &path)
|
void WorldEditNode::setDataPath(const QString &path)
|
||||||
{
|
{
|
||||||
m_dataPath = path;
|
m_dataPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WorldEditNode::dataPath() const
|
QString WorldEditNode::dataPath() const
|
||||||
{
|
{
|
||||||
return m_dataPath;
|
return m_dataPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::NodeType WorldEditNode::type() const
|
Node::NodeType WorldEditNode::type() const
|
||||||
{
|
{
|
||||||
return WorldEditNodeType;
|
return WorldEditNodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
LandscapeNode::LandscapeNode(const QString &name, int id)
|
LandscapeNode::LandscapeNode(const QString &name, int id)
|
||||||
: m_id(id),
|
: m_id(id),
|
||||||
m_fileName(name)
|
m_fileName(name)
|
||||||
{
|
{
|
||||||
setData(Qt::DisplayRole, name);
|
setData(Qt::DisplayRole, name);
|
||||||
setData(Qt::DecorationRole, QIcon(LandscapeEditor::Constants::ICON_ZONE_ITEM));
|
setData(Qt::DecorationRole, QIcon(LandscapeEditor::Constants::ICON_ZONE_ITEM));
|
||||||
}
|
}
|
||||||
|
|
||||||
LandscapeNode::~LandscapeNode()
|
LandscapeNode::~LandscapeNode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LandscapeNode::fileName() const
|
QString LandscapeNode::fileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LandscapeNode::id() const
|
int LandscapeNode::id() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::NodeType LandscapeNode::type() const
|
Node::NodeType LandscapeNode::type() const
|
||||||
{
|
{
|
||||||
return LandscapeNodeType;
|
return LandscapeNodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimitiveNode::PrimitiveNode(NLLIGO::IPrimitive *primitive)
|
PrimitiveNode::PrimitiveNode(NLLIGO::IPrimitive *primitive)
|
||||||
: m_primitive(primitive)
|
: m_primitive(primitive)
|
||||||
{
|
{
|
||||||
setData(Qt::DisplayRole, QString(m_primitive->getName().c_str()));
|
setData(Qt::DisplayRole, QString(m_primitive->getName().c_str()));
|
||||||
setData(Qt::ToolTipRole, QString(m_primitive->getClassName().c_str()));
|
setData(Qt::ToolTipRole, QString(m_primitive->getClassName().c_str()));
|
||||||
|
|
||||||
std::string className;
|
std::string className;
|
||||||
m_primitive->getPropertyByName("class", className);
|
m_primitive->getPropertyByName("class", className);
|
||||||
|
|
||||||
// Set Icon
|
// Set Icon
|
||||||
QString nameIcon = QString("%1/%2.ico").arg(Constants::PATH_TO_OLD_ICONS).arg(className.c_str());
|
QString nameIcon = QString("%1/%2.ico").arg(Constants::PATH_TO_OLD_ICONS).arg(className.c_str());
|
||||||
QIcon icon(nameIcon);
|
QIcon icon(nameIcon);
|
||||||
if (!QFile::exists(nameIcon))
|
if (!QFile::exists(nameIcon))
|
||||||
{
|
{
|
||||||
if (primitive->getParent() == NULL)
|
if (primitive->getParent() == NULL)
|
||||||
icon = QIcon(Constants::ICON_ROOT_PRIMITIVE);
|
icon = QIcon(Constants::ICON_ROOT_PRIMITIVE);
|
||||||
else if (primitive->getNumChildren() == 0)
|
else if (primitive->getNumChildren() == 0)
|
||||||
icon = QIcon(Constants::ICON_PROPERTY);
|
icon = QIcon(Constants::ICON_PROPERTY);
|
||||||
else
|
else
|
||||||
icon = QIcon(Constants::ICON_FOLDER);
|
icon = QIcon(Constants::ICON_FOLDER);
|
||||||
}
|
}
|
||||||
setData(Qt::DecorationRole, icon);
|
setData(Qt::DecorationRole, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimitiveNode::~PrimitiveNode()
|
PrimitiveNode::~PrimitiveNode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NLLIGO::IPrimitive *PrimitiveNode::primitive() const
|
NLLIGO::IPrimitive *PrimitiveNode::primitive() const
|
||||||
{
|
{
|
||||||
return m_primitive;
|
return m_primitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NLLIGO::CPrimitiveClass *PrimitiveNode::primitiveClass() const
|
const NLLIGO::CPrimitiveClass *PrimitiveNode::primitiveClass() const
|
||||||
{
|
{
|
||||||
return Utils::ligoConfig()->getPrimitiveClass(*m_primitive);
|
return Utils::ligoConfig()->getPrimitiveClass(*m_primitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
RootPrimitiveNode *PrimitiveNode::rootPrimitiveNode()
|
RootPrimitiveNode *PrimitiveNode::rootPrimitiveNode()
|
||||||
{
|
{
|
||||||
Node *node = this;
|
Node *node = this;
|
||||||
while (node && (node->type() != Node::RootPrimitiveNodeType))
|
while (node && (node->type() != Node::RootPrimitiveNodeType))
|
||||||
node = node->parent();
|
node = node->parent();
|
||||||
return static_cast<RootPrimitiveNode *>(node);
|
return static_cast<RootPrimitiveNode *>(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::NodeType PrimitiveNode::type() const
|
Node::NodeType PrimitiveNode::type() const
|
||||||
{
|
{
|
||||||
return PrimitiveNodeType;
|
return PrimitiveNodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootPrimitiveNode::RootPrimitiveNode(const QString &name, NLLIGO::CPrimitives *primitives)
|
RootPrimitiveNode::RootPrimitiveNode(const QString &name, NLLIGO::CPrimitives *primitives)
|
||||||
: PrimitiveNode(primitives->RootNode),
|
: PrimitiveNode(primitives->RootNode),
|
||||||
m_fileName(name),
|
m_fileName(name),
|
||||||
m_primitives(primitives)
|
m_primitives(primitives)
|
||||||
{
|
{
|
||||||
setData(Qt::DisplayRole, name);
|
setData(Qt::DisplayRole, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
RootPrimitiveNode::~RootPrimitiveNode()
|
RootPrimitiveNode::~RootPrimitiveNode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NLLIGO::CPrimitives *RootPrimitiveNode::primitives() const
|
NLLIGO::CPrimitives *RootPrimitiveNode::primitives() const
|
||||||
{
|
{
|
||||||
return m_primitives;
|
return m_primitives;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RootPrimitiveNode::setFileName(const QString &fileName)
|
void RootPrimitiveNode::setFileName(const QString &fileName)
|
||||||
{
|
{
|
||||||
setData(Qt::DisplayRole, fileName);
|
setData(Qt::DisplayRole, fileName);
|
||||||
m_fileName = fileName;
|
m_fileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RootPrimitiveNode::fileName() const
|
QString RootPrimitiveNode::fileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::NodeType RootPrimitiveNode::type() const
|
Node::NodeType RootPrimitiveNode::type() const
|
||||||
{
|
{
|
||||||
return RootPrimitiveNodeType;
|
return RootPrimitiveNodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace WorldEditor */
|
} /* namespace WorldEditor */
|
||||||
|
|
|
@ -1,200 +1,200 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#ifndef PRIMITIVE_ITEM_H
|
#ifndef PRIMITIVE_ITEM_H
|
||||||
#define PRIMITIVE_ITEM_H
|
#define PRIMITIVE_ITEM_H
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/ligo/primitive.h>
|
#include <nel/ligo/primitive.h>
|
||||||
#include <nel/ligo/primitive_class.h>
|
#include <nel/ligo/primitive_class.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
{
|
{
|
||||||
class RootPrimitiveNode;
|
class RootPrimitiveNode;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@class Node
|
@class Node
|
||||||
@brief
|
@brief
|
||||||
@details
|
@details
|
||||||
*/
|
*/
|
||||||
class Node
|
class Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum NodeType
|
enum NodeType
|
||||||
{
|
{
|
||||||
BasicNodeType,
|
BasicNodeType,
|
||||||
WorldEditNodeType,
|
WorldEditNodeType,
|
||||||
RootPrimitiveNodeType,
|
RootPrimitiveNodeType,
|
||||||
LandscapeNodeType,
|
LandscapeNodeType,
|
||||||
PrimitiveNodeType,
|
PrimitiveNodeType,
|
||||||
UserNodeType = 1024
|
UserNodeType = 1024
|
||||||
};
|
};
|
||||||
|
|
||||||
Node();
|
Node();
|
||||||
virtual ~Node();
|
virtual ~Node();
|
||||||
|
|
||||||
/// Remove child node from the child list.
|
/// Remove child node from the child list.
|
||||||
void removeChildNode(Node *node);
|
void removeChildNode(Node *node);
|
||||||
|
|
||||||
/// Insert node at the beginning of the list.
|
/// Insert node at the beginning of the list.
|
||||||
void prependChildNode(Node *node);
|
void prependChildNode(Node *node);
|
||||||
|
|
||||||
/// Insert node at the end of the list.
|
/// Insert node at the end of the list.
|
||||||
void appendChildNode(Node *node);
|
void appendChildNode(Node *node);
|
||||||
|
|
||||||
/// Insert node in front of the node pointed to by the pointer before.
|
/// Insert node in front of the node pointed to by the pointer before.
|
||||||
void insertChildNodeBefore(Node *node, Node *before);
|
void insertChildNodeBefore(Node *node, Node *before);
|
||||||
|
|
||||||
/// Insert node in back of the node pointed to by the pointer after.
|
/// Insert node in back of the node pointed to by the pointer after.
|
||||||
void insertChildNodeAfter(Node *node, Node *after);
|
void insertChildNodeAfter(Node *node, Node *after);
|
||||||
|
|
||||||
/// Insert node in pos
|
/// Insert node in pos
|
||||||
void insertChildNode(int pos, Node *node);
|
void insertChildNode(int pos, Node *node);
|
||||||
|
|
||||||
/// Return the node at index position row in the child list.
|
/// Return the node at index position row in the child list.
|
||||||
Node *child(int row);
|
Node *child(int row);
|
||||||
|
|
||||||
/// Return the number of nodes in the list.
|
/// Return the number of nodes in the list.
|
||||||
int childCount() const;
|
int childCount() const;
|
||||||
|
|
||||||
/// Return a row index this node.
|
/// Return a row index this node.
|
||||||
int row() const;
|
int row() const;
|
||||||
|
|
||||||
/// Return a pointer to this node's parent item. If this node does not have a parent, 0 is returned.
|
/// Return a pointer to this node's parent item. If this node does not have a parent, 0 is returned.
|
||||||
Node *parent();
|
Node *parent();
|
||||||
|
|
||||||
/// Set this node's custom data for the key key to value.
|
/// Set this node's custom data for the key key to value.
|
||||||
void setData(int key, const QVariant &data);
|
void setData(int key, const QVariant &data);
|
||||||
|
|
||||||
/// Return this node's custom data for the key key as a QVariant.
|
/// Return this node's custom data for the key key as a QVariant.
|
||||||
QVariant data(int key) const;
|
QVariant data(int key) const;
|
||||||
|
|
||||||
/// Return a type this node.
|
/// Return a type this node.
|
||||||
virtual NodeType type() const;
|
virtual NodeType type() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(Node)
|
Q_DISABLE_COPY(Node)
|
||||||
|
|
||||||
Node *m_parent;
|
Node *m_parent;
|
||||||
QList<Node *> m_children;
|
QList<Node *> m_children;
|
||||||
QHash<int, QVariant> m_data;
|
QHash<int, QVariant> m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@class WorldEditNode
|
@class WorldEditNode
|
||||||
@brief
|
@brief
|
||||||
@details
|
@details
|
||||||
*/
|
*/
|
||||||
class WorldEditNode: public Node
|
class WorldEditNode: public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WorldEditNode(const QString &name);
|
WorldEditNode(const QString &name);
|
||||||
virtual ~WorldEditNode();
|
virtual ~WorldEditNode();
|
||||||
|
|
||||||
void setContext(const QString &name);
|
void setContext(const QString &name);
|
||||||
QString context() const;
|
QString context() const;
|
||||||
void setDataPath(const QString &path);
|
void setDataPath(const QString &path);
|
||||||
QString dataPath() const;
|
QString dataPath() const;
|
||||||
|
|
||||||
virtual NodeType type() const;
|
virtual NodeType type() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_context;
|
QString m_context;
|
||||||
QString m_dataPath;
|
QString m_dataPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@class LandscapeNode
|
@class LandscapeNode
|
||||||
@brief
|
@brief
|
||||||
@details
|
@details
|
||||||
*/
|
*/
|
||||||
class LandscapeNode: public Node
|
class LandscapeNode: public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LandscapeNode(const QString &name, int id);
|
LandscapeNode(const QString &name, int id);
|
||||||
virtual ~LandscapeNode();
|
virtual ~LandscapeNode();
|
||||||
|
|
||||||
int id() const;
|
int id() const;
|
||||||
QString fileName() const;
|
QString fileName() const;
|
||||||
|
|
||||||
virtual NodeType type() const;
|
virtual NodeType type() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
int m_id;
|
int m_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@class PrimitiveNode
|
@class PrimitiveNode
|
||||||
@brief
|
@brief
|
||||||
@details
|
@details
|
||||||
*/
|
*/
|
||||||
class PrimitiveNode: public Node
|
class PrimitiveNode: public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PrimitiveNode(NLLIGO::IPrimitive *primitive);
|
explicit PrimitiveNode(NLLIGO::IPrimitive *primitive);
|
||||||
virtual ~PrimitiveNode();
|
virtual ~PrimitiveNode();
|
||||||
|
|
||||||
NLLIGO::IPrimitive *primitive() const;
|
NLLIGO::IPrimitive *primitive() const;
|
||||||
const NLLIGO::CPrimitiveClass *primitiveClass() const;
|
const NLLIGO::CPrimitiveClass *primitiveClass() const;
|
||||||
RootPrimitiveNode *rootPrimitiveNode();
|
RootPrimitiveNode *rootPrimitiveNode();
|
||||||
|
|
||||||
virtual NodeType type() const;
|
virtual NodeType type() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NLLIGO::IPrimitive *m_primitive;
|
NLLIGO::IPrimitive *m_primitive;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@class RootPrimitiveNode
|
@class RootPrimitiveNode
|
||||||
@brief
|
@brief
|
||||||
@details
|
@details
|
||||||
*/
|
*/
|
||||||
class RootPrimitiveNode: public PrimitiveNode
|
class RootPrimitiveNode: public PrimitiveNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RootPrimitiveNode(const QString &name, NLLIGO::CPrimitives *primitives);
|
RootPrimitiveNode(const QString &name, NLLIGO::CPrimitives *primitives);
|
||||||
virtual ~RootPrimitiveNode();
|
virtual ~RootPrimitiveNode();
|
||||||
|
|
||||||
NLLIGO::CPrimitives *primitives() const;
|
NLLIGO::CPrimitives *primitives() const;
|
||||||
|
|
||||||
void setFileName(const QString &fileName);
|
void setFileName(const QString &fileName);
|
||||||
QString fileName() const;
|
QString fileName() const;
|
||||||
virtual NodeType type() const;
|
virtual NodeType type() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
NLLIGO::CPrimitives *m_primitives;
|
NLLIGO::CPrimitives *m_primitives;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<Node *> NodeList;
|
typedef QList<Node *> NodeList;
|
||||||
|
|
||||||
} /* namespace WorldEditor */
|
} /* namespace WorldEditor */
|
||||||
|
|
||||||
// Enable the use of QVariant with this class.
|
// Enable the use of QVariant with this class.
|
||||||
Q_DECLARE_METATYPE(WorldEditor::Node *)
|
Q_DECLARE_METATYPE(WorldEditor::Node *)
|
||||||
|
|
||||||
#endif // PRIMITIVE_ITEM_H
|
#endif // PRIMITIVE_ITEM_H
|
||||||
|
|
|
@ -1,328 +1,328 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "primitive_item.h"
|
#include "primitive_item.h"
|
||||||
#include "primitives_model.h"
|
#include "primitives_model.h"
|
||||||
#include "world_editor_misc.h"
|
#include "world_editor_misc.h"
|
||||||
#include "world_editor_constants.h"
|
#include "world_editor_constants.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
#include <nel/ligo/primitive.h>
|
#include <nel/ligo/primitive.h>
|
||||||
#include <nel/ligo/primitive_utils.h>
|
#include <nel/ligo/primitive_utils.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
PrimitivesTreeModel::PrimitivesTreeModel(QObject *parent)
|
PrimitivesTreeModel::PrimitivesTreeModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent),
|
: QAbstractItemModel(parent),
|
||||||
m_worldEditNode(0)
|
m_worldEditNode(0)
|
||||||
{
|
{
|
||||||
m_rootNode = new Node();
|
m_rootNode = new Node();
|
||||||
m_rootNode->setData(Qt::DisplayRole, "Name");
|
m_rootNode->setData(Qt::DisplayRole, "Name");
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimitivesTreeModel::~PrimitivesTreeModel()
|
PrimitivesTreeModel::~PrimitivesTreeModel()
|
||||||
{
|
{
|
||||||
delete m_rootNode;
|
delete m_rootNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PrimitivesTreeModel::columnCount(const QModelIndex &parent) const
|
int PrimitivesTreeModel::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
/* if (parent.isValid())
|
/* if (parent.isValid())
|
||||||
return static_cast<BaseTreeItem *>(parent.internalPointer())->columnCount();
|
return static_cast<BaseTreeItem *>(parent.internalPointer())->columnCount();
|
||||||
else
|
else
|
||||||
return m_rootItem->columnCount();
|
return m_rootItem->columnCount();
|
||||||
*/
|
*/
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant PrimitivesTreeModel::data(const QModelIndex &index, int role) const
|
QVariant PrimitivesTreeModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
Node *item = static_cast<Node *>(index.internalPointer());
|
Node *item = static_cast<Node *>(index.internalPointer());
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
// case Qt::TextAlignmentRole:
|
// case Qt::TextAlignmentRole:
|
||||||
// return int(Qt::AlignLeft | Qt::AlignVCenter);
|
// return int(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return item->data(Qt::DisplayRole);
|
return item->data(Qt::DisplayRole);
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
return item->data(Qt::DecorationRole);
|
return item->data(Qt::DecorationRole);
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags PrimitivesTreeModel::flags(const QModelIndex &index) const
|
Qt::ItemFlags PrimitivesTreeModel::flags(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant PrimitivesTreeModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant PrimitivesTreeModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
||||||
// return m_rootNode->data(section);
|
// return m_rootNode->data(section);
|
||||||
return m_rootNode->data(Qt::DisplayRole);
|
return m_rootNode->data(Qt::DisplayRole);
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex PrimitivesTreeModel::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex PrimitivesTreeModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if (!hasIndex(row, column, parent))
|
if (!hasIndex(row, column, parent))
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
Node *parentNode;
|
Node *parentNode;
|
||||||
|
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
parentNode = m_rootNode;
|
parentNode = m_rootNode;
|
||||||
else
|
else
|
||||||
parentNode = static_cast<Node *>(parent.internalPointer());
|
parentNode = static_cast<Node *>(parent.internalPointer());
|
||||||
|
|
||||||
Node *childNode = parentNode->child(row);
|
Node *childNode = parentNode->child(row);
|
||||||
if (childNode)
|
if (childNode)
|
||||||
return createIndex(row, column, childNode);
|
return createIndex(row, column, childNode);
|
||||||
else
|
else
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex PrimitivesTreeModel::parent(const QModelIndex &index) const
|
QModelIndex PrimitivesTreeModel::parent(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
Node *childNode = static_cast<Node *>(index.internalPointer());
|
Node *childNode = static_cast<Node *>(index.internalPointer());
|
||||||
Node *parentNode = childNode->parent();
|
Node *parentNode = childNode->parent();
|
||||||
|
|
||||||
if (parentNode == m_rootNode)
|
if (parentNode == m_rootNode)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
return createIndex(parentNode->row(), 0, parentNode);
|
return createIndex(parentNode->row(), 0, parentNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PrimitivesTreeModel::rowCount(const QModelIndex &parent) const
|
int PrimitivesTreeModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Node *parentNode;
|
Node *parentNode;
|
||||||
if (parent.column() > 0)
|
if (parent.column() > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
parentNode = m_rootNode;
|
parentNode = m_rootNode;
|
||||||
else
|
else
|
||||||
parentNode = static_cast<Node *>(parent.internalPointer());
|
parentNode = static_cast<Node *>(parent.internalPointer());
|
||||||
|
|
||||||
return parentNode->childCount();
|
return parentNode->childCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
Path PrimitivesTreeModel::pathFromIndex(const QModelIndex &index)
|
Path PrimitivesTreeModel::pathFromIndex(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QModelIndex iter = index;
|
QModelIndex iter = index;
|
||||||
Path path;
|
Path path;
|
||||||
while(iter.isValid())
|
while(iter.isValid())
|
||||||
{
|
{
|
||||||
path.prepend(PathItem(iter.row(), iter.column()));
|
path.prepend(PathItem(iter.row(), iter.column()));
|
||||||
iter = iter.parent();
|
iter = iter.parent();
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
Path PrimitivesTreeModel::pathFromNode(Node *node)
|
Path PrimitivesTreeModel::pathFromNode(Node *node)
|
||||||
{
|
{
|
||||||
Node *iter = node;
|
Node *iter = node;
|
||||||
Path path;
|
Path path;
|
||||||
while(iter != 0)
|
while(iter != 0)
|
||||||
{
|
{
|
||||||
path.prepend(PathItem(iter->row(), 0));
|
path.prepend(PathItem(iter->row(), 0));
|
||||||
iter = iter->parent();
|
iter = iter->parent();
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex PrimitivesTreeModel::pathToIndex(const Path &path)
|
QModelIndex PrimitivesTreeModel::pathToIndex(const Path &path)
|
||||||
{
|
{
|
||||||
QModelIndex iter;
|
QModelIndex iter;
|
||||||
for(int i = 0; i < path.size(); i++)
|
for(int i = 0; i < path.size(); i++)
|
||||||
{
|
{
|
||||||
iter = index(path[i].first, path[i].second, iter);
|
iter = index(path[i].first, path[i].second, iter);
|
||||||
}
|
}
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *PrimitivesTreeModel::pathToNode(const Path &path)
|
Node *PrimitivesTreeModel::pathToNode(const Path &path)
|
||||||
{
|
{
|
||||||
Node *node = m_rootNode;
|
Node *node = m_rootNode;
|
||||||
for(int i = 1; i < path.size(); i++)
|
for(int i = 1; i < path.size(); i++)
|
||||||
{
|
{
|
||||||
node = node->child(path[i].first);
|
node = node->child(path[i].first);
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesTreeModel::createWorldEditNode(const QString &fileName)
|
void PrimitivesTreeModel::createWorldEditNode(const QString &fileName)
|
||||||
{
|
{
|
||||||
// World edit node already is created, if yes is showing error message box
|
// World edit node already is created, if yes is showing error message box
|
||||||
if (m_worldEditNode != 0)
|
if (m_worldEditNode != 0)
|
||||||
nlerror("World edit node already is created.");
|
nlerror("World edit node already is created.");
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_worldEditNode = new WorldEditNode(fileName);
|
m_worldEditNode = new WorldEditNode(fileName);
|
||||||
m_rootNode->appendChildNode(m_worldEditNode);
|
m_rootNode->appendChildNode(m_worldEditNode);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesTreeModel::deleteWorldEditNode()
|
void PrimitivesTreeModel::deleteWorldEditNode()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
if (m_worldEditNode != 0)
|
if (m_worldEditNode != 0)
|
||||||
{
|
{
|
||||||
delete m_worldEditNode;
|
delete m_worldEditNode;
|
||||||
m_worldEditNode = 0;
|
m_worldEditNode = 0;
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrimitivesTreeModel::isWorldEditNodeLoaded() const
|
bool PrimitivesTreeModel::isWorldEditNodeLoaded() const
|
||||||
{
|
{
|
||||||
if (m_worldEditNode == 0)
|
if (m_worldEditNode == 0)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Path PrimitivesTreeModel::createLandscapeNode(const QString &fileName, int id, int pos)
|
Path PrimitivesTreeModel::createLandscapeNode(const QString &fileName, int id, int pos)
|
||||||
{
|
{
|
||||||
if (m_worldEditNode == 0)
|
if (m_worldEditNode == 0)
|
||||||
createWorldEditNode("NewWorldEdit");
|
createWorldEditNode("NewWorldEdit");
|
||||||
|
|
||||||
QModelIndex parentIndex = index(0, 0, QModelIndex());
|
QModelIndex parentIndex = index(0, 0, QModelIndex());
|
||||||
int insPos = pos;
|
int insPos = pos;
|
||||||
if (pos == -1)
|
if (pos == -1)
|
||||||
insPos = 0;
|
insPos = 0;
|
||||||
|
|
||||||
beginInsertRows(parentIndex, insPos, insPos);
|
beginInsertRows(parentIndex, insPos, insPos);
|
||||||
LandscapeNode *newNode = new LandscapeNode(fileName, id);
|
LandscapeNode *newNode = new LandscapeNode(fileName, id);
|
||||||
m_worldEditNode->insertChildNode(insPos, newNode);
|
m_worldEditNode->insertChildNode(insPos, newNode);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
return pathFromIndex(index(0, 0, index(insPos, 0, QModelIndex())));
|
return pathFromIndex(index(0, 0, index(insPos, 0, QModelIndex())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path PrimitivesTreeModel::createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives, int pos)
|
Path PrimitivesTreeModel::createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives, int pos)
|
||||||
{
|
{
|
||||||
if (m_worldEditNode == 0)
|
if (m_worldEditNode == 0)
|
||||||
createWorldEditNode("NewWorldEdit");
|
createWorldEditNode("NewWorldEdit");
|
||||||
|
|
||||||
QString name = "NewPrimitive";
|
QString name = "NewPrimitive";
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
name = fileName;
|
name = fileName;
|
||||||
|
|
||||||
int insPos = pos;
|
int insPos = pos;
|
||||||
|
|
||||||
// Get position
|
// Get position
|
||||||
if (pos == AtTheEnd)
|
if (pos == AtTheEnd)
|
||||||
insPos = m_worldEditNode->childCount();
|
insPos = m_worldEditNode->childCount();
|
||||||
|
|
||||||
QModelIndex parentIndex = index(0, 0, QModelIndex());
|
QModelIndex parentIndex = index(0, 0, QModelIndex());
|
||||||
|
|
||||||
// Add root node in tree model
|
// Add root node in tree model
|
||||||
beginInsertRows(parentIndex, insPos, insPos);
|
beginInsertRows(parentIndex, insPos, insPos);
|
||||||
RootPrimitiveNode *newNode = new RootPrimitiveNode(name, primitives);
|
RootPrimitiveNode *newNode = new RootPrimitiveNode(name, primitives);
|
||||||
m_worldEditNode->insertChildNode(insPos, newNode);
|
m_worldEditNode->insertChildNode(insPos, newNode);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
newNode->setData(Constants::PRIMITIVE_FILE_IS_CREATED, !fileName.isEmpty());
|
newNode->setData(Constants::PRIMITIVE_FILE_IS_CREATED, !fileName.isEmpty());
|
||||||
newNode->setData(Constants::PRIMITIVE_IS_MODIFIED, false);
|
newNode->setData(Constants::PRIMITIVE_IS_MODIFIED, false);
|
||||||
|
|
||||||
QModelIndex rootPrimIndex = index(insPos, 0, parentIndex);
|
QModelIndex rootPrimIndex = index(insPos, 0, parentIndex);
|
||||||
|
|
||||||
// Scan childs items and add in the tree model
|
// Scan childs items and add in the tree model
|
||||||
for (uint i = 0; i < primitives->RootNode->getNumChildren(); ++i)
|
for (uint i = 0; i < primitives->RootNode->getNumChildren(); ++i)
|
||||||
{
|
{
|
||||||
NLLIGO::IPrimitive *childPrim;
|
NLLIGO::IPrimitive *childPrim;
|
||||||
primitives->RootNode->getChild(childPrim, i);
|
primitives->RootNode->getChild(childPrim, i);
|
||||||
createChildNodes(childPrim, i, rootPrimIndex);
|
createChildNodes(childPrim, i, rootPrimIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pathFromIndex(rootPrimIndex);
|
return pathFromIndex(rootPrimIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Path PrimitivesTreeModel::createPrimitiveNode(NLLIGO::IPrimitive *primitive, const Path &parent, int pos)
|
Path PrimitivesTreeModel::createPrimitiveNode(NLLIGO::IPrimitive *primitive, const Path &parent, int pos)
|
||||||
{
|
{
|
||||||
QModelIndex parentIndex = pathToIndex(parent);
|
QModelIndex parentIndex = pathToIndex(parent);
|
||||||
Node *parentNode = static_cast<Node *>(parentIndex.internalPointer());
|
Node *parentNode = static_cast<Node *>(parentIndex.internalPointer());
|
||||||
|
|
||||||
int insPos = pos;
|
int insPos = pos;
|
||||||
if (pos == AtTheEnd)
|
if (pos == AtTheEnd)
|
||||||
insPos = parentNode->childCount();
|
insPos = parentNode->childCount();
|
||||||
|
|
||||||
createChildNodes(primitive, insPos, parentIndex);
|
createChildNodes(primitive, insPos, parentIndex);
|
||||||
|
|
||||||
return pathFromIndex(index(insPos, 0, parentIndex));
|
return pathFromIndex(index(insPos, 0, parentIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesTreeModel::deleteNode(const Path &path)
|
void PrimitivesTreeModel::deleteNode(const Path &path)
|
||||||
{
|
{
|
||||||
QModelIndex nodeIndex = pathToIndex(path);
|
QModelIndex nodeIndex = pathToIndex(path);
|
||||||
QModelIndex parentIndex = nodeIndex.parent();
|
QModelIndex parentIndex = nodeIndex.parent();
|
||||||
Node *node = static_cast<Node *>(nodeIndex.internalPointer());
|
Node *node = static_cast<Node *>(nodeIndex.internalPointer());
|
||||||
|
|
||||||
// Scan childs items and delete from the tree model
|
// Scan childs items and delete from the tree model
|
||||||
removeChildNodes(node, parentIndex);
|
removeChildNodes(node, parentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesTreeModel::createChildNodes(NLLIGO::IPrimitive *primitive, int pos, const QModelIndex &parent)
|
void PrimitivesTreeModel::createChildNodes(NLLIGO::IPrimitive *primitive, int pos, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
Node *parentNode = static_cast<Node *>(parent.internalPointer());
|
Node *parentNode = static_cast<Node *>(parent.internalPointer());
|
||||||
|
|
||||||
// Add node in the tree model
|
// Add node in the tree model
|
||||||
beginInsertRows(parent, pos, pos);
|
beginInsertRows(parent, pos, pos);
|
||||||
PrimitiveNode *newNode = new PrimitiveNode(primitive);
|
PrimitiveNode *newNode = new PrimitiveNode(primitive);
|
||||||
parentNode->insertChildNode(pos, newNode);
|
parentNode->insertChildNode(pos, newNode);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
// Scan childs items and add in the tree model
|
// Scan childs items and add in the tree model
|
||||||
QModelIndex childIndex = index(pos, 0, parent);
|
QModelIndex childIndex = index(pos, 0, parent);
|
||||||
for (uint i = 0; i < primitive->getNumChildren(); ++i)
|
for (uint i = 0; i < primitive->getNumChildren(); ++i)
|
||||||
{
|
{
|
||||||
NLLIGO::IPrimitive *childPrim;
|
NLLIGO::IPrimitive *childPrim;
|
||||||
primitive->getChild(childPrim, i);
|
primitive->getChild(childPrim, i);
|
||||||
createChildNodes(childPrim, i, childIndex);
|
createChildNodes(childPrim, i, childIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesTreeModel::removeChildNodes(Node *node, const QModelIndex &parent)
|
void PrimitivesTreeModel::removeChildNodes(Node *node, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
// Delete all child nodes from the tree model
|
// Delete all child nodes from the tree model
|
||||||
while (node->childCount() != 0)
|
while (node->childCount() != 0)
|
||||||
removeChildNodes(node->child(node->childCount() - 1), parent.child(node->row(), 0));
|
removeChildNodes(node->child(node->childCount() - 1), parent.child(node->row(), 0));
|
||||||
|
|
||||||
// Delete node from the tree model
|
// Delete node from the tree model
|
||||||
beginRemoveRows(parent, node->row(), node->row());
|
beginRemoveRows(parent, node->row(), node->row());
|
||||||
delete node;
|
delete node;
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace WorldEditor */
|
} /* namespace WorldEditor */
|
|
@ -1,104 +1,104 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
#ifndef PRIMITIVES_MODEL_H
|
#ifndef PRIMITIVES_MODEL_H
|
||||||
#define PRIMITIVES_MODEL_H
|
#define PRIMITIVES_MODEL_H
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/vector.h>
|
#include <nel/misc/vector.h>
|
||||||
#include <nel/ligo/primitive.h>
|
#include <nel/ligo/primitive.h>
|
||||||
#include <nel/ligo/primitive_class.h>
|
#include <nel/ligo/primitive_class.h>
|
||||||
#include <nel/ligo/ligo_config.h>
|
#include <nel/ligo/ligo_config.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
{
|
{
|
||||||
class Node;
|
class Node;
|
||||||
class WorldEditNode;
|
class WorldEditNode;
|
||||||
|
|
||||||
const int AtTheEnd = -1;
|
const int AtTheEnd = -1;
|
||||||
|
|
||||||
typedef QPair<int, int> PathItem;
|
typedef QPair<int, int> PathItem;
|
||||||
/*
|
/*
|
||||||
@typedef Path
|
@typedef Path
|
||||||
@brief It store a list of row and column numbers which have to walk through from the root index of the model to reach the need item.
|
@brief It store a list of row and column numbers which have to walk through from the root index of the model to reach the need item.
|
||||||
It is used for undo/redo commands.
|
It is used for undo/redo commands.
|
||||||
*/
|
*/
|
||||||
typedef QList<PathItem> Path;
|
typedef QList<PathItem> Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class PrimitivesTreeModel
|
@class PrimitivesTreeModel
|
||||||
@brief
|
@brief
|
||||||
@details
|
@details
|
||||||
*/
|
*/
|
||||||
class PrimitivesTreeModel : public QAbstractItemModel
|
class PrimitivesTreeModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PrimitivesTreeModel(QObject *parent = 0);
|
explicit PrimitivesTreeModel(QObject *parent = 0);
|
||||||
~PrimitivesTreeModel();
|
~PrimitivesTreeModel();
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
int role = Qt::DisplayRole) const;
|
int role = Qt::DisplayRole) const;
|
||||||
QModelIndex index(int row, int column,
|
QModelIndex index(int row, int column,
|
||||||
const QModelIndex &parent = QModelIndex()) const;
|
const QModelIndex &parent = QModelIndex()) const;
|
||||||
QModelIndex parent(const QModelIndex &index) const;
|
QModelIndex parent(const QModelIndex &index) const;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
|
||||||
/// Convert QModelIndex to the persistent index - @Path.
|
/// Convert QModelIndex to the persistent index - @Path.
|
||||||
/// @Path is a list of [row,column] pairs showing us the way through the model.
|
/// @Path is a list of [row,column] pairs showing us the way through the model.
|
||||||
Path pathFromIndex(const QModelIndex &index);
|
Path pathFromIndex(const QModelIndex &index);
|
||||||
QModelIndex pathToIndex(const Path &path);
|
QModelIndex pathToIndex(const Path &path);
|
||||||
|
|
||||||
Path pathFromNode(Node *node);
|
Path pathFromNode(Node *node);
|
||||||
Node *pathToNode(const Path &path);
|
Node *pathToNode(const Path &path);
|
||||||
|
|
||||||
void createWorldEditNode(const QString &fileName);
|
void createWorldEditNode(const QString &fileName);
|
||||||
void deleteWorldEditNode();
|
void deleteWorldEditNode();
|
||||||
bool isWorldEditNodeLoaded() const;
|
bool isWorldEditNodeLoaded() const;
|
||||||
|
|
||||||
/// Add new landscape node in tree model.
|
/// Add new landscape node in tree model.
|
||||||
Path createLandscapeNode(const QString &fileName, int id, int pos = AtTheEnd);
|
Path createLandscapeNode(const QString &fileName, int id, int pos = AtTheEnd);
|
||||||
|
|
||||||
/// Add new root primitive node and all sub-primitives in the tree model.
|
/// Add new root primitive node and all sub-primitives in the tree model.
|
||||||
Path createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives, int pos = AtTheEnd);
|
Path createRootPrimitiveNode(const QString &fileName, NLLIGO::CPrimitives *primitives, int pos = AtTheEnd);
|
||||||
|
|
||||||
/// Add new primitive node and all sub-primitives in the tree model.
|
/// Add new primitive node and all sub-primitives in the tree model.
|
||||||
Path createPrimitiveNode(NLLIGO::IPrimitive *primitive, const Path &parent, int pos = AtTheEnd);
|
Path createPrimitiveNode(NLLIGO::IPrimitive *primitive, const Path &parent, int pos = AtTheEnd);
|
||||||
|
|
||||||
/// Delete node and all child nodes from the tree model
|
/// Delete node and all child nodes from the tree model
|
||||||
void deleteNode(const Path &path);
|
void deleteNode(const Path &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createChildNodes(NLLIGO::IPrimitive *primitive, int pos, const QModelIndex &parent);
|
void createChildNodes(NLLIGO::IPrimitive *primitive, int pos, const QModelIndex &parent);
|
||||||
void removeChildNodes(Node *node, const QModelIndex &parent);
|
void removeChildNodes(Node *node, const QModelIndex &parent);
|
||||||
|
|
||||||
Node *m_rootNode;
|
Node *m_rootNode;
|
||||||
WorldEditNode *m_worldEditNode;
|
WorldEditNode *m_worldEditNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace WorldEditor */
|
} /* namespace WorldEditor */
|
||||||
|
|
||||||
#endif // PRIMITIVES_MODEL_H
|
#endif // PRIMITIVES_MODEL_H
|
||||||
|
|
|
@ -1,458 +1,458 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "primitives_view.h"
|
#include "primitives_view.h"
|
||||||
#include "primitives_model.h"
|
#include "primitives_model.h"
|
||||||
#include "world_editor_actions.h"
|
#include "world_editor_actions.h"
|
||||||
#include "world_editor_constants.h"
|
#include "world_editor_constants.h"
|
||||||
|
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
#include "../landscape_editor/landscape_editor_constants.h"
|
#include "../landscape_editor/landscape_editor_constants.h"
|
||||||
#include "../landscape_editor/builder_zone_base.h"
|
#include "../landscape_editor/builder_zone_base.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/ligo/primitive.h>
|
#include <nel/ligo/primitive.h>
|
||||||
#include <nel/ligo/ligo_config.h>
|
#include <nel/ligo/ligo_config.h>
|
||||||
#include <nel/ligo/primitive_class.h>
|
#include <nel/ligo/primitive_class.h>
|
||||||
#include <nel/ligo/primitive_utils.h>
|
#include <nel/ligo/primitive_utils.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
PrimitivesView::PrimitivesView(QWidget *parent)
|
PrimitivesView::PrimitivesView(QWidget *parent)
|
||||||
: QTreeView(parent),
|
: QTreeView(parent),
|
||||||
m_undoStack(0),
|
m_undoStack(0),
|
||||||
m_worldEditorScene(0),
|
m_worldEditorScene(0),
|
||||||
m_zoneBuilder(0),
|
m_zoneBuilder(0),
|
||||||
m_primitivesTreeModel(0)
|
m_primitivesTreeModel(0)
|
||||||
{
|
{
|
||||||
setContextMenuPolicy(Qt::DefaultContextMenu);
|
setContextMenuPolicy(Qt::DefaultContextMenu);
|
||||||
|
|
||||||
m_unloadAction = new QAction("Unload", this);
|
m_unloadAction = new QAction("Unload", this);
|
||||||
|
|
||||||
m_saveAction = new QAction("Save", this);
|
m_saveAction = new QAction("Save", this);
|
||||||
m_saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
m_saveAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
||||||
|
|
||||||
m_saveAsAction = new QAction("Save As...", this);
|
m_saveAsAction = new QAction("Save As...", this);
|
||||||
m_saveAsAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS));
|
m_saveAsAction->setIcon(QIcon(Core::Constants::ICON_SAVE_AS));
|
||||||
|
|
||||||
m_loadLandAction = new QAction("Load landscape file", this);
|
m_loadLandAction = new QAction("Load landscape file", this);
|
||||||
m_loadLandAction->setIcon(QIcon(LandscapeEditor::Constants::ICON_ZONE_ITEM));
|
m_loadLandAction->setIcon(QIcon(LandscapeEditor::Constants::ICON_ZONE_ITEM));
|
||||||
|
|
||||||
m_loadPrimitiveAction = new QAction("Load primitive file", this);
|
m_loadPrimitiveAction = new QAction("Load primitive file", this);
|
||||||
m_loadPrimitiveAction->setIcon(QIcon(Constants::ICON_ROOT_PRIMITIVE));
|
m_loadPrimitiveAction->setIcon(QIcon(Constants::ICON_ROOT_PRIMITIVE));
|
||||||
|
|
||||||
m_newPrimitiveAction = new QAction("New primitive", this);
|
m_newPrimitiveAction = new QAction("New primitive", this);
|
||||||
|
|
||||||
m_deleteAction = new QAction("Delete", this);
|
m_deleteAction = new QAction("Delete", this);
|
||||||
|
|
||||||
m_selectChildrenAction = new QAction("Select children", this);
|
m_selectChildrenAction = new QAction("Select children", this);
|
||||||
|
|
||||||
m_helpAction = new QAction("Help", this);
|
m_helpAction = new QAction("Help", this);
|
||||||
m_helpAction->setEnabled(false);
|
m_helpAction->setEnabled(false);
|
||||||
|
|
||||||
m_showAction = new QAction("Show", this);
|
m_showAction = new QAction("Show", this);
|
||||||
m_showAction->setEnabled(false);
|
m_showAction->setEnabled(false);
|
||||||
|
|
||||||
m_hideAction = new QAction("Hide", this);
|
m_hideAction = new QAction("Hide", this);
|
||||||
m_hideAction->setEnabled(false);
|
m_hideAction->setEnabled(false);
|
||||||
|
|
||||||
connect(m_loadLandAction, SIGNAL(triggered()), this, SLOT(loadLandscape()));
|
connect(m_loadLandAction, SIGNAL(triggered()), this, SLOT(loadLandscape()));
|
||||||
connect(m_loadPrimitiveAction, SIGNAL(triggered()), this, SLOT(loadRootPrimitive()));
|
connect(m_loadPrimitiveAction, SIGNAL(triggered()), this, SLOT(loadRootPrimitive()));
|
||||||
connect(m_newPrimitiveAction, SIGNAL(triggered()), this, SLOT(createRootPrimitive()));
|
connect(m_newPrimitiveAction, SIGNAL(triggered()), this, SLOT(createRootPrimitive()));
|
||||||
connect(m_selectChildrenAction, SIGNAL(triggered()), this, SLOT(selectChildren()));
|
connect(m_selectChildrenAction, SIGNAL(triggered()), this, SLOT(selectChildren()));
|
||||||
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deletePrimitives()));
|
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deletePrimitives()));
|
||||||
connect(m_saveAction, SIGNAL(triggered()), this, SLOT(save()));
|
connect(m_saveAction, SIGNAL(triggered()), this, SLOT(save()));
|
||||||
connect(m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));
|
connect(m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));
|
||||||
connect(m_unloadAction, SIGNAL(triggered()), this, SLOT(unload()));
|
connect(m_unloadAction, SIGNAL(triggered()), this, SLOT(unload()));
|
||||||
connect(m_showAction, SIGNAL(triggered()), this, SLOT(showPrimitive()));
|
connect(m_showAction, SIGNAL(triggered()), this, SLOT(showPrimitive()));
|
||||||
connect(m_hideAction, SIGNAL(triggered()), this, SLOT(hidePrimitive()));
|
connect(m_hideAction, SIGNAL(triggered()), this, SLOT(hidePrimitive()));
|
||||||
|
|
||||||
#ifdef Q_OS_DARWIN
|
#ifdef Q_OS_DARWIN
|
||||||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimitivesView::~PrimitivesView()
|
PrimitivesView::~PrimitivesView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::setUndoStack(QUndoStack *undoStack)
|
void PrimitivesView::setUndoStack(QUndoStack *undoStack)
|
||||||
{
|
{
|
||||||
m_undoStack = undoStack;
|
m_undoStack = undoStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::setZoneBuilder(LandscapeEditor::ZoneBuilderBase *zoneBuilder)
|
void PrimitivesView::setZoneBuilder(LandscapeEditor::ZoneBuilderBase *zoneBuilder)
|
||||||
{
|
{
|
||||||
m_zoneBuilder = zoneBuilder;
|
m_zoneBuilder = zoneBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::setWorldScene(WorldEditorScene *worldEditorScene)
|
void PrimitivesView::setWorldScene(WorldEditorScene *worldEditorScene)
|
||||||
{
|
{
|
||||||
m_worldEditorScene = worldEditorScene;
|
m_worldEditorScene = worldEditorScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::setModel(PrimitivesTreeModel *model)
|
void PrimitivesView::setModel(PrimitivesTreeModel *model)
|
||||||
{
|
{
|
||||||
QTreeView::setModel(model);
|
QTreeView::setModel(model);
|
||||||
m_primitivesTreeModel = model;
|
m_primitivesTreeModel = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::loadRootPrimitive()
|
void PrimitivesView::loadRootPrimitive()
|
||||||
{
|
{
|
||||||
nlassert(m_undoStack);
|
nlassert(m_undoStack);
|
||||||
nlassert(m_primitivesTreeModel);
|
nlassert(m_primitivesTreeModel);
|
||||||
|
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this,
|
QStringList fileNames = QFileDialog::getOpenFileNames(this,
|
||||||
tr("Open NeL Ligo primitive file"), m_lastDir,
|
tr("Open NeL Ligo primitive file"), m_lastDir,
|
||||||
tr("All NeL Ligo primitive files (*.primitive)"));
|
tr("All NeL Ligo primitive files (*.primitive)"));
|
||||||
|
|
||||||
setCursor(Qt::WaitCursor);
|
setCursor(Qt::WaitCursor);
|
||||||
if (!fileNames.isEmpty())
|
if (!fileNames.isEmpty())
|
||||||
{
|
{
|
||||||
if (fileNames.count() > 1)
|
if (fileNames.count() > 1)
|
||||||
m_undoStack->beginMacro(tr("Load primitive files"));
|
m_undoStack->beginMacro(tr("Load primitive files"));
|
||||||
|
|
||||||
Q_FOREACH(QString fileName, fileNames)
|
Q_FOREACH(QString fileName, fileNames)
|
||||||
{
|
{
|
||||||
m_lastDir = QFileInfo(fileName).absolutePath();
|
m_lastDir = QFileInfo(fileName).absolutePath();
|
||||||
m_undoStack->push(new LoadRootPrimitiveCommand(fileName, m_worldEditorScene, m_primitivesTreeModel, this));
|
m_undoStack->push(new LoadRootPrimitiveCommand(fileName, m_worldEditorScene, m_primitivesTreeModel, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileNames.count() > 1)
|
if (fileNames.count() > 1)
|
||||||
m_undoStack->endMacro();
|
m_undoStack->endMacro();
|
||||||
}
|
}
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::loadLandscape()
|
void PrimitivesView::loadLandscape()
|
||||||
{
|
{
|
||||||
nlassert(m_undoStack);
|
nlassert(m_undoStack);
|
||||||
nlassert(m_zoneBuilder);
|
nlassert(m_zoneBuilder);
|
||||||
nlassert(m_primitivesTreeModel);
|
nlassert(m_primitivesTreeModel);
|
||||||
|
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this,
|
QStringList fileNames = QFileDialog::getOpenFileNames(this,
|
||||||
tr("Open NeL Ligo land file"), m_lastDir,
|
tr("Open NeL Ligo land file"), m_lastDir,
|
||||||
tr("All NeL Ligo land files (*.land)"));
|
tr("All NeL Ligo land files (*.land)"));
|
||||||
|
|
||||||
setCursor(Qt::WaitCursor);
|
setCursor(Qt::WaitCursor);
|
||||||
if (!fileNames.isEmpty())
|
if (!fileNames.isEmpty())
|
||||||
{
|
{
|
||||||
if (fileNames.count() > 1)
|
if (fileNames.count() > 1)
|
||||||
m_undoStack->beginMacro(tr("Load land files"));
|
m_undoStack->beginMacro(tr("Load land files"));
|
||||||
|
|
||||||
Q_FOREACH(QString fileName, fileNames)
|
Q_FOREACH(QString fileName, fileNames)
|
||||||
{
|
{
|
||||||
m_lastDir = QFileInfo(fileName).absolutePath();
|
m_lastDir = QFileInfo(fileName).absolutePath();
|
||||||
m_undoStack->push(new LoadLandscapeCommand(fileName, m_primitivesTreeModel, m_zoneBuilder));
|
m_undoStack->push(new LoadLandscapeCommand(fileName, m_primitivesTreeModel, m_zoneBuilder));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileNames.count() > 1)
|
if (fileNames.count() > 1)
|
||||||
m_undoStack->endMacro();
|
m_undoStack->endMacro();
|
||||||
}
|
}
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::createRootPrimitive()
|
void PrimitivesView::createRootPrimitive()
|
||||||
{
|
{
|
||||||
nlassert(m_undoStack);
|
nlassert(m_undoStack);
|
||||||
nlassert(m_primitivesTreeModel);
|
nlassert(m_primitivesTreeModel);
|
||||||
|
|
||||||
m_undoStack->push(new CreateRootPrimitiveCommand("NewPrimitive", m_primitivesTreeModel));
|
m_undoStack->push(new CreateRootPrimitiveCommand("NewPrimitive", m_primitivesTreeModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::selectChildren()
|
void PrimitivesView::selectChildren()
|
||||||
{
|
{
|
||||||
QModelIndexList indexList = selectionModel()->selectedRows();
|
QModelIndexList indexList = selectionModel()->selectedRows();
|
||||||
QModelIndex parentIndex = indexList.first();
|
QModelIndex parentIndex = indexList.first();
|
||||||
|
|
||||||
selectionModel()->clearSelection();
|
selectionModel()->clearSelection();
|
||||||
|
|
||||||
QItemSelection itemSelection;
|
QItemSelection itemSelection;
|
||||||
selectChildren(parentIndex, itemSelection);
|
selectChildren(parentIndex, itemSelection);
|
||||||
selectionModel()->select(itemSelection, QItemSelectionModel::Select);
|
selectionModel()->select(itemSelection, QItemSelectionModel::Select);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::save()
|
void PrimitivesView::save()
|
||||||
{
|
{
|
||||||
nlassert(m_primitivesTreeModel);
|
nlassert(m_primitivesTreeModel);
|
||||||
|
|
||||||
QModelIndexList indexList = selectionModel()->selectedRows();
|
QModelIndexList indexList = selectionModel()->selectedRows();
|
||||||
QModelIndex index = indexList.first();
|
QModelIndex index = indexList.first();
|
||||||
|
|
||||||
RootPrimitiveNode *node = static_cast<RootPrimitiveNode *>(index.internalPointer());
|
RootPrimitiveNode *node = static_cast<RootPrimitiveNode *>(index.internalPointer());
|
||||||
|
|
||||||
if (node->data(Constants::PRIMITIVE_FILE_IS_CREATED).toBool())
|
if (node->data(Constants::PRIMITIVE_FILE_IS_CREATED).toBool())
|
||||||
{
|
{
|
||||||
if (!NLLIGO::saveXmlPrimitiveFile(*node->primitives(), node->fileName().toStdString()))
|
if (!NLLIGO::saveXmlPrimitiveFile(*node->primitives(), node->fileName().toStdString()))
|
||||||
QMessageBox::warning(this, "World Editor Qt", tr("Error writing output file: %1").arg(node->fileName()));
|
QMessageBox::warning(this, "World Editor Qt", tr("Error writing output file: %1").arg(node->fileName()));
|
||||||
else
|
else
|
||||||
node->setData(Constants::PRIMITIVE_IS_MODIFIED, false);
|
node->setData(Constants::PRIMITIVE_IS_MODIFIED, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
saveAs();
|
saveAs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::saveAs()
|
void PrimitivesView::saveAs()
|
||||||
{
|
{
|
||||||
nlassert(m_primitivesTreeModel);
|
nlassert(m_primitivesTreeModel);
|
||||||
|
|
||||||
QString fileName = QFileDialog::getSaveFileName(this,
|
QString fileName = QFileDialog::getSaveFileName(this,
|
||||||
tr("Save NeL Ligo primitive file"), m_lastDir,
|
tr("Save NeL Ligo primitive file"), m_lastDir,
|
||||||
tr("NeL Ligo primitive file (*.primitive)"));
|
tr("NeL Ligo primitive file (*.primitive)"));
|
||||||
|
|
||||||
setCursor(Qt::WaitCursor);
|
setCursor(Qt::WaitCursor);
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
{
|
{
|
||||||
QModelIndexList indexList = selectionModel()->selectedRows();
|
QModelIndexList indexList = selectionModel()->selectedRows();
|
||||||
QModelIndex index = indexList.first();
|
QModelIndex index = indexList.first();
|
||||||
|
|
||||||
RootPrimitiveNode *node = static_cast<RootPrimitiveNode *>(index.internalPointer());
|
RootPrimitiveNode *node = static_cast<RootPrimitiveNode *>(index.internalPointer());
|
||||||
|
|
||||||
if (!NLLIGO::saveXmlPrimitiveFile(*node->primitives(), fileName.toStdString()))
|
if (!NLLIGO::saveXmlPrimitiveFile(*node->primitives(), fileName.toStdString()))
|
||||||
QMessageBox::warning(this, "World Editor Qt", tr("Error writing output file: %1").arg(fileName));
|
QMessageBox::warning(this, "World Editor Qt", tr("Error writing output file: %1").arg(fileName));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node->setFileName(fileName);
|
node->setFileName(fileName);
|
||||||
node->setData(Constants::PRIMITIVE_FILE_IS_CREATED, true);
|
node->setData(Constants::PRIMITIVE_FILE_IS_CREATED, true);
|
||||||
node->setData(Constants::PRIMITIVE_IS_MODIFIED, false);
|
node->setData(Constants::PRIMITIVE_IS_MODIFIED, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::deletePrimitives()
|
void PrimitivesView::deletePrimitives()
|
||||||
{
|
{
|
||||||
nlassert(m_undoStack);
|
nlassert(m_undoStack);
|
||||||
nlassert(m_primitivesTreeModel);
|
nlassert(m_primitivesTreeModel);
|
||||||
|
|
||||||
QModelIndexList indexList = selectionModel()->selectedRows();
|
QModelIndexList indexList = selectionModel()->selectedRows();
|
||||||
|
|
||||||
QModelIndex index = indexList.first();
|
QModelIndex index = indexList.first();
|
||||||
|
|
||||||
PrimitiveNode *node = static_cast<PrimitiveNode *>(index.internalPointer());
|
PrimitiveNode *node = static_cast<PrimitiveNode *>(index.internalPointer());
|
||||||
|
|
||||||
if (node->primitiveClass()->Deletable)
|
if (node->primitiveClass()->Deletable)
|
||||||
m_undoStack->push(new DeletePrimitiveCommand(index, m_primitivesTreeModel, m_worldEditorScene, this));
|
m_undoStack->push(new DeletePrimitiveCommand(index, m_primitivesTreeModel, m_worldEditorScene, this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::unload()
|
void PrimitivesView::unload()
|
||||||
{
|
{
|
||||||
nlassert(m_undoStack);
|
nlassert(m_undoStack);
|
||||||
nlassert(m_primitivesTreeModel);
|
nlassert(m_primitivesTreeModel);
|
||||||
|
|
||||||
QModelIndexList indexList = selectionModel()->selectedRows();
|
QModelIndexList indexList = selectionModel()->selectedRows();
|
||||||
QModelIndex index = indexList.first();
|
QModelIndex index = indexList.first();
|
||||||
Node *node = static_cast<Node *>(index.internalPointer());
|
Node *node = static_cast<Node *>(index.internalPointer());
|
||||||
switch (node->type())
|
switch (node->type())
|
||||||
{
|
{
|
||||||
case Node::WorldEditNodeType:
|
case Node::WorldEditNodeType:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Node::LandscapeNodeType:
|
case Node::LandscapeNodeType:
|
||||||
{
|
{
|
||||||
m_undoStack->push(new UnloadLandscapeCommand(index, m_primitivesTreeModel, m_zoneBuilder));
|
m_undoStack->push(new UnloadLandscapeCommand(index, m_primitivesTreeModel, m_zoneBuilder));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Node::RootPrimitiveNodeType:
|
case Node::RootPrimitiveNodeType:
|
||||||
{
|
{
|
||||||
m_undoStack->push(new UnloadRootPrimitiveCommand(index, m_worldEditorScene, m_primitivesTreeModel, this));
|
m_undoStack->push(new UnloadRootPrimitiveCommand(index, m_worldEditorScene, m_primitivesTreeModel, this));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::showPrimitive()
|
void PrimitivesView::showPrimitive()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::hidePrimitive()
|
void PrimitivesView::hidePrimitive()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::addNewPrimitiveByClass(int value)
|
void PrimitivesView::addNewPrimitiveByClass(int value)
|
||||||
{
|
{
|
||||||
nlassert(m_undoStack);
|
nlassert(m_undoStack);
|
||||||
nlassert(m_primitivesTreeModel);
|
nlassert(m_primitivesTreeModel);
|
||||||
|
|
||||||
QModelIndexList indexList = selectionModel()->selectedRows();
|
QModelIndexList indexList = selectionModel()->selectedRows();
|
||||||
|
|
||||||
PrimitiveNode *node = static_cast<PrimitiveNode *>(indexList.first().internalPointer());
|
PrimitiveNode *node = static_cast<PrimitiveNode *>(indexList.first().internalPointer());
|
||||||
|
|
||||||
// Get class name
|
// Get class name
|
||||||
QString className = node->primitiveClass()->DynamicChildren[value].ClassName.c_str();
|
QString className = node->primitiveClass()->DynamicChildren[value].ClassName.c_str();
|
||||||
|
|
||||||
m_undoStack->push(new AddPrimitiveByClassCommand(className, m_primitivesTreeModel->pathFromIndex(indexList.first()),
|
m_undoStack->push(new AddPrimitiveByClassCommand(className, m_primitivesTreeModel->pathFromIndex(indexList.first()),
|
||||||
m_worldEditorScene, m_primitivesTreeModel, this));
|
m_worldEditorScene, m_primitivesTreeModel, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::generatePrimitives(int value)
|
void PrimitivesView::generatePrimitives(int value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::openItem(int value)
|
void PrimitivesView::openItem(int value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::contextMenuEvent(QContextMenuEvent *event)
|
void PrimitivesView::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
QWidget::contextMenuEvent(event);
|
QWidget::contextMenuEvent(event);
|
||||||
QModelIndexList indexList = selectionModel()->selectedRows();
|
QModelIndexList indexList = selectionModel()->selectedRows();
|
||||||
if (indexList.size() == 0)
|
if (indexList.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMenu *popurMenu = new QMenu(this);
|
QMenu *popurMenu = new QMenu(this);
|
||||||
|
|
||||||
if (indexList.size() == 1)
|
if (indexList.size() == 1)
|
||||||
{
|
{
|
||||||
Node *node = static_cast<Node *>(indexList.first().internalPointer());
|
Node *node = static_cast<Node *>(indexList.first().internalPointer());
|
||||||
switch (node->type())
|
switch (node->type())
|
||||||
{
|
{
|
||||||
case Node::WorldEditNodeType:
|
case Node::WorldEditNodeType:
|
||||||
fillMenu_WorldEdit(popurMenu);
|
fillMenu_WorldEdit(popurMenu);
|
||||||
break;
|
break;
|
||||||
case Node::RootPrimitiveNodeType:
|
case Node::RootPrimitiveNodeType:
|
||||||
fillMenu_RootPrimitive(popurMenu, indexList.first());
|
fillMenu_RootPrimitive(popurMenu, indexList.first());
|
||||||
break;
|
break;
|
||||||
case Node::LandscapeNodeType:
|
case Node::LandscapeNodeType:
|
||||||
fillMenu_Landscape(popurMenu);
|
fillMenu_Landscape(popurMenu);
|
||||||
break;
|
break;
|
||||||
case Node::PrimitiveNodeType:
|
case Node::PrimitiveNodeType:
|
||||||
fillMenu_Primitive(popurMenu, indexList.first());
|
fillMenu_Primitive(popurMenu, indexList.first());
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
popurMenu->exec(event->globalPos());
|
popurMenu->exec(event->globalPos());
|
||||||
delete popurMenu;
|
delete popurMenu;
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::selectChildren(const QModelIndex &parent, QItemSelection &itemSelection)
|
void PrimitivesView::selectChildren(const QModelIndex &parent, QItemSelection &itemSelection)
|
||||||
{
|
{
|
||||||
const int rowCount = model()->rowCount(parent);
|
const int rowCount = model()->rowCount(parent);
|
||||||
|
|
||||||
QItemSelection mergeItemSelection(parent.child(0, 0), parent.child(rowCount - 1, 0));
|
QItemSelection mergeItemSelection(parent.child(0, 0), parent.child(rowCount - 1, 0));
|
||||||
itemSelection.merge(mergeItemSelection, QItemSelectionModel::Select);
|
itemSelection.merge(mergeItemSelection, QItemSelectionModel::Select);
|
||||||
|
|
||||||
for (int i = 0; i < rowCount; ++i)
|
for (int i = 0; i < rowCount; ++i)
|
||||||
{
|
{
|
||||||
QModelIndex childIndex = parent.child(i, 0);
|
QModelIndex childIndex = parent.child(i, 0);
|
||||||
if (model()->rowCount(childIndex) != 0)
|
if (model()->rowCount(childIndex) != 0)
|
||||||
selectChildren(childIndex, itemSelection);
|
selectChildren(childIndex, itemSelection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::fillMenu_WorldEdit(QMenu *menu)
|
void PrimitivesView::fillMenu_WorldEdit(QMenu *menu)
|
||||||
{
|
{
|
||||||
//menu->addAction(m_unloadAction);
|
//menu->addAction(m_unloadAction);
|
||||||
//menu->addAction(m_saveAction);
|
//menu->addAction(m_saveAction);
|
||||||
//menu->addAction(m_saveAsAction);
|
//menu->addAction(m_saveAsAction);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(m_loadLandAction);
|
menu->addAction(m_loadLandAction);
|
||||||
menu->addAction(m_loadPrimitiveAction);
|
menu->addAction(m_loadPrimitiveAction);
|
||||||
menu->addAction(m_newPrimitiveAction);
|
menu->addAction(m_newPrimitiveAction);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(m_helpAction);
|
menu->addAction(m_helpAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::fillMenu_Landscape(QMenu *menu)
|
void PrimitivesView::fillMenu_Landscape(QMenu *menu)
|
||||||
{
|
{
|
||||||
menu->addAction(m_unloadAction);
|
menu->addAction(m_unloadAction);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(m_showAction);
|
menu->addAction(m_showAction);
|
||||||
menu->addAction(m_hideAction);
|
menu->addAction(m_hideAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::fillMenu_RootPrimitive(QMenu *menu, const QModelIndex &index)
|
void PrimitivesView::fillMenu_RootPrimitive(QMenu *menu, const QModelIndex &index)
|
||||||
{
|
{
|
||||||
menu->addAction(m_saveAction);
|
menu->addAction(m_saveAction);
|
||||||
menu->addAction(m_saveAsAction);
|
menu->addAction(m_saveAsAction);
|
||||||
menu->addAction(m_unloadAction);
|
menu->addAction(m_unloadAction);
|
||||||
fillMenu_Primitive(menu, index);
|
fillMenu_Primitive(menu, index);
|
||||||
menu->removeAction(m_deleteAction);
|
menu->removeAction(m_deleteAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimitivesView::fillMenu_Primitive(QMenu *menu, const QModelIndex &index)
|
void PrimitivesView::fillMenu_Primitive(QMenu *menu, const QModelIndex &index)
|
||||||
{
|
{
|
||||||
menu->addAction(m_deleteAction);
|
menu->addAction(m_deleteAction);
|
||||||
menu->addAction(m_selectChildrenAction);
|
menu->addAction(m_selectChildrenAction);
|
||||||
menu->addAction(m_helpAction);
|
menu->addAction(m_helpAction);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(m_showAction);
|
menu->addAction(m_showAction);
|
||||||
menu->addAction(m_hideAction);
|
menu->addAction(m_hideAction);
|
||||||
|
|
||||||
QSignalMapper *addSignalMapper = new QSignalMapper(menu);
|
QSignalMapper *addSignalMapper = new QSignalMapper(menu);
|
||||||
QSignalMapper *generateSignalMapper = new QSignalMapper(menu);
|
QSignalMapper *generateSignalMapper = new QSignalMapper(menu);
|
||||||
//QSignalMapper *openSignalMapper = new QSignalMapper(menu);
|
//QSignalMapper *openSignalMapper = new QSignalMapper(menu);
|
||||||
connect(addSignalMapper, SIGNAL(mapped(int)), this, SLOT(addNewPrimitiveByClass(int)));
|
connect(addSignalMapper, SIGNAL(mapped(int)), this, SLOT(addNewPrimitiveByClass(int)));
|
||||||
connect(generateSignalMapper, SIGNAL(mapped(int)), this, SLOT(generatePrimitives(int)));
|
connect(generateSignalMapper, SIGNAL(mapped(int)), this, SLOT(generatePrimitives(int)));
|
||||||
//connect(openSignalMapper, SIGNAL(mapped(int)), this, SLOT(openItem(int)));
|
//connect(openSignalMapper, SIGNAL(mapped(int)), this, SLOT(openItem(int)));
|
||||||
|
|
||||||
PrimitiveNode *node = static_cast<PrimitiveNode *>(index.internalPointer());
|
PrimitiveNode *node = static_cast<PrimitiveNode *>(index.internalPointer());
|
||||||
const NLLIGO::CPrimitiveClass *primClass = node->primitiveClass();
|
const NLLIGO::CPrimitiveClass *primClass = node->primitiveClass();
|
||||||
|
|
||||||
// What class is it ?
|
// What class is it ?
|
||||||
if (primClass && primClass->DynamicChildren.size())
|
if (primClass && primClass->DynamicChildren.size())
|
||||||
{
|
{
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
// For each child, add a create method
|
// For each child, add a create method
|
||||||
for (size_t i = 0; i < primClass->DynamicChildren.size(); i++)
|
for (size_t i = 0; i < primClass->DynamicChildren.size(); i++)
|
||||||
{
|
{
|
||||||
// Get class name
|
// Get class name
|
||||||
QString className = primClass->DynamicChildren[i].ClassName.c_str();
|
QString className = primClass->DynamicChildren[i].ClassName.c_str();
|
||||||
|
|
||||||
// Get icon
|
// Get icon
|
||||||
QIcon icon(QString("%1/%2.ico").arg(Constants::PATH_TO_OLD_ICONS).arg(className));
|
QIcon icon(QString("%1/%2.ico").arg(Constants::PATH_TO_OLD_ICONS).arg(className));
|
||||||
|
|
||||||
// Create and add action in popur menu
|
// Create and add action in popur menu
|
||||||
QAction *action = menu->addAction(icon, tr("Add %1").arg(className));
|
QAction *action = menu->addAction(icon, tr("Add %1").arg(className));
|
||||||
addSignalMapper->setMapping(action, i);
|
addSignalMapper->setMapping(action, i);
|
||||||
connect(action, SIGNAL(triggered()), addSignalMapper, SLOT(map()));
|
connect(action, SIGNAL(triggered()), addSignalMapper, SLOT(map()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// What class is it ?
|
// What class is it ?
|
||||||
if (primClass && primClass->GeneratedChildren.size())
|
if (primClass && primClass->GeneratedChildren.size())
|
||||||
{
|
{
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
// For each child, add a create method
|
// For each child, add a create method
|
||||||
for (size_t i = 0; i < primClass->GeneratedChildren.size(); i++)
|
for (size_t i = 0; i < primClass->GeneratedChildren.size(); i++)
|
||||||
{
|
{
|
||||||
// Get class name
|
// Get class name
|
||||||
QString childName = primClass->GeneratedChildren[i].ClassName.c_str();
|
QString childName = primClass->GeneratedChildren[i].ClassName.c_str();
|
||||||
|
|
||||||
// Create and add action in popur menu
|
// Create and add action in popur menu
|
||||||
QAction *action = menu->addAction(tr("Generate %1").arg(childName));
|
QAction *action = menu->addAction(tr("Generate %1").arg(childName));
|
||||||
generateSignalMapper->setMapping(action, i);
|
generateSignalMapper->setMapping(action, i);
|
||||||
connect(action, SIGNAL(triggered()), generateSignalMapper, SLOT(map()));
|
connect(action, SIGNAL(triggered()), generateSignalMapper, SLOT(map()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace WorldEditor */
|
} /* namespace WorldEditor */
|
|
@ -1,112 +1,112 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
#ifndef PRIMITIVES_VIEW_H
|
#ifndef PRIMITIVES_VIEW_H
|
||||||
#define PRIMITIVES_VIEW_H
|
#define PRIMITIVES_VIEW_H
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "primitive_item.h"
|
#include "primitive_item.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/ligo/primitive.h>
|
#include <nel/ligo/primitive.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
#include <QtGui/QTreeView>
|
#include <QtGui/QTreeView>
|
||||||
#include <QtCore/QModelIndex>
|
#include <QtCore/QModelIndex>
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
#include <QtCore/QSignalMapper>
|
#include <QtCore/QSignalMapper>
|
||||||
#include <QtGui/QUndoStack>
|
#include <QtGui/QUndoStack>
|
||||||
#include <QtGui/QItemSelection>
|
#include <QtGui/QItemSelection>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
class ZoneBuilderBase;
|
class ZoneBuilderBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
{
|
{
|
||||||
class PrimitivesTreeModel;
|
class PrimitivesTreeModel;
|
||||||
class WorldEditorScene;
|
class WorldEditorScene;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class PrimitivesView
|
@class PrimitivesView
|
||||||
@brief
|
@brief
|
||||||
@details
|
@details
|
||||||
*/
|
*/
|
||||||
class PrimitivesView : public QTreeView
|
class PrimitivesView : public QTreeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PrimitivesView(QWidget *parent = 0);
|
explicit PrimitivesView(QWidget *parent = 0);
|
||||||
~PrimitivesView();
|
~PrimitivesView();
|
||||||
|
|
||||||
void setUndoStack(QUndoStack *undoStack);
|
void setUndoStack(QUndoStack *undoStack);
|
||||||
void setZoneBuilder(LandscapeEditor::ZoneBuilderBase *zoneBuilder);
|
void setZoneBuilder(LandscapeEditor::ZoneBuilderBase *zoneBuilder);
|
||||||
void setWorldScene(WorldEditorScene *worldEditorScene);
|
void setWorldScene(WorldEditorScene *worldEditorScene);
|
||||||
virtual void setModel(PrimitivesTreeModel *model);
|
virtual void setModel(PrimitivesTreeModel *model);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void loadLandscape();
|
void loadLandscape();
|
||||||
void loadRootPrimitive();
|
void loadRootPrimitive();
|
||||||
void createRootPrimitive();
|
void createRootPrimitive();
|
||||||
void selectChildren();
|
void selectChildren();
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
void saveAs();
|
void saveAs();
|
||||||
void deletePrimitives();
|
void deletePrimitives();
|
||||||
void unload();
|
void unload();
|
||||||
void showPrimitive();
|
void showPrimitive();
|
||||||
void hidePrimitive();
|
void hidePrimitive();
|
||||||
void addNewPrimitiveByClass(int value);
|
void addNewPrimitiveByClass(int value);
|
||||||
void generatePrimitives(int value);
|
void generatePrimitives(int value);
|
||||||
void openItem(int value);
|
void openItem(int value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void selectChildren(const QModelIndex &parent, QItemSelection &itemSelection);
|
void selectChildren(const QModelIndex &parent, QItemSelection &itemSelection);
|
||||||
void fillMenu_WorldEdit(QMenu *menu);
|
void fillMenu_WorldEdit(QMenu *menu);
|
||||||
void fillMenu_Landscape(QMenu *menu);
|
void fillMenu_Landscape(QMenu *menu);
|
||||||
void fillMenu_RootPrimitive(QMenu *menu, const QModelIndex &index);
|
void fillMenu_RootPrimitive(QMenu *menu, const QModelIndex &index);
|
||||||
void fillMenu_Primitive(QMenu *menu, const QModelIndex &index);
|
void fillMenu_Primitive(QMenu *menu, const QModelIndex &index);
|
||||||
|
|
||||||
QString m_lastDir;
|
QString m_lastDir;
|
||||||
|
|
||||||
QAction *m_unloadAction;
|
QAction *m_unloadAction;
|
||||||
QAction *m_saveAction;
|
QAction *m_saveAction;
|
||||||
QAction *m_saveAsAction;
|
QAction *m_saveAsAction;
|
||||||
QAction *m_loadLandAction;
|
QAction *m_loadLandAction;
|
||||||
QAction *m_loadPrimitiveAction;
|
QAction *m_loadPrimitiveAction;
|
||||||
QAction *m_newPrimitiveAction;
|
QAction *m_newPrimitiveAction;
|
||||||
QAction *m_deleteAction;
|
QAction *m_deleteAction;
|
||||||
QAction *m_selectChildrenAction;
|
QAction *m_selectChildrenAction;
|
||||||
QAction *m_helpAction;
|
QAction *m_helpAction;
|
||||||
QAction *m_showAction;
|
QAction *m_showAction;
|
||||||
QAction *m_hideAction;
|
QAction *m_hideAction;
|
||||||
|
|
||||||
QUndoStack *m_undoStack;
|
QUndoStack *m_undoStack;
|
||||||
WorldEditorScene *m_worldEditorScene;
|
WorldEditorScene *m_worldEditorScene;
|
||||||
LandscapeEditor::ZoneBuilderBase *m_zoneBuilder;
|
LandscapeEditor::ZoneBuilderBase *m_zoneBuilder;
|
||||||
PrimitivesTreeModel *m_primitivesTreeModel;
|
PrimitivesTreeModel *m_primitivesTreeModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace WorldEditor */
|
} /* namespace WorldEditor */
|
||||||
|
|
||||||
#endif // PRIMITIVES_VIEW_H
|
#endif // PRIMITIVES_VIEW_H
|
||||||
|
|
|
@ -1,68 +1,68 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "project_settings_dialog.h"
|
#include "project_settings_dialog.h"
|
||||||
#include "world_editor_misc.h"
|
#include "world_editor_misc.h"
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
#include <nel/ligo/ligo_config.h>
|
#include <nel/ligo/ligo_config.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *parent)
|
ProjectSettingsDialog::ProjectSettingsDialog(const QString &dataPath, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
m_ui.pathLineEdit->setText(dataPath);
|
m_ui.pathLineEdit->setText(dataPath);
|
||||||
m_ui.contextComboBox->addItem("empty");
|
m_ui.contextComboBox->addItem("empty");
|
||||||
|
|
||||||
// Init the combo box
|
// Init the combo box
|
||||||
const std::vector<std::string> &contexts = Utils::ligoConfig()->getContextString();
|
const std::vector<std::string> &contexts = Utils::ligoConfig()->getContextString();
|
||||||
for (uint i = 0; i < contexts.size(); i++)
|
for (uint i = 0; i < contexts.size(); i++)
|
||||||
m_ui.contextComboBox->addItem(QString(contexts[i].c_str()));
|
m_ui.contextComboBox->addItem(QString(contexts[i].c_str()));
|
||||||
|
|
||||||
setFixedHeight(sizeHint().height());
|
setFixedHeight(sizeHint().height());
|
||||||
connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath()));
|
connect(m_ui.selectPathButton, SIGNAL(clicked()), this, SLOT(selectPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectSettingsDialog::~ProjectSettingsDialog()
|
ProjectSettingsDialog::~ProjectSettingsDialog()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProjectSettingsDialog::dataPath() const
|
QString ProjectSettingsDialog::dataPath() const
|
||||||
{
|
{
|
||||||
return m_ui.pathLineEdit->text();
|
return m_ui.pathLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsDialog::selectPath()
|
void ProjectSettingsDialog::selectPath()
|
||||||
{
|
{
|
||||||
QString dataPath = QFileDialog::getExistingDirectory(this, tr("Select data path"), m_ui.pathLineEdit->text());
|
QString dataPath = QFileDialog::getExistingDirectory(this, tr("Select data path"), m_ui.pathLineEdit->text());
|
||||||
if (!dataPath.isEmpty())
|
if (!dataPath.isEmpty())
|
||||||
m_ui.pathLineEdit->setText(dataPath);
|
m_ui.pathLineEdit->setText(dataPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace WorldEditor */
|
} /* namespace WorldEditor */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,136 +1,136 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "world_editor_plugin.h"
|
#include "world_editor_plugin.h"
|
||||||
#include "world_editor_window.h"
|
#include "world_editor_window.h"
|
||||||
#include "world_editor_settings_page.h"
|
#include "world_editor_settings_page.h"
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include "nel/misc/debug.h"
|
#include "nel/misc/debug.h"
|
||||||
#include <nel/misc/path.h>
|
#include <nel/misc/path.h>
|
||||||
#include <nel/ligo/primitive_utils.h>
|
#include <nel/ligo/primitive_utils.h>
|
||||||
#include <nel/ligo/primitive.h>
|
#include <nel/ligo/primitive.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
WorldEditorPlugin::~WorldEditorPlugin()
|
WorldEditorPlugin::~WorldEditorPlugin()
|
||||||
{
|
{
|
||||||
Q_FOREACH(QObject *obj, m_autoReleaseObjects)
|
Q_FOREACH(QObject *obj, m_autoReleaseObjects)
|
||||||
{
|
{
|
||||||
m_plugMan->removeObject(obj);
|
m_plugMan->removeObject(obj);
|
||||||
}
|
}
|
||||||
qDeleteAll(m_autoReleaseObjects);
|
qDeleteAll(m_autoReleaseObjects);
|
||||||
m_autoReleaseObjects.clear();
|
m_autoReleaseObjects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||||
{
|
{
|
||||||
m_plugMan = pluginManager;
|
m_plugMan = pluginManager;
|
||||||
|
|
||||||
WorldEditorSettingsPage *weSettings = new WorldEditorSettingsPage(this);
|
WorldEditorSettingsPage *weSettings = new WorldEditorSettingsPage(this);
|
||||||
addAutoReleasedObject(weSettings);
|
addAutoReleasedObject(weSettings);
|
||||||
|
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
|
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
|
||||||
m_ligoConfig.CellSize = settings->value(Constants::WORLD_EDITOR_CELL_SIZE, "160").toFloat();
|
m_ligoConfig.CellSize = settings->value(Constants::WORLD_EDITOR_CELL_SIZE, "160").toFloat();
|
||||||
m_ligoConfig.Snap = settings->value(Constants::WORLD_EDITOR_SNAP, "1").toFloat();
|
m_ligoConfig.Snap = settings->value(Constants::WORLD_EDITOR_SNAP, "1").toFloat();
|
||||||
m_ligoConfig.ZoneSnapShotRes = settings->value(Constants::ZONE_SNAPSHOT_RES, "128").toUInt();
|
m_ligoConfig.ZoneSnapShotRes = settings->value(Constants::ZONE_SNAPSHOT_RES, "128").toUInt();
|
||||||
QString fileName = settings->value(Constants::PRIMITIVE_CLASS_FILENAME, "world_editor_classes.xml").toString();
|
QString fileName = settings->value(Constants::PRIMITIVE_CLASS_FILENAME, "world_editor_classes.xml").toString();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Search path of file world_editor_classes.xml
|
// Search path of file world_editor_classes.xml
|
||||||
std::string ligoPath = NLMISC::CPath::lookup(fileName.toStdString());
|
std::string ligoPath = NLMISC::CPath::lookup(fileName.toStdString());
|
||||||
// Init LIGO
|
// Init LIGO
|
||||||
m_ligoConfig.readPrimitiveClass(ligoPath.c_str(), true);
|
m_ligoConfig.readPrimitiveClass(ligoPath.c_str(), true);
|
||||||
NLLIGO::Register();
|
NLLIGO::Register();
|
||||||
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
||||||
}
|
}
|
||||||
catch (NLMISC::Exception &e)
|
catch (NLMISC::Exception &e)
|
||||||
{
|
{
|
||||||
*errorString = tr("(%1)").arg(e.what());
|
*errorString = tr("(%1)").arg(e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
m_ligoConfig.resetPrimitiveConfiguration ();
|
m_ligoConfig.resetPrimitiveConfiguration ();
|
||||||
|
|
||||||
// TODO: get file names! from settings
|
// TODO: get file names! from settings
|
||||||
m_ligoConfig.readPrimitiveClass("world_editor_primitive_configuration.xml", true);
|
m_ligoConfig.readPrimitiveClass("world_editor_primitive_configuration.xml", true);
|
||||||
|
|
||||||
|
|
||||||
addAutoReleasedObject(new WorldEditorContext(this));
|
addAutoReleasedObject(new WorldEditorContext(this));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorPlugin::extensionsInitialized()
|
void WorldEditorPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorPlugin::shutdown()
|
void WorldEditorPlugin::shutdown()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
void WorldEditorPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
// Ensure that a context doesn't exist yet.
|
// Ensure that a context doesn't exist yet.
|
||||||
// This only applies to platforms without PIC, e.g. Windows.
|
// This only applies to platforms without PIC, e.g. Windows.
|
||||||
nlassert(!NLMISC::INelContext::isContextInitialised());
|
nlassert(!NLMISC::INelContext::isContextInitialised());
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
m_libContext = new NLMISC::CLibraryContext(*nelContext);
|
m_libContext = new NLMISC::CLibraryContext(*nelContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorPlugin::addAutoReleasedObject(QObject *obj)
|
void WorldEditorPlugin::addAutoReleasedObject(QObject *obj)
|
||||||
{
|
{
|
||||||
m_plugMan->addObject(obj);
|
m_plugMan->addObject(obj);
|
||||||
m_autoReleaseObjects.prepend(obj);
|
m_autoReleaseObjects.prepend(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldEditorContext::WorldEditorContext(QObject *parent)
|
WorldEditorContext::WorldEditorContext(QObject *parent)
|
||||||
: IContext(parent),
|
: IContext(parent),
|
||||||
m_worldEditorWindow(0)
|
m_worldEditorWindow(0)
|
||||||
{
|
{
|
||||||
m_worldEditorWindow = new WorldEditorWindow();
|
m_worldEditorWindow = new WorldEditorWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoStack *WorldEditorContext::undoStack()
|
QUndoStack *WorldEditorContext::undoStack()
|
||||||
{
|
{
|
||||||
return m_worldEditorWindow->undoStack();
|
return m_worldEditorWindow->undoStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorContext::open()
|
void WorldEditorContext::open()
|
||||||
{
|
{
|
||||||
m_worldEditorWindow->open();
|
m_worldEditorWindow->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *WorldEditorContext::widget()
|
QWidget *WorldEditorContext::widget()
|
||||||
{
|
{
|
||||||
return m_worldEditorWindow;
|
return m_worldEditorWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(WorldEditor::WorldEditorPlugin)
|
Q_EXPORT_PLUGIN(WorldEditor::WorldEditorPlugin)
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,71 +1,71 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "world_editor_settings_page.h"
|
#include "world_editor_settings_page.h"
|
||||||
#include "world_editor_constants.h"
|
#include "world_editor_constants.h"
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
WorldEditorSettingsPage::WorldEditorSettingsPage(QObject *parent)
|
WorldEditorSettingsPage::WorldEditorSettingsPage(QObject *parent)
|
||||||
: IOptionsPage(parent),
|
: IOptionsPage(parent),
|
||||||
m_currentPage(NULL)
|
m_currentPage(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WorldEditorSettingsPage::id() const
|
QString WorldEditorSettingsPage::id() const
|
||||||
{
|
{
|
||||||
return QLatin1String(Constants::WORLD_EDITOR_PLUGIN);
|
return QLatin1String(Constants::WORLD_EDITOR_PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WorldEditorSettingsPage::trName() const
|
QString WorldEditorSettingsPage::trName() const
|
||||||
{
|
{
|
||||||
return tr("General");
|
return tr("General");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WorldEditorSettingsPage::category() const
|
QString WorldEditorSettingsPage::category() const
|
||||||
{
|
{
|
||||||
return QLatin1String(Constants::WORLD_EDITOR_PLUGIN);
|
return QLatin1String(Constants::WORLD_EDITOR_PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WorldEditorSettingsPage::trCategory() const
|
QString WorldEditorSettingsPage::trCategory() const
|
||||||
{
|
{
|
||||||
return tr("World Editor");
|
return tr("World Editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon WorldEditorSettingsPage::categoryIcon() const
|
QIcon WorldEditorSettingsPage::categoryIcon() const
|
||||||
{
|
{
|
||||||
return QIcon();
|
return QIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *WorldEditorSettingsPage::createPage(QWidget *parent)
|
QWidget *WorldEditorSettingsPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
m_currentPage = new QWidget(parent);
|
m_currentPage = new QWidget(parent);
|
||||||
m_ui.setupUi(m_currentPage);
|
m_ui.setupUi(m_currentPage);
|
||||||
return m_currentPage;
|
return m_currentPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorSettingsPage::apply()
|
void WorldEditorSettingsPage::apply()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace WorldEditor */
|
} /* namespace WorldEditor */
|
|
@ -1,422 +1,422 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// 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/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "world_editor_window.h"
|
#include "world_editor_window.h"
|
||||||
#include "world_editor_constants.h"
|
#include "world_editor_constants.h"
|
||||||
#include "primitives_model.h"
|
#include "primitives_model.h"
|
||||||
#include "world_editor_scene.h"
|
#include "world_editor_scene.h"
|
||||||
#include "world_editor_misc.h"
|
#include "world_editor_misc.h"
|
||||||
#include "world_editor_actions.h"
|
#include "world_editor_actions.h"
|
||||||
#include "world_editor_scene_item.h"
|
#include "world_editor_scene_item.h"
|
||||||
#include "project_settings_dialog.h"
|
#include "project_settings_dialog.h"
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/menu_manager.h"
|
#include "../core/menu_manager.h"
|
||||||
#include "../core/core_constants.h"
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
// Lanscape Editor plugin
|
// Lanscape Editor plugin
|
||||||
#include "../landscape_editor/builder_zone_base.h"
|
#include "../landscape_editor/builder_zone_base.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
#include <QtGui/QStatusBar>
|
#include <QtGui/QStatusBar>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QPersistentModelIndex>
|
#include <QPersistentModelIndex>
|
||||||
|
|
||||||
namespace WorldEditor
|
namespace WorldEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
WorldEditorWindow::WorldEditorWindow(QWidget *parent)
|
WorldEditorWindow::WorldEditorWindow(QWidget *parent)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
m_primitivesModel(0),
|
m_primitivesModel(0),
|
||||||
m_undoStack(0),
|
m_undoStack(0),
|
||||||
m_oglWidget(0)
|
m_oglWidget(0)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
|
|
||||||
m_primitivesModel = new PrimitivesTreeModel(this);
|
m_primitivesModel = new PrimitivesTreeModel(this);
|
||||||
|
|
||||||
m_worldEditorScene = new WorldEditorScene(Utils::ligoConfig()->CellSize, m_primitivesModel, m_undoStack, this);
|
m_worldEditorScene = new WorldEditorScene(Utils::ligoConfig()->CellSize, m_primitivesModel, m_undoStack, this);
|
||||||
m_zoneBuilderBase = new LandscapeEditor::ZoneBuilderBase(m_worldEditorScene);
|
m_zoneBuilderBase = new LandscapeEditor::ZoneBuilderBase(m_worldEditorScene);
|
||||||
|
|
||||||
m_worldEditorScene->setZoneBuilder(m_zoneBuilderBase);
|
m_worldEditorScene->setZoneBuilder(m_zoneBuilderBase);
|
||||||
m_ui.graphicsView->setScene(m_worldEditorScene);
|
m_ui.graphicsView->setScene(m_worldEditorScene);
|
||||||
m_ui.graphicsView->setVisibleText(false);
|
m_ui.graphicsView->setVisibleText(false);
|
||||||
|
|
||||||
m_ui.treePrimitivesView->setModel(m_primitivesModel);
|
m_ui.treePrimitivesView->setModel(m_primitivesModel);
|
||||||
m_ui.treePrimitivesView->setUndoStack(m_undoStack);
|
m_ui.treePrimitivesView->setUndoStack(m_undoStack);
|
||||||
m_ui.treePrimitivesView->setZoneBuilder(m_zoneBuilderBase);
|
m_ui.treePrimitivesView->setZoneBuilder(m_zoneBuilderBase);
|
||||||
m_ui.treePrimitivesView->setWorldScene(m_worldEditorScene);
|
m_ui.treePrimitivesView->setWorldScene(m_worldEditorScene);
|
||||||
|
|
||||||
QActionGroup *sceneModeGroup = new QActionGroup(this);
|
QActionGroup *sceneModeGroup = new QActionGroup(this);
|
||||||
sceneModeGroup->addAction(m_ui.selectAction);
|
sceneModeGroup->addAction(m_ui.selectAction);
|
||||||
sceneModeGroup->addAction(m_ui.moveAction);
|
sceneModeGroup->addAction(m_ui.moveAction);
|
||||||
sceneModeGroup->addAction(m_ui.rotateAction);
|
sceneModeGroup->addAction(m_ui.rotateAction);
|
||||||
sceneModeGroup->addAction(m_ui.scaleAction);
|
sceneModeGroup->addAction(m_ui.scaleAction);
|
||||||
sceneModeGroup->addAction(m_ui.turnAction);
|
sceneModeGroup->addAction(m_ui.turnAction);
|
||||||
m_ui.selectAction->setChecked(true);
|
m_ui.selectAction->setChecked(true);
|
||||||
|
|
||||||
m_ui.newWorldEditAction->setIcon(QIcon(Core::Constants::ICON_NEW));
|
m_ui.newWorldEditAction->setIcon(QIcon(Core::Constants::ICON_NEW));
|
||||||
m_ui.saveWorldEditAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
m_ui.saveWorldEditAction->setIcon(QIcon(Core::Constants::ICON_SAVE));
|
||||||
|
|
||||||
createMenus();
|
createMenus();
|
||||||
createToolBars();
|
createToolBars();
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
QSignalMapper *m_modeMapper = new QSignalMapper(this);
|
QSignalMapper *m_modeMapper = new QSignalMapper(this);
|
||||||
connect(m_ui.selectAction, SIGNAL(triggered()), m_modeMapper, SLOT(map()));
|
connect(m_ui.selectAction, SIGNAL(triggered()), m_modeMapper, SLOT(map()));
|
||||||
m_modeMapper->setMapping(m_ui.selectAction, 0);
|
m_modeMapper->setMapping(m_ui.selectAction, 0);
|
||||||
connect(m_ui.moveAction, SIGNAL(triggered()), m_modeMapper, SLOT(map()));
|
connect(m_ui.moveAction, SIGNAL(triggered()), m_modeMapper, SLOT(map()));
|
||||||
m_modeMapper->setMapping(m_ui.moveAction, 1);
|
m_modeMapper->setMapping(m_ui.moveAction, 1);
|
||||||
connect(m_ui.rotateAction, SIGNAL(triggered()), m_modeMapper, SLOT(map()));
|
connect(m_ui.rotateAction, SIGNAL(triggered()), m_modeMapper, SLOT(map()));
|
||||||
m_modeMapper->setMapping(m_ui.rotateAction, 2);
|
m_modeMapper->setMapping(m_ui.rotateAction, 2);
|
||||||
connect(m_ui.scaleAction, SIGNAL(triggered()), m_modeMapper, SLOT(map()));
|
connect(m_ui.scaleAction, SIGNAL(triggered()), m_modeMapper, SLOT(map()));
|
||||||
m_modeMapper->setMapping(m_ui.scaleAction, 3);
|
m_modeMapper->setMapping(m_ui.scaleAction, 3);
|
||||||
connect(m_ui.turnAction, SIGNAL(triggered()), m_modeMapper, SLOT(map()));
|
connect(m_ui.turnAction, SIGNAL(triggered()), m_modeMapper, SLOT(map()));
|
||||||
m_modeMapper->setMapping(m_ui.turnAction, 4);
|
m_modeMapper->setMapping(m_ui.turnAction, 4);
|
||||||
|
|
||||||
connect(m_modeMapper, SIGNAL(mapped(int)), this, SLOT(setMode(int)));
|
connect(m_modeMapper, SIGNAL(mapped(int)), this, SLOT(setMode(int)));
|
||||||
connect(m_ui.pointsAction, SIGNAL(triggered(bool)), m_worldEditorScene, SLOT(setEnabledEditPoints(bool)));
|
connect(m_ui.pointsAction, SIGNAL(triggered(bool)), m_worldEditorScene, SLOT(setEnabledEditPoints(bool)));
|
||||||
|
|
||||||
connect(m_ui.settingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings()));
|
connect(m_ui.settingsAction, SIGNAL(triggered()), this, SLOT(openProjectSettings()));
|
||||||
connect(m_ui.newWorldEditAction, SIGNAL(triggered()), this, SLOT(newWorldEditFile()));
|
connect(m_ui.newWorldEditAction, SIGNAL(triggered()), this, SLOT(newWorldEditFile()));
|
||||||
connect(m_ui.saveWorldEditAction, SIGNAL(triggered()), this, SLOT(saveWorldEditFile()));
|
connect(m_ui.saveWorldEditAction, SIGNAL(triggered()), this, SLOT(saveWorldEditFile()));
|
||||||
connect(m_ui.visibleGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool)));
|
connect(m_ui.visibleGridAction, SIGNAL(toggled(bool)), m_ui.graphicsView, SLOT(setVisibleGrid(bool)));
|
||||||
|
|
||||||
connect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
|
connect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
|
||||||
this, SLOT(updateSelection(QItemSelection, QItemSelection)));
|
this, SLOT(updateSelection(QItemSelection, QItemSelection)));
|
||||||
|
|
||||||
connect(m_worldEditorScene, SIGNAL(updateSelectedItems(QList<QGraphicsItem *>)),
|
connect(m_worldEditorScene, SIGNAL(updateSelectedItems(QList<QGraphicsItem *>)),
|
||||||
this, SLOT(selectedItemsInScene(QList<QGraphicsItem *>)));
|
this, SLOT(selectedItemsInScene(QList<QGraphicsItem *>)));
|
||||||
|
|
||||||
m_statusBarTimer = new QTimer(this);
|
m_statusBarTimer = new QTimer(this);
|
||||||
connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
|
connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
|
||||||
|
|
||||||
m_statusInfo = new QLabel(this);
|
m_statusInfo = new QLabel(this);
|
||||||
m_statusInfo->hide();
|
m_statusInfo->hide();
|
||||||
Core::ICore::instance()->mainWindow()->statusBar()->addPermanentWidget(m_statusInfo);
|
Core::ICore::instance()->mainWindow()->statusBar()->addPermanentWidget(m_statusInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldEditorWindow::~WorldEditorWindow()
|
WorldEditorWindow::~WorldEditorWindow()
|
||||||
{
|
{
|
||||||
writeSettings();
|
writeSettings();
|
||||||
|
|
||||||
delete m_zoneBuilderBase;
|
delete m_zoneBuilderBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoStack *WorldEditorWindow::undoStack() const
|
QUndoStack *WorldEditorWindow::undoStack() const
|
||||||
{
|
{
|
||||||
return m_undoStack;
|
return m_undoStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::maybeSave()
|
void WorldEditorWindow::maybeSave()
|
||||||
{
|
{
|
||||||
QMessageBox *messageBox = new QMessageBox(tr("World Editor"),
|
QMessageBox *messageBox = new QMessageBox(tr("World Editor"),
|
||||||
tr("The data has been modified.\n"
|
tr("The data has been modified.\n"
|
||||||
"Do you want to save your changes?"),
|
"Do you want to save your changes?"),
|
||||||
QMessageBox::Warning,
|
QMessageBox::Warning,
|
||||||
QMessageBox::Yes | QMessageBox::Default,
|
QMessageBox::Yes | QMessageBox::Default,
|
||||||
QMessageBox::No,
|
QMessageBox::No,
|
||||||
QMessageBox::Cancel | QMessageBox::Escape,
|
QMessageBox::Cancel | QMessageBox::Escape,
|
||||||
this, Qt::Sheet);
|
this, Qt::Sheet);
|
||||||
|
|
||||||
messageBox->setButtonText(QMessageBox::Yes,
|
messageBox->setButtonText(QMessageBox::Yes,
|
||||||
tr("Save"));
|
tr("Save"));
|
||||||
|
|
||||||
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
|
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
|
||||||
|
|
||||||
messageBox->show();
|
messageBox->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::open()
|
void WorldEditorWindow::open()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(this,
|
QString fileName = QFileDialog::getOpenFileName(this,
|
||||||
tr("Open NeL World Edit file"), m_lastDir,
|
tr("Open NeL World Edit file"), m_lastDir,
|
||||||
tr("All NeL World Editor file (*.worldedit)"));
|
tr("All NeL World Editor file (*.worldedit)"));
|
||||||
|
|
||||||
setCursor(Qt::WaitCursor);
|
setCursor(Qt::WaitCursor);
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
{
|
{
|
||||||
m_lastDir = QFileInfo(fileName).absolutePath();
|
m_lastDir = QFileInfo(fileName).absolutePath();
|
||||||
loadWorldEditFile(fileName);
|
loadWorldEditFile(fileName);
|
||||||
}
|
}
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::loadWorldEditFile(const QString &fileName)
|
void WorldEditorWindow::loadWorldEditFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
if (m_primitivesModel->isWorldEditNodeLoaded())
|
if (m_primitivesModel->isWorldEditNodeLoaded())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Utils::WorldEditList worldEditList;
|
Utils::WorldEditList worldEditList;
|
||||||
if (!Utils::loadWorldEditFile(fileName.toStdString(), worldEditList))
|
if (!Utils::loadWorldEditFile(fileName.toStdString(), worldEditList))
|
||||||
{
|
{
|
||||||
// TODO: add the message box
|
// TODO: add the message box
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_undoStack->beginMacro(tr("Load %1").arg(fileName));
|
m_undoStack->beginMacro(tr("Load %1").arg(fileName));
|
||||||
|
|
||||||
checkCurrentWorld();
|
checkCurrentWorld();
|
||||||
|
|
||||||
m_undoStack->push(new CreateWorldCommand(fileName, m_primitivesModel));
|
m_undoStack->push(new CreateWorldCommand(fileName, m_primitivesModel));
|
||||||
for (size_t i = 0; i < worldEditList.size(); ++i)
|
for (size_t i = 0; i < worldEditList.size(); ++i)
|
||||||
{
|
{
|
||||||
switch (worldEditList[i].first)
|
switch (worldEditList[i].first)
|
||||||
{
|
{
|
||||||
case Utils::DataDirectoryType:
|
case Utils::DataDirectoryType:
|
||||||
m_zoneBuilderBase->init(QString(worldEditList[i].second.c_str()), true);
|
m_zoneBuilderBase->init(QString(worldEditList[i].second.c_str()), true);
|
||||||
break;
|
break;
|
||||||
case Utils::ContextType:
|
case Utils::ContextType:
|
||||||
break;
|
break;
|
||||||
case Utils::LandscapeType:
|
case Utils::LandscapeType:
|
||||||
m_undoStack->push(new LoadLandscapeCommand(QString(worldEditList[i].second.c_str()), m_primitivesModel, m_zoneBuilderBase));
|
m_undoStack->push(new LoadLandscapeCommand(QString(worldEditList[i].second.c_str()), m_primitivesModel, m_zoneBuilderBase));
|
||||||
break;
|
break;
|
||||||
case Utils::PrimitiveType:
|
case Utils::PrimitiveType:
|
||||||
m_undoStack->push(new LoadRootPrimitiveCommand(QString(worldEditList[i].second.c_str()),
|
m_undoStack->push(new LoadRootPrimitiveCommand(QString(worldEditList[i].second.c_str()),
|
||||||
m_worldEditorScene, m_primitivesModel, m_ui.treePrimitivesView));
|
m_worldEditorScene, m_primitivesModel, m_ui.treePrimitivesView));
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
m_undoStack->endMacro();
|
m_undoStack->endMacro();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::checkCurrentWorld()
|
void WorldEditorWindow::checkCurrentWorld()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::newWorldEditFile()
|
void WorldEditorWindow::newWorldEditFile()
|
||||||
{
|
{
|
||||||
checkCurrentWorld();
|
checkCurrentWorld();
|
||||||
m_undoStack->push(new CreateWorldCommand("NewWorldEdit", m_primitivesModel));
|
m_undoStack->push(new CreateWorldCommand("NewWorldEdit", m_primitivesModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::saveWorldEditFile()
|
void WorldEditorWindow::saveWorldEditFile()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::openProjectSettings()
|
void WorldEditorWindow::openProjectSettings()
|
||||||
{
|
{
|
||||||
ProjectSettingsDialog *dialog = new ProjectSettingsDialog(m_zoneBuilderBase->dataPath(), this);
|
ProjectSettingsDialog *dialog = new ProjectSettingsDialog(m_zoneBuilderBase->dataPath(), this);
|
||||||
dialog->show();
|
dialog->show();
|
||||||
int ok = dialog->exec();
|
int ok = dialog->exec();
|
||||||
if (ok == QDialog::Accepted)
|
if (ok == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
m_zoneBuilderBase->init(dialog->dataPath(), true);
|
m_zoneBuilderBase->init(dialog->dataPath(), true);
|
||||||
}
|
}
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::setMode(int value)
|
void WorldEditorWindow::setMode(int value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
m_worldEditorScene->setModeEdit(WorldEditorScene::SelectMode);
|
m_worldEditorScene->setModeEdit(WorldEditorScene::SelectMode);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
m_worldEditorScene->setModeEdit(WorldEditorScene::MoveMode);
|
m_worldEditorScene->setModeEdit(WorldEditorScene::MoveMode);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
m_worldEditorScene->setModeEdit(WorldEditorScene::RotateMode);
|
m_worldEditorScene->setModeEdit(WorldEditorScene::RotateMode);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
m_worldEditorScene->setModeEdit(WorldEditorScene::ScaleMode);
|
m_worldEditorScene->setModeEdit(WorldEditorScene::ScaleMode);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
m_worldEditorScene->setModeEdit(WorldEditorScene::TurnMode);
|
m_worldEditorScene->setModeEdit(WorldEditorScene::TurnMode);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
m_worldEditorScene->setModeEdit(WorldEditorScene::RadiusMode);
|
m_worldEditorScene->setModeEdit(WorldEditorScene::RadiusMode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::updateStatusBar()
|
void WorldEditorWindow::updateStatusBar()
|
||||||
{
|
{
|
||||||
m_statusInfo->setText(m_worldEditorScene->zoneNameFromMousePos());
|
m_statusInfo->setText(m_worldEditorScene->zoneNameFromMousePos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::updateSelection(const QItemSelection &selected, const QItemSelection &deselected)
|
void WorldEditorWindow::updateSelection(const QItemSelection &selected, const QItemSelection &deselected)
|
||||||
{
|
{
|
||||||
m_ui.pointsAction->setChecked(false);
|
m_ui.pointsAction->setChecked(false);
|
||||||
m_worldEditorScene->setEnabledEditPoints(false);
|
m_worldEditorScene->setEnabledEditPoints(false);
|
||||||
|
|
||||||
NodeList nodesSelected;
|
NodeList nodesSelected;
|
||||||
Q_FOREACH(QModelIndex modelIndex, selected.indexes())
|
Q_FOREACH(QModelIndex modelIndex, selected.indexes())
|
||||||
{
|
{
|
||||||
Node *node = static_cast<Node *>(modelIndex.internalPointer());
|
Node *node = static_cast<Node *>(modelIndex.internalPointer());
|
||||||
nodesSelected.push_back(node);
|
nodesSelected.push_back(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList nodesDeselected;
|
NodeList nodesDeselected;
|
||||||
Q_FOREACH(QModelIndex modelIndex, deselected.indexes())
|
Q_FOREACH(QModelIndex modelIndex, deselected.indexes())
|
||||||
{
|
{
|
||||||
Node *node = static_cast<Node *>(modelIndex.internalPointer());
|
Node *node = static_cast<Node *>(modelIndex.internalPointer());
|
||||||
nodesDeselected.push_back(node);
|
nodesDeselected.push_back(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update property editor
|
// update property editor
|
||||||
if (nodesSelected.size() > 0)
|
if (nodesSelected.size() > 0)
|
||||||
{
|
{
|
||||||
// only single selection
|
// only single selection
|
||||||
m_ui.propertyEditWidget->updateSelection(nodesSelected.at(0));
|
m_ui.propertyEditWidget->updateSelection(nodesSelected.at(0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ui.propertyEditWidget->clearProperties();
|
m_ui.propertyEditWidget->clearProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QGraphicsItem *> itemSelected;
|
QList<QGraphicsItem *> itemSelected;
|
||||||
Q_FOREACH(Node *node, nodesSelected)
|
Q_FOREACH(Node *node, nodesSelected)
|
||||||
{
|
{
|
||||||
QGraphicsItem *item = getGraphicsItem(node);
|
QGraphicsItem *item = getGraphicsItem(node);
|
||||||
if (item != 0)
|
if (item != 0)
|
||||||
itemSelected.push_back(item);
|
itemSelected.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QGraphicsItem *> itemDeselected;
|
QList<QGraphicsItem *> itemDeselected;
|
||||||
Q_FOREACH(Node *node, nodesDeselected)
|
Q_FOREACH(Node *node, nodesDeselected)
|
||||||
{
|
{
|
||||||
QGraphicsItem *item = getGraphicsItem(node);
|
QGraphicsItem *item = getGraphicsItem(node);
|
||||||
if (item != 0)
|
if (item != 0)
|
||||||
itemDeselected.push_back(item);
|
itemDeselected.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update world editor scene
|
// Update world editor scene
|
||||||
m_worldEditorScene->updateSelection(itemSelected, itemDeselected);
|
m_worldEditorScene->updateSelection(itemSelected, itemDeselected);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::selectedItemsInScene(const QList<QGraphicsItem *> &selected)
|
void WorldEditorWindow::selectedItemsInScene(const QList<QGraphicsItem *> &selected)
|
||||||
{
|
{
|
||||||
QItemSelectionModel *selectionModel = m_ui.treePrimitivesView->selectionModel();
|
QItemSelectionModel *selectionModel = m_ui.treePrimitivesView->selectionModel();
|
||||||
disconnect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
|
disconnect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
|
||||||
this, SLOT(updateSelection(QItemSelection, QItemSelection)));
|
this, SLOT(updateSelection(QItemSelection, QItemSelection)));
|
||||||
|
|
||||||
selectionModel->clear();
|
selectionModel->clear();
|
||||||
QItemSelection itemSelection;
|
QItemSelection itemSelection;
|
||||||
Q_FOREACH(QGraphicsItem *item, selected)
|
Q_FOREACH(QGraphicsItem *item, selected)
|
||||||
{
|
{
|
||||||
QPersistentModelIndex *index = qvariant_cast<QPersistentModelIndex *>(item->data(Constants::NODE_PERISTENT_INDEX));
|
QPersistentModelIndex *index = qvariant_cast<QPersistentModelIndex *>(item->data(Constants::NODE_PERISTENT_INDEX));
|
||||||
if (index->isValid())
|
if (index->isValid())
|
||||||
{
|
{
|
||||||
QModelIndex modelIndex = index->operator const QModelIndex &();
|
QModelIndex modelIndex = index->operator const QModelIndex &();
|
||||||
QItemSelection mergeItemSelection(modelIndex, modelIndex);
|
QItemSelection mergeItemSelection(modelIndex, modelIndex);
|
||||||
itemSelection.merge(mergeItemSelection, QItemSelectionModel::Select);
|
itemSelection.merge(mergeItemSelection, QItemSelectionModel::Select);
|
||||||
}
|
}
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
selectionModel->select(itemSelection, QItemSelectionModel::Select);
|
selectionModel->select(itemSelection, QItemSelectionModel::Select);
|
||||||
|
|
||||||
// update property editor
|
// update property editor
|
||||||
if (!selected.isEmpty())
|
if (!selected.isEmpty())
|
||||||
{
|
{
|
||||||
// only single selection
|
// only single selection
|
||||||
Node *node = qvariant_cast<Node *>(selected.at(0)->data(Constants::WORLD_EDITOR_NODE));
|
Node *node = qvariant_cast<Node *>(selected.at(0)->data(Constants::WORLD_EDITOR_NODE));
|
||||||
m_ui.propertyEditWidget->updateSelection(node);
|
m_ui.propertyEditWidget->updateSelection(node);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ui.propertyEditWidget->clearProperties();
|
m_ui.propertyEditWidget->clearProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
|
connect(m_ui.treePrimitivesView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
|
||||||
this, SLOT(updateSelection(QItemSelection, QItemSelection)));
|
this, SLOT(updateSelection(QItemSelection, QItemSelection)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::showEvent(QShowEvent *showEvent)
|
void WorldEditorWindow::showEvent(QShowEvent *showEvent)
|
||||||
{
|
{
|
||||||
QMainWindow::showEvent(showEvent);
|
QMainWindow::showEvent(showEvent);
|
||||||
if (m_oglWidget != 0)
|
if (m_oglWidget != 0)
|
||||||
m_oglWidget->makeCurrent();
|
m_oglWidget->makeCurrent();
|
||||||
m_statusInfo->show();
|
m_statusInfo->show();
|
||||||
m_statusBarTimer->start(100);
|
m_statusBarTimer->start(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::hideEvent(QHideEvent *hideEvent)
|
void WorldEditorWindow::hideEvent(QHideEvent *hideEvent)
|
||||||
{
|
{
|
||||||
QMainWindow::hideEvent(hideEvent);
|
QMainWindow::hideEvent(hideEvent);
|
||||||
m_statusInfo->hide();
|
m_statusInfo->hide();
|
||||||
m_statusBarTimer->stop();
|
m_statusBarTimer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::createMenus()
|
void WorldEditorWindow::createMenus()
|
||||||
{
|
{
|
||||||
//Core::MenuManager *menuManager = Core::ICore::instance()->menuManager();
|
//Core::MenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::createToolBars()
|
void WorldEditorWindow::createToolBars()
|
||||||
{
|
{
|
||||||
Core::MenuManager *menuManager = Core::ICore::instance()->menuManager();
|
Core::MenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||||
//QAction *action = menuManager->action(Core::Constants::NEW);
|
//QAction *action = menuManager->action(Core::Constants::NEW);
|
||||||
//m_ui.fileToolBar->addAction(action);
|
//m_ui.fileToolBar->addAction(action);
|
||||||
|
|
||||||
m_ui.fileToolBar->addAction(m_ui.newWorldEditAction);
|
m_ui.fileToolBar->addAction(m_ui.newWorldEditAction);
|
||||||
QAction *action = menuManager->action(Core::Constants::OPEN);
|
QAction *action = menuManager->action(Core::Constants::OPEN);
|
||||||
m_ui.fileToolBar->addAction(action);
|
m_ui.fileToolBar->addAction(action);
|
||||||
m_ui.fileToolBar->addAction(m_ui.saveWorldEditAction);
|
m_ui.fileToolBar->addAction(m_ui.saveWorldEditAction);
|
||||||
m_ui.fileToolBar->addSeparator();
|
m_ui.fileToolBar->addSeparator();
|
||||||
|
|
||||||
action = menuManager->action(Core::Constants::UNDO);
|
action = menuManager->action(Core::Constants::UNDO);
|
||||||
if (action != 0)
|
if (action != 0)
|
||||||
m_ui.fileToolBar->addAction(action);
|
m_ui.fileToolBar->addAction(action);
|
||||||
|
|
||||||
action = menuManager->action(Core::Constants::REDO);
|
action = menuManager->action(Core::Constants::REDO);
|
||||||
if (action != 0)
|
if (action != 0)
|
||||||
m_ui.fileToolBar->addAction(action);
|
m_ui.fileToolBar->addAction(action);
|
||||||
|
|
||||||
//action = menuManager->action(Core::Constants::SAVE);
|
//action = menuManager->action(Core::Constants::SAVE);
|
||||||
//m_ui.fileToolBar->addAction(action);
|
//m_ui.fileToolBar->addAction(action);
|
||||||
//action = menuManager->action(Core::Constants::SAVE_AS);
|
//action = menuManager->action(Core::Constants::SAVE_AS);
|
||||||
//m_ui.fileToolBar->addAction(action);
|
//m_ui.fileToolBar->addAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::readSettings()
|
void WorldEditorWindow::readSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
|
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
|
||||||
restoreState(settings->value(Constants::WORLD_WINDOW_STATE).toByteArray());
|
restoreState(settings->value(Constants::WORLD_WINDOW_STATE).toByteArray());
|
||||||
restoreGeometry(settings->value(Constants::WORLD_WINDOW_GEOMETRY).toByteArray());
|
restoreGeometry(settings->value(Constants::WORLD_WINDOW_GEOMETRY).toByteArray());
|
||||||
|
|
||||||
// Use OpenGL graphics system instead raster graphics system
|
// Use OpenGL graphics system instead raster graphics system
|
||||||
if (settings->value(Constants::WORLD_EDITOR_USE_OPENGL, true).toBool())
|
if (settings->value(Constants::WORLD_EDITOR_USE_OPENGL, true).toBool())
|
||||||
{
|
{
|
||||||
m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer));
|
m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer));
|
||||||
//m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers));
|
//m_oglWidget = new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::SampleBuffers));
|
||||||
m_ui.graphicsView->setViewport(m_oglWidget);
|
m_ui.graphicsView->setViewport(m_oglWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorWindow::writeSettings()
|
void WorldEditorWindow::writeSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
|
settings->beginGroup(Constants::WORLD_EDITOR_SECTION);
|
||||||
settings->setValue(Constants::WORLD_WINDOW_STATE, saveState());
|
settings->setValue(Constants::WORLD_WINDOW_STATE, saveState());
|
||||||
settings->setValue(Constants::WORLD_WINDOW_GEOMETRY, saveGeometry());
|
settings->setValue(Constants::WORLD_WINDOW_GEOMETRY, saveGeometry());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->sync();
|
settings->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace LandscapeEditor */
|
} /* namespace LandscapeEditor */
|
||||||
|
|
Loading…
Reference in a new issue