1/*
2 * LegacyClonk
3 *
4 * Copyright (c) 1998-2000, Matthes Bender (RedWolf Design)
5 * Copyright (c) 2017-2020, The LegacyClonk Team and contributors
6 *
7 * Distributed under the terms of the ISC license; see accompanying file
8 * "COPYING" for details.
9 *
10 * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11 * See accompanying file "TRADEMARK" for details.
12 *
13 * To redistribute this file separately, substitute the full license texts
14 * for the above references.
15 */
16
17/* Language module controlling external language packs */
18
19#pragma once
20
21#include "C4DelegatedIterable.h"
22#include <C4Group.h>
23#include <C4GroupSet.h>
24#include "C4ResStrTable.h"
25
26#include <array>
27#include <string>
28#include <vector>
29
30class C4Language;
31
32class C4LanguageInfo
33{
34 friend class C4Language;
35
36public:
37 std::array<char, 2> Code;
38 std::string Name;
39 std::string Info;
40 std::string Fallback;
41 std::string Charset;
42
43protected:
44 C4LanguageInfo *Next;
45};
46
47class C4Language : public C4DelegatedIterable<C4Language>
48{
49public:
50 C4Language();
51 ~C4Language();
52
53protected:
54 C4Group PackDirectory;
55 C4GroupSet Packs;
56 C4GroupSet PackGroups;
57 std::vector<C4LanguageInfo> Infos;
58 char PackGroupLocation[_MAX_FNAME + 1];
59
60public:
61 using Iterable = ConstIterableMember<&C4Language::Infos>;
62
63public:
64 void ClearLanguage();
65 // Initialization
66 bool Init();
67 void Clear();
68 // Handling of external language packs
69 C4GroupSet &GetPackGroups(const char *strRelativePath);
70 // Handling of language info loaded from string tables
71 const C4LanguageInfo *FindInfo(const char *code);
72 // Loading of actual resource string table
73 bool LoadLanguage(const char *strLanguages);
74
75protected:
76 // Handling of language info loaded from string tables
77 void InitInfos();
78 void LoadInfos(C4Group &hGroup);
79 // Loading of actual resource string table
80 bool InitStringTable(const char *strCode);
81 bool LoadStringTable(C4Group &hGroup, const char *strCode);
82};
83
84extern C4Language Languages;
85