From e5b2d05fa733b70f5b7b68373f75669fbe4ff47d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 30 Aug 2014 22:23:21 +0200 Subject: [PATCH] EOL --- .../src/plugins/georges_editor/actions.h | 94 +- .../src/plugins/georges_editor/browser_ctrl.h | 98 +- .../plugins/georges_editor/browser_ctrl_pvt.h | 164 +-- .../src/plugins/gui_editor/action_list.cpp | 98 +- .../src/plugins/gui_editor/action_list.h | 58 +- .../src/plugins/tile_editor/CMakeLists.txt | 100 +- .../plugins/tile_editor/land_edit_dialog.cpp | 210 +-- .../plugins/tile_editor/land_edit_dialog.h | 102 +- .../tile_editor/studio_plugin_tile_editor.xml | 18 +- .../src/plugins/tile_editor/tile_bank.cpp | 1284 ++++++++--------- .../src/plugins/tile_editor/tile_bank.h | 204 +-- .../src/plugins/tile_editor/tile_constants.h | 86 +- .../src/plugins/tile_editor/tile_images.h | 80 +- .../tile_editor/tile_item_delegate.cpp | 242 ++-- .../plugins/tile_editor/tilebank_loader.cpp | 84 +- .../src/plugins/tile_editor/tilebank_loader.h | 70 +- .../plugins/tile_editor/tilebank_saver.cpp | 96 +- .../src/plugins/tile_editor/tilebank_saver.h | 78 +- .../translation_manager/uxt_editor.cpp | 944 ++++++------ code/studio/src/settings_dialog.cpp | 472 +++--- code/studio/src/settings_dialog.h | 124 +- code/studio/src/splash_screen.cpp | 218 +-- code/studio/src/splash_screen.h | 120 +- 23 files changed, 2522 insertions(+), 2522 deletions(-) diff --git a/code/studio/src/plugins/georges_editor/actions.h b/code/studio/src/plugins/georges_editor/actions.h index 0c57b0577..861eaef8e 100644 --- a/code/studio/src/plugins/georges_editor/actions.h +++ b/code/studio/src/plugins/georges_editor/actions.h @@ -1,48 +1,48 @@ -// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework -// Copyright (C) 2011 Adrian Jaekel -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef ACTIONS_H -#define ACTIONS_H - -#include -#include - -namespace GeorgesQt -{ - class CFormItem; - class CGeorgesFormModel; - - class CUndoFormArrayRenameCommand : public QUndoCommand - { - public: - CUndoFormArrayRenameCommand(CGeorgesFormModel *model, CFormItem *item, const QVariant &value, QUndoCommand *parent = 0); - ~CUndoFormArrayRenameCommand() {} - - void redo(); - void undo(); - - void update(bool redo); - - protected: - CFormItem *m_item; - CGeorgesFormModel *m_model; - - QString m_newValue; - QString m_oldValue; - }; -} - +// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework +// Copyright (C) 2011 Adrian Jaekel +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef ACTIONS_H +#define ACTIONS_H + +#include +#include + +namespace GeorgesQt +{ + class CFormItem; + class CGeorgesFormModel; + + class CUndoFormArrayRenameCommand : public QUndoCommand + { + public: + CUndoFormArrayRenameCommand(CGeorgesFormModel *model, CFormItem *item, const QVariant &value, QUndoCommand *parent = 0); + ~CUndoFormArrayRenameCommand() {} + + void redo(); + void undo(); + + void update(bool redo); + + protected: + CFormItem *m_item; + CGeorgesFormModel *m_model; + + QString m_newValue; + QString m_oldValue; + }; +} + #endif // ACTIONS_H \ No newline at end of file diff --git a/code/studio/src/plugins/georges_editor/browser_ctrl.h b/code/studio/src/plugins/georges_editor/browser_ctrl.h index daf77cc87..7c56deceb 100644 --- a/code/studio/src/plugins/georges_editor/browser_ctrl.h +++ b/code/studio/src/plugins/georges_editor/browser_ctrl.h @@ -1,49 +1,49 @@ -#ifndef BROWSER_CTRL_H -#define BROWSER_CTRL_H - -#include - -namespace NLGEORGES -{ - class UForm; -} - -class QtTreePropertyBrowser; -class QModelIndex; -class QVariant; -class QtProperty; - -class BrowserCtrlPvt; - -class BrowserCtrl : public QObject -{ - Q_OBJECT -public: - BrowserCtrl( QtTreePropertyBrowser *browser ); - ~BrowserCtrl(); - void setForm( NLGEORGES::UForm *form ){ m_form = form; } - -public Q_SLOTS: - void clicked( const QModelIndex &idx ); - -Q_SIGNALS: - void arrayResized( const QString &name, int size ); - void modified(); - void valueChanged( const QString &key, const QString &value ); - -private Q_SLOTS: - void onValueChanged( QtProperty *p, const QVariant &value ); - void onValueChanged( const QString &key, const QString &value ); - void onArrayResized( const QString &name, int size ); - void onModified(); - -private: - void enableMgrConnections(); - void disableMgrConnections(); - - - BrowserCtrlPvt *m_pvt; - NLGEORGES::UForm *m_form; -}; - -#endif +#ifndef BROWSER_CTRL_H +#define BROWSER_CTRL_H + +#include + +namespace NLGEORGES +{ + class UForm; +} + +class QtTreePropertyBrowser; +class QModelIndex; +class QVariant; +class QtProperty; + +class BrowserCtrlPvt; + +class BrowserCtrl : public QObject +{ + Q_OBJECT +public: + BrowserCtrl( QtTreePropertyBrowser *browser ); + ~BrowserCtrl(); + void setForm( NLGEORGES::UForm *form ){ m_form = form; } + +public Q_SLOTS: + void clicked( const QModelIndex &idx ); + +Q_SIGNALS: + void arrayResized( const QString &name, int size ); + void modified(); + void valueChanged( const QString &key, const QString &value ); + +private Q_SLOTS: + void onValueChanged( QtProperty *p, const QVariant &value ); + void onValueChanged( const QString &key, const QString &value ); + void onArrayResized( const QString &name, int size ); + void onModified(); + +private: + void enableMgrConnections(); + void disableMgrConnections(); + + + BrowserCtrlPvt *m_pvt; + NLGEORGES::UForm *m_form; +}; + +#endif diff --git a/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h b/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h index 2aabd5ecb..c3d1cf50e 100644 --- a/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h +++ b/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h @@ -1,82 +1,82 @@ -#ifndef BROWSER_CTRL_PVT_H -#define BROWSER_CTRL_PVT_H - -#include - -namespace NLGEORGES -{ - class CFormElm; - class UFormElm; - class CFormElmStruct; -} - -namespace GeorgesQt -{ - class CFormItem; -} - -class QtVariantPropertyManager; -class QtVariantEditorFactory; -class QtTreePropertyBrowser; -class QVariant; -class QtProperty; - -class BrowserCtrlPvt : public QObject -{ - Q_OBJECT -public: - BrowserCtrlPvt( QObject *parent = NULL ); - ~BrowserCtrlPvt(); - - void clear(); - void setupNode( GeorgesQt::CFormItem *node ); - void onValueChanged( QtProperty *p, const QVariant &value ); - - QtVariantPropertyManager* manager() const{ return mgr; } - void setRootNode( NLGEORGES::CFormElm *root ){ m_rootNode = root; } - void setBrowser( QtTreePropertyBrowser *browser ){ m_browser = browser; } - -Q_SIGNALS: - void arrayResized( const QString &name, int size ); - void modified(); - void valueChanged( const QString &key, const QString &value ); - -private: - void setupStruct( NLGEORGES::UFormElm *node ); - void setupAtom( NLGEORGES::CFormElmStruct::CFormElmStructElm &elm ); - - void setupStruct( GeorgesQt::CFormItem *node ); - void setupArray( GeorgesQt::CFormItem *node ); - - void onStructValueChanged( QtProperty *p, const QVariant &value ); - void onArrayValueChanged( QtProperty *p, const QVariant &value ); - void createArray(); - - QtVariantPropertyManager *mgr; - QtVariantEditorFactory *factory; - QtTreePropertyBrowser *m_browser; - - QString m_currentNodeName; - NLGEORGES::CFormElm *m_rootNode; - - struct CurrentNode - { - CurrentNode() - { - clear(); - } - - void clear() - { - p = NULL; - name = ""; - } - - QString name; - NLGEORGES::UFormElm *p; - }; - - CurrentNode m_currentNode; -}; - -#endif +#ifndef BROWSER_CTRL_PVT_H +#define BROWSER_CTRL_PVT_H + +#include + +namespace NLGEORGES +{ + class CFormElm; + class UFormElm; + class CFormElmStruct; +} + +namespace GeorgesQt +{ + class CFormItem; +} + +class QtVariantPropertyManager; +class QtVariantEditorFactory; +class QtTreePropertyBrowser; +class QVariant; +class QtProperty; + +class BrowserCtrlPvt : public QObject +{ + Q_OBJECT +public: + BrowserCtrlPvt( QObject *parent = NULL ); + ~BrowserCtrlPvt(); + + void clear(); + void setupNode( GeorgesQt::CFormItem *node ); + void onValueChanged( QtProperty *p, const QVariant &value ); + + QtVariantPropertyManager* manager() const{ return mgr; } + void setRootNode( NLGEORGES::CFormElm *root ){ m_rootNode = root; } + void setBrowser( QtTreePropertyBrowser *browser ){ m_browser = browser; } + +Q_SIGNALS: + void arrayResized( const QString &name, int size ); + void modified(); + void valueChanged( const QString &key, const QString &value ); + +private: + void setupStruct( NLGEORGES::UFormElm *node ); + void setupAtom( NLGEORGES::CFormElmStruct::CFormElmStructElm &elm ); + + void setupStruct( GeorgesQt::CFormItem *node ); + void setupArray( GeorgesQt::CFormItem *node ); + + void onStructValueChanged( QtProperty *p, const QVariant &value ); + void onArrayValueChanged( QtProperty *p, const QVariant &value ); + void createArray(); + + QtVariantPropertyManager *mgr; + QtVariantEditorFactory *factory; + QtTreePropertyBrowser *m_browser; + + QString m_currentNodeName; + NLGEORGES::CFormElm *m_rootNode; + + struct CurrentNode + { + CurrentNode() + { + clear(); + } + + void clear() + { + p = NULL; + name = ""; + } + + QString name; + NLGEORGES::UFormElm *p; + }; + + CurrentNode m_currentNode; +}; + +#endif diff --git a/code/studio/src/plugins/gui_editor/action_list.cpp b/code/studio/src/plugins/gui_editor/action_list.cpp index 8925e6d04..4cc30aecb 100644 --- a/code/studio/src/plugins/gui_editor/action_list.cpp +++ b/code/studio/src/plugins/gui_editor/action_list.cpp @@ -1,49 +1,49 @@ -#include "action_list.h" -#include "nel/gui/action_handler.h" -#include -#include - -ActionList::ActionList( QDialog *parent ) : -QDialog( parent ) -{ - setupUi( this ); -} - -ActionList::~ActionList() -{ -} - -void ActionList::load() -{ - actionList->clear(); - - NLGUI::CAHManager *am = NLGUI::CAHManager::getInstance(); - std::vector< std::string > handlers; - am->getActionHandlers( handlers ); - - std::vector< std::string >::const_iterator itr = handlers.begin(); - while( itr != handlers.end() ) - { - actionList->addItem( itr->c_str() ); - ++itr; - } -} - -void ActionList::accept() -{ - QListWidgetItem *item = actionList->currentItem(); - if( item == NULL ) - return; - - selectedAction = item->text(); - - QDialog::accept(); -} - -void ActionList::reject() -{ - selectedAction = ""; - - QDialog::reject(); -} - +#include "action_list.h" +#include "nel/gui/action_handler.h" +#include +#include + +ActionList::ActionList( QDialog *parent ) : +QDialog( parent ) +{ + setupUi( this ); +} + +ActionList::~ActionList() +{ +} + +void ActionList::load() +{ + actionList->clear(); + + NLGUI::CAHManager *am = NLGUI::CAHManager::getInstance(); + std::vector< std::string > handlers; + am->getActionHandlers( handlers ); + + std::vector< std::string >::const_iterator itr = handlers.begin(); + while( itr != handlers.end() ) + { + actionList->addItem( itr->c_str() ); + ++itr; + } +} + +void ActionList::accept() +{ + QListWidgetItem *item = actionList->currentItem(); + if( item == NULL ) + return; + + selectedAction = item->text(); + + QDialog::accept(); +} + +void ActionList::reject() +{ + selectedAction = ""; + + QDialog::reject(); +} + diff --git a/code/studio/src/plugins/gui_editor/action_list.h b/code/studio/src/plugins/gui_editor/action_list.h index 752d66467..f61e0d239 100644 --- a/code/studio/src/plugins/gui_editor/action_list.h +++ b/code/studio/src/plugins/gui_editor/action_list.h @@ -1,29 +1,29 @@ -#ifndef ACTION_LIST_H -#define ACTION_LIST_H - - -#include "ui_action_list.h" -#include - - -class ActionList : public QDialog, public Ui::ActionListDialog -{ - Q_OBJECT - -public: - ActionList( QDialog *parent = NULL ); - ~ActionList(); - void load(); - - QString getSelectedAction(){ return selectedAction; } - - -public Q_SLOTS: - void accept(); - void reject(); - -private: - QString selectedAction; -}; - -#endif +#ifndef ACTION_LIST_H +#define ACTION_LIST_H + + +#include "ui_action_list.h" +#include + + +class ActionList : public QDialog, public Ui::ActionListDialog +{ + Q_OBJECT + +public: + ActionList( QDialog *parent = NULL ); + ~ActionList(); + void load(); + + QString getSelectedAction(){ return selectedAction; } + + +public Q_SLOTS: + void accept(); + void reject(); + +private: + QString selectedAction; +}; + +#endif diff --git a/code/studio/src/plugins/tile_editor/CMakeLists.txt b/code/studio/src/plugins/tile_editor/CMakeLists.txt index 396522235..78cc5ef49 100644 --- a/code/studio/src/plugins/tile_editor/CMakeLists.txt +++ b/code/studio/src/plugins/tile_editor/CMakeLists.txt @@ -1,50 +1,50 @@ -INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${LIBXML2_INCLUDE_DIR} - ${QT_INCLUDES}) - -FILE(GLOB SRC *.cpp *.h) -SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h - ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h - ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) - -SET(OVQT_TILE_EDITOR_PLUGIN_HDR - tile_model.h - tile_editor_main_window.h - tile_editor_plugin.h - land_edit_dialog.h) - -SET(OVQT_TILE_EDITOR_PLUGIN_UIS - tile_editor_main_window.ui - land_edit_dialog.ui) - -SET(OVQT_PLUG_TILE_EDITOR_RCS tile_editor.qrc) - -SET(QT_USE_QTGUI TRUE) -SET(QT_USE_QTOPENGL TRUE) - -QT4_WRAP_CPP(OVQT_TILE_EDITOR_PLUGIN_MOC_SRC ${OVQT_TILE_EDITOR_PLUGIN_HDR}) -QT4_ADD_RESOURCES( OVQT_PLUG_TILE_EDITOR_RC_SRCS ${OVQT_PLUG_TILE_EDITOR_RCS}) -QT4_WRAP_UI(OVQT_TILE_EDITOR_PLUGIN_UI_HDRS ${OVQT_TILE_EDITOR_PLUGIN_UIS}) - -SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_TILE_EDITOR_PLUGIN_UI_HDRS}) -SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_TILE_EDITOR_PLUGIN_MOC_SRC} ${OVQT_PLUG_TILE_EDITOR_RC_SRCS}) -SOURCE_GROUP("Tile Editor Plugin" FILES ${SRC}) -SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) - -ADD_LIBRARY(studio_plugin_tile_editor MODULE ${SRC} ${OVQT_TILE_EDITOR_PLUGIN_MOC_SRC} ${OVQT_PLUG_TILE_EDITOR_RC_SRCS} ${OVQT_EXT_SYS_SRC} ${OVQT_TILE_EDITOR_PLUGIN_UI_HDRS}) - -TARGET_LINK_LIBRARIES(studio_plugin_tile_editor studio_plugin_core nelmisc ${QT_LIBRARIES}) - -IF(WITH_STLPORT) - TARGET_LINK_LIBRARIES(studio_plugin_tile_editor ${CMAKE_THREAD_LIBS_INIT}) -ENDIF(WITH_STLPORT) - -NL_DEFAULT_PROPS(studio_plugin_tile_editor "Tools: Studio Plugin: Tile Editor") -NL_ADD_RUNTIME_FLAGS(studio_plugin_tile_editor) -NL_ADD_LIB_SUFFIX(studio_plugin_tile_editor) - -ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) - -INSTALL(TARGETS studio_plugin_tile_editor LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/studio_plugin_tile_editor.xml DESTINATION ${OVQT_PLUGIN_SPECS_DIR} COMPONENT tools3d) +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${QT_INCLUDES}) + +FILE(GLOB SRC *.cpp *.h) +SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) + +SET(OVQT_TILE_EDITOR_PLUGIN_HDR + tile_model.h + tile_editor_main_window.h + tile_editor_plugin.h + land_edit_dialog.h) + +SET(OVQT_TILE_EDITOR_PLUGIN_UIS + tile_editor_main_window.ui + land_edit_dialog.ui) + +SET(OVQT_PLUG_TILE_EDITOR_RCS tile_editor.qrc) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTOPENGL TRUE) + +QT4_WRAP_CPP(OVQT_TILE_EDITOR_PLUGIN_MOC_SRC ${OVQT_TILE_EDITOR_PLUGIN_HDR}) +QT4_ADD_RESOURCES( OVQT_PLUG_TILE_EDITOR_RC_SRCS ${OVQT_PLUG_TILE_EDITOR_RCS}) +QT4_WRAP_UI(OVQT_TILE_EDITOR_PLUGIN_UI_HDRS ${OVQT_TILE_EDITOR_PLUGIN_UIS}) + +SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_TILE_EDITOR_PLUGIN_UI_HDRS}) +SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_TILE_EDITOR_PLUGIN_MOC_SRC} ${OVQT_PLUG_TILE_EDITOR_RC_SRCS}) +SOURCE_GROUP("Tile Editor Plugin" FILES ${SRC}) +SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) + +ADD_LIBRARY(studio_plugin_tile_editor MODULE ${SRC} ${OVQT_TILE_EDITOR_PLUGIN_MOC_SRC} ${OVQT_PLUG_TILE_EDITOR_RC_SRCS} ${OVQT_EXT_SYS_SRC} ${OVQT_TILE_EDITOR_PLUGIN_UI_HDRS}) + +TARGET_LINK_LIBRARIES(studio_plugin_tile_editor studio_plugin_core nelmisc ${QT_LIBRARIES}) + +IF(WITH_STLPORT) + TARGET_LINK_LIBRARIES(studio_plugin_tile_editor ${CMAKE_THREAD_LIBS_INIT}) +ENDIF(WITH_STLPORT) + +NL_DEFAULT_PROPS(studio_plugin_tile_editor "Tools: Studio Plugin: Tile Editor") +NL_ADD_RUNTIME_FLAGS(studio_plugin_tile_editor) +NL_ADD_LIB_SUFFIX(studio_plugin_tile_editor) + +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) + +INSTALL(TARGETS studio_plugin_tile_editor LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/studio_plugin_tile_editor.xml DESTINATION ${OVQT_PLUGIN_SPECS_DIR} COMPONENT tools3d) diff --git a/code/studio/src/plugins/tile_editor/land_edit_dialog.cpp b/code/studio/src/plugins/tile_editor/land_edit_dialog.cpp index 40fbf3024..025e55730 100644 --- a/code/studio/src/plugins/tile_editor/land_edit_dialog.cpp +++ b/code/studio/src/plugins/tile_editor/land_edit_dialog.cpp @@ -1,105 +1,105 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "land_edit_dialog.h" - -LandEditDialog::LandEditDialog( QWidget *parent ) : -QDialog( parent ) -{ - setupUi( this ); - setupConnections(); -} - -LandEditDialog::~LandEditDialog() -{ -} - -void LandEditDialog::getSelectedTileSets( QStringList &l ) const -{ - int c = tilesetLV->count(); - for( int i = 0; i < c; i++ ) - { - l.push_back( tilesetLV->item( i )->text() ); - } -} - -void LandEditDialog::setSelectedTileSets( QStringList &l ) -{ - tilesetLV->clear(); - - QStringListIterator itr( l ); - while( itr.hasNext() ) - { - tilesetLV->addItem( itr.next() ); - } -} - -void LandEditDialog::setTileSets( const QStringList &l ) -{ - tilesetCB->clear(); - - QStringListIterator itr( l ); - while( itr.hasNext() ) - { - tilesetCB->addItem( itr.next() ); - } -} - -void LandEditDialog::setupConnections() -{ - connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOkClicked() ) ); - connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); - connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) ); - connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) ); -} - -void LandEditDialog::onOkClicked() -{ - accept(); -} - -void LandEditDialog::onCancelClicked() -{ - reject(); -} - -void LandEditDialog::onAddClicked() -{ - if( tilesetCB->currentIndex() < 0 ) - return; - - QString text = tilesetCB->currentText(); - - int c = tilesetLV->count(); - for( int i = 0; i < c; i++ ) - { - if( text == tilesetLV->item( i )->text() ) - return; - } - - tilesetLV->addItem( text ); -} - -void LandEditDialog::onRemoveClicked() -{ - if( tilesetLV->currentItem() == NULL ) - return; - - QListWidgetItem *item = tilesetLV->currentItem(); - delete item; -} - +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "land_edit_dialog.h" + +LandEditDialog::LandEditDialog( QWidget *parent ) : +QDialog( parent ) +{ + setupUi( this ); + setupConnections(); +} + +LandEditDialog::~LandEditDialog() +{ +} + +void LandEditDialog::getSelectedTileSets( QStringList &l ) const +{ + int c = tilesetLV->count(); + for( int i = 0; i < c; i++ ) + { + l.push_back( tilesetLV->item( i )->text() ); + } +} + +void LandEditDialog::setSelectedTileSets( QStringList &l ) +{ + tilesetLV->clear(); + + QStringListIterator itr( l ); + while( itr.hasNext() ) + { + tilesetLV->addItem( itr.next() ); + } +} + +void LandEditDialog::setTileSets( const QStringList &l ) +{ + tilesetCB->clear(); + + QStringListIterator itr( l ); + while( itr.hasNext() ) + { + tilesetCB->addItem( itr.next() ); + } +} + +void LandEditDialog::setupConnections() +{ + connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOkClicked() ) ); + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) ); + connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) ); +} + +void LandEditDialog::onOkClicked() +{ + accept(); +} + +void LandEditDialog::onCancelClicked() +{ + reject(); +} + +void LandEditDialog::onAddClicked() +{ + if( tilesetCB->currentIndex() < 0 ) + return; + + QString text = tilesetCB->currentText(); + + int c = tilesetLV->count(); + for( int i = 0; i < c; i++ ) + { + if( text == tilesetLV->item( i )->text() ) + return; + } + + tilesetLV->addItem( text ); +} + +void LandEditDialog::onRemoveClicked() +{ + if( tilesetLV->currentItem() == NULL ) + return; + + QListWidgetItem *item = tilesetLV->currentItem(); + delete item; +} + diff --git a/code/studio/src/plugins/tile_editor/land_edit_dialog.h b/code/studio/src/plugins/tile_editor/land_edit_dialog.h index ac3762b46..3873c6df5 100644 --- a/code/studio/src/plugins/tile_editor/land_edit_dialog.h +++ b/code/studio/src/plugins/tile_editor/land_edit_dialog.h @@ -1,51 +1,51 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#ifndef LAND_EDIT_DLG_H -#define LAND_EDIT_DLG_H - - -#include "ui_land_edit_dialog.h" -#include - -class LandEditDialog : public QDialog, public Ui::LandEditDialog -{ - Q_OBJECT -public: - LandEditDialog( QWidget *parent = NULL ); - ~LandEditDialog(); - - void getSelectedTileSets( QStringList &l ) const; - void setSelectedTileSets( QStringList &l ); - - void setTileSets( const QStringList &l ); - -private: - void setupConnections(); - - -private Q_SLOTS: - void onOkClicked(); - void onCancelClicked(); - void onAddClicked(); - void onRemoveClicked(); - -}; - - -#endif - +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef LAND_EDIT_DLG_H +#define LAND_EDIT_DLG_H + + +#include "ui_land_edit_dialog.h" +#include + +class LandEditDialog : public QDialog, public Ui::LandEditDialog +{ + Q_OBJECT +public: + LandEditDialog( QWidget *parent = NULL ); + ~LandEditDialog(); + + void getSelectedTileSets( QStringList &l ) const; + void setSelectedTileSets( QStringList &l ); + + void setTileSets( const QStringList &l ); + +private: + void setupConnections(); + + +private Q_SLOTS: + void onOkClicked(); + void onCancelClicked(); + void onAddClicked(); + void onRemoveClicked(); + +}; + + +#endif + diff --git a/code/studio/src/plugins/tile_editor/studio_plugin_tile_editor.xml b/code/studio/src/plugins/tile_editor/studio_plugin_tile_editor.xml index d69201f9b..0e5727896 100644 --- a/code/studio/src/plugins/tile_editor/studio_plugin_tile_editor.xml +++ b/code/studio/src/plugins/tile_editor/studio_plugin_tile_editor.xml @@ -1,10 +1,10 @@ - - studio_plugin_tile_editor - TileEditor - 1.0 - Ryzom Core - Tile bank editing plugin. - - - + + studio_plugin_tile_editor + TileEditor + 1.0 + Ryzom Core + Tile bank editing plugin. + + + \ No newline at end of file diff --git a/code/studio/src/plugins/tile_editor/tile_bank.cpp b/code/studio/src/plugins/tile_editor/tile_bank.cpp index 8e4d8f511..8e3578eeb 100644 --- a/code/studio/src/plugins/tile_editor/tile_bank.cpp +++ b/code/studio/src/plugins/tile_editor/tile_bank.cpp @@ -1,642 +1,642 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "tile_bank.h" -#include "nel/3d/tile_bank.h" - -#include - -namespace{ - - bool pixmapToCBGRA( QPixmap &pixmap, std::vector< NLMISC::CBGRA >& pixels ) - { - QImage img = pixmap.toImage(); - if( img.format() != QImage::Format_ARGB32 ) - img = img.convertToFormat( QImage::Format_ARGB32 ); - - if( img.format() != QImage::Format_ARGB32 ) - return false; - - int c = img.width() * img.height(); - - const unsigned char *data = img.bits(); - const unsigned int *idata = reinterpret_cast< const unsigned int* >( data ); - - NLMISC::CBGRA bgra; - pixels.clear(); - - int i = 0; - while( i < c ) - { - bgra.A = ( idata[ i ] & 0xFF000000 ) >> 24; - bgra.R = ( idata[ i ] & 0x00FF0000 ) >> 16; - bgra.G = ( idata[ i ] & 0x0000FF00 ) >> 8; - bgra.B = ( idata[ i ] & 0x000000FF ); - pixels.push_back( bgra ); - - i++; - } - - return true; - } - - - NL3D::CTile::TBitmap channelToTBitmap( TileConstants::TTileChannel channel ) - { - return NL3D::CTile::TBitmap( int( channel ) ); - } - - -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -class TileBankPvt -{ -public: - - bool checkSize( TileConstants::TNodeTileType type, TileConstants::TTileChannel channel, int w, int h ) - { - int width = -1; - - switch( type ) - { - case TileConstants::Tile128: - width = 128; - break; - - case TileConstants::Tile256: - width = 256; - break; - - case TileConstants::TileTransition: - { - if( channel == TileConstants::TileAlpha ) - width = 64; - else - width = 128; - - } - break; - - case TileConstants::TileDisplacement: - width = 32; - break; - } - - if( width == w ) - return true; - - return false; - } - - NL3D::CTileSet::TError checkTile( NL3D::CTileSet *set, int tile, TileConstants::TNodeTileType type, NL3D::CTileBorder &border, NL3D::CTile::TBitmap bitmap, QString &msg ) - { - NL3D::CTileSet::TError error; - - if( bitmap == NL3D::CTile::additive ) - return NL3D::CTileSet::ok; - - if( type == TileConstants::TileDisplacement ) - return NL3D::CTileSet::ok; - - int component; - int pixel; - int idx; - - switch( type ) - { - case TileConstants::Tile128: - error = set->checkTile128( bitmap, border, pixel, component ); - break; - - case TileConstants::Tile256: - error = set->checkTile256( bitmap, border, pixel, component ); - break; - - case TileConstants::TileTransition: - { - if( bitmap != NL3D::CTile::alpha ) - error = set->checkTile128( bitmap, border, pixel, component ); - else - error = set->checkTileTransition( NL3D::CTileSet::TTransition( tile ), bitmap, border, idx, pixel, component ); - - break; - } - } - - if( ( error != NL3D::CTileSet::ok ) && ( error != NL3D::CTileSet::addFirstA128128 ) ) - { - static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; - - msg = NL3D::CTileSet::getErrorMessage( error ); - msg += "\n"; - msg += " pixel %1 component %2"; - msg = msg.arg( pixel ); - msg = msg.arg( comp[ component ] ); - } - - return error; - } - - void setTile( NL3D::CTileSet *set, int tile, int rotation, const QString &name, NL3D::CTile::TBitmap bm, TileConstants::TNodeTileType type, NL3D::CTileBorder &border ) - { - switch( type ) - { - case TileConstants::Tile128: - set->setTile128( tile, name.toUtf8().constData(), bm, m_bank ); - break; - - case TileConstants::Tile256: - set->setTile256( tile, name.toUtf8().constData(), bm, m_bank ); - break; - - case TileConstants::TileTransition: - if( bm != NL3D::CTile::alpha ) - set->setTileTransition( NL3D::CTileSet::TTransition( tile ), name.toUtf8().constData(), bm, m_bank, border ); - else - set->setTileTransitionAlpha( NL3D::CTileSet::TTransition( tile ), name.toUtf8().constData(), m_bank, border, rotation ); - break; - - case TileConstants::TileDisplacement: - set->setDisplacement( NL3D::CTileSet::TDisplacement( tile ), name.toUtf8().constData(), m_bank ); - break; - } - - } - - void buildBorder( QPixmap &pm, NL3D::CTileBorder &border ) - { - std::vector< NLMISC::CBGRA > pixels; - pixmapToCBGRA( pm, pixels ); - border.set( pm.width(), pm.height(), pixels ); - } - - NL3D::CTileBank m_bank; -}; - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -TileBank::TileBank() -{ - m_pvt = new TileBankPvt(); - resetError(); - m_rotation = 0; -} - -TileBank::~TileBank() -{ - delete m_pvt; -} - -void TileBank::addTileSet( const QString &name ) -{ - m_pvt->m_bank.addTileSet( name.toUtf8().constData() ); - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( 0 ); -} - -void TileBank::removeTileSet( int idx ) -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( idx ); - if( set == NULL ) - return; - - int c = m_pvt->m_bank.getLandCount(); - for( int i = 0; i < c; i++ ) - { - NL3D::CTileLand *land = m_pvt->m_bank.getLand( i ); - land->removeTileSet( set->getName() ); - } - - m_pvt->m_bank.removeTileSet( idx ); -} - -void TileBank::renameTileSet( int idx, const QString &newName ) -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( idx ); - if( set == NULL ) - return; - - std::string oldName = set->getName(); - set->setName( newName.toUtf8().constData() ); - - int c = m_pvt->m_bank.getLandCount(); - for( int i = 0; i < c; i++ ) - { - NL3D::CTileLand *land = m_pvt->m_bank.getLand( i ); - land->removeTileSet( oldName ); - land->addTileSet( newName.toUtf8().constData() ); - } - -} - -void TileBank::getTileSets( QStringList &l ) -{ - int c = m_pvt->m_bank.getTileSetCount(); - for( int i = 0; i < c; i++ ) - { - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( i ); - l.push_back( set->getName().c_str() ); - } -} - -void TileBank::addLand( const QString &name ) -{ - m_pvt->m_bank.addLand( name.toUtf8().constData() ); -} - -void TileBank::removeLand( int idx ) -{ - m_pvt->m_bank.removeLand( idx ); -} - -void TileBank::getLands( QStringList &l ) -{ - l.clear(); - - int c = m_pvt->m_bank.getLandCount(); - for( int i = 0; i < c; i++ ) - { - NL3D::CTileLand *land = m_pvt->m_bank.getLand( i ); - l.push_back( land->getName().c_str() ); - } -} - -void TileBank::setLandSets( int idx, const QStringList &l ) -{ - NL3D::CTileLand *land = m_pvt->m_bank.getLand( idx ); - land->clear(); - - QStringListIterator itr( l ); - while( itr.hasNext() ) - { - land->addTileSet( itr.next().toUtf8().constData() ); - } -} - -void TileBank::getLandSets( int idx, QStringList &l ) -{ - NL3D::CTileLand *land = m_pvt->m_bank.getLand( idx ); - if( land == NULL ) - return; - - l.clear(); - - std::set< std::string> sets = land->getTileSets(); - std::set< std::string >::const_iterator itr = sets.begin(); - while( itr != sets.end() ) - { - l.push_back( itr->c_str() ); - ++itr; - } -} - -bool TileBank::addTile( int setIdx, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type ) -{ - resetError(); - - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( setIdx ); - - int tile; - switch( type ) - { - case TileConstants::Tile128: set->addTile128( tile, m_pvt->m_bank ); break; - case TileConstants::Tile256: set->addTile256( tile, m_pvt->m_bank ); break; - } - - bool b = setTile( setIdx, tile, name, pixmap, channel, type ); - if( b ) - return true; - - // There was an error, roll back - switch( type ) - { - case TileConstants::Tile128: set->removeTile128( tile, m_pvt->m_bank ); break; - case TileConstants::Tile256: set->removeTile256( tile, m_pvt->m_bank ); break; - } - - return false; -} - -void TileBank::removeTile( int ts, int type, int tile ) -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( ts ); - - switch( type ) - { - case TileConstants::Tile128: set->removeTile128( tile, m_pvt->m_bank ); break; - case TileConstants::Tile256: set->removeTile256( tile, m_pvt->m_bank ); break; - } -} - -bool TileBank::setTile( int tileset, int tile, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type ) -{ - resetError(); - - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileset ); - if( set == NULL ) - return false; - - QPixmap pm = pixmap.value< QPixmap >(); - if( pm.isNull() ) - { - m_hasError = true; - m_lastError = "Failed to load image."; - return false; - } - - if( pm.width() != pm.height() ) - { - m_hasError = true; - m_lastError = "Image isn't square."; - return false; - } - - if( !m_pvt->checkSize( type, channel, pm.width(), pm.height() ) ) - { - m_hasError = true; - m_lastError = "Invalid image size."; - return false; - } - - NL3D::CTileBorder border; - m_pvt->buildBorder( pm, border ); - - if( ( type == TileConstants::TileTransition ) && ( channel == TileConstants::TileAlpha ) ) - { - int rotBits = m_rotation; - while( rotBits > 0 ) - { - border.rotate(); - rotBits--; - } - } - - QString msg; - NL3D::CTileSet::TError error = m_pvt->checkTile( set, tile, type, border, channelToTBitmap( channel ), msg ); - - // Tile checks out fine, set it - if( ( error == NL3D::CTileSet::ok ) || ( error == NL3D::CTileSet::addFirstA128128 ) ) - { - if( error == NL3D::CTileSet::addFirstA128128 ) - set->setBorder( channelToTBitmap( channel ), border ); - - m_pvt->setTile( set, tile, m_rotation, name, channelToTBitmap( channel ), type, border ); - - return true; - } - - setError( msg ); - - return false; -} - -void TileBank::replaceImage( int ts, int type, int tile, TileConstants::TTileChannel channel, const QString &name, const QVariant &pixmap ) -{ - setTile( ts, tile, name, pixmap, channel, TileConstants::TNodeTileType( type ) ); -} - -void TileBank::clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel ) -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( ts ); - - int tileId; - - NL3D::CTile::TBitmap bm = channelToTBitmap( channel ); - - switch( type ) - { - case TileConstants::Tile128: - set->clearTile128( tile, bm, m_pvt->m_bank ); - break; - - case TileConstants::Tile256: - set->clearTile256( tile, bm, m_pvt->m_bank ); - break; - - case TileConstants::TileTransition: - set->clearTransition( NL3D::CTileSet::TTransition( tile ), bm, m_pvt->m_bank ); - break; - - case TileConstants::TileDisplacement: - set->clearDisplacement( NL3D::CTileSet::TDisplacement( tile ), m_pvt->m_bank ); - break; - } - -} - -int TileBank::getTileCount( int tileSet, TileConstants::TNodeTileType type ) -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); - if( set == NULL ) - return -1; - - int c = 0; - - switch( type ) - { - case TileConstants::Tile128: - c = set->getNumTile128(); - break; - - case TileConstants::Tile256: - c = set->getNumTile256(); - break; - - case TileConstants::TileTransition: - c = NL3D::CTileSet::count; - break; - - case TileConstants::TileDisplacement: - c = NL3D::CTileSet::CountDisplace; - break; - } - - return c; -} - -int TileBank::getRealTileId( int tileSet, TileConstants::TNodeTileType type, int tileIdInSet ) -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); - if( set == NULL ) - return -1; - - int tile = -1; - - switch( type ) - { - case TileConstants::Tile128: - tile = set->getTile128( tileIdInSet ); - break; - - case TileConstants::Tile256: - tile = set->getTile256( tileIdInSet ); - break; - - case TileConstants::TileTransition: - tile = set->getTransition( tileIdInSet )->getTile(); - break; - - case TileConstants::TileDisplacement: - tile = set->getDisplacementTile( NL3D::CTileSet::TDisplacement( tileIdInSet ) ); - break; - } - - return tile; -} - -void TileBank::getTileImages( int tileSet, TileConstants::TNodeTileType type, int tileId, TileImages &images ) -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); - if( set == NULL ) - return; - - switch( type ) - { - case TileConstants::Tile128: - case TileConstants::Tile256: - case TileConstants::TileTransition: - { - NL3D::CTile *t = m_pvt->m_bank.getTile( tileId ); - if( t == NULL ) - return; - - images.diffuse = t->getFileName( channelToTBitmap( TileConstants::TileDiffuse ) ).c_str(); - images.additive = t->getFileName( channelToTBitmap( TileConstants::TileAdditive ) ).c_str(); - images.alpha = t->getFileName( channelToTBitmap( TileConstants::TileAlpha ) ).c_str(); - } - break; - - case TileConstants::TileDisplacement: - { - images.diffuse = m_pvt->m_bank.getDisplacementMap( tileId ); - } - break; - } - -} - -void TileBank::getTileImages( int tileSet, TileConstants::TNodeTileType type, QList< TileImages > &l ) -{ - l.clear(); - - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); - if( set == NULL ) - return; - - int c = getTileCount( tileSet, type ); - - TileImages images; - - for( int i = 0; i < c; i++ ) - { - images.clear(); - - int id = getRealTileId( tileSet, type, i ); - if( id < 0 ) - { - l.push_back( images ); - continue; - } - - getTileImages( tileSet, type, id, images ); - - l.push_back( images ); - } - -} - -void TileBank::setVegetation( int tileSet, const QString &vegetation ) -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); - if( set == NULL ) - return; - - set->setTileVegetableDescFileName( vegetation.toUtf8().constData() ); -} - - -QString TileBank::getVegetation( int tileSet ) const -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); - if( set == NULL ) - return ""; - - return set->getTileVegetableDescFileName().c_str(); -} - -void TileBank::setOriented( int tileSet, bool b ) -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); - if( set == NULL ) - return; - - set->setOriented( b ); -} - -bool TileBank::getOriented( int tileSet ) const -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); - if( set == NULL ) - return false; - - return set->getOriented(); -} - - -void TileBank::setSurfaceData( int tileSet, unsigned long data ) -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); - if( set == NULL ) - return; - - set->SurfaceData = data; -} - -unsigned long TileBank::getSurfaceData( int tileSet ) const -{ - NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); - if( set == NULL ) - return 0; - - return set->SurfaceData; -} - -void TileBank::setTexturePath( const QString &path ) -{ - m_pvt->m_bank.setAbsPath( path.toUtf8().constData() ); -} - -QString TileBank::getTexturePath() const -{ - return m_pvt->m_bank.getAbsPath().c_str(); -} - -void TileBank::setRotation( int rotation ) -{ - m_rotation = rotation; -} - -void TileBank::serial( NLMISC::IStream &f ) -{ - m_pvt->m_bank.serial( f ); -} - - +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "tile_bank.h" +#include "nel/3d/tile_bank.h" + +#include + +namespace{ + + bool pixmapToCBGRA( QPixmap &pixmap, std::vector< NLMISC::CBGRA >& pixels ) + { + QImage img = pixmap.toImage(); + if( img.format() != QImage::Format_ARGB32 ) + img = img.convertToFormat( QImage::Format_ARGB32 ); + + if( img.format() != QImage::Format_ARGB32 ) + return false; + + int c = img.width() * img.height(); + + const unsigned char *data = img.bits(); + const unsigned int *idata = reinterpret_cast< const unsigned int* >( data ); + + NLMISC::CBGRA bgra; + pixels.clear(); + + int i = 0; + while( i < c ) + { + bgra.A = ( idata[ i ] & 0xFF000000 ) >> 24; + bgra.R = ( idata[ i ] & 0x00FF0000 ) >> 16; + bgra.G = ( idata[ i ] & 0x0000FF00 ) >> 8; + bgra.B = ( idata[ i ] & 0x000000FF ); + pixels.push_back( bgra ); + + i++; + } + + return true; + } + + + NL3D::CTile::TBitmap channelToTBitmap( TileConstants::TTileChannel channel ) + { + return NL3D::CTile::TBitmap( int( channel ) ); + } + + +} + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + +class TileBankPvt +{ +public: + + bool checkSize( TileConstants::TNodeTileType type, TileConstants::TTileChannel channel, int w, int h ) + { + int width = -1; + + switch( type ) + { + case TileConstants::Tile128: + width = 128; + break; + + case TileConstants::Tile256: + width = 256; + break; + + case TileConstants::TileTransition: + { + if( channel == TileConstants::TileAlpha ) + width = 64; + else + width = 128; + + } + break; + + case TileConstants::TileDisplacement: + width = 32; + break; + } + + if( width == w ) + return true; + + return false; + } + + NL3D::CTileSet::TError checkTile( NL3D::CTileSet *set, int tile, TileConstants::TNodeTileType type, NL3D::CTileBorder &border, NL3D::CTile::TBitmap bitmap, QString &msg ) + { + NL3D::CTileSet::TError error; + + if( bitmap == NL3D::CTile::additive ) + return NL3D::CTileSet::ok; + + if( type == TileConstants::TileDisplacement ) + return NL3D::CTileSet::ok; + + int component; + int pixel; + int idx; + + switch( type ) + { + case TileConstants::Tile128: + error = set->checkTile128( bitmap, border, pixel, component ); + break; + + case TileConstants::Tile256: + error = set->checkTile256( bitmap, border, pixel, component ); + break; + + case TileConstants::TileTransition: + { + if( bitmap != NL3D::CTile::alpha ) + error = set->checkTile128( bitmap, border, pixel, component ); + else + error = set->checkTileTransition( NL3D::CTileSet::TTransition( tile ), bitmap, border, idx, pixel, component ); + + break; + } + } + + if( ( error != NL3D::CTileSet::ok ) && ( error != NL3D::CTileSet::addFirstA128128 ) ) + { + static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; + + msg = NL3D::CTileSet::getErrorMessage( error ); + msg += "\n"; + msg += " pixel %1 component %2"; + msg = msg.arg( pixel ); + msg = msg.arg( comp[ component ] ); + } + + return error; + } + + void setTile( NL3D::CTileSet *set, int tile, int rotation, const QString &name, NL3D::CTile::TBitmap bm, TileConstants::TNodeTileType type, NL3D::CTileBorder &border ) + { + switch( type ) + { + case TileConstants::Tile128: + set->setTile128( tile, name.toUtf8().constData(), bm, m_bank ); + break; + + case TileConstants::Tile256: + set->setTile256( tile, name.toUtf8().constData(), bm, m_bank ); + break; + + case TileConstants::TileTransition: + if( bm != NL3D::CTile::alpha ) + set->setTileTransition( NL3D::CTileSet::TTransition( tile ), name.toUtf8().constData(), bm, m_bank, border ); + else + set->setTileTransitionAlpha( NL3D::CTileSet::TTransition( tile ), name.toUtf8().constData(), m_bank, border, rotation ); + break; + + case TileConstants::TileDisplacement: + set->setDisplacement( NL3D::CTileSet::TDisplacement( tile ), name.toUtf8().constData(), m_bank ); + break; + } + + } + + void buildBorder( QPixmap &pm, NL3D::CTileBorder &border ) + { + std::vector< NLMISC::CBGRA > pixels; + pixmapToCBGRA( pm, pixels ); + border.set( pm.width(), pm.height(), pixels ); + } + + NL3D::CTileBank m_bank; +}; + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +TileBank::TileBank() +{ + m_pvt = new TileBankPvt(); + resetError(); + m_rotation = 0; +} + +TileBank::~TileBank() +{ + delete m_pvt; +} + +void TileBank::addTileSet( const QString &name ) +{ + m_pvt->m_bank.addTileSet( name.toUtf8().constData() ); + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( 0 ); +} + +void TileBank::removeTileSet( int idx ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( idx ); + if( set == NULL ) + return; + + int c = m_pvt->m_bank.getLandCount(); + for( int i = 0; i < c; i++ ) + { + NL3D::CTileLand *land = m_pvt->m_bank.getLand( i ); + land->removeTileSet( set->getName() ); + } + + m_pvt->m_bank.removeTileSet( idx ); +} + +void TileBank::renameTileSet( int idx, const QString &newName ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( idx ); + if( set == NULL ) + return; + + std::string oldName = set->getName(); + set->setName( newName.toUtf8().constData() ); + + int c = m_pvt->m_bank.getLandCount(); + for( int i = 0; i < c; i++ ) + { + NL3D::CTileLand *land = m_pvt->m_bank.getLand( i ); + land->removeTileSet( oldName ); + land->addTileSet( newName.toUtf8().constData() ); + } + +} + +void TileBank::getTileSets( QStringList &l ) +{ + int c = m_pvt->m_bank.getTileSetCount(); + for( int i = 0; i < c; i++ ) + { + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( i ); + l.push_back( set->getName().c_str() ); + } +} + +void TileBank::addLand( const QString &name ) +{ + m_pvt->m_bank.addLand( name.toUtf8().constData() ); +} + +void TileBank::removeLand( int idx ) +{ + m_pvt->m_bank.removeLand( idx ); +} + +void TileBank::getLands( QStringList &l ) +{ + l.clear(); + + int c = m_pvt->m_bank.getLandCount(); + for( int i = 0; i < c; i++ ) + { + NL3D::CTileLand *land = m_pvt->m_bank.getLand( i ); + l.push_back( land->getName().c_str() ); + } +} + +void TileBank::setLandSets( int idx, const QStringList &l ) +{ + NL3D::CTileLand *land = m_pvt->m_bank.getLand( idx ); + land->clear(); + + QStringListIterator itr( l ); + while( itr.hasNext() ) + { + land->addTileSet( itr.next().toUtf8().constData() ); + } +} + +void TileBank::getLandSets( int idx, QStringList &l ) +{ + NL3D::CTileLand *land = m_pvt->m_bank.getLand( idx ); + if( land == NULL ) + return; + + l.clear(); + + std::set< std::string> sets = land->getTileSets(); + std::set< std::string >::const_iterator itr = sets.begin(); + while( itr != sets.end() ) + { + l.push_back( itr->c_str() ); + ++itr; + } +} + +bool TileBank::addTile( int setIdx, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type ) +{ + resetError(); + + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( setIdx ); + + int tile; + switch( type ) + { + case TileConstants::Tile128: set->addTile128( tile, m_pvt->m_bank ); break; + case TileConstants::Tile256: set->addTile256( tile, m_pvt->m_bank ); break; + } + + bool b = setTile( setIdx, tile, name, pixmap, channel, type ); + if( b ) + return true; + + // There was an error, roll back + switch( type ) + { + case TileConstants::Tile128: set->removeTile128( tile, m_pvt->m_bank ); break; + case TileConstants::Tile256: set->removeTile256( tile, m_pvt->m_bank ); break; + } + + return false; +} + +void TileBank::removeTile( int ts, int type, int tile ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( ts ); + + switch( type ) + { + case TileConstants::Tile128: set->removeTile128( tile, m_pvt->m_bank ); break; + case TileConstants::Tile256: set->removeTile256( tile, m_pvt->m_bank ); break; + } +} + +bool TileBank::setTile( int tileset, int tile, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type ) +{ + resetError(); + + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileset ); + if( set == NULL ) + return false; + + QPixmap pm = pixmap.value< QPixmap >(); + if( pm.isNull() ) + { + m_hasError = true; + m_lastError = "Failed to load image."; + return false; + } + + if( pm.width() != pm.height() ) + { + m_hasError = true; + m_lastError = "Image isn't square."; + return false; + } + + if( !m_pvt->checkSize( type, channel, pm.width(), pm.height() ) ) + { + m_hasError = true; + m_lastError = "Invalid image size."; + return false; + } + + NL3D::CTileBorder border; + m_pvt->buildBorder( pm, border ); + + if( ( type == TileConstants::TileTransition ) && ( channel == TileConstants::TileAlpha ) ) + { + int rotBits = m_rotation; + while( rotBits > 0 ) + { + border.rotate(); + rotBits--; + } + } + + QString msg; + NL3D::CTileSet::TError error = m_pvt->checkTile( set, tile, type, border, channelToTBitmap( channel ), msg ); + + // Tile checks out fine, set it + if( ( error == NL3D::CTileSet::ok ) || ( error == NL3D::CTileSet::addFirstA128128 ) ) + { + if( error == NL3D::CTileSet::addFirstA128128 ) + set->setBorder( channelToTBitmap( channel ), border ); + + m_pvt->setTile( set, tile, m_rotation, name, channelToTBitmap( channel ), type, border ); + + return true; + } + + setError( msg ); + + return false; +} + +void TileBank::replaceImage( int ts, int type, int tile, TileConstants::TTileChannel channel, const QString &name, const QVariant &pixmap ) +{ + setTile( ts, tile, name, pixmap, channel, TileConstants::TNodeTileType( type ) ); +} + +void TileBank::clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( ts ); + + int tileId; + + NL3D::CTile::TBitmap bm = channelToTBitmap( channel ); + + switch( type ) + { + case TileConstants::Tile128: + set->clearTile128( tile, bm, m_pvt->m_bank ); + break; + + case TileConstants::Tile256: + set->clearTile256( tile, bm, m_pvt->m_bank ); + break; + + case TileConstants::TileTransition: + set->clearTransition( NL3D::CTileSet::TTransition( tile ), bm, m_pvt->m_bank ); + break; + + case TileConstants::TileDisplacement: + set->clearDisplacement( NL3D::CTileSet::TDisplacement( tile ), m_pvt->m_bank ); + break; + } + +} + +int TileBank::getTileCount( int tileSet, TileConstants::TNodeTileType type ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return -1; + + int c = 0; + + switch( type ) + { + case TileConstants::Tile128: + c = set->getNumTile128(); + break; + + case TileConstants::Tile256: + c = set->getNumTile256(); + break; + + case TileConstants::TileTransition: + c = NL3D::CTileSet::count; + break; + + case TileConstants::TileDisplacement: + c = NL3D::CTileSet::CountDisplace; + break; + } + + return c; +} + +int TileBank::getRealTileId( int tileSet, TileConstants::TNodeTileType type, int tileIdInSet ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return -1; + + int tile = -1; + + switch( type ) + { + case TileConstants::Tile128: + tile = set->getTile128( tileIdInSet ); + break; + + case TileConstants::Tile256: + tile = set->getTile256( tileIdInSet ); + break; + + case TileConstants::TileTransition: + tile = set->getTransition( tileIdInSet )->getTile(); + break; + + case TileConstants::TileDisplacement: + tile = set->getDisplacementTile( NL3D::CTileSet::TDisplacement( tileIdInSet ) ); + break; + } + + return tile; +} + +void TileBank::getTileImages( int tileSet, TileConstants::TNodeTileType type, int tileId, TileImages &images ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return; + + switch( type ) + { + case TileConstants::Tile128: + case TileConstants::Tile256: + case TileConstants::TileTransition: + { + NL3D::CTile *t = m_pvt->m_bank.getTile( tileId ); + if( t == NULL ) + return; + + images.diffuse = t->getFileName( channelToTBitmap( TileConstants::TileDiffuse ) ).c_str(); + images.additive = t->getFileName( channelToTBitmap( TileConstants::TileAdditive ) ).c_str(); + images.alpha = t->getFileName( channelToTBitmap( TileConstants::TileAlpha ) ).c_str(); + } + break; + + case TileConstants::TileDisplacement: + { + images.diffuse = m_pvt->m_bank.getDisplacementMap( tileId ); + } + break; + } + +} + +void TileBank::getTileImages( int tileSet, TileConstants::TNodeTileType type, QList< TileImages > &l ) +{ + l.clear(); + + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return; + + int c = getTileCount( tileSet, type ); + + TileImages images; + + for( int i = 0; i < c; i++ ) + { + images.clear(); + + int id = getRealTileId( tileSet, type, i ); + if( id < 0 ) + { + l.push_back( images ); + continue; + } + + getTileImages( tileSet, type, id, images ); + + l.push_back( images ); + } + +} + +void TileBank::setVegetation( int tileSet, const QString &vegetation ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return; + + set->setTileVegetableDescFileName( vegetation.toUtf8().constData() ); +} + + +QString TileBank::getVegetation( int tileSet ) const +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return ""; + + return set->getTileVegetableDescFileName().c_str(); +} + +void TileBank::setOriented( int tileSet, bool b ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return; + + set->setOriented( b ); +} + +bool TileBank::getOriented( int tileSet ) const +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return false; + + return set->getOriented(); +} + + +void TileBank::setSurfaceData( int tileSet, unsigned long data ) +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return; + + set->SurfaceData = data; +} + +unsigned long TileBank::getSurfaceData( int tileSet ) const +{ + NL3D::CTileSet *set = m_pvt->m_bank.getTileSet( tileSet ); + if( set == NULL ) + return 0; + + return set->SurfaceData; +} + +void TileBank::setTexturePath( const QString &path ) +{ + m_pvt->m_bank.setAbsPath( path.toUtf8().constData() ); +} + +QString TileBank::getTexturePath() const +{ + return m_pvt->m_bank.getAbsPath().c_str(); +} + +void TileBank::setRotation( int rotation ) +{ + m_rotation = rotation; +} + +void TileBank::serial( NLMISC::IStream &f ) +{ + m_pvt->m_bank.serial( f ); +} + + diff --git a/code/studio/src/plugins/tile_editor/tile_bank.h b/code/studio/src/plugins/tile_editor/tile_bank.h index a4620ad41..9d765b8ae 100644 --- a/code/studio/src/plugins/tile_editor/tile_bank.h +++ b/code/studio/src/plugins/tile_editor/tile_bank.h @@ -1,102 +1,102 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#ifndef TILE_BANK_H -#define TILE_BANK_H - -#include -#include -#include -#include - -#include "tile_constants.h" -#include "tile_images.h" - -namespace NLMISC -{ - class IStream; -} - -class TileBankPvt; - -class TileBank -{ -public: - TileBank(); - ~TileBank(); - - void addTileSet( const QString &name ); - void removeTileSet( int idx ); - void renameTileSet( int idx, const QString &newName ); - void getTileSets( QStringList &l ); - - void addLand( const QString &name ); - void removeLand( int idx ); - void getLands( QStringList &l ); - void setLandSets( int idx, const QStringList &l ); - void getLandSets( int idx, QStringList &l ); - - bool addTile( int setIdx, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type ); - void removeTile( int ts, int type, int tile ); - bool setTile( int tileset, int tile, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type ); - void replaceImage( int ts, int type, int tile, TileConstants::TTileChannel channel, const QString &name, const QVariant &pixmap ); - void clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel ); - - - int getTileCount( int tileSet, TileConstants::TNodeTileType type ); - int getRealTileId( int tileSet, TileConstants::TNodeTileType type, int tileIdInSet ); - void getTileImages( int tileSet, TileConstants::TNodeTileType type, int tileId, TileImages &images ); - void getTileImages( int tileSet, TileConstants::TNodeTileType type, QList< TileImages > &l ); - - void setVegetation( int tileSet, const QString &vegetation ); - QString getVegetation( int tileSet ) const; - - void setOriented( int tileSet, bool b ); - bool getOriented( int tileSet ) const; - - void setSurfaceData( int tileSet, unsigned long data ); - unsigned long getSurfaceData( int tileSet ) const; - - void setTexturePath( const QString &path ); - QString getTexturePath() const; - - void setRotation( int rotation ); - - void serial( NLMISC::IStream &f ); - - bool hasError() const{ return m_hasError; } - QString getLastError() const{ return m_lastError; } - void resetError(){ - m_hasError = false; - m_lastError = ""; - } - - void setError( const QString &msg ) - { - m_hasError = true; - m_lastError = msg; - } - -private: - TileBankPvt *m_pvt; - QString m_lastError; - bool m_hasError; - int m_rotation; -}; - -#endif - +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef TILE_BANK_H +#define TILE_BANK_H + +#include +#include +#include +#include + +#include "tile_constants.h" +#include "tile_images.h" + +namespace NLMISC +{ + class IStream; +} + +class TileBankPvt; + +class TileBank +{ +public: + TileBank(); + ~TileBank(); + + void addTileSet( const QString &name ); + void removeTileSet( int idx ); + void renameTileSet( int idx, const QString &newName ); + void getTileSets( QStringList &l ); + + void addLand( const QString &name ); + void removeLand( int idx ); + void getLands( QStringList &l ); + void setLandSets( int idx, const QStringList &l ); + void getLandSets( int idx, QStringList &l ); + + bool addTile( int setIdx, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type ); + void removeTile( int ts, int type, int tile ); + bool setTile( int tileset, int tile, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type ); + void replaceImage( int ts, int type, int tile, TileConstants::TTileChannel channel, const QString &name, const QVariant &pixmap ); + void clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel ); + + + int getTileCount( int tileSet, TileConstants::TNodeTileType type ); + int getRealTileId( int tileSet, TileConstants::TNodeTileType type, int tileIdInSet ); + void getTileImages( int tileSet, TileConstants::TNodeTileType type, int tileId, TileImages &images ); + void getTileImages( int tileSet, TileConstants::TNodeTileType type, QList< TileImages > &l ); + + void setVegetation( int tileSet, const QString &vegetation ); + QString getVegetation( int tileSet ) const; + + void setOriented( int tileSet, bool b ); + bool getOriented( int tileSet ) const; + + void setSurfaceData( int tileSet, unsigned long data ); + unsigned long getSurfaceData( int tileSet ) const; + + void setTexturePath( const QString &path ); + QString getTexturePath() const; + + void setRotation( int rotation ); + + void serial( NLMISC::IStream &f ); + + bool hasError() const{ return m_hasError; } + QString getLastError() const{ return m_lastError; } + void resetError(){ + m_hasError = false; + m_lastError = ""; + } + + void setError( const QString &msg ) + { + m_hasError = true; + m_lastError = msg; + } + +private: + TileBankPvt *m_pvt; + QString m_lastError; + bool m_hasError; + int m_rotation; +}; + +#endif + diff --git a/code/studio/src/plugins/tile_editor/tile_constants.h b/code/studio/src/plugins/tile_editor/tile_constants.h index bf09f21a5..56748cb58 100644 --- a/code/studio/src/plugins/tile_editor/tile_constants.h +++ b/code/studio/src/plugins/tile_editor/tile_constants.h @@ -1,43 +1,43 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#ifndef TILE_CONSTANTS_H -#define TILE_CONSTANTS_H - - -namespace TileConstants -{ - enum TTileChannel - { - TileDiffuse = 0, - TileAdditive = 1, - TileAlpha = 2, - TileChannelCount = 3 - }; - - enum TNodeTileType - { - Tile128 = 0, - Tile256 = 1, - TileTransition = 2, - TileDisplacement = 3, - TileNodeTypeCount = 4 - }; -} - - -#endif +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef TILE_CONSTANTS_H +#define TILE_CONSTANTS_H + + +namespace TileConstants +{ + enum TTileChannel + { + TileDiffuse = 0, + TileAdditive = 1, + TileAlpha = 2, + TileChannelCount = 3 + }; + + enum TNodeTileType + { + Tile128 = 0, + Tile256 = 1, + TileTransition = 2, + TileDisplacement = 3, + TileNodeTypeCount = 4 + }; +} + + +#endif diff --git a/code/studio/src/plugins/tile_editor/tile_images.h b/code/studio/src/plugins/tile_editor/tile_images.h index e17267001..280e0a126 100644 --- a/code/studio/src/plugins/tile_editor/tile_images.h +++ b/code/studio/src/plugins/tile_editor/tile_images.h @@ -1,40 +1,40 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#ifndef TILE_IMAGES_H -#define TILE_IMAGES_H - -#include - -struct TileImages -{ - QString diffuse; - QString additive; - QString alpha; - - void clear() - { - diffuse.clear(); - additive.clear(); - alpha.clear(); - } -}; - - - -#endif - +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef TILE_IMAGES_H +#define TILE_IMAGES_H + +#include + +struct TileImages +{ + QString diffuse; + QString additive; + QString alpha; + + void clear() + { + diffuse.clear(); + additive.clear(); + alpha.clear(); + } +}; + + + +#endif + diff --git a/code/studio/src/plugins/tile_editor/tile_item_delegate.cpp b/code/studio/src/plugins/tile_editor/tile_item_delegate.cpp index 43751d612..6f9479354 100644 --- a/code/studio/src/plugins/tile_editor/tile_item_delegate.cpp +++ b/code/studio/src/plugins/tile_editor/tile_item_delegate.cpp @@ -1,122 +1,122 @@ -// Object Viewer Qt - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include - -#include - -#include "tile_item_delegate.h" - -#include "tile_model.h" - -TileItemDelegate::TileItemDelegate() -{ - m_zoomFactor = ZoomNormal; - m_imageHint = 128; -} - -TileItemDelegate::~TileItemDelegate() -{ -} - -void TileItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - QStyledItemDelegate::paint(painter,option,index); - - painter->save(); - - QFont font = QApplication::font(); - - //font.setBold(true); - //SubFont.setWeight(SubFont.weight()-2); - QFontMetrics fm(font); - - QPixmap tile = qvariant_cast(index.data(TileModel::TilePixmapRole)); - QString tileFileText = qvariant_cast(index.data(TileModel::TileFilenameRole)); - QString tileIdText = qvariant_cast(index.data(TileModel::TileIndexRole)); - - QSize tileSize = tile.size(); - - //QRect headerRect = option.rect; - QRect rect(option.rect); - //QRect tileRect(option.rect); - int textHeight = fm.height(); - int iconPosModX = PIXMAP_MARGIN + (tile.width() / 2); - int iconPosModY = (option.rect.height() - tile.height()) / 2; - - painter->drawPixmap(rect.adjusted(iconPosModX, iconPosModY, iconPosModX, iconPosModY).topLeft(), tile); - - - - //tileRect.setRight(tileSize.width()+30); - //tileRect.setTop(tileRect.top()+5); - //headerRect.setLeft(tileRect.right()); - //subheaderRect.setLeft(tileRect.right()); - //headerRect.setTop(headerRect.top()+5); - //headerRect.setBottom(headerRect.top()+fm.height()); - - //subheaderRect.setTop(headerRect.bottom()+2); - - //painter->drawPixmap(targetrect, pixmap, sourcerect) - - //painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height())); - //painter->drawPixmap(QPoint(tileRect.left()+tileSize.width()/2+2,tileRect.top()+tileSize.height()/2+3),tile); - - //painter->setFont(font); - //painter->drawText(headerRect,headerText); - - - //painter->setFont(SubFont); - //painter->drawText(subheaderRect.left(),subheaderRect.top()+17,subText); - - painter->restore(); -} - -QSize TileItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const -{ - QPixmap tile = qvariant_cast(index.data(TileModel::TilePixmapRole)); - QSize tileSize = tile.size(); - QFont font = QApplication::font(); - QFontMetrics fm(font); - - return(QSize(tileSize.width()+(2*PIXMAP_MARGIN), tileSize.height()+fm.height()+(2*PIXMAP_MARGIN))); -} - -TileItemDelegate::TZoomFactor TileItemDelegate::getZoomFactor() -{ - return m_zoomFactor; -} - -void TileItemDelegate::setZoomFactor(TileItemDelegate::TZoomFactor zoomFactor) -{ - m_zoomFactor = zoomFactor; -} - -// SLOTS - -void TileItemDelegate::currentTab(int index) -{ - if(index == 1) - { - nlinfo("switching delegate to 1 or 256"); - m_imageHint = 256; - } - else - { - nlinfo("switching delegate to 0,2,3 or 128"); - m_imageHint = 128; - } +// Object Viewer Qt - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include + +#include + +#include "tile_item_delegate.h" + +#include "tile_model.h" + +TileItemDelegate::TileItemDelegate() +{ + m_zoomFactor = ZoomNormal; + m_imageHint = 128; +} + +TileItemDelegate::~TileItemDelegate() +{ +} + +void TileItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QStyledItemDelegate::paint(painter,option,index); + + painter->save(); + + QFont font = QApplication::font(); + + //font.setBold(true); + //SubFont.setWeight(SubFont.weight()-2); + QFontMetrics fm(font); + + QPixmap tile = qvariant_cast(index.data(TileModel::TilePixmapRole)); + QString tileFileText = qvariant_cast(index.data(TileModel::TileFilenameRole)); + QString tileIdText = qvariant_cast(index.data(TileModel::TileIndexRole)); + + QSize tileSize = tile.size(); + + //QRect headerRect = option.rect; + QRect rect(option.rect); + //QRect tileRect(option.rect); + int textHeight = fm.height(); + int iconPosModX = PIXMAP_MARGIN + (tile.width() / 2); + int iconPosModY = (option.rect.height() - tile.height()) / 2; + + painter->drawPixmap(rect.adjusted(iconPosModX, iconPosModY, iconPosModX, iconPosModY).topLeft(), tile); + + + + //tileRect.setRight(tileSize.width()+30); + //tileRect.setTop(tileRect.top()+5); + //headerRect.setLeft(tileRect.right()); + //subheaderRect.setLeft(tileRect.right()); + //headerRect.setTop(headerRect.top()+5); + //headerRect.setBottom(headerRect.top()+fm.height()); + + //subheaderRect.setTop(headerRect.bottom()+2); + + //painter->drawPixmap(targetrect, pixmap, sourcerect) + + //painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height())); + //painter->drawPixmap(QPoint(tileRect.left()+tileSize.width()/2+2,tileRect.top()+tileSize.height()/2+3),tile); + + //painter->setFont(font); + //painter->drawText(headerRect,headerText); + + + //painter->setFont(SubFont); + //painter->drawText(subheaderRect.left(),subheaderRect.top()+17,subText); + + painter->restore(); +} + +QSize TileItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const +{ + QPixmap tile = qvariant_cast(index.data(TileModel::TilePixmapRole)); + QSize tileSize = tile.size(); + QFont font = QApplication::font(); + QFontMetrics fm(font); + + return(QSize(tileSize.width()+(2*PIXMAP_MARGIN), tileSize.height()+fm.height()+(2*PIXMAP_MARGIN))); +} + +TileItemDelegate::TZoomFactor TileItemDelegate::getZoomFactor() +{ + return m_zoomFactor; +} + +void TileItemDelegate::setZoomFactor(TileItemDelegate::TZoomFactor zoomFactor) +{ + m_zoomFactor = zoomFactor; +} + +// SLOTS + +void TileItemDelegate::currentTab(int index) +{ + if(index == 1) + { + nlinfo("switching delegate to 1 or 256"); + m_imageHint = 256; + } + else + { + nlinfo("switching delegate to 0,2,3 or 128"); + m_imageHint = 128; + } } \ No newline at end of file diff --git a/code/studio/src/plugins/tile_editor/tilebank_loader.cpp b/code/studio/src/plugins/tile_editor/tilebank_loader.cpp index 1aaa055f0..ceae137cc 100644 --- a/code/studio/src/plugins/tile_editor/tilebank_loader.cpp +++ b/code/studio/src/plugins/tile_editor/tilebank_loader.cpp @@ -1,42 +1,42 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "tilebank_loader.h" - -#include "tile_model.h" -#include "nel/misc/file.h" - -TileBankLoader::TileBankLoader() -{ -} - -TileBankLoader::~TileBankLoader() -{ -} - -bool TileBankLoader::load( const char *filename, TileModel *model ) -{ - NLMISC::CIFile file; - if( !file.open( filename, false ) ) - return false; - - model->serial( file ); - - file.close(); - - return true; -} +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "tilebank_loader.h" + +#include "tile_model.h" +#include "nel/misc/file.h" + +TileBankLoader::TileBankLoader() +{ +} + +TileBankLoader::~TileBankLoader() +{ +} + +bool TileBankLoader::load( const char *filename, TileModel *model ) +{ + NLMISC::CIFile file; + if( !file.open( filename, false ) ) + return false; + + model->serial( file ); + + file.close(); + + return true; +} diff --git a/code/studio/src/plugins/tile_editor/tilebank_loader.h b/code/studio/src/plugins/tile_editor/tilebank_loader.h index 643cab67f..6f41234ba 100644 --- a/code/studio/src/plugins/tile_editor/tilebank_loader.h +++ b/code/studio/src/plugins/tile_editor/tilebank_loader.h @@ -1,35 +1,35 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef TILEBANK_LOADER_H -#define TILEBANK_LOADER_H - -class TileModel; - -class TileBankLoader -{ -public: - TileBankLoader(); - ~TileBankLoader(); - - bool load( const char *filename, TileModel *model ); - -private: -}; - - -#endif - +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef TILEBANK_LOADER_H +#define TILEBANK_LOADER_H + +class TileModel; + +class TileBankLoader +{ +public: + TileBankLoader(); + ~TileBankLoader(); + + bool load( const char *filename, TileModel *model ); + +private: +}; + + +#endif + diff --git a/code/studio/src/plugins/tile_editor/tilebank_saver.cpp b/code/studio/src/plugins/tile_editor/tilebank_saver.cpp index 3f087c979..85c96ee94 100644 --- a/code/studio/src/plugins/tile_editor/tilebank_saver.cpp +++ b/code/studio/src/plugins/tile_editor/tilebank_saver.cpp @@ -1,48 +1,48 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "tilebank_saver.h" -#include "tile_model.h" -#include "tile_item.h" - -#include "nel/3d/tile_bank.h" -#include "nel/misc/file.h" - -TileBankSaver::TileBankSaver() -{ -} - -TileBankSaver::~TileBankSaver() -{ -} - -bool TileBankSaver::save( const char *fileName, TileModel* model ) -{ - // Save to file - NLMISC::COFile f; - bool b = f.open( fileName, false, false, false ); - if( !b ) - return false; - - model->serial( f ); - - f.flush(); - f.close(); - - return true; -} - +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "tilebank_saver.h" +#include "tile_model.h" +#include "tile_item.h" + +#include "nel/3d/tile_bank.h" +#include "nel/misc/file.h" + +TileBankSaver::TileBankSaver() +{ +} + +TileBankSaver::~TileBankSaver() +{ +} + +bool TileBankSaver::save( const char *fileName, TileModel* model ) +{ + // Save to file + NLMISC::COFile f; + bool b = f.open( fileName, false, false, false ); + if( !b ) + return false; + + model->serial( f ); + + f.flush(); + f.close(); + + return true; +} + diff --git a/code/studio/src/plugins/tile_editor/tilebank_saver.h b/code/studio/src/plugins/tile_editor/tilebank_saver.h index 0f8983157..ba9c3c7fd 100644 --- a/code/studio/src/plugins/tile_editor/tilebank_saver.h +++ b/code/studio/src/plugins/tile_editor/tilebank_saver.h @@ -1,39 +1,39 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#ifndef TILEBANK_SAVER_H -#define TILEBANK_SAVER_H - -#include -#include - -class TileModel; - -class TileBankSaver -{ -public: - TileBankSaver(); - ~TileBankSaver(); - - bool save( const char *filename, TileModel* model ); - -private: - -}; - -#endif - +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef TILEBANK_SAVER_H +#define TILEBANK_SAVER_H + +#include +#include + +class TileModel; + +class TileBankSaver +{ +public: + TileBankSaver(); + ~TileBankSaver(); + + bool save( const char *filename, TileModel* model ); + +private: + +}; + +#endif + diff --git a/code/studio/src/plugins/translation_manager/uxt_editor.cpp b/code/studio/src/plugins/translation_manager/uxt_editor.cpp index 99b0b200c..06e6f98b4 100644 --- a/code/studio/src/plugins/translation_manager/uxt_editor.cpp +++ b/code/studio/src/plugins/translation_manager/uxt_editor.cpp @@ -1,472 +1,472 @@ -// Ryzom Core Studio - Translation Manager Plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "translation_manager_constants.h" -#include "uxt_editor.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "nel/misc/diff_tool.h" -#include "nel/misc/i18n.h" - -namespace -{ - -QString getLang( const QString &fn ) -{ - QString lang = fn; - int idx = lang.lastIndexOf( '/' ); - if( idx == -1 ) - return ""; - - lang = lang.mid( idx + 1 ); - idx = lang.lastIndexOf( '.' ); - if( idx == -1 ) - return ""; - - lang = lang.left( idx ); - return lang; -} - -} - -namespace TranslationManager -{ - -void markItemTranslated( QTableWidgetItem *item ) -{ - item->setBackground( QColor::fromRgb( 126, 247, 134 ) ); -} - -void markItemUntranslated( QTableWidgetItem *item ) -{ - item->setBackground( QColor::fromRgb( 247, 126, 126 ) ); -} - -class UXTEditorPvt -{ -public: - - UXTEditorPvt() - { - t = new QTableWidget(); - loadedFromWK = false; - } - - QTableWidget *t; - std::vector< STRING_MANAGER::TStringInfo > infos; - bool loadedFromWK; -}; - - -UXTEditor::UXTEditor( QMdiArea *parent ) : -CEditor( parent ) -{ - editor_type = Constants::ED_UXT; - setAttribute( Qt::WA_DeleteOnClose ); - - d_ptr = new UXTEditorPvt(); - - blockTableSignals( false ); -} - -UXTEditor::~UXTEditor() -{ - delete d_ptr; - d_ptr = NULL; -} - -void UXTEditor::open( QString filename ) -{ - std::vector< STRING_MANAGER::TStringInfo > &infos = d_ptr->infos; - QString lang = getLang( filename ); - - infos.clear(); - STRING_MANAGER::loadStringFile( filename.toUtf8().constData(), infos, false ); - - if( d_ptr->infos.size() == 0 ) - { - // The work file cannot be found, cannot proceed - if( filename.endsWith( "wk.uxt" ) ) - { - QMessageBox::critical( this, - tr( "Error opening file.." ), - tr( "There was an error opening wk.uxt" ) ); - return; - } - - int l = filename.lastIndexOf( "/" ); - if( l == -1 ) - return; - - QString fn = filename.left( l ); - fn += "/wk.uxt"; - - // The work file cannot be found, cannot proceed - STRING_MANAGER::loadStringFile( fn.toUtf8().constData(), infos, true ); - if( d_ptr->infos.size() == 0 ) - { - QMessageBox::critical( this, - tr( "Error opening Uxt file" ), - tr( "Neither the specified file nor wk.uxt could be opened." ) ); - return; - } - - d_ptr->loadedFromWK = true; - } - - blockTableSignals( true ); - - d_ptr->t->clear(); - d_ptr->t->setColumnCount( 2 ); - d_ptr->t->setRowCount( infos.size() ); - - setHeaderText( "Id", lang.toUpper() + " Text" ); - - int i = 0; - - std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = infos.begin(); - while( itr != infos.end() ) - { - const STRING_MANAGER::TStringInfo &info = *itr; - - QTableWidgetItem *name = new QTableWidgetItem( info.Identifier.c_str() ); - QTableWidgetItem *text1 = new QTableWidgetItem( info.Text.toUtf8().c_str() ); - - d_ptr->t->setItem( i, 0, name ); - d_ptr->t->setItem( i, 1, text1 ); - - if( ( info.HashValue != 0 ) && !d_ptr->loadedFromWK ) - { - markItemTranslated( name ); - markItemTranslated( text1 ); - } - else - { - markItemUntranslated( name ); - markItemUntranslated( text1 ); - } - - ++itr; - i++; - } - - d_ptr->t->resizeColumnsToContents(); - - blockTableSignals( false ); - - setWidget( d_ptr->t ); - - current_file = filename; - setWindowTitle( filename + "[*]" ); - setWindowFilePath( filename ); -} - -void UXTEditor::save() -{ - saveAs( current_file ); -} - -void UXTEditor::saveAs( QString filename ) -{ - QFile f( filename ); - if( !f.open( QIODevice::WriteOnly ) ) - return; - - QTextStream out( &f ); - - int idx = 0; - std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = d_ptr->infos.begin(); - while( itr != d_ptr->infos.end() ) - { - uint64 hash = 0; - - // If text2 is not empty we can assume the string was translated, so we store with the correct hash - // If text2 is empty, it wasn't translated so we can just use the old hash. - // Additionally, if the strings were loaded from the wk.uxt file, we use a hash of 0 so we know it was not translated - if( itr->Text2.empty() ) - { - if( d_ptr->loadedFromWK ) - hash = 0; - else - hash = itr->HashValue; - } - else - { - hash = NLMISC::CI18N::makeHash( itr->Text2 ); - } - - QString hashLine = "// HASH_VALUE "; - hashLine += QString( NLMISC::CI18N::hashToString( hash ).c_str() ).toUpper(); - hashLine += "\r\n"; - - QString idxLine = "// INDEX "; - idxLine += QString::number( idx ); - idxLine += "\r\n"; - - - QString trLine = ""; - trLine += itr->Identifier.c_str(); - trLine += "\t"; - trLine += "["; - - if( itr->Text2.empty() ) - trLine += itr->Text.toUtf8().c_str(); - else - trLine += itr->Text2.toUtf8().c_str(); - - trLine += "]"; - trLine += "\r\n"; - - QString newLine = "\r\n"; - - out << hashLine; - out << idxLine; - out << trLine; - out << newLine; - - ++itr; - idx++; - } - - f.close(); - - setWindowModified( false ); -} - -void UXTEditor::activateWindow() -{ - showMaximized(); -} - - -void UXTEditor::insertRow() -{ - blockTableSignals( true ); - - d_ptr->infos.push_back( STRING_MANAGER::TStringInfo() ); - d_ptr->t->setRowCount( d_ptr->t->rowCount() + 1 ); - int row = d_ptr->t->rowCount() - 1; - - QTableWidgetItem *item1 = new QTableWidgetItem(); - QTableWidgetItem *item2 = new QTableWidgetItem(); - d_ptr->t->setItem( row, 0, item1 ); - d_ptr->t->setItem( row, 1, item2 ); - - markRowUntranslated( row ); - - setWindowModified( true ); - - blockTableSignals( false ); -} - - -void UXTEditor::deleteRow() -{ - int r = d_ptr->t->currentRow(); - if( r < 0 ) - return; - - int answer = QMessageBox::question( this, - tr( "Deleting a row" ), - tr( "Are you sure you want to delete this row?" ), - QMessageBox::Yes, - QMessageBox::Cancel ); - if( QMessageBox::Yes != answer ) - return; - - std::vector< STRING_MANAGER::TStringInfo >::iterator itr = d_ptr->infos.begin(); - itr += r; - d_ptr->infos.erase( itr ); - - d_ptr->t->removeRow( r ); - - setWindowModified( true ); -} - -void UXTEditor::closeEvent( QCloseEvent *e ) -{ - if( isWindowModified() ) - { - int reply = QMessageBox::question( this, - tr( "Table changed" ), - tr( "The table has changed. Would you like to save your changes?" ), - QMessageBox::Yes, - QMessageBox::No - ); - - if( reply == QMessageBox::Yes ) - save(); - - } - - e->accept(); - close(); -} - -void UXTEditor::contextMenuEvent( QContextMenuEvent *e ) -{ - QMenu *menu = new QMenu( this ); - QAction *insertAction = new QAction( "Insert row", menu ); - QAction *deleteAction = new QAction( "Delete row", menu ); - QAction *markAction = new QAction( "Mark translated", menu ); - QAction *unmarkAction = new QAction( "Mark not-translated", menu ); - QAction *saveAction = new QAction( "Save", menu ); - QAction *saveAsAction = new QAction( "Save as..", menu ); - - connect( insertAction, SIGNAL( triggered( bool ) ), this, SLOT( insertRow() ) ); - connect( deleteAction, SIGNAL( triggered( bool ) ), this, SLOT( deleteRow() ) ); - connect( markAction, SIGNAL( triggered( bool ) ), this, SLOT( markTranslated() ) ); - connect( unmarkAction, SIGNAL( triggered( bool ) ), this, SLOT( markUntranslated() ) ); - connect( saveAction, SIGNAL( triggered( bool ) ), this, SLOT( onSaveClicked() ) ); - connect( saveAsAction, SIGNAL( triggered( bool ) ), this, SLOT( onSaveAsClicked() ) ); - - menu->addAction( insertAction ); - menu->addAction( deleteAction ); - menu->addAction( markAction ); - menu->addAction( unmarkAction ); - menu->addAction( saveAction ); - menu->addAction( saveAsAction ); - menu->exec( e->globalPos() ); -} - -void UXTEditor::onCellChanged( int row, int column ) -{ - QTableWidgetItem *item = d_ptr->t->item( row, column ); - STRING_MANAGER::TStringInfo &info = d_ptr->infos[ row ]; - - if( column == 0 ) - info.Identifier = item->text().toUtf8().constData(); - else - if( column == 1 ) - info.Text2 = item->text().toUtf8().constData(); - - setWindowModified( true ); - - markRowTranslated( row ); -} - -void UXTEditor::markTranslated() -{ - int r = d_ptr->t->currentRow(); - if( r < 0 ) - return; - - STRING_MANAGER::TStringInfo &info = d_ptr->infos[ r ]; - if( !info.Text2.empty() ) - return; - - info.Text2 = info.Text; - - setWindowModified( true ); - - markRowTranslated( r ); -} - -void UXTEditor::markUntranslated() -{ - int r = d_ptr->t->currentRow(); - if( r < 0 ) - return; - - STRING_MANAGER::TStringInfo &info = d_ptr->infos[ r ]; - - info.Text2.clear(); - info.HashValue = 0; - - setWindowModified( true ); - - markRowUntranslated( r ); -} - -void UXTEditor::onSaveClicked() -{ - save(); -} - -void UXTEditor::onSaveAsClicked() -{ - QString path = current_file; - int idx = path.lastIndexOf( '/' ); - if( idx < 0 ) - path = ""; - else - path = path.left( idx + 1 ); - - QString file = QFileDialog::getSaveFileName( this, - tr( "Save Uxt as.." ), - path, - tr( "Uxt files ( *.uxt)" ) ); - - if( file.isEmpty() ) - return; - - saveAs( file ); -} - -void UXTEditor::setHeaderText( const QString &id, const QString &text ) -{ - QTableWidgetItem *h1 = new QTableWidgetItem( id ); - QTableWidgetItem *h2 = new QTableWidgetItem( text ); - h1->setTextAlignment( Qt::AlignLeft ); - h2->setTextAlignment( Qt::AlignLeft ); - d_ptr->t->setHorizontalHeaderItem( 0, h1 ); - d_ptr->t->setHorizontalHeaderItem( 1, h2 ); -} - -void UXTEditor::blockTableSignals( bool block ) -{ - if( block ) - disconnect( d_ptr->t, SIGNAL( cellChanged( int, int ) ), this, SLOT( onCellChanged( int, int ) ) ); - else - connect( d_ptr->t, SIGNAL( cellChanged( int, int ) ), this, SLOT( onCellChanged( int, int ) ) ); -} - -void UXTEditor::markRowTranslated( int row ) -{ - blockTableSignals( true ); - - QTableWidgetItem *item1 = d_ptr->t->item( row, 0 ); - QTableWidgetItem *item2 = d_ptr->t->item( row, 1 ); - markItemTranslated( item1 ); - markItemTranslated( item2 ); - - blockTableSignals( false ); -} - -void UXTEditor::markRowUntranslated( int row ) -{ - blockTableSignals( true ); - - QTableWidgetItem *item1 = d_ptr->t->item( row, 0 ); - QTableWidgetItem *item2 = d_ptr->t->item( row, 1 ); - markItemUntranslated( item1 ); - markItemUntranslated( item2 ); - - blockTableSignals( false ); -} - -} +// Ryzom Core Studio - Translation Manager Plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "translation_manager_constants.h" +#include "uxt_editor.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "nel/misc/diff_tool.h" +#include "nel/misc/i18n.h" + +namespace +{ + +QString getLang( const QString &fn ) +{ + QString lang = fn; + int idx = lang.lastIndexOf( '/' ); + if( idx == -1 ) + return ""; + + lang = lang.mid( idx + 1 ); + idx = lang.lastIndexOf( '.' ); + if( idx == -1 ) + return ""; + + lang = lang.left( idx ); + return lang; +} + +} + +namespace TranslationManager +{ + +void markItemTranslated( QTableWidgetItem *item ) +{ + item->setBackground( QColor::fromRgb( 126, 247, 134 ) ); +} + +void markItemUntranslated( QTableWidgetItem *item ) +{ + item->setBackground( QColor::fromRgb( 247, 126, 126 ) ); +} + +class UXTEditorPvt +{ +public: + + UXTEditorPvt() + { + t = new QTableWidget(); + loadedFromWK = false; + } + + QTableWidget *t; + std::vector< STRING_MANAGER::TStringInfo > infos; + bool loadedFromWK; +}; + + +UXTEditor::UXTEditor( QMdiArea *parent ) : +CEditor( parent ) +{ + editor_type = Constants::ED_UXT; + setAttribute( Qt::WA_DeleteOnClose ); + + d_ptr = new UXTEditorPvt(); + + blockTableSignals( false ); +} + +UXTEditor::~UXTEditor() +{ + delete d_ptr; + d_ptr = NULL; +} + +void UXTEditor::open( QString filename ) +{ + std::vector< STRING_MANAGER::TStringInfo > &infos = d_ptr->infos; + QString lang = getLang( filename ); + + infos.clear(); + STRING_MANAGER::loadStringFile( filename.toUtf8().constData(), infos, false ); + + if( d_ptr->infos.size() == 0 ) + { + // The work file cannot be found, cannot proceed + if( filename.endsWith( "wk.uxt" ) ) + { + QMessageBox::critical( this, + tr( "Error opening file.." ), + tr( "There was an error opening wk.uxt" ) ); + return; + } + + int l = filename.lastIndexOf( "/" ); + if( l == -1 ) + return; + + QString fn = filename.left( l ); + fn += "/wk.uxt"; + + // The work file cannot be found, cannot proceed + STRING_MANAGER::loadStringFile( fn.toUtf8().constData(), infos, true ); + if( d_ptr->infos.size() == 0 ) + { + QMessageBox::critical( this, + tr( "Error opening Uxt file" ), + tr( "Neither the specified file nor wk.uxt could be opened." ) ); + return; + } + + d_ptr->loadedFromWK = true; + } + + blockTableSignals( true ); + + d_ptr->t->clear(); + d_ptr->t->setColumnCount( 2 ); + d_ptr->t->setRowCount( infos.size() ); + + setHeaderText( "Id", lang.toUpper() + " Text" ); + + int i = 0; + + std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = infos.begin(); + while( itr != infos.end() ) + { + const STRING_MANAGER::TStringInfo &info = *itr; + + QTableWidgetItem *name = new QTableWidgetItem( info.Identifier.c_str() ); + QTableWidgetItem *text1 = new QTableWidgetItem( info.Text.toUtf8().c_str() ); + + d_ptr->t->setItem( i, 0, name ); + d_ptr->t->setItem( i, 1, text1 ); + + if( ( info.HashValue != 0 ) && !d_ptr->loadedFromWK ) + { + markItemTranslated( name ); + markItemTranslated( text1 ); + } + else + { + markItemUntranslated( name ); + markItemUntranslated( text1 ); + } + + ++itr; + i++; + } + + d_ptr->t->resizeColumnsToContents(); + + blockTableSignals( false ); + + setWidget( d_ptr->t ); + + current_file = filename; + setWindowTitle( filename + "[*]" ); + setWindowFilePath( filename ); +} + +void UXTEditor::save() +{ + saveAs( current_file ); +} + +void UXTEditor::saveAs( QString filename ) +{ + QFile f( filename ); + if( !f.open( QIODevice::WriteOnly ) ) + return; + + QTextStream out( &f ); + + int idx = 0; + std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = d_ptr->infos.begin(); + while( itr != d_ptr->infos.end() ) + { + uint64 hash = 0; + + // If text2 is not empty we can assume the string was translated, so we store with the correct hash + // If text2 is empty, it wasn't translated so we can just use the old hash. + // Additionally, if the strings were loaded from the wk.uxt file, we use a hash of 0 so we know it was not translated + if( itr->Text2.empty() ) + { + if( d_ptr->loadedFromWK ) + hash = 0; + else + hash = itr->HashValue; + } + else + { + hash = NLMISC::CI18N::makeHash( itr->Text2 ); + } + + QString hashLine = "// HASH_VALUE "; + hashLine += QString( NLMISC::CI18N::hashToString( hash ).c_str() ).toUpper(); + hashLine += "\r\n"; + + QString idxLine = "// INDEX "; + idxLine += QString::number( idx ); + idxLine += "\r\n"; + + + QString trLine = ""; + trLine += itr->Identifier.c_str(); + trLine += "\t"; + trLine += "["; + + if( itr->Text2.empty() ) + trLine += itr->Text.toUtf8().c_str(); + else + trLine += itr->Text2.toUtf8().c_str(); + + trLine += "]"; + trLine += "\r\n"; + + QString newLine = "\r\n"; + + out << hashLine; + out << idxLine; + out << trLine; + out << newLine; + + ++itr; + idx++; + } + + f.close(); + + setWindowModified( false ); +} + +void UXTEditor::activateWindow() +{ + showMaximized(); +} + + +void UXTEditor::insertRow() +{ + blockTableSignals( true ); + + d_ptr->infos.push_back( STRING_MANAGER::TStringInfo() ); + d_ptr->t->setRowCount( d_ptr->t->rowCount() + 1 ); + int row = d_ptr->t->rowCount() - 1; + + QTableWidgetItem *item1 = new QTableWidgetItem(); + QTableWidgetItem *item2 = new QTableWidgetItem(); + d_ptr->t->setItem( row, 0, item1 ); + d_ptr->t->setItem( row, 1, item2 ); + + markRowUntranslated( row ); + + setWindowModified( true ); + + blockTableSignals( false ); +} + + +void UXTEditor::deleteRow() +{ + int r = d_ptr->t->currentRow(); + if( r < 0 ) + return; + + int answer = QMessageBox::question( this, + tr( "Deleting a row" ), + tr( "Are you sure you want to delete this row?" ), + QMessageBox::Yes, + QMessageBox::Cancel ); + if( QMessageBox::Yes != answer ) + return; + + std::vector< STRING_MANAGER::TStringInfo >::iterator itr = d_ptr->infos.begin(); + itr += r; + d_ptr->infos.erase( itr ); + + d_ptr->t->removeRow( r ); + + setWindowModified( true ); +} + +void UXTEditor::closeEvent( QCloseEvent *e ) +{ + if( isWindowModified() ) + { + int reply = QMessageBox::question( this, + tr( "Table changed" ), + tr( "The table has changed. Would you like to save your changes?" ), + QMessageBox::Yes, + QMessageBox::No + ); + + if( reply == QMessageBox::Yes ) + save(); + + } + + e->accept(); + close(); +} + +void UXTEditor::contextMenuEvent( QContextMenuEvent *e ) +{ + QMenu *menu = new QMenu( this ); + QAction *insertAction = new QAction( "Insert row", menu ); + QAction *deleteAction = new QAction( "Delete row", menu ); + QAction *markAction = new QAction( "Mark translated", menu ); + QAction *unmarkAction = new QAction( "Mark not-translated", menu ); + QAction *saveAction = new QAction( "Save", menu ); + QAction *saveAsAction = new QAction( "Save as..", menu ); + + connect( insertAction, SIGNAL( triggered( bool ) ), this, SLOT( insertRow() ) ); + connect( deleteAction, SIGNAL( triggered( bool ) ), this, SLOT( deleteRow() ) ); + connect( markAction, SIGNAL( triggered( bool ) ), this, SLOT( markTranslated() ) ); + connect( unmarkAction, SIGNAL( triggered( bool ) ), this, SLOT( markUntranslated() ) ); + connect( saveAction, SIGNAL( triggered( bool ) ), this, SLOT( onSaveClicked() ) ); + connect( saveAsAction, SIGNAL( triggered( bool ) ), this, SLOT( onSaveAsClicked() ) ); + + menu->addAction( insertAction ); + menu->addAction( deleteAction ); + menu->addAction( markAction ); + menu->addAction( unmarkAction ); + menu->addAction( saveAction ); + menu->addAction( saveAsAction ); + menu->exec( e->globalPos() ); +} + +void UXTEditor::onCellChanged( int row, int column ) +{ + QTableWidgetItem *item = d_ptr->t->item( row, column ); + STRING_MANAGER::TStringInfo &info = d_ptr->infos[ row ]; + + if( column == 0 ) + info.Identifier = item->text().toUtf8().constData(); + else + if( column == 1 ) + info.Text2 = item->text().toUtf8().constData(); + + setWindowModified( true ); + + markRowTranslated( row ); +} + +void UXTEditor::markTranslated() +{ + int r = d_ptr->t->currentRow(); + if( r < 0 ) + return; + + STRING_MANAGER::TStringInfo &info = d_ptr->infos[ r ]; + if( !info.Text2.empty() ) + return; + + info.Text2 = info.Text; + + setWindowModified( true ); + + markRowTranslated( r ); +} + +void UXTEditor::markUntranslated() +{ + int r = d_ptr->t->currentRow(); + if( r < 0 ) + return; + + STRING_MANAGER::TStringInfo &info = d_ptr->infos[ r ]; + + info.Text2.clear(); + info.HashValue = 0; + + setWindowModified( true ); + + markRowUntranslated( r ); +} + +void UXTEditor::onSaveClicked() +{ + save(); +} + +void UXTEditor::onSaveAsClicked() +{ + QString path = current_file; + int idx = path.lastIndexOf( '/' ); + if( idx < 0 ) + path = ""; + else + path = path.left( idx + 1 ); + + QString file = QFileDialog::getSaveFileName( this, + tr( "Save Uxt as.." ), + path, + tr( "Uxt files ( *.uxt)" ) ); + + if( file.isEmpty() ) + return; + + saveAs( file ); +} + +void UXTEditor::setHeaderText( const QString &id, const QString &text ) +{ + QTableWidgetItem *h1 = new QTableWidgetItem( id ); + QTableWidgetItem *h2 = new QTableWidgetItem( text ); + h1->setTextAlignment( Qt::AlignLeft ); + h2->setTextAlignment( Qt::AlignLeft ); + d_ptr->t->setHorizontalHeaderItem( 0, h1 ); + d_ptr->t->setHorizontalHeaderItem( 1, h2 ); +} + +void UXTEditor::blockTableSignals( bool block ) +{ + if( block ) + disconnect( d_ptr->t, SIGNAL( cellChanged( int, int ) ), this, SLOT( onCellChanged( int, int ) ) ); + else + connect( d_ptr->t, SIGNAL( cellChanged( int, int ) ), this, SLOT( onCellChanged( int, int ) ) ); +} + +void UXTEditor::markRowTranslated( int row ) +{ + blockTableSignals( true ); + + QTableWidgetItem *item1 = d_ptr->t->item( row, 0 ); + QTableWidgetItem *item2 = d_ptr->t->item( row, 1 ); + markItemTranslated( item1 ); + markItemTranslated( item2 ); + + blockTableSignals( false ); +} + +void UXTEditor::markRowUntranslated( int row ) +{ + blockTableSignals( true ); + + QTableWidgetItem *item1 = d_ptr->t->item( row, 0 ); + QTableWidgetItem *item2 = d_ptr->t->item( row, 1 ); + markItemUntranslated( item1 ); + markItemUntranslated( item2 ); + + blockTableSignals( false ); +} + +} diff --git a/code/studio/src/settings_dialog.cpp b/code/studio/src/settings_dialog.cpp index 6824b0f56..78773a666 100644 --- a/code/studio/src/settings_dialog.cpp +++ b/code/studio/src/settings_dialog.cpp @@ -1,236 +1,236 @@ -// Ryzom Core - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "settings_dialog.h" -#include -#include -#include - -int findListItem( QListWidget *l, const QString &s ) -{ - for( int i = 0; i < l->count(); i++ ) - { - QListWidgetItem *item = l->item( i ); - if( item->text() == s ) - return i; - } - - return -1; -} - -SettingsDialog::SettingsDialog( QDialog *parent ) : -QDialog( parent ) -{ - setupUi( this ); - setupConnections(); - settings = NULL; -} - -SettingsDialog::~SettingsDialog() -{ -} - -void SettingsDialog::load() -{ - pluginsLE->setText( settings->value( "PluginPath" ).toString() ); - - settings->beginGroup( "DataPath" ); - - sheetsLE->setText( settings->value( "LevelDesignPath" ).toString() ); - assetsLE->setText( settings->value( "AssetsPath" ).toString() ); - primitivesLE->setText( settings->value( "PrimitivesPath" ).toString() ); - ligoLE->setText( settings->value( "LigoConfigFile" ).toString() ); - - QStringList l = settings->value( "SearchPaths" ).toStringList(); - { - QStringListIterator itr( l ); - while( itr.hasNext() ) - { - QString p = itr.next(); - if( findListItem( searchLW, p ) == -1 ) - searchLW->addItem( p ); - } - } - - l.clear(); - - l = settings->value( "RecursiveSearchPathes" ).toStringList(); - { - QStringListIterator itr( l ); - while( itr.hasNext() ) - { - QString p = itr.next(); - if( findListItem( recursiveLW, p ) == -1 ) - recursiveLW->addItem( p ); - } - } - - settings->endGroup(); -} - -void SettingsDialog::saveSearchPaths() -{ - QStringList l; - for( int i = 0; i < searchLW->count(); i++ ) - { - l.push_back( searchLW->item( i )->text() ); - } - - settings->setValue( "SearchPaths", l ); -} - -void SettingsDialog::saveRecursivePaths() -{ - QStringList l; - for( int i = 0; i < recursiveLW->count(); i++ ) - { - l.push_back( recursiveLW->item( i )->text() ); - } - - settings->setValue( "RecursiveSearchPathes", l ); -} - -void SettingsDialog::save() -{ - settings->setValue( "PluginPath", pluginsLE->text() ); - - settings->beginGroup( "DataPath" ); - - settings->setValue( "LevelDesignPath", sheetsLE->text() ); - settings->setValue( "AssetsPath", assetsLE->text() ); - settings->setValue( "PrimitivesPath", primitivesLE->text() ); - settings->setValue( "LigoConfigFile", ligoLE->text() ); - - saveSearchPaths(); - saveRecursivePaths(); - - settings->endGroup(); - - settings->sync(); -} - -void SettingsDialog::accept() -{ - save(); - QDialog::accept(); -} - -void SettingsDialog::reject() -{ - QDialog::reject(); -} - -void SettingsDialog::onOKClicked() -{ - accept(); -} - -void SettingsDialog::onCancelClicked() -{ - reject(); -} - -void SettingsDialog::onPluginBClicked() -{ - QString p = QFileDialog::getExistingDirectory( this, tr( "Plugins directory" ), "" ); - pluginsLE->setText( p ); -} - -void SettingsDialog::onSheetsBClicked() -{ - QString p = QFileDialog::getExistingDirectory( this, tr( "Sheets directory" ), "" ); - sheetsLE->setText( p ); -} - -void SettingsDialog::onAssetsBClicked() -{ - QString p = QFileDialog::getExistingDirectory( this, tr( "Assets directory" ), "" ); - assetsLE->setText( p ); -} - -void SettingsDialog::onPrimitivesBClicked() -{ - QString p = QFileDialog::getExistingDirectory( this, tr( "Primitives directory" ), "" ); - primitivesLE->setText( p ); -} - -void SettingsDialog::onLigoBClicked() -{ - QString p = QFileDialog::getExistingDirectory( this, tr( "LIGO directory" ), "" ); - ligoLE->setText( p ); -} - -void SettingsDialog::onPathAddClicked() -{ - QString p = QFileDialog::getExistingDirectory( this, tr( "Search path" ), "" ); - if( p.isEmpty() ) - return; - - if( findListItem( searchLW, p ) != -1 ) - return; - - searchLW->addItem( p ); -} - -void SettingsDialog::onPathRemoveClicked() -{ - QListWidgetItem *i = searchLW->currentItem(); - if( i == NULL ) - return; - - delete i; -} - -void SettingsDialog::onRecursiveAddClicked() -{ - QString p = QFileDialog::getExistingDirectory( this, tr( "Recursive search path" ), "" ); - if( p.isEmpty() ) - return; - - if( findListItem( recursiveLW, p ) != -1 ) - return; - - recursiveLW->addItem( p ); -} - -void SettingsDialog::onRecursiveRemoveClicked() -{ - QListWidgetItem *i = recursiveLW->currentItem(); - if( i == NULL ) - return; - - delete i; -} - - -void SettingsDialog::setupConnections() -{ - connect( bb, SIGNAL( accepted() ), this, SLOT( onOKClicked() ) ); - connect( bb, SIGNAL( rejected() ), this, SLOT( onCancelClicked() ) ); - - connect( pluginsB, SIGNAL( clicked( bool ) ), this, SLOT( onPluginBClicked() ) ); - connect( sheetsB, SIGNAL( clicked( bool ) ), this, SLOT( onSheetsBClicked() ) ); - connect( assetsB, SIGNAL( clicked( bool ) ), this, SLOT( onAssetsBClicked() ) ); - connect( primitivesB, SIGNAL( clicked( bool ) ), this, SLOT( onPrimitivesBClicked() ) ); - connect( ligoB, SIGNAL( clicked( bool ) ), this, SLOT( onLigoBClicked() ) ); - - connect( pathAddB, SIGNAL( clicked( bool ) ), this, SLOT( onPathAddClicked() ) ); - connect( pathRemoveB, SIGNAL( clicked( bool ) ), this, SLOT( onPathRemoveClicked() ) ); - connect( recAddB, SIGNAL( clicked( bool ) ), this, SLOT( onRecursiveAddClicked() ) ); - connect( recRemoveB, SIGNAL( clicked( bool ) ), this, SLOT( onRecursiveRemoveClicked() ) ); -} - +// Ryzom Core - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "settings_dialog.h" +#include +#include +#include + +int findListItem( QListWidget *l, const QString &s ) +{ + for( int i = 0; i < l->count(); i++ ) + { + QListWidgetItem *item = l->item( i ); + if( item->text() == s ) + return i; + } + + return -1; +} + +SettingsDialog::SettingsDialog( QDialog *parent ) : +QDialog( parent ) +{ + setupUi( this ); + setupConnections(); + settings = NULL; +} + +SettingsDialog::~SettingsDialog() +{ +} + +void SettingsDialog::load() +{ + pluginsLE->setText( settings->value( "PluginPath" ).toString() ); + + settings->beginGroup( "DataPath" ); + + sheetsLE->setText( settings->value( "LevelDesignPath" ).toString() ); + assetsLE->setText( settings->value( "AssetsPath" ).toString() ); + primitivesLE->setText( settings->value( "PrimitivesPath" ).toString() ); + ligoLE->setText( settings->value( "LigoConfigFile" ).toString() ); + + QStringList l = settings->value( "SearchPaths" ).toStringList(); + { + QStringListIterator itr( l ); + while( itr.hasNext() ) + { + QString p = itr.next(); + if( findListItem( searchLW, p ) == -1 ) + searchLW->addItem( p ); + } + } + + l.clear(); + + l = settings->value( "RecursiveSearchPathes" ).toStringList(); + { + QStringListIterator itr( l ); + while( itr.hasNext() ) + { + QString p = itr.next(); + if( findListItem( recursiveLW, p ) == -1 ) + recursiveLW->addItem( p ); + } + } + + settings->endGroup(); +} + +void SettingsDialog::saveSearchPaths() +{ + QStringList l; + for( int i = 0; i < searchLW->count(); i++ ) + { + l.push_back( searchLW->item( i )->text() ); + } + + settings->setValue( "SearchPaths", l ); +} + +void SettingsDialog::saveRecursivePaths() +{ + QStringList l; + for( int i = 0; i < recursiveLW->count(); i++ ) + { + l.push_back( recursiveLW->item( i )->text() ); + } + + settings->setValue( "RecursiveSearchPathes", l ); +} + +void SettingsDialog::save() +{ + settings->setValue( "PluginPath", pluginsLE->text() ); + + settings->beginGroup( "DataPath" ); + + settings->setValue( "LevelDesignPath", sheetsLE->text() ); + settings->setValue( "AssetsPath", assetsLE->text() ); + settings->setValue( "PrimitivesPath", primitivesLE->text() ); + settings->setValue( "LigoConfigFile", ligoLE->text() ); + + saveSearchPaths(); + saveRecursivePaths(); + + settings->endGroup(); + + settings->sync(); +} + +void SettingsDialog::accept() +{ + save(); + QDialog::accept(); +} + +void SettingsDialog::reject() +{ + QDialog::reject(); +} + +void SettingsDialog::onOKClicked() +{ + accept(); +} + +void SettingsDialog::onCancelClicked() +{ + reject(); +} + +void SettingsDialog::onPluginBClicked() +{ + QString p = QFileDialog::getExistingDirectory( this, tr( "Plugins directory" ), "" ); + pluginsLE->setText( p ); +} + +void SettingsDialog::onSheetsBClicked() +{ + QString p = QFileDialog::getExistingDirectory( this, tr( "Sheets directory" ), "" ); + sheetsLE->setText( p ); +} + +void SettingsDialog::onAssetsBClicked() +{ + QString p = QFileDialog::getExistingDirectory( this, tr( "Assets directory" ), "" ); + assetsLE->setText( p ); +} + +void SettingsDialog::onPrimitivesBClicked() +{ + QString p = QFileDialog::getExistingDirectory( this, tr( "Primitives directory" ), "" ); + primitivesLE->setText( p ); +} + +void SettingsDialog::onLigoBClicked() +{ + QString p = QFileDialog::getExistingDirectory( this, tr( "LIGO directory" ), "" ); + ligoLE->setText( p ); +} + +void SettingsDialog::onPathAddClicked() +{ + QString p = QFileDialog::getExistingDirectory( this, tr( "Search path" ), "" ); + if( p.isEmpty() ) + return; + + if( findListItem( searchLW, p ) != -1 ) + return; + + searchLW->addItem( p ); +} + +void SettingsDialog::onPathRemoveClicked() +{ + QListWidgetItem *i = searchLW->currentItem(); + if( i == NULL ) + return; + + delete i; +} + +void SettingsDialog::onRecursiveAddClicked() +{ + QString p = QFileDialog::getExistingDirectory( this, tr( "Recursive search path" ), "" ); + if( p.isEmpty() ) + return; + + if( findListItem( recursiveLW, p ) != -1 ) + return; + + recursiveLW->addItem( p ); +} + +void SettingsDialog::onRecursiveRemoveClicked() +{ + QListWidgetItem *i = recursiveLW->currentItem(); + if( i == NULL ) + return; + + delete i; +} + + +void SettingsDialog::setupConnections() +{ + connect( bb, SIGNAL( accepted() ), this, SLOT( onOKClicked() ) ); + connect( bb, SIGNAL( rejected() ), this, SLOT( onCancelClicked() ) ); + + connect( pluginsB, SIGNAL( clicked( bool ) ), this, SLOT( onPluginBClicked() ) ); + connect( sheetsB, SIGNAL( clicked( bool ) ), this, SLOT( onSheetsBClicked() ) ); + connect( assetsB, SIGNAL( clicked( bool ) ), this, SLOT( onAssetsBClicked() ) ); + connect( primitivesB, SIGNAL( clicked( bool ) ), this, SLOT( onPrimitivesBClicked() ) ); + connect( ligoB, SIGNAL( clicked( bool ) ), this, SLOT( onLigoBClicked() ) ); + + connect( pathAddB, SIGNAL( clicked( bool ) ), this, SLOT( onPathAddClicked() ) ); + connect( pathRemoveB, SIGNAL( clicked( bool ) ), this, SLOT( onPathRemoveClicked() ) ); + connect( recAddB, SIGNAL( clicked( bool ) ), this, SLOT( onRecursiveAddClicked() ) ); + connect( recRemoveB, SIGNAL( clicked( bool ) ), this, SLOT( onRecursiveRemoveClicked() ) ); +} + diff --git a/code/studio/src/settings_dialog.h b/code/studio/src/settings_dialog.h index c6e7cc93a..173ba37d4 100644 --- a/code/studio/src/settings_dialog.h +++ b/code/studio/src/settings_dialog.h @@ -1,62 +1,62 @@ -// Ryzom Core - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef SETTINGS_DIALOG_H -#define SETTINGS_DIALOG_H - -#include "ui_settings_dialog.h" - -class QSettings; - -class SettingsDialog : public QDialog, public Ui::SettingsDialog -{ - Q_OBJECT -public: - SettingsDialog( QDialog *parent = NULL ); - ~SettingsDialog(); - - void setSettings( QSettings *s ){ settings = s; } - - void load(); - -public Q_SLOTS: - void accept(); - void reject(); - - void onOKClicked(); - void onCancelClicked(); - - void onPluginBClicked(); - void onSheetsBClicked(); - void onAssetsBClicked(); - void onPrimitivesBClicked(); - void onLigoBClicked(); - - void onPathAddClicked(); - void onPathRemoveClicked(); - void onRecursiveAddClicked(); - void onRecursiveRemoveClicked(); - -private: - void setupConnections(); - void save(); - void saveSearchPaths(); - void saveRecursivePaths(); - - QSettings *settings; -}; - -#endif +// Ryzom Core - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef SETTINGS_DIALOG_H +#define SETTINGS_DIALOG_H + +#include "ui_settings_dialog.h" + +class QSettings; + +class SettingsDialog : public QDialog, public Ui::SettingsDialog +{ + Q_OBJECT +public: + SettingsDialog( QDialog *parent = NULL ); + ~SettingsDialog(); + + void setSettings( QSettings *s ){ settings = s; } + + void load(); + +public Q_SLOTS: + void accept(); + void reject(); + + void onOKClicked(); + void onCancelClicked(); + + void onPluginBClicked(); + void onSheetsBClicked(); + void onAssetsBClicked(); + void onPrimitivesBClicked(); + void onLigoBClicked(); + + void onPathAddClicked(); + void onPathRemoveClicked(); + void onRecursiveAddClicked(); + void onRecursiveRemoveClicked(); + +private: + void setupConnections(); + void save(); + void saveSearchPaths(); + void saveRecursivePaths(); + + QSettings *settings; +}; + +#endif diff --git a/code/studio/src/splash_screen.cpp b/code/studio/src/splash_screen.cpp index 252472e8d..36f7b3bc0 100644 --- a/code/studio/src/splash_screen.cpp +++ b/code/studio/src/splash_screen.cpp @@ -1,109 +1,109 @@ -// Ryzom Core - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#include "splash_screen.h" -#include -#include -#include -#include - -SplashScreen::SplashScreen() : -QSplashScreen() -{ - progress = 0; - textX = 5; - textY = 20; - pbLeft = 2; - pbTop = 0; - pbWidth = 100; - pbHeight = 20; -} - -SplashScreen::~SplashScreen() -{ -} - -void SplashScreen::setPixmap( const QPixmap &pixmap ) -{ - QSplashScreen::setPixmap( pixmap ); - - if( this->pixmap().width() > 0 ) - pbWidth = this->pixmap().width() - 4; - - if( this->pixmap().height() > 0 ) - pbTop = this->pixmap().height() - pbHeight - 2; - - textY = pbTop - pbHeight / 2; -} - -void SplashScreen::setText( const QString &text ) -{ - this->text = text; - repaint(); - QCoreApplication::instance()->processEvents(); -} - -void SplashScreen::clearText() -{ - setText( "" ); -} - -void SplashScreen::setProgress( int percent ) -{ - progress = percent; - repaint(); - QCoreApplication::instance()->processEvents(); -} - -void SplashScreen::advanceProgress( int percent ) -{ - progress += percent; - repaint(); - QCoreApplication::instance()->processEvents(); -} - -void SplashScreen::drawContents( QPainter *painter ) -{ - QSplashScreen::drawContents( painter ); - - if( progressBarEnabled ) - { - QStyleOptionProgressBarV2 pbStyle; - pbStyle.initFrom( this ); - pbStyle.state = QStyle::State_Enabled; - pbStyle.textVisible = false; - pbStyle.minimum = 0; - pbStyle.maximum = 100; - pbStyle.progress = progress; - pbStyle.invertedAppearance = false; - pbStyle.rect = QRect( pbLeft, pbTop, pbWidth, pbHeight ); - - style()->drawControl( QStyle::CE_ProgressBar, &pbStyle, painter, this ); - } - - if( !text.isEmpty() ) - { - QPen oldPen = painter->pen(); - QPen pen; - pen.setColor( Qt::white ); - painter->setPen( pen ); - painter->drawText( textX, textY, text ); - painter->setPen( oldPen ); - } -} - - +// Ryzom Core - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "splash_screen.h" +#include +#include +#include +#include + +SplashScreen::SplashScreen() : +QSplashScreen() +{ + progress = 0; + textX = 5; + textY = 20; + pbLeft = 2; + pbTop = 0; + pbWidth = 100; + pbHeight = 20; +} + +SplashScreen::~SplashScreen() +{ +} + +void SplashScreen::setPixmap( const QPixmap &pixmap ) +{ + QSplashScreen::setPixmap( pixmap ); + + if( this->pixmap().width() > 0 ) + pbWidth = this->pixmap().width() - 4; + + if( this->pixmap().height() > 0 ) + pbTop = this->pixmap().height() - pbHeight - 2; + + textY = pbTop - pbHeight / 2; +} + +void SplashScreen::setText( const QString &text ) +{ + this->text = text; + repaint(); + QCoreApplication::instance()->processEvents(); +} + +void SplashScreen::clearText() +{ + setText( "" ); +} + +void SplashScreen::setProgress( int percent ) +{ + progress = percent; + repaint(); + QCoreApplication::instance()->processEvents(); +} + +void SplashScreen::advanceProgress( int percent ) +{ + progress += percent; + repaint(); + QCoreApplication::instance()->processEvents(); +} + +void SplashScreen::drawContents( QPainter *painter ) +{ + QSplashScreen::drawContents( painter ); + + if( progressBarEnabled ) + { + QStyleOptionProgressBarV2 pbStyle; + pbStyle.initFrom( this ); + pbStyle.state = QStyle::State_Enabled; + pbStyle.textVisible = false; + pbStyle.minimum = 0; + pbStyle.maximum = 100; + pbStyle.progress = progress; + pbStyle.invertedAppearance = false; + pbStyle.rect = QRect( pbLeft, pbTop, pbWidth, pbHeight ); + + style()->drawControl( QStyle::CE_ProgressBar, &pbStyle, painter, this ); + } + + if( !text.isEmpty() ) + { + QPen oldPen = painter->pen(); + QPen pen; + pen.setColor( Qt::white ); + painter->setPen( pen ); + painter->drawText( textX, textY, text ); + painter->setPen( oldPen ); + } +} + + diff --git a/code/studio/src/splash_screen.h b/code/studio/src/splash_screen.h index ec6cd3da8..c4ba0f648 100644 --- a/code/studio/src/splash_screen.h +++ b/code/studio/src/splash_screen.h @@ -1,60 +1,60 @@ -// Ryzom Core - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - -#ifndef SPLASH_SCREEN_H -#define SPLASH_SCREEN_H - - -#include - -class SplashScreen : public QSplashScreen -{ - Q_OBJECT -public: - SplashScreen(); - ~SplashScreen(); - - void setPixmap( const QPixmap &pixmap ); - - void setText( const QString &text ); - void clearText(); - void setTextXY( int x, int y ){ textX = x; textY = y; } - void setProgress( int percent ); - void advanceProgress( int percent ); - - void setProgressBarEnabled( bool b ){ progressBarEnabled = b; } - void setProgressBarRect( int left, int top, int width, int height ){} - -protected: - void drawContents( QPainter *painter ); - -private: - int progress; - int pbLeft; - int pbTop; - int pbWidth; - int pbHeight; - - QString text; - int textX; - int textY; - - bool progressBarEnabled; -}; - -#endif - +// Ryzom Core - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef SPLASH_SCREEN_H +#define SPLASH_SCREEN_H + + +#include + +class SplashScreen : public QSplashScreen +{ + Q_OBJECT +public: + SplashScreen(); + ~SplashScreen(); + + void setPixmap( const QPixmap &pixmap ); + + void setText( const QString &text ); + void clearText(); + void setTextXY( int x, int y ){ textX = x; textY = y; } + void setProgress( int percent ); + void advanceProgress( int percent ); + + void setProgressBarEnabled( bool b ){ progressBarEnabled = b; } + void setProgressBarRect( int left, int top, int width, int height ){} + +protected: + void drawContents( QPainter *painter ); + +private: + int progress; + int pbLeft; + int pbTop; + int pbWidth; + int pbHeight; + + QString text; + int textX; + int textY; + + bool progressBarEnabled; +}; + +#endif +