mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-27 01:06:19 +00:00
EOL
This commit is contained in:
parent
2abbd37304
commit
36f77a2ab0
14 changed files with 1799 additions and 1799 deletions
|
@ -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)
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef LAND_EDIT_DLG_H
|
||||
#define LAND_EDIT_DLG_H
|
||||
|
||||
|
||||
#include "ui_land_edit_dialog.h"
|
||||
#include <QStringList>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef LAND_EDIT_DLG_H
|
||||
#define LAND_EDIT_DLG_H
|
||||
|
||||
|
||||
#include "ui_land_edit_dialog.h"
|
||||
#include <QStringList>
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<plugin-spec>
|
||||
<library-name>studio_plugin_tile_editor</library-name>
|
||||
<name>TileEditor</name>
|
||||
<version>1.0</version>
|
||||
<vendor>Ryzom Core</vendor>
|
||||
<description>Tile bank editing plugin.</description>
|
||||
<dependencies>
|
||||
<dependency plugin-name="Core" version="0.8"/>
|
||||
</dependencies>
|
||||
<plugin-spec>
|
||||
<library-name>studio_plugin_tile_editor</library-name>
|
||||
<name>TileEditor</name>
|
||||
<version>1.0</version>
|
||||
<vendor>Ryzom Core</vendor>
|
||||
<description>Tile bank editing plugin.</description>
|
||||
<dependencies>
|
||||
<dependency plugin-name="Core" version="0.8"/>
|
||||
</dependencies>
|
||||
</plugin-spec>
|
File diff suppressed because it is too large
Load diff
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef TILE_BANK_H
|
||||
#define TILE_BANK_H
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QVariant>
|
||||
#include <QList>
|
||||
|
||||
#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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef TILE_BANK_H
|
||||
#define TILE_BANK_H
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QVariant>
|
||||
#include <QList>
|
||||
|
||||
#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
|
||||
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#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
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef TILE_IMAGES_H
|
||||
#define TILE_IMAGES_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef TILE_IMAGES_H
|
||||
#define TILE_IMAGES_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
struct TileImages
|
||||
{
|
||||
QString diffuse;
|
||||
QString additive;
|
||||
QString alpha;
|
||||
|
||||
void clear()
|
||||
{
|
||||
diffuse.clear();
|
||||
additive.clear();
|
||||
alpha.clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,122 +1,122 @@
|
|||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
#include <nel/misc/debug.h>
|
||||
|
||||
#include "tile_item_delegate.h"
|
||||
|
||||
#include "tile_model.h"
|
||||
|
||||
TileItemDelegate::TileItemDelegate()
|
||||
{
|
||||
m_zoomFactor = ZoomNormal;
|
||||
m_imageHint = 128;
|
||||
}
|
||||
|
||||
TileItemDelegate::~TileItemDelegate()
|
||||
{
|
||||
}
|
||||
|
||||
void TileItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QStyledItemDelegate::paint(painter,option,index);
|
||||
|
||||
painter->save();
|
||||
|
||||
QFont font = QApplication::font();
|
||||
|
||||
//font.setBold(true);
|
||||
//SubFont.setWeight(SubFont.weight()-2);
|
||||
QFontMetrics fm(font);
|
||||
|
||||
QPixmap tile = qvariant_cast<QPixmap>(index.data(TileModel::TilePixmapRole));
|
||||
QString tileFileText = qvariant_cast<QString>(index.data(TileModel::TileFilenameRole));
|
||||
QString tileIdText = qvariant_cast<QString>(index.data(TileModel::TileIndexRole));
|
||||
|
||||
QSize tileSize = tile.size();
|
||||
|
||||
//QRect headerRect = option.rect;
|
||||
QRect rect(option.rect);
|
||||
//QRect tileRect(option.rect);
|
||||
int textHeight = fm.height();
|
||||
int iconPosModX = PIXMAP_MARGIN + (tile.width() / 2);
|
||||
int iconPosModY = (option.rect.height() - tile.height()) / 2;
|
||||
|
||||
painter->drawPixmap(rect.adjusted(iconPosModX, iconPosModY, iconPosModX, iconPosModY).topLeft(), tile);
|
||||
|
||||
|
||||
|
||||
//tileRect.setRight(tileSize.width()+30);
|
||||
//tileRect.setTop(tileRect.top()+5);
|
||||
//headerRect.setLeft(tileRect.right());
|
||||
//subheaderRect.setLeft(tileRect.right());
|
||||
//headerRect.setTop(headerRect.top()+5);
|
||||
//headerRect.setBottom(headerRect.top()+fm.height());
|
||||
|
||||
//subheaderRect.setTop(headerRect.bottom()+2);
|
||||
|
||||
//painter->drawPixmap(targetrect, pixmap, sourcerect)
|
||||
|
||||
//painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height()));
|
||||
//painter->drawPixmap(QPoint(tileRect.left()+tileSize.width()/2+2,tileRect.top()+tileSize.height()/2+3),tile);
|
||||
|
||||
//painter->setFont(font);
|
||||
//painter->drawText(headerRect,headerText);
|
||||
|
||||
|
||||
//painter->setFont(SubFont);
|
||||
//painter->drawText(subheaderRect.left(),subheaderRect.top()+17,subText);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QSize TileItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const
|
||||
{
|
||||
QPixmap tile = qvariant_cast<QPixmap>(index.data(TileModel::TilePixmapRole));
|
||||
QSize tileSize = tile.size();
|
||||
QFont font = QApplication::font();
|
||||
QFontMetrics fm(font);
|
||||
|
||||
return(QSize(tileSize.width()+(2*PIXMAP_MARGIN), tileSize.height()+fm.height()+(2*PIXMAP_MARGIN)));
|
||||
}
|
||||
|
||||
TileItemDelegate::TZoomFactor TileItemDelegate::getZoomFactor()
|
||||
{
|
||||
return m_zoomFactor;
|
||||
}
|
||||
|
||||
void TileItemDelegate::setZoomFactor(TileItemDelegate::TZoomFactor zoomFactor)
|
||||
{
|
||||
m_zoomFactor = zoomFactor;
|
||||
}
|
||||
|
||||
// SLOTS
|
||||
|
||||
void TileItemDelegate::currentTab(int index)
|
||||
{
|
||||
if(index == 1)
|
||||
{
|
||||
nlinfo("switching delegate to 1 or 256");
|
||||
m_imageHint = 256;
|
||||
}
|
||||
else
|
||||
{
|
||||
nlinfo("switching delegate to 0,2,3 or 128");
|
||||
m_imageHint = 128;
|
||||
}
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
#include <nel/misc/debug.h>
|
||||
|
||||
#include "tile_item_delegate.h"
|
||||
|
||||
#include "tile_model.h"
|
||||
|
||||
TileItemDelegate::TileItemDelegate()
|
||||
{
|
||||
m_zoomFactor = ZoomNormal;
|
||||
m_imageHint = 128;
|
||||
}
|
||||
|
||||
TileItemDelegate::~TileItemDelegate()
|
||||
{
|
||||
}
|
||||
|
||||
void TileItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QStyledItemDelegate::paint(painter,option,index);
|
||||
|
||||
painter->save();
|
||||
|
||||
QFont font = QApplication::font();
|
||||
|
||||
//font.setBold(true);
|
||||
//SubFont.setWeight(SubFont.weight()-2);
|
||||
QFontMetrics fm(font);
|
||||
|
||||
QPixmap tile = qvariant_cast<QPixmap>(index.data(TileModel::TilePixmapRole));
|
||||
QString tileFileText = qvariant_cast<QString>(index.data(TileModel::TileFilenameRole));
|
||||
QString tileIdText = qvariant_cast<QString>(index.data(TileModel::TileIndexRole));
|
||||
|
||||
QSize tileSize = tile.size();
|
||||
|
||||
//QRect headerRect = option.rect;
|
||||
QRect rect(option.rect);
|
||||
//QRect tileRect(option.rect);
|
||||
int textHeight = fm.height();
|
||||
int iconPosModX = PIXMAP_MARGIN + (tile.width() / 2);
|
||||
int iconPosModY = (option.rect.height() - tile.height()) / 2;
|
||||
|
||||
painter->drawPixmap(rect.adjusted(iconPosModX, iconPosModY, iconPosModX, iconPosModY).topLeft(), tile);
|
||||
|
||||
|
||||
|
||||
//tileRect.setRight(tileSize.width()+30);
|
||||
//tileRect.setTop(tileRect.top()+5);
|
||||
//headerRect.setLeft(tileRect.right());
|
||||
//subheaderRect.setLeft(tileRect.right());
|
||||
//headerRect.setTop(headerRect.top()+5);
|
||||
//headerRect.setBottom(headerRect.top()+fm.height());
|
||||
|
||||
//subheaderRect.setTop(headerRect.bottom()+2);
|
||||
|
||||
//painter->drawPixmap(targetrect, pixmap, sourcerect)
|
||||
|
||||
//painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height()));
|
||||
//painter->drawPixmap(QPoint(tileRect.left()+tileSize.width()/2+2,tileRect.top()+tileSize.height()/2+3),tile);
|
||||
|
||||
//painter->setFont(font);
|
||||
//painter->drawText(headerRect,headerText);
|
||||
|
||||
|
||||
//painter->setFont(SubFont);
|
||||
//painter->drawText(subheaderRect.left(),subheaderRect.top()+17,subText);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QSize TileItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const
|
||||
{
|
||||
QPixmap tile = qvariant_cast<QPixmap>(index.data(TileModel::TilePixmapRole));
|
||||
QSize tileSize = tile.size();
|
||||
QFont font = QApplication::font();
|
||||
QFontMetrics fm(font);
|
||||
|
||||
return(QSize(tileSize.width()+(2*PIXMAP_MARGIN), tileSize.height()+fm.height()+(2*PIXMAP_MARGIN)));
|
||||
}
|
||||
|
||||
TileItemDelegate::TZoomFactor TileItemDelegate::getZoomFactor()
|
||||
{
|
||||
return m_zoomFactor;
|
||||
}
|
||||
|
||||
void TileItemDelegate::setZoomFactor(TileItemDelegate::TZoomFactor zoomFactor)
|
||||
{
|
||||
m_zoomFactor = zoomFactor;
|
||||
}
|
||||
|
||||
// SLOTS
|
||||
|
||||
void TileItemDelegate::currentTab(int index)
|
||||
{
|
||||
if(index == 1)
|
||||
{
|
||||
nlinfo("switching delegate to 1 or 256");
|
||||
m_imageHint = 256;
|
||||
}
|
||||
else
|
||||
{
|
||||
nlinfo("switching delegate to 0,2,3 or 128");
|
||||
m_imageHint = 128;
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef TILEBANK_LOADER_H
|
||||
#define TILEBANK_LOADER_H
|
||||
|
||||
class TileModel;
|
||||
|
||||
class TileBankLoader
|
||||
{
|
||||
public:
|
||||
TileBankLoader();
|
||||
~TileBankLoader();
|
||||
|
||||
bool load( const char *filename, TileModel *model );
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef TILEBANK_SAVER_H
|
||||
#define TILEBANK_SAVER_H
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef TILEBANK_SAVER_H
|
||||
#define TILEBANK_SAVER_H
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
class TileModel;
|
||||
|
||||
class TileBankSaver
|
||||
{
|
||||
public:
|
||||
TileBankSaver();
|
||||
~TileBankSaver();
|
||||
|
||||
bool save( const char *filename, TileModel* model );
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "translation_manager_constants.h"
|
||||
#include "uxt_editor.h"
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <QFormLayout>
|
||||
#include <QCloseEvent>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QMenu>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "translation_manager_constants.h"
|
||||
#include "uxt_editor.h"
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <QFormLayout>
|
||||
#include <QCloseEvent>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QMenu>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue