Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* Hyperspace Reward Name Reader
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "CommonTools/OCR/OCR_RawOCR.h"
#include "PokemonLZA_HyperspaceRewardNameReader.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonLZA{

HyperspaceRewardNameReader& HyperspaceRewardNameReader::instance(){
static HyperspaceRewardNameReader reader;
return reader;
}


HyperspaceRewardNameReader::HyperspaceRewardNameReader()
: SmallDictionaryMatcher("PokemonLZA/HyperBattle/HyperspaceRewardNameOCR.json")
{}

OCR::StringMatchResult HyperspaceRewardNameReader::read_substring(
Logger& logger,
Language language,
const ImageViewRGB32& image,
const std::vector<OCR::TextColorRange>& text_color_ranges,
double min_text_ratio, double max_text_ratio
) const{
return match_substring_from_image_multifiltered(
&logger, language, image, text_color_ranges,
MAX_LOG10P, MAX_LOG10P_SPREAD, min_text_ratio, max_text_ratio
);
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Hyperspace Reward Name Reader
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_PokemonLZA_HyperspaceRewardNameReader_H
#define PokemonAutomation_PokemonLZA_HyperspaceRewardNameReader_H

#include "CommonTools/OCR/OCR_SmallDictionaryMatcher.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonLZA{

class HyperspaceRewardNameReader : public OCR::SmallDictionaryMatcher{
public:
static constexpr double MAX_LOG10P = -1.40;
static constexpr double MAX_LOG10P_SPREAD = 0.50;

public:
HyperspaceRewardNameReader();

static HyperspaceRewardNameReader& instance();

OCR::StringMatchResult read_substring(
Logger& logger,
Language language,
const ImageViewRGB32& image,
const std::vector<OCR::TextColorRange>& text_color_ranges,
double min_text_ratio = 0.01, double max_text_ratio = 0.50
) const;

};
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Hyperspace Reward Option
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "CommonFramework/Logging/Logger.h"
#include "PokemonLZA/Resources/PokemonLZA_HyperspaceRewardNames.h"
#include "PokemonLZA_HyperspaceRewardOption.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonLZA{

StringSelectDatabase make_hyperspace_reward_database(){
StringSelectDatabase ret;
for (const auto& slug : HYPERSPACE_REWARD_SLUGS()){
const HyperspaceRewardNames& data = get_hyperspace_reward_name(slug);
ret.add_entry(StringSelectEntry(slug, data.display_name()));
}
return ret;
}
const StringSelectDatabase& HYPERSPACE_REWARD_DATABASE(){
static StringSelectDatabase database = make_hyperspace_reward_database();
return database;
}


HyperspaceRewardCell::HyperspaceRewardCell(
const std::string& default_slug
)
: StringSelectCell(
HYPERSPACE_REWARD_DATABASE(),
LockMode::LOCK_WHILE_RUNNING,
default_slug
)
{}


}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* Hyperspace Reward Option
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_PokemonLZA_HyperspaceRewardOption_H
#define PokemonAutomation_PokemonLZA_HyperspaceRewardOption_H

#include "CommonTools/Options/StringSelectOption.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonLZA{

class HyperspaceRewardCell : public StringSelectCell{
public:
HyperspaceRewardCell(const std::string& default_slug);
};

}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* Hyperspace Reward Table
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "PokemonLZA/Resources/PokemonLZA_HyperspaceRewardNames.h"
#include "PokemonLZA_HyperspaceRewardTable.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonLZA{

HyperspaceRewardRow::HyperspaceRewardRow(EditableTableOption& parent_table)
: EditableTableRow(parent_table)
, item("bottle-cap")
{
PA_ADD_OPTION(item);
}
std::unique_ptr<EditableTableRow> HyperspaceRewardRow::clone() const{
std::unique_ptr<HyperspaceRewardRow> ret(new HyperspaceRewardRow(parent()));
ret->item.set_by_index(item.index());
return ret;
}

HyperspaceRewardTable::HyperspaceRewardTable(std::string label)
: EditableTableOption_t<HyperspaceRewardRow>(
std::move(label),
LockMode::LOCK_WHILE_RUNNING,
make_defaults()
)
{}

bool HyperspaceRewardTable::find_item(const std::string& item_slug) const{
std::vector<std::unique_ptr<HyperspaceRewardRow>> table = copy_snapshot();
for (const std::unique_ptr<HyperspaceRewardRow>& row : table){
if (row->item.slug() == item_slug){
return true;
}
}
return false;
}

std::vector<std::string> HyperspaceRewardTable::selected_items() const{
std::vector<std::unique_ptr<HyperspaceRewardRow>> table = copy_snapshot();
std::vector<std::string> slugs;
for (const std::unique_ptr<HyperspaceRewardRow>& row : table){
slugs.emplace_back(row->item.slug());
}
return slugs;
}


std::vector<std::string> HyperspaceRewardTable::make_header() const{
return std::vector<std::string>{
"Item",
};
}

std::vector<std::unique_ptr<EditableTableRow>> HyperspaceRewardTable::make_defaults(){
std::vector<std::unique_ptr<EditableTableRow>> ret;
ret.emplace_back(std::make_unique<HyperspaceRewardRow>(*this));
return ret;
}






}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Hyperspace Reward Table
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_PokemonLZA_HyperspaceRewardTable_H
#define PokemonAutomation_PokemonLZA_HyperspaceRewardTable_H

#include "Common/Cpp/Options/EditableTableOption.h"
#include "PokemonLZA_HyperspaceRewardOption.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonLZA{



class HyperspaceRewardRow : public EditableTableRow{
public:
HyperspaceRewardRow(EditableTableOption& parent_table);
virtual std::unique_ptr<EditableTableRow> clone() const override;

public:
HyperspaceRewardCell item;
};



class HyperspaceRewardTable : public EditableTableOption_t<HyperspaceRewardRow>{
public:
HyperspaceRewardTable(std::string label);


// Whether item_slug is among the selected items.
bool find_item(const std::string& item_slug) const;
std::vector<std::string> selected_items() const;

virtual std::vector<std::string> make_header() const override;

std::vector<std::unique_ptr<EditableTableRow>> make_defaults();
};





}
}
}
#endif
2 changes: 2 additions & 0 deletions SerialPrograms/Source/PokemonLZA/PokemonLZA_Panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "Programs/Farming/PokemonLZA_JacintheInfiniteFarmer.h"
#include "Programs/Farming/PokemonLZA_FriendshipFarmer.h"
#include "Programs/Farming/PokemonLZA_InPlaceCatcher.h"
#include "Programs/Farming/PokemonLZA_HyperspaceRewardReset.h"

// Shiny Hunting
#include "Programs/ShinyHunting/PokemonLZA_AutoFossil.h"
Expand Down Expand Up @@ -78,6 +79,7 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
ret.emplace_back(make_single_switch_program<FriendshipFarmer_Descriptor, FriendshipFarmer>());
ret.emplace_back(make_single_switch_program<InPlaceCatcher_Descriptor, InPlaceCatcher>());
if (IS_BETA_VERSION){
ret.emplace_back(make_single_switch_program<HyperspaceRewardReset_Descriptor, HyperspaceRewardReset>());
}

ret.emplace_back("---- Shiny Hunting ----");
Expand Down
Loading