Skip to content

Commit 2b09004

Browse files
committed
Fixed crash when trying to sort party list
1 parent 9ae5c10 commit 2b09004

7 files changed

Lines changed: 25 additions & 31 deletions

File tree

Dependencies/GWCA/bin/gwca.dll

1.02 KB
Binary file not shown.

Dependencies/GWCA/include/GWCA/GWCAVersion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#define GWCA_VERSION_MAJOR 4
44
#define GWCA_VERSION_MINOR 5
5-
#define GWCA_VERSION_PATCH 1
5+
#define GWCA_VERSION_PATCH 2
66
#define GWCA_VERSION_BUILD 0
7-
#define GWCA_VERSION "4.5.1.0"
7+
#define GWCA_VERSION "4.5.2.0"
88

99
namespace GWCA {
1010
constexpr int VersionMajor = GWCA_VERSION_MAJOR;

Dependencies/GWCA/include/GWCA/GameEntities/Frame.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,17 @@ namespace GW {
4040
GWCA_API GW::ButtonFrame* GetTabButton(GW::UI::Frame* tab_frame);
4141

4242
};
43+
// Sorting handler is actually a boolean function - return "1" if frame_id_1 needs to be bubbled higher than frame_id_2
44+
typedef int(__cdecl* SortHandler_pt)(uint32_t frame_id_1, uint32_t frame_id_2);
45+
struct ItemListFrame : UI::Frame {
46+
// Returns false if the request failed, or nothing is selected
47+
GWCA_API bool GetSelectedValue(uint32_t* selected_value);
48+
GWCA_API bool SetSortHandler(SortHandler_pt sortHandler);
49+
GWCA_API SortHandler_pt GetSortHandler();
50+
};
51+
4352
struct ScrollableFrame : UI::Frame {
44-
// Sorting handler is actually a boolean function - return "1" if frame_id_1 needs to be bubbled higher than frame_id_2
45-
typedef int(__cdecl* SortHandler_pt)(uint32_t frame_id_1, uint32_t frame_id_2);
53+
4654
// Scrollable frame always has an "inner" page that handles the content. Only really need to mess with this if you're doing something odd.
4755
struct ScrollablePageContext {
4856
uint32_t flags;
@@ -59,18 +67,20 @@ namespace GW {
5967
GWCA_API bool RemoveItem(uint32_t child_offset_id);
6068
GWCA_API bool AddItem(uint32_t flags, uint32_t child_offset_id, GW::UI::UIInteractionCallback callback);
6169
GWCA_API uint32_t GetItemFrameId(uint32_t child_offset_id);
62-
// Returns false if the request failed, or nothing is selected
6370
GWCA_API bool GetSelectedValue(uint32_t* selected_value);
71+
6472
// This is actually the child_frame_id of the last child in the list - things that use sorting, or the child id to identify the frame, will not represent the size.
6573
GWCA_API bool GetCount(uint32_t* size);
6674
GWCA_API uint32_t GetItems(uint32_t* child_frame_id_buffer = nullptr, uint32_t buffer_len = 0);
6775

68-
GWCA_API GW::UI::Frame* GetPage();
76+
GWCA_API GW::ItemListFrame* GetPage();
6977
// Scrollable frame always has an "inner" page that handles the content. Only really need to mess with this if you're doing something odd.
70-
GWCA_API GW::UI::Frame* SetPage(ScrollablePageContext*);
78+
GWCA_API GW::ItemListFrame* SetPage(ScrollablePageContext*);
7179
};
7280

7381

82+
83+
7484
struct FrameWithValue {
7585
FrameWithValue() = default;
7686
virtual ~FrameWithValue() = default;

Dependencies/GWCA/lib/gwca.lib

1.1 KB
Binary file not shown.

GWToolboxdll/Modules/PartyWindowModule.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,8 @@ namespace {
490490

491491
bool OverridePartySortOrder(bool _override = true)
492492
{
493-
const auto player_list = (GW::ScrollableFrame*)GW::UI::GetChildFrame(SnapsToPartyWindow::GetPartyWindowHealthBars(), 0);
493+
const auto player_list = (GW::ItemListFrame*)GW::UI::GetChildFrame(SnapsToPartyWindow::GetPartyWindowHealthBars(), 0);
494494
if (!player_list) return false;
495-
uint32_t count = 0;
496-
player_list->GetCount(&count);
497495
return player_list->SetSortHandler(0) && player_list->SetSortHandler(_override ? PartySortHandler : 0);
498496
}
499497
void RefreshPartySortHandler()
@@ -740,7 +738,8 @@ namespace {
740738
ImGui::SetNextItemWidth(120.0f * fontScale);
741739
if (ImGui::BeginCombo("##primary", ToolboxUtils::GetProfessionAcronym(static_cast<GW::Constants::Profession>(primary))->string().c_str())) {
742740
for (uint8_t prof = 0; prof <= 10; prof++) {
743-
if (ImGui::Selectable(ToolboxUtils::GetProfessionAcronym(static_cast<GW::Constants::Profession>(prof))->string().c_str(), primary == prof)) {
741+
auto id = std::format("{}##prof_{}", ToolboxUtils::GetProfessionAcronym(static_cast<GW::Constants::Profession>(prof))->string(), prof);
742+
if (ImGui::Selectable(id.c_str(), primary == prof)) {
744743
primary = prof;
745744
edit_profession_order[i] = (static_cast<uint16_t>(primary) << 8) | secondary;
746745
}
@@ -756,7 +755,8 @@ namespace {
756755
ImGui::SetNextItemWidth(120.0f * fontScale);
757756
if (ImGui::BeginCombo("##secondary", ToolboxUtils::GetProfessionAcronym(static_cast<GW::Constants::Profession>(secondary))->string().c_str())) {
758757
for (uint8_t prof = 0; prof <= 10; prof++) {
759-
if (ImGui::Selectable(ToolboxUtils::GetProfessionAcronym(static_cast<GW::Constants::Profession>(prof))->string().c_str(), secondary == prof)) {
758+
auto id = std::format("{}##prof_{}", ToolboxUtils::GetProfessionAcronym(static_cast<GW::Constants::Profession>(prof))->string(), prof);
759+
if (ImGui::Selectable(id.c_str(), secondary == prof)) {
760760
secondary = prof;
761761
edit_profession_order[i] = (static_cast<uint16_t>(primary) << 8) | secondary;
762762
}

GWToolboxdll/Widgets/SnapsToPartyWindow.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,8 @@ bool SnapsToPartyWindow::RecalculatePartyPositions() {
194194
ImVec2 top_left;
195195
ImVec2 bottom_right;
196196
const auto party = GW::PartyMgr::GetPartyInfo();
197-
// @Cleanup: Fetch party frame once, only update when it has been destroyed
198-
const auto party_frame = party ? GW::UI::GetFrameByLabel(L"Party") : nullptr;
199-
if (!(party_frame && party_frame->IsVisible()))
200-
return false;
201-
202-
// Traverse to health bars
203-
if (GW::Map::GetInstanceType() == GW::Constants::InstanceType::Outpost) {
204-
auto sub_frame = GW::UI::GetChildFrame(party_frame, 1);
205-
sub_frame = GW::UI::GetChildFrame(sub_frame, 8);
206-
sub_frame = GW::UI::GetChildFrame(sub_frame, 0);
207-
sub_frame = GW::UI::GetChildFrame(sub_frame, 0);
208-
party_window_health_bars = GW::UI::GetChildFrame(sub_frame, 0);
209-
}
210-
else {
211-
auto sub_frame = GW::UI::GetChildFrame(party_frame, 0);
212-
sub_frame = GW::UI::GetChildFrame(sub_frame, 0);
213-
party_window_health_bars = GW::UI::GetChildFrame(sub_frame, 0);
214-
}
197+
GW::UI::Frame* party_frame = 0;
198+
party_window_health_bars = GetPartyWindowHealthBars(&party_frame);
215199

216200
if (!party_window_health_bars)
217201
return false;

GWToolboxdll/Widgets/TitleTrackerWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ namespace {
182182
TitleProgress p1(title_id_1), p2(title_id_2);
183183
return CompareTitleProgress(&p1, &p2) ? 1 : 0;
184184
}
185-
GW::ScrollableFrame::SortHandler_pt OriginalSortHandler = 0;
185+
GW::SortHandler_pt OriginalSortHandler = 0;
186186
bool OverrideTitleSortOrder(bool _override = true)
187187
{
188188
const auto frame = (GW::ScrollableFrame*)GW::UI::GetChildFrame(GW::UI::GetFrameByLabel(L"Attributes"), 5, 2, 0);

0 commit comments

Comments
 (0)