Skip to content

Commit

Permalink
add MenuOption to change the menu options/settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jw098 committed Sep 1, 2024
1 parent 2f17b07 commit 03a4f23
Show file tree
Hide file tree
Showing 8 changed files with 653 additions and 0 deletions.
12 changes: 12 additions & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1348,8 +1348,12 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/Inference/PokemonSV_ESPEmotionDetector.h
Source/PokemonSV/Inference/PokemonSV_MainMenuDetector.cpp
Source/PokemonSV/Inference/PokemonSV_MainMenuDetector.h
Source/PokemonSV/Inference/PokemonSV_MenuOptionReader.cpp
Source/PokemonSV/Inference/PokemonSV_MenuOptionReader.h
Source/PokemonSV/Inference/PokemonSV_MoneyReader.cpp
Source/PokemonSV/Inference/PokemonSV_MoneyReader.h
# Source/PokemonSV/Inference/PokemonSV_PokemonMovesReader.cpp
# Source/PokemonSV/Inference/PokemonSV_PokemonMovesReader.h
Source/PokemonSV/Inference/PokemonSV_PokePortalDetector.cpp
Source/PokemonSV/Inference/PokemonSV_PokePortalDetector.h
Source/PokemonSV/Inference/PokemonSV_PokemonSummaryReader.cpp
Expand All @@ -1360,6 +1364,8 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/Inference/PokemonSV_SweatBubbleDetector.h
Source/PokemonSV/Inference/PokemonSV_TournamentPrizeNameReader.cpp
Source/PokemonSV/Inference/PokemonSV_TournamentPrizeNameReader.h
# Source/PokemonSV/Inference/PokemonSV_TutorialDetector.cpp
# Source/PokemonSV/Inference/PokemonSV_TutorialDetector.h
Source/PokemonSV/Inference/PokemonSV_WhiteButtonDetector.cpp
Source/PokemonSV/Inference/PokemonSV_WhiteButtonDetector.h
Source/PokemonSV/Inference/PokemonSV_ZeroGateWarpPromptDetector.cpp
Expand Down Expand Up @@ -1418,6 +1424,12 @@ file(GLOB MAIN_SOURCES
Source/PokemonSV/PokemonSV_Panels.h
Source/PokemonSV/PokemonSV_Settings.cpp
Source/PokemonSV/PokemonSV_Settings.h
# Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp
# Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOptionDatabase.cpp
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOptionDatabase.h
Source/PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.cpp
Source/PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.h
Source/PokemonSV/Programs/Battles/PokemonSV_Battles.cpp
Expand Down
12 changes: 12 additions & 0 deletions SerialPrograms/SerialPrograms.pro
Original file line number Diff line number Diff line change
Expand Up @@ -674,12 +674,15 @@ SOURCES += \
Source/PokemonSV/Inference/PokemonSV_ClothingTopDetector.cpp \
Source/PokemonSV/Inference/PokemonSV_ESPEmotionDetector.cpp \
Source/PokemonSV/Inference/PokemonSV_MainMenuDetector.cpp \
Source/PokemonSV/Inference/PokemonSV_MenuOptionReader.cpp \
Source/PokemonSV/Inference/PokemonSV_MoneyReader.cpp \
#Source/PokemonSV/Inference/PokemonSV_PokemonMovesReader.cpp \
Source/PokemonSV/Inference/PokemonSV_PokePortalDetector.cpp \
Source/PokemonSV/Inference/PokemonSV_PokemonSummaryReader.cpp \
Source/PokemonSV/Inference/PokemonSV_StatHexagonReader.cpp \
Source/PokemonSV/Inference/PokemonSV_SweatBubbleDetector.cpp \
Source/PokemonSV/Inference/PokemonSV_TournamentPrizeNameReader.cpp \
#Source/PokemonSV/Inference/PokemonSV_TutorialDetector.cpp \
Source/PokemonSV/Inference/PokemonSV_WhiteButtonDetector.cpp \
Source/PokemonSV/Inference/PokemonSV_ZeroGateWarpPromptDetector.cpp \
Source/PokemonSV/Inference/Tera/PokemonSV_TeraCardDetector.cpp \
Expand Down Expand Up @@ -708,6 +711,9 @@ SOURCES += \
Source/PokemonSV/Options/PokemonSV_TournamentPrizeTable.cpp \
Source/PokemonSV/PokemonSV_Panels.cpp \
Source/PokemonSV/PokemonSV_Settings.cpp \
#Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp \
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOptionDatabase.cpp \
Source/PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.cpp \
Source/PokemonSV/Programs/Battles/PokemonSV_Battles.cpp \
Source/PokemonSV/Programs/Battles/PokemonSV_SinglesBattler.cpp \
Expand Down Expand Up @@ -1750,12 +1756,15 @@ HEADERS += \
Source/PokemonSV/Inference/PokemonSV_ClothingTopDetector.h \
Source/PokemonSV/Inference/PokemonSV_ESPEmotionDetector.h \
Source/PokemonSV/Inference/PokemonSV_MainMenuDetector.h \
Source/PokemonSV/Inference/PokemonSV_MenuOptionReader.h \
Source/PokemonSV/Inference/PokemonSV_MoneyReader.h \
#Source/PokemonSV/Inference/PokemonSV_PokemonMovesReader.h \
Source/PokemonSV/Inference/PokemonSV_PokePortalDetector.h \
Source/PokemonSV/Inference/PokemonSV_PokemonSummaryReader.h \
Source/PokemonSV/Inference/PokemonSV_StatHexagonReader.h \
Source/PokemonSV/Inference/PokemonSV_SweatBubbleDetector.h \
Source/PokemonSV/Inference/PokemonSV_TournamentPrizeNameReader.h \
#Source/PokemonSV/Inference/PokemonSV_TutorialDetector.h \
Source/PokemonSV/Inference/PokemonSV_WhiteButtonDetector.h \
Source/PokemonSV/Inference/PokemonSV_ZeroGateWarpPromptDetector.h \
Source/PokemonSV/Inference/Tera/PokemonSV_TeraCardDetector.h \
Expand Down Expand Up @@ -1786,6 +1795,9 @@ HEADERS += \
Source/PokemonSV/Options/PokemonSV_TournamentPrizeTable.h \
Source/PokemonSV/PokemonSV_Panels.h \
Source/PokemonSV/PokemonSV_Settings.h \
#Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h \
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOptionDatabase.h \
Source/PokemonSV/Programs/Battles/PokemonSV_BasicCatcher.h \
Source/PokemonSV/Programs/Battles/PokemonSV_Battles.h \
Source/PokemonSV/Programs/Battles/PokemonSV_SinglesBattler.h \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* Menu Option Reader
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#include <algorithm>
#include "Common/Cpp/Containers/FixedLimitVector.tpp"
#include "Common/Cpp/Concurrency/AsyncDispatcher.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "CommonFramework/Exceptions/OperationFailedException.h"
#include "CommonFramework/VideoPipeline/VideoFeed.h"
#include "CommonFramework/Tools/ConsoleHandle.h"
#include "PokemonSV_MenuOptionReader.h"

#include "Common/Cpp/PrettyPrint.h"
#include <iostream>
using std::cout;
using std::endl;

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonSV{



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

MenuOptionReader::MenuOptionReader()
: SmallDictionaryMatcher("PokemonSV/MenuOptionsOCR.json")
{}

OCR::StringMatchResult MenuOptionReader::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,49 @@
/* Menu Option Reader
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#ifndef PokemonAutomation_PokemonSV_MenuOptionReader_H
#define PokemonAutomation_PokemonSV_MenuOptionReader_H

#include <map>
#include <array>
#include "Common/Cpp/Containers/FixedLimitVector.h"
#include "CommonFramework/Language.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "CommonFramework/OCR/OCR_SmallDictionaryMatcher.h"
#include "PokemonSV/Inference/Dialogs/PokemonSV_GradientArrowDetector.h"
#include "PokemonSV/Programs/AutoStory/PokemonSV_MenuOptionDatabase.h"

namespace PokemonAutomation{
class AsyncDispatcher;
class ConsoleHandle;
class BotBaseContext;
namespace NintendoSwitch{
namespace PokemonSV{

class MenuOptionReader : public OCR::SmallDictionaryMatcher{
static constexpr double MAX_LOG10P = -1.30;
static constexpr double MAX_LOG10P_SPREAD = 0.50;

public:
MenuOptionReader();

static MenuOptionReader& 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
Loading

0 comments on commit 03a4f23

Please sign in to comment.