AppItem.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #ifndef FREESHOP_APPITEM_HPP
  2. #define FREESHOP_APPITEM_HPP
  3. #include <memory>
  4. #include <cpp3ds/Graphics/Drawable.hpp>
  5. #include <cpp3ds/Graphics/Texture.hpp>
  6. #include <cpp3ds/Graphics/Sprite.hpp>
  7. #include <rapidjson/document.h>
  8. #include <cpp3ds/System/Thread.hpp>
  9. #include <cpp3ds/System/Lock.hpp>
  10. #include <cpp3ds/System/Mutex.hpp>
  11. #include "GUI/NinePatch.hpp"
  12. #include "TweenObjects.hpp"
  13. #ifndef EMULATION
  14. #include <3ds.h>
  15. #endif
  16. namespace FreeShop {
  17. class AppItem : public std::enable_shared_from_this<AppItem> {
  18. public:
  19. enum Region {
  20. Japan = 1 << 0,
  21. USA = 1 << 1,
  22. Europe = 1 << 2,
  23. Australia = 1 << 3,
  24. China = 1 << 4,
  25. Korea = 1 << 5,
  26. Taiwan = 1 << 6,
  27. Free = 0x7FFFFFFF,
  28. };
  29. enum Language {
  30. Japanese = 1 << 0,
  31. English = 1 << 1,
  32. Spanish = 1 << 2,
  33. French = 1 << 3,
  34. German = 1 << 4,
  35. Italian = 1 << 5,
  36. Dutch = 1 << 6,
  37. Portuguese = 1 << 7,
  38. Russian = 1 << 8,
  39. };
  40. AppItem();
  41. ~AppItem();
  42. void loadFromJSON(const char* titleId, const rapidjson::Value &json);
  43. void loadFromSystemTitleId(cpp3ds::Uint64 titleId);
  44. const cpp3ds::String &getTitle() const;
  45. const std::string &getNormalizedTitle() const;
  46. cpp3ds::Uint64 getTitleId() const;
  47. const std::string &getTitleIdStr() const;
  48. const std::string &getContentId() const;
  49. const std::string &getUriRegion() const;
  50. int getRegions() const;
  51. int getLanguages() const;
  52. const std::vector<char> &getSeed() const;
  53. cpp3ds::Uint64 getFilesize() const;
  54. void setInstalled(bool installed);
  55. bool isInstalled() const;
  56. const std::string getJsonFilename() const;
  57. bool isCached() const;
  58. const cpp3ds::Texture* getIcon(cpp3ds::IntRect &outRect) const;
  59. int getIconIndex() const;
  60. const std::vector<int> &getGenres() const;
  61. int getPlatform() const;
  62. int getPublisher() const;
  63. const std::vector<int> &getFeatures() const;
  64. float getVoteScore() const;
  65. int getVoteCount() const;
  66. time_t getReleaseDate() const;
  67. const std::string &getProductCode() const;
  68. void queueForInstall();
  69. void queueForSleepInstall(bool installRelated = true, bool isDemo = false);
  70. void queueForSleepInstallThread();
  71. void removeSleepInstall(bool removeRelated = true);
  72. void askUserToRemove(cpp3ds::Uint64 titleID, cpp3ds::String titleName);
  73. const std::vector<cpp3ds::Uint64> &getUpdates() const;
  74. const std::vector<cpp3ds::Uint64> &getDemos() const;
  75. const std::vector<cpp3ds::Uint64> &getDLC() const;
  76. bool isSleepBusy() const;
  77. void setSleepBusy(bool newState);
  78. private:
  79. void setIconIndex(size_t iconIndex);
  80. cpp3ds::String m_title;
  81. std::string m_normalizedTitle;
  82. cpp3ds::Uint64 m_filesize;
  83. cpp3ds::Uint64 m_titleId;
  84. std::string m_titleIdStr;
  85. std::string m_contentId;
  86. std::string m_uriRegion;
  87. std::vector<char> m_seed;
  88. std::vector<int> m_genres;
  89. std::vector<int> m_features;
  90. int m_platform;
  91. int m_publisher;
  92. int m_languages;
  93. int m_regions;
  94. float m_voteScore;
  95. int m_voteCount;
  96. time_t m_releaseDate;
  97. int m_iconIndex;
  98. std::string m_productCode;
  99. bool m_isSleepBusy;
  100. bool m_sleepInstallRelated;
  101. bool m_sleepInstallDemo;
  102. bool m_removeSleepRelated;
  103. std::vector<cpp3ds::Uint64> m_updates;
  104. std::vector<cpp3ds::Uint64> m_demos;
  105. std::vector<cpp3ds::Uint64> m_dlc;
  106. bool m_installed;
  107. cpp3ds::Texture *m_iconTexture;
  108. cpp3ds::Texture *m_systemIconTexture;
  109. cpp3ds::IntRect m_iconRect;
  110. cpp3ds::Thread m_threadSleepInstall;
  111. cpp3ds::Mutex m_mutexSleepInstall;
  112. };
  113. } // namepace FreeShop
  114. #endif // FREESHOP_APPITEM_HPP