AppItem.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 "GUI/NinePatch.hpp"
  9. #include "TweenObjects.hpp"
  10. namespace FreeShop {
  11. class AppItem : public std::enable_shared_from_this<AppItem> {
  12. public:
  13. enum Region {
  14. Japan = 1 << 0,
  15. USA = 1 << 1,
  16. Europe = 1 << 2,
  17. Australia = 1 << 3,
  18. China = 1 << 4,
  19. Korea = 1 << 5,
  20. Taiwan = 1 << 6,
  21. };
  22. enum Language {
  23. Japanese = 1 << 0,
  24. English = 1 << 1,
  25. Spanish = 1 << 2,
  26. French = 1 << 3,
  27. German = 1 << 4,
  28. Italian = 1 << 5,
  29. Dutch = 1 << 6,
  30. Portuguese = 1 << 7,
  31. Russian = 1 << 8,
  32. };
  33. AppItem();
  34. ~AppItem();
  35. void loadFromJSON(const char* titleId, const rapidjson::Value &json);
  36. void loadFromSystemTitleId(cpp3ds::Uint64 titleId);
  37. const cpp3ds::String &getTitle() const;
  38. const std::string &getNormalizedTitle() const;
  39. cpp3ds::Uint64 getTitleId() const;
  40. const std::string &getTitleIdStr() const;
  41. const std::string &getContentId() const;
  42. const std::string &getUriRegion() const;
  43. int getRegions() const;
  44. int getLanguages() const;
  45. const std::vector<char> &getSeed() const;
  46. cpp3ds::Uint64 getFilesize() const;
  47. void setInstalled(bool installed);
  48. bool isInstalled() const;
  49. const std::string getJsonFilename() const;
  50. bool isCached() const;
  51. const cpp3ds::Texture* getIcon(cpp3ds::IntRect &outRect) const;
  52. int getIconIndex() const;
  53. const std::vector<int> &getGenres() const;
  54. int getPlatform() const;
  55. int getPublisher() const;
  56. float getVoteScore() const;
  57. int getVoteCount() const;
  58. time_t getReleaseDate() const;
  59. const std::string &getProductCode() const;
  60. void queueForInstall();
  61. const std::vector<cpp3ds::Uint64> &getUpdates() const;
  62. const std::vector<cpp3ds::Uint64> &getDemos() const;
  63. const std::vector<cpp3ds::Uint64> &getDLC() const;
  64. private:
  65. void setIconIndex(size_t iconIndex);
  66. cpp3ds::String m_title;
  67. std::string m_normalizedTitle;
  68. cpp3ds::Uint64 m_filesize;
  69. cpp3ds::Uint64 m_titleId;
  70. std::string m_titleIdStr;
  71. std::string m_contentId;
  72. std::string m_uriRegion;
  73. std::vector<char> m_seed;
  74. std::vector<int> m_genres;
  75. std::vector<int> m_features;
  76. int m_platform;
  77. int m_publisher;
  78. int m_languages;
  79. int m_regions;
  80. float m_voteScore;
  81. int m_voteCount;
  82. time_t m_releaseDate;
  83. int m_iconIndex;
  84. std::string m_productCode;
  85. std::vector<cpp3ds::Uint64> m_updates;
  86. std::vector<cpp3ds::Uint64> m_demos;
  87. std::vector<cpp3ds::Uint64> m_dlc;
  88. bool m_installed;
  89. cpp3ds::Texture *m_iconTexture;
  90. cpp3ds::Texture *m_systemIconTexture;
  91. cpp3ds::IntRect m_iconRect;
  92. };
  93. } // namepace FreeShop
  94. #endif // FREESHOP_APPITEM_HPP