This commit is contained in:
dfighter1985 2014-08-30 22:23:21 +02:00
parent 2a3751dae2
commit e5b2d05fa7
23 changed files with 2522 additions and 2522 deletions

View file

@ -1,48 +1,48 @@
// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/> // Object Viewer Qt - Georges Editor Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com> // Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef ACTIONS_H #ifndef ACTIONS_H
#define ACTIONS_H #define ACTIONS_H
#include <QtGui/QUndoCommand> #include <QtGui/QUndoCommand>
#include <QModelIndex> #include <QModelIndex>
namespace GeorgesQt namespace GeorgesQt
{ {
class CFormItem; class CFormItem;
class CGeorgesFormModel; class CGeorgesFormModel;
class CUndoFormArrayRenameCommand : public QUndoCommand class CUndoFormArrayRenameCommand : public QUndoCommand
{ {
public: public:
CUndoFormArrayRenameCommand(CGeorgesFormModel *model, CFormItem *item, const QVariant &value, QUndoCommand *parent = 0); CUndoFormArrayRenameCommand(CGeorgesFormModel *model, CFormItem *item, const QVariant &value, QUndoCommand *parent = 0);
~CUndoFormArrayRenameCommand() {} ~CUndoFormArrayRenameCommand() {}
void redo(); void redo();
void undo(); void undo();
void update(bool redo); void update(bool redo);
protected: protected:
CFormItem *m_item; CFormItem *m_item;
CGeorgesFormModel *m_model; CGeorgesFormModel *m_model;
QString m_newValue; QString m_newValue;
QString m_oldValue; QString m_oldValue;
}; };
} }
#endif // ACTIONS_H #endif // ACTIONS_H

View file

@ -1,49 +1,49 @@
#ifndef BROWSER_CTRL_H #ifndef BROWSER_CTRL_H
#define BROWSER_CTRL_H #define BROWSER_CTRL_H
#include <QObject> #include <QObject>
namespace NLGEORGES namespace NLGEORGES
{ {
class UForm; class UForm;
} }
class QtTreePropertyBrowser; class QtTreePropertyBrowser;
class QModelIndex; class QModelIndex;
class QVariant; class QVariant;
class QtProperty; class QtProperty;
class BrowserCtrlPvt; class BrowserCtrlPvt;
class BrowserCtrl : public QObject class BrowserCtrl : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
BrowserCtrl( QtTreePropertyBrowser *browser ); BrowserCtrl( QtTreePropertyBrowser *browser );
~BrowserCtrl(); ~BrowserCtrl();
void setForm( NLGEORGES::UForm *form ){ m_form = form; } void setForm( NLGEORGES::UForm *form ){ m_form = form; }
public Q_SLOTS: public Q_SLOTS:
void clicked( const QModelIndex &idx ); void clicked( const QModelIndex &idx );
Q_SIGNALS: Q_SIGNALS:
void arrayResized( const QString &name, int size ); void arrayResized( const QString &name, int size );
void modified(); void modified();
void valueChanged( const QString &key, const QString &value ); void valueChanged( const QString &key, const QString &value );
private Q_SLOTS: private Q_SLOTS:
void onValueChanged( QtProperty *p, const QVariant &value ); void onValueChanged( QtProperty *p, const QVariant &value );
void onValueChanged( const QString &key, const QString &value ); void onValueChanged( const QString &key, const QString &value );
void onArrayResized( const QString &name, int size ); void onArrayResized( const QString &name, int size );
void onModified(); void onModified();
private: private:
void enableMgrConnections(); void enableMgrConnections();
void disableMgrConnections(); void disableMgrConnections();
BrowserCtrlPvt *m_pvt; BrowserCtrlPvt *m_pvt;
NLGEORGES::UForm *m_form; NLGEORGES::UForm *m_form;
}; };
#endif #endif

View file

@ -1,82 +1,82 @@
#ifndef BROWSER_CTRL_PVT_H #ifndef BROWSER_CTRL_PVT_H
#define BROWSER_CTRL_PVT_H #define BROWSER_CTRL_PVT_H
#include <QObject> #include <QObject>
namespace NLGEORGES namespace NLGEORGES
{ {
class CFormElm; class CFormElm;
class UFormElm; class UFormElm;
class CFormElmStruct; class CFormElmStruct;
} }
namespace GeorgesQt namespace GeorgesQt
{ {
class CFormItem; class CFormItem;
} }
class QtVariantPropertyManager; class QtVariantPropertyManager;
class QtVariantEditorFactory; class QtVariantEditorFactory;
class QtTreePropertyBrowser; class QtTreePropertyBrowser;
class QVariant; class QVariant;
class QtProperty; class QtProperty;
class BrowserCtrlPvt : public QObject class BrowserCtrlPvt : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
BrowserCtrlPvt( QObject *parent = NULL ); BrowserCtrlPvt( QObject *parent = NULL );
~BrowserCtrlPvt(); ~BrowserCtrlPvt();
void clear(); void clear();
void setupNode( GeorgesQt::CFormItem *node ); void setupNode( GeorgesQt::CFormItem *node );
void onValueChanged( QtProperty *p, const QVariant &value ); void onValueChanged( QtProperty *p, const QVariant &value );
QtVariantPropertyManager* manager() const{ return mgr; } QtVariantPropertyManager* manager() const{ return mgr; }
void setRootNode( NLGEORGES::CFormElm *root ){ m_rootNode = root; } void setRootNode( NLGEORGES::CFormElm *root ){ m_rootNode = root; }
void setBrowser( QtTreePropertyBrowser *browser ){ m_browser = browser; } void setBrowser( QtTreePropertyBrowser *browser ){ m_browser = browser; }
Q_SIGNALS: Q_SIGNALS:
void arrayResized( const QString &name, int size ); void arrayResized( const QString &name, int size );
void modified(); void modified();
void valueChanged( const QString &key, const QString &value ); void valueChanged( const QString &key, const QString &value );
private: private:
void setupStruct( NLGEORGES::UFormElm *node ); void setupStruct( NLGEORGES::UFormElm *node );
void setupAtom( NLGEORGES::CFormElmStruct::CFormElmStructElm &elm ); void setupAtom( NLGEORGES::CFormElmStruct::CFormElmStructElm &elm );
void setupStruct( GeorgesQt::CFormItem *node ); void setupStruct( GeorgesQt::CFormItem *node );
void setupArray( GeorgesQt::CFormItem *node ); void setupArray( GeorgesQt::CFormItem *node );
void onStructValueChanged( QtProperty *p, const QVariant &value ); void onStructValueChanged( QtProperty *p, const QVariant &value );
void onArrayValueChanged( QtProperty *p, const QVariant &value ); void onArrayValueChanged( QtProperty *p, const QVariant &value );
void createArray(); void createArray();
QtVariantPropertyManager *mgr; QtVariantPropertyManager *mgr;
QtVariantEditorFactory *factory; QtVariantEditorFactory *factory;
QtTreePropertyBrowser *m_browser; QtTreePropertyBrowser *m_browser;
QString m_currentNodeName; QString m_currentNodeName;
NLGEORGES::CFormElm *m_rootNode; NLGEORGES::CFormElm *m_rootNode;
struct CurrentNode struct CurrentNode
{ {
CurrentNode() CurrentNode()
{ {
clear(); clear();
} }
void clear() void clear()
{ {
p = NULL; p = NULL;
name = ""; name = "";
} }
QString name; QString name;
NLGEORGES::UFormElm *p; NLGEORGES::UFormElm *p;
}; };
CurrentNode m_currentNode; CurrentNode m_currentNode;
}; };
#endif #endif

View file

@ -1,49 +1,49 @@
#include "action_list.h" #include "action_list.h"
#include "nel/gui/action_handler.h" #include "nel/gui/action_handler.h"
#include <vector> #include <vector>
#include <string> #include <string>
ActionList::ActionList( QDialog *parent ) : ActionList::ActionList( QDialog *parent ) :
QDialog( parent ) QDialog( parent )
{ {
setupUi( this ); setupUi( this );
} }
ActionList::~ActionList() ActionList::~ActionList()
{ {
} }
void ActionList::load() void ActionList::load()
{ {
actionList->clear(); actionList->clear();
NLGUI::CAHManager *am = NLGUI::CAHManager::getInstance(); NLGUI::CAHManager *am = NLGUI::CAHManager::getInstance();
std::vector< std::string > handlers; std::vector< std::string > handlers;
am->getActionHandlers( handlers ); am->getActionHandlers( handlers );
std::vector< std::string >::const_iterator itr = handlers.begin(); std::vector< std::string >::const_iterator itr = handlers.begin();
while( itr != handlers.end() ) while( itr != handlers.end() )
{ {
actionList->addItem( itr->c_str() ); actionList->addItem( itr->c_str() );
++itr; ++itr;
} }
} }
void ActionList::accept() void ActionList::accept()
{ {
QListWidgetItem *item = actionList->currentItem(); QListWidgetItem *item = actionList->currentItem();
if( item == NULL ) if( item == NULL )
return; return;
selectedAction = item->text(); selectedAction = item->text();
QDialog::accept(); QDialog::accept();
} }
void ActionList::reject() void ActionList::reject()
{ {
selectedAction = ""; selectedAction = "";
QDialog::reject(); QDialog::reject();
} }

View file

@ -1,29 +1,29 @@
#ifndef ACTION_LIST_H #ifndef ACTION_LIST_H
#define ACTION_LIST_H #define ACTION_LIST_H
#include "ui_action_list.h" #include "ui_action_list.h"
#include <QString> #include <QString>
class ActionList : public QDialog, public Ui::ActionListDialog class ActionList : public QDialog, public Ui::ActionListDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
ActionList( QDialog *parent = NULL ); ActionList( QDialog *parent = NULL );
~ActionList(); ~ActionList();
void load(); void load();
QString getSelectedAction(){ return selectedAction; } QString getSelectedAction(){ return selectedAction; }
public Q_SLOTS: public Q_SLOTS:
void accept(); void accept();
void reject(); void reject();
private: private:
QString selectedAction; QString selectedAction;
}; };
#endif #endif

View file

@ -1,50 +1,50 @@
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${LIBXML2_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}
${QT_INCLUDES}) ${QT_INCLUDES})
FILE(GLOB SRC *.cpp *.h) FILE(GLOB SRC *.cpp *.h)
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
SET(OVQT_TILE_EDITOR_PLUGIN_HDR SET(OVQT_TILE_EDITOR_PLUGIN_HDR
tile_model.h tile_model.h
tile_editor_main_window.h tile_editor_main_window.h
tile_editor_plugin.h tile_editor_plugin.h
land_edit_dialog.h) land_edit_dialog.h)
SET(OVQT_TILE_EDITOR_PLUGIN_UIS SET(OVQT_TILE_EDITOR_PLUGIN_UIS
tile_editor_main_window.ui tile_editor_main_window.ui
land_edit_dialog.ui) land_edit_dialog.ui)
SET(OVQT_PLUG_TILE_EDITOR_RCS tile_editor.qrc) SET(OVQT_PLUG_TILE_EDITOR_RCS tile_editor.qrc)
SET(QT_USE_QTGUI TRUE) SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE) SET(QT_USE_QTOPENGL TRUE)
QT4_WRAP_CPP(OVQT_TILE_EDITOR_PLUGIN_MOC_SRC ${OVQT_TILE_EDITOR_PLUGIN_HDR}) 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_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}) 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(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(QtGeneratedMocSrc FILES ${OVQT_TILE_EDITOR_PLUGIN_MOC_SRC} ${OVQT_PLUG_TILE_EDITOR_RC_SRCS})
SOURCE_GROUP("Tile Editor Plugin" FILES ${SRC}) SOURCE_GROUP("Tile Editor Plugin" FILES ${SRC})
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
ADD_LIBRARY(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}) 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}) TARGET_LINK_LIBRARIES(studio_plugin_tile_editor studio_plugin_core nelmisc ${QT_LIBRARIES})
IF(WITH_STLPORT) IF(WITH_STLPORT)
TARGET_LINK_LIBRARIES(studio_plugin_tile_editor ${CMAKE_THREAD_LIBS_INIT}) TARGET_LINK_LIBRARIES(studio_plugin_tile_editor ${CMAKE_THREAD_LIBS_INIT})
ENDIF(WITH_STLPORT) ENDIF(WITH_STLPORT)
NL_DEFAULT_PROPS(studio_plugin_tile_editor "Tools: Studio Plugin: Tile Editor") NL_DEFAULT_PROPS(studio_plugin_tile_editor "Tools: Studio Plugin: Tile Editor")
NL_ADD_RUNTIME_FLAGS(studio_plugin_tile_editor) NL_ADD_RUNTIME_FLAGS(studio_plugin_tile_editor)
NL_ADD_LIB_SUFFIX(studio_plugin_tile_editor) NL_ADD_LIB_SUFFIX(studio_plugin_tile_editor)
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) 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(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) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/studio_plugin_tile_editor.xml DESTINATION ${OVQT_PLUGIN_SPECS_DIR} COMPONENT tools3d)

View file

@ -1,105 +1,105 @@
// Ryzom Core Studio - Tile Editor plugin // Ryzom Core Studio - Tile Editor plugin
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "land_edit_dialog.h" #include "land_edit_dialog.h"
LandEditDialog::LandEditDialog( QWidget *parent ) : LandEditDialog::LandEditDialog( QWidget *parent ) :
QDialog( parent ) QDialog( parent )
{ {
setupUi( this ); setupUi( this );
setupConnections(); setupConnections();
} }
LandEditDialog::~LandEditDialog() LandEditDialog::~LandEditDialog()
{ {
} }
void LandEditDialog::getSelectedTileSets( QStringList &l ) const void LandEditDialog::getSelectedTileSets( QStringList &l ) const
{ {
int c = tilesetLV->count(); int c = tilesetLV->count();
for( int i = 0; i < c; i++ ) for( int i = 0; i < c; i++ )
{ {
l.push_back( tilesetLV->item( i )->text() ); l.push_back( tilesetLV->item( i )->text() );
} }
} }
void LandEditDialog::setSelectedTileSets( QStringList &l ) void LandEditDialog::setSelectedTileSets( QStringList &l )
{ {
tilesetLV->clear(); tilesetLV->clear();
QStringListIterator itr( l ); QStringListIterator itr( l );
while( itr.hasNext() ) while( itr.hasNext() )
{ {
tilesetLV->addItem( itr.next() ); tilesetLV->addItem( itr.next() );
} }
} }
void LandEditDialog::setTileSets( const QStringList &l ) void LandEditDialog::setTileSets( const QStringList &l )
{ {
tilesetCB->clear(); tilesetCB->clear();
QStringListIterator itr( l ); QStringListIterator itr( l );
while( itr.hasNext() ) while( itr.hasNext() )
{ {
tilesetCB->addItem( itr.next() ); tilesetCB->addItem( itr.next() );
} }
} }
void LandEditDialog::setupConnections() void LandEditDialog::setupConnections()
{ {
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOkClicked() ) ); connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOkClicked() ) );
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) ); connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) ); connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
} }
void LandEditDialog::onOkClicked() void LandEditDialog::onOkClicked()
{ {
accept(); accept();
} }
void LandEditDialog::onCancelClicked() void LandEditDialog::onCancelClicked()
{ {
reject(); reject();
} }
void LandEditDialog::onAddClicked() void LandEditDialog::onAddClicked()
{ {
if( tilesetCB->currentIndex() < 0 ) if( tilesetCB->currentIndex() < 0 )
return; return;
QString text = tilesetCB->currentText(); QString text = tilesetCB->currentText();
int c = tilesetLV->count(); int c = tilesetLV->count();
for( int i = 0; i < c; i++ ) for( int i = 0; i < c; i++ )
{ {
if( text == tilesetLV->item( i )->text() ) if( text == tilesetLV->item( i )->text() )
return; return;
} }
tilesetLV->addItem( text ); tilesetLV->addItem( text );
} }
void LandEditDialog::onRemoveClicked() void LandEditDialog::onRemoveClicked()
{ {
if( tilesetLV->currentItem() == NULL ) if( tilesetLV->currentItem() == NULL )
return; return;
QListWidgetItem *item = tilesetLV->currentItem(); QListWidgetItem *item = tilesetLV->currentItem();
delete item; delete item;
} }

View file

@ -1,51 +1,51 @@
// Ryzom Core Studio - Tile Editor plugin // Ryzom Core Studio - Tile Editor plugin
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef LAND_EDIT_DLG_H #ifndef LAND_EDIT_DLG_H
#define LAND_EDIT_DLG_H #define LAND_EDIT_DLG_H
#include "ui_land_edit_dialog.h" #include "ui_land_edit_dialog.h"
#include <QStringList> #include <QStringList>
class LandEditDialog : public QDialog, public Ui::LandEditDialog class LandEditDialog : public QDialog, public Ui::LandEditDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
LandEditDialog( QWidget *parent = NULL ); LandEditDialog( QWidget *parent = NULL );
~LandEditDialog(); ~LandEditDialog();
void getSelectedTileSets( QStringList &l ) const; void getSelectedTileSets( QStringList &l ) const;
void setSelectedTileSets( QStringList &l ); void setSelectedTileSets( QStringList &l );
void setTileSets( const QStringList &l ); void setTileSets( const QStringList &l );
private: private:
void setupConnections(); void setupConnections();
private Q_SLOTS: private Q_SLOTS:
void onOkClicked(); void onOkClicked();
void onCancelClicked(); void onCancelClicked();
void onAddClicked(); void onAddClicked();
void onRemoveClicked(); void onRemoveClicked();
}; };
#endif #endif

View file

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

File diff suppressed because it is too large Load diff

View file

@ -1,102 +1,102 @@
// Ryzom Core Studio - Tile Editor plugin // Ryzom Core Studio - Tile Editor plugin
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef TILE_BANK_H #ifndef TILE_BANK_H
#define TILE_BANK_H #define TILE_BANK_H
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QVariant> #include <QVariant>
#include <QList> #include <QList>
#include "tile_constants.h" #include "tile_constants.h"
#include "tile_images.h" #include "tile_images.h"
namespace NLMISC namespace NLMISC
{ {
class IStream; class IStream;
} }
class TileBankPvt; class TileBankPvt;
class TileBank class TileBank
{ {
public: public:
TileBank(); TileBank();
~TileBank(); ~TileBank();
void addTileSet( const QString &name ); void addTileSet( const QString &name );
void removeTileSet( int idx ); void removeTileSet( int idx );
void renameTileSet( int idx, const QString &newName ); void renameTileSet( int idx, const QString &newName );
void getTileSets( QStringList &l ); void getTileSets( QStringList &l );
void addLand( const QString &name ); void addLand( const QString &name );
void removeLand( int idx ); void removeLand( int idx );
void getLands( QStringList &l ); void getLands( QStringList &l );
void setLandSets( int idx, const QStringList &l ); void setLandSets( int idx, const QStringList &l );
void getLandSets( int idx, QStringList &l ); void getLandSets( int idx, QStringList &l );
bool addTile( int setIdx, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type ); bool addTile( int setIdx, const QString &name, const QVariant &pixmap, TileConstants::TTileChannel channel, TileConstants::TNodeTileType type );
void removeTile( int ts, int type, int tile ); 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 ); 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 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 ); void clearImage( int ts, int type, int tile, TileConstants::TTileChannel channel );
int getTileCount( int tileSet, TileConstants::TNodeTileType type ); int getTileCount( int tileSet, TileConstants::TNodeTileType type );
int getRealTileId( int tileSet, TileConstants::TNodeTileType type, int tileIdInSet ); 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, int tileId, TileImages &images );
void getTileImages( int tileSet, TileConstants::TNodeTileType type, QList< TileImages > &l ); void getTileImages( int tileSet, TileConstants::TNodeTileType type, QList< TileImages > &l );
void setVegetation( int tileSet, const QString &vegetation ); void setVegetation( int tileSet, const QString &vegetation );
QString getVegetation( int tileSet ) const; QString getVegetation( int tileSet ) const;
void setOriented( int tileSet, bool b ); void setOriented( int tileSet, bool b );
bool getOriented( int tileSet ) const; bool getOriented( int tileSet ) const;
void setSurfaceData( int tileSet, unsigned long data ); void setSurfaceData( int tileSet, unsigned long data );
unsigned long getSurfaceData( int tileSet ) const; unsigned long getSurfaceData( int tileSet ) const;
void setTexturePath( const QString &path ); void setTexturePath( const QString &path );
QString getTexturePath() const; QString getTexturePath() const;
void setRotation( int rotation ); void setRotation( int rotation );
void serial( NLMISC::IStream &f ); void serial( NLMISC::IStream &f );
bool hasError() const{ return m_hasError; } bool hasError() const{ return m_hasError; }
QString getLastError() const{ return m_lastError; } QString getLastError() const{ return m_lastError; }
void resetError(){ void resetError(){
m_hasError = false; m_hasError = false;
m_lastError = ""; m_lastError = "";
} }
void setError( const QString &msg ) void setError( const QString &msg )
{ {
m_hasError = true; m_hasError = true;
m_lastError = msg; m_lastError = msg;
} }
private: private:
TileBankPvt *m_pvt; TileBankPvt *m_pvt;
QString m_lastError; QString m_lastError;
bool m_hasError; bool m_hasError;
int m_rotation; int m_rotation;
}; };
#endif #endif

View file

@ -1,43 +1,43 @@
// Ryzom Core Studio - Tile Editor plugin // Ryzom Core Studio - Tile Editor plugin
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef TILE_CONSTANTS_H #ifndef TILE_CONSTANTS_H
#define TILE_CONSTANTS_H #define TILE_CONSTANTS_H
namespace TileConstants namespace TileConstants
{ {
enum TTileChannel enum TTileChannel
{ {
TileDiffuse = 0, TileDiffuse = 0,
TileAdditive = 1, TileAdditive = 1,
TileAlpha = 2, TileAlpha = 2,
TileChannelCount = 3 TileChannelCount = 3
}; };
enum TNodeTileType enum TNodeTileType
{ {
Tile128 = 0, Tile128 = 0,
Tile256 = 1, Tile256 = 1,
TileTransition = 2, TileTransition = 2,
TileDisplacement = 3, TileDisplacement = 3,
TileNodeTypeCount = 4 TileNodeTypeCount = 4
}; };
} }
#endif #endif

View file

@ -1,40 +1,40 @@
// Ryzom Core Studio - Tile Editor plugin // Ryzom Core Studio - Tile Editor plugin
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef TILE_IMAGES_H #ifndef TILE_IMAGES_H
#define TILE_IMAGES_H #define TILE_IMAGES_H
#include <QString> #include <QString>
struct TileImages struct TileImages
{ {
QString diffuse; QString diffuse;
QString additive; QString additive;
QString alpha; QString alpha;
void clear() void clear()
{ {
diffuse.clear(); diffuse.clear();
additive.clear(); additive.clear();
alpha.clear(); alpha.clear();
} }
}; };
#endif #endif

View file

@ -1,122 +1,122 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtGui/QtGui> #include <QtGui/QtGui>
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
#include "tile_item_delegate.h" #include "tile_item_delegate.h"
#include "tile_model.h" #include "tile_model.h"
TileItemDelegate::TileItemDelegate() TileItemDelegate::TileItemDelegate()
{ {
m_zoomFactor = ZoomNormal; m_zoomFactor = ZoomNormal;
m_imageHint = 128; m_imageHint = 128;
} }
TileItemDelegate::~TileItemDelegate() TileItemDelegate::~TileItemDelegate()
{ {
} }
void TileItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const void TileItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{ {
QStyledItemDelegate::paint(painter,option,index); QStyledItemDelegate::paint(painter,option,index);
painter->save(); painter->save();
QFont font = QApplication::font(); QFont font = QApplication::font();
//font.setBold(true); //font.setBold(true);
//SubFont.setWeight(SubFont.weight()-2); //SubFont.setWeight(SubFont.weight()-2);
QFontMetrics fm(font); QFontMetrics fm(font);
QPixmap tile = qvariant_cast<QPixmap>(index.data(TileModel::TilePixmapRole)); QPixmap tile = qvariant_cast<QPixmap>(index.data(TileModel::TilePixmapRole));
QString tileFileText = qvariant_cast<QString>(index.data(TileModel::TileFilenameRole)); QString tileFileText = qvariant_cast<QString>(index.data(TileModel::TileFilenameRole));
QString tileIdText = qvariant_cast<QString>(index.data(TileModel::TileIndexRole)); QString tileIdText = qvariant_cast<QString>(index.data(TileModel::TileIndexRole));
QSize tileSize = tile.size(); QSize tileSize = tile.size();
//QRect headerRect = option.rect; //QRect headerRect = option.rect;
QRect rect(option.rect); QRect rect(option.rect);
//QRect tileRect(option.rect); //QRect tileRect(option.rect);
int textHeight = fm.height(); int textHeight = fm.height();
int iconPosModX = PIXMAP_MARGIN + (tile.width() / 2); int iconPosModX = PIXMAP_MARGIN + (tile.width() / 2);
int iconPosModY = (option.rect.height() - tile.height()) / 2; int iconPosModY = (option.rect.height() - tile.height()) / 2;
painter->drawPixmap(rect.adjusted(iconPosModX, iconPosModY, iconPosModX, iconPosModY).topLeft(), tile); painter->drawPixmap(rect.adjusted(iconPosModX, iconPosModY, iconPosModX, iconPosModY).topLeft(), tile);
//tileRect.setRight(tileSize.width()+30); //tileRect.setRight(tileSize.width()+30);
//tileRect.setTop(tileRect.top()+5); //tileRect.setTop(tileRect.top()+5);
//headerRect.setLeft(tileRect.right()); //headerRect.setLeft(tileRect.right());
//subheaderRect.setLeft(tileRect.right()); //subheaderRect.setLeft(tileRect.right());
//headerRect.setTop(headerRect.top()+5); //headerRect.setTop(headerRect.top()+5);
//headerRect.setBottom(headerRect.top()+fm.height()); //headerRect.setBottom(headerRect.top()+fm.height());
//subheaderRect.setTop(headerRect.bottom()+2); //subheaderRect.setTop(headerRect.bottom()+2);
//painter->drawPixmap(targetrect, pixmap, sourcerect) //painter->drawPixmap(targetrect, pixmap, sourcerect)
//painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height())); //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->drawPixmap(QPoint(tileRect.left()+tileSize.width()/2+2,tileRect.top()+tileSize.height()/2+3),tile);
//painter->setFont(font); //painter->setFont(font);
//painter->drawText(headerRect,headerText); //painter->drawText(headerRect,headerText);
//painter->setFont(SubFont); //painter->setFont(SubFont);
//painter->drawText(subheaderRect.left(),subheaderRect.top()+17,subText); //painter->drawText(subheaderRect.left(),subheaderRect.top()+17,subText);
painter->restore(); painter->restore();
} }
QSize TileItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const QSize TileItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const
{ {
QPixmap tile = qvariant_cast<QPixmap>(index.data(TileModel::TilePixmapRole)); QPixmap tile = qvariant_cast<QPixmap>(index.data(TileModel::TilePixmapRole));
QSize tileSize = tile.size(); QSize tileSize = tile.size();
QFont font = QApplication::font(); QFont font = QApplication::font();
QFontMetrics fm(font); QFontMetrics fm(font);
return(QSize(tileSize.width()+(2*PIXMAP_MARGIN), tileSize.height()+fm.height()+(2*PIXMAP_MARGIN))); return(QSize(tileSize.width()+(2*PIXMAP_MARGIN), tileSize.height()+fm.height()+(2*PIXMAP_MARGIN)));
} }
TileItemDelegate::TZoomFactor TileItemDelegate::getZoomFactor() TileItemDelegate::TZoomFactor TileItemDelegate::getZoomFactor()
{ {
return m_zoomFactor; return m_zoomFactor;
} }
void TileItemDelegate::setZoomFactor(TileItemDelegate::TZoomFactor zoomFactor) void TileItemDelegate::setZoomFactor(TileItemDelegate::TZoomFactor zoomFactor)
{ {
m_zoomFactor = zoomFactor; m_zoomFactor = zoomFactor;
} }
// SLOTS // SLOTS
void TileItemDelegate::currentTab(int index) void TileItemDelegate::currentTab(int index)
{ {
if(index == 1) if(index == 1)
{ {
nlinfo("switching delegate to 1 or 256"); nlinfo("switching delegate to 1 or 256");
m_imageHint = 256; m_imageHint = 256;
} }
else else
{ {
nlinfo("switching delegate to 0,2,3 or 128"); nlinfo("switching delegate to 0,2,3 or 128");
m_imageHint = 128; m_imageHint = 128;
} }
} }

View file

@ -1,42 +1,42 @@
// Ryzom Core Studio - Tile Editor plugin // Ryzom Core Studio - Tile Editor plugin
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "tilebank_loader.h" #include "tilebank_loader.h"
#include "tile_model.h" #include "tile_model.h"
#include "nel/misc/file.h" #include "nel/misc/file.h"
TileBankLoader::TileBankLoader() TileBankLoader::TileBankLoader()
{ {
} }
TileBankLoader::~TileBankLoader() TileBankLoader::~TileBankLoader()
{ {
} }
bool TileBankLoader::load( const char *filename, TileModel *model ) bool TileBankLoader::load( const char *filename, TileModel *model )
{ {
NLMISC::CIFile file; NLMISC::CIFile file;
if( !file.open( filename, false ) ) if( !file.open( filename, false ) )
return false; return false;
model->serial( file ); model->serial( file );
file.close(); file.close();
return true; return true;
} }

View file

@ -1,35 +1,35 @@
// Ryzom Core Studio - Tile Editor plugin // Ryzom Core Studio - Tile Editor plugin
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef TILEBANK_LOADER_H #ifndef TILEBANK_LOADER_H
#define TILEBANK_LOADER_H #define TILEBANK_LOADER_H
class TileModel; class TileModel;
class TileBankLoader class TileBankLoader
{ {
public: public:
TileBankLoader(); TileBankLoader();
~TileBankLoader(); ~TileBankLoader();
bool load( const char *filename, TileModel *model ); bool load( const char *filename, TileModel *model );
private: private:
}; };
#endif #endif

View file

@ -1,48 +1,48 @@
// Ryzom Core Studio - Tile Editor plugin // Ryzom Core Studio - Tile Editor plugin
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "tilebank_saver.h" #include "tilebank_saver.h"
#include "tile_model.h" #include "tile_model.h"
#include "tile_item.h" #include "tile_item.h"
#include "nel/3d/tile_bank.h" #include "nel/3d/tile_bank.h"
#include "nel/misc/file.h" #include "nel/misc/file.h"
TileBankSaver::TileBankSaver() TileBankSaver::TileBankSaver()
{ {
} }
TileBankSaver::~TileBankSaver() TileBankSaver::~TileBankSaver()
{ {
} }
bool TileBankSaver::save( const char *fileName, TileModel* model ) bool TileBankSaver::save( const char *fileName, TileModel* model )
{ {
// Save to file // Save to file
NLMISC::COFile f; NLMISC::COFile f;
bool b = f.open( fileName, false, false, false ); bool b = f.open( fileName, false, false, false );
if( !b ) if( !b )
return false; return false;
model->serial( f ); model->serial( f );
f.flush(); f.flush();
f.close(); f.close();
return true; return true;
} }

View file

@ -1,39 +1,39 @@
// Ryzom Core Studio - Tile Editor plugin // Ryzom Core Studio - Tile Editor plugin
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef TILEBANK_SAVER_H #ifndef TILEBANK_SAVER_H
#define TILEBANK_SAVER_H #define TILEBANK_SAVER_H
#include <QString> #include <QString>
#include <QList> #include <QList>
class TileModel; class TileModel;
class TileBankSaver class TileBankSaver
{ {
public: public:
TileBankSaver(); TileBankSaver();
~TileBankSaver(); ~TileBankSaver();
bool save( const char *filename, TileModel* model ); bool save( const char *filename, TileModel* model );
private: private:
}; };
#endif #endif

View file

@ -1,472 +1,472 @@
// Ryzom Core Studio - Translation Manager Plugin // Ryzom Core Studio - Translation Manager Plugin
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "translation_manager_constants.h" #include "translation_manager_constants.h"
#include "uxt_editor.h" #include "uxt_editor.h"
#include <QTableWidget> #include <QTableWidget>
#include <QFormLayout> #include <QFormLayout>
#include <QCloseEvent> #include <QCloseEvent>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMessageBox> #include <QMessageBox>
#include <QMenu> #include <QMenu>
#include <QFileDialog> #include <QFileDialog>
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include "nel/misc/diff_tool.h" #include "nel/misc/diff_tool.h"
#include "nel/misc/i18n.h" #include "nel/misc/i18n.h"
namespace namespace
{ {
QString getLang( const QString &fn ) QString getLang( const QString &fn )
{ {
QString lang = fn; QString lang = fn;
int idx = lang.lastIndexOf( '/' ); int idx = lang.lastIndexOf( '/' );
if( idx == -1 ) if( idx == -1 )
return ""; return "";
lang = lang.mid( idx + 1 ); lang = lang.mid( idx + 1 );
idx = lang.lastIndexOf( '.' ); idx = lang.lastIndexOf( '.' );
if( idx == -1 ) if( idx == -1 )
return ""; return "";
lang = lang.left( idx ); lang = lang.left( idx );
return lang; return lang;
} }
} }
namespace TranslationManager namespace TranslationManager
{ {
void markItemTranslated( QTableWidgetItem *item ) void markItemTranslated( QTableWidgetItem *item )
{ {
item->setBackground( QColor::fromRgb( 126, 247, 134 ) ); item->setBackground( QColor::fromRgb( 126, 247, 134 ) );
} }
void markItemUntranslated( QTableWidgetItem *item ) void markItemUntranslated( QTableWidgetItem *item )
{ {
item->setBackground( QColor::fromRgb( 247, 126, 126 ) ); item->setBackground( QColor::fromRgb( 247, 126, 126 ) );
} }
class UXTEditorPvt class UXTEditorPvt
{ {
public: public:
UXTEditorPvt() UXTEditorPvt()
{ {
t = new QTableWidget(); t = new QTableWidget();
loadedFromWK = false; loadedFromWK = false;
} }
QTableWidget *t; QTableWidget *t;
std::vector< STRING_MANAGER::TStringInfo > infos; std::vector< STRING_MANAGER::TStringInfo > infos;
bool loadedFromWK; bool loadedFromWK;
}; };
UXTEditor::UXTEditor( QMdiArea *parent ) : UXTEditor::UXTEditor( QMdiArea *parent ) :
CEditor( parent ) CEditor( parent )
{ {
editor_type = Constants::ED_UXT; editor_type = Constants::ED_UXT;
setAttribute( Qt::WA_DeleteOnClose ); setAttribute( Qt::WA_DeleteOnClose );
d_ptr = new UXTEditorPvt(); d_ptr = new UXTEditorPvt();
blockTableSignals( false ); blockTableSignals( false );
} }
UXTEditor::~UXTEditor() UXTEditor::~UXTEditor()
{ {
delete d_ptr; delete d_ptr;
d_ptr = NULL; d_ptr = NULL;
} }
void UXTEditor::open( QString filename ) void UXTEditor::open( QString filename )
{ {
std::vector< STRING_MANAGER::TStringInfo > &infos = d_ptr->infos; std::vector< STRING_MANAGER::TStringInfo > &infos = d_ptr->infos;
QString lang = getLang( filename ); QString lang = getLang( filename );
infos.clear(); infos.clear();
STRING_MANAGER::loadStringFile( filename.toUtf8().constData(), infos, false ); STRING_MANAGER::loadStringFile( filename.toUtf8().constData(), infos, false );
if( d_ptr->infos.size() == 0 ) if( d_ptr->infos.size() == 0 )
{ {
// The work file cannot be found, cannot proceed // The work file cannot be found, cannot proceed
if( filename.endsWith( "wk.uxt" ) ) if( filename.endsWith( "wk.uxt" ) )
{ {
QMessageBox::critical( this, QMessageBox::critical( this,
tr( "Error opening file.." ), tr( "Error opening file.." ),
tr( "There was an error opening wk.uxt" ) ); tr( "There was an error opening wk.uxt" ) );
return; return;
} }
int l = filename.lastIndexOf( "/" ); int l = filename.lastIndexOf( "/" );
if( l == -1 ) if( l == -1 )
return; return;
QString fn = filename.left( l ); QString fn = filename.left( l );
fn += "/wk.uxt"; fn += "/wk.uxt";
// The work file cannot be found, cannot proceed // The work file cannot be found, cannot proceed
STRING_MANAGER::loadStringFile( fn.toUtf8().constData(), infos, true ); STRING_MANAGER::loadStringFile( fn.toUtf8().constData(), infos, true );
if( d_ptr->infos.size() == 0 ) if( d_ptr->infos.size() == 0 )
{ {
QMessageBox::critical( this, QMessageBox::critical( this,
tr( "Error opening Uxt file" ), tr( "Error opening Uxt file" ),
tr( "Neither the specified file nor wk.uxt could be opened." ) ); tr( "Neither the specified file nor wk.uxt could be opened." ) );
return; return;
} }
d_ptr->loadedFromWK = true; d_ptr->loadedFromWK = true;
} }
blockTableSignals( true ); blockTableSignals( true );
d_ptr->t->clear(); d_ptr->t->clear();
d_ptr->t->setColumnCount( 2 ); d_ptr->t->setColumnCount( 2 );
d_ptr->t->setRowCount( infos.size() ); d_ptr->t->setRowCount( infos.size() );
setHeaderText( "Id", lang.toUpper() + " Text" ); setHeaderText( "Id", lang.toUpper() + " Text" );
int i = 0; int i = 0;
std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = infos.begin(); std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = infos.begin();
while( itr != infos.end() ) while( itr != infos.end() )
{ {
const STRING_MANAGER::TStringInfo &info = *itr; const STRING_MANAGER::TStringInfo &info = *itr;
QTableWidgetItem *name = new QTableWidgetItem( info.Identifier.c_str() ); QTableWidgetItem *name = new QTableWidgetItem( info.Identifier.c_str() );
QTableWidgetItem *text1 = new QTableWidgetItem( info.Text.toUtf8().c_str() ); QTableWidgetItem *text1 = new QTableWidgetItem( info.Text.toUtf8().c_str() );
d_ptr->t->setItem( i, 0, name ); d_ptr->t->setItem( i, 0, name );
d_ptr->t->setItem( i, 1, text1 ); d_ptr->t->setItem( i, 1, text1 );
if( ( info.HashValue != 0 ) && !d_ptr->loadedFromWK ) if( ( info.HashValue != 0 ) && !d_ptr->loadedFromWK )
{ {
markItemTranslated( name ); markItemTranslated( name );
markItemTranslated( text1 ); markItemTranslated( text1 );
} }
else else
{ {
markItemUntranslated( name ); markItemUntranslated( name );
markItemUntranslated( text1 ); markItemUntranslated( text1 );
} }
++itr; ++itr;
i++; i++;
} }
d_ptr->t->resizeColumnsToContents(); d_ptr->t->resizeColumnsToContents();
blockTableSignals( false ); blockTableSignals( false );
setWidget( d_ptr->t ); setWidget( d_ptr->t );
current_file = filename; current_file = filename;
setWindowTitle( filename + "[*]" ); setWindowTitle( filename + "[*]" );
setWindowFilePath( filename ); setWindowFilePath( filename );
} }
void UXTEditor::save() void UXTEditor::save()
{ {
saveAs( current_file ); saveAs( current_file );
} }
void UXTEditor::saveAs( QString filename ) void UXTEditor::saveAs( QString filename )
{ {
QFile f( filename ); QFile f( filename );
if( !f.open( QIODevice::WriteOnly ) ) if( !f.open( QIODevice::WriteOnly ) )
return; return;
QTextStream out( &f ); QTextStream out( &f );
int idx = 0; int idx = 0;
std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = d_ptr->infos.begin(); std::vector< STRING_MANAGER::TStringInfo >::const_iterator itr = d_ptr->infos.begin();
while( itr != d_ptr->infos.end() ) while( itr != d_ptr->infos.end() )
{ {
uint64 hash = 0; 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 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. // 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 // 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( itr->Text2.empty() )
{ {
if( d_ptr->loadedFromWK ) if( d_ptr->loadedFromWK )
hash = 0; hash = 0;
else else
hash = itr->HashValue; hash = itr->HashValue;
} }
else else
{ {
hash = NLMISC::CI18N::makeHash( itr->Text2 ); hash = NLMISC::CI18N::makeHash( itr->Text2 );
} }
QString hashLine = "// HASH_VALUE "; QString hashLine = "// HASH_VALUE ";
hashLine += QString( NLMISC::CI18N::hashToString( hash ).c_str() ).toUpper(); hashLine += QString( NLMISC::CI18N::hashToString( hash ).c_str() ).toUpper();
hashLine += "\r\n"; hashLine += "\r\n";
QString idxLine = "// INDEX "; QString idxLine = "// INDEX ";
idxLine += QString::number( idx ); idxLine += QString::number( idx );
idxLine += "\r\n"; idxLine += "\r\n";
QString trLine = ""; QString trLine = "";
trLine += itr->Identifier.c_str(); trLine += itr->Identifier.c_str();
trLine += "\t"; trLine += "\t";
trLine += "["; trLine += "[";
if( itr->Text2.empty() ) if( itr->Text2.empty() )
trLine += itr->Text.toUtf8().c_str(); trLine += itr->Text.toUtf8().c_str();
else else
trLine += itr->Text2.toUtf8().c_str(); trLine += itr->Text2.toUtf8().c_str();
trLine += "]"; trLine += "]";
trLine += "\r\n"; trLine += "\r\n";
QString newLine = "\r\n"; QString newLine = "\r\n";
out << hashLine; out << hashLine;
out << idxLine; out << idxLine;
out << trLine; out << trLine;
out << newLine; out << newLine;
++itr; ++itr;
idx++; idx++;
} }
f.close(); f.close();
setWindowModified( false ); setWindowModified( false );
} }
void UXTEditor::activateWindow() void UXTEditor::activateWindow()
{ {
showMaximized(); showMaximized();
} }
void UXTEditor::insertRow() void UXTEditor::insertRow()
{ {
blockTableSignals( true ); blockTableSignals( true );
d_ptr->infos.push_back( STRING_MANAGER::TStringInfo() ); d_ptr->infos.push_back( STRING_MANAGER::TStringInfo() );
d_ptr->t->setRowCount( d_ptr->t->rowCount() + 1 ); d_ptr->t->setRowCount( d_ptr->t->rowCount() + 1 );
int row = d_ptr->t->rowCount() - 1; int row = d_ptr->t->rowCount() - 1;
QTableWidgetItem *item1 = new QTableWidgetItem(); QTableWidgetItem *item1 = new QTableWidgetItem();
QTableWidgetItem *item2 = new QTableWidgetItem(); QTableWidgetItem *item2 = new QTableWidgetItem();
d_ptr->t->setItem( row, 0, item1 ); d_ptr->t->setItem( row, 0, item1 );
d_ptr->t->setItem( row, 1, item2 ); d_ptr->t->setItem( row, 1, item2 );
markRowUntranslated( row ); markRowUntranslated( row );
setWindowModified( true ); setWindowModified( true );
blockTableSignals( false ); blockTableSignals( false );
} }
void UXTEditor::deleteRow() void UXTEditor::deleteRow()
{ {
int r = d_ptr->t->currentRow(); int r = d_ptr->t->currentRow();
if( r < 0 ) if( r < 0 )
return; return;
int answer = QMessageBox::question( this, int answer = QMessageBox::question( this,
tr( "Deleting a row" ), tr( "Deleting a row" ),
tr( "Are you sure you want to delete this row?" ), tr( "Are you sure you want to delete this row?" ),
QMessageBox::Yes, QMessageBox::Yes,
QMessageBox::Cancel ); QMessageBox::Cancel );
if( QMessageBox::Yes != answer ) if( QMessageBox::Yes != answer )
return; return;
std::vector< STRING_MANAGER::TStringInfo >::iterator itr = d_ptr->infos.begin(); std::vector< STRING_MANAGER::TStringInfo >::iterator itr = d_ptr->infos.begin();
itr += r; itr += r;
d_ptr->infos.erase( itr ); d_ptr->infos.erase( itr );
d_ptr->t->removeRow( r ); d_ptr->t->removeRow( r );
setWindowModified( true ); setWindowModified( true );
} }
void UXTEditor::closeEvent( QCloseEvent *e ) void UXTEditor::closeEvent( QCloseEvent *e )
{ {
if( isWindowModified() ) if( isWindowModified() )
{ {
int reply = QMessageBox::question( this, int reply = QMessageBox::question( this,
tr( "Table changed" ), tr( "Table changed" ),
tr( "The table has changed. Would you like to save your changes?" ), tr( "The table has changed. Would you like to save your changes?" ),
QMessageBox::Yes, QMessageBox::Yes,
QMessageBox::No QMessageBox::No
); );
if( reply == QMessageBox::Yes ) if( reply == QMessageBox::Yes )
save(); save();
} }
e->accept(); e->accept();
close(); close();
} }
void UXTEditor::contextMenuEvent( QContextMenuEvent *e ) void UXTEditor::contextMenuEvent( QContextMenuEvent *e )
{ {
QMenu *menu = new QMenu( this ); QMenu *menu = new QMenu( this );
QAction *insertAction = new QAction( "Insert row", menu ); QAction *insertAction = new QAction( "Insert row", menu );
QAction *deleteAction = new QAction( "Delete row", menu ); QAction *deleteAction = new QAction( "Delete row", menu );
QAction *markAction = new QAction( "Mark translated", menu ); QAction *markAction = new QAction( "Mark translated", menu );
QAction *unmarkAction = new QAction( "Mark not-translated", menu ); QAction *unmarkAction = new QAction( "Mark not-translated", menu );
QAction *saveAction = new QAction( "Save", menu ); QAction *saveAction = new QAction( "Save", menu );
QAction *saveAsAction = new QAction( "Save as..", menu ); QAction *saveAsAction = new QAction( "Save as..", menu );
connect( insertAction, SIGNAL( triggered( bool ) ), this, SLOT( insertRow() ) ); connect( insertAction, SIGNAL( triggered( bool ) ), this, SLOT( insertRow() ) );
connect( deleteAction, SIGNAL( triggered( bool ) ), this, SLOT( deleteRow() ) ); connect( deleteAction, SIGNAL( triggered( bool ) ), this, SLOT( deleteRow() ) );
connect( markAction, SIGNAL( triggered( bool ) ), this, SLOT( markTranslated() ) ); connect( markAction, SIGNAL( triggered( bool ) ), this, SLOT( markTranslated() ) );
connect( unmarkAction, SIGNAL( triggered( bool ) ), this, SLOT( markUntranslated() ) ); connect( unmarkAction, SIGNAL( triggered( bool ) ), this, SLOT( markUntranslated() ) );
connect( saveAction, SIGNAL( triggered( bool ) ), this, SLOT( onSaveClicked() ) ); connect( saveAction, SIGNAL( triggered( bool ) ), this, SLOT( onSaveClicked() ) );
connect( saveAsAction, SIGNAL( triggered( bool ) ), this, SLOT( onSaveAsClicked() ) ); connect( saveAsAction, SIGNAL( triggered( bool ) ), this, SLOT( onSaveAsClicked() ) );
menu->addAction( insertAction ); menu->addAction( insertAction );
menu->addAction( deleteAction ); menu->addAction( deleteAction );
menu->addAction( markAction ); menu->addAction( markAction );
menu->addAction( unmarkAction ); menu->addAction( unmarkAction );
menu->addAction( saveAction ); menu->addAction( saveAction );
menu->addAction( saveAsAction ); menu->addAction( saveAsAction );
menu->exec( e->globalPos() ); menu->exec( e->globalPos() );
} }
void UXTEditor::onCellChanged( int row, int column ) void UXTEditor::onCellChanged( int row, int column )
{ {
QTableWidgetItem *item = d_ptr->t->item( row, column ); QTableWidgetItem *item = d_ptr->t->item( row, column );
STRING_MANAGER::TStringInfo &info = d_ptr->infos[ row ]; STRING_MANAGER::TStringInfo &info = d_ptr->infos[ row ];
if( column == 0 ) if( column == 0 )
info.Identifier = item->text().toUtf8().constData(); info.Identifier = item->text().toUtf8().constData();
else else
if( column == 1 ) if( column == 1 )
info.Text2 = item->text().toUtf8().constData(); info.Text2 = item->text().toUtf8().constData();
setWindowModified( true ); setWindowModified( true );
markRowTranslated( row ); markRowTranslated( row );
} }
void UXTEditor::markTranslated() void UXTEditor::markTranslated()
{ {
int r = d_ptr->t->currentRow(); int r = d_ptr->t->currentRow();
if( r < 0 ) if( r < 0 )
return; return;
STRING_MANAGER::TStringInfo &info = d_ptr->infos[ r ]; STRING_MANAGER::TStringInfo &info = d_ptr->infos[ r ];
if( !info.Text2.empty() ) if( !info.Text2.empty() )
return; return;
info.Text2 = info.Text; info.Text2 = info.Text;
setWindowModified( true ); setWindowModified( true );
markRowTranslated( r ); markRowTranslated( r );
} }
void UXTEditor::markUntranslated() void UXTEditor::markUntranslated()
{ {
int r = d_ptr->t->currentRow(); int r = d_ptr->t->currentRow();
if( r < 0 ) if( r < 0 )
return; return;
STRING_MANAGER::TStringInfo &info = d_ptr->infos[ r ]; STRING_MANAGER::TStringInfo &info = d_ptr->infos[ r ];
info.Text2.clear(); info.Text2.clear();
info.HashValue = 0; info.HashValue = 0;
setWindowModified( true ); setWindowModified( true );
markRowUntranslated( r ); markRowUntranslated( r );
} }
void UXTEditor::onSaveClicked() void UXTEditor::onSaveClicked()
{ {
save(); save();
} }
void UXTEditor::onSaveAsClicked() void UXTEditor::onSaveAsClicked()
{ {
QString path = current_file; QString path = current_file;
int idx = path.lastIndexOf( '/' ); int idx = path.lastIndexOf( '/' );
if( idx < 0 ) if( idx < 0 )
path = ""; path = "";
else else
path = path.left( idx + 1 ); path = path.left( idx + 1 );
QString file = QFileDialog::getSaveFileName( this, QString file = QFileDialog::getSaveFileName( this,
tr( "Save Uxt as.." ), tr( "Save Uxt as.." ),
path, path,
tr( "Uxt files ( *.uxt)" ) ); tr( "Uxt files ( *.uxt)" ) );
if( file.isEmpty() ) if( file.isEmpty() )
return; return;
saveAs( file ); saveAs( file );
} }
void UXTEditor::setHeaderText( const QString &id, const QString &text ) void UXTEditor::setHeaderText( const QString &id, const QString &text )
{ {
QTableWidgetItem *h1 = new QTableWidgetItem( id ); QTableWidgetItem *h1 = new QTableWidgetItem( id );
QTableWidgetItem *h2 = new QTableWidgetItem( text ); QTableWidgetItem *h2 = new QTableWidgetItem( text );
h1->setTextAlignment( Qt::AlignLeft ); h1->setTextAlignment( Qt::AlignLeft );
h2->setTextAlignment( Qt::AlignLeft ); h2->setTextAlignment( Qt::AlignLeft );
d_ptr->t->setHorizontalHeaderItem( 0, h1 ); d_ptr->t->setHorizontalHeaderItem( 0, h1 );
d_ptr->t->setHorizontalHeaderItem( 1, h2 ); d_ptr->t->setHorizontalHeaderItem( 1, h2 );
} }
void UXTEditor::blockTableSignals( bool block ) void UXTEditor::blockTableSignals( bool block )
{ {
if( block ) if( block )
disconnect( d_ptr->t, SIGNAL( cellChanged( int, int ) ), this, SLOT( onCellChanged( int, int ) ) ); disconnect( d_ptr->t, SIGNAL( cellChanged( int, int ) ), this, SLOT( onCellChanged( int, int ) ) );
else else
connect( d_ptr->t, SIGNAL( cellChanged( int, int ) ), this, SLOT( onCellChanged( int, int ) ) ); connect( d_ptr->t, SIGNAL( cellChanged( int, int ) ), this, SLOT( onCellChanged( int, int ) ) );
} }
void UXTEditor::markRowTranslated( int row ) void UXTEditor::markRowTranslated( int row )
{ {
blockTableSignals( true ); blockTableSignals( true );
QTableWidgetItem *item1 = d_ptr->t->item( row, 0 ); QTableWidgetItem *item1 = d_ptr->t->item( row, 0 );
QTableWidgetItem *item2 = d_ptr->t->item( row, 1 ); QTableWidgetItem *item2 = d_ptr->t->item( row, 1 );
markItemTranslated( item1 ); markItemTranslated( item1 );
markItemTranslated( item2 ); markItemTranslated( item2 );
blockTableSignals( false ); blockTableSignals( false );
} }
void UXTEditor::markRowUntranslated( int row ) void UXTEditor::markRowUntranslated( int row )
{ {
blockTableSignals( true ); blockTableSignals( true );
QTableWidgetItem *item1 = d_ptr->t->item( row, 0 ); QTableWidgetItem *item1 = d_ptr->t->item( row, 0 );
QTableWidgetItem *item2 = d_ptr->t->item( row, 1 ); QTableWidgetItem *item2 = d_ptr->t->item( row, 1 );
markItemUntranslated( item1 ); markItemUntranslated( item1 );
markItemUntranslated( item2 ); markItemUntranslated( item2 );
blockTableSignals( false ); blockTableSignals( false );
} }
} }

View file

@ -1,236 +1,236 @@
// Ryzom Core - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // Ryzom Core - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "settings_dialog.h" #include "settings_dialog.h"
#include <QFileDialog> #include <QFileDialog>
#include <QSettings> #include <QSettings>
#include <QStringList> #include <QStringList>
int findListItem( QListWidget *l, const QString &s ) int findListItem( QListWidget *l, const QString &s )
{ {
for( int i = 0; i < l->count(); i++ ) for( int i = 0; i < l->count(); i++ )
{ {
QListWidgetItem *item = l->item( i ); QListWidgetItem *item = l->item( i );
if( item->text() == s ) if( item->text() == s )
return i; return i;
} }
return -1; return -1;
} }
SettingsDialog::SettingsDialog( QDialog *parent ) : SettingsDialog::SettingsDialog( QDialog *parent ) :
QDialog( parent ) QDialog( parent )
{ {
setupUi( this ); setupUi( this );
setupConnections(); setupConnections();
settings = NULL; settings = NULL;
} }
SettingsDialog::~SettingsDialog() SettingsDialog::~SettingsDialog()
{ {
} }
void SettingsDialog::load() void SettingsDialog::load()
{ {
pluginsLE->setText( settings->value( "PluginPath" ).toString() ); pluginsLE->setText( settings->value( "PluginPath" ).toString() );
settings->beginGroup( "DataPath" ); settings->beginGroup( "DataPath" );
sheetsLE->setText( settings->value( "LevelDesignPath" ).toString() ); sheetsLE->setText( settings->value( "LevelDesignPath" ).toString() );
assetsLE->setText( settings->value( "AssetsPath" ).toString() ); assetsLE->setText( settings->value( "AssetsPath" ).toString() );
primitivesLE->setText( settings->value( "PrimitivesPath" ).toString() ); primitivesLE->setText( settings->value( "PrimitivesPath" ).toString() );
ligoLE->setText( settings->value( "LigoConfigFile" ).toString() ); ligoLE->setText( settings->value( "LigoConfigFile" ).toString() );
QStringList l = settings->value( "SearchPaths" ).toStringList(); QStringList l = settings->value( "SearchPaths" ).toStringList();
{ {
QStringListIterator itr( l ); QStringListIterator itr( l );
while( itr.hasNext() ) while( itr.hasNext() )
{ {
QString p = itr.next(); QString p = itr.next();
if( findListItem( searchLW, p ) == -1 ) if( findListItem( searchLW, p ) == -1 )
searchLW->addItem( p ); searchLW->addItem( p );
} }
} }
l.clear(); l.clear();
l = settings->value( "RecursiveSearchPathes" ).toStringList(); l = settings->value( "RecursiveSearchPathes" ).toStringList();
{ {
QStringListIterator itr( l ); QStringListIterator itr( l );
while( itr.hasNext() ) while( itr.hasNext() )
{ {
QString p = itr.next(); QString p = itr.next();
if( findListItem( recursiveLW, p ) == -1 ) if( findListItem( recursiveLW, p ) == -1 )
recursiveLW->addItem( p ); recursiveLW->addItem( p );
} }
} }
settings->endGroup(); settings->endGroup();
} }
void SettingsDialog::saveSearchPaths() void SettingsDialog::saveSearchPaths()
{ {
QStringList l; QStringList l;
for( int i = 0; i < searchLW->count(); i++ ) for( int i = 0; i < searchLW->count(); i++ )
{ {
l.push_back( searchLW->item( i )->text() ); l.push_back( searchLW->item( i )->text() );
} }
settings->setValue( "SearchPaths", l ); settings->setValue( "SearchPaths", l );
} }
void SettingsDialog::saveRecursivePaths() void SettingsDialog::saveRecursivePaths()
{ {
QStringList l; QStringList l;
for( int i = 0; i < recursiveLW->count(); i++ ) for( int i = 0; i < recursiveLW->count(); i++ )
{ {
l.push_back( recursiveLW->item( i )->text() ); l.push_back( recursiveLW->item( i )->text() );
} }
settings->setValue( "RecursiveSearchPathes", l ); settings->setValue( "RecursiveSearchPathes", l );
} }
void SettingsDialog::save() void SettingsDialog::save()
{ {
settings->setValue( "PluginPath", pluginsLE->text() ); settings->setValue( "PluginPath", pluginsLE->text() );
settings->beginGroup( "DataPath" ); settings->beginGroup( "DataPath" );
settings->setValue( "LevelDesignPath", sheetsLE->text() ); settings->setValue( "LevelDesignPath", sheetsLE->text() );
settings->setValue( "AssetsPath", assetsLE->text() ); settings->setValue( "AssetsPath", assetsLE->text() );
settings->setValue( "PrimitivesPath", primitivesLE->text() ); settings->setValue( "PrimitivesPath", primitivesLE->text() );
settings->setValue( "LigoConfigFile", ligoLE->text() ); settings->setValue( "LigoConfigFile", ligoLE->text() );
saveSearchPaths(); saveSearchPaths();
saveRecursivePaths(); saveRecursivePaths();
settings->endGroup(); settings->endGroup();
settings->sync(); settings->sync();
} }
void SettingsDialog::accept() void SettingsDialog::accept()
{ {
save(); save();
QDialog::accept(); QDialog::accept();
} }
void SettingsDialog::reject() void SettingsDialog::reject()
{ {
QDialog::reject(); QDialog::reject();
} }
void SettingsDialog::onOKClicked() void SettingsDialog::onOKClicked()
{ {
accept(); accept();
} }
void SettingsDialog::onCancelClicked() void SettingsDialog::onCancelClicked()
{ {
reject(); reject();
} }
void SettingsDialog::onPluginBClicked() void SettingsDialog::onPluginBClicked()
{ {
QString p = QFileDialog::getExistingDirectory( this, tr( "Plugins directory" ), "" ); QString p = QFileDialog::getExistingDirectory( this, tr( "Plugins directory" ), "" );
pluginsLE->setText( p ); pluginsLE->setText( p );
} }
void SettingsDialog::onSheetsBClicked() void SettingsDialog::onSheetsBClicked()
{ {
QString p = QFileDialog::getExistingDirectory( this, tr( "Sheets directory" ), "" ); QString p = QFileDialog::getExistingDirectory( this, tr( "Sheets directory" ), "" );
sheetsLE->setText( p ); sheetsLE->setText( p );
} }
void SettingsDialog::onAssetsBClicked() void SettingsDialog::onAssetsBClicked()
{ {
QString p = QFileDialog::getExistingDirectory( this, tr( "Assets directory" ), "" ); QString p = QFileDialog::getExistingDirectory( this, tr( "Assets directory" ), "" );
assetsLE->setText( p ); assetsLE->setText( p );
} }
void SettingsDialog::onPrimitivesBClicked() void SettingsDialog::onPrimitivesBClicked()
{ {
QString p = QFileDialog::getExistingDirectory( this, tr( "Primitives directory" ), "" ); QString p = QFileDialog::getExistingDirectory( this, tr( "Primitives directory" ), "" );
primitivesLE->setText( p ); primitivesLE->setText( p );
} }
void SettingsDialog::onLigoBClicked() void SettingsDialog::onLigoBClicked()
{ {
QString p = QFileDialog::getExistingDirectory( this, tr( "LIGO directory" ), "" ); QString p = QFileDialog::getExistingDirectory( this, tr( "LIGO directory" ), "" );
ligoLE->setText( p ); ligoLE->setText( p );
} }
void SettingsDialog::onPathAddClicked() void SettingsDialog::onPathAddClicked()
{ {
QString p = QFileDialog::getExistingDirectory( this, tr( "Search path" ), "" ); QString p = QFileDialog::getExistingDirectory( this, tr( "Search path" ), "" );
if( p.isEmpty() ) if( p.isEmpty() )
return; return;
if( findListItem( searchLW, p ) != -1 ) if( findListItem( searchLW, p ) != -1 )
return; return;
searchLW->addItem( p ); searchLW->addItem( p );
} }
void SettingsDialog::onPathRemoveClicked() void SettingsDialog::onPathRemoveClicked()
{ {
QListWidgetItem *i = searchLW->currentItem(); QListWidgetItem *i = searchLW->currentItem();
if( i == NULL ) if( i == NULL )
return; return;
delete i; delete i;
} }
void SettingsDialog::onRecursiveAddClicked() void SettingsDialog::onRecursiveAddClicked()
{ {
QString p = QFileDialog::getExistingDirectory( this, tr( "Recursive search path" ), "" ); QString p = QFileDialog::getExistingDirectory( this, tr( "Recursive search path" ), "" );
if( p.isEmpty() ) if( p.isEmpty() )
return; return;
if( findListItem( recursiveLW, p ) != -1 ) if( findListItem( recursiveLW, p ) != -1 )
return; return;
recursiveLW->addItem( p ); recursiveLW->addItem( p );
} }
void SettingsDialog::onRecursiveRemoveClicked() void SettingsDialog::onRecursiveRemoveClicked()
{ {
QListWidgetItem *i = recursiveLW->currentItem(); QListWidgetItem *i = recursiveLW->currentItem();
if( i == NULL ) if( i == NULL )
return; return;
delete i; delete i;
} }
void SettingsDialog::setupConnections() void SettingsDialog::setupConnections()
{ {
connect( bb, SIGNAL( accepted() ), this, SLOT( onOKClicked() ) ); connect( bb, SIGNAL( accepted() ), this, SLOT( onOKClicked() ) );
connect( bb, SIGNAL( rejected() ), this, SLOT( onCancelClicked() ) ); connect( bb, SIGNAL( rejected() ), this, SLOT( onCancelClicked() ) );
connect( pluginsB, SIGNAL( clicked( bool ) ), this, SLOT( onPluginBClicked() ) ); connect( pluginsB, SIGNAL( clicked( bool ) ), this, SLOT( onPluginBClicked() ) );
connect( sheetsB, SIGNAL( clicked( bool ) ), this, SLOT( onSheetsBClicked() ) ); connect( sheetsB, SIGNAL( clicked( bool ) ), this, SLOT( onSheetsBClicked() ) );
connect( assetsB, SIGNAL( clicked( bool ) ), this, SLOT( onAssetsBClicked() ) ); connect( assetsB, SIGNAL( clicked( bool ) ), this, SLOT( onAssetsBClicked() ) );
connect( primitivesB, SIGNAL( clicked( bool ) ), this, SLOT( onPrimitivesBClicked() ) ); connect( primitivesB, SIGNAL( clicked( bool ) ), this, SLOT( onPrimitivesBClicked() ) );
connect( ligoB, SIGNAL( clicked( bool ) ), this, SLOT( onLigoBClicked() ) ); connect( ligoB, SIGNAL( clicked( bool ) ), this, SLOT( onLigoBClicked() ) );
connect( pathAddB, SIGNAL( clicked( bool ) ), this, SLOT( onPathAddClicked() ) ); connect( pathAddB, SIGNAL( clicked( bool ) ), this, SLOT( onPathAddClicked() ) );
connect( pathRemoveB, SIGNAL( clicked( bool ) ), this, SLOT( onPathRemoveClicked() ) ); connect( pathRemoveB, SIGNAL( clicked( bool ) ), this, SLOT( onPathRemoveClicked() ) );
connect( recAddB, SIGNAL( clicked( bool ) ), this, SLOT( onRecursiveAddClicked() ) ); connect( recAddB, SIGNAL( clicked( bool ) ), this, SLOT( onRecursiveAddClicked() ) );
connect( recRemoveB, SIGNAL( clicked( bool ) ), this, SLOT( onRecursiveRemoveClicked() ) ); connect( recRemoveB, SIGNAL( clicked( bool ) ), this, SLOT( onRecursiveRemoveClicked() ) );
} }

View file

@ -1,62 +1,62 @@
// Ryzom Core - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // Ryzom Core - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SETTINGS_DIALOG_H #ifndef SETTINGS_DIALOG_H
#define SETTINGS_DIALOG_H #define SETTINGS_DIALOG_H
#include "ui_settings_dialog.h" #include "ui_settings_dialog.h"
class QSettings; class QSettings;
class SettingsDialog : public QDialog, public Ui::SettingsDialog class SettingsDialog : public QDialog, public Ui::SettingsDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
SettingsDialog( QDialog *parent = NULL ); SettingsDialog( QDialog *parent = NULL );
~SettingsDialog(); ~SettingsDialog();
void setSettings( QSettings *s ){ settings = s; } void setSettings( QSettings *s ){ settings = s; }
void load(); void load();
public Q_SLOTS: public Q_SLOTS:
void accept(); void accept();
void reject(); void reject();
void onOKClicked(); void onOKClicked();
void onCancelClicked(); void onCancelClicked();
void onPluginBClicked(); void onPluginBClicked();
void onSheetsBClicked(); void onSheetsBClicked();
void onAssetsBClicked(); void onAssetsBClicked();
void onPrimitivesBClicked(); void onPrimitivesBClicked();
void onLigoBClicked(); void onLigoBClicked();
void onPathAddClicked(); void onPathAddClicked();
void onPathRemoveClicked(); void onPathRemoveClicked();
void onRecursiveAddClicked(); void onRecursiveAddClicked();
void onRecursiveRemoveClicked(); void onRecursiveRemoveClicked();
private: private:
void setupConnections(); void setupConnections();
void save(); void save();
void saveSearchPaths(); void saveSearchPaths();
void saveRecursivePaths(); void saveRecursivePaths();
QSettings *settings; QSettings *settings;
}; };
#endif #endif

View file

@ -1,109 +1,109 @@
// Ryzom Core - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // Ryzom Core - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "splash_screen.h" #include "splash_screen.h"
#include <QPainter> #include <QPainter>
#include <QStyleOptionProgressBarV2> #include <QStyleOptionProgressBarV2>
#include <QCoreApplication> #include <QCoreApplication>
#include <QPixmap> #include <QPixmap>
SplashScreen::SplashScreen() : SplashScreen::SplashScreen() :
QSplashScreen() QSplashScreen()
{ {
progress = 0; progress = 0;
textX = 5; textX = 5;
textY = 20; textY = 20;
pbLeft = 2; pbLeft = 2;
pbTop = 0; pbTop = 0;
pbWidth = 100; pbWidth = 100;
pbHeight = 20; pbHeight = 20;
} }
SplashScreen::~SplashScreen() SplashScreen::~SplashScreen()
{ {
} }
void SplashScreen::setPixmap( const QPixmap &pixmap ) void SplashScreen::setPixmap( const QPixmap &pixmap )
{ {
QSplashScreen::setPixmap( pixmap ); QSplashScreen::setPixmap( pixmap );
if( this->pixmap().width() > 0 ) if( this->pixmap().width() > 0 )
pbWidth = this->pixmap().width() - 4; pbWidth = this->pixmap().width() - 4;
if( this->pixmap().height() > 0 ) if( this->pixmap().height() > 0 )
pbTop = this->pixmap().height() - pbHeight - 2; pbTop = this->pixmap().height() - pbHeight - 2;
textY = pbTop - pbHeight / 2; textY = pbTop - pbHeight / 2;
} }
void SplashScreen::setText( const QString &text ) void SplashScreen::setText( const QString &text )
{ {
this->text = text; this->text = text;
repaint(); repaint();
QCoreApplication::instance()->processEvents(); QCoreApplication::instance()->processEvents();
} }
void SplashScreen::clearText() void SplashScreen::clearText()
{ {
setText( "" ); setText( "" );
} }
void SplashScreen::setProgress( int percent ) void SplashScreen::setProgress( int percent )
{ {
progress = percent; progress = percent;
repaint(); repaint();
QCoreApplication::instance()->processEvents(); QCoreApplication::instance()->processEvents();
} }
void SplashScreen::advanceProgress( int percent ) void SplashScreen::advanceProgress( int percent )
{ {
progress += percent; progress += percent;
repaint(); repaint();
QCoreApplication::instance()->processEvents(); QCoreApplication::instance()->processEvents();
} }
void SplashScreen::drawContents( QPainter *painter ) void SplashScreen::drawContents( QPainter *painter )
{ {
QSplashScreen::drawContents( painter ); QSplashScreen::drawContents( painter );
if( progressBarEnabled ) if( progressBarEnabled )
{ {
QStyleOptionProgressBarV2 pbStyle; QStyleOptionProgressBarV2 pbStyle;
pbStyle.initFrom( this ); pbStyle.initFrom( this );
pbStyle.state = QStyle::State_Enabled; pbStyle.state = QStyle::State_Enabled;
pbStyle.textVisible = false; pbStyle.textVisible = false;
pbStyle.minimum = 0; pbStyle.minimum = 0;
pbStyle.maximum = 100; pbStyle.maximum = 100;
pbStyle.progress = progress; pbStyle.progress = progress;
pbStyle.invertedAppearance = false; pbStyle.invertedAppearance = false;
pbStyle.rect = QRect( pbLeft, pbTop, pbWidth, pbHeight ); pbStyle.rect = QRect( pbLeft, pbTop, pbWidth, pbHeight );
style()->drawControl( QStyle::CE_ProgressBar, &pbStyle, painter, this ); style()->drawControl( QStyle::CE_ProgressBar, &pbStyle, painter, this );
} }
if( !text.isEmpty() ) if( !text.isEmpty() )
{ {
QPen oldPen = painter->pen(); QPen oldPen = painter->pen();
QPen pen; QPen pen;
pen.setColor( Qt::white ); pen.setColor( Qt::white );
painter->setPen( pen ); painter->setPen( pen );
painter->drawText( textX, textY, text ); painter->drawText( textX, textY, text );
painter->setPen( oldPen ); painter->setPen( oldPen );
} }
} }

View file

@ -1,60 +1,60 @@
// Ryzom Core - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // Ryzom Core - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef SPLASH_SCREEN_H #ifndef SPLASH_SCREEN_H
#define SPLASH_SCREEN_H #define SPLASH_SCREEN_H
#include <QSplashScreen> #include <QSplashScreen>
class SplashScreen : public QSplashScreen class SplashScreen : public QSplashScreen
{ {
Q_OBJECT Q_OBJECT
public: public:
SplashScreen(); SplashScreen();
~SplashScreen(); ~SplashScreen();
void setPixmap( const QPixmap &pixmap ); void setPixmap( const QPixmap &pixmap );
void setText( const QString &text ); void setText( const QString &text );
void clearText(); void clearText();
void setTextXY( int x, int y ){ textX = x; textY = y; } void setTextXY( int x, int y ){ textX = x; textY = y; }
void setProgress( int percent ); void setProgress( int percent );
void advanceProgress( int percent ); void advanceProgress( int percent );
void setProgressBarEnabled( bool b ){ progressBarEnabled = b; } void setProgressBarEnabled( bool b ){ progressBarEnabled = b; }
void setProgressBarRect( int left, int top, int width, int height ){} void setProgressBarRect( int left, int top, int width, int height ){}
protected: protected:
void drawContents( QPainter *painter ); void drawContents( QPainter *painter );
private: private:
int progress; int progress;
int pbLeft; int pbLeft;
int pbTop; int pbTop;
int pbWidth; int pbWidth;
int pbHeight; int pbHeight;
QString text; QString text;
int textX; int textX;
int textY; int textY;
bool progressBarEnabled; bool progressBarEnabled;
}; };
#endif #endif