From 776eb13663089fade44e74d2ff10bf46aefd68d3 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Sat, 16 Feb 2013 16:37:43 +0000 Subject: [PATCH] * editor menus --- Editor/Editor.cpp | 60 +++++++++++++++++++++++++++++++++---- Editor/Editor.h | 2 ++ lib/CGeneralTextHandler.cpp | 2 +- lib/CGeneralTextHandler.h | 1 + 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index d9174c2c8..937059eb6 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -3,6 +3,7 @@ #include "../lib/VCMI_Lib.h" #include "../lib/VCMIDirs.h" #include "../lib/Filesystem/CResourceLoader.h" +#include "../lib/CGeneralTextHandler.h" Editor::Editor(QWidget *parent) : QMainWindow(parent) @@ -13,6 +14,9 @@ Editor::Editor(QWidget *parent) preinitDLL(console,logfile); loadDLLClasses(); + VLC->generaltexth->readToVector("DATA/EDITOR", txtEditor); + VLC->generaltexth->readToVector("DATA/EDITRCMD", txtEditorCmd); + ui.setupUi(this); createMenus(); @@ -25,10 +29,54 @@ Editor::~Editor() void Editor::createMenus() { - QMenu * fileMenu = menuBar()->addMenu(tr("File")); - QMenu * editMenu = menuBar()->addMenu(tr("Edit")); - QMenu * viewMenu = menuBar()->addMenu(tr("View")); - QMenu * toolsMenu = menuBar()->addMenu(tr("Tools")); - QMenu * playerMenu = menuBar()->addMenu(tr("Player")); - QMenu * helpMenu = menuBar()->addMenu(tr("Help")); + enum MenuName {FILE, EDIT, VIEW, TOOLS, PLAYER, HELP}; + QMenu * menus[6]; + for(int i=0; i<6; ++i) + menus[i] = menuBar()->addMenu(tr(txtEditor[751+i].c_str())); + + for(int i=0; i<6; ++i) + { + if(i == 4) + menus[FILE]->addSeparator(); + QAction * qa = new QAction(tr(txtEditor[758+i].c_str()), menus[FILE]); + menus[FILE]->addAction(qa); + } + + for(int i=0; i<10; ++i) + { + if(i == 2 || i == 6 || i == 9) + menus[EDIT]->addSeparator(); + QAction * qa = new QAction(tr(txtEditor[860+i].c_str()), menus[EDIT]); + menus[EDIT]->addAction(qa); + } + + for(int i=0; i<10; ++i) + { + if(i == 2 || i == 3 || i == 7) + menus[VIEW]->addSeparator(); + QAction * qa = new QAction(tr(txtEditor[778+i].c_str()), menus[VIEW]); + menus[VIEW]->addAction(qa); + } + + for(int i=0; i<9; ++i) + { + if(i == 6 || i == 8) + menus[TOOLS]->addSeparator(); + QAction * qa = new QAction(tr(txtEditor[789+i].c_str()), menus[TOOLS]); + menus[TOOLS]->addAction(qa); + } + + for(int i=0; i<9; ++i) + { + QAction * qa = new QAction(tr(txtEditor[846+i].c_str()), menus[PLAYER]); + menus[PLAYER]->addAction(qa); + } + + for(int i=0; i<2; ++i) + { + if(i == 1) + menus[HELP]->addSeparator(); + QAction * qa = new QAction(tr(txtEditor[856+i].c_str()), menus[HELP]); + menus[HELP]->addAction(qa); + } } diff --git a/Editor/Editor.h b/Editor/Editor.h index 3ca428241..4ad60bc78 100644 --- a/Editor/Editor.h +++ b/Editor/Editor.h @@ -16,6 +16,8 @@ public: void createMenus(); private: + std::vector txtEditor, txtEditorCmd; + std::ofstream * logfile; CConsoleHandler * console; diff --git a/lib/CGeneralTextHandler.cpp b/lib/CGeneralTextHandler.cpp index ed8eebc35..eeb539933 100644 --- a/lib/CGeneralTextHandler.cpp +++ b/lib/CGeneralTextHandler.cpp @@ -139,7 +139,7 @@ bool CLegacyConfigParser::endLine() return curr < end; } -void readToVector(std::string sourceName, std::vector & dest) +void CGeneralTextHandler::readToVector(std::string sourceName, std::vector & dest) { CLegacyConfigParser parser(sourceName); do diff --git a/lib/CGeneralTextHandler.h b/lib/CGeneralTextHandler.h index 612080d05..e416027e5 100644 --- a/lib/CGeneralTextHandler.h +++ b/lib/CGeneralTextHandler.h @@ -104,6 +104,7 @@ public: std::vector campaignMapNames; std::vector < std::vector > campaignRegionNames; + void readToVector(std::string sourceName, std::vector & dest); void load(); CGeneralTextHandler(); };