AppInfo.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 <cpp3ds/System/Thread.hpp>
  9. #include "TweenObjects.hpp"
  10. #include "AppItem.hpp"
  11. #include "RichText.hpp"
  12. #include "AppStats.hpp"
  13. #include <cpp3ds/Window/Window.hpp>
  14. #include "States/State.hpp"
  15. #include "TweenObjects.hpp"
  16. #include "GUI/Scrollable.hpp"
  17. #include "GUI/ScrollBar.hpp"
  18. namespace FreeShop {
  19. class AppInfo : public cpp3ds::Drawable, public util3ds::TweenTransformable<cpp3ds::Transformable>, public Scrollable {
  20. public:
  21. static const int ALPHA = 11;
  22. AppInfo();
  23. ~AppInfo();
  24. static AppInfo &getInstance();
  25. void drawTop(cpp3ds::Window &window);
  26. bool processEvent(const cpp3ds::Event& event);
  27. void update(float delta);
  28. void loadApp(std::shared_ptr<AppItem> appItem);
  29. const std::shared_ptr<AppItem> getAppItem() const;
  30. void setCurrentScreenshot(int screenshotIndex);
  31. virtual void setScroll(float position);
  32. virtual float getScroll();
  33. virtual const cpp3ds::Vector2f &getScrollSize();
  34. void setCanDraw(bool canDraw);
  35. bool canDraw();
  36. protected:
  37. virtual void draw(cpp3ds::RenderTarget &target, cpp3ds::RenderStates states) const;
  38. virtual void setValues(int tweenType, float *newValues);
  39. virtual int getValues(int tweenType, float *returnValues);
  40. void updateInfo();
  41. private:
  42. void setDescription(const rapidjson::Value &jsonDescription);
  43. void setScreenshots(const rapidjson::Value &jsonScreenshots);
  44. void addScreenshot(int index, const rapidjson::Value &jsonScreenshot);
  45. void addEmptyScreenshot(int index, bool isUpper);
  46. void addInfoToDescription(const rapidjson::Value &jsonTitle);
  47. cpp3ds::String calculateWordWrapping(cpp3ds::String sentence);
  48. void setBanner(const rapidjson::Value &jsonBanner);
  49. void closeBanner();
  50. cpp3ds::Sprite m_icon;
  51. util3ds::TweenText m_textTitle;
  52. util3ds::RichText m_textDescriptionDrawn;
  53. util3ds::TweenText m_textDescription;
  54. util3ds::TweenText m_textLittleDescription;
  55. cpp3ds::Text m_textTitleId;
  56. float m_descriptionVelocity;
  57. cpp3ds::RectangleShape m_fadeTextRect;
  58. bool m_isDemoInstalled;
  59. cpp3ds::Text m_textDemo;
  60. cpp3ds::Text m_textIconDemo;
  61. util3ds::TweenText m_textDownload;
  62. util3ds::TweenText m_textDelete;
  63. util3ds::TweenText m_textExecute;
  64. util3ds::TweenText m_textSleepDownload;
  65. std::vector<std::unique_ptr<cpp3ds::Texture>> m_screenshotTopTextures;
  66. std::vector<std::unique_ptr<cpp3ds::Texture>> m_screenshotBottomTextures;
  67. std::vector<std::unique_ptr<cpp3ds::Sprite>> m_screenshotTops;
  68. std::vector<std::unique_ptr<cpp3ds::Sprite>> m_screenshotBottoms;
  69. int m_currentScreenshot;
  70. util3ds::TweenSprite m_screenshotTopTop;
  71. util3ds::TweenSprite m_screenshotTopBottom;
  72. util3ds::TweenSprite m_screenshotBottom;
  73. util3ds::TweenText m_arrowLeft;
  74. util3ds::TweenText m_arrowRight;
  75. util3ds::TweenText m_close;
  76. cpp3ds::RectangleShape m_screenshotsBackground;
  77. cpp3ds::RectangleShape m_separator;
  78. cpp3ds::Text m_textScreenshotsEmpty;
  79. util3ds::TweenText m_textNothingSelected;
  80. cpp3ds::RectangleShape m_fadeRect;
  81. bool m_isBannerLoaded;
  82. cpp3ds::Texture m_gameBannerTexture;
  83. util3ds::TweenSprite m_gameBanner;
  84. util3ds::TweenRectangleShape m_overlay;
  85. util3ds::TweenSprite m_topIcon;
  86. std::shared_ptr<AppItem> m_appItem;
  87. AppStats m_appStats;
  88. bool m_showAppStats;
  89. cpp3ds::Thread m_threadUninstallGame;
  90. cpp3ds::Thread m_threadUninstallDemo;
  91. void uninstallGame();
  92. void uninstallDemo();
  93. bool m_canDraw;
  94. TweenEngine::TweenManager m_tweenManager;
  95. ScrollBar m_scrollbar;
  96. cpp3ds::Vector2f m_scrollSize;
  97. float m_scrollPos;
  98. };
  99. } // namepace FreeShop
  100. #endif // FREESHOP_APPINFO_HPP