InstalledList.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef FREESHOP_INSTALLEDLIST_HPP
  2. #define FREESHOP_INSTALLEDLIST_HPP
  3. #include <TweenEngine/TweenManager.h>
  4. #include <cpp3ds/Window/Event.hpp>
  5. #include <cpp3ds/System/Mutex.hpp>
  6. #include "InstalledItem.hpp"
  7. #include "InstalledOptions.hpp"
  8. #include "TweenObjects.hpp"
  9. #include "GUI/Scrollable.hpp"
  10. #include "States/BrowseState.hpp"
  11. namespace FreeShop {
  12. class InstalledList : public cpp3ds::Drawable, public Scrollable, public util3ds::TweenTransformable<cpp3ds::Transformable> {
  13. public:
  14. enum SortType {
  15. Name,
  16. Size,
  17. VoteScore,
  18. VoteCount,
  19. ReleaseDate,
  20. };
  21. static InstalledList &getInstance();
  22. void refresh();
  23. void setSortType(SortType sortType, bool ascending);
  24. void filterBySearch(std::string search);
  25. void update(float delta);
  26. bool processEvent(const cpp3ds::Event& event);
  27. virtual void setScroll(float position);
  28. virtual float getScroll();
  29. virtual const cpp3ds::Vector2f &getScrollSize();
  30. static bool isInstalled(cpp3ds::Uint64 titleId);
  31. std::vector<std::shared_ptr<InstalledItem>> &getList() { return m_installedItems; }
  32. void setDrawList(bool canDrawList);
  33. bool canDrawList();
  34. int getGameCount();
  35. protected:
  36. InstalledList();
  37. virtual void draw(cpp3ds::RenderTarget& target, cpp3ds::RenderStates states) const;
  38. void repositionItems();
  39. void expandItem(InstalledItem *item);
  40. void sort();
  41. private:
  42. cpp3ds::Mutex m_mutexRefresh;
  43. bool m_cardInserted;
  44. std::vector<cpp3ds::Uint64> m_installedTitleIds;
  45. std::vector<std::shared_ptr<InstalledItem>> m_installedItems;
  46. std::vector<std::shared_ptr<InstalledItem>> m_installedItemsFiltered;
  47. TweenEngine::TweenManager m_tweenManager;
  48. float m_scrollPos;
  49. cpp3ds::Vector2f m_size;
  50. InstalledItem *m_expandedItem;
  51. InstalledOptions m_options;
  52. bool m_isUpdatingList;
  53. int m_gameCount;
  54. bool m_canDrawList;
  55. SortType m_sortType;
  56. bool m_sortAscending;
  57. std::string m_currentSearch;
  58. };
  59. } // namespace FreeShop
  60. #endif // FREESHOP_INSTALLEDLIST_HPP