mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 20:43:26 +02:00
Full modal dialog functionality
This commit is contained in:
@@ -506,9 +506,9 @@ void Game::processQuestLine(int questId, const std::vector<std::tuple<std::strin
|
||||
g_lua.callGlobalField("g_game", "onQuestLine", questId, questMissions);
|
||||
}
|
||||
|
||||
void Game::processModalDialog(uint32 id, std::string title, std::string message, int enterId, std::string enterText, int escapeId, std::string escapeText, std::vector<std::tuple<int, std::string> > choiceList)
|
||||
void Game::processModalDialog(uint32 id, std::string title, std::string message, std::vector<std::tuple<int, std::string> > buttonList, int enterButton, int escapeButton, std::vector<std::tuple<int, std::string> > choiceList, bool priority)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onModalDialog", id, title, message, enterId, enterText, escapeId, escapeText, choiceList);
|
||||
g_lua.callGlobalField("g_game", "onModalDialog", id, title, message, buttonList, enterButton, escapeButton, choiceList, priority);
|
||||
}
|
||||
|
||||
void Game::processAttackCancel(uint seq)
|
||||
|
@@ -132,7 +132,7 @@ protected:
|
||||
void processQuestLine(int questId, const std::vector<std::tuple<std::string, std::string> >& questMissions);
|
||||
|
||||
// modal dialogs >= 970
|
||||
void processModalDialog(uint32 id, std::string title, std::string message, int enterId, std::string enterText, int escapeId, std::string escapeText, std::vector<std::tuple<int, std::string> > choiceList);
|
||||
void processModalDialog(uint32 id, std::string title, std::string message, std::vector<std::tuple<int, std::string> > buttonList, int enterButton, int escapeButton, std::vector<std::tuple<int, std::string> > choiceList, bool priority);
|
||||
|
||||
friend class ProtocolGame;
|
||||
friend class Map;
|
||||
|
@@ -145,7 +145,7 @@ namespace Proto {
|
||||
GameServerMarketLeave = 247, // 944
|
||||
GameServerMarketDetail = 248, // 944
|
||||
GameServerMarketBrowse = 249, // 944
|
||||
GameServerShowModalDialog = 250 // 960
|
||||
GameServerModalDialog = 250 // 960
|
||||
};
|
||||
|
||||
enum ClientOpcodes : uint8
|
||||
|
@@ -212,7 +212,7 @@ private:
|
||||
void parseChannelEvent(const InputMessagePtr& msg);
|
||||
void parseItemInfo(const InputMessagePtr& msg);
|
||||
void parsePlayerInventory(const InputMessagePtr& msg);
|
||||
void parseShowModalDialog(const InputMessagePtr& msg);
|
||||
void parseModalDialog(const InputMessagePtr& msg);
|
||||
void parseExtendedOpcode(const InputMessagePtr& msg);
|
||||
void parseChangeMapAwareRange(const InputMessagePtr& msg);
|
||||
void parseCreaturesMark(const InputMessagePtr& msg);
|
||||
|
@@ -316,8 +316,8 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg)
|
||||
parsePlayerInfo(msg);
|
||||
break;
|
||||
// PROTOCOL>=970
|
||||
case Proto::GameServerShowModalDialog:
|
||||
parseShowModalDialog(msg);
|
||||
case Proto::GameServerModalDialog:
|
||||
parseModalDialog(msg);
|
||||
break;
|
||||
// PROTOCOL>=980
|
||||
case Proto::GameServerLoginSuccess:
|
||||
@@ -1596,18 +1596,18 @@ void ProtocolGame::parsePlayerInventory(const InputMessagePtr& msg)
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolGame::parseShowModalDialog(const InputMessagePtr& msg)
|
||||
void ProtocolGame::parseModalDialog(const InputMessagePtr& msg)
|
||||
{
|
||||
uint32 id = msg->getU32();
|
||||
std::string title = msg->getString();
|
||||
std::string message = msg->getString();
|
||||
|
||||
int sizeButtons = msg->getU8();
|
||||
std::map<int, std::string > buttonList;
|
||||
std::vector<std::tuple<int, std::string> > buttonList;
|
||||
for(int i = 0; i < sizeButtons; ++i) {
|
||||
std::string value = msg->getString();
|
||||
int id = msg->getU8();
|
||||
buttonList[id] = value;
|
||||
buttonList.push_back(std::make_tuple(id, value));
|
||||
}
|
||||
|
||||
int sizeChoices = msg->getU8();
|
||||
@@ -1628,21 +1628,9 @@ void ProtocolGame::parseShowModalDialog(const InputMessagePtr& msg)
|
||||
escapeButton = msg->getU8();
|
||||
}
|
||||
|
||||
msg->getU8(); // popup value (no clue what it is for)
|
||||
bool priority = msg->getU8() == 0x01;
|
||||
|
||||
std::map<int, std::string>::iterator itEnter = buttonList.find(enterButton);
|
||||
if(itEnter == buttonList.end()) {
|
||||
g_logger.info(stdext::format("Enter button does not exist for dialog id: %d", id));
|
||||
return;
|
||||
}
|
||||
|
||||
std::map<int, std::string >::iterator itEscape = buttonList.find(escapeButton);
|
||||
if(itEscape == buttonList.end()) {
|
||||
g_logger.info(stdext::format("Escape button does not exist for dialog id: %d", id));
|
||||
return;
|
||||
}
|
||||
|
||||
g_game.processModalDialog(id, title, message, itEnter->first, itEnter->second, itEscape->first, itEscape->second, choiceList);
|
||||
g_game.processModalDialog(id, title, message, buttonList, enterButton, escapeButton, choiceList, priority);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseExtendedOpcode(const InputMessagePtr& msg)
|
||||
|
Reference in New Issue
Block a user