43
43
#include < GWCA/Managers/UIMgr.h>
44
44
#include < GWCA/Managers/RenderMgr.h>
45
45
#include < GWCA/Managers/QuestMgr.h>
46
+ #include < GWCA/Managers/MerchantMgr.h>
46
47
47
48
#include < GWCA/Utilities/Hooker.h>
48
49
@@ -215,6 +216,16 @@ namespace {
215
216
bool prevent_weapon_spell_animation_on_player = false ;
216
217
bool block_vanquish_complete_popup = false ;
217
218
219
+ bool was_leading = true ;
220
+ bool hide_dungeon_chest_popup = false ;
221
+ bool skip_entering_name_for_faction_donate = false ;
222
+ bool stop_screen_shake = false ;
223
+ bool disable_camera_smoothing = false ;
224
+
225
+ bool check_message_on_party_change = true ;
226
+
227
+ bool is_prompting_hard_mode_mission = false ;
228
+
218
229
GW::HookEntry SkillList_UICallback_HookEntry;
219
230
GW::UI::UIInteractionCallback SkillList_UICallback_Func = 0 , SkillList_UICallback_Ret = 0 ;
220
231
@@ -1049,43 +1060,31 @@ namespace {
1049
1060
1050
1061
GW::HookEntry OnQuestUIMessage_HookEntry;
1051
1062
1052
- void OnPostQuestUIMessage (const GW::HookStatus* status, const GW::UI::UIMessage message_id, void *, void *)
1053
- {
1054
- switch (message_id) {
1055
- case GW::UI::UIMessage::kSendSetActiveQuest :
1056
- if (status->blocked ) {
1057
- break ;
1058
- }
1059
- player_requested_active_quest_id = GW::QuestMgr::GetActiveQuestId ();
1060
- break ;
1061
- case GW::UI::UIMessage::kQuestAdded :
1062
- if (status->blocked ) {
1063
- break ;
1064
- }
1065
- if (GW::QuestMgr::GetActiveQuestId () == player_requested_active_quest_id) {
1066
- break ;
1067
- }
1068
- if (keep_current_quest_when_new_quest_added) {
1069
- // Re-request a quest change
1070
- const auto quest = GW::QuestMgr::GetQuest (player_requested_active_quest_id);
1071
- if (!quest) {
1072
- break ;
1073
- }
1074
- GW::Packet::StoC::QuestAdd packet;
1075
- packet.quest_id = quest->quest_id ;
1076
- packet.marker = quest->marker ;
1077
- packet.map_to = quest->map_to ;
1078
- packet.log_state = quest->log_state ;
1079
- packet.map_from = quest->map_from ;
1080
- wcscpy (packet.location , quest->location );
1081
- wcscpy (packet.name , quest->name );
1082
- wcscpy (packet.npc , quest->npc );
1083
- GW::StoC::EmulatePacket (&packet); // Why? Can we not send more ui messages if thats the need?
1084
- GW::QuestMgr::SetActiveQuestId (quest->quest_id );
1085
- }
1086
-
1087
- break ;
1063
+ void OnQuestAdded (uint32_t ) {
1064
+ if (GW::QuestMgr::GetActiveQuestId () == player_requested_active_quest_id) {
1065
+ return ;
1088
1066
}
1067
+ if (keep_current_quest_when_new_quest_added) {
1068
+ // Re-request a quest change
1069
+ const auto quest = GW::QuestMgr::GetQuest (player_requested_active_quest_id);
1070
+ if (!quest) {
1071
+ return ;
1072
+ }
1073
+ // Emulate the StoC packet because the packet handler itself sorts memory out, and then calls affected modules via UI messages with the new (current) data...
1074
+ GW::Packet::StoC::QuestAdd packet;
1075
+ packet.quest_id = quest->quest_id ;
1076
+ packet.marker = quest->marker ;
1077
+ packet.map_to = quest->map_to ;
1078
+ packet.log_state = quest->log_state ;
1079
+ packet.map_from = quest->map_from ;
1080
+ wcscpy (packet.location , quest->location );
1081
+ wcscpy (packet.name , quest->name );
1082
+ wcscpy (packet.npc , quest->npc );
1083
+ // ...We do this because sending UI messages doesn't actually update the quest data, it only notifies te ui that stuff has changed
1084
+ GW::StoC::EmulatePacket (&packet);
1085
+ GW::QuestMgr::SetActiveQuestId (quest->quest_id );
1086
+ }
1087
+
1089
1088
}
1090
1089
1091
1090
void CHAT_CMD_FUNC (CmdReinvite)
@@ -1236,6 +1235,34 @@ namespace {
1236
1235
}
1237
1236
}
1238
1237
1238
+ void OnVendorWindow (GW::UI::UIPacket::kVendorWindow * packet) {
1239
+ // Pre-fill character name when donating faction
1240
+ if (!(skip_entering_name_for_faction_donate && packet && packet->transaction_type == GW::Merchant::TransactionType::DonateFaction))
1241
+ return ;
1242
+ auto frame = GW::UI::GetChildFrame (GW::UI::GetFrameByLabel (L" NPCInteract" ), 0 , 0 );
1243
+ const auto sign_btn = GW::UI::GetChildFrame (frame, 2 );
1244
+ if (!(sign_btn && sign_btn->IsVisible ()))
1245
+ return ; // If sign button isn't visible, the player doesn't have enough faction
1246
+ const auto name_input = GW::UI::GetChildFrame (frame, 4 , 2 );
1247
+ const auto agent_enc_name = GW::PlayerMgr::GetPlayerName ();
1248
+ // Prefill and hide the name input
1249
+ GW::UI::SendFrameUIMessage (name_input, (GW::UI::UIMessage)0x4e , (void *)agent_enc_name);
1250
+ GW::UI::SetFrameVisible (name_input, 0 );
1251
+ // Show and enable the "Sign" button
1252
+ GW::UI::SetFrameDisabled (sign_btn, 0 );
1253
+ }
1254
+
1255
+ void OnDialogButton (GW::UI::DialogButtonInfo* packet) {
1256
+ if (auto_open_locked_chest_with_key && wcscmp (packet->message , L" \x8101\x7F88\x10A\x8101\x13BE\x1 " ) == 0 ) {
1257
+ // Auto use key
1258
+ DialogModule::SendDialog (packet->dialog_id );
1259
+ }
1260
+ if (auto_open_locked_chest && wcscmp (packet->message , L" \x8101\x7f88\x010a\x8101\x730e\x1 " ) == 0 ) {
1261
+ // Auto use lockpick
1262
+ DialogModule::SendDialog (packet->dialog_id );
1263
+ }
1264
+ }
1265
+
1239
1266
GW::HookEntry OnPostUIMessage_HookEntry;
1240
1267
void OnPostUIMessage (GW::HookStatus* status, GW::UI::UIMessage message_id, void * wParam, void *) {
1241
1268
if (status->blocked )
@@ -1248,6 +1275,12 @@ namespace {
1248
1275
GW::UI::ButtonClick (GW::UI::GetChildFrame (GW::UI::GetFrameByLabel (L" Party" ), 1 , 10 , 6 ));
1249
1276
}
1250
1277
} break ;
1278
+ case GW::UI::UIMessage::kSendSetActiveQuest :
1279
+ player_requested_active_quest_id = GW::QuestMgr::GetActiveQuestId ();
1280
+ break ;
1281
+ case GW::UI::UIMessage::kQuestAdded :
1282
+ OnQuestAdded (*(uint32_t *)wParam);
1283
+ break ;
1251
1284
case GW::UI::UIMessage::kTradeSessionStart : {
1252
1285
if (flash_window_on_trade) {
1253
1286
FlashWindow ();
@@ -1256,6 +1289,9 @@ namespace {
1256
1289
FocusWindow ();
1257
1290
}
1258
1291
} break ;
1292
+ case GW::UI::UIMessage::kVendorWindow : {
1293
+ OnVendorWindow ((GW::UI::UIPacket::kVendorWindow *)wParam);
1294
+ } break ;
1259
1295
case GW::UI::UIMessage::kPartySearchInviteSent : {
1260
1296
// Automatically send a party window invite when a party search invite is sent
1261
1297
const auto packet = (GW::UI::UIPacket::kPartySearchInvite *)wParam;
@@ -1268,16 +1304,16 @@ namespace {
1268
1304
CheckRemoveWindowBorder ();
1269
1305
} break ;
1270
1306
case GW::UI::UIMessage::kPartyDefeated : {
1271
- if (auto_return_on_defeat && GW::PartyMgr::GetIsLeader () && ! GW::PartyMgr::ReturnToOutpost () )
1272
- Log::Warning (" Failed to return to outpost" );
1307
+ if (auto_return_on_defeat && GW::PartyMgr::GetIsLeader ())
1308
+ GW::PartyMgr::ReturnToOutpost () || ( Log::Warning (" Failed to return to outpost" ), true );
1273
1309
} break ;
1274
1310
case GW::UI::UIMessage::kMapLoaded : {
1275
1311
last_online_status = static_cast <uint32_t >(GW::FriendListMgr::GetMyStatus ());
1276
1312
} break ;
1277
1313
case GW::UI::UIMessage::kShowCancelEnterMissionBtn : {
1278
1314
CheckPromptBeforeEnterMission (status);
1279
- if (status->blocked && ! GW::Map::CancelEnterChallenge () )
1280
- Log::Warning (" Failed to cancel mission entry" );
1315
+ if (status->blocked )
1316
+ GW::Map::CancelEnterChallenge () || ( Log::Warning (" Failed to cancel mission entry" ), true );
1281
1317
break ;
1282
1318
} break ;
1283
1319
case GW::UI::UIMessage::kVanquishComplete : {
@@ -1286,6 +1322,9 @@ namespace {
1286
1322
if (block_vanquish_complete_popup)
1287
1323
GW::UI::SetFrameVisible (GW::UI::GetChildFrame (GW::UI::GetFrameByLabel (L" Game" ), 6 , 8 ), false ) || (Log::Warning (" Failed to hide vanquish popup" ), true );
1288
1324
} break ;
1325
+ case GW::UI::UIMessage::kDialogButton : {
1326
+ OnDialogButton ((GW::UI::DialogButtonInfo*)wParam);
1327
+ } break ;
1289
1328
}
1290
1329
}
1291
1330
@@ -1585,7 +1624,6 @@ void GameSettings::Initialize()
1585
1624
GW::Hook::EnableHooks (CharacterStatIncreased_Func);
1586
1625
}
1587
1626
1588
- RegisterUIMessageCallback (&OnDialog_Entry, GW::UI::UIMessage::kSendDialog , bind_member (this , &GameSettings::OnFactionDonate));
1589
1627
RegisterUIMessageCallback (&OnDialog_Entry, GW::UI::UIMessage::kSendLoadSkillTemplate , &OnPreLoadSkillBar);
1590
1628
GW::StoC::RegisterPacketCallback (&OnDialog_Entry, GAME_SMSG_SKILL_UPDATE_SKILL_COUNT_1, OnUpdateSkillCount, -0x3000 );
1591
1629
GW::StoC::RegisterPacketCallback (&OnDialog_Entry, GAME_SMSG_SKILL_UPDATE_SKILL_COUNT_2, OnUpdateSkillCount, -0x3000 );
@@ -1645,20 +1683,6 @@ void GameSettings::Initialize()
1645
1683
GW::FriendListMgr::RegisterFriendStatusCallback (&FriendStatusCallback_Entry, FriendStatusCallback);
1646
1684
RegisterUIMessageCallback (&OnPreSendDialog_Entry, GW::UI::UIMessage::kSendPingWeaponSet , OnPingWeaponSet);
1647
1685
1648
- constexpr GW::UI::UIMessage dialog_ui_messages[] = {
1649
- GW::UI::UIMessage::kSendDialog ,
1650
- GW::UI::UIMessage::kDialogBody ,
1651
- GW::UI::UIMessage::kDialogButton
1652
- };
1653
- for (const auto message_id : dialog_ui_messages) {
1654
- RegisterUIMessageCallback (
1655
- &OnPostSendDialog_Entry,
1656
- message_id,
1657
- OnDialogUIMessage,
1658
- 0x8000
1659
- );
1660
- }
1661
-
1662
1686
constexpr GW::UI::UIMessage party_target_ui_messages[] = {
1663
1687
GW::UI::UIMessage::kTargetPlayerPartyMember ,
1664
1688
GW::UI::UIMessage::kTargetNPCPartyMember ,
@@ -1686,7 +1710,11 @@ void GameSettings::Initialize()
1686
1710
GW::UI::UIMessage::kShowCancelEnterMissionBtn ,
1687
1711
GW::UI::UIMessage::kPartyDefeated ,
1688
1712
GW::UI::UIMessage::kVanquishComplete ,
1689
- GW::UI::UIMessage::kPartyShowConfirmDialog
1713
+ GW::UI::UIMessage::kPartyShowConfirmDialog ,
1714
+ GW::UI::UIMessage::kVendorWindow ,
1715
+ GW::UI::UIMessage::kDialogButton ,
1716
+ GW::UI::UIMessage::kQuestAdded ,
1717
+ GW::UI::UIMessage::kSendSetActiveQuest
1690
1718
};
1691
1719
for (const auto message_id : post_ui_messages) {
1692
1720
RegisterUIMessageCallback (&OnPostUIMessage_HookEntry, message_id, OnPostUIMessage, 0x8000 );
@@ -1699,13 +1727,6 @@ void GameSettings::Initialize()
1699
1727
1700
1728
set_window_title_delay = TIMER_INIT ();
1701
1729
1702
- GW::UI::UIMessage ui_message_ids[] = {
1703
- GW::UI::UIMessage::kQuestAdded ,
1704
- GW::UI::UIMessage::kSendSetActiveQuest
1705
- };
1706
- for (const auto message_id : ui_message_ids) {
1707
- RegisterUIMessageCallback (&OnQuestUIMessage_HookEntry, message_id, OnPostQuestUIMessage, 0x8000 );
1708
- }
1709
1730
player_requested_active_quest_id = GW::QuestMgr::GetActiveQuestId ();
1710
1731
1711
1732
last_online_status = static_cast <uint32_t >(GW::FriendListMgr::GetMyStatus ());
@@ -1719,24 +1740,6 @@ void GameSettings::Initialize()
1719
1740
#endif
1720
1741
}
1721
1742
1722
- void GameSettings::OnDialogUIMessage (GW::HookStatus*, const GW::UI::UIMessage message_id, void * wparam, void *)
1723
- {
1724
- switch (message_id) {
1725
- case GW::UI::UIMessage::kDialogButton : {
1726
- const auto info = static_cast <GW::UI::DialogButtonInfo*>(wparam);
1727
- if (auto_open_locked_chest_with_key && wcscmp (info->message , L" \x8101\x7F88\x10A\x8101\x13BE\x1 " ) == 0 ) {
1728
- // Auto use key
1729
- DialogModule::SendDialog (info->dialog_id );
1730
- }
1731
- if (auto_open_locked_chest && wcscmp (info->message , L" \x8101\x7f88\x010a\x8101\x730e\x1 " ) == 0 ) {
1732
- // Auto use lockpick
1733
- DialogModule::SendDialog (info->dialog_id );
1734
- }
1735
- }
1736
- break ;
1737
- }
1738
- }
1739
-
1740
1743
1741
1744
void GameSettings::MessageOnPartyChange ()
1742
1745
{
@@ -2584,48 +2587,6 @@ void GameSettings::OnAgentLoopingAnimation(GW::HookStatus*, const GW::Packet::St
2584
2587
GW::StoC::EmulatePacket (&pak2);
2585
2588
}
2586
2589
2587
- // Skip char name entry dialog when donating faction
2588
- void GameSettings::OnFactionDonate (GW::HookStatus* status, GW::UI::UIMessage, void * wparam, void *) const
2589
- {
2590
- const auto dialog_id = (uint32_t )wparam;
2591
- if (!(dialog_id == 0x87 && skip_entering_name_for_faction_donate)) {
2592
- return ;
2593
- }
2594
- uint32_t allegiance = 2 ;
2595
- const auto raising_luxon_faction_cap = L" \x8102\x4A32\xAF32\xBDB5\x21AE " ;
2596
- const auto raising_kurzick_faction_cap = L" \x8102\x4A26\x814C\x89CC\x5B0 " ;
2597
- // Look for "Raising Luxon/Kurzick faction cap" dialog option to check allegiance
2598
- for (const auto dialog : DialogModule::Instance ().GetDialogButtons ()) {
2599
- if (wcscmp (dialog->message , raising_luxon_faction_cap) == 0 ) {
2600
- allegiance = 1 ; // Luxon
2601
- }
2602
- if (wcscmp (dialog->message , raising_kurzick_faction_cap) == 0 ) {
2603
- allegiance = 0 ; // Kurzick
2604
- }
2605
- }
2606
- const uint32_t * current_faction = nullptr ;
2607
- switch (allegiance) {
2608
- case 0 : // Kurzick
2609
- current_faction = &GW::GetWorldContext ()->current_kurzick ;
2610
- break ;
2611
- case 1 : // Luxon
2612
- current_faction = &GW::GetWorldContext ()->current_luxon ;
2613
- break ;
2614
- default : // Didn't find an allegiance, not the relevent dialog
2615
- return ;
2616
- }
2617
- GW::GuildContext* c = GW::GetGuildContext ();
2618
- if (!c || !c->player_guild_index || c->guilds [c->player_guild_index ]->faction != allegiance) {
2619
- return ; // Alliance isn't the right faction. Return here and the NPC will reply.
2620
- }
2621
- if (*current_faction < 5000 ) {
2622
- return ; // Not enough to donate. Return here and the NPC will reply.
2623
- }
2624
- status->blocked = true ;
2625
- GW::PlayerMgr::DepositFaction (allegiance);
2626
- GW::Agents::InteractAgent (GW::Agents::GetAgentByID (DialogModule::GetDialogAgent ()));
2627
- }
2628
-
2629
2590
// Show a message when player leaves the outpost
2630
2591
void GameSettings::OnPlayerLeaveInstance (GW::HookStatus*, const GW::Packet::StoC::PlayerLeaveInstance* pak)
2631
2592
{
0 commit comments