Editor.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include "StdInc.h"
  2. #include "Editor.h"
  3. #include "../lib/VCMI_Lib.h"
  4. #include "../lib/VCMIDirs.h"
  5. #include "../lib/Filesystem/CResourceLoader.h"
  6. #include "../lib/CGeneralTextHandler.h"
  7. Editor::Editor(QWidget *parent)
  8. : QMainWindow(parent)
  9. {
  10. logfile = new std::ofstream((GVCMIDirs.UserPath + "/VCMI_Editor_log.txt").c_str());
  11. console = new CConsoleHandler;
  12. preinitDLL(console,logfile);
  13. loadDLLClasses();
  14. VLC->generaltexth->readToVector("DATA/EDITOR", txtEditor);
  15. VLC->generaltexth->readToVector("DATA/EDITRCMD", txtEditorCmd);
  16. ui.setupUi(this);
  17. createMenus();
  18. }
  19. Editor::~Editor()
  20. {
  21. }
  22. void Editor::createMenus()
  23. {
  24. enum MenuName {FILE, EDIT, VIEW, TOOLS, PLAYER, HELP};
  25. QMenu * menus[6];
  26. for(int i=0; i<6; ++i)
  27. menus[i] = menuBar()->addMenu(tr(txtEditor[751+i].c_str()));
  28. for(int i=0; i<6; ++i)
  29. {
  30. if(i == 4)
  31. menus[FILE]->addSeparator();
  32. QAction * qa = new QAction(tr(txtEditor[758+i].c_str()), menus[FILE]);
  33. menus[FILE]->addAction(qa);
  34. }
  35. for(int i=0; i<10; ++i)
  36. {
  37. if(i == 2 || i == 6 || i == 9)
  38. menus[EDIT]->addSeparator();
  39. QAction * qa = new QAction(tr(txtEditor[860+i].c_str()), menus[EDIT]);
  40. menus[EDIT]->addAction(qa);
  41. }
  42. for(int i=0; i<10; ++i)
  43. {
  44. if(i == 2 || i == 3 || i == 7)
  45. menus[VIEW]->addSeparator();
  46. QAction * qa = new QAction(tr(txtEditor[778+i].c_str()), menus[VIEW]);
  47. menus[VIEW]->addAction(qa);
  48. }
  49. for(int i=0; i<9; ++i)
  50. {
  51. if(i == 6 || i == 8)
  52. menus[TOOLS]->addSeparator();
  53. QAction * qa = new QAction(tr(txtEditor[789+i].c_str()), menus[TOOLS]);
  54. menus[TOOLS]->addAction(qa);
  55. }
  56. for(int i=0; i<9; ++i)
  57. {
  58. QAction * qa = new QAction(tr(txtEditor[846+i].c_str()), menus[PLAYER]);
  59. menus[PLAYER]->addAction(qa);
  60. }
  61. for(int i=0; i<2; ++i)
  62. {
  63. if(i == 1)
  64. menus[HELP]->addSeparator();
  65. QAction * qa = new QAction(tr(txtEditor[856+i].c_str()), menus[HELP]);
  66. menus[HELP]->addAction(qa);
  67. }
  68. }