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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef PETKA_BIG_DIALOGUE_H 24 #define PETKA_BIG_DIALOGUE_H 25 26 #include "common/array.h" 27 #include "common/ustr.h" 28 29 namespace Petka { 30 31 class PetkaEngine; 32 33 enum { 34 kOpcodePlay = 1, 35 kOpcodeMenu, 36 kOpcodeEnd, 37 kOpcodeUserMessage 38 }; 39 40 enum { 41 kOperationBreak = 1, 42 kOperationMenu, 43 kOperationGoTo, 44 kOperationDisableMenuItem, 45 kOperationEnableMenuItem, 46 kOperationReturn, 47 kOperationPlay, 48 kOperationCircle, 49 kOperationUserMessage 50 }; 51 52 struct Operation { 53 union { 54 struct { 55 byte bits; 56 uint16 bitField; 57 } menu; 58 struct { 59 uint16 opIndex; 60 } goTo; 61 struct { 62 uint16 opIndex; 63 byte bit; 64 } disableMenuItem; 65 struct { 66 uint16 opIndex; 67 byte bit; 68 } enableMenuItem; 69 struct { 70 uint16 messageIndex; 71 } play; 72 struct { 73 uint16 count; 74 byte curr; 75 } circle; 76 struct { 77 uint16 arg; 78 } userMsg; 79 }; 80 byte type; 81 }; 82 83 struct Dialog { 84 uint32 startOpIndex; 85 // uint32 opsCount; 86 // Operation *ops; 87 }; 88 89 struct DialogHandler { 90 uint32 opcode; 91 uint32 startDialogIndex; 92 Common::Array<Dialog> dialogs; 93 }; 94 95 struct DialogGroup { 96 uint32 objId; 97 Common::Array<DialogHandler> handlers; 98 }; 99 100 struct SpeechInfo { 101 uint32 speakerId; 102 char soundName[16]; 103 Common::U32String text; 104 }; 105 106 class BigDialogue { 107 public: 108 BigDialogue(PetkaEngine &vm); 109 110 uint opcode(); 111 112 uint choicesCount(); 113 114 void next(int choice = -1); 115 116 const DialogHandler *findHandler(uint objId, uint opcode, bool *fallback) const; 117 void setHandler(uint objId, uint opcode); 118 119 const Common::U32String *getSpeechInfo(int *talkerId, const char **soundName, int choice); 120 void getMenuChoices(Common::Array<Common::U32String> &choices); 121 122 void load(Common::ReadStream *s); 123 void save(Common::WriteStream *s); 124 125 private: 126 void loadSpeechesInfo(); 127 bool checkMenu(uint opIndex); 128 bool findOperation(uint startOpIndex, uint opType, uint *resIndex); 129 void circleMoveTo(byte index); 130 131 private: 132 PetkaEngine &_vm; 133 134 Operation *_currOp; 135 Common::Array<Operation> _ops; 136 uint _startOpIndex; 137 138 Common::Array<SpeechInfo> _speeches; 139 Common::Array<DialogGroup> _objDialogs; 140 }; 141 142 } // End of namespace Petka 143 144 #endif 145