| 1 | #ifndef GAME_CLIENT_COMPONENTS_COMMUNITY_ICONS_H |
| 2 | #define |
| 3 | |
| 4 | #include <base/hash.h> |
| 5 | |
| 6 | #include <engine/graphics.h> |
| 7 | #include <engine/serverbrowser.h> |
| 8 | #include <engine/shared/http.h> |
| 9 | #include <engine/shared/jobs.h> |
| 10 | |
| 11 | #include <game/client/component.h> |
| 12 | #include <game/client/ui_rect.h> |
| 13 | |
| 14 | #include <optional> |
| 15 | |
| 16 | class |
| 17 | { |
| 18 | friend class CCommunityIcons; |
| 19 | |
| 20 | private: |
| 21 | char [CServerInfo::MAX_COMMUNITY_ID_LENGTH]; |
| 22 | SHA256_DIGEST ; |
| 23 | IGraphics::CTextureHandle ; |
| 24 | IGraphics::CTextureHandle ; |
| 25 | }; |
| 26 | |
| 27 | class : public CComponentInterfaces |
| 28 | { |
| 29 | public: |
| 30 | const CCommunityIcon *(const char *); |
| 31 | void (const CCommunityIcon *pIcon, CUIRect Rect, bool Active); |
| 32 | void (); |
| 33 | void (); |
| 34 | void (); |
| 35 | |
| 36 | private: |
| 37 | class |
| 38 | { |
| 39 | protected: |
| 40 | CCommunityIcons *; |
| 41 | char [CServerInfo::MAX_COMMUNITY_ID_LENGTH]; |
| 42 | char [IO_MAX_PATH_LENGTH]; |
| 43 | int ; |
| 44 | bool = false; |
| 45 | SHA256_DIGEST ; |
| 46 | |
| 47 | (CCommunityIcons *, const char *, int StorageType); |
| 48 | |
| 49 | public: |
| 50 | const char *() const { return m_aCommunityId; } |
| 51 | bool () const { return m_Success; } |
| 52 | const SHA256_DIGEST &() const { return m_Sha256; } |
| 53 | virtual () = default; |
| 54 | }; |
| 55 | |
| 56 | class : public IJob, public CAbstractCommunityIconJob |
| 57 | { |
| 58 | CImageInfo ; |
| 59 | CImageInfo ; |
| 60 | |
| 61 | protected: |
| 62 | void () override; |
| 63 | |
| 64 | public: |
| 65 | (CCommunityIcons *, const char *, int StorageType); |
| 66 | () override; |
| 67 | |
| 68 | CImageInfo &() { return m_ImageInfo; } |
| 69 | CImageInfo &() { return m_ImageInfoGrayscale; } |
| 70 | }; |
| 71 | |
| 72 | class : public CHttpRequest, public CAbstractCommunityIconJob |
| 73 | { |
| 74 | public: |
| 75 | (CCommunityIcons *, const char *, const char *pUrl, const SHA256_DIGEST &Sha256); |
| 76 | }; |
| 77 | |
| 78 | std::vector<CCommunityIcon> ; |
| 79 | std::deque<std::shared_ptr<CCommunityIconLoadJob>> ; |
| 80 | std::deque<std::shared_ptr<CCommunityIconDownloadJob>> ; |
| 81 | std::optional<SHA256_DIGEST> ; |
| 82 | static int (const char *pName, int IsDir, int DirType, void *pUser); |
| 83 | bool (const char *pPath, int DirType, CImageInfo &Info, CImageInfo &InfoGrayscale, SHA256_DIGEST &Sha256); |
| 84 | void (const char *, CImageInfo &Info, CImageInfo &InfoGrayscale, const SHA256_DIGEST &Sha256); |
| 85 | }; |
| 86 | |
| 87 | #endif |
| 88 | |