From 3fe1101f443bfec1ce3e0c6c1d70779cec213f01 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 27 Jul 2014 20:38:08 +0200 Subject: [PATCH] Implemented the GUI part of saving... --- .../tile_editor/tile_editor_main_window.cpp | 49 +++++++++++++++++++ .../tile_editor/tile_editor_main_window.h | 6 +++ .../plugins/tile_editor/tile_editor_plugin.h | 10 ++++ .../plugins/tile_editor/tilebank_saver.cpp | 37 ++++++++++++++ .../src/plugins/tile_editor/tilebank_saver.h | 38 ++++++++++++++ 5 files changed, 140 insertions(+) create mode 100644 code/studio/src/plugins/tile_editor/tilebank_saver.cpp create mode 100644 code/studio/src/plugins/tile_editor/tilebank_saver.h diff --git a/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp b/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp index e272faeee..75d2c31f4 100644 --- a/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp +++ b/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp @@ -32,6 +32,8 @@ #include "tile_item.h" #include "tile_item_delegate.h" +#include "tilebank_saver.h" + TileEditorMainWindow::TileEditorMainWindow(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::TileEditorMainWindow) @@ -142,6 +144,14 @@ TileEditorMainWindow::TileEditorMainWindow(QWidget *parent) connect(m_ui->actionZoom200, SIGNAL(triggered()), m_zoomSignalMapper, SLOT(map())); m_zoomSignalMapper->setMapping(m_ui->actionZoom200, 2); connect(m_zoomSignalMapper, SIGNAL(mapped(int)), this, SLOT(onZoomFactor(int))); + + QAction *saveAction = Core::ICore::instance()->menuManager()->action( Core::Constants::SAVE ); + saveAction->setEnabled( true ); + QAction *saveAsAction = Core::ICore::instance()->menuManager()->action( Core::Constants::SAVE_AS ); + saveAsAction->setEnabled( true ); + + connect( m_ui->actionSaveTileBank, SIGNAL( triggered() ), this, SLOT( save() ) ); + connect( m_ui->actionSaveTileBankAs, SIGNAL( triggered() ), this, SLOT( saveAs() ) ); } TileEditorMainWindow::~TileEditorMainWindow() @@ -161,6 +171,45 @@ TileEditorMainWindow::~TileEditorMainWindow() m_tileModels.clear(); } +void TileEditorMainWindow::save() +{ + saveAs(); +} + +void TileEditorMainWindow::saveAs() +{ + if( m_fileName.isEmpty() ) + { + m_fileName = QFileDialog::getSaveFileName( this, + tr( "Save TileBank as..." ), + "", + tr( "TileBank files (*.tilebank)" ) ); + + if( m_fileName.isEmpty() ) + return; + + } + + QList< QString > landNames; + + int c = m_ui->landLW->count(); + for( int i = 0; i < c; i++ ) + { + QListWidgetItem *item = m_ui->landLW->item( i ); + landNames.push_back( item->text() ); + } + + TileBankSaver saver; + bool ok = saver.save( m_fileName.toUtf8().constData(), m_tileModels, landNames ); + + if( !ok ) + { + QMessageBox::critical( this, + tr( "Saving tilebank" ), + tr( "Failed to save tilebank :(" ) ); + } +} + void TileEditorMainWindow::onZoomFactor(int level) { int tile128Scaled=TileModel::TILE_128_BASE_SIZE; diff --git a/code/studio/src/plugins/tile_editor/tile_editor_main_window.h b/code/studio/src/plugins/tile_editor/tile_editor_main_window.h index 14cb7cf75..c1fb662b0 100644 --- a/code/studio/src/plugins/tile_editor/tile_editor_main_window.h +++ b/code/studio/src/plugins/tile_editor/tile_editor_main_window.h @@ -42,6 +42,10 @@ public: QUndoStack *getUndoStack() { return m_undoStack; } +public Q_SLOTS: + void save(); + void saveAs(); + private Q_SLOTS: void onActionAddTile(bool triggered); void onActionDeleteTile(bool triggered); @@ -102,6 +106,8 @@ private: TAB_DISPLACEMENT = 3, TAB_DETAILS = 4 }; + + QString m_fileName; }; #endif // TILE_EDITOR_MAIN_WINDOW_H diff --git a/code/studio/src/plugins/tile_editor/tile_editor_plugin.h b/code/studio/src/plugins/tile_editor/tile_editor_plugin.h index cb7be7fc1..024e6a6e2 100644 --- a/code/studio/src/plugins/tile_editor/tile_editor_plugin.h +++ b/code/studio/src/plugins/tile_editor/tile_editor_plugin.h @@ -95,6 +95,16 @@ public: { } + void save() + { + m_tileEditorMainWindow->save(); + } + + void saveAs() + { + m_tileEditorMainWindow->saveAs(); + } + virtual QWidget *widget() { return m_tileEditorMainWindow; diff --git a/code/studio/src/plugins/tile_editor/tilebank_saver.cpp b/code/studio/src/plugins/tile_editor/tilebank_saver.cpp new file mode 100644 index 000000000..d149648ff --- /dev/null +++ b/code/studio/src/plugins/tile_editor/tilebank_saver.cpp @@ -0,0 +1,37 @@ +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "tilebank_saver.h" +#include "tile_model.h" + +#include "nel/3d/tile_bank.h" + +TileBankSaver::TileBankSaver() +{ +} + +TileBankSaver::~TileBankSaver() +{ +} + +bool TileBankSaver::save( const char *fileName, const QList< TileModel* > &models, const QList< QString > &lands ) +{ + NL3D::CTileBank bank; + + return false; +} + diff --git a/code/studio/src/plugins/tile_editor/tilebank_saver.h b/code/studio/src/plugins/tile_editor/tilebank_saver.h new file mode 100644 index 000000000..80fb119d8 --- /dev/null +++ b/code/studio/src/plugins/tile_editor/tilebank_saver.h @@ -0,0 +1,38 @@ +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef TILEBANK_SAVER_H +#define TILEBANK_SAVER_H + +#include +#include + +class TileModel; + +class TileBankSaver +{ +public: + TileBankSaver(); + ~TileBankSaver(); + + bool save( const char *filename, const QList< TileModel* > &models, const QList< QString > &lands ); + +private: +}; + +#endif +