tooltipgenerator.cpp
1 //------------------------------------------------------------------------------
2 // tooltipgenerator.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "tooltipgenerator.h"
24 
25 #include "serverapi/server.h"
26 #include "serverapi/tooltips/dmflagshtmlgenerator.h"
27 #include "serverapi/tooltips/gameinfotip.h"
28 #include "serverapi/tooltips/generalinfotip.h"
29 #include "serverapi/tooltips/playertable.h"
30 #include "serverapi/tooltips/tooltiprenderhint.h"
31 
32 DClass<TooltipGenerator>
33 {
34 public:
35  TooltipRenderHint renderHint;
36  ServerCPtr server;
37 };
38 
39 DPointered(TooltipGenerator)
40 
41 TooltipGenerator::TooltipGenerator(const ServerCPtr &server)
42 {
43  d->server = server;
44 }
45 
46 TooltipGenerator::~TooltipGenerator()
47 {
48 }
49 
51 {
52  DmflagsHtmlGenerator generator(server());
53  return generator.generate();
54 }
55 
57 {
58  GameInfoTip tip(server());
59  return tip.generateHTML();
60 }
61 
63 {
64  GeneralInfoTip tip(server());
65  return tip.generateHTML();
66 }
67 
69 {
70  PlayerTable table(renderHint(), server());
71  return table.generateHTML();
72 }
73 
74 const TooltipRenderHint &TooltipGenerator::renderHint() const
75 {
76  return d->renderHint;
77 }
78 
79 void TooltipGenerator::setRenderHint(const TooltipRenderHint &hint)
80 {
81  d->renderHint = hint;
82 }
83 
84 ServerCPtr TooltipGenerator::server() const
85 {
86  return d->server;
87 }