CHeroBackpackWindow.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * CHeroBackpackWindow.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 "CHeroBackpackWindow.h"
  12. #include "../gui/CGuiHandler.h"
  13. #include "../gui/Shortcut.h"
  14. #include "../widgets/Buttons.h"
  15. #include "../widgets/Images.h"
  16. #include "CMessage.h"
  17. #include "render/Canvas.h"
  18. #include "CPlayerInterface.h"
  19. CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero)
  20. : CWindowObject((EOptions)0)
  21. {
  22. OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
  23. stretchedBackground = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, 410, 425));
  24. arts = std::make_shared<CArtifactsOfHeroBackpack>(Point(windowMargin, windowMargin));
  25. arts->setHero(hero);
  26. addSetAndCallbacks(arts);
  27. addCloseCallback(std::bind(&CHeroBackpackWindow::close, this));
  28. quitButton = std::make_shared<CButton>(Point(), AnimationPath::builtin("IOKAY32.def"), CButton::tooltip(""), [this]() { close(); }, EShortcut::GLOBAL_RETURN);
  29. stretchedBackground->pos.w = arts->pos.w + 2 * windowMargin;
  30. stretchedBackground->pos.h = arts->pos.h + quitButton->pos.h + 3 * windowMargin;
  31. pos.w = stretchedBackground->pos.w;
  32. pos.h = stretchedBackground->pos.h;
  33. center();
  34. quitButton->moveBy(Point(GH.screenDimensions().x / 2 - quitButton->pos.w / 2 - quitButton->pos.x, arts->pos.h + 2 * windowMargin));
  35. }
  36. void CHeroBackpackWindow::showAll(Canvas & to)
  37. {
  38. CIntObject::showAll(to);
  39. CMessage::drawBorder(PlayerColor(LOCPLINT->playerID), to.getInternalSurface(), pos.w+28, pos.h+29, pos.x-14, pos.y-15);
  40. }