diff options
Diffstat (limited to 'src/gui/windows')
-rw-r--r-- | src/gui/windows/socialwindow.h | 162 | ||||
-rw-r--r-- | src/gui/windows/textdialog.h | 62 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.h | 292 | ||||
-rw-r--r-- | src/gui/windows/whoisonline.h | 169 |
4 files changed, 344 insertions, 341 deletions
diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h index 6ce903a5a..80cc38b0e 100644 --- a/src/gui/windows/socialwindow.h +++ b/src/gui/windows/socialwindow.h @@ -50,127 +50,127 @@ class SocialWindow final : public Window, private ActionListener, public PlayerRelationsListener { -public: - SocialWindow(); + public: + SocialWindow(); - A_DELETE_COPY(SocialWindow) + A_DELETE_COPY(SocialWindow) - ~SocialWindow(); + ~SocialWindow(); - void postInit() override final; + void postInit() override final; - bool addTab(Guild *const guild); + bool addTab(Guild *const guild); - bool removeTab(Guild *const guild); + bool removeTab(Guild *const guild); - bool addTab(Party *const party); + bool addTab(Party *const party); - bool removeTab(Party *const party); + bool removeTab(Party *const party); - void action(const ActionEvent &event) override final; + void action(const ActionEvent &event) override final; - void showGuildInvite(const std::string &restrict guildName, - const int guildId, - const std::string &restrict inviterName); + void showGuildInvite(const std::string &restrict guildName, + const int guildId, + const std::string &restrict inviterName); - void showGuildCreate(); + void showGuildCreate(); - void showPartyInvite(const std::string &restrict partyName, - const std::string &restrict inviter = ""); + void showPartyInvite(const std::string &restrict partyName, + const std::string &restrict inviter = ""); - void showPartyCreate(); + void showPartyCreate(); - void updateActiveList(); + void updateActiveList(); - void updateAvatar(const std::string &name); + void updateAvatar(const std::string &name); - void resetDamage(const std::string &name); + void resetDamage(const std::string &name); - void slowLogic(); + void slowLogic(); - void updatePortals(); + void updatePortals(); - void updatePortalNames(); + void updatePortalNames(); - void updateParty(); + void updateParty(); - int getPortalIndex(const int x, const int y) A_WARN_UNUSED; + int getPortalIndex(const int x, const int y) A_WARN_UNUSED; - void addPortal(const int x, const int y); + void addPortal(const int x, const int y); - void removePortal(const int x, const int y); + void removePortal(const int x, const int y); - void nextTab(); + void nextTab(); - void prevTab(); + void prevTab(); - const Map* getMap() const A_WARN_UNUSED - { return mMap; } + const Map* getMap() const A_WARN_UNUSED + { return mMap; } - void setMap(Map *const map) - { mMap = map; mProcessedPortals = false; } + void setMap(Map *const map) + { mMap = map; mProcessedPortals = false; } - bool getProcessedPortals() const A_WARN_UNUSED - { return mProcessedPortals; } + bool getProcessedPortals() const A_WARN_UNUSED + { return mProcessedPortals; } - void setProcessedPortals(const bool n) - { mProcessedPortals = n; } + void setProcessedPortals(const bool n) + { mProcessedPortals = n; } - void selectPortal(const unsigned num); + void selectPortal(const unsigned num); - void updateAttackFilter(); + void updateAttackFilter(); - void updatePickupFilter(); + void updatePickupFilter(); - void widgetResized(const Event &event) override final; + void widgetResized(const Event &event) override final; - void setCounter(const SocialTab *const tab, const std::string &str); + void setCounter(const SocialTab *const tab, const std::string &str); - void updateGuildCounter(const int online = 0, const int total = 0); + void updateGuildCounter(const int online = 0, const int total = 0); - void updatedPlayer(const std::string &name); + void updatedPlayer(const std::string &name); - void updateAll(); + void updateAll(); #ifdef USE_PROFILER - void logicChildren(); + void logicChildren(); #endif -protected: - friend class SocialTab; - typedef std::map<Guild*, SocialTab*> GuildMap; - typedef std::map<Party*, SocialTab*> PartyMap; - - void updateButtons(); - - int mGuildInvited; - ConfirmDialog *mGuildAcceptDialog; - TextDialog *mGuildCreateDialog; - std::string mPartyInviter; - GuildMap mGuilds; - PartyMap mParties; - - ConfirmDialog *mPartyAcceptDialog; - TextDialog *mPartyCreateDialog; - - SocialTab *mAttackFilter; - SocialTab *mPickupFilter; - SocialTab *mPlayers; - SocialTab *mNavigation; - SocialTab *mFriends; - - CreatePartyPopup *mCreatePopup; - - Button *mCreateButton; - Button *mInviteButton; - Button *mLeaveButton; - Label *mCountLabel; - TabbedArea *mTabs; - Map *mMap; - - int mLastUpdateTime; - bool mNeedUpdate; - bool mProcessedPortals; + protected: + friend class SocialTab; + typedef std::map<Guild*, SocialTab*> GuildMap; + typedef std::map<Party*, SocialTab*> PartyMap; + + void updateButtons(); + + int mGuildInvited; + ConfirmDialog *mGuildAcceptDialog; + TextDialog *mGuildCreateDialog; + std::string mPartyInviter; + GuildMap mGuilds; + PartyMap mParties; + + ConfirmDialog *mPartyAcceptDialog; + TextDialog *mPartyCreateDialog; + + SocialTab *mAttackFilter; + SocialTab *mPickupFilter; + SocialTab *mPlayers; + SocialTab *mNavigation; + SocialTab *mFriends; + + CreatePartyPopup *mCreatePopup; + + Button *mCreateButton; + Button *mInviteButton; + Button *mLeaveButton; + Label *mCountLabel; + TabbedArea *mTabs; + Map *mMap; + + int mLastUpdateTime; + bool mNeedUpdate; + bool mProcessedPortals; }; extern SocialWindow *socialWindow; diff --git a/src/gui/windows/textdialog.h b/src/gui/windows/textdialog.h index 8e69e8a3d..f1dc70792 100644 --- a/src/gui/windows/textdialog.h +++ b/src/gui/windows/textdialog.h @@ -39,47 +39,47 @@ class TextField; class TextDialog final : public Window, public ActionListener { -public: - /** - * Constructor. - * - * @see Window::Window - */ - TextDialog(const std::string &restrict title, - const std::string &restrict msg, - Window *const parent = nullptr, - const bool isPassword = false); + public: + /** + * Constructor. + * + * @see Window::Window + */ + TextDialog(const std::string &restrict title, + const std::string &restrict msg, + Window *const parent = nullptr, + const bool isPassword = false); - A_DELETE_COPY(TextDialog) + A_DELETE_COPY(TextDialog) - ~TextDialog(); + ~TextDialog(); - void postInit() override final; + void postInit() override final; - /** - * Called when receiving actions from the widgets. - */ - void action(const ActionEvent &event) override final; + /** + * Called when receiving actions from the widgets. + */ + void action(const ActionEvent &event) override final; - /** - * Get the text in the textfield - */ - const std::string &getText() const A_WARN_UNUSED; + /** + * Get the text in the textfield + */ + const std::string &getText() const A_WARN_UNUSED; - void setText(const std::string &text); + void setText(const std::string &text); - static bool isActive() A_WARN_UNUSED - { return instances; } + static bool isActive() A_WARN_UNUSED + { return instances; } - void close() override final; + void close() override final; -private: - static int instances; + private: + static int instances; - TextField *mTextField; - PasswordField *mPasswordField; - Button *mOkButton; - bool mEnabledKeyboard; + TextField *mTextField; + PasswordField *mPasswordField; + Button *mOkButton; + bool mEnabledKeyboard; }; #endif // GUI_WINDOWS_TEXTDIALOG_H diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index fec31fce0..59afa5a24 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -60,204 +60,206 @@ class UpdaterWindow final : public Window, public LinkHandler, public KeyListener { - public: - /** - * Constructor. - * - * @param updateHost Host where to get the updated files. - * @param updatesDir Directory where to store updates (should be absolute - * and already created). - * @param applyUpdates If true, the update window will pass the updates to teh - * resource manager - */ - UpdaterWindow(const std::string &restrict updateHost, - const std::string &restrict updatesDir, - const bool applyUpdates, const int updateType); + public: + /** + * Constructor. + * + * @param updateHost Host where to get the updated files. + * @param updatesDir Directory where to store updates (should be + * absolute and already created). + * @param applyUpdates If true, the update window will pass the updates + * to teh resource manager. + */ + UpdaterWindow(const std::string &restrict updateHost, + const std::string &restrict updatesDir, + const bool applyUpdates, const int updateType); - A_DELETE_COPY(UpdaterWindow) + A_DELETE_COPY(UpdaterWindow) - /** - * Destructor - */ - ~UpdaterWindow(); + /** + * Destructor + */ + ~UpdaterWindow(); - void postInit() override final; + void postInit() override final; - /** - * Set's progress bar status - */ - void setProgress(const float p); - - /** - * Set's label above progress - */ - void setLabel(const std::string &); + /** + * Set's progress bar status + */ + void setProgress(const float p); + + /** + * Set's label above progress + */ + void setLabel(const std::string &); - /** - * Enables play button - */ - void enable(); + /** + * Enables play button + */ + void enable(); - /** - * Loads and display news. Assumes the news file contents have been loaded - * into the memory buffer. - */ - void loadNews(); + /** + * Loads and display news. Assumes the news file contents have been + * loaded into the memory buffer. + */ + void loadNews(); - void loadPatch(); + void loadPatch(); - void action(const ActionEvent &event) override final; + void action(const ActionEvent &event) override final; - void keyPressed(KeyEvent &event) override final; + void keyPressed(KeyEvent &event) override final; - void logic() override final; + void logic() override final; - void handleLink(const std::string &link, - MouseEvent *event A_UNUSED) override final; + void handleLink(const std::string &link, + MouseEvent *event A_UNUSED) override final; - void loadFile(std::string file); + void loadFile(std::string file); - void deleteSelf(); + void deleteSelf(); - static void loadLocalUpdates(const std::string &dir); + static void loadLocalUpdates(const std::string &dir); - static void unloadUpdates(const std::string &dir); + static void unloadUpdates(const std::string &dir); - static void addUpdateFile(const ResourceManager *const resman, - const std::string &restrict path, - const std::string &restrict fixPath, - const std::string &restrict file, - const bool append); + static void addUpdateFile(const ResourceManager *const resman, + const std::string &restrict path, + const std::string &restrict fixPath, + const std::string &restrict file, + const bool append); - static void removeUpdateFile(const ResourceManager *const resman, - const std::string &restrict path, - const std::string &restrict fixPath, - const std::string &filerestrict); + static void removeUpdateFile(const ResourceManager *const resman, + const std::string &restrict path, + const std::string &restrict fixPath, + const std::string &filerestrict); - static void loadManaPlusUpdates(const std::string &dir, - const ResourceManager *const resman); + static void loadManaPlusUpdates(const std::string &dir, + const ResourceManager *const resman); - static void unloadManaPlusUpdates(const std::string &dir, - const ResourceManager *const resman); + static void unloadManaPlusUpdates(const std::string &dir, + const ResourceManager *const resman); - static unsigned long getFileHash(const std::string &filePath); + static unsigned long getFileHash(const std::string &filePath); - static void loadMods(const std::string &dir, - const ResourceManager *const resman, - const std::vector<UpdateFile> &updateFiles); + static void loadMods(const std::string &dir, + const ResourceManager *const resman, + const std::vector<UpdateFile> &updateFiles); - static void loadDirMods(const std::string &dir); + static void loadDirMods(const std::string &dir); - static void unloadMods(const std::string &dir); + static void unloadMods(const std::string &dir); -private: - void download(); + private: + void download(); - /** - * Loads the updates this window has gotten into the resource manager - */ - void loadUpdates(); + /** + * Loads the updates this window has gotten into the resource manager + */ + void loadUpdates(); - /** - * A download callback for progress updates. - */ - static int updateProgress(void *ptr, DownloadStatus::Type status, - size_t dt, size_t dn); + /** + * A download callback for progress updates. + */ + static int updateProgress(void *ptr, DownloadStatus::Type status, + size_t dt, size_t dn); - /** - * A libcurl callback for writing to memory. - */ - static size_t memoryWrite(void *ptr, size_t size, size_t nmemb, - void *stream); + /** + * A libcurl callback for writing to memory. + */ + static size_t memoryWrite(void *ptr, size_t size, size_t nmemb, + void *stream); - static bool validateFile(const std::string &filePath, - const unsigned long hash) A_WARN_UNUSED; + static bool validateFile(const std::string &filePath, + const unsigned long hash) A_WARN_UNUSED; - enum UpdateDownloadStatus - { - UPDATE_ERROR = 0, - UPDATE_IDLE, - UPDATE_LIST, - UPDATE_COMPLETE, - UPDATE_NEWS, - UPDATE_RESOURCES, - UPDATE_PATCH, - UPDATE_LIST2, - UPDATE_RESOURCES2 - }; + enum UpdateDownloadStatus + { + UPDATE_ERROR = 0, + UPDATE_IDLE, + UPDATE_LIST, + UPDATE_COMPLETE, + UPDATE_NEWS, + UPDATE_RESOURCES, + UPDATE_PATCH, + UPDATE_LIST2, + UPDATE_RESOURCES2 + }; - /** The new progress value to be set in the logic method. */ - float mDownloadProgress; + /** The new progress value to be set in the logic method. */ + float mDownloadProgress; - /** Host where we get the updated files. */ - std::string mUpdateHost; + /** Host where we get the updated files. */ + std::string mUpdateHost; - /** Place where the updates are stored (absolute path). */ - std::string mUpdatesDir; + /** Place where the updates are stored (absolute path). */ + std::string mUpdatesDir; - std::string mUpdatesDirReal; + std::string mUpdatesDirReal; - /** The file currently downloading. */ - std::string mCurrentFile; + /** The file currently downloading. */ + std::string mCurrentFile; - /** The new label caption to be set in the logic method. */ - std::string mNewLabelCaption; + /** The new label caption to be set in the logic method. */ + std::string mNewLabelCaption; - // The mutex used to guard access to mNewLabelCaption - // and mDownloadProgress. - Mutex mDownloadMutex; + // The mutex used to guard access to mNewLabelCaption + // and mDownloadProgress. + Mutex mDownloadMutex; - /** The Adler32 checksum of the file currently downloading. */ - unsigned long mCurrentChecksum; + /** The Adler32 checksum of the file currently downloading. */ + unsigned long mCurrentChecksum; - /** Buffer for files downloaded to memory. */ - char *mMemoryBuffer; + /** Buffer for files downloaded to memory. */ + char *mMemoryBuffer; - /** Download handle. */ - Net::Download *mDownload; + /** Download handle. */ + Net::Download *mDownload; - /** List of files to download. */ - std::vector<UpdateFile> mUpdateFiles; + /** List of files to download. */ + std::vector<UpdateFile> mUpdateFiles; - /** List of temp files to download. */ - std::vector<UpdateFile> mTempUpdateFiles; + /** List of temp files to download. */ + std::vector<UpdateFile> mTempUpdateFiles; - std::string mUpdateServerPath; + std::string mUpdateServerPath; - Label *mLabel; /**< Progress bar caption. */ - Button *mCancelButton; /**< Button to stop the update process. */ - Button *mPlayButton; /**< Button to start playing. */ - ProgressBar *mProgressBar; /**< Update progress bar. */ - BrowserBox *mBrowserBox; /**< Box to display news. */ - ScrollArea *mScrollArea; /**< Used to scroll news box. */ + Label *mLabel; /**< Progress bar caption. */ + Button *mCancelButton; /**< Button to stop the update process. */ + Button *mPlayButton; /**< Button to start playing. */ + ProgressBar *mProgressBar; /**< Update progress bar. */ + BrowserBox *mBrowserBox; /**< Box to display news. */ + ScrollArea *mScrollArea; /**< Used to scroll news box. */ - /** Status of the current download. */ - UpdateDownloadStatus mDownloadStatus; + /** Status of the current download. */ + UpdateDownloadStatus mDownloadStatus; - /** Byte count currently downloaded in mMemoryBuffer. */ - int mDownloadedBytes; + /** Byte count currently downloaded in mMemoryBuffer. */ + int mDownloadedBytes; - /** Index of the file to be downloaded. */ - unsigned int mUpdateIndex; + /** Index of the file to be downloaded. */ + unsigned int mUpdateIndex; - /** Index offset for disaplay downloaded file. */ - unsigned int mUpdateIndexOffset; + /** Index offset for disaplay downloaded file. */ + unsigned int mUpdateIndexOffset; - int mUpdateType; + int mUpdateType; - /** A flag to indicate whether to use a memory buffer or a regular file. */ - bool mStoreInMemory; + /** A flag to indicate whether to use a memory buffer or a regular + * file. + */ + bool mStoreInMemory; - /** Flag that show if current download is complete. */ - bool mDownloadComplete; + /** Flag that show if current download is complete. */ + bool mDownloadComplete; - /** Flag that show if the user has canceled the update. */ - bool mUserCancel; + /** Flag that show if the user has canceled the update. */ + bool mUserCancel; - /** Tells ~UpdaterWindow() if it should load updates */ - bool mLoadUpdates; + /** Tells ~UpdaterWindow() if it should load updates */ + bool mLoadUpdates; - bool mValidateXml; + bool mValidateXml; }; extern UpdaterWindow *updaterWindow; diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index 6e49308d4..504013712 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -49,124 +49,125 @@ class WhoIsOnline final : public Window, public ActionListener, public ConfigListener { -public: - /** - * Constructor. - */ - WhoIsOnline(); + public: + /** + * Constructor. + */ + WhoIsOnline(); - A_DELETE_COPY(WhoIsOnline) + A_DELETE_COPY(WhoIsOnline) - /** - * Destructor - */ - ~WhoIsOnline(); + /** + * Destructor + */ + ~WhoIsOnline(); - void postInit() override final; + void postInit() override final; - /** - * Loads and display online list from the memory buffer. - */ - void loadWebList(); + /** + * Loads and display online list from the memory buffer. + */ + void loadWebList(); - void loadList(const std::vector<OnlinePlayer*> &list); + void loadList(const std::vector<OnlinePlayer*> &list); - void handleLink(const std::string& link, - MouseEvent *event) override final; + void handleLink(const std::string& link, + MouseEvent *event) override final; - void logic() override final; + void logic() override final; - void slowLogic(); + void slowLogic(); - void action(const ActionEvent &event) override final; + void action(const ActionEvent &event) override final; - void widgetResized(const Event &event) override final; + void widgetResized(const Event &event) override final; - const std::set<OnlinePlayer*> &getOnlinePlayers() const A_WARN_UNUSED - { return mOnlinePlayers; } + const std::set<OnlinePlayer*> &getOnlinePlayers() const A_WARN_UNUSED + { return mOnlinePlayers; } - const std::set<std::string> &getOnlineNicks() const A_WARN_UNUSED - { return mOnlineNicks; } + const std::set<std::string> &getOnlineNicks() const A_WARN_UNUSED + { return mOnlineNicks; } - void setAllowUpdate(const bool n) - { mAllowUpdate = n; } + void setAllowUpdate(const bool n) + { mAllowUpdate = n; } - void optionChanged(const std::string &name) override final; + void optionChanged(const std::string &name) override final; - void updateList(StringVect &list); + void updateList(StringVect &list); - void readFromWeb(); + void readFromWeb(); - static void setNeutralColor(OnlinePlayer *const player); + static void setNeutralColor(OnlinePlayer *const player); - void getPlayerNames(StringVect &names); + void getPlayerNames(StringVect &names); -private: - void download(); + private: + void download(); - void updateSize(); + void updateSize(); - void handlerPlayerRelation(const std::string &nick, - OnlinePlayer *const player); - /** - * The thread function that download the files. - */ - static int downloadThread(void *ptr); + void handlerPlayerRelation(const std::string &nick, + OnlinePlayer *const player); + /** + * The thread function that download the files. + */ + static int downloadThread(void *ptr); - /** - * A libcurl callback for writing to memory. - */ - static size_t memoryWrite(void *ptr, size_t size, size_t nmemb, - FILE *stream); + /** + * A libcurl callback for writing to memory. + */ + static size_t memoryWrite(void *ptr, size_t size, + size_t nmemb, + FILE *stream); - const std::string prepareNick(const std::string &restrict nick, - const int level, - const std::string &restrict color) - const A_WARN_UNUSED; + const std::string prepareNick(const std::string &restrict nick, + const int level, + const std::string &restrict color) + const A_WARN_UNUSED; - void updateWindow(size_t numOnline); + void updateWindow(size_t numOnline); - enum DownloadStatus - { - UPDATE_ERROR = 0, - UPDATE_COMPLETE, - UPDATE_LIST - }; + enum DownloadStatus + { + UPDATE_ERROR = 0, + UPDATE_COMPLETE, + UPDATE_LIST + }; - int mUpdateTimer; + int mUpdateTimer; - /** A thread that use libcurl to download updates. */ - SDL_Thread *mThread; + /** A thread that use libcurl to download updates. */ + SDL_Thread *mThread; - /** Buffer for files downloaded to memory. */ - char *mMemoryBuffer; + /** Buffer for files downloaded to memory. */ + char *mMemoryBuffer; - /** Buffer to handler human readable error provided by curl. */ - char *mCurlError; + /** Buffer to handler human readable error provided by curl. */ + char *mCurlError; - BrowserBox *mBrowserBox; - ScrollArea *mScrollArea; - std::set<OnlinePlayer*> mOnlinePlayers; - std::set<std::string> mOnlineNicks; + BrowserBox *mBrowserBox; + ScrollArea *mScrollArea; + std::set<OnlinePlayer*> mOnlinePlayers; + std::set<std::string> mOnlineNicks; - Button *mUpdateButton; - std::vector<OnlinePlayer*> mFriends; - std::vector<OnlinePlayer*> mNeutral; - std::vector<OnlinePlayer*> mDisregard; - std::vector<OnlinePlayer*> mEnemy; + Button *mUpdateButton; + std::vector<OnlinePlayer*> mFriends; + std::vector<OnlinePlayer*> mNeutral; + std::vector<OnlinePlayer*> mDisregard; + std::vector<OnlinePlayer*> mEnemy; - /** Byte count currently downloaded in mMemoryBuffer. */ - int mDownloadedBytes; + /** Byte count currently downloaded in mMemoryBuffer. */ + int mDownloadedBytes; - /** Status of the current download. */ - DownloadStatus mDownloadStatus; + /** Status of the current download. */ + DownloadStatus mDownloadStatus; - /** Flag that show if current download is complete. */ - bool mDownloadComplete; - bool mAllowUpdate; - bool mShowLevel; - bool mUpdateOnlineList; - bool mGroupFriends; + /** Flag that show if current download is complete. */ + bool mDownloadComplete; + bool mAllowUpdate; + bool mShowLevel; + bool mUpdateOnlineList; + bool mGroupFriends; }; extern WhoIsOnline *whoIsOnline; |