ScummVM API documentation
words.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef AGI_WORDS_H
23 #define AGI_WORDS_H
24 
25 namespace Agi {
26 
27 #define DICTIONARY_RESULT_UNKNOWN -1
28 #define DICTIONARY_RESULT_IGNORE 0
29 
30 struct WordEntry {
31  uint16 id;
32  Common::String word;
33 };
34 
35 class Words {
36 public:
37  Words(AgiEngine *vm);
38  ~Words();
39 
40 private:
41  AgiEngine *_vm;
42 
43  // Dictionary
44  // 158 = 255 - 'a' ; that's allows us to support extended character set, and does no harm for regular English games
45  Common::Array<WordEntry *> _dictionaryWords[158];
46 
47  WordEntry _egoWords[MAX_WORDS];
48  uint16 _egoWordCount;
49 
50 public:
51  uint16 getEgoWordCount();
52  const char *getEgoWord(int16 wordNr);
53  uint16 getEgoWordId(int16 wordNr);
54 
55  int loadDictionary_v1(Common::File &f);
56  int loadDictionary(const char *fname);
57  // used for fan made translations requiring extended char set
58  int loadExtendedDictionary(const char *fname);
59  void unloadDictionary();
60 
61  void clearEgoWords();
62  void parseUsingDictionary(const char *rawUserInput);
63 
64 private:
65  void cleanUpInput(const char *userInput, Common::String &cleanInput);
66  int16 findWordInDictionary(const Common::String &userInput, uint16 userInputLen, uint16 userInputPos, uint16 &foundWordLen);
67 };
68 
69 } // End of namespace Agi
70 
71 #endif /* AGI_WORDS_H */
Definition: str.h:59
Definition: array.h:52
Definition: file.h:47
Definition: agi.h:787
Definition: words.h:30
Definition: words.h:35
Definition: agi.h:63