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 of words in WORDS.TOK or WORDS.TOK.EXTENDED.
44  // key: first character of the word
45  // value: words in the order they appear
47 
48  WordEntry _egoWords[MAX_WORDS];
49  uint16 _egoWordCount;
50 
51 public:
52  uint16 getEgoWordCount() const;
53  const char *getEgoWord(int16 wordNr) const;
54  uint16 getEgoWordId(int16 wordNr) const;
55 
56  int loadDictionary_v1(Common::SeekableReadStream &stream);
57  int loadDictionary(const char *fname);
58  int loadDictionary(Common::SeekableReadStream &stream);
59  // used for fan made translations requiring extended char set
60  int loadExtendedDictionary(const char *fname);
61  void unloadDictionary();
62 
63  void clearEgoWords();
64  void parseUsingDictionary(const char *rawUserInput);
65 
66 private:
67  void cleanUpInput(const char *userInput, Common::String &cleanInput);
68  int16 findWordInDictionary(const Common::String &userInputLowercase, uint16 userInputLen, uint16 userInputPos, uint16 &foundWordLen);
69 
70  bool handleSpeedCommands(const Common::String &userInputLowercase);
71  static void convertRussianUserInput(Common::String &userInputLowercase);
72 };
73 
74 } // End of namespace Agi
75 
76 #endif /* AGI_WORDS_H */
Definition: str.h:59
Definition: stream.h:745
Definition: hashmap.h:85
Definition: agi.h:700
Definition: words.h:30
Definition: words.h:35
Definition: agi.h:64