BrowseState.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #ifndef FREESHOP_BROWSESTATE_HPP
  2. #define FREESHOP_BROWSESTATE_HPP
  3. #include "State.hpp"
  4. #include "../AppList.hpp"
  5. #include "../AppInfo.hpp"
  6. #include "../DownloadQueue.hpp"
  7. #include "../Keyboard/Keyboard.hpp"
  8. #include "../RichText.hpp"
  9. #include "../IconSet.hpp"
  10. #include "../BotInformations.hpp"
  11. #include "../TopInformations.hpp"
  12. #include "../GUI/Settings.hpp"
  13. #include "../GUI/ScrollBar.hpp"
  14. #include "../MusicBCSTM.hpp"
  15. #include "../MusicMP3.hpp"
  16. #include <cpp3ds/Graphics/Sprite.hpp>
  17. #include <cpp3ds/Graphics/Texture.hpp>
  18. #include <cpp3ds/System/Clock.hpp>
  19. #include <cpp3ds/Graphics/RectangleShape.hpp>
  20. #include <TweenEngine/TweenManager.h>
  21. #include <cpp3ds/Audio/SoundBuffer.hpp>
  22. #include <cpp3ds/Audio/Sound.hpp>
  23. #include <cpp3ds/Audio/Music.hpp>
  24. #include <Gwen/Renderers/cpp3ds.h>
  25. #include <Gwen/Input/cpp3ds.h>
  26. #include <Gwen/Skins/Simple.h>
  27. #include <Gwen/Skins/TexturedBase.h>
  28. namespace FreeShop {
  29. class BrowseState : public State
  30. {
  31. public:
  32. BrowseState(StateStack& stack, Context& context, StateCallback callback);
  33. ~BrowseState();
  34. virtual void renderTopScreen(cpp3ds::Window& window);
  35. virtual void renderBottomScreen(cpp3ds::Window& window);
  36. virtual bool update(float delta);
  37. virtual bool processEvent(const cpp3ds::Event& event);
  38. bool playBGM(const std::string &filename);
  39. bool playBGMeShop();
  40. void stopBGM();
  41. void reloadKeyboard();
  42. int getMode();
  43. bool isAppInfoLoaded();
  44. bool getJapKeyboard();
  45. bool getTIDKeyboard();
  46. void setInstalledListSearchText(std::string text);
  47. static cpp3ds::Clock clockDownloadInactivity;
  48. void wokeUp();
  49. std::string getCtrSdPath();
  50. void blockControls(bool isControlsBlocked);
  51. bool isControlsBlocked();
  52. void settingsSaveToConfig();
  53. private:
  54. enum Mode {
  55. Info = 0,
  56. App,
  57. Downloads,
  58. Installed,
  59. Settings,
  60. Search,
  61. };
  62. void initialize();
  63. void setMode(Mode mode);
  64. void loadApp();
  65. private:
  66. AppInfo m_appInfo;
  67. util3ds::TweenText m_textListEmpty;
  68. TweenEngine::TweenManager m_tweenManager;
  69. float m_appListPositionX;
  70. cpp3ds::Thread m_threadInitialize;
  71. cpp3ds::Thread m_threadLoadApp;
  72. bool m_threadBusy;
  73. IconSet m_iconSet;
  74. IconSet m_iconInfo;
  75. BotInformations m_botInfos;
  76. TopInformations m_topInfos;
  77. size_t m_activeDownloadCount;
  78. util3ds::TweenText m_textActiveDownloads;
  79. util3ds::TweenText m_textInstalledCount;
  80. ScrollBar m_scrollbarInstalledList;
  81. ScrollBar m_scrollbarDownloadQueue;
  82. int m_counter;
  83. bool m_isControlsBlocked;
  84. // Sounds
  85. cpp3ds::Sound m_soundClick;
  86. cpp3ds::Sound m_soundLoading;
  87. MusicMP3 m_musicLoopMP3;
  88. MusicBCSTM m_musicLoopBCSTM;
  89. cpp3ds::Music m_musicLoop;
  90. int m_musicMode;
  91. std::string m_musicFileName;
  92. bool m_isSliderOff;
  93. // Keyboard
  94. util3ds::Keyboard m_keyboard;
  95. cpp3ds::String m_lastKeyboardInput;
  96. std::vector<util3ds::RichText> m_textMatches;
  97. std::vector<int> m_keyHistory;
  98. bool m_isJapKeyboard;
  99. bool m_isTIDKeyboard;
  100. // Transitioning
  101. bool m_isTransitioning;
  102. Mode m_mode;
  103. util3ds::TweenRectangleShape m_whiteScreen;
  104. util3ds::TweenableView m_bottomView;
  105. // GWEN
  106. Gwen::Renderer::cpp3dsRenderer *m_gwenRenderer;
  107. Gwen::Skin::TexturedBase *m_gwenSkin;
  108. GUI::Settings *m_settingsGUI;
  109. //Nintendo 3DS SD Folder
  110. std::string m_ctrSdPath;
  111. // Installed list search box
  112. util3ds::TweenText m_textSearchInstalledList;
  113. util3ds::TweenRectangleShape m_textBoxInstalledList;
  114. };
  115. extern BrowseState *g_browseState;
  116. extern bool g_isLatestFirmwareVersion;
  117. } // namespace FreeShop
  118. #endif // FREESHOP_BROWSESTATE_HPP