ManaPlus
socialtab.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2010 The Mana Developers
4  * Copyright (C) 2011-2019 The ManaPlus Developers
5  * Copyright (C) 2019-2021 Andrei Karas
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef GUI_WIDGETS_TABS_SOCIALTAB_H
24 #define GUI_WIDGETS_TABS_SOCIALTAB_H
25 
27 
29 #include "gui/windows/textdialog.h"
30 
33 #include "gui/widgets/scrollarea.h"
34 
35 #include "gui/widgets/tabs/tab.h"
36 
37 #include "localconsts.h"
38 
39 class AvatarListModel;
40 
41 class SocialTab notfinal : public Tab
42 {
43  public:
45 
46  virtual void invite()
47  {
48  }
49 
50  virtual void leave()
51  {
52  }
53 
54  virtual void updateList()
55  {
56  }
57 
58  virtual void updateAvatar(const std::string &name A_UNUSED)
59  {
60  }
61 
62  virtual void resetDamage(const std::string &name A_UNUSED)
63  {
64  }
65 
66  virtual void selectIndex(const unsigned num A_UNUSED)
67  {
68  }
69 
70  virtual void buildCounter(const int online A_UNUSED,
71  const int total A_UNUSED)
72  {
73  }
74 
75  protected:
76  friend class SocialWindow;
77 
78  explicit SocialTab(const Widget2 *const widget) :
79  Tab(widget),
83  mList(nullptr),
85  mMenuAction("menu")
86  {
87  }
88 
89  ~SocialTab() override
90  {
91  // Cleanup dialogs
92  if (mInviteDialog != nullptr)
93  {
96  mInviteDialog = nullptr;
97  }
98 
99  if (mConfirmDialog != nullptr)
100  {
103  mConfirmDialog = nullptr;
104  }
105  }
106 
107  void createControls(AvatarListModel *const listModel,
108  const Opaque showBackground)
109  {
110  CREATEWIDGETV(mList, AvatarListBox, this, listModel);
111  mScroll = new ScrollArea(this, mList, showBackground,
112  "social_background.xml");
113 
116  }
117 
119  {
120  updateCounter();
121  updateMenu();
122  }
123 
124  void updateCounter() const
125  {
126  if (socialWindow != nullptr)
128  }
129 
130  void updateMenu() const
131  {
132  if (socialWindow != nullptr)
134  }
135 
140  std::string mCounterString;
141  std::string mMenuAction;
142 };
143 
144 #endif // GUI_WIDGETS_TABS_SOCIALTAB_H
void setVerticalScrollPolicy(const ScrollPolicy vPolicy)
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)
void createControls(AvatarListModel *const listModel, const Opaque showBackground)
Definition: socialtab.h:107
void setCurrent()
Definition: socialtab.h:118
virtual void updateAvatar(const std::string &name)
Definition: socialtab.h:58
ConfirmDialog * mConfirmDialog
Definition: socialtab.h:137
TextDialog * mInviteDialog
Definition: socialtab.h:136
ScrollArea * mScroll
Definition: socialtab.h:138
std::string mMenuAction
Definition: socialtab.h:141
void updateMenu() const
Definition: socialtab.h:130
~SocialTab()
Definition: socialtab.h:89
virtual void invite()
Definition: socialtab.h:46
virtual void selectIndex(const unsigned num)
Definition: socialtab.h:66
virtual void buildCounter(const int online, const int total)
Definition: socialtab.h:70
virtual void leave()
Definition: socialtab.h:50
virtual void resetDamage(const std::string &name)
Definition: socialtab.h:62
SocialTab(const Widget2 *const widget)
Definition: socialtab.h:78
AvatarListBox * mList
Definition: socialtab.h:139
void updateCounter() const
Definition: socialtab.h:124
virtual void updateList()
Definition: socialtab.h:54
std::string mCounterString
Definition: socialtab.h:140
void updateMenu(const SocialTab *const tab, const std::string &menu)
void updateCounter(const SocialTab *const tab, const std::string &count)
Definition: tab.h:88
void close()
Definition: textdialog.cpp:141
virtual void close()
Definition: window.cpp:902
virtual void scheduleDelete()
Definition: window.cpp:831
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:25
#define override
Definition: localconsts.h:47
#define notfinal
Definition: localconsts.h:261
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
#define nullptr
Definition: localconsts.h:45
#define A_UNUSED
Definition: localconsts.h:160
bool Opaque
Definition: opaque.h:30
SocialWindow * socialWindow