Skip to content

Commit

Permalink
easyfind ui for starting a find
Browse files Browse the repository at this point in the history
  • Loading branch information
brainiac committed Aug 1, 2021
1 parent 6b48774 commit 4e325cb
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 9 deletions.
51 changes: 42 additions & 9 deletions MQ2EasyFind.cpp
Expand Up @@ -983,6 +983,36 @@ class CFindLocationWndOverride : public WindowOverride<CFindLocationWndOverride,
return false;
}

private:
void FindLocationByListIndex(int listIndex, bool group)
{
// Perform navigaiton by triggering a selection in the list.
s_performCommandFind = true;
s_performGroupCommandFind = group;

findLocationList->SetCurSel(listIndex);
findLocationList->ParentWndNotification(findLocationList, XWM_LCLICK, (void*)listIndex);

s_performCommandFind = false;
s_performGroupCommandFind = false;
}

public:
void FindLocationByRefNum(int refNum, bool group)
{
for (int index = 0; index < findLocationList->GetItemCount(); ++index)
{
int itemRefNum = (int)findLocationList->GetItemData(index);
if (itemRefNum == refNum)
{
FindLocationByListIndex(index, group);
return;
}
}

WriteChatf(PLUGIN_MSG "\arCouldn't find location by ref: %d", refNum);
}

void FindLocation(std::string_view searchTerm, bool group)
{
// TODO: Wait for zone connections.
Expand Down Expand Up @@ -1042,15 +1072,7 @@ class CFindLocationWndOverride : public WindowOverride<CFindLocationWndOverride,
return;
}

// Perform navigaiton by triggering a selection in the list.
s_performCommandFind = true;
s_performGroupCommandFind = group;

findLocationList->SetCurSel(foundIndex);
findLocationList->ParentWndNotification(findLocationList, XWM_LCLICK, (void*)foundIndex);

s_performCommandFind = false;
s_performGroupCommandFind = false;
FindLocationByListIndex(foundIndex, group);
}

void LoadZoneSettings()
Expand Down Expand Up @@ -2018,6 +2040,17 @@ PLUGIN_API void OnUpdateImGui()
ImGui::TextColored(MQColor(127, 127, 127).ToImColor(), "Unmodified");
}

if (ImGui::Button("EasyFind"))
{
findLocWnd->FindLocationByRefNum(selectedRef, false);
}

ImGui::SameLine();
if (ImGui::Button("Group EasyFind"))
{
findLocWnd->FindLocationByRefNum(selectedRef, true);
}

ImGui::NewLine();
ImGui::TextColored(MQColor("#D040FF").ToImColor(), "Find Location Data:");
ImGui::Separator();
Expand Down
1 change: 1 addition & 0 deletions MQ2EasyFind.vcxproj
Expand Up @@ -74,6 +74,7 @@
<ResourceCompile Include="MQ2EasyFind.rc" />
</ItemGroup>
<ItemGroup>
<None Include="config\MQ2EasyFind.yaml" />
<None Include="README.md" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
3 changes: 3 additions & 0 deletions MQ2EasyFind.vcxproj.filters
Expand Up @@ -28,5 +28,8 @@
</ItemGroup>
<ItemGroup>
<None Include="README.md" />
<None Include="config\MQ2EasyFind.yaml">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions config/MQ2EasyFind.yaml
Expand Up @@ -48,6 +48,10 @@ FindLocations:
- type: ZoneConnection
switch: 2
targetZone: chapterhouse
- type: Translocator
name: Magus Zeir
keyword: Nedaria's Landing
targetZone: nedaria
corathus:
- type: ZoneConnection
location: [-390.25, -135.460006, -63.7000007]
Expand Down Expand Up @@ -106,6 +110,11 @@ FindLocations:
- type: ZoneConnection
location: [-3445, 1550, -344]
targetZone: trakanon
everfrost:
- type: Translocator
name: Magus Delin
keyword: Nedaria's Landing
targetZone: nedaria
feerrott:
- type: ZoneConnection
location: [400, 3410, 6]
Expand Down Expand Up @@ -199,6 +208,10 @@ FindLocations:
- type: ZoneConnection
switch: 2
targetZone: poknowledge
- type: Translocator
name: Magus Alaria
keyword: Nedaria's Landing
targetZone: nedaria
gyrospireb:
- type: ZoneConnection
switch: 2
Expand Down

0 comments on commit 4e325cb

Please sign in to comment.