HoverRace  2.0
Announcement.h
Go to the documentation of this file.
1 
2 // Announcement.h
3 //
4 // Copyright (c) 2014-2016 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 namespace HoverRace {
25  namespace Display {
26  class Container;
27  class Display;
28  class Box;
29  class FlexGrid;
30  }
31  namespace Player {
32  class Player;
33  }
34 }
35 
36 namespace HoverRace {
37 namespace Client {
38 
44 {
45 public:
53  Announcement(const std::string &postType, const std::string &label,
54  std::shared_ptr<Player::Player> player) :
55  postType(postType), label(label), player(std::move(player)) { }
56  virtual ~Announcement() { }
57 
58  Announcement &operator=(const Announcement&) = delete;
59 
60 public:
61  virtual std::ostream &StreamOut(std::ostream &os) const
62  {
63  os << label;
64  return os;
65  }
66 
67 public:
68  const std::string &GetPostType() const { return postType; }
69  const std::string &GetLabel() const { return label; }
70  std::shared_ptr<Player::Player> GetPlayer() const { return player; }
71 
72 public:
79  virtual std::shared_ptr<Display::Box> CreateIcon(
80  Display::Display &display, Display::Container &parent) const = 0;
81 
88  virtual void CreateContents(Display::Display &display,
89  Display::FlexGrid &grid) const = 0;
90 
94  virtual void OnClick() { }
95 
96 private:
97  const std::string postType;
98  const std::string label;
99  std::shared_ptr<Player::Player> player;
100 };
101 
102 inline std::ostream &operator<<(std::ostream &os, const Announcement &ann)
103 {
104  return ann.StreamOut(os);
105 }
106 
107 } // namespace Client
108 } // namespace HoverRace
Announcement(const std::string &postType, const std::string &label, std::shared_ptr< Player::Player > player)
Constructor.
Definition: Announcement.h:53
virtual ~Announcement()
Definition: Announcement.h:56
const std::string postType
Definition: Announcement.h:97
Base class for low-level bounded widgets.
Definition: Box.h:51
STL namespace.
std::shared_ptr< Player::Player > GetPlayer() const
Definition: Announcement.h:70
const std::string & GetPostType() const
Definition: Announcement.h:68
const std::string & GetLabel() const
Definition: Announcement.h:69
const std::string label
Definition: Announcement.h:98
Base class for display managers.
Definition: Display.h:73
std::ostream & operator<<(std::ostream &os, const Color &c)
Definition: Color.cpp:61
virtual std::ostream & StreamOut(std::ostream &os) const
Definition: Announcement.h:61
An invisible container for other UI widgets.
Definition: Container.h:49
A container that arranges components into a grid that is automatically sized to the contents...
Definition: FlexGrid.h:52
std::shared_ptr< Player::Player > player
Definition: Announcement.h:99
Definition: Announcement.h:24
virtual void OnClick()
Handle when the announcement is clicked.
Definition: Announcement.h:94
Base class for connected players.
Definition: Player.h:49
std::shared_ptr< Announcement > ann
Definition: ClientApp.cpp:110
Base class for announcements.
Definition: Announcement.h:43