SuperTuxKart
online_profile_achievements.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2013-2015 Glenn De Jonghe
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 3
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 
18 
19 #ifndef __HEADER_ONLINE_PROFILE_ACHIEVEMENTS_HPP__
20 #define __HEADER_ONLINE_PROFILE_ACHIEVEMENTS_HPP__
21 
22 #include <string>
23 #include <irrString.h>
24 
25 #include "achievements/achievement.hpp"
26 #include "guiengine/screen.hpp"
27 #include "guiengine/widgets/list_widget.hpp"
28 #include "states_screens/online/online_profile_base.hpp"
29 
30 
31 namespace GUIEngine { class Widget; }
32 
33 
40 {
41 private:
42 
43  GUIEngine::ListWidget * m_achievements_list_widget;
44 
45  int m_selected_achievement_index;
46  bool m_waiting_for_achievements;
47 
50 
51  bool m_sort_desc;
52 
53  bool m_sort_default;
54 
55  void displayResults();
56  // True if a < b
57  bool goalSort(Achievement *a, Achievement *b);
59 
60 protected:
61  BaseOnlineProfileAchievements(const std::string &filename);
62 
63 public:
65 
67  virtual void loadedFromFile() OVERRIDE;
68 
70  virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID) OVERRIDE;
71 
73  virtual void init() OVERRIDE;
74 
75  virtual void onUpdate(float delta) OVERRIDE;
76 
77  virtual void beforeAddingWidget() OVERRIDE;
78  virtual void onColumnClicked(int column_id, bool sort_desc, bool sort_default) OVERRIDE;
79 
80  // ------------------------------------------------------------------------
81  virtual void refreshAchievementsList()
82  {
83  m_waiting_for_achievements = true;
84  } // refreshAchievementsList
85 };
86 
87 // ============================================================================
93  public GUIEngine::ScreenSingleton<TabOnlineProfileAchievements>
94 {
95 protected:
97 
99  : BaseOnlineProfileAchievements("online/profile_achievements_tab.stkgui")
100  {}
101 
102 }; // TabOnlineProfileAchievements
103 
104 // ============================================================================
110  public GUIEngine::ScreenSingleton < OnlineProfileAchievements >
111 {
112 protected:
114 
116  : BaseOnlineProfileAchievements("online/profile_achievements.stkgui")
117  {}
118 
119 }; // class
120 
121 
122 #endif
Definition: achievement.hpp:42
Online profiel overview screen.
Definition: online_profile_achievements.hpp:40
virtual void beforeAddingWidget() OVERRIDE
Callback before widgets are added.
Definition: online_profile_achievements.cpp:74
virtual void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_profile_achievements.cpp:124
bool goalSort(Achievement *a, Achievement *b)
True if a's goal progression is <= to b's.
Definition: online_profile_achievements.cpp:277
virtual void init() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_profile_achievements.cpp:94
void displayResults()
Displays the achievements from a given profile.
Definition: online_profile_achievements.cpp:180
BaseOnlineProfileAchievements(const std::string &filename)
Constructor.
Definition: online_profile_achievements.cpp:50
virtual void onUpdate(float delta) OVERRIDE
Called every frame.
Definition: online_profile_achievements.cpp:309
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_profile_achievements.cpp:62
bool progressSort(Achievement *a, Achievement *b)
True if a's single-goal progress is <= to b's.
Definition: online_profile_achievements.cpp:290
int m_sort_column
Which column to use for sorting.
Definition: online_profile_achievements.hpp:49
Definition: list_widget.hpp:37
A vertical list widget with text entries.
Definition: list_widget.hpp:50
Declares a class to be a singleton.
Definition: screen.hpp:59
Online profiel overview screen.
Definition: online_profile_achievements.hpp:111
Online profile base screen.
Definition: online_profile_base.hpp:37
Online profiel overview screen.
Definition: online_profile_achievements.hpp:94
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33