xoreos  0.0.5
talkman.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef AURORA_TALKMAN_H
26 #define AURORA_TALKMAN_H
27 
28 #include <list>
29 
30 #include "src/common/types.h"
31 #include "src/common/ustring.h"
32 #include "src/common/singleton.h"
33 #include "src/common/changeid.h"
34 
35 #include "src/aurora/language.h"
36 
37 namespace Aurora {
38 
39 class TalkTable;
40 
42 class TalkManager : public Common::Singleton<TalkManager> {
43 public:
44  TalkManager();
45  ~TalkManager();
46 
47  void clear();
48 
57  void addTable(const Common::UString &nameMale, const Common::UString &nameFemale,
58  bool isAlt, uint32 priority, Common::ChangeID *changeID = 0);
59 
61  void removeTable(Common::ChangeID &changeID);
62 
65 
66 private:
67  struct Table {
70 
73 
75  id(i), priority(p), tableMale(tM), tableFemale(tF) { }
76 
77  bool operator<(const Table &right) const { return priority < right.priority; }
78  };
79 
80  class Change : public Common::ChangeContent {
81  private:
82  Change(uint32 id, bool isAlt) : _id(id), _isAlt(isAlt) { }
83 
85  bool _isAlt;
86 
87  friend class TalkManager;
88 
89  public:
90  ~Change() { }
91 
92  Common::ChangeContent *clone() const { return new Change(_id, _isAlt); }
93  };
94 
95  typedef std::list<Table> Tables;
96 
97 
100 
101 
102  void deleteTable(Table &table);
103 
104  const TalkTable *find(uint32 strRef, LanguageGender gender) const;
105  const TalkTable *find(const Tables &tables, uint32 strRef, LanguageGender gender) const;
106 };
107 
108 } // End of namespace Aurora
109 
111 #define TalkMan ::Aurora::TalkManager::instance()
112 
113 #endif // AURORA_TALKMAN_H
LanguageGender
Definition: language.h:67
const TalkTable * find(uint32 strRef, LanguageGender gender) const
Definition: talkman.cpp:177
Class and macro for implementing singletons.
TalkTable * tableMale
Definition: talkman.h:71
A class holding an UTF-8 string.
Definition: ustring.h:48
const Common::UString & getString(uint32 strRef, LanguageGender gender=kLanguageGenderCurrent)
Definition: talkman.cpp:130
The global Aurora talk manager, holding the current talk tables.
Definition: talkman.h:42
Base class for BioWare&#39;s talk tables.
Definition: talktable.h:52
Tables _tablesMain
Definition: talkman.h:98
bool operator<(const Table &right) const
Definition: talkman.h:77
Generic template base class for implementing the singleton design pattern.
Definition: singleton.h:61
void addTable(const Common::UString &nameMale, const Common::UString &nameFemale, bool isAlt, uint32 priority, Common::ChangeID *changeID=0)
Add a talk table to the talk manager.
Definition: talkman.cpp:78
const Common::UString & getSoundResRef(uint32 strRef, LanguageGender gender=kLanguageGenderCurrent)
Definition: talkman.cpp:144
Helper class to represent an undoable change.
Types and functions related to language.
Low-level type definitions to handle fixed width types portably.
void deleteTable(Table &table)
Definition: talkman.cpp:100
void removeTable(Common::ChangeID &changeID)
Remove a talk table from the talk manager again.
Definition: talkman.cpp:108
Unicode string handling.
Change(uint32 id, bool isAlt)
Definition: talkman.h:82
Pseudo value that means the current language gender.
Definition: language.h:72
TalkTable * tableFemale
Definition: talkman.h:72
A class representing an undoable change.
Definition: changeid.h:35
uint32_t uint32
Definition: types.h:204
Common::ChangeContent * clone() const
Definition: talkman.h:92
std::list< Table > Tables
Definition: talkman.h:95
Tables _tablesAlt
Definition: talkman.h:99
Table(TalkTable *tM, TalkTable *tF, uint32 p, uint32 i)
Definition: talkman.h:74