Skip to content

Commit

Permalink
Add a few new features and cleanup
Browse files Browse the repository at this point in the history
- Update version to 0.8.0 BETA
- Add easyfind command after arriving in travelto destination via @ syntax
- Add /easyfind reloadsettings
- Add About tab
  • Loading branch information
brainiac committed Aug 30, 2021
1 parent 84ddf08 commit e584517
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 56 deletions.
56 changes: 43 additions & 13 deletions EasyFind.cpp
Expand Up @@ -6,9 +6,9 @@
#include "plugins/lua/LuaInterface.h"

PreSetup("MQ2EasyFind");
PLUGIN_VERSION(0.7);
PLUGIN_VERSION(0.8);

#define EASYFIND_PLUGIN_VERSION "0.7.1"
#define EASYFIND_PLUGIN_VERSION "0.8.0"

static mq::lua::LuaPluginInterface* s_lua = nullptr;

Expand Down Expand Up @@ -146,20 +146,24 @@ void ShowHelp()
{
WriteChatf(PLUGIN_MSG "EasyFind Usage:");
WriteChatf(PLUGIN_MSG "\ag/easyfind \ao[search term]");
WriteChatf(PLUGIN_MSG "\ag/easyfind \aygroup\ax \ao[search term]");
WriteChatf(PLUGIN_MSG " Searches the Find Window for the given \ao[search term]\ax, either exact or partial match. If found, begins navigation. "
"\ao[search term]\ax may also be a zone shortname. In this case, the closest zone connection matching for that zone will be found. "
"If \aggroup\ax is specified, the command will attempt to navigate the whole group.");
"\ao[search term]\ax may also be a zone shortname. In this case, the closest zone connection matching for that zone will be found. ");
WriteChatf(PLUGIN_MSG "\ag/easyfind \aygroup\ax \ao[command]");
WriteChatf(PLUGIN_MSG, " Broadcasts the command to the group, using the configured group plugin.");
WriteChatf(PLUGIN_MSG "\ag/easyfind \aystop\aw - Stops any active easyfind.");
WriteChatf(PLUGIN_MSG "\ag/easyfind \ayreload\aw - Reload zone connections from easyfind folder: \ay%s", g_zoneConnections->GetConfigDir().c_str());
WriteChatf(PLUGIN_MSG "\ag/easyfind \ayui\aw - Toggle EasyFind ui");
WriteChatf(PLUGIN_MSG "\ag/easyfind \aymigrate\aw - Migrate MQ2EasyFind.ini from old MQ2EasyFind to new format");
WriteChatf(PLUGIN_MSG "\ag/easyfind \aynav \ao[nav command]\aw - Find using a nav command of find window.");

WriteChatf(PLUGIN_MSG "");
WriteChatf(PLUGIN_MSG "\ag/travelto \ao[zonename]");
WriteChatf(PLUGIN_MSG "\ag/travelto \aygroup\ax \ao[zonename]");
WriteChatf(PLUGIN_MSG " Find a route to the specified \ao[zonename]\ax (short or long) and then follow it. "
"If \aggroup\ax is specified, the command will attempt to navigate the whole group.");
WriteChatf(PLUGIN_MSG " Find a route to the specified \ao[zonename]\ax (short or long) and then follow it.");
WriteChatf(PLUGIN_MSG "\ag/travelto \ao[zonename] \ay@\ax \ao[easyfind command]\ax");
WriteChatf(PLUGIN_MSG " Upon arrival in \ao[zonename]\ax, execute \ao[easyfind command]\ax");
WriteChatf(PLUGIN_MSG " Ex: /travelto poknowledge @ Dogle Pitt");
WriteChatf(PLUGIN_MSG "\ag/travelto \aygroup\ax \ao[command]");
WriteChatf(" Broadcasts the command to the group, using the configured group plugin.");
WriteChatf(PLUGIN_MSG "\ag/travelto \ayactivate\aw - If an existing zone path is active (created by the zone guide), "
"activate that path with /travelto");
WriteChatf(PLUGIN_MSG "\ag/travelto \aystop\aw - Stops an active /travelto");
Expand All @@ -180,7 +184,6 @@ void Command_EasyFind(SPAWNINFO* pSpawn, char* szLine)
if (ci_equals(szLine, "migrate"))
{
g_zoneConnections->MigrateIniData();
// TODO: Save/Reload?
return;
}

Expand All @@ -190,6 +193,12 @@ void Command_EasyFind(SPAWNINFO* pSpawn, char* szLine)
return;
}

if (ci_equals(szLine, "reloadsettings"))
{
g_configuration->ReloadSettings();
return;
}

if (ci_equals(szLine, "ui"))
{
ImGui_ToggleWindow();
Expand Down Expand Up @@ -272,10 +281,24 @@ void Command_TravelTo(SPAWNINFO* pSpawn, char* szLine)
return;
}

EQZoneInfo* pTargetZone = pWorldData->GetZone(GetZoneID(szLine));
// Extract target query if provided
std::string command = szLine;
std::string query;

size_t pos = command.find_first_of("@");
if (pos != std::string::npos)
{
query = command.substr(pos + 1);
command = command.substr(0, pos);

trim(command);
trim(query);
}

EQZoneInfo* pTargetZone = pWorldData->GetZone(GetZoneID(command.c_str()));
if (!pTargetZone)
{
SPDLOG_ERROR("Invalid zone: {}", szLine);
SPDLOG_ERROR("Invalid zone: {}", command);
return;
}

Expand All @@ -294,9 +317,16 @@ void Command_TravelTo(SPAWNINFO* pSpawn, char* szLine)
return;
}

SPDLOG_INFO("\aoTraveling to: \ag{}", pTargetZone->LongName);
if (query.empty())
SPDLOG_INFO("\aoTraveling to: \ag{}", pTargetZone->LongName);
else
SPDLOG_INFO("\aoTraveling to: \ag{}\ao at \ay{}", pTargetZone->LongName, query);

ZonePathRequest request;
request.zonePath = std::move(path);
request.targetQuery = std::move(query);

ZonePath_SetActive(path, true);
ZonePath_SetActive(request, true);
}

PLUGIN_API void InitializePlugin()
Expand Down
14 changes: 13 additions & 1 deletion EasyFind.h
Expand Up @@ -110,8 +110,20 @@ struct ZonePathNode {
: zoneId(data.zoneId), transferTypeIndex(data.transferTypeIndex) {}
};

struct ZonePathRequest
{
std::vector<ZonePathNode> zonePath;
std::string targetQuery;

void clear()
{
zonePath.clear();
targetQuery.clear();
}
};

std::vector<ZonePathNode> ZonePath_GeneratePath(EQZoneIndex fromZone, EQZoneIndex toZone, std::string& outputMessage);
void ZonePath_SetActive(const std::vector<ZonePathNode>& zonePathData, bool travel);
void ZonePath_SetActive(const ZonePathRequest& zonePathData, bool travel);
void ZonePath_OnPulse();
void ZonePath_NavCanceled(bool message);
void ZonePath_FollowActive();
Expand Down
11 changes: 11 additions & 0 deletions EasyFindConfiguration.cpp
Expand Up @@ -251,6 +251,8 @@ void EasyFindConfiguration::ResetSettings()
m_groupPluginSelection = ConfiguredGroupPlugin::Auto;
m_distanceColumnEnabled = true;
m_coloredFindWindowEnabled = true;
m_silentGroupCommands = true;
m_verboseMessages = false;

m_configNode = YAML::Node();
SaveSettings();
Expand Down Expand Up @@ -283,6 +285,7 @@ void EasyFindConfiguration::LoadSettings()
m_coloredFindWindowEnabled = m_configNode["ColoredFindWindow"].as<bool>(true);
m_distanceColumnEnabled = m_configNode["DistanceColumn"].as<bool>(true);
m_silentGroupCommands = m_configNode["SilentGroupCommands"].as<bool>(true);
m_verboseMessages = m_configNode["VerboseMessages"].as<bool>(false);
}
catch (const YAML::ParserException& ex)
{
Expand Down Expand Up @@ -392,6 +395,14 @@ void EasyFindConfiguration::SetSilentGroupCommands(bool silent)
SaveSettings();
}

void EasyFindConfiguration::SetVerboseMessages(bool verbose)
{
m_verboseMessages = verbose;
m_configNode["VerboseMessages"] = verbose;

SaveSettings();
}

//----------------------------------------------------------------------------

void EasyFindConfiguration::RefreshTransferTypes()
Expand Down
3 changes: 3 additions & 0 deletions EasyFindConfiguration.h
Expand Up @@ -70,6 +70,9 @@ class EasyFindConfiguration
void SetSilentGroupCommands(bool silent);
bool IsSilentGroupCommands() const { return m_silentGroupCommands; }

void SetVerboseMessages(bool verbose);
bool IsVerboseMEssages() const { return m_verboseMessages; }

// transfer types
void RefreshTransferTypes();
bool IsSupportedTransferType(int transferTypeIndex) const;
Expand Down
89 changes: 77 additions & 12 deletions EasyFindImGui.cpp
Expand Up @@ -599,23 +599,73 @@ static void DrawEasyFindZonePathGeneration()

if (ImGui::Button("Set Active"))
{
ZonePath_SetActive(s_zonePathTest, false);
ZonePathRequest req;
req.zonePath = s_zonePathTest;

ZonePath_SetActive(req, false);
}
ImGui::SameLine();
if (ImGui::Button("Travel"))
{
ZonePath_SetActive(s_zonePathTest, true);
ZonePathRequest req;
req.zonePath = s_zonePathTest;

ZonePath_SetActive(req, true);
}
}
}

void DrawEasyFindSettingsPanel()
void DrawAboutPanel()
{
if (!ImGui::BeginChild("##SettingsPanel"))
{
ImGui::EndChild();
return;
}
ImGui::PushFont(imgui::LargeTextFont);
ImGui::TextColored(MQColor(255, 255, 0).ToImColor(), "About");
ImGui::Separator();
ImGui::PopFont();

ImGui::TextWrapped("EasyFind is currently a BETA version.");
ImGui::PushStyleColor(ImGuiCol_Text, MQColor(255, 255, 0).ToImU32());
ImGui::TextWrapped("There may be some bugs or breaking changes in the future! Documentation is a work in progress and has not been completed.");
ImGui::PopStyleColor();

ImGui::NewLine();
ImGui::TextWrapped(
"EasyFind is a plugin that helps get you around EverQuest. The heavy lifting and actual "
"character movement is provided by the Nav plugin. EasyFind simply tells it where to go.\n"
"\n"
"EasyFind provides two main categories of functionality:\n"
" 1. Finding locations in the current zone.\n"
" 2. Navigating to other zones.\n"
"\n"
"You can interact with this plugin in the following ways:\n"
" * Ctrl+click on items in the Find window (opens with Ctrl+F by default)\n"
" * The /easyfind command - find locations in the current zone\n"
" * The /travelto command - travel to another zone\n"
" * Other tabs in this window\n"
"\n"
"You can also access settings for EasyFind through /mqsettings\n"
"\n"
"EasyFind uses the Find window to find locations in the current zone. This list can be "
"augmented by modifying resources/EasyFind/ZoneConnections.yaml. Sometimes existing locations "
"in the find window do not have enough information (or the information is inaccurate) and edits need "
"to be made to make them findable.\n\n"
"EasyFind uses the Zone Guide to find connections between zones, so that it can plot a course with /travelto. "
"Sometimes these connections are not reliable, so again we use ZoneConnections.yaml to fill in the blanks. "
"We use this yaml file for teleport NPCs because the Zone Guide and find window doesn't provide any information "
"about them, so if they are not in the yaml file, they will not be usable.\n"
"\n"
"Documentation on editing the ZoneConnections.yaml file is forthcoming. For now, hopefully it provides "
"enough examples to get started.\n\n"
);

ImGui::PushStyleColor(ImGuiCol_Text, MQColor(255, 255, 0).ToImU32());
ImGui::TextWrapped(
"For additional information on commands, run /easyfind help");
ImGui::PopStyleColor();

}

void DrawEasyFindSettingsPanel()
{
const ZoneGuideManagerClient& mgr = ZoneGuideManagerClient::Instance();

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -696,6 +746,12 @@ void DrawEasyFindSettingsPanel()
bool silentGroupCommands = g_configuration->IsSilentGroupCommands();
if (ImGui::Checkbox("Silent Group Commands", &silentGroupCommands))
g_configuration->SetSilentGroupCommands(silentGroupCommands);
HelpLabel("If checked, eqbc and dannet commands will be squelched.");

bool verboseMessages = g_configuration->IsVerboseMessages();
if (ImGui::Checkbox("Verbose status messages", &verboseMessages))
g_configuration->SetVerboseMessages(verboseMessages);
HelpLabel("If checked, some messages will contain additional status information");

ImGui::NewLine();
ImGui::Text("Colors:");
Expand Down Expand Up @@ -817,8 +873,6 @@ void DrawEasyFindSettingsPanel()
{
ImGui::Text("Zone Connections have not been loaded. Come back once in game.");
}

ImGui::EndChild();
}

static void DrawEasyFindSettingsPanel_MQSettings()
Expand Down Expand Up @@ -881,14 +935,25 @@ void ImGui_OnUpdate()

if (ImGui::BeginTabBar("EasyFindTabBar", ImGuiTabBarFlags_None))
{
if (ImGui::BeginTabItem("Welcome"))
if (ImGui::BeginTabItem("About"))
{
if (ImGui::BeginChild("##AboutPanel"))
{
DrawAboutPanel();
ImGui::EndChild();
}

ImGui::EndTabItem();
}

if (ImGui::BeginTabItem("Settings"))
{
DrawEasyFindSettingsPanel();
if (ImGui::BeginChild("##SettingsPanel"))
{
DrawEasyFindSettingsPanel();
ImGui::EndChild();
}

ImGui::EndTabItem();
}

Expand Down
2 changes: 1 addition & 1 deletion EasyFindWindow.cpp
Expand Up @@ -735,7 +735,7 @@ bool CFindLocationWndOverride::PerformFindWindowNavigation(int refId, bool asGro
if (customLocation)
request.findableLocation = std::make_shared<FindableLocation>(*customLocation);

if (pSwitch)
if (pSwitch && g_configuration->IsVerboseMessages())
{
SPDLOG_INFO("Navigating to \ayZone Connection\ax: \ag{}\ax (via switch \ao{}\ax)", locationName, pSwitch->Name);
}
Expand Down

0 comments on commit e584517

Please sign in to comment.