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 @@ -195,6 +195,42 @@ int8_t ItemPrinterMaterialDetector::find_happiny_dust_row_index(

}


int16_t ItemPrinterMaterialDetector::find_highest_quantity_of_value_68(VideoStream& stream, ProControllerContext& context) const{
int16_t highest_quantity_of_value_68 = 0;
bool seen_material_value_68 = false;
for (size_t c = 0; c < 30; c++){
context.wait_for_all_requests();
VideoSnapshot snapshot = stream.video().snapshot();

std::vector<int8_t> value_68_row_indexes = find_material_value_row_index(stream, context, 68);
if (!value_68_row_indexes.empty()){
seen_material_value_68 = true;
}

for (int8_t row_index : value_68_row_indexes){
int16_t quantity = detect_material_quantity(stream, snapshot, context, row_index);
if (quantity > highest_quantity_of_value_68){
highest_quantity_of_value_68 = quantity;
}
}

// keep searching for highest quantity of value 68.
pbf_press_dpad(context, DPAD_RIGHT, 20, 30);
}

if (!seen_material_value_68){
OperationFailedException::fire(
ErrorReport::SEND_ERROR_REPORT,
"find_highest_quantity_of_value_68: Failed to find any material with value of 68, after multiple attempts.",
stream
);
}

return highest_quantity_of_value_68;

}

std::string ItemPrinterMaterialDetector::detect_material_name(
VideoStream& stream,
const ImageViewRGB32& screen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class ItemPrinterMaterialDetector{
VideoStream& stream, ProControllerContext& context
) const;

// find the quantity of all materials with a value of 68. return the highest quantity.
int16_t find_highest_quantity_of_value_68(VideoStream& stream, ProControllerContext& context) const;

std::vector<int8_t> find_material_value_row_index(
VideoStream& stream,
ProControllerContext& context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ ItemPrinterRNG::ItemPrinterRNG()
, MODE(
"<b>Item Printer mode:</b><br>",
{
{ItemPrinterMode::STANDARD_MODE, "standard", "Standard Mode: Manually select exactly what is being printed for each print job."},
{ItemPrinterMode::AUTO_MODE, "auto", "Auto Mode: Select your desired item and its quantity, and items will be automatically printed."},
{ItemPrinterMode::STANDARD_MODE, "standard", "Standard Mode: Manually select exactly what is being printed for each print job."},
},
LockMode::LOCK_WHILE_RUNNING,
ItemPrinterMode::STANDARD_MODE
ItemPrinterMode::AUTO_MODE
)
, DESIRED_ITEM_TABLE(
"<b>Item Table:</b><br>"
Expand Down Expand Up @@ -191,6 +191,15 @@ ItemPrinterRNG::ItemPrinterRNG()
LockMode::UNLOCK_WHILE_RUNNING,
true
)
, AVOID_STRING_OCR(
"<b>Avoid using OCR on strings:</b><br>"
"Only use this if you're having issues (particularly with Asian languages). "
"This will detect all materials with a value of 68%, and the highest quantity of this is assumed to be your Happiny Dust quantity. "
"i.e. This only detects numbers, therefore sidestepping the issue of poor OCR with Asian languages. "
"If you enable this, I recommend ensuring that your quantity of Happiny Dust is greater than the other materials with a value of 68% (Beldum Claw, Ditto Goo, Magby Hair).",
LockMode::UNLOCK_WHILE_RUNNING,
false
)
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600))
, NOTIFICATIONS({
&NOTIFICATION_STATUS_UPDATE,
Expand All @@ -214,6 +223,7 @@ ItemPrinterRNG::ItemPrinterRNG()
PA_ADD_OPTION(MATERIAL_FARMER_FIXED_NUM_JOBS);
PA_ADD_OPTION(MIN_HAPPINY_DUST);
PA_ADD_OPTION(MATERIAL_FARMER_OPTIONS);
PA_ADD_OPTION(AVOID_STRING_OCR);
if (PreloadSettings::instance().DEVELOPER_MODE){
PA_ADD_OPTION(ENABLE_SEED_CALC);
}
Expand Down Expand Up @@ -988,19 +998,25 @@ uint32_t ItemPrinterRNG::check_num_happiny_dust(
case 3:{
env.log("Detected material selection.");
ItemPrinterMaterialDetector detector(COLOR_RED, LANGUAGE);
if (AVOID_STRING_OCR){
uint32_t highest_quantity_of_value_68 = detector.find_highest_quantity_of_value_68(env.console, context);
return highest_quantity_of_value_68;

}else{
int8_t happiny_dust_row_num = detector.find_happiny_dust_row_index(
env.console, context
);

context.wait_for_all_requests();
VideoSnapshot snapshot = env.console.video().snapshot();
num_happiny_dust = detector.detect_material_quantity(
env.console, snapshot, context,
happiny_dust_row_num
);
pbf_mash_button(context, BUTTON_B, 100);
return num_happiny_dust;
}

int8_t happiny_dust_row_num = detector.find_happiny_dust_row_index(
env.console, context
);

context.wait_for_all_requests();
VideoSnapshot snapshot = env.console.video().snapshot();
num_happiny_dust = detector.detect_material_quantity(
env.console, snapshot, context,
happiny_dust_row_num
);
pbf_mash_button(context, BUTTON_B, 100);
return num_happiny_dust;
}
default:
stats.errors++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ class ItemPrinterRNG : public SingleSwitchProgramInstance, public ConfigOption::

BooleanCheckBoxOption ENABLE_SEED_CALC;

BooleanCheckBoxOption AVOID_STRING_OCR;

EventNotificationOption NOTIFICATION_STATUS_UPDATE;
EventNotificationsOption NOTIFICATIONS;
};
Expand Down