From a4f222c6511c8aff6ed0172126e86e9108ef37f8 Mon Sep 17 00:00:00 2001 From: cemycc Date: Tue, 5 Jul 2011 05:01:13 +0300 Subject: [PATCH] Changed: #1307 Added extraction words options for: item, creature, sbrick, sphrase --HG-- branch : gsoc2011-translationovqt --- .../translation_manager/CMakeLists.txt | 4 +- .../translation_manager/editor_worksheet.cpp | 108 +++- .../translation_manager/editor_worksheet.h | 21 +- .../translation_manager/extract_bot_names.cpp | 467 +-------------- .../translation_manager/extract_bot_names.h | 111 ++++ .../extract_new_sheet_names.cpp | 154 +++++ .../extract_new_sheet_names.h | 70 +++ .../translation_manager_editor.h | 16 + .../translation_manager_main_window.cpp | 190 +++++-- .../translation_manager_main_window.h | 24 +- .../translation_manager_plugin.cpp | 17 + .../translation_manager_plugin.h | 17 + .../translation_manager_settings_page.cpp | 120 +--- .../translation_manager_settings_page.h | 11 +- .../translation_manager_settings_page.ui | 531 ++++++------------ 15 files changed, 834 insertions(+), 1027 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/CMakeLists.txt index edc0a60e5..56195d6e0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/CMakeLists.txt @@ -13,7 +13,9 @@ SET(OVQT_PLUG_TRANSLATION_MANAGER_HDR translation_manager_plugin.h translation_manager_main_window.h translation_manager_settings_page.h translation_manager_editor.h - editor_worksheet.h) + editor_worksheet.h + extract_new_sheet_names.h + extract_bot_names.h) SET(OVQT_PLUG_TRANSLATION_MANAGER_UIS translation_manager_settings_page.ui translation_manager_main_window.ui) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.cpp index ee32e3979..d19d28723 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.cpp @@ -1,6 +1,6 @@ -// Object Viewer Qt - MMORPG Framework +// Translation Manager Plugin - OVQT Plugin // Copyright (C) 2010 Winch Gate Property Limited -// Copyright (C) 2011 Dzmitry Kamiahin +// Copyright (C) 2011 Emanuel Costea // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -24,21 +24,9 @@ #include #include -using namespace std; - -struct TEntryInfo -{ - string SheetName; -}; +#include "extract_bot_names.h" -set getGenericNames(); -void cleanGenericNames(); -map getSimpleNames(); -void cleanSimpleNames(); -void setPathsForPrimitives(map > config_paths, string ligo_class_file); -void extractBotNamesFromPrimitives(); -string cleanupName(const std::string &name); -ucstring cleanupUcName(const ucstring &name); +using namespace std; namespace Plugin { @@ -251,12 +239,15 @@ void CEditorWorksheet::worksheetEditorChanged(int row, int column) } -void CEditorWorksheet::extractBotNames() +void CEditorWorksheet::extractBotNames(list filters, string level_design_path, NLLIGO::CLigoConfig ligoConfig) { bool modified = false; -// get SimpleNames + ExtractBotNames ebn; + ebn.setRequiredSettings(filters, level_design_path); + ebn.extractBotNamesFromPrimitives(ligoConfig); + // get SimpleNames { - map SimpleNames = getSimpleNames(); + map SimpleNames = ebn.getSimpleNames(); map::iterator it(SimpleNames.begin()), last(SimpleNames.end()); for (; it != last; ++it) @@ -281,15 +272,15 @@ void CEditorWorksheet::extractBotNames() if(!modified) modified = true; } } - cleanSimpleNames(); + ebn.cleanSimpleNames(); } // get GenericNames { - set GenericNames = getGenericNames(); + set GenericNames = ebn.getGenericNames(); set::iterator it(GenericNames.begin()), last(GenericNames.end()); for (; it != last; ++it) { - string gnName = "gn_" + cleanupName(*it); + string gnName = "gn_" + ebn.cleanupName(*it); QList search_results = table_editor->findItems(tr((*it).c_str()), Qt::MatchExactly); if(search_results.size() == 0) { @@ -310,7 +301,7 @@ void CEditorWorksheet::extractBotNames() if(!modified) modified = true; } } - cleanGenericNames(); + ebn.cleanGenericNames(); } if(modified) { @@ -319,6 +310,77 @@ void CEditorWorksheet::extractBotNames() } +void CEditorWorksheet::extractWords(QString filename, QString columnId, IWordListBuilder& wordListBuilder) +{ + uint i; + + // **** Load the excel sheet + // load + TWorksheet workSheet; + if(!loadExcelSheet(filename.toStdString(), workSheet, true)) + { + nlwarning("Error reading '%s'. Aborted", filename.toStdString().c_str()); + return; + } + // get the key column index + uint keyColIndex = 0; + if(!workSheet.findCol(columnId.toStdString(), keyColIndex)) + { + nlwarning("Error: Don't find the column '%s'. '%s' Aborted", columnId.toStdString().c_str(), filename.toStdString().c_str()); + return; + } + // get the name column index + uint nameColIndex; + if(!workSheet.findCol(ucstring("name"), nameColIndex)) + { + nlwarning("Error: Don't find the column 'name'. '%s' Aborted", filename.toStdString().c_str()); + return; + } + + // **** List all words with the builder given + std::vector allWords; + if(!wordListBuilder.buildWordList(allWords, filename.toStdString())) + { + return; + } + bool modified = false; + for(i = 0; i < allWords.size(); i++) + { + string keyName = allWords[i]; + QList search_results = table_editor->findItems(tr(keyName.c_str()), Qt::MatchExactly); + if(search_results.size() == 0) + { + + int knPos = 0, nPos = 0; + if(workSheet.getData(0, 0) == ucstring("*HASH_VALUE")) + { + knPos = keyColIndex - 1; + nPos = nameColIndex - 1; + } else { + knPos = keyColIndex; + nPos = nameColIndex; + } + const int currentRow = table_editor->rowCount(); + table_editor->setRowCount(currentRow + 1); + // keyName row + QTableWidgetItem *key_name_row = new QTableWidgetItem(); + key_name_row->setText(tr(keyName.c_str())); + key_name_row->setBackgroundColor(QColor("#F75D59")); + table_editor ->setItem(currentRow, knPos, key_name_row); + // nameColumn key + QTableWidgetItem *name_row = new QTableWidgetItem(); + name_row->setText(QString("") + tr(keyName.c_str())); + name_row->setBackgroundColor(QColor("#F75D59")); + table_editor ->setItem(currentRow, nPos, name_row); + if(!modified) modified = true; + } + } + if(modified) + { + setWindowModified(true); + } +} + void CEditorWorksheet::setCurrentFile(QString filename) { QFileInfo *file = new QFileInfo(filename); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.h index 71e86af84..497e23913 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/editor_worksheet.h @@ -1,3 +1,19 @@ +// Translation Manager Plugin - OVQT Plugin +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Emanuel Costea +// +// 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 EDITOR_WORKSHEET_H #define EDITOR_WORKSHEET_H @@ -7,6 +23,7 @@ #include "nel/misc/sheet_id.h" #include "nel/misc/path.h" #include "nel/misc/diff_tool.h" +#include "nel/ligo/ligo_config.h" // Qt includes #include @@ -16,6 +33,7 @@ #include #include "translation_manager_editor.h" +#include "extract_new_sheet_names.h" namespace Plugin { @@ -31,7 +49,8 @@ public: void save(); void saveAs(QString filename); void activateWindow(); - void extractBotNames(); + void extractBotNames(list filters, string level_design_path, NLLIGO::CLigoConfig ligoConfig); + void extractWords(QString filename, QString columnId, IWordListBuilder &wordListBuilder); bool isBotNamesTable(); void closeEvent(QCloseEvent *event); private Q_SLOTS: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.cpp index 66d7d1c69..4de3d889d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.cpp @@ -1,5 +1,6 @@ -// Ryzom - MMORPG Framework +// Translation Manager Plugin - OVQT Plugin // Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Emanuel Costea // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -14,67 +15,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "nel/misc/types_nl.h" -#include "nel/misc/config_file.h" -#include "nel/misc/sheet_id.h" -#include "nel/misc/path.h" -#include "nel/misc/diff_tool.h" -#include "nel/georges/u_form.h" -#include "nel/georges/u_form_elm.h" -#include "nel/georges/load_form.h" -#include "nel/ligo/ligo_config.h" -#include "nel/ligo/primitive.h" -#include "nel/ligo/primitive_utils.h" - -using namespace std; -using namespace NLMISC; -using namespace NLLIGO; -using namespace STRING_MANAGER; - -vector Filters; - -static CLigoConfig LigoConfig; -static bool RemoveOlds = false; - - -struct TCreatureInfo -{ - CSheetId SheetId; - bool ForceSheetName; - bool DisplayName; +#include "extract_bot_names.h" - void readGeorges (const NLMISC::CSmartPtr &form, const NLMISC::CSheetId &sheetId) - { - const NLGEORGES::UFormElm &item=form->getRootNode(); - - SheetId=sheetId; - item.getValueByName(ForceSheetName, "3d data.ForceDisplayCreatureName"); - item.getValueByName(DisplayName, "3d data.DisplayName"); - } - - void serial(NLMISC::IStream &f) - { - f.serial(SheetId); - f.serial(ForceSheetName); - f.serial(DisplayName); - } +static bool RemoveOlds = false; - static uint getVersion () - { - return 1; - } - void removed() - { - } - -}; -std::map Creatures; +namespace Plugin +{ -TCreatureInfo *getCreature(const std::string &sheetName) +TCreatureInfo *ExtractBotNames::getCreature(const std::string &sheetName) { CSheetId id(sheetName+".creature"); @@ -84,7 +36,7 @@ TCreatureInfo *getCreature(const std::string &sheetName) return NULL; } -string cleanupName(const std::string &name) +string ExtractBotNames::cleanupName(const std::string &name) { string ret; @@ -99,7 +51,7 @@ string cleanupName(const std::string &name) return ret; } -ucstring cleanupUcName(const ucstring &name) +ucstring ExtractBotNames::cleanupUcName(const ucstring &name) { ucstring ret; @@ -118,7 +70,7 @@ ucstring cleanupUcName(const ucstring &name) /* Removes first and last '$' */ -ucstring makeGroupName(const ucstring & translationName) +ucstring ExtractBotNames::makeGroupName(const ucstring & translationName) { ucstring ret = translationName; if (ret.size() >= 2) @@ -136,36 +88,31 @@ ucstring makeGroupName(const ucstring & translationName) return ret; } -struct TEntryInfo -{ - string SheetName; -}; -set GenericNames; -map SimpleNames; -set Functions; -set getGenericNames() + + +set ExtractBotNames::getGenericNames() { return GenericNames; } -map getSimpleNames() +map ExtractBotNames::getSimpleNames() { return SimpleNames; } -void cleanSimpleNames() +void ExtractBotNames::cleanSimpleNames() { SimpleNames.clear(); } -void cleanGenericNames() +void ExtractBotNames::cleanGenericNames() { GenericNames.clear(); } -string removeAndStoreFunction(const std::string &fullName) +string ExtractBotNames::removeAndStoreFunction(const std::string &fullName) { string::size_type pos = fullName.find("$"); if (pos == string::npos) @@ -193,7 +140,7 @@ string removeAndStoreFunction(const std::string &fullName) } -void addGenericName(const std::string &name, const std::string &sheetName) +void ExtractBotNames::addGenericName(const std::string &name, const std::string &sheetName) { TCreatureInfo *c = getCreature(sheetName); if (!c || c->ForceSheetName || !c->DisplayName) @@ -213,7 +160,7 @@ void addGenericName(const std::string &name, const std::string &sheetName) } } -void addSimpleName(const std::string &name, const std::string &sheetName) +void ExtractBotNames::addSimpleName(const std::string &name, const std::string &sheetName) { TCreatureInfo *c = getCreature(sheetName); if (!c || c->ForceSheetName || !c->DisplayName) @@ -238,18 +185,9 @@ void addSimpleName(const std::string &name, const std::string &sheetName) } } -void setPathsForPrimitives(map > config_paths, string ligo_class_file) +void ExtractBotNames::setRequiredSettings(list filters, string level_design_path) { - for (std::list::iterator it = config_paths["paths"].begin(); it != config_paths["paths"].end(); ++it) - { - CPath::addSearchPath(*it, true, false); - } - for (std::list::iterator it = config_paths["pathsR"].begin(); it != config_paths["pathsR"].end(); ++it) - { - CPath::addSearchPath(*it, false, false); - } - - for (std::list::iterator it = config_paths["filters"].begin(); it != config_paths["filters"].end(); ++it) + for (std::list::iterator it = filters.begin(); it != filters.end(); ++it) { Filters.push_back(*it); } @@ -262,35 +200,28 @@ void setPathsForPrimitives(map > config_paths, string ligo_c if (Creatures.empty()) { - for (std::list::iterator it = config_paths["georges"].begin(); it != config_paths["georges"].end(); ++it) - CPath::addSearchPath((*it).c_str(), true, false); - - loadForm("creature", PACKED_SHEETS_NAME, Creatures, true); + loadForm("creature", PACKED_SHEETS_NAME, Creatures, true); } - - - //------------------------------------------------------------------- - // init ligo config - string ligoPath = CPath::lookup(ligo_class_file, true, true); - LigoConfig.readPrimitiveClass(ligoPath.c_str(), false); - NLLIGO::Register(); - - CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig; + } -void extractBotNamesFromPrimitives() +void ExtractBotNames::extractBotNamesFromPrimitives(CLigoConfig ligoConfig) { + //------------------------------------------------------------------- // ok, ready for the real work, // first, read the primitives files and parse the primitives vector files; CPath::getFileList("primitive", files); + for (uint i=0; i > config_paths, string ligo_class_file, string trans_path, string work_path) -{ - - /* - //------------------------------------------------------------------- - // step 2 : load the reference file - - nlinfo("Looking for missing translation:"); - - string work_path_file = work_path + "/bot_names.txt"; - string trans_path_file = trans_path + "/bot_names.txt"; - string title_path_file = work_path + "/title_words_wk.txt"; - - TWorksheet botNames; - if (!CFile::fileExists(work_path_file) || !loadExcelSheet(work_path_file, botNames)) - { - botNames.resize(botNames.size() + 1); - botNames.insertColumn(botNames.ColCount); - botNames.setData(0,botNames.ColCount - 1,ucstring("bot name")); - botNames.insertColumn(botNames.ColCount); - botNames.setData(0,botNames.ColCount - 1,ucstring("translated name")); - botNames.insertColumn(botNames.ColCount); - botNames.setData(0,botNames.ColCount - 1,ucstring("sheet_name")); - } - - TWorksheet transBotNames; - if (!CFile::fileExists(trans_path_file) || !loadExcelSheet(trans_path_file, transBotNames)) - { - transBotNames.resize(transBotNames.size() + 1); - transBotNames.insertColumn(transBotNames.ColCount); - transBotNames.setData(0,transBotNames.ColCount - 1,ucstring("*HASH_VALUE")); - transBotNames.insertColumn(transBotNames.ColCount); - transBotNames.setData(0,transBotNames.ColCount - 1,ucstring("bot name")); - transBotNames.insertColumn(transBotNames.ColCount); - transBotNames.setData(0,transBotNames.ColCount - 1,ucstring("translated name")); - transBotNames.insertColumn(transBotNames.ColCount); - transBotNames.setData(0,transBotNames.ColCount - 1,ucstring("sheet_name")); - } - - TWorksheet fcts; - if (!CFile::fileExists(title_path_file) || !loadExcelSheet(title_path_file, fcts)) - { - fcts.resize(fcts.size() + 1); - fcts.insertColumn(fcts.ColCount); - fcts.setData(0,fcts.ColCount - 1,ucstring("title_id")); - fcts.insertColumn(fcts.ColCount); - fcts.setData(0,fcts.ColCount - 1,ucstring("name")); - fcts.insertColumn(fcts.ColCount); - fcts.setData(0,fcts.ColCount - 1,ucstring("women_name")); - } - - loadExcelSheet(work_path_file, botNames, true); - loadExcelSheet(trans_path_file, transBotNames, true); - loadExcelSheet(title_path_file, fcts, true); - - // add missing element - - uint nbAddSimpleName = 0; - uint nbAddFunction = 0; - uint nbAddGenericName = 0; - - uint botIdCol; - nlverify(botNames.findId(botIdCol)); - uint transIdCol; - nlverify(transBotNames.findId(transIdCol)); - uint fctsIdCol; - nlverify(fcts.findId(fctsIdCol)); - - // special treatment to add the sheet_name col - { - uint sheetCol; - if (!botNames.findCol(ucstring("sheet_name"), sheetCol)) - { - botNames.insertColumn(botNames.ColCount); - botNames.setData(0, botNames.ColCount-1, ucstring("sheet_name")); - } - - if (!transBotNames.findCol(ucstring("sheet_name"), sheetCol)) - { - transBotNames.insertColumn(transBotNames.ColCount); - transBotNames.setData(0, transBotNames.ColCount-1, ucstring("sheet_name")); - } - } - // 1 - simple names - { - nlinfo(" Simple names..."); - - - map::iterator first(SimpleNames.begin()), last(SimpleNames.end()); - for (; first != last; ++first) - { - uint rowIdx; - if (!botNames.findRow(botIdCol, first->first, rowIdx)) - { - // we need to add the entry - rowIdx = botNames.size(); - botNames.resize(botNames.size()+1); - - botNames.setData(rowIdx, ucstring("bot name"), first->first); - botNames.setData(rowIdx, ucstring("translated name"), first->first); - botNames.setData(rowIdx, ucstring("sheet_name"), first->second.SheetName); - - nbAddSimpleName++; - } - else - { - // set/update the sheet name info - // try to restore the existing translation - uint transRowIdx; - if (transBotNames.findRow(transIdCol, first->first, transRowIdx)) - { - ucstring wkBotName = botNames.getData(rowIdx, ucstring("bot name")); - ucstring wkSheetName = botNames.getData(rowIdx, ucstring("sheet_name")); - ucstring wkTranslationName = botNames.getData(rowIdx, ucstring("translated name")); - ucstring ucWkHash; - uint64 hash = CI18N::makeHash(wkBotName + wkTranslationName +wkSheetName); - CI18N::hashToUCString(hash, ucWkHash); - ucstring trUcHash = transBotNames[transRowIdx][0]; - bool isWkTranslationNameAGroupName = wkTranslationName.find(ucstring("$")) != ucstring::npos; - bool hashIsValide = std::equal(ucWkHash.begin(), ucWkHash.end(), trUcHash.begin()+1); - // Hash is equal get the translation - if (hashIsValide && !isWkTranslationNameAGroupName) - { - wkTranslationName = transBotNames.getData(transRowIdx, ucstring("translated name")); - wkSheetName = transBotNames.getData(transRowIdx, ucstring("sheet_name")); - botNames.setData(rowIdx, ucstring("translated name"), wkTranslationName); - botNames.setData(rowIdx, ucstring("sheet_name"), wkSheetName); - hash = CI18N::makeHash(wkBotName + wkTranslationName + wkSheetName); - // update the hash code - CI18N::hashToUCString(hash, transBotNames[transRowIdx][0]); - } - // bots_name.txt has been manually changed. We trust what the Level Designer has done. We don't destroy is work. - // or it is a simple - else - { - //use the "translated name" of the manually changed work/bot_name.txt - botNames.setData(rowIdx, ucstring("translated name"), wkTranslationName); - botNames.setData(rowIdx, ucstring("sheet_name"), wkSheetName); - } - } - } - } - } - - // 2 - generic names - - { - nlinfo(" Generic names..."); - - set::iterator first(GenericNames.begin()), last(GenericNames.end()); - for (; first != last; ++first) - { - string gnName = "gn_" + cleanupName(*first); - - ucstring fctsTitleId; - ucstring fctsName; - // add or modify the bot names - uint rowIdx; - if (!botNames.findRow(botIdCol, *first, rowIdx)) - { - // we need to add the entry - rowIdx = botNames.size(); - botNames.resize(botNames.size()+1); - - botNames.setData(rowIdx, ucstring("bot name"), *first); - botNames.setData(rowIdx, ucstring("translated name"), ucstring("$") + gnName + "$"); - botNames.setData(rowIdx, ucstring("sheet_name"), ucstring()); - fctsTitleId = gnName; - fctsName = *first; - - nbAddSimpleName++; - } - else - { - // look in the translated table to remember the translated name to write it in the string file - ucstring wkBotName = botNames.getData(rowIdx, ucstring("bot name")); - ucstring wkTranslationName = botNames.getData(rowIdx, ucstring("translated name")); - ucstring wkSheetName = botNames.getData(rowIdx, ucstring("sheet_name")); - - - nlinfo("Bot name:%s\n",wkBotName.toString().c_str()); - bool isWkTranslationNameAGroupName = wkTranslationName.find(ucstring("$")) != ucstring::npos; - - if ( isWkTranslationNameAGroupName ) //work name looks like "$gn_***$: do not modify - { - - //Do not change work/bot_name.txt - // update work/world_title.txt - - ucstring transName; - fctsTitleId = makeGroupName(wkTranslationName); - uint transRowIdx; - if (transBotNames.findRow(transIdCol, *first, transRowIdx)) - { - transName = transBotNames.getData(transRowIdx, ucstring("translated name")); - - if (transName.find(ucstring("$")) != ucstring::npos) - { - transName = fctsTitleId; - } - } - else - { - transName = fctsTitleId; - } - //Do not touch anything - botNames.setData(rowIdx, ucstring("translated name"), wkTranslationName); - botNames.setData(rowIdx, ucstring("sheet_name"), wkSheetName); - // fctsTitleId = makeGroupName(wkTranslationName); - fctsName = transName; - - } - else // WkTranslationName != "$gn*$" - { - uint transRowIdx; - ucstring transName; - ucstring wkSheetName; - // Get the translation as a simple name. - if (transBotNames.findRow(transIdCol, *first, transRowIdx)) - { - - transName = transBotNames.getData(transRowIdx, ucstring("translated name")); - ucstring trSheetName = transBotNames.getData(transRowIdx, ucstring("sheet_name")); - - //tr."translation name" is - if (transName.find(ucstring("$")) != ucstring::npos) - { - //get Translation, update hash - botNames[rowIdx][1] = transName; - botNames[rowIdx][2] = trSheetName; - fctsTitleId = makeGroupName(transName); - fctsName = makeGroupName(transName); - ucstring trNewUcHash; - uint64 hash = CI18N::makeHash(wkBotName + transName +trSheetName); - CI18N::hashToUCString(hash, trNewUcHash); - transBotNames[transRowIdx][0] = ucstring("_") + trNewUcHash; - } - else //botNames."translated name" != $gn_$ && tansName."translated name" != $gn_$ - { - - // get the translation back - //update work/bot_name.txt - wkTranslationName = ucstring("$")+gnName+"$"; - botNames[rowIdx][0] = wkBotName; - botNames[rowIdx][1] = wkTranslationName; - botNames[rowIdx][2] = wkSheetName; - - //update translated/bot_name.txt - - fctsName = transName; //transName - fctsTitleId = gnName; - ucstring trNewUcHash; - uint64 hash = CI18N::makeHash(botNames[rowIdx][0] + botNames[rowIdx][1] +botNames[rowIdx][2]); - CI18N::hashToUCString(hash, trNewUcHash); - transBotNames[transRowIdx][0] = ucstring("_") + trNewUcHash; - } - - } - else //There is no translation yet - { - fctsName = wkTranslationName; - wkTranslationName = ucstring("$")+gnName+"$"; - botNames[rowIdx][0] = wkBotName; - botNames[rowIdx][1] = wkTranslationName; - botNames[rowIdx][2] = wkSheetName; - fctsTitleId = gnName; - - - } - } - - } - - - // look for a corresponding entry - uint gnNameRow; - - - if (!fcts.findRow(fctsIdCol, fctsTitleId, gnNameRow)) - { - - // not found, add it - gnNameRow = fcts.size(); - fcts.resize(fcts.size()+1); - fcts.setData(gnNameRow, ucstring("title_id"), fctsTitleId); - fcts.setData(gnNameRow, ucstring("name"), fctsName); - nbAddGenericName++; - - } - else //Update - { - - } - } - } - - - // 3 - functions - { - nlinfo(" Functions..."); - - set::iterator first(Functions.begin()), last(Functions.end()); - for (; first != last; ++first) - { - string fctName = *first; - // look for a corresponding entry - uint functionRow; - if (!fcts.findRow(fctsIdCol, fctName, functionRow)) - { - // not found, add it - functionRow = fcts.size(); - fcts.resize(fcts.size()+1); - - fcts.setData(functionRow, ucstring("title_id"), fctName); - fcts.setData(functionRow, ucstring("name"), *first); - - nbAddFunction++; - } - } - } - - // display resum\E9 - nlinfo("Adding %u new simple name", nbAddSimpleName); - nlinfo("Adding %u new generic name", nbAddGenericName); - nlinfo("Adding %u new function name", nbAddFunction); - - // saving the modified files - ucstring s = prepareExcelSheet(botNames); - CI18N::writeTextFile(work_path_file, s, false); - s = prepareExcelSheet(transBotNames); - CI18N::writeTextFile(trans_path_file, s, false); - s = prepareExcelSheet(fcts); - CI18N::writeTextFile(title_path_file, s, false); -*/ - return 0; -} - + +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.h new file mode 100644 index 000000000..9c4ea51d2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_bot_names.h @@ -0,0 +1,111 @@ +// Translation Manager Plugin - OVQT Plugin +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Emanuel Costea +// +// 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 EXTRACT_BOT_NAMES_H +#define EXTRACT_BOT_NAMES_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/config_file.h" +#include "nel/misc/sheet_id.h" +#include "nel/misc/path.h" +#include "nel/misc/diff_tool.h" +#include "nel/georges/u_form.h" +#include "nel/georges/u_form_elm.h" +#include "nel/georges/load_form.h" +#include "nel/ligo/ligo_config.h" +#include "nel/ligo/primitive.h" +#include "nel/ligo/primitive_utils.h" + +using namespace std; +using namespace NLMISC; +using namespace NLLIGO; +using namespace STRING_MANAGER; + +namespace Plugin +{ + +struct TCreatureInfo +{ + CSheetId SheetId; + bool ForceSheetName; + bool DisplayName; + + + void readGeorges (const NLMISC::CSmartPtr &form, const NLMISC::CSheetId &sheetId) + { + const NLGEORGES::UFormElm &item=form->getRootNode(); + + SheetId=sheetId; + item.getValueByName(ForceSheetName, "3d data.ForceDisplayCreatureName"); + item.getValueByName(DisplayName, "3d data.DisplayName"); + } + + void serial(NLMISC::IStream &f) + { + f.serial(SheetId); + f.serial(ForceSheetName); + f.serial(DisplayName); + } + + + static uint getVersion () + { + return 1; + } + + void removed() + { + } + +}; + +struct TEntryInfo +{ + string SheetName; +}; + +struct ExtractBotNames +{ +private: + vector Filters; + std::map Creatures; + set GenericNames; + map SimpleNames; + set Functions; +private: + TCreatureInfo *getCreature(const std::string &sheetName); + ucstring makeGroupName(const ucstring & translationName); + string removeAndStoreFunction(const std::string &fullName); + void addGenericName(const std::string &name, const std::string &sheetName); + void addSimpleName(const std::string &name, const std::string &sheetName); +public: + void extractBotNamesFromPrimitives(CLigoConfig ligoConfig); + void setRequiredSettings(list filters, string level_design_path); + set getGenericNames(); + map getSimpleNames(); + string cleanupName(const std::string &name); + ucstring cleanupUcName(const ucstring &name); + void cleanSimpleNames(); + void cleanGenericNames(); + +}; + +} + + +#endif /* EXTRACT_BOT_NAMES_H */ + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.cpp new file mode 100644 index 000000000..e881177bb --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.cpp @@ -0,0 +1,154 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "extract_new_sheet_names.h" + +using namespace std; +using namespace NLMISC; +using namespace NLLIGO; +using namespace STRING_MANAGER; + +namespace Plugin { + + + +// *************************************************************************** +/* + * Specialisation of IWordListBuilder to list sheets in a directory + */ + + +bool CSheetWordListBuilder::buildWordList(std::vector &allWords, string workSheetFileName) + { + SheetExt= toLower(SheetExt); + nlinfo("aaaa"); + // verify the directory is correct + if(!CFile::isDirectory(SheetPath)) + { + nlwarning("Error: Directory '%s' not found. '%s' Aborted", SheetPath.c_str(), workSheetFileName.c_str()); + return false; + } + + // list all files. + std::vector allFiles; + allFiles.reserve(100000); + CPath::getPathContent(SheetPath, true, false, true, allFiles, NULL); + + // Keep only the extension we want, and remove "_" (parent) + allWords.clear(); + allWords.reserve(allFiles.size()); + for(uint i=0;i &allWords, string workSheetFileName) + { + // verify the directory is correct + if(!CFile::isDirectory(PrimPath)) + { + nlwarning("Error: Directory '%s' not found. '%s' Aborted", PrimPath.c_str(), workSheetFileName.c_str()); + return false; + } + + // list all files. + std::vector allFiles; + allFiles.reserve(100000); + CPath::getPathContent(PrimPath, true, false, true, allFiles, NULL); + + // parse all primitive that match the filter + allWords.clear(); + allWords.reserve(100000); + // to avoid duplicate + set allWordSet; + for(uint i=0;i setPlace; + TPrimitiveSet placeRes; + setPlace.buildSet(PrimDoc.RootNode, predCont, placeRes); + // for all found + for (uint placeId= 0; placeId < placeRes.size(); ++placeId) + { + string primName; + if(placeRes[placeId]->getPropertyByName(listProp[cid], primName) && !primName.empty()) + { + primName= toLower(primName); + // avoid duplicate + if(allWordSet.insert(primName).second) + { + allWords.push_back(primName); + } + } + } + } + } + + return true; + } + +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.h new file mode 100644 index 000000000..007018a08 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/extract_new_sheet_names.h @@ -0,0 +1,70 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef EXTRACT_NEW_SHEET_NAMES_H +#define EXTRACT_NEW_SHEET_NAMES_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/config_file.h" +#include "nel/misc/sheet_id.h" +#include "nel/misc/path.h" +#include "nel/misc/diff_tool.h" +#include "nel/misc/algo.h" +#include "nel/georges/u_form.h" +#include "nel/georges/u_form_elm.h" +#include "nel/georges/load_form.h" +#include "nel/ligo/ligo_config.h" +#include "nel/ligo/primitive.h" +#include "nel/ligo/primitive_utils.h" + +using namespace std; +using namespace NLMISC; +using namespace NLLIGO; +using namespace STRING_MANAGER; + +namespace Plugin { + + +// *************************************************************************** +/* + * Interface to build the whole list of words (key id) for a specific worksheet + */ +struct IWordListBuilder +{ + virtual bool buildWordList(std::vector &allWords, string workSheetFileName) =0; + +}; + +struct CSheetWordListBuilder : public IWordListBuilder +{ + string SheetExt; + string SheetPath; + + virtual bool buildWordList(std::vector &allWords, string workSheetFileName); +}; + +struct CRegionPrimWordListBuilder : public IWordListBuilder +{ + string PrimPath; + vector PrimFilter; + virtual bool buildWordList(std::vector &allWords, string workSheetFileName); +}; + +} + + +#endif /* EXTRACT_NEW_SHEET_NAMES_H */ + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_editor.h index 605d11d6e..7af2b061d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_editor.h @@ -1,3 +1,19 @@ +// Translation Manager Plugin - OVQT Plugin +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Emanuel Costea +// +// 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 TRANSLATION_MANAGER_EDITOR_H #define TRANSLATION_MANAGER_EDITOR_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_main_window.cpp index 8b8c50a22..95a5fe95f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_main_window.cpp @@ -1,6 +1,6 @@ -// Object Viewer Qt - MMORPG Framework +// Translation Manager Plugin - OVQT Plugin // Copyright (C) 2010 Winch Gate Property Limited -// Copyright (C) 2011 Dzmitry Kamiahin +// Copyright (C) 2011 Emanuel Costea // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -46,21 +46,6 @@ #include - -struct TEntryInfo -{ - string SheetName; -}; - -set getGenericNames(); -void cleanGenericNames(); -map getSimpleNames(); -void cleanSimpleNames(); -void setPathsForPrimitives(map > config_paths, string ligo_class_file); -void extractBotNamesFromPrimitives(); -string cleanupName(const std::string &name); -ucstring cleanupUcName(const ucstring &name); - namespace Plugin { @@ -74,9 +59,8 @@ CMainWindow::CMainWindow(QWidget *parent) windowMapper = new QSignalMapper(this); connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*))); - // set extraction scripts counters - execution_count["extract_bot_names"] = 0; - + initialize_settings["georges"] = false; + initialize_settings["ligo"] = false; readSettings(); createToolbar(); m_undoStack = new QUndoStack(this); @@ -99,9 +83,33 @@ void CMainWindow::createToolbar() QMenu *wordsExtractionMenu = new QMenu("&Words extraction..."); wordsExtractionMenu->setIcon(QIcon(Core::Constants::ICON_SETTINGS)); _ui.toolBar->addAction(wordsExtractionMenu->menuAction()); + // extract bot names QAction *extractBotNamesAct = wordsExtractionMenu->addAction("&Extract bot names..."); extractBotNamesAct->setStatusTip(tr("Extract bot names from primitives.")); connect(extractBotNamesAct, SIGNAL(triggered()), this, SLOT(extractBotNames())); + // signal mapper for extraction words + QSignalMapper *wordsExtractionMapper = new QSignalMapper(this); + connect(wordsExtractionMapper, SIGNAL(mapped(QString)), this, SLOT(extractWords(QString))); + // extract item words + QAction *extractItemWordsAct = wordsExtractionMenu->addAction("&Extract item words..."); + extractItemWordsAct->setStatusTip(tr("Extract item words")); + connect(extractItemWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map())); + wordsExtractionMapper->setMapping(extractItemWordsAct, "item"); + // extract creature words + QAction *extractCreatureWordsAct = wordsExtractionMenu->addAction("&Extract creature words..."); + extractCreatureWordsAct->setStatusTip(tr("Extract creature words")); + connect(extractCreatureWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map())); + wordsExtractionMapper->setMapping(extractCreatureWordsAct, "creature"); + // extract sbrick words + QAction *extractSbrickWordsAct = wordsExtractionMenu->addAction("&Extract sbrick words..."); + extractSbrickWordsAct->setStatusTip(tr("Extract sbrick words")); + connect(extractSbrickWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map())); + wordsExtractionMapper->setMapping(extractSbrickWordsAct, "sbrick"); + // extract sphrase words + QAction *extractSphraseWordsAct = wordsExtractionMenu->addAction("&Extract sphrase words..."); + extractSphraseWordsAct->setStatusTip(tr("Extract sphrase words")); + connect(extractSphraseWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map())); + wordsExtractionMapper->setMapping(extractSphraseWordsAct, "sphrase"); // Windows menu windowMenu = new QMenu(tr("&Windows..."), _ui.toolBar); @@ -194,6 +202,29 @@ void CMainWindow::open() } +void CMainWindow::openWorkFile(QString file) +{ + QFileInfo* file_path = new QFileInfo(QString("%1/%2").arg(QString(work_path.c_str())).arg(file)); + if(file_path->exists()) + { + if(isWorksheetEditor(file_path->filePath())) + { + CEditorWorksheet *new_window = new CEditorWorksheet(_ui.mdiArea); + new_window->open(file_path->filePath()); + new_window->activateWindow(); + } + } else { + QErrorMessage error; + QString text; + text.append("The "); + text.append(file_path->fileName()); + text.append(" file don't exists."); + error.showMessage(text); + error.exec(); + } + +} + void CMainWindow::save() { CEditor* current_window = qobject_cast(_ui.mdiArea->currentSubWindow()); @@ -223,49 +254,101 @@ void CMainWindow::saveAs() } } +void CMainWindow::initializeSettings(bool georges = false) +{ + if(georges == true && initialize_settings["georges"] == false) + { + CPath::addSearchPath(level_design_path + "/DFN", true, false); + CPath::addSearchPath(level_design_path + "/Game_elem/Creature", true, false); + initialize_settings["georges"] = true; + } + + if(initialize_settings["ligo"] == false) + { + //------------------------------------------------------------------- + // init ligo config + string ligoPath = CPath::lookup("world_editor_classes.xml", true, true); + ligoConfig.readPrimitiveClass(ligoPath.c_str(), false); + NLLIGO::Register(); + NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &ligoConfig; + initialize_settings["ligo"] = true; + } +} + +void CMainWindow::extractWords(QString type) +{ + CEditor* editor_window = qobject_cast(_ui.mdiArea->currentSubWindow()); + CEditorWorksheet* current_window = qobject_cast(editor_window); + + // initializeSettings(false); + + CSheetWordListBuilder builder; + QString column_name; + + if(type == "item") + { + column_name = "item ID"; + builder.SheetExt = "sitem"; + builder.SheetPath = level_design_path + "/game_element/sitem"; + } else if(type == "creature") { + column_name = "creature ID"; + builder.SheetExt = "creature"; + builder.SheetPath = level_design_path + "/Game_elem/Creature/fauna"; + } else if(type == "sbrick") { + column_name = "sbrick ID"; + builder.SheetExt = "sbrick"; + builder.SheetPath = level_design_path + "/game_element/sbrick"; + } else if(type == "sphrase") { + column_name = "sphrase ID"; + builder.SheetExt = "sphrase"; + builder.SheetPath = level_design_path + "/game_element/sphrase"; + } + current_window->extractWords(current_window->windowFilePath(), column_name, builder); +} + void CMainWindow::extractBotNames() { if(verifySettings() == true) { + CEditorWorksheet* current_window; + if(_ui.mdiArea->subWindowList().size() > 0) + { CEditor* editor_window = qobject_cast(_ui.mdiArea->currentSubWindow()); if(QString(editor_window->widget()->metaObject()->className()) == "QTableWidget") // Sheet Editor { - CEditorWorksheet* current_window = qobject_cast(editor_window); + current_window = qobject_cast(editor_window); QString file_path = current_window->subWindowFilePath(); if(!current_window->isBotNamesTable()) { list subWindows = convertSubWindowList(_ui.mdiArea->subWindowList()); list::iterator it = subWindows.begin(); bool finded = false; - for(; it != subWindows.end(), finded != true; ++it) + + for(; it != subWindows.end(); ++it) { - current_window = qobject_cast((*it)); - file_path = current_window->subWindowFilePath(); - if(current_window->isBotNamesTable()) - { - finded = true; - current_window->activateWindow(); - } + current_window = qobject_cast((*it)); + file_path = current_window->subWindowFilePath(); + if(current_window->isBotNamesTable()) + { + finded = true; + current_window->activateWindow(); + } } if(!finded) { - open(); + openWorkFile("bot_names_wk.txt"); current_window = qobject_cast(_ui.mdiArea->currentSubWindow()); file_path = current_window->windowFilePath(); } - } - if(execution_count["extract_bot_names"] == 0) - setPathsForPrimitives(config_paths, ligo_path); - extractBotNamesFromPrimitives(); - execution_count["extract_bot_names"] = execution_count["extract_bot_names"] + 1; - - current_window->extractBotNames(); - // if(current_window->isWindowModified()) - // { - - // } - + } } + } else { + openWorkFile("bot_names_wk.txt"); + current_window = qobject_cast(_ui.mdiArea->currentSubWindow()); + QString file_path = current_window->windowFilePath(); + } + initializeSettings(true); + current_window->extractBotNames(filters, level_design_path, ligoConfig); } } @@ -273,22 +356,14 @@ void CMainWindow::readSettings() { QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("translationmanager"); - - list paths = convertQStringList(settings->value("paths").toStringList()); /* paths */ - config_paths["paths"] = paths; - list pathsR = convertQStringList(settings->value("pathsR").toStringList()); /* pathsR */ - config_paths["pathsR"] = pathsR; - list georges = convertQStringList(settings->value("georges").toStringList()); /* georges */ - config_paths["georges"] = georges; - list filters = convertQStringList(settings->value("filters").toStringList()); /* filters */ - config_paths["filters"] = filters; - + filters = convertQStringList(settings->value("filters").toStringList()); /* filters */ languages = convertQStringList(settings->value("trlanguages").toStringList()); /* languages */ - ligo_path = settings->value("ligo").toString().toStdString(); translation_path = settings->value("translation").toString().toStdString(); work_path = settings->value("work").toString().toStdString(); - - settings->endGroup(); + settings->endGroup(); + settings->beginGroup(Core::Constants::DATA_PATH_SECTION); + level_design_path = settings->value(Core::Constants::LEVELDESIGN_PATH).toString().toStdString(); + settings->endGroup(); } void CMainWindow::debug(QString text) @@ -305,10 +380,7 @@ bool CMainWindow::verifySettings() QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("translationmanager"); - if(settings->value("paths").toList().count() == 0 - || settings->value("pathsR").toList().count() == 0 - || settings->value("georges").toList().count() == 0 - || settings->value("filters").toList().count() == 0) + if(settings->value("filters").toList().count() == 0) { QErrorMessage error_settings; error_settings.showMessage("Please write all the paths on the settings dialog."); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_main_window.h index 13a3ead97..b0d59fe29 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_main_window.h @@ -1,6 +1,6 @@ -// Object Viewer Qt - MMORPG Framework +// Translation Manager Plugin - OVQT Plugin // Copyright (C) 2010 Winch Gate Property Limited -// Copyright (C) 2011 Dzmitry Kamiahin +// Copyright (C) 2011 Emanuel Costea // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -27,6 +27,7 @@ #include "nel/misc/sheet_id.h" #include "nel/misc/path.h" #include "nel/misc/diff_tool.h" +#include "nel/ligo/ligo_config.h" // Qt includes #include @@ -51,13 +52,6 @@ using namespace std; namespace Plugin { -class CMdiSubWindow; - -struct WStatus -{ - bool modified; -}; - class CMainWindow : public QMainWindow { Q_OBJECT @@ -75,15 +69,16 @@ private: QMenu *windowMenu; QSignalMapper *windowMapper; // config - map > config_paths; + map initialize_settings; + list filters; list languages; - string ligo_path; + string level_design_path; string translation_path; string work_path; - // counts - map execution_count; + NLLIGO::CLigoConfig ligoConfig; private Q_SLOTS: void extractBotNames(); + void extractWords(QString); void open(); void save(); void saveAs(); @@ -93,12 +88,13 @@ private Q_SLOTS: void debug(QString text); // TODO private: + void openWorkFile(QString file); void updateToolbar(QMdiSubWindow *window); bool verifySettings(); void readSettings(); void createMenus(); void createToolbar(); - + void initializeSettings(bool georges); list convertQStringList(QStringList listq); list convertSubWindowList(QList listq); bool isWorksheetEditor(QString filename); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_plugin.cpp index 890c589e9..caf677a0d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_plugin.cpp @@ -1,3 +1,20 @@ +// Translation Manager Plugin - OVQT Plugin +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Emanuel Costea +// +// 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 . + // Project includes #include "translation_manager_plugin.h" #include "translation_manager_settings_page.h" diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_plugin.h index 42515cb2f..ed42b4882 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_plugin.h @@ -1,3 +1,20 @@ +// Translation Manager Plugin - OVQT Plugin +// Copyright (C) 2010 Winch Gate Property Limited +// Copyright (C) 2011 Emanuel Costea +// +// 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 TRANSLATION_MANAGER_PLUGIN_H #define TRANSLATION_MANAGER_PLUGIN_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.cpp index 078a9c18c..4870da41b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.cpp @@ -1,6 +1,6 @@ -// Object Viewer Qt - MMORPG Framework +// Translation Manager Plugin - OVQT Plugin // Copyright (C) 2010 Winch Gate Property Limited -// Copyright (C) 2011 Dzmitry Kamiahin +// Copyright (C) 2011 Emanuel Costea // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -69,12 +69,6 @@ QWidget *CTranslationManagerSettingsPage::createPage(QWidget *parent) _currentPage = new QWidget(parent); _ui.setupUi(_currentPage); readSettings(); - connect(_ui.paths_add, SIGNAL(clicked()), this, SLOT(pathAdd())); - connect(_ui.paths_del, SIGNAL(clicked()), this, SLOT(pathDel())); - connect(_ui.pathsR_add, SIGNAL(clicked()), this, SLOT(pathRAdd())); - connect(_ui.pathsR_del, SIGNAL(clicked()), this, SLOT(pathRDel())); - connect(_ui.georges_add, SIGNAL(clicked()), this, SLOT(georgeAdd())); - connect(_ui.georges_del, SIGNAL(clicked()), this, SLOT(georgeDel())); connect(_ui.filter_add, SIGNAL(clicked()), this, SLOT(filterAdd())); connect(_ui.filter_del, SIGNAL(clicked()), this, SLOT(filterDel())); connect(_ui.lang_add, SIGNAL(clicked()), this, SLOT(languageAdd())); @@ -85,66 +79,6 @@ QWidget *CTranslationManagerSettingsPage::createPage(QWidget *parent) return _currentPage; } -void CTranslationManagerSettingsPage::pathAdd() -{ - QString newPath = QFileDialog::getExistingDirectory(_currentPage, "", lastDir); - if (!newPath.isEmpty()) - { - QListWidgetItem *newItem = new QListWidgetItem; - newItem->setText(newPath); - newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - _ui.paths_list->addItem(newItem); - lastDir = newPath; - } -} - -void CTranslationManagerSettingsPage::pathDel() -{ - QListWidgetItem *removeItem = _ui.paths_list->takeItem(_ui.paths_list->currentRow()); - if (!removeItem) - delete removeItem; -} - -void CTranslationManagerSettingsPage::pathRAdd() -{ - QString newPath = QFileDialog::getExistingDirectory(_currentPage, "", lastDir); - if (!newPath.isEmpty()) - { - QListWidgetItem *newItem = new QListWidgetItem; - newItem->setText(newPath); - newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - _ui.pathsR_list->addItem(newItem); - lastDir = newPath; - } -} - -void CTranslationManagerSettingsPage::pathRDel() -{ - QListWidgetItem *removeItem = _ui.pathsR_list->takeItem(_ui.pathsR_list->currentRow()); - if (!removeItem) - delete removeItem; -} - -void CTranslationManagerSettingsPage::georgeAdd() -{ - QString newPath = QFileDialog::getExistingDirectory(_currentPage, "", lastDir); - if (!newPath.isEmpty()) - { - QListWidgetItem *newItem = new QListWidgetItem; - newItem->setText(newPath); - newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - _ui.georges_list->addItem(newItem); - lastDir = newPath; - } -} - -void CTranslationManagerSettingsPage::georgeDel() -{ - QListWidgetItem *removeItem = _ui.georges_list->takeItem(_ui.georges_list->currentRow()); - if (!removeItem) - delete removeItem; -} - void CTranslationManagerSettingsPage::filterAdd() { QString newValue = _ui.filter_edit->text(); @@ -208,15 +142,12 @@ void CTranslationManagerSettingsPage::apply() void CTranslationManagerSettingsPage::readSettings() { - QStringList paths, pathsR, georges, filters, languages; + QStringList filters, languages; QString ligo, translation, work; QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("translationmanager"); - paths = settings->value("paths").toStringList(); /* paths */ - pathsR = settings->value("pathsR").toStringList(); /* pathsR */ - georges = settings->value("georges").toStringList(); /* georges */ filters = settings->value("filters").toStringList(); /* filters */ languages = settings->value("trlanguages").toStringList(); /* languages */ ligo = settings->value("ligo").toString(); @@ -224,30 +155,6 @@ void CTranslationManagerSettingsPage::readSettings() work = settings->value("work").toString(); settings->endGroup(); - // paths - Q_FOREACH(QString path, paths) - { - QListWidgetItem *newItem = new QListWidgetItem; - newItem->setText(path); - newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - _ui.paths_list->addItem(newItem); - } - // pathsR - Q_FOREACH(QString pathR, pathsR) - { - QListWidgetItem *newItem = new QListWidgetItem; - newItem->setText(pathR); - newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - _ui.pathsR_list->addItem(newItem); - } - // georges - Q_FOREACH(QString george, georges) - { - QListWidgetItem *newItem = new QListWidgetItem; - newItem->setText(george); - newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - _ui.georges_list->addItem(newItem); - } // filter Q_FOREACH(QString filter, filters) { @@ -264,8 +171,6 @@ void CTranslationManagerSettingsPage::readSettings() newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); _ui.lang_list->addItem(newItem); } - // ligo - _ui.ligo_edit->setText(ligo); // translation _ui.translation_edit->setText(translation); // work @@ -275,25 +180,14 @@ void CTranslationManagerSettingsPage::readSettings() void CTranslationManagerSettingsPage::writeSettings() { - QStringList paths, pathsR, georges, filters, languages; + QStringList filters, languages; QString ligo, translation, work; - // paths - for (int i = 0; i < _ui.paths_list->count(); ++i) - paths << _ui.paths_list->item(i)->text(); - // pathsR - for (int i = 0; i < _ui.pathsR_list->count(); ++i) - pathsR << _ui.pathsR_list->item(i)->text(); - // georges - for (int i = 0; i < _ui.georges_list->count(); ++i) - georges << _ui.georges_list->item(i)->text(); // filters for (int i = 0; i < _ui.filter_list->count(); ++i) filters << _ui.filter_list->item(i)->text(); // languages for (int i = 0; i < _ui.lang_list->count(); ++i) languages << _ui.lang_list->item(i)->text(); - // ligo path - ligo = _ui.ligo_edit->text(); // translations path translation = _ui.translation_edit->text(); // work path @@ -301,12 +195,8 @@ void CTranslationManagerSettingsPage::writeSettings() QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup("translationmanager"); - settings->setValue("paths", paths); - settings->setValue("pathsR", pathsR); - settings->setValue("georges", georges); settings->setValue("filters", filters); - settings->setValue("trlanguages", languages); - settings->setValue("ligo", ligo); + settings->setValue("trlanguages", languages); settings->setValue("translation", translation); settings->setValue("work", work); settings->endGroup(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.h index 7a082f199..1cf19787a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.h @@ -1,6 +1,6 @@ -// Object Viewer Qt - MMORPG Framework +// Translation Manager Plugin - OVQT Plugin // Copyright (C) 2010 Winch Gate Property Limited -// Copyright (C) 2011 Dzmitry Kamiahin +// Copyright (C) 2011 Emanuel Costea // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -15,7 +15,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - #ifndef TRANSLATION_MANAGER_SETTINGS_PAGE_H #define TRANSLATION_MANAGER_SETTINGS_PAGE_H @@ -49,12 +48,6 @@ public: virtual void apply(); virtual void finish() {} private Q_SLOTS: - void pathAdd(); - void pathDel(); - void pathRAdd(); - void pathRDel(); - void georgeAdd(); - void georgeDel(); void filterAdd(); void filterDel(); void languageAdd(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.ui index 4c932b4f5..aaa4337f4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/translation_manager/translation_manager_settings_page.ui @@ -6,388 +6,181 @@ 0 0 - 490 - 496 + 533 + 478 Form - - - - - 1 - - - - Core paths - - - - - - - - - - Paths - - - - - - - Qt::Horizontal - - - - 318 - 20 - - - - - - - - dwadwadwa - - - - :/icons/ic_nel_add_item.png:/icons/ic_nel_add_item.png - - - Qt::ToolButtonIconOnly - - - true - - - - - - - ... - - - - :/icons/ic_nel_delete_item.png:/icons/ic_nel_delete_item.png - - - true - - - - - - - - - - - - - - - - - - Paths non recursives - - - - - - - Qt::Horizontal - - - - 218 - 20 - - - - - - - - - - - - :/icons/ic_nel_add_item.png:/icons/ic_nel_add_item.png - - - true - - - - - - - ... - - - - :/icons/ic_nel_delete_item.png:/icons/ic_nel_delete_item.png - - - true - - - - - - - - - - - - - - - - - - Georges Paths - - - - - - - Qt::Horizontal - - - - 258 - 20 - - - - - - - - - - - - :/icons/ic_nel_add_item.png:/icons/ic_nel_add_item.png - - - true - - - - - - - - - - - :/icons/ic_nel_delete_item.png:/icons/ic_nel_delete_item.png - - - true - - - - - - - - - - - - - - - Translation files paths - - - - - 9 - 190 - 454 - 161 - + + + + 0 + 10 + 531 + 421 + + + + Translation Manager Plugin + + + + + 0 + 30 + 521 + 232 + + + + + + + Filters - - - - - Ligo class file - This is the name of the world_editor_classes.xml file. - - - - - - - - - - Work directory - - - - - - - - - - - - ... - - - - - - - - - Translation directory - - - - - - - - - - - - ... - - - - - - - - - - 9 - 10 - 211 - 181 - + + + + + + + + + + + + :/core/icons/ic_nel_add_item.png:/core/icons/ic_nel_add_item.png + + + true + + + + + + + + + + + :/core/icons/ic_nel_delete_item.png:/core/icons/ic_nel_delete_item.png + + + true + + + + + + + Languages + + + + + + + + + + + + + + :/core/icons/ic_nel_add_item.png:/core/icons/ic_nel_add_item.png + + + true + + + + + + + + + + + :/core/icons/ic_nel_delete_item.png:/core/icons/ic_nel_delete_item.png + + + true + + + + + + + + + + + + + + + 0 + 340 + 521 + 60 + + + + + + + Translation directory + + + + + + + + + + ... + + + + + + + + + 0 + 270 + 521 + 60 + + + + + + + Work directory - - - - - Filters - - - - - - - - - - - - - - :/icons/ic_nel_add_item.png:/icons/ic_nel_add_item.png - - - true - - - - - - - - - - - :/icons/ic_nel_delete_item.png:/icons/ic_nel_delete_item.png - - - true - - - - - - - - - - - 240 - 10 - 221 - 181 - + + + + + + + + ... - - - - - Languages - - - - - - - - - - - - - - :/icons/ic_nel_add_item.png:/icons/ic_nel_add_item.png - - - true - - - - - - - - - - - :/icons/ic_nel_delete_item.png:/icons/ic_nel_delete_item.png - - - true - - - - - - - - - - - + + + + - - +