CTutorialWindow.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * CTutorialWindow.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "CTutorialWindow.h"
  12. #include "../eventsSDL/InputHandler.h"
  13. #include "../../lib/CConfigHandler.h"
  14. #include "../../lib/CondSh.h"
  15. #include "../CPlayerInterface.h"
  16. #include "../CGameInfo.h"
  17. #include "../CVideoHandler.h"
  18. #include "../gui/CGuiHandler.h"
  19. #include "../gui/Shortcut.h"
  20. #include "../gui/WindowHandler.h"
  21. #include "../widgets/Images.h"
  22. #include "../widgets/Buttons.h"
  23. #include "../widgets/TextControls.h"
  24. #include "../render/Canvas.h"
  25. CTutorialWindow::CTutorialWindow(const TutorialMode & m)
  26. : CWindowObject(BORDERED, ImagePath::builtin("DIBOXBCK")), mode { m }
  27. {
  28. OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
  29. pos = Rect(pos.x, pos.y, 540, 400); //video: 480x320
  30. background = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, pos.w, pos.h));
  31. updateShadow();
  32. center();
  33. addUsedEvents(LCLICK);
  34. buttonOk = std::make_shared<CButton>(Point(239, 367), AnimationPath::builtin("IOKAY"), CButton::tooltip(), std::bind(&CTutorialWindow::close, this), EShortcut::GLOBAL_ACCEPT); //62x28
  35. buttonLeft = std::make_shared<CButton>(Point(5, 177), AnimationPath::builtin("HSBTNS3"), CButton::tooltip(), std::bind(&CTutorialWindow::previous, this), EShortcut::MOVE_LEFT); //22x46
  36. buttonRight = std::make_shared<CButton>(Point(513, 177), AnimationPath::builtin("HSBTNS5"), CButton::tooltip(), std::bind(&CTutorialWindow::next, this), EShortcut::MOVE_RIGHT); //22x46
  37. buttonLeft->block(true);
  38. labelTitle = std::make_shared<CLabel>(270, 15, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, "Touchscreen Intro");
  39. labelInformation = std::make_shared<CMultiLineLabel>(Rect(5, 50, 530, 60), EFonts::FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.");
  40. }
  41. void CTutorialWindow::openWindowFirstTime(const TutorialMode & m)
  42. {
  43. if(GH.input().hasTouchInputDevice() && !persistentStorage["gui"]["tutorialCompleted" + std::to_string(m)].Bool())
  44. {
  45. if(LOCPLINT)
  46. LOCPLINT->showingDialog->set(true);
  47. GH.windows().pushWindow(std::make_shared<CTutorialWindow>(m));
  48. Settings s = persistentStorage.write["gui"]["tutorialCompleted" + std::to_string(m)];
  49. s->Bool() = true;
  50. }
  51. }
  52. void CTutorialWindow::close()
  53. {
  54. if(LOCPLINT)
  55. LOCPLINT->showingDialog->setn(false);
  56. WindowBase::close();
  57. }
  58. void CTutorialWindow::next()
  59. {
  60. }
  61. void CTutorialWindow::previous()
  62. {
  63. }
  64. void CTutorialWindow::show(Canvas & to)
  65. {
  66. CCS->videoh->update(pos.x + 200, pos.y + 200, to.getInternalSurface(), true, false,
  67. [&]()
  68. {
  69. CCS->videoh->close();
  70. CCS->videoh->open(VideoPath::builtin(video));
  71. });
  72. redraw();
  73. CIntObject::show(to);
  74. }
  75. void CTutorialWindow::activate()
  76. {
  77. video = "tutorial/BattleDirection";
  78. CCS->videoh->open(VideoPath::builtin(video));
  79. CIntObject::activate();
  80. }
  81. void CTutorialWindow::deactivate()
  82. {
  83. CCS->videoh->close();
  84. }