Skip to content

Commit

Permalink
Add patch 6.4 Ruby Route
Browse files Browse the repository at this point in the history
Add option to have multiple database files for multiple routes
Add route dropdown menu option in property inspector
Add default fish icon for when no target is selected
Add images for ruby route fish
Add more tests
Moved processing code into FFXIVOceanFishingProcessor files, made Helper just a wrapper around multiple processors
Added multi-achievement images for routes with two achievements, made this show up when viewing by Next Route
Updated to v2.0
  • Loading branch information
momokotomoko committed May 26, 2023
1 parent cec7b34 commit 1c9616c
Show file tree
Hide file tree
Showing 75 changed files with 1,915 additions and 855 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# FFXIV Ocean Fishing Plugin for the Elgato StreamDeck

## NOW UPDATED FOR PATCH 6.4 RUBY ROUTE
[Please refer to Installation section](#installation), **the previous installation must be removed or it won't install properly.**

StreamDeck is an external LCD key macro device that allows the installation of plugins to improve productivity.

Final Fantasy XIV is a MMORPG video game.
Expand Down
Binary file modified Release/com.elgato.ffxivoceanfishing.streamDeckPlugin
Binary file not shown.
108 changes: 77 additions & 31 deletions Sources/FFXIVOceanFishingTrackerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
@file FFXIVOceanFishingTrackerPlugin.cpp
@brief FFXIV Ocean Fishing Tracker plugin
@copyright (c) 2020, Momoko Tomoko
@copyright (c) 2023, Momoko Tomoko
**/
//==============================================================================

Expand All @@ -17,12 +17,17 @@

#include "Common/ESDConnectionManager.h"

//#define LOGGING
#define LOGGING


FFXIVOceanFishingTrackerPlugin::FFXIVOceanFishingTrackerPlugin()
{
mFFXIVOceanFishingHelper = new FFXIVOceanFishingHelper();
mFFXIVOceanFishingHelper = new FFXIVOceanFishingHelper(
{
"oceanFishingDatabase - Indigo Route.json",
"oceanFishingDatabase - Ruby Route.json"
}
);

// timer that is called on certain minutes of the hour
mTimer = new CallBackTimer();
Expand Down Expand Up @@ -81,26 +86,45 @@ void FFXIVOceanFishingTrackerPlugin::startTimers()
{
// First find what routes we are actually looking for.
// So convert what is requested to be tracked into route IDs
std::unordered_set<uint32_t> routeIds = mFFXIVOceanFishingHelper->getRouteIdByTracker(context.second.tracker, context.second.name);
std::unordered_set<uint32_t> routeIds =
mFFXIVOceanFishingHelper->getVoyageIdByTracker(
context.second.routeName,
context.second.tracker,
context.second.targetName
);

// now call the helper to compute the relative time until the next window
int relativeSecondsTillNextRoute = 0;
int relativeWindowTime = 0;
uint32_t relativeSecondsTillNextRoute = 0;
uint32_t relativeWindowTime = 0;
time_t startTime = time(0);
uint32_t nextRoute;
status = mFFXIVOceanFishingHelper->getSecondsUntilNextRoute(relativeSecondsTillNextRoute, relativeWindowTime, nextRoute, startTime, routeIds, context.second.skips);
status = mFFXIVOceanFishingHelper->getSecondsUntilNextVoyage(
relativeSecondsTillNextRoute,
relativeWindowTime,
startTime,
routeIds,
context.second.routeName,
context.second.skips
);
// store the absolute times
context.second.routeTime = startTime + relativeSecondsTillNextRoute;
context.second.windowTime = startTime + relativeWindowTime;

std::string imageName;
std::string buttonLabel;
mFFXIVOceanFishingHelper->getImageNameAndLabel(imageName, buttonLabel, context.second.tracker, context.second.name, context.second.priority, context.second.skips);
mFFXIVOceanFishingHelper->getImageNameAndLabel(
imageName,
buttonLabel,
context.second.routeName,
context.second.tracker,
context.second.targetName,
context.second.priority,
context.second.skips
);
if (context.second.imageName != imageName || context.second.buttonLabel != buttonLabel)
context.second.needUpdate = true;

// update the image
if (status && context.second.needUpdate)
if (context.second.needUpdate)
{
context.second.imageName = imageName;
context.second.buttonLabel = buttonLabel;
Expand Down Expand Up @@ -135,9 +159,10 @@ void FFXIVOceanFishingTrackerPlugin::UpdateUI()
time_t now = time(0);
for (const auto & context : mContextServerMap)
{
if (context.second.name.length() > 0)
std::string titleString = "";
if (context.second.targetName.length() > 0)
{
std::string titleString = context.second.buttonLabel + "\n";
titleString = context.second.buttonLabel + "\n";
// if we have skips, add a number to the top right
if (context.second.skips != 0)
{
Expand Down Expand Up @@ -167,12 +192,11 @@ void FFXIVOceanFishingTrackerPlugin::UpdateUI()
}
else
{
titleString += timeutils::convertSecondsToHMSString(static_cast<int>(difftime(context.second.routeTime, now)));
titleString += "\n" + timeutils::convertSecondsToHMSString(static_cast<int>(difftime(context.second.routeTime, now)));
}

// send the title to StreamDeck
mConnectionManager->SetTitle(titleString, context.first, kESDSDKTarget_HardwareAndSoftware);
}
// send the title to StreamDeck
mConnectionManager->SetTitle(titleString, context.first, kESDSDKTarget_HardwareAndSoftware);
}
mVisibleContextsMutex.unlock();
}
Expand Down Expand Up @@ -209,14 +233,19 @@ FFXIVOceanFishingTrackerPlugin::contextMetaData_t FFXIVOceanFishingTrackerPlugin
mConnectionManager->LogMessage(payload.dump(4));
#endif
contextMetaData_t data{};
if (payload.find("Tracker") != payload.end())
if (payload.find("Route") != payload.end())
{
data.routeName = payload["Route"].get<std::string>();
}
if (payload.find("Tracker") != payload.end() &&
payload["Tracker"].is_string())
{
data.tracker = payload["Tracker"].get<std::string>();
}
if (payload.find("Name") != payload.end())
{
data.name = payload["Name"].get<std::string>();
data.buttonLabel = data.name;
data.targetName = payload["Name"].get<std::string>();
data.buttonLabel = data.targetName;
data.imageName = data.imageName;
}
if (payload.find("DateOrTime") != payload.end())
Expand Down Expand Up @@ -252,6 +281,9 @@ FFXIVOceanFishingTrackerPlugin::contextMetaData_t FFXIVOceanFishingTrackerPlugin
**/
void FFXIVOceanFishingTrackerPlugin::updateImage(std::string name, const std::string& inContext)
{
if (name.empty())
name = "default";

// if image was cached, just retrieve from cache
if (mImageNameToBase64Map.contains(name))
{
Expand Down Expand Up @@ -281,26 +313,26 @@ void FFXIVOceanFishingTrackerPlugin::updateImage(std::string name, const std::st
**/
void FFXIVOceanFishingTrackerPlugin::WillAppearForAction(const std::string& inAction, const std::string& inContext, const json &inPayload, const std::string& inDeviceID)
{
// setup the dropdown menu by sending all possible settings
mConnectionManager->LogMessage("WillAppearForAction");
// read payload for any saved settings, update image if needed
contextMetaData_t data{};
if (inPayload.find("settings") != inPayload.end())
{
data = readJsonIntoMetaData(inPayload["settings"]);
}
data.needUpdate = true;

// setup the routes menu
mInitMutex.lock();
if (mConnectionManager != nullptr && mIsInit == false)
{
json j;
j["menuheaders"] = mFFXIVOceanFishingHelper->getTrackerTypesJson();
j["targets"] = mFFXIVOceanFishingHelper->getTargetsJson();
j["routes"] = mFFXIVOceanFishingHelper->getRouteNames();
mConnectionManager->SetGlobalSettings(j);
mIsInit = true;
}
mInitMutex.unlock();

// read payload for any saved settings, update image if needed
contextMetaData_t data{};
if (inPayload.find("settings") != inPayload.end())
{
data = readJsonIntoMetaData(inPayload["settings"]);
}
data.needUpdate = true;

// if this is the first plugin to be displayed, boot up the timers
if (mContextServerMap.empty())
{
Expand Down Expand Up @@ -352,15 +384,29 @@ void FFXIVOceanFishingTrackerPlugin::SendToPlugin(const std::string& inAction, c
// PI dropdown menu has saved new settings for this context, load those
contextMetaData_t data;
mVisibleContextsMutex.lock();

mConnectionManager->LogMessage("BLAH");

mConnectionManager->LogMessage(inPayload.dump(4));
if (mContextServerMap.find(inContext) != mContextServerMap.end())
{
data = readJsonIntoMetaData(inPayload);
if (data.name != mContextServerMap.at(inContext).name || data.tracker != mContextServerMap.at(inContext).tracker)
if (data.routeName != mContextServerMap.at(inContext).routeName ||
data.targetName != mContextServerMap.at(inContext).targetName ||
data.tracker != mContextServerMap.at(inContext).tracker)
{
// update image since name changed
data.needUpdate = true;
}

if (data.routeName != mContextServerMap.at(inContext).routeName)
{
json j;
j["menuheaders"] = mFFXIVOceanFishingHelper->getTrackerTypesJson(data.routeName);
j["targets"] = mFFXIVOceanFishingHelper->getTargetsJson(data.routeName);
mConnectionManager->SetSettings(j, inContext);
}

// updated stored settings
mContextServerMap.at(inContext) = data;
}
Expand Down
5 changes: 3 additions & 2 deletions Sources/FFXIVOceanFishingTrackerPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
@file FFXIVOceanFishingTrackerPlugin.h
@brief FFXIV Ocean Fishing Tracker plugin
@copyright (c) 2020, Momoko Tomoko
@copyright (c) 2023, Momoko Tomoko
**/
//==============================================================================

Expand Down Expand Up @@ -49,7 +49,8 @@ class FFXIVOceanFishingTrackerPlugin : public ESDBasePlugin
// this struct contains a context's saved settings
struct contextMetaData_t
{
std::string name; // name of what we are tracking
std::string routeName; // name of the route we are using
std::string targetName; // name of target we are tracking
std::string tracker; // tracker type, ie: blue fish or route name
std::string buttonLabel; // the text on the top of the button
std::string imageName; // the name of hte image to use for this button
Expand Down
Binary file added Sources/Resources/Shellfish_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/Shrimp_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/Squid_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Dusk_Shark_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Fishy_Shark_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Gakugyo_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Glass_Dragon_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Hells'_Claw_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Mailfish_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Mizuhiki_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Pitch_Pickle_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Shellfish_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Shrimp_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Spadefish_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Squid_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Taniwha_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Un-Namazu_Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Sources/Resources/rescaled/Yellow_Iris_Icon.png

0 comments on commit 1c9616c

Please sign in to comment.