Skip to content

Commit

Permalink
Fix first time use bug, small refactoring
Browse files Browse the repository at this point in the history
Make getImageNameAndLabel not compute time internally
Add more tests for processor
Fix bug in processor for next-route names not appearing, this was not in release but from previous .contains refactor.
Fix issue where on first placing a plugin icon, clicking it would not load the default webpage.
May haev fixed issue where first time users could not see a route dropdown.
Add default text to Route/Track by dropdown menus to make it more clear what the user should do.
Update readme.
Release v2.01
  • Loading branch information
momokotomoko committed May 27, 2023
1 parent baee0c4 commit 35f2f55
Show file tree
Hide file tree
Showing 15 changed files with 262 additions and 67 deletions.
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# 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.**

Note: it is rare but some users may not see a dropdown menu for Routes on first install and initial use. This bug is still being investigated, but may be fixed in v2.01. A restart typically solves this issue.

-----------------------

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 Expand Up @@ -34,7 +40,17 @@ In the Release folder, you can find the file `com.elgato.ffxivoceanfishing.strea

[com.elgato.ffxivoceanfishing.streamDeckPlugin](Release/com.elgato.ffxivoceanfishing.streamDeckPlugin)

If an installation was previously present, you must delete the plugin folder located in Elgato's AppData folder. For example: `C:\Users\<username>\AppData\Roaming\Elgato\StreamDeck\Plugins`
If an installation was previously present, it must be uninstalled before re-installing. This can be done by right-clicking the plugin name in the Stream Deck right-hand list of plugins, and selecting Uninstall.

The image below shows the steps:

1. Search for the plugin name in Stream Deck application search bar.
2. Right click the plugin name to bring up a menu.
3. Click Uninstall.

![](uninstall_steps.png)

Alternatively, delete the plugin folder located in Elgato's AppData folder. For example: `C:\Users\<username>\AppData\Roaming\Elgato\StreamDeck\Plugins`

## Settings

Expand All @@ -44,6 +60,10 @@ If an installation was previously present, you must delete the plugin folder loc

The title is automatically set by the plugin to display the server name and progress percentage.

`Route`

Select an Ocean Fishing route, such as the Indigo Route or Ruby Route.

`Track by:`

Select either an Achievement, Blue Fish or a Route to track. You can also select Next Route to display whatever is coming up next. Icons will be dynamically updated.
Expand Down Expand Up @@ -74,11 +94,26 @@ This option has no effect if tracking by Achievements or Blue Fish directly.

A custom URL per button can be set such that when the StreamDeck button is pressed, the webpage is opened by the default browser.

By default, the webpage is set to the [Ocean Fishing Spreadsheet](https://docs.google.com/spreadsheets/d/1brCfvmSdYl7RcY9lkgm_ds8uaFqq7qaxOOz-5BfHuuk/htmlview)
By default, the webpage is set to the [Ocean Fishing Spreadsheet](https://docs.google.com/spreadsheets/d/1R0Nt8Ye7EAQtU8CXF1XRRj67iaFpUk1BXeDgt6abxsQ/edit#gid=93698338)

Other suggested links include:

- [Lulu's Tools'](https://ffxiv.pf-n.co/ocean-fishing)
- Pastebin notes for macros/instructions for particular achievements/fish

## Source Code

The source code can be found in the Sources folder.
The source code can be found in the [`Sources`](Sources) folder, with plugin specific files found in [`Windows`](Sources/Windows).

The Property Inspector and other associated files can be found in [`com.elgato.ffxivoceanfishing.sdPlugin`](Sources/com.elgato.ffxivoceanfishing.sdPlugin).

General Elgato and 3rd party files are found in [`Common`](Sources/Common) and [`Vendor`](Sources/Vendor).

Fish images are stored in [`Resources`](Sources/Resources), however the files used are rescaled and placed in [`Icons`](Sources/com.elgato.ffxivoceanfishing.sdPlugin/Icons).

To repackage the plugin after compilation, [`repackage.bat`](repackage.bat) uses the included Elgato [distribution tool](DistributionTool.exe), creating the installable in [`Release/com.elgato.ffxivoceanfishing.streamDeckPlugin`](Release/com.elgato.ffxivoceanfishing.streamDeckPlugin).

For development, [`reload.bat`](reload.bat) removes the old installation and re-installs it.

## Developed By

Expand Down
Binary file modified Release/com.elgato.ffxivoceanfishing.streamDeckPlugin
Binary file not shown.
13 changes: 7 additions & 6 deletions Sources/FFXIVOceanFishingTrackerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ void FFXIVOceanFishingTrackerPlugin::startTimers()
context.second.routeName,
context.second.tracker,
context.second.targetName,
startTime,
context.second.priority,
context.second.skips
);
if (context.second.imageName != imageName || context.second.buttonLabel != buttonLabel)
context.second.needUpdate = true;

// update the image
if (context.second.needUpdate)
// update the image if needUpdate flag was set, or if name/label changed
if (context.second.needUpdate ||
context.second.imageName != imageName ||
context.second.buttonLabel != buttonLabel)
{
context.second.imageName = imageName;
context.second.buttonLabel = buttonLabel;
Expand Down Expand Up @@ -293,7 +294,7 @@ void FFXIVOceanFishingTrackerPlugin::updateImage(std::string name, const std::st
/**
@brief Runs when app shows up on streamdeck profile
**/
void FFXIVOceanFishingTrackerPlugin::WillAppearForAction(const std::string& inAction, const std::string& inContext, const json &inPayload, const std::string& inDeviceID)
void FFXIVOceanFishingTrackerPlugin::WillAppearForAction(const std::string& inAction, const std::string& inContext, const json& inPayload, const std::string& inDeviceID)
{
// read payload for any saved settings, update image if needed
contextMetaData_t data{};
Expand Down Expand Up @@ -374,7 +375,7 @@ void FFXIVOceanFishingTrackerPlugin::SendToPlugin(const std::string& inAction, c

if (data.routeName != mContextServerMap.at(inContext).routeName)
{
json j;
json j = inPayload;
j["menuheaders"] = mFFXIVOceanFishingHelper->getTrackerTypesJson(data.routeName);
j["targets"] = mFFXIVOceanFishingHelper->getTargetsJson(data.routeName);
mConnectionManager->SetSettings(j, inContext);
Expand Down
2 changes: 2 additions & 0 deletions Sources/Windows/FFXIVOceanFishingHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void FFXIVOceanFishingHelper::getImageNameAndLabel(
const std::string& routeName,
const std::string& tracker,
const std::string& name,
const time_t& startTime,
const PRIORITY priority,
const uint32_t skips
)
Expand All @@ -103,6 +104,7 @@ void FFXIVOceanFishingHelper::getImageNameAndLabel(
buttonLabel,
tracker,
name,
startTime,
priority,
skips
);
Expand Down
1 change: 1 addition & 0 deletions Sources/Windows/FFXIVOceanFishingHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class FFXIVOceanFishingHelper
const std::string& routeName,
const std::string& tracker,
const std::string& name,
const time_t& startTime,
const PRIORITY priority,
const uint32_t skips
);
Expand Down
14 changes: 11 additions & 3 deletions Sources/Windows/FFXIVOceanFishingProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ std::string FFXIVOceanFishingProcessor::createButtonLabelFromRouteId(const uint3
if (!mRouteIdToNameMap.contains(routeId))
return "";
std::string routeName = mRouteIdToNameMap.at(routeId);
if (mRoutes.contains(routeName))
if (!mRoutes.contains(routeName))
return "";

std::string blueFishName = mRoutes.at(routeName).blueFishPattern;
Expand All @@ -647,10 +647,19 @@ std::string FFXIVOceanFishingProcessor::createButtonLabelFromRouteId(const uint3
@param[in] routeName the name of the route
@param[in] tracker the name of the tracker type (ie: Blue Fish, Achievement)
@param[in] name the name of the actual thing to track (ie: name of fish, name of Achievement)
@param[in] startTime the time to start counting from.
@param[in] priority whether to prioritize achievement name or blue fish name
@param[in] skips number of windows to skip over
**/
void FFXIVOceanFishingProcessor::getImageNameAndLabel(std::string& imageName, std::string& buttonLabel, const std::string& tracker, const std::string& name, const PRIORITY priority, const uint32_t skips)
void FFXIVOceanFishingProcessor::getImageNameAndLabel(
std::string& imageName,
std::string& buttonLabel,
const std::string& tracker,
const std::string& name,
const time_t& startTime,
const PRIORITY priority,
const uint32_t skips
)
{
imageName = "";
buttonLabel = "";
Expand All @@ -670,7 +679,6 @@ void FFXIVOceanFishingProcessor::getImageNameAndLabel(std::string& imageName, st
std::unordered_set<uint32_t> routeIds = getRouteIdByTracker(tracker, name);

// get next route
time_t startTime = time(0);
uint32_t nextRoute;
if (getNextRoute(nextRoute, startTime, routeIds, skips))
{
Expand Down
20 changes: 18 additions & 2 deletions Sources/Windows/FFXIVOceanFishingProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,27 @@ class FFXIVOceanFishingProcessor
void loadDatabase(const json& j);

bool getNextRoute(uint32_t& nextRoute, const time_t& startTime, const std::unordered_set<uint32_t>& routeIds, const uint32_t skips = 0);
bool getSecondsUntilNextRoute(uint32_t& secondsTillNextRoute, uint32_t& secondsLeftInWindow, uint32_t& nextRoute, const time_t& startTime, const std::unordered_set<uint32_t>& routeIds, const uint32_t skips = 0);
bool getSecondsUntilNextRoute(
uint32_t& secondsTillNextRoute,
uint32_t& secondsLeftInWindow,
uint32_t& nextRoute,
const time_t& startTime,
const std::unordered_set<uint32_t>& routeIds,
const uint32_t skips = 0
);
std::string getNextRouteName(const time_t& t, const uint32_t skips = 0);

std::unordered_set<uint32_t> getRouteIdByTracker(const std::string& tracker, const std::string& name);
void getImageNameAndLabel(std::string& imageName, std::string& buttonLabel, const std::string& tracker, const std::string& name, const PRIORITY priority, const uint32_t skips);
void getImageNameAndLabel(
std::string& imageName,
std::string& buttonLabel,
const std::string& tracker,
const std::string& name,
const time_t& startTime,
const PRIORITY priority,
const uint32_t skips
);

json getTargetsJson();
json getTrackerTypesJson();
private:
Expand Down
6 changes: 2 additions & 4 deletions Sources/Windows/PluginTests/FFXIVOceanFishingHelperTests .cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ namespace {
}
};

std::unordered_set<uint32_t> zeroId = { 0 };
std::unordered_set<uint32_t> emptyId = { };

INSTANTIATE_TEST_CASE_P(
NoRouteTests,
FFXIVOceanFishingHelperNoRouteFixture,
Expand All @@ -141,7 +138,8 @@ namespace {
::testing::Values(0), // window time
::testing::Values(0, 1), // start time
::testing::Values( // routes
zeroId, emptyId
std::unordered_set<uint32_t>({ 0 }), // no route should have index 0
std::unordered_set<uint32_t>({ }) // empty routes shouldn't crash protram
),
::testing::Values("Indigo Route", "Ruby Route", "Invalid Name"), // routeName
::testing::Values(0, 1, 2) // skips
Expand Down

0 comments on commit 35f2f55

Please sign in to comment.