Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -224,13 +224,15 @@ bool BattleOutOfPpDetector::detect(const ImageViewRGB32& screen){
return num_red_pixels > threshold;
}

BattleLevelUpDetector::BattleLevelUpDetector(Color color, BattleLevelUpDialog dialog_type)
BattleLevelUpDetector::BattleLevelUpDetector(Color color, BattleLevelUpDialog dialog_type, Language language)
: dialog_type(dialog_type)
, jpn(language == Language::Japanese)
, m_border_top_box(0.619231, 0.374038, 0.362179, 0.001923) // gray (120, 115, 140)
, m_border_right_box(0.982692, 0.376923, 0.001923, 0.597115)
, m_dialog_top_box(0.626282, 0.393492, 0.341026, 0.006175) // white
, m_dialog_right_box(0.967949, 0.401923, 0.003846, 0.550962)
, m_plus_box(0.862663, 0.402852, 0.034267, 0.553560)
, m_plus_box_jpn(0.895663, 0.402852, 0.021267, 0.553560)
{}
void BattleLevelUpDetector::make_overlays(VideoOverlaySet& items) const{
const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX;
Expand All @@ -251,12 +253,23 @@ bool BattleLevelUpDetector::detect(const ImageViewRGB32& screen){
ImageViewRGB32 dialog_right_image = extract_box_reference(game_screen, m_dialog_right_box);

//Plus box is not solid white on the first screen, but is white on the second one
ImageViewRGB32 plus_image = extract_box_reference(game_screen, m_plus_box);
bool good_plus_image = (
dialog_type == BattleLevelUpDialog::either
|| (dialog_type == BattleLevelUpDialog::plus && !is_white(plus_image))
|| (dialog_type == BattleLevelUpDialog::stats && is_white(plus_image))
);
//For Japanese, this logic is flipped. The first screen will have no text in the 10s place,
//and the second screen always will
ImageViewRGB32 plus_image = extract_box_reference(game_screen, jpn ? m_plus_box_jpn : m_plus_box);
bool good_plus_image = false;
if (dialog_type == BattleLevelUpDialog::either){
good_plus_image = true;
}else if (jpn){
good_plus_image = (
(dialog_type == BattleLevelUpDialog::plus && is_white(plus_image)) ||
(dialog_type == BattleLevelUpDialog::stats && !is_white(plus_image))
);
}else{
good_plus_image = (
(dialog_type == BattleLevelUpDialog::plus && !is_white(plus_image)) ||
(dialog_type == BattleLevelUpDialog::stats && is_white(plus_image))
);
}

if (is_solid(border_top_image, { 0.320, 0.307, 0.373 }, 0.25, 20)
&& is_solid(border_right_image, { 0.320, 0.307, 0.373 }, 0.25, 20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Common/Cpp/Color.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "CommonFramework/Language.h"
#include "CommonTools/VisualDetector.h"
#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h"

Expand Down Expand Up @@ -148,23 +149,25 @@ enum class BattleLevelUpDialog{

class BattleLevelUpDetector : public StaticScreenDetector{
public:
BattleLevelUpDetector(Color color, BattleLevelUpDialog dialog_type);
BattleLevelUpDetector(Color color, BattleLevelUpDialog dialog_type, Language Language);

virtual void make_overlays(VideoOverlaySet& items) const override;
virtual bool detect(const ImageViewRGB32& screen) override;

private:
BattleLevelUpDialog dialog_type;
bool jpn;
ImageFloatBox m_border_top_box;
ImageFloatBox m_border_right_box;
ImageFloatBox m_dialog_top_box;
ImageFloatBox m_dialog_right_box;
ImageFloatBox m_plus_box;
ImageFloatBox m_plus_box_jpn;
};
class BattleLevelUpWatcher : public DetectorToFinder<BattleLevelUpDetector>{
public:
BattleLevelUpWatcher(Color color, BattleLevelUpDialog dialog_type)
: DetectorToFinder("BattleLevelUpWatcher", std::chrono::milliseconds(250), color, dialog_type)
BattleLevelUpWatcher(Color color, BattleLevelUpDialog dialog_type, Language language)
: DetectorToFinder("BattleLevelUpWatcher", std::chrono::milliseconds(250), color, dialog_type, language)
{}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ bool PartySelectionDetector::detect(const ImageViewRGB32& screen){
}


PartyLevelUpDetector::PartyLevelUpDetector(Color color, PartyLevelUpDialog dialog_type)
PartyLevelUpDetector::PartyLevelUpDetector(Color color, PartyLevelUpDialog dialog_type, Language language)
: dialog_type(dialog_type)
, jpn(language == Language::Japanese)
, m_border_top_box(0.619231, 0.023038, 0.362179, 0.001923) // gray (120, 115, 140)
, m_border_right_box(0.982692, 0.025923, 0.001923, 0.597115)
, m_dialog_top_box(0.626282, 0.042492, 0.341026, 0.006175) // white
, m_dialog_right_box(0.967949, 0.050923, 0.003846, 0.550962)
, m_plus_box(0.862663, 0.051852, 0.034267, 0.553560)
, m_plus_box_jpn(0.895663, 0.051852, 0.021267, 0.553560)
{}
void PartyLevelUpDetector::make_overlays(VideoOverlaySet& items) const{
const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX;
Expand All @@ -66,12 +68,23 @@ bool PartyLevelUpDetector::detect(const ImageViewRGB32& screen){
ImageViewRGB32 dialog_right_image = extract_box_reference(game_screen, m_dialog_right_box);

//Plus box is not solid white on the first screen, but is white on the second one
ImageViewRGB32 plus_image = extract_box_reference(game_screen, m_plus_box);
bool good_plus_image = (
dialog_type == PartyLevelUpDialog::either
|| (dialog_type == PartyLevelUpDialog::plus && !is_white(plus_image))
|| (dialog_type == PartyLevelUpDialog::stats && is_white(plus_image))
);
//For Japanese, this logic is flipped. The first screen will have no text in the 10s place,
//and the second screen always will
ImageViewRGB32 plus_image = extract_box_reference(game_screen, jpn ? m_plus_box_jpn : m_plus_box);
bool good_plus_image = false;
if (dialog_type == PartyLevelUpDialog::either){
good_plus_image = true;
}else if (jpn){
good_plus_image = (
(dialog_type == PartyLevelUpDialog::plus && is_white(plus_image)) ||
(dialog_type == PartyLevelUpDialog::stats && !is_white(plus_image))
);
}else{
good_plus_image = (
(dialog_type == PartyLevelUpDialog::plus && !is_white(plus_image)) ||
(dialog_type == PartyLevelUpDialog::stats && is_white(plus_image))
);
}

if (is_solid(border_top_image, { 0.320, 0.307, 0.373 }, 0.25, 20)
&& is_solid(border_right_image, { 0.320, 0.307, 0.373 }, 0.25, 20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Common/Cpp/Color.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "CommonFramework/Language.h"
#include "CommonTools/VisualDetector.h"
#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h"

Expand Down Expand Up @@ -49,23 +50,25 @@ enum class PartyLevelUpDialog{

class PartyLevelUpDetector : public StaticScreenDetector{
public:
PartyLevelUpDetector(Color color, PartyLevelUpDialog dialog_type);
PartyLevelUpDetector(Color color, PartyLevelUpDialog dialog_type, Language language);

virtual void make_overlays(VideoOverlaySet& items) const override;
virtual bool detect(const ImageViewRGB32& screen) override;

private:
PartyLevelUpDialog dialog_type;
bool jpn;
ImageFloatBox m_border_top_box;
ImageFloatBox m_border_right_box;
ImageFloatBox m_dialog_top_box;
ImageFloatBox m_dialog_right_box;
ImageFloatBox m_plus_box;
ImageFloatBox m_plus_box_jpn;
};
class PartyLevelUpWatcher : public DetectorToFinder<PartyLevelUpDetector>{
public:
PartyLevelUpWatcher(Color color, PartyLevelUpDialog dialog_type)
: DetectorToFinder("BattleLevelUpWatcher", std::chrono::milliseconds(250), color, dialog_type)
PartyLevelUpWatcher(Color color, PartyLevelUpDialog dialog_type, Language language)
: DetectorToFinder("PartyLevelUpWatcher", std::chrono::milliseconds(250), color, dialog_type, language)
{}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ namespace PokemonFRLG {

BattleLevelUpReader::BattleLevelUpReader(Color color)
: m_color(color)
, m_box_hp(0.904069, 0.402852, 0.068535, 0.079387)
, m_box_attack(0.904069, 0.496052, 0.068535, 0.079387)
, m_box_defense(0.904069, 0.589252, 0.068535, 0.079387)
, m_box_sp_attack(0.904069, 0.682452, 0.068535, 0.079387)
, m_box_sp_defense(0.904069, 0.775652, 0.068535, 0.079387)
, m_box_speed(0.904069, 0.868852, 0.068535, 0.0793879)
, m_box_hp(0.844069, 0.402852, 0.128535, 0.079387)
, m_box_attack(0.844069, 0.496052, 0.128535, 0.079387)
, m_box_defense(0.844069, 0.589252, 0.128535, 0.079387)
, m_box_sp_attack(0.844069, 0.682452, 0.128535, 0.079387)
, m_box_sp_defense(0.844069, 0.775652, 0.128535, 0.079387)
, m_box_speed(0.844069, 0.868852, 0.128535, 0.0793879)
{}

void BattleLevelUpReader::make_overlays(VideoOverlaySet &items) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ namespace PokemonFRLG {

PartyLevelUpReader::PartyLevelUpReader(Color color)
: m_color(color)
, m_box_hp(0.904069, 0.051852, 0.068535, 0.079387)
, m_box_attack(0.904069, 0.145052, 0.068535, 0.079387)
, m_box_defense(0.904069, 0.238252, 0.068535, 0.079387)
, m_box_sp_attack(0.904069, 0.331452, 0.068535, 0.079387)
, m_box_sp_defense(0.904069, 0.424652, 0.068535, 0.079387)
, m_box_speed(0.904069, 0.517852, 0.068535, 0.0793879)
, m_box_hp(0.844069, 0.051852, 0.128535, 0.079387)
, m_box_attack(0.844069, 0.145052, 0.128535, 0.079387)
, m_box_defense(0.844069, 0.238252, 0.128535, 0.079387)
, m_box_sp_attack(0.844069, 0.331452, 0.128535, 0.079387)
, m_box_sp_defense(0.844069, 0.424652, 0.128535, 0.079387)
, m_box_speed(0.844069, 0.517852, 0.128535, 0.0793879)
{}

void PartyLevelUpReader::make_overlays(VideoOverlaySet &items) const {
Expand Down
Loading