void NpcHandler::handleMessage(Net::MessageIn &msg) { if (msg.getId() == SMSG_NPC_CHOICE || msg.getId() == SMSG_NPC_MESSAGE) { msg.readInt16(); // length } int npcId = msg.readInt32(); Event *event = 0; switch (msg.getId()) { case SMSG_NPC_CHOICE: event = new Event(Event::Menu); event->setInt("id", npcId); parseMenu(event, msg.readString(msg.getLength() - 8)); event->trigger(Event::NpcChannel); break; case SMSG_NPC_MESSAGE: event = new Event(Event::Message); event->setInt("id", npcId); event->setString("text", msg.readString(msg.getLength() - 8)); event->trigger(Event::NpcChannel); break; case SMSG_NPC_CLOSE: // Show the close button event = new Event(Event::Close); event->setInt("id", npcId); event->trigger(Event::NpcChannel); break; case SMSG_NPC_NEXT: // Show the next button event = new Event(Event::Next); event->setInt("id", npcId); event->trigger(Event::NpcChannel); break; case SMSG_NPC_INT_INPUT: // Request for an integer event = new Event(Event::IntegerInput); event->setInt("id", npcId); event->trigger(Event::NpcChannel); break; case SMSG_NPC_STR_INPUT: // Request for a string event = new Event(Event::StringInput); event->setInt("id", npcId); event->trigger(Event::NpcChannel); break; } delete event; if (local_player->getCurrentAction() != Being::SIT) local_player->setAction(Being::STAND); }
/** \brief Loads the main UI theme, and a menu theme. * * See also foundtheme(void), it will return true when called after * this method if this method was successful. * * \param menufile name of menu item xml file */ void MythThemedMenu::Init(const QString &menufile) { if (!m_state->m_loaded) { if (m_state->Create()) m_foundtheme = true; } else m_foundtheme = true; if (!m_foundtheme) return; CopyFrom(m_state); connect(m_buttonList, SIGNAL(itemSelected(MythUIButtonListItem*)), SLOT(setButtonActive(MythUIButtonListItem*))); connect(m_buttonList, SIGNAL(itemClicked(MythUIButtonListItem*)), SLOT(buttonAction(MythUIButtonListItem*))); if (!parseMenu(menufile)) m_foundtheme = false; }
void Lingo::addCode(const char *code, ScriptType type, uint16 id) { debugC(2, kDebugLingoCompile, "Add code \"%s\" for type %d with id %d", code, type, id); if (_scripts[type].contains(id)) { delete _scripts[type][id]; } _currentScript = new ScriptData; _currentScriptType = type; _scripts[type][id] = _currentScript; _linenumber = _colnumber = 1; _hadError = false; const char *begin, *end; if (!strncmp(code, "menu:", 5)) { debugC(2, kDebugLingoCompile, "Parsing menu"); parseMenu(code); return; } // macros and factories have conflicting grammar. Thus we ease life for the parser. if ((begin = findNextDefinition(code))) { bool first = true; while ((end = findNextDefinition(begin + 1))) { if (first) { begin = code; first = false; } Common::String chunk(begin, end); if (chunk.hasPrefix("factory") || chunk.hasPrefix("method")) _inFactory = true; else if (chunk.hasPrefix("macro")) _inFactory = false; else _inFactory = false; debugC(2, kDebugLingoCompile, "Code chunk:\n#####\n%s#####", chunk.c_str()); parse(chunk.c_str()); if (debugChannelSet(3, kDebugLingoCompile)) { uint pc = 0; while (pc < _currentScript->size()) { Common::String instr = decodeInstruction(pc, &pc); debugC(3, kDebugLingoCompile, "[%5d] %s", pc, instr.c_str()); } } _currentScript->clear(); begin = end; } _hadError = true; // HACK: This is for preventing test execution debugC(2, kDebugLingoCompile, "Code chunk:\n#####\n%s#####", begin); parse(begin); } else { parse(code); code1(STOP); } _inFactory = false; if (debugChannelSet(3, kDebugLingoCompile)) { if (_currentScript->size() && !_hadError) Common::hexdump((byte *)&_currentScript->front(), _currentScript->size() * sizeof(inst)); uint pc = 0; while (pc < _currentScript->size()) { Common::String instr = decodeInstruction(pc, &pc); debugC(3, kDebugLingoCompile, "[%5d] %s", pc, instr.c_str()); } } }