1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#include "Localization/BsStringTableManager.h"
4
5namespace bs
6{
7 void StringTableManager::setActiveLanguage(Language language)
8 {
9 if (language != mActiveLanguage)
10 {
11 mActiveLanguage = language;
12
13 for (auto& tablePair : mTables)
14 tablePair.second->setActiveLanguage(language);
15 }
16 }
17
18 HStringTable StringTableManager::getTable(UINT32 id)
19 {
20 auto iterFind = mTables.find(id);
21 if (iterFind != mTables.end())
22 return iterFind->second;
23
24 HStringTable newTable = StringTable::create();
25 setTable(id, newTable);
26
27 return newTable;
28 }
29
30 void StringTableManager::removeTable(UINT32 id)
31 {
32 mTables.erase(id);
33 }
34
35 void StringTableManager::setTable(UINT32 id, const HStringTable& table)
36 {
37 mTables[id] = table;
38
39 if (table != nullptr)
40 table->setActiveLanguage(mActiveLanguage);
41 }
42
43 StringTableManager& gStringTableManager()
44 {
45 return StringTableManager::instance();
46 }
47}