CTutorialWindow.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "../gui/CGuiHandler.h"
  17. #include "../gui/Shortcut.h"
  18. #include "../gui/WindowHandler.h"
  19. #include "../widgets/Images.h"
  20. #include "../widgets/Buttons.h"
  21. #include "../widgets/TextControls.h"
  22. CTutorialWindow::CTutorialWindow(const TutorialMode & m)
  23. : CWindowObject(BORDERED, ImagePath::builtin("DIBOXBCK")), mode { m }
  24. {
  25. OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
  26. pos = Rect(pos.x, pos.y, 540, 400); //video: 480x320
  27. background = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, pos.w, pos.h));
  28. updateShadow();
  29. center();
  30. addUsedEvents(LCLICK);
  31. buttonOk = std::make_shared<CButton>(Point(239, 367), AnimationPath::builtin("IOKAY"), CButton::tooltip(), std::bind(&CTutorialWindow::close, this), EShortcut::GLOBAL_ACCEPT); //62x28
  32. buttonLeft = std::make_shared<CButton>(Point(5, 177), AnimationPath::builtin("HSBTNS3"), CButton::tooltip(), std::bind(&CTutorialWindow::previous, this), EShortcut::MOVE_LEFT); //22x46
  33. buttonRight = std::make_shared<CButton>(Point(513, 177), AnimationPath::builtin("HSBTNS5"), CButton::tooltip(), std::bind(&CTutorialWindow::next, this), EShortcut::MOVE_RIGHT); //22x46
  34. buttonLeft->block(true);
  35. labelTitle = std::make_shared<CLabel>(270, 15, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, "Touchscreen Intro");
  36. 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.");
  37. }
  38. void CTutorialWindow::openWindowFirstTime(const TutorialMode & m)
  39. {
  40. if(GH.input().hasTouchInputDevice() && !persistentStorage["gui"]["tutorialCompleted" + std::to_string(m)].Bool())
  41. {
  42. if(LOCPLINT)
  43. LOCPLINT->showingDialog->set(true);
  44. GH.windows().pushWindow(std::make_shared<CTutorialWindow>(m));
  45. Settings s = persistentStorage.write["gui"]["tutorialCompleted" + std::to_string(m)];
  46. s->Bool() = true;
  47. }
  48. }
  49. void CTutorialWindow::close()
  50. {
  51. if(LOCPLINT)
  52. LOCPLINT->showingDialog->setn(false);
  53. WindowBase::close();
  54. }
  55. void CTutorialWindow::next()
  56. {
  57. }
  58. void CTutorialWindow::previous()
  59. {
  60. }