AppInfo.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef FREESHOP_APPINFO_HPP
  2. #define FREESHOP_APPINFO_HPP
  3. #include <cpp3ds/Graphics/Drawable.hpp>
  4. #include <cpp3ds/Graphics/Texture.hpp>
  5. #include <cpp3ds/Graphics/Sprite.hpp>
  6. #include <TweenEngine/TweenManager.h>
  7. #include <cpp3ds/Window/Event.hpp>
  8. #include "TweenObjects.hpp"
  9. #include "AppItem.hpp"
  10. #include <cpp3ds/Window/Window.hpp>
  11. #include "States/State.hpp"
  12. #include "TweenObjects.hpp"
  13. #include "GUI/Scrollable.hpp"
  14. #include "GUI/ScrollBar.hpp"
  15. namespace FreeShop {
  16. class AppInfo : public cpp3ds::Drawable, public util3ds::TweenTransformable<cpp3ds::Transformable>, public Scrollable {
  17. public:
  18. static const int ALPHA = 11;
  19. AppInfo();
  20. ~AppInfo();
  21. static AppInfo &getInstance();
  22. void drawTop(cpp3ds::Window &window);
  23. bool processEvent(const cpp3ds::Event& event);
  24. void update(float delta);
  25. void loadApp(std::shared_ptr<AppItem> appItem);
  26. const std::shared_ptr<AppItem> getAppItem() const;
  27. void setCurrentScreenshot(int screenshotIndex);
  28. virtual void setScroll(float position);
  29. virtual float getScroll();
  30. virtual const cpp3ds::Vector2f &getScrollSize();
  31. protected:
  32. virtual void draw(cpp3ds::RenderTarget &target, cpp3ds::RenderStates states) const;
  33. virtual void setValues(int tweenType, float *newValues);
  34. virtual int getValues(int tweenType, float *returnValues);
  35. void updateInfo();
  36. private:
  37. void setDescription(const rapidjson::Value &jsonDescription);
  38. void setScreenshots(const rapidjson::Value &jsonScreenshots);
  39. void addScreenshot(int index, const rapidjson::Value &jsonScreenshot);
  40. cpp3ds::Sprite m_icon;
  41. cpp3ds::Text m_textTitle;
  42. util3ds::TweenText m_textDescription;
  43. cpp3ds::Text m_textTitleId;
  44. float m_descriptionVelocity;
  45. cpp3ds::RectangleShape m_fadeTextRect;
  46. bool m_isDemoInstalled;
  47. cpp3ds::Text m_textDemo;
  48. cpp3ds::Text m_textIconDemo;
  49. util3ds::TweenText m_textDownload;
  50. util3ds::TweenText m_textDelete;
  51. util3ds::TweenText m_textExecute;
  52. util3ds::TweenText m_textSleepDownload;
  53. std::vector<std::unique_ptr<cpp3ds::Texture>> m_screenshotTopTextures;
  54. std::vector<std::unique_ptr<cpp3ds::Texture>> m_screenshotBottomTextures;
  55. std::vector<std::unique_ptr<cpp3ds::Sprite>> m_screenshotTops;
  56. std::vector<std::unique_ptr<cpp3ds::Sprite>> m_screenshotBottoms;
  57. int m_currentScreenshot;
  58. util3ds::TweenSprite m_screenshotTopTop;
  59. util3ds::TweenSprite m_screenshotTopBottom;
  60. util3ds::TweenSprite m_screenshotBottom;
  61. util3ds::TweenText m_arrowLeft;
  62. util3ds::TweenText m_arrowRight;
  63. util3ds::TweenText m_close;
  64. cpp3ds::RectangleShape m_screenshotsBackground;
  65. cpp3ds::Text m_textScreenshotsEmpty;
  66. util3ds::TweenText m_textNothingSelected;
  67. cpp3ds::RectangleShape m_fadeRect;
  68. std::shared_ptr<AppItem> m_appItem;
  69. TweenEngine::TweenManager m_tweenManager;
  70. ScrollBar m_scrollbar;
  71. cpp3ds::Vector2f m_scrollSize;
  72. float m_scrollPos;
  73. };
  74. } // namepace FreeShop
  75. #endif // FREESHOP_APPINFO_HPP