Browse Source

* editor menus

mateuszb 12 years ago
parent
commit
776eb13663
4 changed files with 58 additions and 7 deletions
  1. 54 6
      Editor/Editor.cpp
  2. 2 0
      Editor/Editor.h
  3. 1 1
      lib/CGeneralTextHandler.cpp
  4. 1 0
      lib/CGeneralTextHandler.h

+ 54 - 6
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);
+	}
 }

+ 2 - 0
Editor/Editor.h

@@ -16,6 +16,8 @@ public:
 	void createMenus();
 private:
 
+	std::vector<std::string> txtEditor, txtEditorCmd;
+
 	std::ofstream * logfile;
 	CConsoleHandler * console;
 

+ 1 - 1
lib/CGeneralTextHandler.cpp

@@ -139,7 +139,7 @@ bool CLegacyConfigParser::endLine()
 	return curr < end;
 }
 
-void readToVector(std::string sourceName, std::vector<std::string> & dest)
+void CGeneralTextHandler::readToVector(std::string sourceName, std::vector<std::string> & dest)
 {
 	CLegacyConfigParser parser(sourceName);
 	do

+ 1 - 0
lib/CGeneralTextHandler.h

@@ -104,6 +104,7 @@ public:
 	std::vector <std::string> campaignMapNames;
 	std::vector < std::vector <std::string> > campaignRegionNames;
 
+	void readToVector(std::string sourceName, std::vector<std::string> & dest);
 	void load();
 	CGeneralTextHandler();
 };